delete useless files
This commit is contained in:
parent
5d559eb831
commit
02cc91d2d9
@ -1,55 +0,0 @@
|
||||
CFLAGS_INC += -I$(TOP)/PLAT/driver/board/$(TARGET)/inc \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/eeprom \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/camera \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/camera/cameraDev \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/codec \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/codec/codecDev \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/lcd/lcdDev \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/lcd \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/tp/tpDev \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/tp \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/ntc \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/exstorage \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/keypad
|
||||
|
||||
ifeq ($(DRIVER_CODEC2601_ENABLE),y)
|
||||
CFLAGS += -DCODEC_SC2601_ENABLE
|
||||
endif
|
||||
|
||||
libdriver-$(DRIVER_PLATCFG_ENABLE) += PLAT/driver/board/$(TARGET)/src/plat_config.o
|
||||
libdriver-$(DRIVER_ECMAIN_ENABLE) += PLAT/driver/board/$(TARGET)/src/bsp.o
|
||||
libdriverprivate-$(DRIVER_ECMAIN_ENABLE) += PLAT/driver/board/$(TARGET)/src/ec_main.o
|
||||
libdriver-$(DRIVER_EEPROM_ENABLE) += PLAT/driver/board/$(TARGET)/src/eeprom/eepRom.o
|
||||
libdriver-$(DRIVER_CAMERA_ENABLE) += PLAT/driver/board/$(TARGET)/src/camera/cameraDrv.o \
|
||||
PLAT/driver/board/$(TARGET)/src/camera/cameraDev/gc032A.o \
|
||||
PLAT/driver/board/$(TARGET)/src/camera/cameraDev/gc6153.o
|
||||
|
||||
ifeq ($(DRIVER_CODEC_ENABLE), y)
|
||||
libdriver-$(DRIVER_CODEC8311_ENABLE) += PLAT/driver/board/$(TARGET)/src/codec/codecDev/es8311.o
|
||||
libdriver-$(DRIVER_CODEC8374_ENABLE) += PLAT/driver/board/$(TARGET)/src/codec/codecDev/es8374.o
|
||||
libdriver-$(DRIVER_CODEC2601_ENABLE) += PLAT/driver/board/$(TARGET)/src/codec/codecDev/sc2601.o
|
||||
libdriver-y +=PLAT/driver/board/$(TARGET)/src/codec/codecDrv.o
|
||||
endif
|
||||
|
||||
libdriver-$(DRIVER_KEYPAD_ENABLE) += PLAT/driver/board/$(TARGET)/src/keypad/keypad.o
|
||||
|
||||
libdriver-$(DRIVER_LCD_ENABLE) += PLAT/driver/board/$(TARGET)/src/lcd/lcdComm.o \
|
||||
PLAT/driver/board/$(TARGET)/src/lcd/disFormat.o \
|
||||
PLAT/driver/board/$(TARGET)/src/lcd/lcdDrv.o
|
||||
|
||||
ifeq ($(DRIVER_LCD_ENABLE), y)
|
||||
libdriver-$(DRIVER_LCD_ST7789_ENABLE) += PLAT/driver/board/$(TARGET)/src/lcd/lcdDev/lcdDev_7789.o
|
||||
libdriver-$(DRIVER_LCD_ST77903_ENABLE) += PLAT/driver/board/$(TARGET)/src/lcd/lcdDev/lcdDev_77903.o
|
||||
libdriver-$(DRIVER_LCD_AXS15231_ENABLE) += PLAT/driver/board/$(TARGET)/src/lcd/lcdDev/lcdDev_15231.o
|
||||
libdriver-$(DRIVER_LCD_CO5300_ENABLE) += PLAT/driver/board/$(TARGET)/src/lcd/lcdDev/lcdDev_5300.o
|
||||
endif
|
||||
|
||||
libdriver-$(DRIVER_TP_ENABLE) += PLAT/driver/board/$(TARGET)/src/tp/tpDrv.o \
|
||||
PLAT/driver/board/$(TARGET)/src/tp/tpComm.o
|
||||
|
||||
libdriver-$(DRIVER_EXSTORAGE_ENABLE) += PLAT/driver/board/$(TARGET)/src/exstorage/ex_flash.o \
|
||||
PLAT/driver/board/$(TARGET)/src/exstorage/ex_storage.o
|
||||
|
||||
ifeq ($(DRIVER_TP_ENABLE), y)
|
||||
libdriver-$(DRIVER_TP_FT6336_ENABLE) += PLAT/driver/board/$(TARGET)/src/tp/tpDev/ft6336.o
|
||||
endif
|
@ -1,104 +0,0 @@
|
||||
#ifndef BSP_H
|
||||
#define BSP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "version.h"
|
||||
#include "Driver_Common.h"
|
||||
#include "Driver_I2C.h"
|
||||
#include "Driver_SPI.h"
|
||||
#include "Driver_USART.h"
|
||||
#include "RTE_Device.h"
|
||||
#include "pad.h"
|
||||
#include "gpio.h"
|
||||
#include "ic.h"
|
||||
#include "dma.h"
|
||||
#include "clock.h"
|
||||
|
||||
#define STRING_EOL "\r\n"
|
||||
|
||||
#if (defined TYPE_EC718S)
|
||||
#define CHIP_TYPE "EC718S"
|
||||
#elif (defined TYPE_EC718H)
|
||||
#define CHIP_TYPE "EC718H"
|
||||
#elif (defined TYPE_EC718P)
|
||||
#define CHIP_TYPE "EC718P"
|
||||
#elif (defined TYPE_EC718U)
|
||||
#define CHIP_TYPE "EC718U"
|
||||
#elif (defined TYPE_EC718PM)
|
||||
#define CHIP_TYPE "EC718PM"
|
||||
#elif (defined TYPE_EC718UM)
|
||||
#define CHIP_TYPE "EC718UM"
|
||||
#elif (defined TYPE_EC718SM)
|
||||
#define CHIP_TYPE "EC718SM"
|
||||
#elif (defined TYPE_EC718HM)
|
||||
#define CHIP_TYPE "EC718HM"
|
||||
#elif (defined TYPE_EC716S)
|
||||
#define CHIP_TYPE "EC716S"
|
||||
#elif (defined TYPE_EC716E)
|
||||
#define CHIP_TYPE "EC716E"
|
||||
#endif
|
||||
|
||||
#define BOARD_NAME CHIP_TYPE"_EVK"
|
||||
|
||||
|
||||
#define SDK_VERSION CHIP_TYPE"_SW_V"SDK_MAJOR_VERSION"."SDK_MINOR_VERSION"."SDK_PATCH_VERSION
|
||||
#define EVB_VERSION CHIP_TYPE"_HW_V"EVB_MAJOR_VERSION"."EVB_MINOR_VERSION
|
||||
#define VERSION_INFO "-- SDK Version: "SDK_VERSION" -- "STRING_EOL"-- EVB Version: "EVB_VERSION" -- "STRING_EOL
|
||||
|
||||
#define BSP_HEADER STRING_EOL"-- Board: "BOARD_NAME " -- "STRING_EOL \
|
||||
VERSION_INFO \
|
||||
"-- Compiled: "__DATE__" "__TIME__" -- "STRING_EOL
|
||||
|
||||
#define ATI_VERSION_INFO STRING_EOL"-- Board: "BOARD_NAME " -- "STRING_EOL \
|
||||
"-- SDK Version: "SDK_VERSION" -- "STRING_EOL
|
||||
|
||||
#define SOFTVERSION "V"SDK_MAJOR_VERSION"."SDK_MINOR_VERSION"."SDK_PATCH_VERSION
|
||||
|
||||
|
||||
#define CREATE_SYMBOL(name, port) name##port
|
||||
|
||||
/** @brief UART port index
|
||||
* | UART port | Hardware Flow Control |
|
||||
* |-----------|-----------------------|
|
||||
* | UART0 | Y |
|
||||
* | UART1 | Y |
|
||||
* | UART2 | N |
|
||||
*/
|
||||
typedef enum usart_port
|
||||
{
|
||||
PORT_USART_0, /**< USART port 0. */
|
||||
PORT_USART_1, /**< USART port 1. */
|
||||
PORT_USART_2, /**< USART port 2. */
|
||||
PORT_USART_3, /**< USART port 3. */
|
||||
PORT_USART_MAX, /**< The total number of USART ports (invalid UART port number). */
|
||||
PORT_USART_INVALID /**< USART invalid. */
|
||||
} usart_port_t;
|
||||
|
||||
extern ARM_DRIVER_USART *UsartPrintHandle;
|
||||
extern ARM_DRIVER_USART *UsartUnilogHandle;
|
||||
extern ARM_DRIVER_USART *UsartAtCmdHandle;
|
||||
|
||||
/** @brief IRQ Callback functions
|
||||
*/
|
||||
typedef void (*IRQ_Callback_t)();
|
||||
|
||||
|
||||
uint8_t* getBuildInfo(void);
|
||||
uint8_t* getATIVersionInfo(void);
|
||||
uint8_t* getVersionInfo(void);
|
||||
uint32_t getUnilogUartPort(void);
|
||||
void getUnilogRamLogBuff(uint32_t *addr, uint32_t *len);
|
||||
void FlushUnilogOutput(void);
|
||||
void SetUnilogUart(usart_port_t port, uint32_t baudrate, bool startRecv);
|
||||
void BSP_CommonInit(void);
|
||||
void setOSState(uint8_t state);
|
||||
uint8_t * getDebugDVersion(void);
|
||||
void delay_us(uint32_t us);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BSP_H */
|
@ -1,9 +0,0 @@
|
||||
#ifndef GC032A_H
|
||||
#define GC032A_H
|
||||
|
||||
#define GC032A_I2C_ADDR 0x21
|
||||
|
||||
uint16_t gc032aGetRegCnt(char* regName);
|
||||
|
||||
#endif
|
||||
|
@ -1,9 +0,0 @@
|
||||
#ifndef GC6153_H
|
||||
#define GC6153_H
|
||||
|
||||
#define GC6153_I2C_ADDR 0x40
|
||||
|
||||
uint16_t gc6153GetRegCnt(char* regName);
|
||||
|
||||
#endif
|
||||
|
@ -1,184 +0,0 @@
|
||||
#ifndef __CAMERA_DRV_H__
|
||||
#define __CAMERA_DRV_H__
|
||||
|
||||
#include "cspi.h"
|
||||
#include "gc032A.h"
|
||||
#include "gc6153.h"
|
||||
|
||||
/**
|
||||
\addtogroup cam_interface_gr
|
||||
\{
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t regAddr; ///< Sensor I2C register address
|
||||
uint8_t regVal; ///< Sensor I2C register value
|
||||
}camI2cCfg_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CAM_LSB_MODE = 0, ///< Little endian
|
||||
CAM_MSB_MODE = 1, ///< Big endian
|
||||
}endianMode_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
WIRE_1 = 0, ///< 1 wire
|
||||
WIRE_2 = 1, ///< 2 wire
|
||||
}wireNum_e;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SEQ_0 = 0, ///< rxd[0] 6 4 2 0
|
||||
///< rxd[1] 7 5 3 1
|
||||
SEQ_1 = 1, ///< rxd[1] 6 4 2 0
|
||||
///< rxd[0] 7 5 3 1
|
||||
}rxSeq_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CSPI_0 = 0,
|
||||
CSPI_1 = 1,
|
||||
}cspiInstance_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CSPI_START = 1, ///< cspi enable
|
||||
CSPI_STOP = 0, ///< Cspi disable
|
||||
}cspiStartStop_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CSPI_INT_ENABLE = 1, ///< cspi interrupt enable
|
||||
CSPI_INT_DISABLE = 0, ///< Cspi interrupt disable
|
||||
}cspiIntEnable_e;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
endianMode_e endianMode; ///< Endian mode
|
||||
wireNum_e wireNum; ///< Wire numbers
|
||||
rxSeq_e rxSeq; ///< Bit sequence in 2 wire mode
|
||||
uint8_t cpol;
|
||||
uint8_t cpha;
|
||||
uint8_t ddrMode;
|
||||
uint8_t wordIdSeq;
|
||||
uint8_t yOnly;
|
||||
uint8_t rowScaleRatio;
|
||||
uint8_t colScaleRatio;
|
||||
uint8_t scaleBytes;
|
||||
uint8_t dummyAllowed;
|
||||
}camParamCfg_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t enableForCamera : 1; // 0: isn't work for camera now; 1: is working for camera now
|
||||
uint32_t enableForUsr : 1; // 0: isn't ready for usr; 1: is ready for usr
|
||||
uint32_t workingForUsr : 1; // 0: usr has used this buf; 1: usr is using this buf
|
||||
uint32_t camErrCnt : 3; // record camera err count
|
||||
uint32_t rsvd : 26;
|
||||
uint32_t timeStamp;
|
||||
uint8_t data[320*240*2]; // can be configured
|
||||
} CameraBuf_t;
|
||||
|
||||
typedef void (*camCbEvent_fn) (uint32_t event); ///< Camera callback event.
|
||||
typedef void (*camIrq_fn)(void); ///< Camera irq
|
||||
typedef void (*camErrCb)(uint32_t stats);
|
||||
|
||||
|
||||
/**
|
||||
\brief Init camera, include pinMux, and enable clock.
|
||||
\param[in] dataAddr Mem addr to store picture.
|
||||
\param[in] uspCb usp cb.
|
||||
\param[in] dmaCb dma cb.
|
||||
\return
|
||||
*/
|
||||
void camInit(void* dataAddr, cspiCbEvent_fn uspCb, void* dmaCb,camErrCb errCb);
|
||||
|
||||
/**
|
||||
\brief Receive the picture has been taken.
|
||||
\param[out] dataIn The buffer which is used to store the picture.
|
||||
\return
|
||||
*/
|
||||
void camRecv(uint8_t * dataIn);
|
||||
|
||||
/**
|
||||
\brief Init sensor's registers.
|
||||
\return
|
||||
*/
|
||||
void camRegCfg(void);
|
||||
|
||||
/**
|
||||
\brief Write some parameters into the sensor.
|
||||
\param[in] regInfo Sensor I2C addr and value.
|
||||
\return
|
||||
*/
|
||||
void camWriteReg(camI2cCfg_t* regInfo);
|
||||
|
||||
/**
|
||||
\brief Read from the sensor's I2C address.
|
||||
\param[in] regAddr Sensor's I2C register address.
|
||||
\return
|
||||
*/
|
||||
uint8_t camReadReg(uint8_t regAddr);
|
||||
|
||||
/**
|
||||
\brief Start or stop Camera controller.
|
||||
\param[in] startStop If true, start camera controller. If false, stop camera controller.
|
||||
\return
|
||||
*/
|
||||
void camStartStop(cspiStartStop_e startStop);
|
||||
|
||||
/**
|
||||
\brief Register irq for cspi.
|
||||
\param[in] instance cspi0 or cspi1.
|
||||
\param[in] irqCb irq cb.
|
||||
\return
|
||||
*/
|
||||
void camRegisterIRQ(cspiInstance_e instance, camIrq_fn irqCb);
|
||||
|
||||
/**
|
||||
\brief Get cspi status.
|
||||
\param[in] instance cspi0 or cspi1.
|
||||
\return
|
||||
*/
|
||||
uint32_t camGetCspiStats();
|
||||
|
||||
/**
|
||||
\brief Clear cspi interrupt status.
|
||||
\param[in] instance cspi0 or cspi1.
|
||||
\param[in] mask which bit needs to clear.
|
||||
\return
|
||||
*/
|
||||
void camClearIntStats(cspiInstance_e instance, uint32_t mask);
|
||||
|
||||
/**
|
||||
\brief Set memory addr which is used to store picture of camera.
|
||||
\param[in] dataAddr data addr.
|
||||
\return
|
||||
*/
|
||||
void camSetMemAddr(uint32_t dataAddr);
|
||||
|
||||
/**
|
||||
\brief Enable or disable interrupt of cspi.
|
||||
\param[in] intEnable interrupt enable or not.
|
||||
\return
|
||||
*/
|
||||
void cspiStartIntEnable(cspiIntEnable_e intEnable);
|
||||
void cspiEndIntEnable(cspiIntEnable_e endIntEnable);
|
||||
uint32_t camGetCspiInt(cspiInstance_e instance);
|
||||
void cspi2LspiEnable(uint8_t enable);
|
||||
void camRegisterErrStatsCb(camErrCb errCb);
|
||||
int camCheckErrStats();
|
||||
#if (ENABLE_CAMERA_LDO == 1)
|
||||
void camPowerOn(uint8_t ioInitVal);
|
||||
#endif
|
||||
void camGpioPulseCfg(uint8_t padAddr, uint8_t pinInstance, uint8_t pinNum);
|
||||
void camGpioPulse(uint8_t pinInstance, uint8_t pinNum, uint32_t pulseDurationUs, uint8_t initialState, bool needLoop);
|
||||
void camRegisterSlp1Cb(cspiSlp1Cb_fn cb);
|
||||
|
||||
/** \} */
|
||||
|
||||
#endif
|
@ -1,280 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: es8311.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: Rev1.0 2020-02-24
|
||||
*
|
||||
* Notes: es8311 interface
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _CODEC_ES8311_H
|
||||
#define _CODEC_ES8311_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "codecDrv.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
// ES8311_REGISTER NAME_REG_REGISTER ADDRESS
|
||||
#define ES8311_RESET_REG00 0x00 /*reset digital,csm,clock manager etc.*/
|
||||
|
||||
// Clock Scheme Register definition
|
||||
#define ES8311_CLK_MANAGER_REG01 0x01 // select clk src for mclk, enable clock for codec
|
||||
#define ES8311_CLK_MANAGER_REG02 0x02 // clk divider and clk multiplier
|
||||
#define ES8311_CLK_MANAGER_REG03 0x03 // adc fsmode and osr
|
||||
#define ES8311_CLK_MANAGER_REG04 0x04 // dac osr
|
||||
#define ES8311_CLK_MANAGER_REG05 0x05 // clk divier for adc and dac
|
||||
#define ES8311_CLK_MANAGER_REG06 0x06 // bclk inverter and divider
|
||||
#define ES8311_CLK_MANAGER_REG07 0x07 // tri-state, lrck divider
|
||||
#define ES8311_CLK_MANAGER_REG08 0x08 // lrck divider
|
||||
|
||||
// SDP
|
||||
#define ES8311_SDPIN_REG09 0x09 // dac serial digital port */
|
||||
#define ES8311_SDPOUT_REG0A 0x0A // adc serial digital port */
|
||||
|
||||
// SYSTEM
|
||||
#define ES8311_SYSTEM_REG0B 0x0B // system
|
||||
#define ES8311_SYSTEM_REG0C 0x0C // system
|
||||
#define ES8311_SYSTEM_REG0D 0x0D // system, power up/down
|
||||
#define ES8311_SYSTEM_REG0E 0x0E // system, power up/down
|
||||
#define ES8311_SYSTEM_REG0F 0x0F // system, low power
|
||||
#define ES8311_SYSTEM_REG10 0x10 // system
|
||||
#define ES8311_SYSTEM_REG11 0x11 // system
|
||||
#define ES8311_SYSTEM_REG12 0x12 // system, Enable DAC
|
||||
#define ES8311_SYSTEM_REG13 0x13 // system
|
||||
#define ES8311_SYSTEM_REG14 0x14 // system, mic gain, select DMIC, select analog pga gain
|
||||
|
||||
// ADC
|
||||
#define ES8311_ADC_REG15 0x15 // ADC, adc ramp rate, dmic sense
|
||||
#define ES8311_ADC_REG16 0x16 // ADC
|
||||
#define ES8311_ADC_REG17 0x17 // ADC, mic volume
|
||||
#define ES8311_ADC_REG18 0x18 // ADC, alc enable and winsize
|
||||
#define ES8311_ADC_REG19 0x19 // ADC, alc maxlevel
|
||||
#define ES8311_ADC_REG1A 0x1A // ADC, alc automute
|
||||
#define ES8311_ADC_REG1B 0x1B // ADC, alc automute, adc hpf s1
|
||||
#define ES8311_ADC_REG1C 0x1C // ADC, equalizer, hpf s2
|
||||
#define ES8311_ADC_REG1D 0x1D // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG1E 0x1E // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG1F 0x1F // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG20 0x20 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG21 0x21 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG22 0x22 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG23 0x23 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG24 0x24 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG25 0x25 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG26 0x26 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG27 0x27 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG28 0x28 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG29 0x29 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG2A 0x2A // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG2B 0x2B // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG2C 0x2C // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG2D 0x2D // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG2E 0x2E // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG2F 0x2F // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG30 0x30 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
|
||||
// DAC
|
||||
#define ES8311_DAC_REG31 0x31 // DAC, mute
|
||||
#define ES8311_DAC_REG32 0x32 // DAC, volume
|
||||
#define ES8311_DAC_REG33 0x33 // DAC, offset
|
||||
#define ES8311_DAC_REG34 0x34 // DAC, drc enable, drc winsize
|
||||
#define ES8311_DAC_REG35 0x35 // DAC, drc maxlevel, minilevel
|
||||
#define ES8311_DAC_REG37 0x37 // DAC, ramprate
|
||||
|
||||
// GPIO
|
||||
#define ES8311_GPIO_REG44 0x44 // GPIO, dac2adc for test
|
||||
#define ES8311_GP_REG45 0x45 // GP CONTROL
|
||||
|
||||
// CHIP
|
||||
#define ES8311_CHD1_REGFD 0xFD // CHIP ID1
|
||||
#define ES8311_CHD2_REGFE 0xFE // CHIP ID2
|
||||
#define ES8311_CHVER_REGFF 0xFF // VERSION
|
||||
#define ES8311_CHD1_REGFD 0xFD // CHIP ID1
|
||||
|
||||
#define ES8311_MAX_REGISTER 0xFF
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern HalCodecFuncList_t es8311DefaultHandle;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\brief Enables or disables PA
|
||||
\param[in] enable true/false
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es8311EnablePA(bool enable);
|
||||
|
||||
/**
|
||||
\brief Initialize ES8311 codec chip
|
||||
\param[in] codec_cfg configuration of ES8311
|
||||
\return -CODEC_EOK -CODEC_INIT_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311Init(HalCodecCfg_t *codecCfg);
|
||||
|
||||
/**
|
||||
\brief Deinitialize ES8311 codec chip
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es8311DeInit(void);
|
||||
|
||||
/**
|
||||
\brief start/stop ES8311 codec chip
|
||||
\param[in] mode codec mode
|
||||
\param[in] ctrlState start or stop decode or encode progress
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311StartStop(HalCodecMode_e mode, HalCodecCtrlState_e ctrlState);
|
||||
|
||||
/**
|
||||
\brief Configure ES8311 codec mode and I2S interface
|
||||
\param[in] mode codec mode
|
||||
\param[in] iface I2S config
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311Config(HalCodecMode_e mode, HalCodecIface_t *iface);
|
||||
|
||||
/**
|
||||
\brief Configure ES8311 DAC mute or not. Basically you can use this function to mute the output or unmute
|
||||
\param[in] enable enable(1) or disable(0)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311SetMute(HalCodecCfg_t* codecHalCfg, bool enable);
|
||||
|
||||
/**
|
||||
\brief Set voice volume
|
||||
\param[in] volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311SetVolume(HalCodecCfg_t* codecHalCfg, int volume);
|
||||
|
||||
/**
|
||||
\brief Get voice volume
|
||||
\param[out] *volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311GetVolume(HalCodecCfg_t* codecHalCfg, int *volume);
|
||||
|
||||
/**
|
||||
\brief Configure ES8311 I2S format
|
||||
\param[in] mod: set ADC or DAC or both
|
||||
\param[in] cfg: ES8388 I2S format
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311ConfigFmt(HalCodecIfaceFormat_e fmt);
|
||||
|
||||
/**
|
||||
\brief Configure ES8311 data sample bits
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\param[in] bits: bit number of per sample
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311SetBitsPerSample(HalCodecIfaceBits_e bits);
|
||||
|
||||
/**
|
||||
\brief Start ES8311 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311Start(HalCodecMode_e mode);
|
||||
|
||||
/**
|
||||
\brief Stop ES8311 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311Stop(HalCodecMode_e mode);
|
||||
|
||||
/**
|
||||
\brief Get ES8311 DAC mute status
|
||||
\param[out] mute get mute
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311GetVoiceMute(int *mute);
|
||||
|
||||
/**
|
||||
\brief Set ES8311 mic gain and volume
|
||||
\param[in] micGain db of mic gain, varies from 0~10, default is 8
|
||||
\param[in] micVolume micVolume, varies from 0~100, default is 75
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311SetMicVolume(HalCodecCfg_t* codecHalCfg, uint8_t micGain, int micVolume);
|
||||
|
||||
HalCodecSts_e es8311GetMicVolume(HalCodecCfg_t* codecHalCfg, uint8_t *micGain, int *micVolume);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Print all ES8311 registers
|
||||
*
|
||||
* @return
|
||||
* - void
|
||||
*/
|
||||
/**
|
||||
\brief Print all ES8311 registers
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es8311ReadAll();
|
||||
|
||||
/**
|
||||
\brief get es8311 default config
|
||||
\param[in] NULL
|
||||
\return HalCodecCfg_t codecCfg
|
||||
\note
|
||||
*/
|
||||
HalCodecCfg_t es8311GetDefaultCfg();
|
||||
|
||||
HalCodecSts_e es8311Resume(HalCodecMode_e mode);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CODEC_ES8311_H */
|
||||
|
@ -1,262 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: es8374.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: Rev1.0 2020-02-24
|
||||
*
|
||||
* Notes: es8374 interface
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _CODEC_ES8374_H
|
||||
#define _CODEC_ES8374_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "codecDrv.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern HalCodecFuncList_t es8374DefaultHandle;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
// ES8374_REG_ISTER NAME_REG_REGISTER ADDRESS
|
||||
#define ES8374_REG_00 0x00
|
||||
#define ES8374_REG_01 0x01
|
||||
#define ES8374_REG_02 0x02
|
||||
#define ES8374_REG_03 0x03
|
||||
#define ES8374_REG_04 0x04
|
||||
#define ES8374_REG_05 0x05
|
||||
#define ES8374_REG_06 0x06
|
||||
#define ES8374_REG_07 0x07
|
||||
#define ES8374_REG_08 0x08
|
||||
#define ES8374_REG_09 0x09
|
||||
#define ES8374_REG_0A 0x0A
|
||||
#define ES8374_REG_0B 0x0B
|
||||
#define ES8374_REG_0C 0x0C
|
||||
#define ES8374_REG_0D 0x0D
|
||||
#define ES8374_REG_0E 0x0E
|
||||
#define ES8374_REG_0F 0x0F
|
||||
#define ES8374_REG_10 0x10
|
||||
#define ES8374_REG_11 0x11
|
||||
#define ES8374_REG_12 0x12
|
||||
#define ES8374_REG_13 0x13
|
||||
#define ES8374_REG_14 0x14
|
||||
#define ES8374_REG_15 0x15
|
||||
#define ES8374_REG_16 0x16
|
||||
#define ES8374_REG_17 0x17
|
||||
#define ES8374_REG_18 0x18
|
||||
#define ES8374_REG_19 0x19
|
||||
#define ES8374_REG_1A 0x1A
|
||||
#define ES8374_REG_1B 0x1B
|
||||
#define ES8374_REG_1C 0x1C
|
||||
#define ES8374_REG_1D 0x1D
|
||||
#define ES8374_REG_1E 0x1E
|
||||
#define ES8374_REG_1F 0x1F
|
||||
#define ES8374_REG_20 0x20
|
||||
#define ES8374_REG_21 0x21
|
||||
#define ES8374_REG_22 0x22
|
||||
#define ES8374_REG_23 0x23
|
||||
#define ES8374_REG_24 0x24
|
||||
#define ES8374_REG_25 0x25
|
||||
#define ES8374_REG_26 0x26
|
||||
#define ES8374_REG_27 0x27
|
||||
#define ES8374_REG_28 0x28
|
||||
#define ES8374_REG_29 0x29
|
||||
#define ES8374_REG_2A 0x2A
|
||||
#define ES8374_REG_2B 0x2B
|
||||
#define ES8374_REG_2C 0x2C
|
||||
#define ES8374_REG_2D 0x2D
|
||||
#define ES8374_REG_2E 0x2E
|
||||
#define ES8374_REG_2F 0x2F
|
||||
#define ES8374_REG_30 0x30
|
||||
#define ES8374_REG_31 0x31
|
||||
#define ES8374_REG_32 0x32
|
||||
#define ES8374_REG_33 0x33
|
||||
#define ES8374_REG_34 0x34
|
||||
#define ES8374_REG_35 0x35
|
||||
#define ES8374_REG_36 0x36
|
||||
#define ES8374_REG_37 0x37
|
||||
#define ES8374_REG_38 0x38
|
||||
#define ES8374_REG_6D 0x6D
|
||||
#define ES8374_REG_6F 0x6F
|
||||
#define ES8374_REG_72 0x72
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern HalCodecFuncList_t es8374DefaultHandle;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\brief Enables or disables PA
|
||||
\param[in] enable true/false
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es8374EnablePA(bool enable);
|
||||
|
||||
/**
|
||||
\brief Initialize ES8374 codec chip
|
||||
\param[in] codec_cfg configuration of ES8374
|
||||
\return -CODEC_EOK -CODEC_INIT_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374Init(HalCodecCfg_t *codecCfg);
|
||||
|
||||
/**
|
||||
\brief Deinitialize ES8374 codec chip
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es8374DeInit(void);
|
||||
|
||||
/**
|
||||
\brief start/stop ES8374 codec chip
|
||||
\param[in] mode codec mode
|
||||
\param[in] ctrlState start or stop decode or encode progress
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374StartStop(HalCodecMode_e mode, HalCodecCtrlState_e ctrlState);
|
||||
|
||||
/**
|
||||
\brief Configure ES8374 codec mode and I2S interface
|
||||
\param[in] mode codec mode
|
||||
\param[in] iface I2S config
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374Config(HalCodecMode_e mode, HalCodecIface_t *iface);
|
||||
|
||||
/**
|
||||
\brief Configure ES8374 DAC mute or not. Basically you can use this function to mute the output or unmute
|
||||
\param[in] enable enable(1) or disable(0)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374SetMute(HalCodecCfg_t* codecHalCfg, bool enable);
|
||||
|
||||
/**
|
||||
\brief Set voice volume
|
||||
\param[in] volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374SetVolume(HalCodecCfg_t* codecHalCfg, int volume);
|
||||
|
||||
/**
|
||||
\brief Get voice volume
|
||||
\param[out] *volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374GetVolume(HalCodecCfg_t* codecHalCfg, int *volume);
|
||||
|
||||
/**
|
||||
\brief Configure ES8374 I2S format
|
||||
\param[in] mod: set ADC or DAC or both
|
||||
\param[in] cfg: ES8388 I2S format
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374ConfigFmt(HalCodecIfaceFormat_e fmt);
|
||||
|
||||
/**
|
||||
\brief Configure ES8374 data sample bits
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\param[in] bits: bit number of per sample
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374SetBitsPerSample(HalCodecIfaceBits_e bits);
|
||||
|
||||
/**
|
||||
\brief Start ES8374 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374Start(HalCodecModule_e mode);
|
||||
|
||||
/**
|
||||
\brief Stop ES8374 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374Stop(HalCodecModule_e mode);
|
||||
|
||||
/**
|
||||
\brief Get ES8374 DAC mute status
|
||||
\param[out] mute get mute
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374GetVoiceMute(uint8_t *mute);
|
||||
|
||||
/**
|
||||
\brief Set ES8374 mic gain and volume
|
||||
\param[in] not used
|
||||
\param[in] micVolume micVolume, varies from 0~100, default is 75
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374SetMicVolume(HalCodecCfg_t* codecHalCfg, uint8_t micGain, int micVolume);
|
||||
|
||||
/**
|
||||
* @brief Print all ES8374 registers
|
||||
*
|
||||
* @return
|
||||
* - void
|
||||
*/
|
||||
/**
|
||||
\brief Print all ES8374 registers
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es8374ReadAll();
|
||||
|
||||
/**
|
||||
\brief get es8374 default config
|
||||
\param[in] NULL
|
||||
\return HalCodecCfg_t codecCfg
|
||||
\note
|
||||
*/
|
||||
HalCodecCfg_t es8374GetDefaultCfg();
|
||||
|
||||
HalCodecSts_e es8374Resume(HalCodecMode_e mode);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CODEC_ES8374_H */
|
||||
|
@ -1,425 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: hal_codec.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: Rev1.0 2020-02-24
|
||||
*
|
||||
* Notes: codec interface
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _CODEC_DRV_H
|
||||
#define _CODEC_DRV_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "ec7xx.h"
|
||||
#include "string.h"
|
||||
#include "Driver_Common.h"
|
||||
#include "bsp.h"
|
||||
#include "hal_i2c.h"
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
#include "osasys.h"
|
||||
#include "cmsis_os2.h"
|
||||
#endif
|
||||
#include "slpman.h"
|
||||
#include "exception_process.h"
|
||||
#ifndef CHIP_EC618
|
||||
#include "mw_nvm_audio.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define HAL_CODEC_VOL_SPEAKER_DEFAULT 65
|
||||
#define HAL_CODEC_MIC_GAIN_DEFAULT 8
|
||||
#define HAL_CODEC_VOL_MIC_DEFAULT 191
|
||||
#define HAL_CODEC_VOL_SPEAKER_GAIN_DEFAULT 8
|
||||
|
||||
// Codec I2C address
|
||||
#define ES8388_IICADDR 0x11
|
||||
#define ES8311_IICADDR 0x18
|
||||
#define ES8374_IICADDR 0x10
|
||||
#define SC2601_IICADDR 0x18
|
||||
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
#define HAL_CODEC_CHECK_NULL(a, format, b, ...) \
|
||||
if ((a) == 0) { \
|
||||
return b;\
|
||||
}
|
||||
|
||||
#define DEBUG_PRINT(moduleId, subId, debugLevel, format, ...) ECPLAT_PRINTF(moduleId, subId, debugLevel, format, ##__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_PRINT(moduleId, subId, debugLevel, format, ...)
|
||||
#define HAL_CODEC_CHECK_NULL(a, format, b, ...)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/** \brief CODEC_PA location */
|
||||
#define CODEC_PA_GPIO_INSTANCE (0)
|
||||
#define CODEC_PA_GPIO_PIN (2)
|
||||
#define CODEC_PA_PAD_INDEX (17)
|
||||
#define CODEC_PA_PAD_ALT_FUNC (PAD_MUX_ALT0)
|
||||
|
||||
#define DIRECTION_TX (0)
|
||||
#define DIRECTION_RX (1)
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
bool isDmic;
|
||||
bool isExPa;
|
||||
int16_t exPaGain;
|
||||
int16_t txDigGain;
|
||||
int16_t txAnaGain;
|
||||
|
||||
int16_t rxDigGain0;
|
||||
int16_t rxAnaGain0;
|
||||
int16_t rxDigGain50;
|
||||
int16_t rxAnaGain50;
|
||||
int16_t rxDigGain100;
|
||||
int16_t rxAnaGain100;
|
||||
}HalCodecTlvDefault_t;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* usr set codec volumn parameter
|
||||
*/
|
||||
typedef struct _USR_SET_CODEC_VOLUMN
|
||||
{
|
||||
UINT16 rxDigUsrSet; // bit15: flag; bit14~bit8: 1level; bit7~bit0: 2level
|
||||
UINT16 rxAnaUsrSet; // bit15: flag; bit14~bit8: 1level; bit7~bit0: 2level
|
||||
}MWNvmCfgUsrSetCodecVolumn;
|
||||
|
||||
/*
|
||||
* indicate usr whether set volumn in nv
|
||||
*/
|
||||
typedef struct _VOLUMN_SET_FLAG
|
||||
{
|
||||
UINT8 rxDigUsrSetFlag;
|
||||
UINT8 rxAnaUsrSetFlag;
|
||||
UINT8 txDigGainFlag;
|
||||
UINT8 txAnaGainFlag;
|
||||
}MWNvmCfgVolumnSetFlag;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int slope;
|
||||
int offset;
|
||||
HalCodecTlvDefault_t defaultVal;
|
||||
}HalCodecVolParam_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ES8311 = 0,
|
||||
ES8374,
|
||||
ES8388,
|
||||
ES7148,
|
||||
ES7149,
|
||||
TM8211,
|
||||
SC2601
|
||||
}HalCodecType_e;
|
||||
|
||||
// codec status
|
||||
typedef enum
|
||||
{
|
||||
CODEC_EOK = 0, // operation completed successfull
|
||||
CODEC_ERR = -1, // unspecified error: no other errno fits
|
||||
CODEC_TIMEOUT = -2, // invalid argument(s)
|
||||
CODEC_INIT_ERR = -3, // invalid argument(s)
|
||||
CODEC_CFG_ERR = -4, // invalid argument(s)
|
||||
CODEC_SET_VOLUME_ERR = -5, // invalid argument(s)
|
||||
CODEC_START_ERR = -6, // invalid argument(s)
|
||||
CODEC_START_I2C_ERR = -7, // invalid argument(s)
|
||||
|
||||
CODEC_STATUS_RSVD = 0x7FFFFFFF
|
||||
}HalCodecSts_e;
|
||||
|
||||
// module gain
|
||||
typedef enum
|
||||
{
|
||||
MODULE_MIN = -1,
|
||||
MODULE_ADC = 0x01,
|
||||
MODULE_DAC = 0x02,
|
||||
MODULE_ADC_DAC = 0x03,
|
||||
MODULE_LINE = 0x04,
|
||||
MODULE_MAX
|
||||
}HalCodecModule_e;
|
||||
|
||||
// Select media hal codec mode
|
||||
typedef enum
|
||||
{
|
||||
CODEC_MODE_ENCODE = 1, // select adc
|
||||
CODEC_MODE_DECODE, // select dac
|
||||
CODEC_MODE_BOTH, // select both adc and dac
|
||||
CODEC_MODE_LINE_IN, // set adc channel
|
||||
}HalCodecMode_e;
|
||||
|
||||
|
||||
// Select adc channel for input mic signal
|
||||
typedef enum
|
||||
{
|
||||
CODEC_ADC_INPUT_LINE1 = 0x00, // mic input to adc channel 1
|
||||
CODEC_ADC_INPUT_LINE2, // mic input to adc channel 2
|
||||
CODEC_ADC_INPUT_ALL, // mic input to both channels of adc
|
||||
CODEC_ADC_INPUT_DIFFERENCE, // mic input to adc difference channel
|
||||
}HalAdcInput_e;
|
||||
|
||||
// Select channel for dac output
|
||||
typedef enum
|
||||
{
|
||||
CODEC_DAC_OUTPUT_LINE1 = 0x00, // dac output signal to channel 1
|
||||
CODEC_DAC_OUTPUT_LINE2, // dac output signal to channel 2
|
||||
CODEC_DAC_OUTPUT_ALL, // dac output signal to both channels
|
||||
}HalDacOutput_e;
|
||||
|
||||
|
||||
// Select operating mode i.e. start or stop for audio codec chip
|
||||
typedef enum
|
||||
{
|
||||
CODEC_CTRL_STOP = 0x00, // set stop mode
|
||||
CODEC_CTRL_START = 0x01, // set start mode
|
||||
CODEC_CTRL_RESUME = 0x02, // set resume mode
|
||||
CODEC_CTRL_POWERDONW = 0x03, // set powerdown mode
|
||||
}HalCodecCtrlState_e;
|
||||
|
||||
// Select I2S interface operating mode i.e. master or slave for audio codec chip
|
||||
typedef enum
|
||||
{
|
||||
CODEC_MODE_MASTER = 0x00, // set master mode
|
||||
CODEC_MODE_SLAVE = 0x01, // set slave mode
|
||||
}HalCodecIfaceMode_e;
|
||||
|
||||
// Select I2S interface samples per second
|
||||
typedef enum
|
||||
{
|
||||
CODEC_08K_SAMPLES, // set to 8k samples per second
|
||||
CODEC_16K_SAMPLES, // set to 16k samples in per second
|
||||
CODEC_22K_SAMPLES, // set to 22.050k samples per second
|
||||
CODEC_32K_SAMPLES, // set to 32k samples in per second
|
||||
CODEC_44K_SAMPLES, // set to 44.1k samples per second
|
||||
CODEC_48K_SAMPLES, // set to 48k samples per second
|
||||
}HalCodecIfaceSample_e;
|
||||
|
||||
// Select I2S interface number of bits per sample
|
||||
typedef enum
|
||||
{
|
||||
CODEC_BIT_LENGTH_16BITS = 0, // set 16 bits per sample
|
||||
CODEC_BIT_LENGTH_24BITS = 2, // set 24 bits per sample
|
||||
CODEC_BIT_LENGTH_32BITS = 3, // set 32 bits per sample
|
||||
}HalCodecIfaceBits_e;
|
||||
|
||||
// Select I2S interface format for audio codec chip
|
||||
typedef enum
|
||||
{
|
||||
CODEC_MSB_MODE, // set all left format */
|
||||
CODEC_LSB_MODE, // set all right format */
|
||||
CODEC_I2S_MODE, // set normal I2S format */
|
||||
CODEC_PCM_MODE, // set dsp/pcm format */
|
||||
}HalCodecIfaceFormat_e;
|
||||
|
||||
// codec channel
|
||||
typedef enum
|
||||
{
|
||||
CODEC_MONO,
|
||||
CODEC_DUAL,
|
||||
}HalCodecChannel_e;
|
||||
|
||||
// I2s interface configuration for audio codec chip
|
||||
typedef struct
|
||||
{
|
||||
HalCodecIfaceMode_e mode; // audio codec chip mode
|
||||
HalCodecIfaceFormat_e fmt; // I2S interface format
|
||||
HalCodecIfaceSample_e samples; // I2S interface samples per second
|
||||
HalCodecIfaceBits_e bits; // i2s interface number of bits per sample
|
||||
HalCodecChannel_e channel; // mono or dual channel
|
||||
uint8_t polarity;
|
||||
}HalCodecIface_t;
|
||||
|
||||
// Configure media hal for initialization of audio codec chip
|
||||
typedef struct
|
||||
{
|
||||
HalAdcInput_e adcInput; // set adc channel
|
||||
HalDacOutput_e dacOutput; // set dac channel
|
||||
HalCodecMode_e codecMode; // select codec mode: adc, dac or both
|
||||
HalCodecIface_t codecIface; // set I2S interface configuration
|
||||
bool hasPA;
|
||||
uint8_t codecDeviceType;// 0:HAND_SET 1:HEAD_SET_3_4_POLE 2:HEAD_SET 3:HANDS_OFF
|
||||
uint8_t deviceMode; // 0: NB 1: WB
|
||||
uint8_t direction; // 0: TX 1: RX
|
||||
HalCodecVolParam_t codecVolParam; // each codec volume param, include slope and offset
|
||||
}HalCodecCfg_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CODEC_NONE = 0,
|
||||
CODEC_INIT = 1,
|
||||
CODEC_START = 2,
|
||||
CODEC_STANDBY = 3,
|
||||
CODEC_RESUME = 4,
|
||||
CODEC_POWER_DOWN = 5
|
||||
}HalCodecState_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t playState : 4;
|
||||
uint16_t recordState : 4;
|
||||
uint16_t playCnt : 4;
|
||||
uint16_t recordCnt : 4;
|
||||
}HalCodecState_t;
|
||||
|
||||
// HAL codec func list
|
||||
typedef struct
|
||||
{
|
||||
uint8_t codecType;
|
||||
HalCodecSts_e (*halCodecInitFunc)(HalCodecCfg_t *codec_cfg); // initialize codec
|
||||
void (*halCodecDeinitFunc)(void); // deinitialize codec
|
||||
HalCodecSts_e (*halCodecCtrlStateFunc)(HalCodecMode_e mode, HalCodecCtrlState_e ctrl_state); // control codec mode and state
|
||||
HalCodecSts_e (*halCodecCfgIfaceFunc)(HalCodecMode_e mode, HalCodecIface_t *iface); // configure i2s interface
|
||||
HalCodecSts_e (*halCodecSetMuteFunc) (HalCodecCfg_t* codecHalCfg, bool mute); // set codec mute
|
||||
HalCodecSts_e (*halCodecSetVolumeFunc)(HalCodecCfg_t* codecHalCfg, int volume); // set codec volume
|
||||
HalCodecSts_e (*halCodecGetVolumeFunc)(HalCodecCfg_t* codecHalCfg, int *volume); // get codec volume
|
||||
HalCodecSts_e (*halCodecSetMicVolumeFunc)(HalCodecCfg_t* codecHalCfg, uint8_t micGain, int volume); // set codec mic gain and volume
|
||||
HalCodecSts_e (*halCodecGetMicVolumeFunc)(HalCodecCfg_t* codecHalCfg, uint8_t* micGain, int *volume); // get codec mic gain and volume
|
||||
void (*halCodecEnablePAFunc) (bool enable); // enable pa
|
||||
void *halCodecLock; // semaphore of codec
|
||||
void *handle; // handle of audio codec
|
||||
HalCodecCfg_t (*halCodecGetDefaultCfg)();
|
||||
}HalCodecFuncList_t;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
\brief Hal codec init
|
||||
\param[in] codecHalCfg codec config
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return HalCodecFuncList_t* codec funclist
|
||||
\note
|
||||
*/
|
||||
HalCodecFuncList_t* halCodecInit(HalCodecCfg_t* codecHalCfg, HalCodecFuncList_t* codecHalFunc, bool needLock);
|
||||
|
||||
/**
|
||||
\brief HAL CODEC Deinit
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecDeinit(HalCodecFuncList_t* codecHal);
|
||||
|
||||
/**
|
||||
\brief Hal codec start/stop control
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] mode codec mode
|
||||
\param[in] codecStartStop codec start or stop
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecCtrlState(HalCodecFuncList_t* codecHal, HalCodecMode_e mode, HalCodecCtrlState_e codecStartStop, bool needLock);
|
||||
|
||||
/**
|
||||
\brief Hal codec interface config
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] mode codec mode
|
||||
\param[in] iface codec interface
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecIfaceCfg(HalCodecFuncList_t* codecHal, HalCodecMode_e mode, HalCodecIface_t *iface, bool needLock);
|
||||
|
||||
/**
|
||||
\brief Hal codec set mute
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] mute codec set mute
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecSetMute(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, bool mute, bool needLock);
|
||||
|
||||
#if 0
|
||||
/**
|
||||
\brief Hal codec enable pa
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] enable codec enable/disable pa
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecEnablePA(HalCodecFuncList_t* codecHal, bool enable, bool needLock);
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Hal codec set volume
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] volume codec set volume
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecSetVolume(HalCodecFuncList_t* codecHal,HalCodecCfg_t* codecHalCfg, int volume, bool needLock);
|
||||
|
||||
/**
|
||||
\brief Hal codec get volume
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[out] volume codec get volume
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecGetVolume(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, int *volume, bool needLock);
|
||||
|
||||
/**
|
||||
\brief Hal codec set mic volume
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] micGain codec set mic gain
|
||||
\param[in] micVolume codec set volume
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecSetMicVolume(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, uint8_t micGain, int micVolume, bool needLock);
|
||||
|
||||
/**
|
||||
\brief Hal codec get default config
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\return HalCodecCfg_t codec defalt config
|
||||
\note
|
||||
*/
|
||||
HalCodecCfg_t halCodecGetDefaultCfg(HalCodecFuncList_t* codecHalFunc);
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CODEC_DRV_H */
|
@ -1,96 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2020-, Copyrigths of EigenComm Ltd.
|
||||
* File name: eepRom.h
|
||||
* Description: EC618 eepRom driver file
|
||||
* History: Rev1.0 2020-12-17
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _EEPROM_EC618_H
|
||||
#define _EEPROM_EC618_H
|
||||
|
||||
#include "ec7xx.h"
|
||||
#include "Driver_Common.h"
|
||||
#include "oneWire.h"
|
||||
|
||||
/**
|
||||
\addtogroup eepRom_interface_gr
|
||||
\{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/** \brief ROM Operation Command */
|
||||
#define ROM_READ_CMD 0x33
|
||||
#define ROM_MATCH_CMD 0x55
|
||||
#define ROM_SKIP_CMD 0xCC
|
||||
#define ROM_SEARCH_CMD 0xF0
|
||||
|
||||
/** \brief Memory Operation Command */
|
||||
#define MEM_READ_CMD 0xF0
|
||||
#define SCRATCHPAD_READ_CMD 0xAA
|
||||
#define SCRATCHPAD_WRITE_CMD 0x0F
|
||||
#define SCRATCHPAD_COPY_CMD 0x55
|
||||
|
||||
/** \brief EEPROM Status */
|
||||
#define EEPROMDRV_OK (0)
|
||||
#define EEPROMDRV_RESET_ERR (-1)
|
||||
#define EEPROMDRV_RESETPD_ERR (-2)
|
||||
#define EEPROMDRV_ROMREAD_ERR (-3)
|
||||
#define EEPROMDRV_ROMMATCH_ERR (-4)
|
||||
#define EEPROMDRV_ROMSKIP_ERR (-5)
|
||||
#define EEPROMDRV_ROMSEARCH_ERR (-6)
|
||||
#define EEPROMDRV_MEMREAD_ERR (-7)
|
||||
#define EEPROMDRV_SCRATCHPADREAD_ERR (-8)
|
||||
#define EEPROMDRV_SCRATCHPADWRITE_ERR (-9)
|
||||
#define EEPROMDRV_SCRATCHPADCOPY_ERR (-10)
|
||||
|
||||
/**
|
||||
\fn int32_t eePromReadRom(uint8_t* romCode)
|
||||
\brief EEPROM read ROM code
|
||||
\param[out] romCode ROM infomation read back.
|
||||
\return read ROM status
|
||||
*/
|
||||
int32_t eePromReadRom(uint8_t* romCode);
|
||||
|
||||
/**
|
||||
\fn eePromReadMem(uint8_t targetAddr, uint8_t len, uint8_t* buffer)
|
||||
\brief EEPROM read memory.
|
||||
\param[in] targetAddr The target address of EEPROM.
|
||||
\param[in] len Length of this read.
|
||||
\param[out] buffer Data read back.
|
||||
\return read memory status
|
||||
*/
|
||||
int32_t eePromReadMem(uint8_t targetAddr, uint8_t len, uint8_t* buffer);
|
||||
|
||||
/**
|
||||
\fn int32_t eePromWriteMem(uint8_t targetAddr, uint8_t len, uint8_t* buffer)
|
||||
\brief EEPROM write memory
|
||||
\param[in] targetAddr The target address of EEPROM.
|
||||
\param[in] len Length of this write.
|
||||
\param[in] buffer Data needs to write into memory.
|
||||
\return Write memory status
|
||||
*/
|
||||
int32_t eePromWriteMem(uint8_t targetAddr, uint8_t len, uint8_t* buffer);
|
||||
|
||||
void eepRomInit(OwModeSel_e mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,202 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __EX_FLASH_H__
|
||||
#define __EX_FLASH_H__
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* EXFLASH Error codes */
|
||||
#define EXFLASH_OK ((uint8_t)0x00)
|
||||
#define EXFLASH_ERROR ((uint8_t)0x01)
|
||||
#define EXFLASH_BUSY ((uint8_t)0x02)
|
||||
#define EXFLASH_NOT_SUPPORTED ((uint8_t)0x04)
|
||||
|
||||
|
||||
#define PAGE_SIZE 256
|
||||
#define SECTOR_SIZE 4096
|
||||
|
||||
#define Dummy_Byte1 0xFF
|
||||
|
||||
|
||||
|
||||
|
||||
/*********commands*******************************************/
|
||||
|
||||
/* Read Operations */
|
||||
#define READ_CMD 0x03
|
||||
#define FAST_READ_CMD 0x0B
|
||||
|
||||
|
||||
/* Write Operations */
|
||||
#define WRITE_ENABLE_CMD 0x06
|
||||
#define WRITE_DISABLE_CMD 0x04
|
||||
|
||||
#define WRITE_VOLATILE_REG_CMD 0x50
|
||||
|
||||
/* Register Operations */
|
||||
#define READ_STATUS_REG1_CMD 0x05
|
||||
#define READ_STATUS_REG2_CMD 0x35
|
||||
#define WRITE_STATUS_REG1_CMD 0x01
|
||||
#define WRITE_STATUS_REG2_CMD 0x31
|
||||
|
||||
/* Program Operations */
|
||||
#define PAGE_PROG_CMD 0x02
|
||||
#define QUAD_INPUT_PAGE_PROG_CMD 0x32
|
||||
|
||||
/* Erase Operations */
|
||||
#define SECTOR_ERASE_CMD 0x20
|
||||
#define BLOCK_ERASE_32K_CMD 0x52
|
||||
#define BLOCK_ERASE_64K_CMD 0xD8
|
||||
#define CHIP_ERASE_CMD 0xC7//or 0x60
|
||||
|
||||
|
||||
/* Identification Operations */
|
||||
#define READ_ID_CMD 0x90
|
||||
#define DUAL_READ_ID_CMD 0x92
|
||||
#define QUAD_READ_ID_CMD 0x94
|
||||
#define READ_JEDEC_ID_CMD 0x9F
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashChipErase(void)
|
||||
\brief perform chip level erase, use with caution!!
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
void exFlashChipErase(void);
|
||||
|
||||
/**
|
||||
\fn exFlashBlockErase(void)
|
||||
\brief perform block level erase
|
||||
\param[in] u32Data_Addr :Block first address to start erasing
|
||||
u8mode :Erase mode 1=32K other=64K
|
||||
\note
|
||||
*/
|
||||
void exFlashBlockErase(uint32_t u32Erase_Addr, uint8_t u8mode);
|
||||
|
||||
/**
|
||||
\fn exFlashSectorErase(void)
|
||||
\brief perform sector level erase, normally sector is 4K
|
||||
\param[in] u32Data_Addr :Block first address to start erasing
|
||||
\note
|
||||
*/
|
||||
void exFlashSectorErase(uint32_t u32Erase_Addr);
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashRead(void)
|
||||
\brief reading data of the specified length at the specified address
|
||||
\param[in] u32ReadAddr Start reading address(24bit)
|
||||
pu8Buffer Data storage buffer
|
||||
u16NumByteToRead The number of bytes to read(max 65535)
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashRead(uint8_t *pu8Buffer, uint32_t u32ReadAddr, uint16_t u16NumByteToRead);
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashPagePro(void)
|
||||
\brief starts writing data of up to 256 bytes at a specified address on one page (0~65535)
|
||||
\param[in] u32ReadAddr Start reading address(24bit)
|
||||
pu8Buffer:Data storage buffer
|
||||
u16NumByteToWrite:The number of bytes to write (maximum 256),
|
||||
* the number should not exceed the number of remaining bytes on the page!!!
|
||||
\note
|
||||
*/
|
||||
void exFlashPagePro(uint32_t u32WriteAddr, uint8_t *pu8Buffer, uint16_t u16NumByteToWrite);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashReadMDID(void)
|
||||
\brief reading device ID from flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
uint16_t exFlashReadMDID(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashErase(uint32_t eAddr, uint32_t size)
|
||||
\brief Erases the flash region. use different erase cmd according to size
|
||||
\param[in] eAddr addr to erase
|
||||
size erase len
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashErase(uint32_t eAddr, uint32_t size);
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashWrite(uint8_t* pData, uint32_t WriteAddr, uint32_t Size)
|
||||
\brief Writes an amount of data to the QSPI flash.
|
||||
\param[in] pData: Data Pointer to write
|
||||
WriteAddr: Write start address
|
||||
Size: Size of data to write
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashWrite(uint8_t* pData, uint32_t WriteAddr, uint32_t Size);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashInit(void)
|
||||
\brief init the external spi flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashInit(void);
|
||||
|
||||
/**
|
||||
\fn exFlashDeinit(void)
|
||||
\brief deinit the external spi flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashDeinit(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,176 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __EX_STORAGE_H__
|
||||
#define __EX_STORAGE_H__
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define EXSTO_OK 0
|
||||
#define EXSTO_EUNDEF -1 /* undefined error */
|
||||
#define EXSTO_EINIT -2 /* ex-storage init fail */
|
||||
#define EXSTO_EDEINIT -3 /* ex-storage deinit fail */
|
||||
#define EXSTO_EERASE -4 /* flash erase fail */
|
||||
#define EXSTO_EWRITE -5 /* flash write fail */
|
||||
#define EXSTO_EREAD -6 /* flash read fail */
|
||||
#define EXSTO_EMALLOC -7 /* memory alloc fail*/
|
||||
#define EXSTO_EOVRFLOW -8 /* data overflow */
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EXSTO_ZONE_BEGIN = 0,
|
||||
EXSTO_ZONE_EF_DATA = EXSTO_ZONE_BEGIN,
|
||||
EXSTO_ZONE_EF_RSVD,
|
||||
EXSTO_ZONE_SD_DATA,
|
||||
EXSTO_ZONE_SD_RSVD,
|
||||
|
||||
EXSTO_ZONE_MAXNUM,
|
||||
EXSTO_ZONE_UNDEF = 0xff
|
||||
}ExStoZoneId_e;
|
||||
|
||||
typedef uint32_t ExStoZoneId_bm;
|
||||
#define EXSTO_BM_ZONE_EF_DATA (1 << EXSTO_ZONE_EF_DATA)
|
||||
#define EXSTO_BM_ZONE_EF_RSVD (1 << EXSTO_ZONE_EF_RSVD)
|
||||
#define EXSTO_BM_ZONE_SD_DATA (1 << EXSTO_ZONE_SD_DATA)
|
||||
#define EXSTO_BM_ZONE_SD_RSVD (1 << EXSTO_ZONE_SD_RSVD)
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\fn uint8_t exStorageInit(void)
|
||||
\brief init the external storage
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageInit(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageDeinit(void)
|
||||
\brief deinit the external storage
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageDeinit(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageClear(uint32_t zid, uint32_t offset, uint32_t len)
|
||||
\brief erase the area to be write
|
||||
\param[in] zid resv for future use
|
||||
offset erase start addr
|
||||
len erase len
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageClear(uint32_t zid, uint32_t offset, uint32_t len);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageWrite(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen)
|
||||
\brief write data of the specified length at the specified address
|
||||
\param[in] zid resv for future use
|
||||
offset write start addr
|
||||
buf write buf
|
||||
bufLen write len
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageWrite(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageRead(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen)
|
||||
\brief reading data of the specified length at the specified address
|
||||
\param[in] zid resv for future use
|
||||
offset read start addr
|
||||
buf read buf
|
||||
bufLen read len
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageRead(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen);
|
||||
|
||||
/**
|
||||
* @brief exStorageGetZid(uint32_t addr, uint32_t *size, uint32_t *offset);
|
||||
* @details get the es zid according starting address and size of the zone
|
||||
*
|
||||
* @param addr the starting addr of the zone
|
||||
* @param size the size of the zone
|
||||
* @param offset the offset to starting addr of the zone
|
||||
* @return the zone ID.
|
||||
*/
|
||||
uint32_t exStorageGetZid(uint32_t addr, uint32_t *size, uint32_t *offset);
|
||||
|
||||
/**
|
||||
* @brief exStorageGetSize(uint32_t zid, uint8_t isOvhdExcl)
|
||||
* @details get the nvm size of specific fota zone
|
||||
*
|
||||
* @param zid zone Id of fota nvm
|
||||
* @param isOvhdExcl overhead size of the zone is excluded or not
|
||||
* @return the size of zone.
|
||||
*/
|
||||
uint32_t exStorageGetSize(uint32_t zid, uint8_t isOvhdExcl);
|
||||
|
||||
/**
|
||||
* @brief exStorageVerifyPkg(uint32_t zid, uint8_t *hash, uint32_t pkgSize, uint32_t *pkgState)
|
||||
* @details validate the data pkg
|
||||
*
|
||||
* @param pkgState the last state of data pkg
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t exStorageVerifyPkg(uint32_t zid, uint8_t *hash, uint32_t pkgSize, uint32_t *pkgState);
|
||||
|
||||
/**
|
||||
* @brief exStorageGetUpdResult(uint32_t zid, int32_t *pkgState)
|
||||
* @details get the updated result
|
||||
*
|
||||
* @param pkgState the last state of data pkg
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t exStorageGetUpdResult(uint32_t zid, int32_t *pkgState);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,86 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2020-, Copyrigths of EigenComm Ltd.
|
||||
* File name: tp.h
|
||||
* Description: EC618 tp driver file
|
||||
* History: Rev1.0 2020-12-17
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _KEYPAD_EC718_H
|
||||
#define _KEYPAD_EC718_H
|
||||
|
||||
#include "ec7xx.h"
|
||||
#include "Driver_Common.h"
|
||||
|
||||
#include "kpc.h"
|
||||
#include "kpc_defs.h"
|
||||
/**
|
||||
\addtogroup tp_interface_gr
|
||||
\{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
/** \brief KEYPAD location */
|
||||
// ROW PIN
|
||||
/* GPIO27 */
|
||||
#define KEYPAD_ROW_0_PAD_INDEX (52)
|
||||
#define KEYPAD_ROW_0_ALT_FUNC (PAD_MUX_ALT6)
|
||||
|
||||
/* GPIO26 */
|
||||
#define KEYPAD_ROW_1_PAD_INDEX (51)
|
||||
#define KEYPAD_ROW_1_ALT_FUNC (PAD_MUX_ALT6)
|
||||
|
||||
/* GPIO25 */
|
||||
#define KEYPAD_ROW_2_PAD_INDEX (50)
|
||||
#define KEYPAD_ROW_2_ALT_FUNC (PAD_MUX_ALT6)
|
||||
|
||||
/* GPIO24 */
|
||||
#define KEYPAD_ROW_3_PAD_INDEX (49)
|
||||
#define KEYPAD_ROW_3_ALT_FUNC (PAD_MUX_ALT6)
|
||||
|
||||
/* GPIO23-AGPIO3 */
|
||||
#define KEYPAD_ROW_4_PAD_INDEX (48)
|
||||
#define KEYPAD_ROW_4_ALT_FUNC (PAD_MUX_ALT6)
|
||||
|
||||
|
||||
// COLUMNS PIN
|
||||
/* GPIO13 */
|
||||
#define KEYPAD_COLUMN_0_PAD_INDEX (28)
|
||||
#define KEYPAD_COLUMN_0_ALT_FUNC (PAD_MUX_ALT6)
|
||||
|
||||
/* GPIO12 */
|
||||
#define KEYPAD_COLUMN_1_PAD_INDEX (27)
|
||||
#define KEYPAD_COLUMN_1_ALT_FUNC (PAD_MUX_ALT6)
|
||||
|
||||
/* GPIO20 */
|
||||
#define KEYPAD_COLUMN_2_PAD_INDEX (45)
|
||||
#define KEYPAD_COLUMN_2_ALT_FUNC (PAD_MUX_ALT6)
|
||||
|
||||
/* GPIO21 */
|
||||
#define KEYPAD_COLUMN_3_PAD_INDEX (46)
|
||||
#define KEYPAD_COLUMN_3_ALT_FUNC (PAD_MUX_ALT6)
|
||||
|
||||
#define ROWS (5)
|
||||
#define COLUMNS (4)
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void keypadInit(void);
|
||||
void keypadScan(void);
|
||||
void keypadLoop(void);
|
||||
int32_t KPC_eventQueueRead(KpcReportEvent_t *eventPtr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,68 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2023-, Copyrigths of EigenComm Ltd.
|
||||
* File name: kpc_defs.h
|
||||
* Description: ec7xx keypad func code header file
|
||||
* History: Rev1.0 2023-11-22
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _KPC_DEFS_H
|
||||
#define _KPC_DEFS_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OK_KEY_ROW (1)
|
||||
#define OK_KEY_COLUMN (1)
|
||||
#define OK_KEY_CODE (0xF2)
|
||||
|
||||
#define CLEAR_KEY_ROW (2)
|
||||
#define CLEAR_KEY_COLUMN (3)
|
||||
#define CLEAR_KEY_CODE (0xF0)
|
||||
|
||||
#define CANCEL_KEY_ROW (1)
|
||||
#define CANCEL_KEY_COLUMN (3)
|
||||
#define CANCEL_KEY_CODE (0xF1)
|
||||
|
||||
#define UP_KEY_ROW (4)
|
||||
#define UP_KEY_COLUMN (0)
|
||||
#define UP_KEY_CODE (0xF3)
|
||||
|
||||
#define DOWN_KEY_ROW (3)
|
||||
#define DOWN_KEY_COLUMN (2)
|
||||
#define DOWN_KEY_CODE (0xF4)
|
||||
|
||||
#define F1_KEY_ROW (0)
|
||||
#define F1_KEY_COLUMN (1)
|
||||
#define F1_KEY_CODE (0xF5)
|
||||
|
||||
#define F2_KEY_ROW (0)
|
||||
#define F2_KEY_COLUMN (2)
|
||||
#define F2_KEY_CODE (0xF6)
|
||||
|
||||
#define NULL_KEY_CODE (0xFF)
|
||||
|
||||
#define FUNC_KEY_ROW (3)
|
||||
#define FUNC_KEY_COLUMN (2)
|
||||
#define FUNC_KEY_CODE (0xFE)
|
||||
|
||||
#define MENU_KEY_ROW (3)
|
||||
#define MENU_KEY_COLUMN (0)
|
||||
#define MENU_KEY_CODE (0xFD)
|
||||
|
||||
#define FUNC_CODE_YES 'a'
|
||||
#define FUNC_CODE_NO 'b'
|
||||
|
||||
//在LCD V1.1和手机板上的menu yes按键互换
|
||||
#define FUNC_CODE_MENU 'm'
|
||||
#define FUNC_CODE_BACK 'n'
|
||||
#define FUNC_CODE_DIAL 'C'
|
||||
#define FUNC_CODE_DIR_U 'U'
|
||||
#define FUNC_CODE_DIR_D 'D'
|
||||
#define FUNC_CODE_DIR_L 'L'
|
||||
#define FUNC_CODE_DIR_R 'R'
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,109 +0,0 @@
|
||||
# LCD
|
||||
|
||||
```bash
|
||||
├── lcdDev
|
||||
| ├── disFormat.c
|
||||
| ├── lcdComm.c
|
||||
| ├── lcdDev_7796.c
|
||||
| ├── lcdDev_3037.c
|
||||
| └── lcdDev_7789.c
|
||||
└── lcdDrv.c
|
||||
```
|
||||
|
||||
* 时钟测量接口用于分析执行耗时,并将所有耗时存储到外部flash导出(格式为csv)
|
||||
|
||||
```bash
|
||||
uint32_t measure_execution(void (*func)(va_list), ...)
|
||||
```
|
||||
|
||||
## LSPI
|
||||
|
||||
## Interface
|
||||
|
||||
* 3线I型 – SCL、CS、SDA - 3线1data 9bit SPI – 半双工,只有一根双向的数据线
|
||||
* 3线II型 –SCL、CS、SDI、SDO - 3线2data 9bit SPI – 全双工,有独立的MOSI、MISO
|
||||
* 4线I型 – SCL、DCX、CS、SDA - 4线1data 8bit SPI – 半双工,只有一根双向的数据线
|
||||
* 4线II型 – SCL、DCX、CS、SDI、SDO - 4线2data 8bit SPI –全双工,有独立的MOSI、MISO
|
||||
|
||||
**SCL对应LSPI CLK,DCX对应LSPI WRX,多数LCD没有SDO**
|
||||
|
||||
```bash
|
||||
lspiCtrl.busType = 1; // Interface II
|
||||
lspiCtrl.line4 = 1;
|
||||
lspiCtrl.data2Lane = 0;
|
||||
```
|
||||
|
||||
## DataFormat
|
||||
|
||||
* 相较很多LCD的接收数据格式,LSPI默认先发送放低位(大端模式,bit0在低位),所以会导致颜色反转,读出的数据也会大小端反转。
|
||||
* 如果采用32位寄存器长度,不进行数据压缩,是无法修法数据顺序的。
|
||||
|
||||
```bash
|
||||
lspiDataFmt.wordSize = 15;
|
||||
lspiDataFmt.txPack = 1;
|
||||
lspiDataFmt.rxPack = 1;
|
||||
lspiDataFmt.endianMode = 1;
|
||||
lspiDataFmt.rxFifoEndianMode = 1;
|
||||
lcdDrv->ctrl(LSPI_CTRL_DATA_FORMAT, 0);
|
||||
```
|
||||
|
||||
在转换编码时,典型流程如将RGB565转换为YUV420的步骤:
|
||||
|
||||
* 将RGB565转换为RGB888
|
||||
* 将RGB888转换为YUV444
|
||||
* 将YUV444转换为YUV420
|
||||
|
||||
### 注意事项
|
||||
|
||||
* 1)使用DMA->LSPI需要使能相关时钟
|
||||
```bash
|
||||
PSRAM_dmaAccessClkCtrl(true);
|
||||
```
|
||||
|
||||
* 2)DMA传输RGB565奇数像素时最后一个像素无法输出,需要在填充DMA数据时补一个像素(RGB565 - 2bytes),而LSPI的传输长度不需要补,这样实际传输的像素不会多出一个。
|
||||
|
||||
## LCD
|
||||
|
||||
| Driver | Interface | DataLane | Resolution | TransTime | FrameRate
|
||||
| ------- | ------- | ------- | ------- | ------- | ------- |
|
||||
| ST7789 | 4Wire-II | 1 | 240x320 | 24ms | 41 fps
|
||||
| ST7789 | 4Wire-II | 2 | 240x320 | 14ms | 72 fps
|
||||
| NV3037 | 4Wire-II | 2 | 320x480 | 27ms | 37 fps
|
||||
| ST7796 | 4Wire-II | 1 | 320x480 | 41ms | 24 fps
|
||||
|
||||
* 最高速率在LSPI配置51MHz时钟条件下测得,相关配置**lspi.c**
|
||||
|
||||
### ST7796S
|
||||
|
||||
* 读数据的时钟推荐12MHz,时钟太高会出现数据无法对齐
|
||||
* 读取LCD RAM数据使用0x3E寄存器
|
||||
* MADCTL 0x36 / MADCTR影响RGB排列顺序
|
||||
* RDDST 0x09 (0x53) 写入和读出的数据反色
|
||||
|
||||
MADCTL寄存器控制显示方向
|
||||
```bash
|
||||
Bit D7 MY
|
||||
0:Top to Bottom
|
||||
1:Bottom to Top
|
||||
|
||||
Bit D6 MX
|
||||
0:Left to Right (MX=0 MEM RGB)
|
||||
1:Right to Left (MX=1 MEM BGR)
|
||||
|
||||
Bit D5 MV
|
||||
1: Row/column exchange
|
||||
|
||||
Bit D4 ML (Vertical Refresh Order)
|
||||
0:LCD refresh Top to Bottom
|
||||
1:LCD refresh Bottom to Top
|
||||
|
||||
Bit D3 RGB
|
||||
0:RGB
|
||||
1:BGR
|
||||
|
||||
Bit D2 MH (Horizontal Refresh Order)
|
||||
0:Left to Right
|
||||
1:Right to Left
|
||||
```
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
#ifndef _DIS_FMT_H_
|
||||
#define _DIS_FMT_H_
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void yuv422ToRgb565(const void *inbuf, void *outbuf, int width, int height);
|
||||
void yuv420ToRgb565(const void* inbuf, void* outbuf, int width, int height);
|
||||
void rgb565ToYuv422(const void *inbuf, void *outbuf, int width, int height);
|
||||
void rgb565ToYuv420(const void* inbuf, void* outbuf, int width, int height);
|
||||
void rgb565ToYCbCr(const void *inbuf, void *outbuf, int width, int height);
|
||||
void yCbCrToRgb565(const void *inbuf, void *outbuf, int width, int height);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _DIS_FMT_H_ */
|
||||
|
@ -1,52 +0,0 @@
|
||||
#ifndef _LCD_COMM_H
|
||||
#define _LCD_COMM_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "ec7xx.h"
|
||||
#include "bsp.h"
|
||||
#include "lspi.h"
|
||||
|
||||
#define DMA_BULK_NUM (1023*8)
|
||||
#define DMA_DESC_MAX (160) // RGB888 man need big desc chain
|
||||
|
||||
|
||||
void lcdWriteCmd(uint8_t cmd);
|
||||
void lcdWriteData(uint8_t data);
|
||||
void lcdInterfaceType(uint8_t type);
|
||||
void lspiCmdSend(uint8_t cmd, uint8_t *data, uint8_t num);
|
||||
void lspiReadReg(uint8_t addr,uint8_t *data,uint16_t num, uint8_t dummyCycleLen);
|
||||
void lspiReadRam(uint32_t *data,uint32_t num);
|
||||
void lcdDrvDelay(uint32_t ms);
|
||||
void lspiFifoWrite(uint32_t data);
|
||||
|
||||
#if (BK_USE_PWM == 1)
|
||||
uint32_t millis(void);
|
||||
uint8_t lcdPwmBkLevel(uint8_t level);
|
||||
#endif
|
||||
|
||||
#if (BK_USE_GPIO == 1)
|
||||
void lcdGpioBkLevel(uint8_t level);
|
||||
#endif
|
||||
|
||||
typedef void (*lcdDmaCb)(uint32_t event);
|
||||
typedef void (*lcdUspCb)();
|
||||
|
||||
int dmaInit(lcdDmaCb cb);
|
||||
void lcdRst(uint32_t highUs, uint32_t lowUs);
|
||||
void dmaStartStop(bool start);
|
||||
int lspiDefaultCfg(lcdDrvFunc_t *lcd, lcdUspCb cb, uint32_t freq, uint8_t bpp);
|
||||
int lcdDmaTrans(lcdDrvFunc_t *lcd, void *sourceAddress, uint32_t totalLength);
|
||||
void lcdMspiSet(uint8_t enable, uint8_t addrLane, uint8_t dataLane, uint8_t instruction);
|
||||
void lcdMspiHsyncSet(uint8_t hsyncAddr, uint8_t hsyncInst, uint16_t vbpNum, uint16_t vfpNum);
|
||||
void lcdMspiVsyncSet(uint8_t vsyncEnable, uint8_t vsyncInst, uint8_t lspiDiv);
|
||||
void lcdCsnHighCycleMin(uint8_t lspiDiv);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* LCDCOMM_H */
|
||||
|
@ -1,41 +0,0 @@
|
||||
#ifndef LCD_AXS15231_
|
||||
#define LCD_AXS15231_
|
||||
|
||||
#define AXS15231_BPP (16) // 12: 444; 16:565; 18:666
|
||||
#define AXS15231_WIDTH (320)
|
||||
#define AXS15231_HEIGHT (480)
|
||||
#define AXS15231_FREQ (51*1024*1024)
|
||||
#define AXS15231_INTERFACE (SPI_3W_I)
|
||||
#define AXS15231_TIME_OF_FRAME (149356) // us
|
||||
#define AXS15231_TE_CYCLE (16742) // us
|
||||
#define AXS15231_TE_WAIT_TIME (623) // us
|
||||
#define AXS15231_X_OFFSET (0)
|
||||
#define AXS15231_Y_OFFSET (0)
|
||||
|
||||
#if (LCD_INTERFACE_8080 == 1)
|
||||
#if (AXS15231_INTERFACE != INTERFACE_8080)
|
||||
#error "Please choose 8080 interface for AXS15231_INTERFACE"
|
||||
#endif
|
||||
#elif (LCD_INTERFACE_SPI == 1)
|
||||
#if ((AXS15231_INTERFACE != SPI_3W_I) && (AXS15231_INTERFACE != SPI_3W_II) && (AXS15231_INTERFACE != SPI_4W_I) && (AXS15231_INTERFACE != SPI_4W_II))
|
||||
#error "Please choose SPI interface for AXS15231_INTERFACE"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#undef LCD_WIDTH
|
||||
#undef LCD_HEIGHT
|
||||
#define LCD_HEIGHT (AXS15231_HEIGHT)
|
||||
#define LCD_WIDTH (AXS15231_WIDTH)
|
||||
#define LCD_BPP_USE (AXS15231_BPP)
|
||||
#define LCD_INTERFACE (AXS15231_INTERFACE)
|
||||
#define LCD_FREQ (AXS15231_FREQ)
|
||||
#define LCD_X_OFFSET (AXS15231_X_OFFSET)
|
||||
#define LCD_Y_OFFSET (AXS15231_Y_OFFSET)
|
||||
|
||||
#define LCD_PIXEL (LCD_HEIGHT*LCD_WIDTH)
|
||||
#define LCD_TIME_OF_FRAME (AXS15231_TIME_OF_FRAME) // us
|
||||
#define LCD_TE_CYCLE (AXS15231_TE_CYCLE) // us
|
||||
#define LCD_TE_WAIT_TIME (AXS15231_TE_WAIT_TIME) // us
|
||||
|
||||
#endif
|
@ -1,36 +0,0 @@
|
||||
#ifndef LCD_CO5300_
|
||||
#define LCD_CO5300_
|
||||
|
||||
#define CO5300_BPP (16) // 16:565; 18:666 24:888
|
||||
#define CO5300_WIDTH (460)
|
||||
#define CO5300_HEIGHT (460)
|
||||
#define CO5300_FREQ (51*1024*1024)
|
||||
#define CO5300_INTERFACE (MSPI_4W_II)
|
||||
#define CO5300_TE_CYCLE (16327) // us
|
||||
#define CO5300_TE_WAIT_TIME (425) // us
|
||||
#define CO5300_X_OFFSET (0xa)
|
||||
#define CO5300_Y_OFFSET (0)
|
||||
|
||||
#if (ST8601_INTERFACE == MSPI_4W_II)
|
||||
#if (LCD_INTERFACE_MSPI != 1)
|
||||
#error "Please choose MSPI interface in RTE_Device.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#undef LCD_WIDTH
|
||||
#undef LCD_HEIGHT
|
||||
#define LCD_HEIGHT (CO5300_HEIGHT)
|
||||
#define LCD_WIDTH (CO5300_WIDTH)
|
||||
#define DEFAULT_INST (0x2)
|
||||
#define LCD_BPP_USE (CO5300_BPP)
|
||||
#define LCD_INTERFACE (CO5300_INTERFACE)
|
||||
#define LCD_FREQ (CO5300_FREQ)
|
||||
#define LCD_X_OFFSET (CO5300_X_OFFSET)
|
||||
#define LCD_Y_OFFSET (CO5300_Y_OFFSET)
|
||||
|
||||
#define LCD_PIXEL (LCD_HEIGHT*LCD_WIDTH)
|
||||
#define LCD_TE_CYCLE (CO5300_TE_CYCLE) // us
|
||||
#define LCD_TE_WAIT_TIME (CO5300_TE_WAIT_TIME) // us
|
||||
|
||||
#endif
|
@ -1,42 +0,0 @@
|
||||
#ifndef LCD_ST7789_
|
||||
#define LCD_ST7789_
|
||||
|
||||
#define ST7789_BPP (16) // 12: 444; 16:565; 18:666
|
||||
#define ST7789_WIDTH (240)
|
||||
#define ST7789_HEIGHT (320)
|
||||
#define ST7789_FREQ (51*1024*1024)
|
||||
#define ST7789_INTERFACE (SPI_4W_II)
|
||||
#define ST7789_TIME_OF_FRAME (149356) // us
|
||||
#define ST7789_TE_CYCLE (16742) // us
|
||||
#define ST7789_TE_WAIT_TIME (623) // us
|
||||
#define ST7789_X_OFFSET (0)
|
||||
#define ST7789_Y_OFFSET (0)
|
||||
|
||||
#if (LCD_INTERFACE_8080 == 1)
|
||||
#if (ST7789_INTERFACE != INTERFACE_8080)
|
||||
#error "Please choose 8080 interface for ST7789_INTERFACE"
|
||||
#endif
|
||||
#elif (LCD_INTERFACE_SPI == 1)
|
||||
#if ((ST7789_INTERFACE != SPI_3W_I) && (ST7789_INTERFACE != SPI_3W_II) && (ST7789_INTERFACE != SPI_4W_I) && (ST7789_INTERFACE != SPI_4W_II))
|
||||
#error "Please choose SPI interface for ST7789_INTERFACE"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#undef LCD_WIDTH
|
||||
#undef LCD_HEIGHT
|
||||
#define LCD_HEIGHT (ST7789_HEIGHT)
|
||||
#define LCD_WIDTH (ST7789_WIDTH)
|
||||
#define LCD_BPP_USE (ST7789_BPP)
|
||||
#define LCD_INTERFACE (ST7789_INTERFACE)
|
||||
#define LCD_FREQ (ST7789_FREQ)
|
||||
#define LCD_X_OFFSET (ST7789_X_OFFSET)
|
||||
#define LCD_Y_OFFSET (ST7789_Y_OFFSET)
|
||||
|
||||
#define LCD_PIXEL (LCD_HEIGHT*LCD_WIDTH)
|
||||
#define LCD_FREQ (ST7789_FREQ)
|
||||
#define LCD_TIME_OF_FRAME (ST7789_TIME_OF_FRAME) // us
|
||||
#define LCD_TE_CYCLE (ST7789_TE_CYCLE) // us
|
||||
#define LCD_TE_WAIT_TIME (ST7789_TE_WAIT_TIME) // us
|
||||
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
#ifndef LCD_ST77903_
|
||||
#define LCD_ST77903_
|
||||
|
||||
#define ST77903_BPP (16) // 16:565; 18:666 24:888
|
||||
#define ST77903_WIDTH (400)
|
||||
#define ST77903_HEIGHT (400)
|
||||
#define ST77903_FREQ (8*1024*1024)
|
||||
#define ST77903_INTERFACE (MSPI_4W_II)
|
||||
#define BIST_TEST (0)
|
||||
#define ST77903_TIME_OF_FRAME (149356) // us
|
||||
#define ST77903_TE_CYCLE (16742) // us
|
||||
#define ST77903_TE_WAIT_TIME (623) // us
|
||||
#define ST77903_X_OFFSET (0)
|
||||
#define ST77903_Y_OFFSET (0)
|
||||
|
||||
#if (ST77903_INTERFACE == MSPI_4W_II)
|
||||
#if (LCD_INTERFACE_MSPI != 1)
|
||||
#error "Please choose MSPI interface in RTE_Device.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#undef LCD_WIDTH
|
||||
#undef LCD_HEIGHT
|
||||
#define LCD_HEIGHT (ST77903_HEIGHT)
|
||||
#define LCD_WIDTH (ST77903_WIDTH)
|
||||
#define DEFAULT_INST (0xde)
|
||||
#define LCD_BPP_USE (ST77903_BPP)
|
||||
#define LCD_INTERFACE (ST77903_INTERFACE)
|
||||
#define LCD_FREQ (ST77903_FREQ)
|
||||
#define LCD_X_OFFSET (ST77903_X_OFFSET)
|
||||
#define LCD_Y_OFFSET (ST77903_Y_OFFSET)
|
||||
|
||||
#define LCD_PIXEL (LCD_HEIGHT*LCD_WIDTH)
|
||||
#define LCD_TIME_OF_FRAME (ST77903_TIME_OF_FRAME) // us
|
||||
#define LCD_TE_CYCLE (ST77903_TE_CYCLE) // us
|
||||
#define LCD_TE_WAIT_TIME (ST77903_TE_WAIT_TIME) // us
|
||||
|
||||
|
||||
#endif
|
@ -1,236 +0,0 @@
|
||||
#ifndef _LCD_DRV_H
|
||||
#define _LCD_DRV_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "ec7xx.h"
|
||||
#include "bsp.h"
|
||||
#include "lspi.h"
|
||||
#include "disFormat.h"
|
||||
|
||||
#define LCD_COLOR565(r, g, b) (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3))
|
||||
|
||||
#define RED (0x001f)
|
||||
#define GREEN (0x07e0)
|
||||
#define BLUE (0xf800)
|
||||
#define WHITE (0xffff)
|
||||
#define BLACK (0x0000)
|
||||
#define YELLOW (0xffe0)
|
||||
#define PURPLE (0x8010)
|
||||
#define GOLDEN (0xFEA0)
|
||||
|
||||
#define SPI_3W_I (0)
|
||||
#define SPI_3W_II (1)
|
||||
#define SPI_4W_I (2)
|
||||
#define SPI_4W_II (3)
|
||||
#define MSPI_4W_II (4)
|
||||
#define INTERFACE_8080 (5)
|
||||
|
||||
|
||||
#define LCD_RST_LOW do {GPIO_pinWrite(LSPI_RST_GPIO_INSTANCE, 1 << LSPI_RST_GPIO_PIN, 0);}while(0)
|
||||
#define LCD_RST_HIGH do {GPIO_pinWrite(LSPI_RST_GPIO_INSTANCE, 1 << LSPI_RST_GPIO_PIN, 1 << LSPI_RST_GPIO_PIN);}while(0)
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t cmd;
|
||||
uint8_t len;
|
||||
uint8_t data[32];
|
||||
}initLine_t;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
stopPreview = 0,
|
||||
startPreview = 1,
|
||||
}camPreviewStartStop_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
cbForCam = 0,
|
||||
cbForFill = 1,
|
||||
}uspCbRole_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TE_RISE_EDGE = 0,
|
||||
TE_FALL_EDGE = 1,
|
||||
}teEdgeSel_e;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/* @---> X
|
||||
|
|
||||
Y
|
||||
*/
|
||||
DIS_DIR_LRTB, /**< From left to right then from top to bottom, this consider as the original direction of the screen */
|
||||
|
||||
/* Y
|
||||
|
|
||||
@---> X
|
||||
*/
|
||||
DIS_DIR_LRBT, /**< From left to right then from bottom to top */
|
||||
|
||||
/* X <---@
|
||||
|
|
||||
Y
|
||||
*/
|
||||
DIS_DIR_RLTB, /**< From right to left then from top to bottom */
|
||||
|
||||
/* Y
|
||||
|
|
||||
X <---@
|
||||
*/
|
||||
DIS_DIR_RLBT, /**< From right to left then from bottom to top */
|
||||
|
||||
/* @---> Y
|
||||
|
|
||||
X
|
||||
*/
|
||||
DIS_DIR_TBLR, /**< From top to bottom then from left to right */
|
||||
|
||||
/* X
|
||||
|
|
||||
@---> Y
|
||||
*/
|
||||
DIS_DIR_BTLR, /**< From bottom to top then from left to right */
|
||||
|
||||
/* Y <---@
|
||||
|
|
||||
X
|
||||
*/
|
||||
DIS_DIR_TBRL, /**< From top to bottom then from right to left */
|
||||
|
||||
/* X
|
||||
|
|
||||
Y <---@
|
||||
*/
|
||||
DIS_DIR_BTRL, /**< From bottom to top then from right to left */
|
||||
|
||||
DIS_DIR_MAX,
|
||||
/* Another way to represent rotation with 3 bit*/
|
||||
DIS_MIRROR_X = 0x40, /**< Mirror X-axis */
|
||||
DIS_MIRROR_Y = 0x20, /**< Mirror Y-axis */
|
||||
DIS_SWAP_XY = 0x80, /**< Swap XY axis */
|
||||
} DisDirection_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LCD_POWER_OFF = 0,
|
||||
LCD_POWER_ON = 1
|
||||
}lcdPowerOnOff_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CAM_PREVIEW_SET_AUTO = 0,
|
||||
CAM_PREVIEW_SET_MANUAL = 1
|
||||
}lcdPreviewModeSel_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t rowScaleFrac;
|
||||
uint16_t colScaleFrac;
|
||||
uint16_t tailorLeft;
|
||||
uint16_t tailorRight;
|
||||
uint16_t tailorTop;
|
||||
uint16_t tailorBottom;
|
||||
}lcdPreviewManulItem_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
lcdPreviewModeSel_e previewModeSel;
|
||||
lcdPreviewManulItem_t previewManulSet;
|
||||
}lcdIoCtrl_t;
|
||||
|
||||
typedef struct _lcdDrvFunc_t lcdDrvFunc_t;
|
||||
typedef void (*lspiErrCb)(uint32_t stats);
|
||||
|
||||
typedef struct _lcdDrvFunc_t
|
||||
{
|
||||
uint32_t id;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint32_t freq;
|
||||
uint8_t bpp;
|
||||
initLine_t *initRegTbl;
|
||||
uint32_t initRegTblLen;
|
||||
uint8_t dir; // vertical: 0; horizontal: 1;
|
||||
|
||||
int (*init) (lcdDrvFunc_t *lcd, void* uspCb, void* dmaCb, uint32_t freq, uint8_t bpp);
|
||||
void (*drawPoint) (lcdDrvFunc_t *lcd, uint16_t x, uint16_t y, uint32_t dataWrite);
|
||||
uint32_t (*setWindow) (lcdDrvFunc_t *lcd, uint16_t sx, uint16_t ex, uint16_t sy, uint16_t ey);
|
||||
int (*fill) (lcdDrvFunc_t *lcd, uint32_t fillLen, uint8_t *buf);
|
||||
void (*backLight) (lcdDrvFunc_t *lcd, uint8_t level);
|
||||
void (*powerOnOff) (lcdDrvFunc_t *lcd, lcdPowerOnOff_e onoff);
|
||||
void (*startStop) (lcdDrvFunc_t *lcd, bool startOrStop);
|
||||
void (*startStopPreview) (lcdDrvFunc_t *lcd, camPreviewStartStop_e previewStartStop);
|
||||
void (*uspIrq4CamCb) (lcdDrvFunc_t *lcd);
|
||||
void (*uspIrq4FillCb) (lcdDrvFunc_t *lcd);
|
||||
void (*registerUspIrqCb) (lcdDrvFunc_t *lcd, uspCbRole_e who);
|
||||
void (*unregisterUspIrqCb) (lcdDrvFunc_t *lcd, uspCbRole_e who);
|
||||
int (*direction) (lcdDrvFunc_t *lcd, DisDirection_e dir);
|
||||
int (*close) (lcdDrvFunc_t *lcd);
|
||||
}lcdDrvFunc_t;
|
||||
|
||||
|
||||
#if (LCD_ST7789_ENABLE == 1)
|
||||
#include "lcdDev_7789.h"
|
||||
extern lcdDrvFunc_t st7789Drv;
|
||||
#elif (LCD_SH8601_ENABLE == 1)
|
||||
#include "lcdDev_8601.h"
|
||||
extern lcdDrvFunc_t sh8601Drv;
|
||||
#elif (LCD_ST7571_ENABLE == 1)
|
||||
#include "lcdDev_7571.h"
|
||||
extern lcdDrvFunc_t st7571Drv;
|
||||
#elif (LCD_ST7567_ENABLE == 1)
|
||||
#include "lcdDev_7567.h"
|
||||
extern lcdDrvFunc_t st7567Drv;
|
||||
#elif (LCD_ST77903_ENABLE == 1)
|
||||
#include "lcdDev_77903.h"
|
||||
extern lcdDrvFunc_t st77903Drv;
|
||||
#elif (LCD_GC9307_ENABLE == 1)
|
||||
#include "lcdDev_9307.h"
|
||||
extern lcdDrvFunc_t gc9307Drv;
|
||||
#elif (LCD_AXS15231_ENABLE == 1)
|
||||
#include "lcdDev_15231.h"
|
||||
extern lcdDrvFunc_t axs15231Drv;
|
||||
#elif (LCD_CO5300_ENABLE == 1)
|
||||
#include "lcdDev_5300.h"
|
||||
extern lcdDrvFunc_t co5300Drv;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void lcdRegInit(uint32_t id);
|
||||
lcdDrvFunc_t* lcdOpen(uint32_t id, void* uspCb, void* dmaCb);
|
||||
int lcdClose(lcdDrvFunc_t *pdrv);
|
||||
void lcdIoInit(bool isAonIO);
|
||||
void lcdRegisterSlp1Cb(lcdSlp1Cb_fn cb);
|
||||
int lcdDirection(lcdDrvFunc_t *pdrv, DisDirection_e dir);
|
||||
int lcdFill(lcdDrvFunc_t *pdrv, uint32_t fillLen, uint8_t* buf);
|
||||
void lcdDrawPoint(lcdDrvFunc_t *pdrv, uint16_t x, uint16_t y, uint32_t dataWrite);
|
||||
void camPreview(lcdDrvFunc_t *pdrv, camPreviewStartStop_e previewStartStop);
|
||||
void lcdBackLight(lcdDrvFunc_t *pdrv, uint8_t level);
|
||||
uint32_t lcdSetWindow(lcdDrvFunc_t *pdrv, uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey);
|
||||
void lspiRstAndClearFifo();
|
||||
void lspiRegisterErrStatsCb(lspiErrCb errCb);
|
||||
void lspiCheckErrStats();
|
||||
void imageRotateColor(uint8_t* src, uint32_t width, uint32_t height, uint8_t* dst, uint8_t bpp);
|
||||
void imageRotateGray(uint8_t* src, uint32_t width, uint32_t height, uint8_t* dst);
|
||||
void yuv422ToRgb565_2(const void* inbuf, void* outbuf, int width, int height);
|
||||
void lcdIoCtrl(lcdDrvFunc_t *lcd, lcdIoCtrl_t ioCtrl);
|
||||
void lcdConfigReg(lcdDrvFunc_t *lcd, uint8_t cmd, uint8_t *data, uint8_t dataLen);
|
||||
#if ((defined CHIP_EC718) && !(defined TYPE_EC718M)) || (defined CHIP_EC716)
|
||||
void calTe(uint32_t totalBytes, uint16_t sy);
|
||||
#else // 719
|
||||
void calTe(teEdgeSel_e teEdge, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
#ifndef _NTC_H
|
||||
#define _NTC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Get NTC temperature
|
||||
|
||||
Vref(AIO1 output 1200000 uV)
|
||||
v
|
||||
|
|
||||
|
|
||||
+-+
|
||||
| |
|
||||
| | R = 10 Kohm
|
||||
| |
|
||||
+-+
|
||||
|--------->(AIO2)
|
||||
+-+
|
||||
| |
|
||||
| | Rntc
|
||||
| |
|
||||
+-+
|
||||
|
|
||||
-----
|
||||
--- (GND)
|
||||
-
|
||||
|
||||
\param[in] adcInputVoltage ADC input voltage in unit of uV
|
||||
\return temperature in unit of mili degree centigrade
|
||||
*/
|
||||
int32_t ntcGetTemperature(int32_t adcInputVoltage);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NTC_H */
|
@ -1,852 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2019-, Copyrigths of EigenComm Ltd.
|
||||
* File name: plat_config.h
|
||||
* Description: platform configuration header file
|
||||
* History: Rev1.0 2019-01-18
|
||||
* Rev1.1 2019-11-27 Reimplement file operations with OSA APIs(LFS wrapper), not directly using LFS APIs in case of file system replacement
|
||||
* Rev1.2 2020-01-01 Separate plat config into two parts, FS and raw flash
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _PLAT_CONFIG_H
|
||||
#define _PLAT_CONFIG_H
|
||||
|
||||
#include "Driver_Common.h"
|
||||
#include "cmsis_compiler.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
//use FEATURE_PLAT_CFG_FS_SUP_USBNET_ATA not DFEATURE_USBNET_ATA_FOR_AP, the plat cfgfs structure is same for bootloader and ap
|
||||
#ifndef FEATURE_PLAT_CFG_FS_SUP_USBNET_ATA
|
||||
|
||||
#define FS_PLAT_CONFIG_FILE_CURRENT_VERSION (0)
|
||||
#else
|
||||
// the version 1 use scalable plat cfg fs data structure, it's more useful when then data config grows dynamically
|
||||
#define FS_PLAT_CONFIG_FILE_CURRENT_VERSION (1)
|
||||
#endif
|
||||
|
||||
#define RAW_FLASH_PLAT_CONFIG_FILE_CURRENT_VERSION (1)
|
||||
|
||||
|
||||
/** \brief config file header typedef */
|
||||
__PACKED_STRUCT _config_file_header
|
||||
{
|
||||
uint16_t fileBodySize; /**< size of file body, in unit of byte */
|
||||
uint8_t version; /**< file version, this field shall be updated when file structure is changed */
|
||||
uint8_t checkSum; /**< check sum value of file body */
|
||||
};
|
||||
typedef struct _config_file_header config_file_header_t;
|
||||
|
||||
/** \brief typedef of platform configuration stored in fs */
|
||||
typedef __PACKED_UNION _EPAT_atPortFrameFormat
|
||||
{
|
||||
uint32_t wholeValue;
|
||||
__PACKED_STRUCT _config
|
||||
{
|
||||
uint32_t dataBits : 3;
|
||||
uint32_t parity : 2;
|
||||
uint32_t stopBits : 2;
|
||||
uint32_t flowControl : 3;
|
||||
} config;
|
||||
} atPortFrameFormat_t;
|
||||
|
||||
|
||||
|
||||
// ulg port enum
|
||||
typedef enum
|
||||
{
|
||||
PLAT_CFG_ULG_PORT_USB=0,
|
||||
PLAT_CFG_ULG_PORT_UART,
|
||||
PLAT_CFG_ULG_PORT_MIX,
|
||||
PLAT_CFG_ULG_PORT_SRAM,
|
||||
PLAT_CFG_ULG_PORT_MAX
|
||||
} PlatCfgUlgPort_e;
|
||||
|
||||
|
||||
|
||||
#if (FS_PLAT_CONFIG_FILE_CURRENT_VERSION==0)
|
||||
/*verion 0 orignal plat cfg, no change the data structure compare to released sdk,
|
||||
so no merge needed when new sdk release, and plat cfg fs will also not change
|
||||
when new sdk burned. */
|
||||
|
||||
/** \brief typedef of platform configuration stored in fs */
|
||||
typedef __PACKED_STRUCT _NVM_EPAT_plat_config
|
||||
{
|
||||
/** PM on/off flag
|
||||
* valid value:
|
||||
* 0x504D5544 -- PM is disabled, "PMUD"
|
||||
* 0x504D5545 -- PM is enabled, "PMUE"
|
||||
*/
|
||||
uint32_t enablePM;
|
||||
|
||||
/** sleep mode
|
||||
* valid value:
|
||||
* 0 -- dummy
|
||||
* 1 -- dummy
|
||||
*/
|
||||
uint8_t sleepMode;
|
||||
|
||||
/** wait n ms before sleep, when wakeup from pad
|
||||
* valid value:
|
||||
* 0 -- do not wait
|
||||
* x -- wait x ms
|
||||
*/
|
||||
uint32_t slpWaitTime;
|
||||
|
||||
/** AT baudrate,for AP only
|
||||
* should be equal to 'atPortBaudRate' in struct plat_config_raw_flash_t
|
||||
*/
|
||||
uint32_t atPortBaudRate;
|
||||
|
||||
/** AT port frame format*/
|
||||
atPortFrameFormat_t atPortFrameFormat;
|
||||
|
||||
/** ECQSCLK config
|
||||
* valid value:
|
||||
* 0 -- ECQSCLK set to 0
|
||||
* 1 -- ECQSCLK set to 1
|
||||
*/
|
||||
uint8_t ecSclkCfg;
|
||||
|
||||
|
||||
} plat_config_fs_t;
|
||||
|
||||
#else
|
||||
/*version 1, scalable plat cfg, two method to update the config data structure
|
||||
1.The total data size for scalable area does not change when some new config data added, the reserved data array still have some bytes spare,
|
||||
the added data just use one or some bytes of the reserved data array.
|
||||
When the new config data added the upgrade is compatitble. and downgrade is also compatitble too.
|
||||
If the new config data added is a automatical parameter, such as the usbNetAdaptResult, it's automatically setted by the UE connected with different Host Windows or Ubuntu.
|
||||
If the new config data added is not a automatical parameter, it should be setted to a meaningful value otherwise when upgrade ,it may not work correctly as required by the default 0.
|
||||
|
||||
In this case, the plat cfg fs data will not be overwrited to fs when both upgarde or downgrade initlal between the old/new sdk versions that plat cfg fs data size same .
|
||||
it's more convenient for lightly upgrade or downgrade.
|
||||
|
||||
2.The total data size for scalable area is increased when some new config data added. because the reserved data array has no some bytes spare,
|
||||
Increase the scalable area with some bytes each time, such as each time 16 bytes(_NVM_PLATCFG_SCALE_UNIT_SZ) for example. use one or some of the increased bytes by new added parameter,
|
||||
some other bytes defined as reserverd data array.
|
||||
In this case, the plat cfg fs data will be writed when upgrade or downgrade ocurrs.
|
||||
|
||||
Set recPrevArAllSzForUpg = scaleAreaAllSize - SCALE_AREA_SCALE_UNIT_SIZE
|
||||
|
||||
|
||||
2.1 Upgarde from previous plat cfg fs structure to a new added parameter new plat cfg fs structure.
|
||||
Provided condition: readed scalable area total size from plat cfg fs is not same with current scaleAreaAllSize real size
|
||||
|
||||
|
||||
If the readed scalable area total size from plat cfg fs is same with recPrevArAllSzForUpg, then it's upgradable.
|
||||
If not same with recPrevArAllSzForUpg, then it's not upgardable because may have a lot of difference between old/new versions.
|
||||
|
||||
2.2 Downgrade from a new added parameter new plat cfg fs structure to an old plat cfg fs structure.
|
||||
Provided condition: readed scalable area total size from plat cfg fs is not same with current scaleAreaAllSize var
|
||||
|
||||
If the readed recPrevArAllSzForUpg from plat cfg fs is current scaleAreaAllSize real size, then it's downgradable.
|
||||
If recPrevArAllSzForUpg not same with current scaleAreaAllSize real size, then it's not downgradable because may have a lot of difference between old/new versions.
|
||||
*/
|
||||
|
||||
#define _NVM_PLATCFG_SCALE_UNIT_SZ 16
|
||||
|
||||
|
||||
// S 53 C 43 A 41 L 4C
|
||||
#define PLAT_CFG_SCALE_START_MARK 0x4353
|
||||
#define PLAT_CFG_SCALE_END_MARK 0x4C41
|
||||
|
||||
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP_CNT 1
|
||||
#define PLAT_CFG_FIX_BASE_SIZE 18
|
||||
|
||||
#define SCALE_AREA_GRP_UNIT_SIZE 16
|
||||
#define PLAT_CFG_GRP0_RSVBYTES_NUM 15
|
||||
#define PLAT_CFG_GRP0_TOKBYTES_NUM (SCALE_AREA_GRP_UNIT_SIZE-PLAT_CFG_GRP0_RSVBYTES_NUM)
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP_DATA_X(_TYPE_XX, __NAME_XX) _TYPE_XX __NAME_XX
|
||||
#define PLAT_CFG_DATA_0(_TYPE_XX, __NAME_XX) PLAT_CFG_DATA_X(_TYPE_XX, __NAME_XX)
|
||||
|
||||
#define PLAT_CFG_GRP_RSV_BYTE_X(__GRP_XX, __IDX_XX) uint8_t rsvBytes_##__GRP_XX##__IDX_XX
|
||||
|
||||
#define PLAT_CFG_GRP0_ALL_TOK_BYTES() \
|
||||
uint8_t usbNetAdaptResult;
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_0() PLAT_CFG_GRP_RSV_BYTE_X(0, 0);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_1() PLAT_CFG_GRP_RSV_BYTE_X(0, 1);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_2() PLAT_CFG_GRP_RSV_BYTE_X(0, 2);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_3() PLAT_CFG_GRP_RSV_BYTE_X(0, 3);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_4() PLAT_CFG_GRP_RSV_BYTE_X(0, 4);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_5() PLAT_CFG_GRP_RSV_BYTE_X(0, 5);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_6() PLAT_CFG_GRP_RSV_BYTE_X(0, 6);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_7() PLAT_CFG_GRP_RSV_BYTE_X(0, 7);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_8() PLAT_CFG_GRP_RSV_BYTE_X(0, 8);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_9() PLAT_CFG_GRP_RSV_BYTE_X(0, 9);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_10() PLAT_CFG_GRP_RSV_BYTE_X(0, 10);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_11() PLAT_CFG_GRP_RSV_BYTE_X(0, 11);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_12() PLAT_CFG_GRP_RSV_BYTE_X(0, 12);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_13() PLAT_CFG_GRP_RSV_BYTE_X(0, 13);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_14() PLAT_CFG_GRP_RSV_BYTE_X(0, 14);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_15() PLAT_CFG_GRP_RSV_BYTE_X(0, 15);
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_0() PLAT_CFG_GRP0_RSVBYTE_0()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_1() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_0() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_1()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_2() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_1() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_2()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_3() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_2() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_3()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_4() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_3() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_4()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_5() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_4 ()\
|
||||
PLAT_CFG_GRP0_RSVBYTE_5()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_6() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_5() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_6()
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_7() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_6() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_7()
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_8() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_7() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_8()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_9() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_8() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_9()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_10() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_9() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_10()
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_11() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_10() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_11()
|
||||
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_12() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_11() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_12()
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_13() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_12() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_13()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_14() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_13() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_14()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_15() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_14() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_15()
|
||||
|
||||
|
||||
#if (PLAT_CFG_GRP0_RSVBYTES_NUM== 0)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==1)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_0()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==2)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_1()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==3)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_2()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==4)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_3()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==5)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_4()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==6)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_5()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==7)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_6()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==8)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_7()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM== 9)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_8()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==10)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_9()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==11)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_10)
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==12)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_11)
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==13)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_12()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==14)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_13()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==15)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_14()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==16)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_15()
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef __PACKED_STRUCT plat_cfg_sc_grp0_tok_tag {
|
||||
PLAT_CFG_GRP0_ALL_TOK_BYTES()
|
||||
}plat_cfg_sc_grp0_tok_st;
|
||||
|
||||
|
||||
typedef __PACKED_STRUCT plat_cfg_sc_grp0_all_data_tag {
|
||||
PLAT_CFG_GRP0_ALL_TOK_BYTES()
|
||||
PLAT_CFG_GRP0_ALL_RSV_BYTES()
|
||||
}plat_cfg_sc_grp0_all_data_st;
|
||||
|
||||
|
||||
#define SIZE_OF_TYPE_EQUAL_TO_SZX(type_x, size_x) \
|
||||
static inline char size_of##type_x##_equal_to_##size_x(void) { \
|
||||
char __dummy1[sizeof(type_x) - size_x]; \
|
||||
char __dummy2[size_x-sizeof(type_x)]; \
|
||||
return __dummy1[-1]+__dummy2[-1]; \
|
||||
}
|
||||
|
||||
#define SIZE_OF_TYPE_EQUAL_TO_CALX(type_x, cal_sz_x) \
|
||||
static inline char size_of##type_x##_equal_to_cal_sz_x(void) { \
|
||||
char __dummy1[sizeof(type_x) - (cal_sz_x)]; \
|
||||
char __dummy2[(cal_sz_x)-sizeof(type_x)]; \
|
||||
return __dummy1[-1]+__dummy2[-1]; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef __PACKED_STRUCT _NVM_EPAT_plat_config
|
||||
{
|
||||
/*do not change any variable function or name of base fix area if want to upgrade ,
|
||||
because when sync para from prev plat config scale fs the para may be syncd unmatched and used uncorrectly*/
|
||||
|
||||
/** PM on/off flag
|
||||
* valid value:
|
||||
* 0x504D5544 -- PM is disabled, "PMUD"
|
||||
* 0x504D5545 -- PM is enabled, "PMUE"
|
||||
*/
|
||||
uint32_t enablePM;
|
||||
|
||||
/** sleep mode
|
||||
* valid value:
|
||||
* 0 -- dummy
|
||||
* 1 -- dummy
|
||||
*/
|
||||
uint8_t sleepMode;
|
||||
|
||||
/** wait n ms before sleep, when wakeup from pad
|
||||
* valid value:
|
||||
* 0 -- do not wait
|
||||
* x -- wait x ms
|
||||
*/
|
||||
uint32_t slpWaitTime;
|
||||
|
||||
/** AT baudrate,for AP only
|
||||
* should be equal to 'atPortBaudRate' in struct plat_config_raw_flash_t
|
||||
*/
|
||||
uint32_t atPortBaudRate;
|
||||
|
||||
/** AT port frame format*/
|
||||
atPortFrameFormat_t atPortFrameFormat;
|
||||
|
||||
/** ECQSCLK config
|
||||
* valid value:
|
||||
* 0 -- ECQSCLK set to 0
|
||||
* 1 -- ECQSCLK set to 1
|
||||
*/
|
||||
uint8_t ecSclkCfg;
|
||||
|
||||
|
||||
/*Mark for reserve bytes area*/
|
||||
uint16_t scaleAreaStartMark;
|
||||
|
||||
/*scalable area data define*/
|
||||
/*do not change any variable function or name of used scale area data,
|
||||
because when sync para from prev plat config scale fs the para may be syncd unmatched and used uncorrectly*/
|
||||
//scaleAreaPureData0
|
||||
//uint8_t usbNetAdaptResult;/* 7-4: Adapt valid, 3-0:adapt result*/
|
||||
|
||||
|
||||
//scaleAreaPureData1- scaleAreaPureDataX X=(SCALE_AREA_SCALE_UNIT_SIZE-1)
|
||||
//uint8_t scaleAreaSpareBytes[SCALE_AREA_SCALED_SPARE_SZ];
|
||||
PLAT_CFG_GRP0_ALL_TOK_BYTES()
|
||||
PLAT_CFG_GRP0_ALL_RSV_BYTES()
|
||||
|
||||
uint16_t scaleAreaEndMark;
|
||||
|
||||
//scalable area data structure version, added 1 by customer if sometimes need to upgrade from specific scalable area verson to another specific scalable area version,
|
||||
//if not need specific upgrade, set to defautl 0 ro add 1 just for record
|
||||
uint16_t recScaleAreaGrpNum;
|
||||
|
||||
uint16_t recPrevArAllSzForUpg;
|
||||
|
||||
//uint16_t scaleTimers;
|
||||
uint16_t scaleAreaAllSize;
|
||||
} plat_config_fs_t;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/** \brief typedef of platform configuration stored in raw flash --old v0*/
|
||||
__PACKED_STRUCT _plat_config_raw_flash_v0
|
||||
{
|
||||
/** action to perform when assert or hard fault occurs
|
||||
* valid value:
|
||||
* 0 -- dump full exception info to flash and EPAT tool then trapped in endless loop(while(1))
|
||||
* 1 -- print necessary exception info then reset
|
||||
* 2 -- dump full exception info to flash then reset
|
||||
* 3 -- dump full exception info to flash and EPAT tool then reset
|
||||
* 4 -- reset directly
|
||||
* 10 -- enable uart help dump and dump full exception info to flash and EPAT tool then trapped in endless loop(while(1))
|
||||
* 13 -- enable uart help dump and dump full exception info to flash and EPAT tool, and then reset
|
||||
*/
|
||||
uint8_t faultAction;
|
||||
|
||||
/** port select for dump info output when exception occurs
|
||||
* valid value:
|
||||
* 0,1,2,3,(4) -- specify which port
|
||||
* 0xff -- disable this function
|
||||
*/
|
||||
uint8_t uartDumpPort;
|
||||
|
||||
/** WDT start/stop control
|
||||
* valid value:
|
||||
* 0 -- stop WDT
|
||||
* 1 -- start WDT
|
||||
*/
|
||||
uint8_t startWDT;
|
||||
|
||||
/** unilog on/off flag
|
||||
* valid value:
|
||||
* 0 -- unilog is disabled
|
||||
* 1 -- only sw log is enabled
|
||||
* 2 -- All log is enabled
|
||||
*/
|
||||
uint8_t logControl;
|
||||
|
||||
/** uart baudrate for unilog output */
|
||||
uint32_t uartBaudRate;
|
||||
|
||||
/** debug trace log level setting, refer to 'DebugTraceLevelType_e' */
|
||||
uint32_t logLevel;
|
||||
|
||||
/** unilog output port select
|
||||
* valid value:
|
||||
* 0 -- USB
|
||||
* 1 -- UART
|
||||
* 2 -- MIX(for future use UART/USB dynamic select)
|
||||
**/
|
||||
PlatCfgUlgPort_e logPortSel;
|
||||
|
||||
/** RNDIS enum control
|
||||
* valid value:
|
||||
* 0 -- enable USB init and enum RNDIS
|
||||
* 1 -- enable USB init but not enum RNDIS
|
||||
* 2 -- disable USB init
|
||||
*/
|
||||
uint8_t usbCtrl;
|
||||
|
||||
/** usb software trace control
|
||||
* valid value:
|
||||
* 0 -- disable all usb software trace
|
||||
* 1 -- enable all usb software trace
|
||||
* others -- misc usb software trace
|
||||
*/
|
||||
uint8_t usbSwTrace;
|
||||
|
||||
|
||||
|
||||
/** USB sleep mask
|
||||
* valid value:
|
||||
* 0 -- usb should vote to enter sleep
|
||||
* 1 -- do not consider usb vote before sleep
|
||||
*/
|
||||
uint8_t usbSlpMask;
|
||||
|
||||
/** USB sleep thd
|
||||
* valid value:
|
||||
* set the minimal time to sleep, when usbSlpMask=1
|
||||
*/
|
||||
uint16_t usbSlpThd;
|
||||
|
||||
/** pwrkey mode
|
||||
* valid value:
|
||||
* 1 power key mode
|
||||
* 0 normal key mode
|
||||
*/
|
||||
uint8_t pwrKeyMode;
|
||||
};
|
||||
|
||||
// fota urc port type
|
||||
typedef enum
|
||||
{
|
||||
PLAT_CFG_FOTA_URC_PORT_USB=0,
|
||||
PLAT_CFG_FOTA_URC_PORT_UART,
|
||||
PLAT_CFG_FOTA_URC_PORT_MAXTYPE
|
||||
} PlatCfgFotaUrcPortType_e;
|
||||
|
||||
#define PLAT_CFG_FOTA_URC_USB_PORT_IDX_MIN 0
|
||||
#define PLAT_CFG_FOTA_URC_USB_PORT_IDX_MAX 2
|
||||
|
||||
#define PLAT_CFG_FOTA_URC_UART_PORT_IDX_MIN 0
|
||||
#define PLAT_CFG_FOTA_URC_UART_PORT_IDX_MAX 1
|
||||
|
||||
|
||||
#define PLAT_CFG_RAW_FLASH_RSVD_SIZE 16
|
||||
|
||||
/** \brief typedef of platform configuration stored in raw flash */
|
||||
__PACKED_STRUCT _plat_config_raw_flash
|
||||
{
|
||||
/** action to perform when assert or hard fault occurs
|
||||
* valid value:
|
||||
* 0 -- dump full exception info to flash and EPAT tool then trapped in endless loop(while(1))
|
||||
* 1 -- print necessary exception info then reset
|
||||
* 2 -- dump full exception info to flash then reset
|
||||
* 3 -- dump full exception info to flash and EPAT tool then reset
|
||||
* 4 -- reset directly
|
||||
* 10 -- enable uart help dump and dump full exception info to flash and EPAT tool then trapped in endless loop(while(1))
|
||||
* 13 -- enable uart help dump and dump full exception info to flash and EPAT tool, and then reset
|
||||
*/
|
||||
uint8_t faultAction;
|
||||
|
||||
/** port select for dump info output when exception occurs
|
||||
* valid value:
|
||||
* 0,1,2,3,(4) -- specify which port
|
||||
* 0xff -- disable this function
|
||||
*/
|
||||
uint8_t uartDumpPort;
|
||||
|
||||
|
||||
/** WDT start/stop control
|
||||
* valid value:
|
||||
* 0 -- stop WDT
|
||||
* 1 -- start WDT
|
||||
*/
|
||||
uint8_t startWDT;
|
||||
|
||||
/** unilog on/off flag
|
||||
* valid value:
|
||||
* 0 -- unilog is disabled
|
||||
* 1 -- only sw log is enabled
|
||||
* 2 -- All log is enabled
|
||||
*/
|
||||
uint8_t logControl;
|
||||
|
||||
/** uart baudrate for unilog output */
|
||||
uint32_t uartBaudRate;
|
||||
|
||||
/** debug trace log level setting, refer to 'DebugTraceLevelType_e' */
|
||||
uint32_t logLevel;
|
||||
|
||||
/** unilog output port select
|
||||
* valid value:
|
||||
* 0 -- USB
|
||||
* 1 -- UART
|
||||
* 2 -- MIX(for future use UART/USB dynamic select)
|
||||
**/
|
||||
PlatCfgUlgPort_e logPortSel;
|
||||
|
||||
/** RNDIS enum control
|
||||
* valid value:
|
||||
* 0 -- enable USB init and enum RNDIS
|
||||
* 1 -- enable USB init but not enum RNDIS
|
||||
* 2 -- disable USB init
|
||||
*/
|
||||
uint8_t usbCtrl;
|
||||
|
||||
/** usb software trace control
|
||||
* valid value:
|
||||
* 0 -- disable all usb software trace
|
||||
* 1 -- enable all usb software trace
|
||||
* others -- misc usb software trace
|
||||
*/
|
||||
uint8_t usbSwTrace;
|
||||
|
||||
|
||||
|
||||
/** USB sleep mask
|
||||
* valid value:
|
||||
* 0 -- usb should vote to enter sleep
|
||||
* 1 -- do not consider usb vote before sleep
|
||||
*/
|
||||
uint8_t usbSlpMask;
|
||||
|
||||
/** USB sleep thd
|
||||
* valid value:
|
||||
* set the minimal time to sleep, when usbSlpMask=1
|
||||
*/
|
||||
uint16_t usbSlpThd;
|
||||
|
||||
/** pwrkey mode
|
||||
* valid value:
|
||||
* 1 power key mode
|
||||
* 0 normal key mode
|
||||
*/
|
||||
uint8_t pwrKeyMode;
|
||||
|
||||
/** USB VBUS MODE Enable,Disable Flag
|
||||
* valid value:
|
||||
* 0 -- usb vbus mode disable
|
||||
* 1 -- usb vbus mode enable
|
||||
*/
|
||||
uint8_t usbVBUSModeEn;
|
||||
|
||||
/** USB VBUS MODE Wakup Pad Index
|
||||
* valid value:
|
||||
* 0,1,2,3,4,5 PAD IDX FOR USB VBUS WKUP PAD
|
||||
*/
|
||||
uint8_t usbVBUSWkupPad;
|
||||
|
||||
/** USB NET IF SEL
|
||||
* valid value:
|
||||
* 0----RNDIS,default
|
||||
* 1----ECM
|
||||
*/
|
||||
uint8_t usbNet;
|
||||
|
||||
/** USB VCOM EN bitmap
|
||||
* valid value:
|
||||
* bit0---vcom0
|
||||
* bit1---vcom1
|
||||
* ----
|
||||
* ----
|
||||
*/
|
||||
uint8_t usbVcomEnBitMap;
|
||||
|
||||
/** AT/fotaURC baudrate, for AP & BL*/
|
||||
uint32_t atPortBaudRate;
|
||||
|
||||
/** FOTA control
|
||||
* 0 -- disable FOTA
|
||||
* 1 -- enable FOTA
|
||||
**/
|
||||
uint8_t fotaCtrl;
|
||||
|
||||
/** FOTA URC output port select
|
||||
* valid value(Bit4-7):
|
||||
* 0 -- USB
|
||||
* 1 -- UART
|
||||
**
|
||||
* valid value(Bit0-3):
|
||||
* 0-2 -- USB
|
||||
* 0-1 -- UART
|
||||
**/
|
||||
uint8_t fotaUrcPortSel;
|
||||
|
||||
/** FOTA USB URC output port control
|
||||
* 0 -- disable USB URC output
|
||||
* 1 -- enable USB URC output
|
||||
**/
|
||||
uint8_t fotaUsbUrcCtrl;
|
||||
|
||||
/** pmuInCdrx
|
||||
* valid value:
|
||||
* 0----
|
||||
* 1----
|
||||
*/
|
||||
uint8_t pmuInCdrx;
|
||||
|
||||
/** slpLimitEn
|
||||
* valid value:
|
||||
* 0---- disable
|
||||
* 1---- enable
|
||||
*/
|
||||
uint8_t slpLimitEn;
|
||||
|
||||
/** slpLimitTime
|
||||
* valid value:
|
||||
* 0---0xFFFFFFFF
|
||||
*/
|
||||
uint32_t slpLimitTime;
|
||||
|
||||
/** logOwnerAndLevel
|
||||
* valid value:
|
||||
* 0---0xFFFFFFFF
|
||||
*/
|
||||
uint32_t logOwnerAndLevel;
|
||||
|
||||
/** wfi mode, do not enter doze */
|
||||
uint8_t wfiMode;
|
||||
|
||||
/** ECIDLEP config
|
||||
* valid value:
|
||||
* 0 -- print flag set to 0
|
||||
* 1 -- print flag set to 1
|
||||
*/
|
||||
uint8_t apIdlePercentPrintMode;
|
||||
|
||||
/** cpSlpTest
|
||||
* 0: disable sleep test
|
||||
* 1: CP deepslp
|
||||
* 2: Doze+pll vote disable
|
||||
* 3. Doze+pll vote enable
|
||||
* 4: DFC+WFI
|
||||
* 5: WFI DFC disable
|
||||
* 6. while
|
||||
*/
|
||||
uint8_t cpSlpTest;
|
||||
|
||||
/* 'PLAT_CFG_RAW_FLASH_RSVD_SIZE' bytes rsvd for future */
|
||||
uint8_t resv[PLAT_CFG_RAW_FLASH_RSVD_SIZE];
|
||||
};
|
||||
|
||||
typedef struct _plat_config_raw_flash plat_config_raw_flash_t;//current
|
||||
typedef struct _plat_config_raw_flash_v0 plat_config_raw_flash_v0_t;//old v0
|
||||
|
||||
/** \brief typedef of platform info layout stored in raw flash */
|
||||
__PACKED_STRUCT _plat_info_layout
|
||||
{
|
||||
config_file_header_t header; /**< raw flash plat config header */
|
||||
plat_config_raw_flash_t config; /**< raw flash plat config body */
|
||||
uint32_t fsAssertCount; /**< count for monitoring FS assert, when it reaches specific number, FS region will be re-formated */
|
||||
};
|
||||
typedef struct _plat_info_layout plat_info_layout_t;
|
||||
|
||||
/** @brief List of platform configuration items used to set/get sepecific setting */
|
||||
typedef enum _plat_config_id
|
||||
{
|
||||
PLAT_CONFIG_ITEM_FAULT_ACTION = 0, /**< faultAction item */
|
||||
PLAT_CONFIG_ITEM_UART_DUMP_PORT, /**< uartDumpPort item */
|
||||
PLAT_CONFIG_ITEM_START_WDT, /**< startWDT item */
|
||||
PLAT_CONFIG_ITEM_LOG_CONTROL, /**< logControl item */
|
||||
PLAT_CONFIG_ITEM_LOG_BAUDRATE, /**< uart baudrate for log output */
|
||||
PLAT_CONFIG_ITEM_LOG_LEVEL, /**< logLevel item */
|
||||
PLAT_CONFIG_ITEM_ENABLE_PM, /**< enablePM item */
|
||||
PLAT_CONFIG_ITEM_SLEEP_MODE, /**< sleepMode item */
|
||||
PLAT_CONFIG_ITEM_WAIT_SLEEP, /**< wait ms before sleep */
|
||||
PLAT_CONFIG_ITEM_AT_PORT_BAUDRATE, /**< AT port baudrate */
|
||||
PLAT_CONFIG_ITEM_AT_PORT_FRAME_FORMAT, /**< AT port frame format */
|
||||
PLAT_CONFIG_ITEM_ECSCLK_CFG, /**< ECSCLK config */
|
||||
PLAT_CONFIG_ITEM_LOG_PORT_SEL, /**< ULG output port select */
|
||||
PLAT_CONFIG_ITEM_USB_CTRL, /**< USB control */
|
||||
PLAT_CONFIG_ITEM_USB_SW_TRACE_FLAG, /**< USB control */
|
||||
PLAT_CONFIG_ITEM_USB_SLEEP_MASK, /**< USB Sleep Vote Mask */
|
||||
PLAT_CONFIG_ITEM_USB_SLEEP_THD, /**< USB Sleep Thread */
|
||||
PLAT_CONFIG_ITEM_PWRKEY_MODE, /**< PWRKEY Mode */
|
||||
PLAT_CONFIG_ITEM_USB_VBUS_MODE_EN, /**< USB VBUS MODE ENABLE, DISABLE*/
|
||||
PLAT_CONFIG_ITEM_USB_VBUS_WKUP_PAD, /**< USB VBUS MODE WKUP PAD INDEX*/
|
||||
PLAT_CONFIG_ITEM_USB_NET, /**< USB NET Select*/
|
||||
PLAT_CONFIG_ITEM_USBNET_ATA_RESULT, /*USB NET Autoadapt result */
|
||||
PLAT_CONFIG_ITEM_USB_VCOM_EN_BMP, /**< USB VCOM Enabled Bitmap*/
|
||||
PLAT_CONFIG_ITEM_FOTA_CONTROL, /**< FOTA URC Port control*/
|
||||
PLAT_CONFIG_ITEM_FOTA_URC_PORT_SEL, /**< FOTA URC Port Select*/
|
||||
PLAT_CONFIG_ITEM_FOTA_USB_URC_CONTROL, /**< FOTA USB URC control*/
|
||||
PLAT_CONFIG_ITEM_PMUINCDRX, /**< PMUINCDRX Select*/
|
||||
PLAT_CONFIG_ITEM_SLP_LIMIT_EN, /**< enable sleep time limit*/
|
||||
PLAT_CONFIG_ITEM_SLP_LIMIT_TIME, /**< set maximum sleep time in mili second*/
|
||||
PLAT_CONFIG_ITEM_WFI_MODE, /**< WFI Mode */
|
||||
PLAT_CONFIG_ITEM_IDLEPERCENT_PRINT_MODE, /**< PRINT IDLE PERCENT MODE */
|
||||
PLAT_CONFIG_ITEM_CPSLPTEST_MODE, /**< CP Sleep Mode Test */
|
||||
PLAT_CONFIG_ITEM_TOTAL_NUMBER, /**< total number of items */
|
||||
PLAT_CONFIG_ITEM_LOG_OWNER_AND_LEVEL, /**< log Owner and logLevel for this Owner item */
|
||||
} plat_config_id_t;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
\fn void BSP_SavePlatConfigToFs(void)
|
||||
\brief Save platform configuration into FS
|
||||
\return void
|
||||
*/
|
||||
void BSP_SavePlatConfigToFs(void);
|
||||
|
||||
/**
|
||||
\fn void BSP_LoadPlatConfigFromFs(void)
|
||||
\brief Load platform configuration from FS
|
||||
\return void
|
||||
*/
|
||||
void BSP_LoadPlatConfigFromFs(void);
|
||||
|
||||
/**
|
||||
\fn plat_config_fs_t* BSP_GetFsPlatConfig(void)
|
||||
\brief Get FS platform configuration variable pointer
|
||||
\return pointer to internal platform configuration loaded from FS
|
||||
*/
|
||||
plat_config_fs_t* BSP_GetFsPlatConfig(void);
|
||||
|
||||
/**
|
||||
\fn void BSP_SavePlatConfigToRawFlash(void)
|
||||
\brief Save platform configuration into raw flash
|
||||
\return void
|
||||
*/
|
||||
void BSP_SavePlatConfigToRawFlash(void);
|
||||
|
||||
/**
|
||||
\fn void BSP_LoadPlatConfigFromRawFlash(void)
|
||||
\brief Load platform configuration from raw flash
|
||||
\return void
|
||||
*/
|
||||
void BSP_LoadPlatConfigFromRawFlash(void);
|
||||
|
||||
/**
|
||||
\fn plat_config_raw_flash_t* BSP_GetRawFlashPlatConfig(void)
|
||||
\brief Get raw flash platform configuration variable pointer
|
||||
\return pointer to internal platform configuration loaded from raw flash
|
||||
*/
|
||||
plat_config_raw_flash_t* BSP_GetRawFlashPlatConfig(void);
|
||||
|
||||
/**
|
||||
\fn uint32_t BSP_GetPlatConfigItemValue(plat_config_id_t id)
|
||||
\brief Get value of specific platform configuration item
|
||||
\param[in] id id of platform configuration item, \ref plat_config_id_t
|
||||
\return value of current configuration item
|
||||
*/
|
||||
uint32_t BSP_GetPlatConfigItemValue(plat_config_id_t id);
|
||||
|
||||
/**
|
||||
\fn void BSP_SetPlatConfigItemValue(plat_config_id_t id, uint32_t value)
|
||||
\brief Set value of specific platform configuration item
|
||||
\param[in] id id of platform configuration item, \ref plat_config_id_t
|
||||
\param[in] value value of configuration item to set
|
||||
\return void
|
||||
*/
|
||||
void BSP_SetPlatConfigItemValue(plat_config_id_t id, uint32_t value);
|
||||
|
||||
/**
|
||||
\fn uint32_t BSP_GetFSAssertCount(void)
|
||||
\brief Fetch current 'fsAssertCount' value from PLAT_INFO region
|
||||
\return current fsAssertCount value
|
||||
*/
|
||||
uint32_t BSP_GetFSAssertCount(void);
|
||||
|
||||
/**
|
||||
\fn void BSP_SetFSAssertCount(uint32_t value);
|
||||
\brief Update 'fsAssertCount' value
|
||||
\param[in] value new value assigned to 'fsAssertCount'
|
||||
\return void
|
||||
\note Internal use only on FS assert occurs
|
||||
*/
|
||||
void BSP_SetFSAssertCount(uint32_t value);
|
||||
|
||||
/**
|
||||
\fn void BSP_SetFsPorDefaultValue(void);
|
||||
\brief when por happened some data may retore to it's default
|
||||
\return void
|
||||
*/
|
||||
void BSP_SetFsPorDefaultValue(void);
|
||||
|
||||
/**
|
||||
\fn void BSP_SetPlatCfgUsbNetATAItemVal(void);
|
||||
\brief when USB net auto adapt enabled, to store the adapt result usb net type
|
||||
\return void
|
||||
*/
|
||||
void BSP_SetPlatCfgUsbNetATAItemVal(uint32_t val);
|
||||
|
||||
/**
|
||||
\fn void BSP_GetPlatCfgUsbNetATAEnabled(void);
|
||||
\brief when USB net type config equal to ATC_ECPCFG_USBNET_VAL_AUTOADAPT_TYPE auto adapt enabled, return 1, other return 0
|
||||
\return void
|
||||
*/
|
||||
uint32_t BSP_GetPlatCfgUsbNetATAEnabled(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _PLAT_CONFIG_H */
|
@ -1,32 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2023-, Copyrigths of EigenComm Ltd.
|
||||
* File name: tpComm.h
|
||||
* Description: ec7xx tpComm.h
|
||||
* History: Rev1.0 2023-11-13
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _TP_COMM_H
|
||||
#define _TP_COMM_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ec7xx.h"
|
||||
#include "Driver_Common.h"
|
||||
#include "bsp.h"
|
||||
|
||||
typedef void (*tpIsrFunc)(uint32_t);
|
||||
#define I2C_IO_MODE RTE_I2C0_IO_MODE
|
||||
|
||||
extern ARM_DRIVER_I2C *i2cMasterDrv;
|
||||
|
||||
void tpBusInit(void);
|
||||
void tpRstInit(void);
|
||||
void tpIsrInit(void *cb);
|
||||
uint8_t tp_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint16_t len, uint8_t *data);
|
||||
uint8_t tp_i2c_send(uint8_t dev_id, uint8_t reg_addr, uint16_t len, uint8_t *data);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,36 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2023-, Copyrigths of EigenComm Ltd.
|
||||
* File name: CST816.h
|
||||
* Description: CST816 driver file
|
||||
* History: Rev1.0 2023-09-18
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _TP_CST816_H
|
||||
#define _TP_CST816_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ec7xx.h"
|
||||
#include "Driver_Common.h"
|
||||
|
||||
|
||||
#define CST816_ADDR 0X15
|
||||
|
||||
#define CST816_GET_GESTUREID 0x01
|
||||
#define CST816_GET_FINGERNUM 0x02
|
||||
#define CST816_GET_LOC0 0x03
|
||||
#define CST816_GET_CHIPID 0xA7
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
uint8_t tp_cst816_scan(int16_t *pos);
|
||||
void tp_cst816_init(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,31 +0,0 @@
|
||||
#ifndef _TP_FT6336_H
|
||||
#define _TP_FT6336_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "tpComm.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
//I2C读写命令
|
||||
#define FT6336_ADDR 0x38
|
||||
|
||||
/********************************FT6336 部分寄存器定义***************************/
|
||||
|
||||
#define FT6336_GET_FINGERNUM 0x02
|
||||
#define FT6336_GET_LOC0 0x03
|
||||
#define FT6336_GET_LOC1 0x09
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,53 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2020-, Copyrigths of EigenComm Ltd.
|
||||
* File name: GT911.h
|
||||
* Description: EC7xx touchpanel driver file
|
||||
* History: Rev1.0 2023-09-18
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _TP_GT911_H
|
||||
#define _TP_GT911_H
|
||||
|
||||
#include "ec7xx.h"
|
||||
#include "Driver_Common.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
//I2C读写命令
|
||||
// #define GT911_ADDR 0X5D
|
||||
#define GT911_ADDR 0x14 //由初始化INT输出状态决定
|
||||
/********************************GT911部分寄存器定义***************************/
|
||||
#define GT_CTRL_REG 0X8040 //GT911控制寄存器
|
||||
#define GT_CFGS_REG 0X8047 //配置版本
|
||||
#define GT_X_MAX_LOW 0X8048 //X轴低字节
|
||||
#define GT_X_MAX_HOW 0X8049 //X轴高字节
|
||||
#define GT_Y_MAX_LOW 0X804A //Y轴低字节
|
||||
#define GT_Y_MAX_HOW 0X804B //Y轴高字节
|
||||
#define GT_TOUCH_NUM 0X804C //输出触摸点数1--10
|
||||
|
||||
|
||||
#define GT_CHECK_REG 0X80FF //GT911校验和寄存器
|
||||
#define GT_PID_REG 0X8140 //GT911产品ID寄存器
|
||||
|
||||
#define GT_GSTID_REG 0X814E //当前检测到的触摸情况
|
||||
#define GT_TP1_REG 0X8150 //第一个触摸点数据地址
|
||||
#define GT_TP2_REG 0X8158 //第二个触摸点数据地址
|
||||
#define GT_TP3_REG 0X8160 //第三个触摸点数据地址
|
||||
#define GT_TP4_REG 0X8168 //第四个触摸点数据地址
|
||||
#define GT_TP5_REG 0X8170 //第五个触摸点数据地址
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,60 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2023-, Copyrigths of EigenComm Ltd.
|
||||
* File name: tpDrv.h
|
||||
* Description: ec7xx tpDrv
|
||||
* History: Rev1.0 2023-09-18
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _TP_DRV_H
|
||||
#define _TP_DRV_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "tpComm.h"
|
||||
|
||||
#define SUPPORT_TP_NUM (3)
|
||||
#define INSTALL_TP_NUM (1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t chipID;
|
||||
int (*init)(void *cb);
|
||||
int (*send)(void *tp);
|
||||
int (*read)(void *tp);
|
||||
int (*scan)(void *tp);
|
||||
}tpDrvFunc_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t id;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
}tpDrvPra_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *name; ///< lcd's name used to configure its id, then use id to find its info, including driver function
|
||||
uint16_t id; ///< every lcd's id should be different, no matter lcd's type is the same or not
|
||||
}tpObj_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int handle;
|
||||
tpObj_t *obj;
|
||||
tpDrvPra_t *pra;
|
||||
tpDrvFunc_t *drv;
|
||||
}tpDev_t;
|
||||
|
||||
int tpInit(void* tp_cb);
|
||||
tpDev_t* tpOpen(char* name);
|
||||
uint8_t tpScan(tpDev_t* tpDev);
|
||||
void tpLoop(tpDev_t* tpDev,uint32_t timeout);
|
||||
void tpData(int16_t* x,int16_t* y);
|
||||
bool tpPressed(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,505 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2018 Copyrigths of EigenComm Ltd.
|
||||
* File name: bsp.c
|
||||
* Description:
|
||||
* History:
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "Driver_Common.h"
|
||||
#include "clock.h"
|
||||
#include "bsp.h"
|
||||
#include "system_ec7xx.h"
|
||||
#include DEBUG_LOG_HEADER_FILE
|
||||
#include "ec_string.h"
|
||||
#include "mem_map.h"
|
||||
#ifdef FEATURE_CCIO_ENABLE
|
||||
#include "uart_device.h"
|
||||
#endif
|
||||
#include "dbversion.h"
|
||||
#include "clock.h"
|
||||
#include "hal_adcproxy.h"
|
||||
#include "apmu_external.h"
|
||||
#include "slpman.h"
|
||||
|
||||
#define BSP_TEXT_SECTION SECTION_DEF_IMPL(.sect_bsp_text)
|
||||
#define BSP_RODATA_SECTION SECTION_DEF_IMPL(.sect_bsp_rodata)
|
||||
#define BSP_DATA_SECTION SECTION_DEF_IMPL(.sect_bsp_data)
|
||||
#define BSP_BSS_SECTION SECTION_DEF_IMPL(.sect_bsp_bss)
|
||||
#define FLASH_READ_GRANT_SIZE (16)
|
||||
#define FLASH_READ_MAX_DELAY (10000)//10ms
|
||||
|
||||
|
||||
extern ARM_DRIVER_USART Driver_USART0;
|
||||
extern ARM_DRIVER_USART Driver_USART1;
|
||||
|
||||
BSP_BSS_SECTION ARM_DRIVER_USART *UsartPrintHandle = NULL;
|
||||
BSP_BSS_SECTION ARM_DRIVER_USART *UsartUnilogHandle = NULL;
|
||||
BSP_BSS_SECTION ARM_DRIVER_USART *UsartAtCmdHandle = NULL;
|
||||
|
||||
BSP_BSS_SECTION static uint8_t OSState = 0; // OSState = 0 os not start, OSState = 1 os started
|
||||
BSP_BSS_SECTION static uint32_t gUartBaudrate[3]; // a copy for uart baud rate
|
||||
extern void trimAdcSetGolbalVar(void);
|
||||
#if defined CHIP_EC718 || defined CHIP_EC716
|
||||
extern void trimLdoAIOVadjSetGolbalVar(void);
|
||||
#endif
|
||||
#if defined CHIP_EC718
|
||||
extern void trimVadjVbatSenseSetGolbalVar(void);
|
||||
#endif
|
||||
extern void GPR_RmiErrCfg(bool en);
|
||||
extern uint32_t GPR_RmiErrAddrGet(void);
|
||||
extern uint8_t FLASH_XIPRead(uint8_t* pData, uint32_t ReadAddr, uint32_t Size);
|
||||
extern uint8_t ShareInfoAPGetCPBusyFlag( void );
|
||||
|
||||
|
||||
void BSP_InitUartDriver(ARM_DRIVER_USART *drvHandler,
|
||||
ARM_POWER_STATE powerMode,
|
||||
uint32_t settings,
|
||||
uint32_t baudRate,
|
||||
ARM_USART_SignalEvent_t cb_event)
|
||||
{
|
||||
if(drvHandler)
|
||||
{
|
||||
drvHandler->Initialize(cb_event);
|
||||
drvHandler->PowerControl(powerMode);
|
||||
drvHandler->Control(settings, baudRate);
|
||||
}
|
||||
}
|
||||
|
||||
void BSP_DeinitUartDriver(ARM_DRIVER_USART *drvHandler)
|
||||
{
|
||||
if(drvHandler)
|
||||
{
|
||||
drvHandler->PowerControl(ARM_POWER_OFF);
|
||||
drvHandler->Uninitialize();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined ( __GNUC__ )
|
||||
|
||||
/*
|
||||
* retarget for _write implementation
|
||||
* Parameter: ch: character will be out
|
||||
*/
|
||||
int io_putchar(int ch)
|
||||
{
|
||||
if (UsartPrintHandle != NULL)
|
||||
UsartPrintHandle->SendPolling((uint8_t*)&ch, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* retarget for _read implementation
|
||||
* Parameter: ch: character will be read
|
||||
*/
|
||||
int io_getchar()
|
||||
{
|
||||
uint8_t ch = 0;
|
||||
if (UsartPrintHandle != NULL)
|
||||
UsartPrintHandle->Receive(&ch, 1);
|
||||
return (ch);
|
||||
}
|
||||
|
||||
|
||||
int fgetc(FILE *f)
|
||||
{
|
||||
uint8_t ch = 0;
|
||||
if (UsartPrintHandle != NULL)
|
||||
UsartPrintHandle->Receive(&ch, 1);
|
||||
return (ch);
|
||||
}
|
||||
|
||||
__attribute__((weak,noreturn))
|
||||
void __aeabi_assert (const char *expr, const char *file, int line) {
|
||||
printf("Assert, expr:%s, file: %s, line: %d\r\n", expr, file, line);
|
||||
while(1);
|
||||
}
|
||||
|
||||
|
||||
void __assert_func(const char *filename, int line, const char *assert_func, const char *expr)
|
||||
{
|
||||
for(uint8_t i = 0; i<5; i++)
|
||||
{
|
||||
uniLogFlushOut();
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, assert_func_1, P_ERROR, "Assert, expr:%s, file: %s, line: %d\r\n", expr, filename, line);
|
||||
}
|
||||
while(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#elif defined (__CC_ARM)
|
||||
|
||||
/*
|
||||
* retarget for printf implementation
|
||||
* Parameter: ch: character will be out
|
||||
* f: not used
|
||||
*/
|
||||
int fputc(int ch, FILE *f)
|
||||
{
|
||||
if (UsartPrintHandle != NULL)
|
||||
UsartPrintHandle->SendPolling((uint8_t*)&ch,1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* retarget for scanf implementation
|
||||
* Parameter: f: not used
|
||||
*/
|
||||
int fgetc(FILE *f)
|
||||
{
|
||||
uint8_t ch = 0;
|
||||
if (UsartPrintHandle != NULL)
|
||||
UsartPrintHandle->Receive(&ch,1);
|
||||
return (ch);
|
||||
}
|
||||
|
||||
__attribute__((weak,noreturn))
|
||||
void __aeabi_assert (const char *expr, const char *file, int line) {
|
||||
printf("Assert, expr:%s, file: %s, line: %d\r\n", expr, file, line);
|
||||
while(1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
uint32_t GET_PMU_RAWFLASH_OFFSET(void)
|
||||
{
|
||||
return FLASH_MEM_BACKUP_ADDR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setOSState(uint8_t state)
|
||||
{
|
||||
OSState = state;
|
||||
}
|
||||
|
||||
PLAT_PA_RAMCODE uint8_t getOSState(void) //1 os started. 0 no OS or OS not started yet
|
||||
{
|
||||
return OSState;
|
||||
}
|
||||
|
||||
|
||||
uint8_t* getBuildInfo(void)
|
||||
{
|
||||
return (uint8_t *)BSP_HEADER;
|
||||
}
|
||||
|
||||
uint8_t* getVersionInfo(void)
|
||||
{
|
||||
return (uint8_t *)VERSION_INFO;
|
||||
}
|
||||
|
||||
uint8_t* getATIVersionInfo(void)
|
||||
{
|
||||
return (uint8_t *)ATI_VERSION_INFO;
|
||||
}
|
||||
|
||||
//move here since this is an common and opensource place
|
||||
uint8_t* getDebugDVersion(void)
|
||||
{
|
||||
return (uint8_t*)DB_VERSION_UNIQ_ID;
|
||||
}
|
||||
|
||||
extern void excepDump(uint32_t* start, uint32_t len);
|
||||
|
||||
void cpCoreRegsDumpCheckHook(void)
|
||||
{
|
||||
excepDump((uint32_t*)0x4f000000, 40);
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) uint32_t getUnilogUartPort(void)
|
||||
{
|
||||
return UART_0_FOR_UNILOG; // Swith to UART_x_FOR_UNILOG if need to use other uart for unilog
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) void getUnilogRamLogBuff(uint32_t *addr, uint32_t *len)
|
||||
{
|
||||
#ifdef FEATURE_EXCEPTION_FLASH_DUMP_ENABLE
|
||||
ecGetUnilogDumpAddrAndLen(addr, len);
|
||||
#else
|
||||
*addr = 0; // suggest to be 16 bytes aligned, note this area shall not be initialized in boot phase
|
||||
*len = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void setUartBaudRate(uint8_t idx, uint32_t baudRate)
|
||||
{
|
||||
gUartBaudrate[idx] = baudRate;
|
||||
|
||||
ECPLAT_PRINTF(UNILOG_PMU, setUartBaudRate_1, P_WARNING, "Set BaudRate = %d, %d, %d", gUartBaudrate[0], gUartBaudrate[1], gUartBaudrate[2]);
|
||||
}
|
||||
|
||||
|
||||
void FLASH_appRead(uint8_t *pData, uint32_t ReadAddr, uint32_t Size)
|
||||
{
|
||||
uint32_t numOfReadTrunk = 0, i=0;
|
||||
uint32_t waitLoop =0;
|
||||
|
||||
numOfReadTrunk = (Size/FLASH_READ_GRANT_SIZE);
|
||||
if(Size <= FLASH_READ_GRANT_SIZE)
|
||||
{
|
||||
FLASH_XIPRead(pData, ReadAddr, Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0; i<numOfReadTrunk; i++)
|
||||
{
|
||||
while(ShareInfoAPGetCPBusyFlag() == 1)
|
||||
{
|
||||
delay_us(1);
|
||||
waitLoop ++;
|
||||
if(waitLoop >=FLASH_READ_MAX_DELAY)
|
||||
{
|
||||
waitLoop = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
FLASH_XIPRead(pData+i*FLASH_READ_GRANT_SIZE, ReadAddr+i*FLASH_READ_GRANT_SIZE, FLASH_READ_GRANT_SIZE);
|
||||
|
||||
}
|
||||
if((Size - i*FLASH_READ_GRANT_SIZE) != 0)
|
||||
{
|
||||
while(ShareInfoAPGetCPBusyFlag() == 1)
|
||||
{
|
||||
delay_us(1);
|
||||
waitLoop ++;
|
||||
if(waitLoop >=FLASH_READ_MAX_DELAY)
|
||||
{
|
||||
waitLoop = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
FLASH_XIPRead(pData+i*FLASH_READ_GRANT_SIZE, ReadAddr+i*FLASH_READ_GRANT_SIZE, Size-i*FLASH_READ_GRANT_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn bool getCPWakeupType(void)
|
||||
\brief wakeup cp in polling mode or int mode
|
||||
in polling mode interrupt mask for 700us at most which may cause uart fifo overflow @ 921600.
|
||||
in int mode, interrupt mask for less than 200us
|
||||
\returns true: cp wakeup in int mode false: cp wakeup in polling mode
|
||||
*/
|
||||
bool getCPWakeupType(void) // true: cp wakeup in int mode false: cp wakeup in polling mode
|
||||
{
|
||||
#if 0 // just an example for customer to enable int mode
|
||||
if((gUartBaudrate[0] == 921600) || (gUartBaudrate[1] == 921600) || (gUartBaudrate[2] == 921600))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t getAPFlashLoadAddr(void)
|
||||
{
|
||||
return AP_FLASH_LOAD_ADDR;
|
||||
}
|
||||
|
||||
/**
|
||||
\fn void apmuNeedSlpWaitTimeInWakeupFlow(bool *bUartDelay, bool *bSlp1ExtIntDelay)
|
||||
\brief give pmu module information to restart slpWaitTime in pmu flow
|
||||
\param[out] bUartDelay: give a result to pmu module whether we need restart sleep wait timer when, (1)sleep failed with uart pending in all sleep mode (2)receive uart in sleep1 wakeup flow
|
||||
\param[out] bSlp1ExtIntDelay: give a result to pmu module whether we need restart sleep wait timer when, (1) wakeup from sleep1 with external int pending
|
||||
for sleep2/hib mode, restart slpWaitTime in BSP_CustomInit
|
||||
\returns void
|
||||
*/
|
||||
void apmuNeedSlpWaitTimeInWakeupFlow(bool *bUartDelay, bool *bSlp1ExtIntDelay)
|
||||
{
|
||||
uint32_t xic0_latch = XIC_LatchIRQ(APXIC_0);
|
||||
slpManWakeSrc_e wakeSrc = slpManGetWakeupSrc();
|
||||
|
||||
*bUartDelay = true;
|
||||
*bSlp1ExtIntDelay = false;
|
||||
|
||||
if((xic0_latch & (1<<(PXIC0_UART2_IRQn-32))) == 0)
|
||||
{
|
||||
if((xic0_latch & (1<<(PXIC0_UART1_IRQn-32))) == 0)
|
||||
{
|
||||
if((xic0_latch & (1<<(PXIC0_UART0_IRQn-32))) == 0)
|
||||
{
|
||||
*bUartDelay = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if((WAKEUP_FROM_PAD == wakeSrc) || (WAKEUP_FROM_LPUART == wakeSrc))
|
||||
{
|
||||
*bSlp1ExtIntDelay = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef UINILOG_FEATURE_ENABLE
|
||||
/**
|
||||
\fn void logToolCommandHandle(uint8_t *atcmd_buffer, uint32_t len)
|
||||
\brief handle downlink command sent from unilog tool EPAT
|
||||
if need to handle more command in future, add command-handler table
|
||||
\param[in] event UART event, note used in this function
|
||||
\param[in] cmd_buffer command received from UART
|
||||
\param[in] len command length
|
||||
\returns void
|
||||
*/
|
||||
void logToolCommandHandle(uint32_t event, uint8_t *cmd_buffer, uint32_t len)
|
||||
{
|
||||
(void)event;
|
||||
|
||||
uint8_t * LogDbVserion=getDebugDVersion();
|
||||
|
||||
if(ec_strnstr((const char *)cmd_buffer, "^logversion", len))
|
||||
{
|
||||
|
||||
ECPLAT_PRINTF(UNILOG_PLA_INTERNAL_CMD, get_log_version, P_SIG, "LOGVERSION:%s",LogDbVserion);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ECPLAT_PRINTF(UNILOG_PLA_STRING, get_log_version_1, P_ERROR, "%s", "invalid command from EPAT");
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* unilog entity is removed for the reason of BSP small image.
|
||||
* for more implementation details, pls refer to
|
||||
* gCustSerlEntity[CUST_ENTITY_UNILOG] in ccio_provider.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* set unilog uart port
|
||||
* Parameter: port: for unilog
|
||||
* Parameter: baudrate: uart baudrate
|
||||
*/
|
||||
void SetUnilogUart(usart_port_t port, uint32_t baudrate, bool startRecv)
|
||||
{
|
||||
ARM_POWER_STATE powerMode = ARM_POWER_FULL;
|
||||
uint32_t ctrlSetting = ARM_USART_MODE_ASYNCHRONOUS | ARM_USART_DATA_BITS_8 | \
|
||||
ARM_USART_PARITY_NONE | ARM_USART_STOP_BITS_1 | \
|
||||
ARM_USART_FLOW_CONTROL_NONE;
|
||||
|
||||
if (port == PORT_USART_0)
|
||||
{
|
||||
#if (RTE_UART0)
|
||||
UsartUnilogHandle = &CREATE_SYMBOL(Driver_USART, 0);
|
||||
#endif
|
||||
}
|
||||
else if (port == PORT_USART_1)
|
||||
{
|
||||
#if (RTE_UART1)
|
||||
UsartUnilogHandle = &CREATE_SYMBOL(Driver_USART, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (UsartUnilogHandle == NULL) return;
|
||||
|
||||
#ifdef FEATURE_CCIO_ENABLE
|
||||
UartDevConf_t uartDevConf;
|
||||
UartHwConf_t *uartHwConf = &uartDevConf.hwConf;
|
||||
|
||||
memset(&uartDevConf, 0, sizeof(UartDevConf_t));
|
||||
|
||||
uartHwConf->powerMode = powerMode;
|
||||
uartHwConf->ctrlSetting = ctrlSetting;
|
||||
uartHwConf->baudRate = baudrate;
|
||||
|
||||
uartDevConf.drvHandler = UsartUnilogHandle;
|
||||
uartDevConf.mainUsage = CSIO_DT_DIAG;
|
||||
uartDevConf.speedType = CCIO_ST_HIGH;
|
||||
uartDevConf.rbufFlags = CUST_RBUF_FOR_DIAG;
|
||||
if(startRecv)
|
||||
{
|
||||
uartDevConf.bmCreateFlag = CCIO_TASK_FLAG_RX;
|
||||
}
|
||||
else
|
||||
{
|
||||
uartDevConf.bmCreateFlag = CCIO_TASK_FLAG_NONE;
|
||||
}
|
||||
|
||||
uartDevCreate(port, &uartDevConf);
|
||||
#else
|
||||
BSP_InitUartDriver(UsartUnilogHandle, powerMode, ctrlSetting, baudrate, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void GPR_rmiErrDetectIsr(void)
|
||||
{
|
||||
volatile uint32_t rmiErrAddr;
|
||||
rmiErrAddr = GPR_RmiErrAddrGet();
|
||||
|
||||
ECPLAT_PRINTF(UNILOG_PMU, GPR_rmiErrDetectIsr_1, P_WARNING, "Rmi Err Detect Address=0x%x", rmiErrAddr);
|
||||
}
|
||||
|
||||
|
||||
void GPR_rmiErrDetectInit(void)
|
||||
{
|
||||
XIC_SetVector(PXIC0_RMIIF_TOERR_IRQn, &GPR_rmiErrDetectIsr);
|
||||
XIC_EnableIRQ(PXIC0_RMIIF_TOERR_IRQn);
|
||||
GPR_RmiErrCfg(true);
|
||||
}
|
||||
|
||||
|
||||
void FlushUnilogOutput(void)
|
||||
{
|
||||
uniLogFlushOut();
|
||||
|
||||
if(UsartUnilogHandle == NULL)
|
||||
return;
|
||||
UsartUnilogHandle->Control(ARM_USART_CONTROL_FLUSH_TX, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void BSP_CommonInit(void)
|
||||
{
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
PAD_driverInit();
|
||||
|
||||
GPR_initialize();
|
||||
|
||||
trimAdcSetGolbalVar();
|
||||
|
||||
#if defined CHIP_EC718 || defined CHIP_EC716
|
||||
trimLdoAIOVadjSetGolbalVar();
|
||||
#endif
|
||||
|
||||
#if defined CHIP_EC718
|
||||
trimVadjVbatSenseSetGolbalVar();
|
||||
#endif
|
||||
|
||||
apmuInit();
|
||||
|
||||
//interrupt config
|
||||
IC_PowupInit();
|
||||
|
||||
if(apmuGetAPBootFlag() == 0) // power on
|
||||
{
|
||||
apmuSetCPFastBoot(false); // set cp fast boot in case of cp dap wakeup
|
||||
}
|
||||
|
||||
cpADCInit(); // enable adc ref output, need stable time
|
||||
|
||||
GPR_rmiErrDetectInit();
|
||||
|
||||
BOOT_TIMESTAMP_SET(1, 3);
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,172 +0,0 @@
|
||||
#include "cameraDrv.h"
|
||||
#include "sctdef.h"
|
||||
|
||||
AP_PLAT_COMMON_DATA camI2cCfg_t gc6153_1sdrRegInfo[] =
|
||||
{
|
||||
// SYS
|
||||
{0xfe, 0xa0},
|
||||
{0xfe, 0xa0},
|
||||
{0xfe, 0xa0},
|
||||
{0xfa, 0x11},
|
||||
{0xfc, 0x00},
|
||||
{0xf6, 0x00},
|
||||
{0xfc, 0x12},
|
||||
|
||||
// ANALOG & CISCTL
|
||||
{0xfe, 0x00},
|
||||
{0x01, 0x40},
|
||||
{0x02, 0x12},
|
||||
{0x0d, 0x40},
|
||||
{0x14, 0x7c}, // 0x7e
|
||||
{0x16, 0x05}, // 0x05
|
||||
{0x17, 0x18}, // 0x18
|
||||
{0x1c, 0x31},
|
||||
{0x1d, 0xbb},
|
||||
{0x1f, 0x3f},
|
||||
{0x73, 0x20},
|
||||
{0x74, 0x71},
|
||||
{0x77, 0x22},
|
||||
{0x7a, 0x08},
|
||||
{0x11, 0x18},
|
||||
{0x13, 0x48},
|
||||
{0x12, 0xc8},
|
||||
{0x70, 0xc8},
|
||||
{0x7b, 0x18},
|
||||
{0x7d, 0x30},
|
||||
{0x7e, 0x02},
|
||||
|
||||
{0xfe, 0x10},
|
||||
{0xfe, 0x00},
|
||||
{0xfe, 0x00},
|
||||
{0xfe, 0x00},
|
||||
{0xfe, 0x00},
|
||||
{0xfe, 0x00},
|
||||
{0xfe, 0x10},
|
||||
{0xfe, 0x00},
|
||||
|
||||
{0x49, 0x61},
|
||||
{0x4a, 0x40},
|
||||
{0x4b, 0x58},
|
||||
|
||||
/*ISP*/
|
||||
{0xfe, 0x00},
|
||||
{0x39, 0x02},
|
||||
{0x3a, 0x80},
|
||||
{0x20, 0x7e},
|
||||
{0x26, 0xa7},
|
||||
|
||||
/*BLK*/
|
||||
{0x33, 0x10},
|
||||
{0x37, 0x06},
|
||||
{0x2a, 0x21},
|
||||
|
||||
/*GAIN*/
|
||||
{0x3f, 0x16},
|
||||
|
||||
/*DNDD*/
|
||||
{0x52, 0xa6},
|
||||
{0x53, 0x81},
|
||||
{0x54, 0x43},
|
||||
{0x56, 0x78},
|
||||
{0x57, 0xaa},
|
||||
{0x58, 0xff},
|
||||
|
||||
/*ASDE*/
|
||||
{0x5b, 0x60},
|
||||
{0x5c, 0x50},
|
||||
{0xab, 0x2a},
|
||||
{0xac, 0xb5},
|
||||
|
||||
/*INTPEE*/
|
||||
{0x5e, 0x06},
|
||||
{0x5f, 0x06},
|
||||
{0x60, 0x44},
|
||||
{0x61, 0xff},
|
||||
{0x62, 0x69},
|
||||
{0x63, 0x13},
|
||||
|
||||
/*CC*/
|
||||
{0x65, 0x13},
|
||||
{0x66, 0x26},
|
||||
{0x67, 0x07},
|
||||
{0x68, 0xf5},
|
||||
{0x69, 0xea},
|
||||
{0x6a, 0x21},
|
||||
{0x6b, 0x21},
|
||||
{0x6c, 0xe4},
|
||||
{0x6d, 0xfb},
|
||||
|
||||
/*YCP*/
|
||||
{0x81, 0x3b}, // 0
|
||||
{0x82, 0x3b}, // 0 : uyvy コレーラ
|
||||
{0x83, 0x4b},
|
||||
{0x84, 0x90},
|
||||
{0x86, 0xf0},
|
||||
{0x87, 0x1d},
|
||||
{0x88, 0x16},
|
||||
{0x8d, 0x74},
|
||||
{0x8e, 0x25},
|
||||
|
||||
/*AEC*/
|
||||
{0x90, 0x36},
|
||||
{0x92, 0x43},
|
||||
{0x9d, 0x32},
|
||||
{0x9e, 0x81},
|
||||
{0x9f, 0xf4},
|
||||
{0xa0, 0xa0},
|
||||
{0xa1, 0x04},
|
||||
{0xa3, 0x2d},
|
||||
{0xa4, 0x01},
|
||||
|
||||
/*AWB*/
|
||||
{0xb0, 0xc2},
|
||||
{0xb1, 0x1e},
|
||||
{0xb2, 0x10},
|
||||
{0xb3, 0x20},
|
||||
{0xb4, 0x2d},
|
||||
{0xb5, 0x1b},
|
||||
{0xb6, 0x2e},
|
||||
{0xb8, 0x13},
|
||||
{0xba, 0x60},
|
||||
{0xbb, 0x62},
|
||||
{0xbd, 0x78},
|
||||
{0xbe, 0x55},
|
||||
{0xbf, 0xa0},
|
||||
{0xc4, 0xe7},
|
||||
{0xc5, 0x15},
|
||||
{0xc6, 0x16},
|
||||
{0xc7, 0xeb},
|
||||
{0xc8, 0xe4},
|
||||
{0xc9, 0x16},
|
||||
{0xca, 0x16},
|
||||
{0xcb, 0xe9},
|
||||
{0x22, 0xf8},
|
||||
|
||||
/*SPI*/
|
||||
{0xfe, 0x02},
|
||||
{0x01, 0x01},
|
||||
{0x02, 0x02},
|
||||
{0x03, 0x20},
|
||||
{0x04, 0x20},
|
||||
{0x0a, 0x00},
|
||||
{0x13, 0x10},
|
||||
{0x24, 0x00},
|
||||
{0x28, 0x03},
|
||||
{0xfe, 0x00},
|
||||
|
||||
/*OUTPUT*/
|
||||
{0xf2, 0x03},
|
||||
{0xfe, 0x00},
|
||||
};
|
||||
|
||||
uint16_t gc6153GetRegCnt(char* regName)
|
||||
{
|
||||
if (strcmp(regName, "gc6153_1sdr") == 0)
|
||||
{
|
||||
return (sizeof(gc6153_1sdrRegInfo) / sizeof(gc6153_1sdrRegInfo[0]));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,669 +0,0 @@
|
||||
#include "cameraDrv.h"
|
||||
#include "hal_i2c.h"
|
||||
#include "sctdef.h"
|
||||
|
||||
extern cspiDrvInterface_t cspiDrvInterface0;
|
||||
extern cspiDrvInterface_t cspiDrvInterface1;
|
||||
|
||||
extern camI2cCfg_t sp0A39Cfg[];
|
||||
extern camI2cCfg_t sp0821Cfg[];
|
||||
extern camI2cCfg_t gc6123Cfg[];
|
||||
extern camI2cCfg_t gc032ACfg[];
|
||||
extern camI2cCfg_t bf30a2Cfg[];
|
||||
extern cspiCtrl_t cspiCtrl;
|
||||
extern cspiBinaryCtrl_t cspiBinaryCtrl;
|
||||
extern cspiIntCtrl_t cspiIntCtrl;
|
||||
extern cspiDataFmt_t cspiDataFmt;
|
||||
extern cspiFrameProcLspi_t cspiFrameProcLspi;
|
||||
|
||||
#define EIGEN_CSPI(n) ((CSPI_TypeDef *) (MP_USP0_BASE_ADDR + 0x1000*n))
|
||||
AP_PLAT_COMMON_BSS static camErrCb camErrStatsFunc;
|
||||
AP_PLAT_COMMON_BSS static cspiCbEvent_fn userCamUspCb = NULL;
|
||||
AP_PLAT_COMMON_BSS static cspiCbEvent_fn userCamDmaCb = NULL;
|
||||
CameraBuf_t *camBuffBak;
|
||||
void camDmaCb(uint32_t dmastatus);
|
||||
|
||||
#if (CAMERA_ENABLE_GC032A)
|
||||
#if (GC032A_2SDR)
|
||||
char* regName = "gc032a_2sdr";
|
||||
#elif (GC032A_1SDR)
|
||||
char* regName = "gc032a_1sdr";
|
||||
#elif (GC032A_2DDR)
|
||||
char* regName = "gc032a_2ddr";
|
||||
#endif
|
||||
#elif (CAMERA_ENABLE_GC6153)
|
||||
#if (GC6153_1SDR)
|
||||
char* regName = "gc6153_1sdr";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
AP_PLAT_COMMON_BSS static uint8_t slaveAddr;
|
||||
AP_PLAT_COMMON_BSS static uint16_t regCnt;
|
||||
AP_PLAT_COMMON_BSS static camI2cCfg_t* regInfo = NULL;
|
||||
|
||||
#if (RTE_CSPI1 == 1)
|
||||
AP_PLAT_COMMON_DATA static cspiDrvInterface_t *cspiDrv = &CREATE_SYMBOL(cspiDrvInterface, 1);
|
||||
#else
|
||||
AP_PLAT_COMMON_DATA static cspiDrvInterface_t *cspiDrv = &CREATE_SYMBOL(cspiDrvInterface, 0);
|
||||
#endif
|
||||
extern void delay_us(uint32_t us);
|
||||
|
||||
void findRegInfo(char* regName, uint8_t* slaveAddr, uint16_t* regCnt, camI2cCfg_t** regInfo)
|
||||
{
|
||||
if (strcmp(regName, "gc032a_2sdr") == 0)
|
||||
{
|
||||
extern camI2cCfg_t gc032A_2sdrRegInfo[];
|
||||
*regInfo = gc032A_2sdrRegInfo;
|
||||
*slaveAddr = GC032A_I2C_ADDR;
|
||||
*regCnt = gc032aGetRegCnt(regName);
|
||||
}
|
||||
else if (strcmp(regName, "gc032a_1sdr") == 0)
|
||||
{
|
||||
extern camI2cCfg_t gc032A_1sdrRegInfo[];
|
||||
*regInfo = gc032A_1sdrRegInfo;
|
||||
*slaveAddr = GC032A_I2C_ADDR;
|
||||
*regCnt = gc032aGetRegCnt(regName);
|
||||
}
|
||||
else if (strcmp(regName, "gc032a_2ddr") == 0)
|
||||
{
|
||||
extern camI2cCfg_t gc032A_2ddrRegInfo[];
|
||||
*regInfo = gc032A_2ddrRegInfo;
|
||||
*slaveAddr = GC032A_I2C_ADDR;
|
||||
*regCnt = gc032aGetRegCnt(regName);
|
||||
}
|
||||
else if (strcmp(regName, "gc6153_1sdr") == 0)
|
||||
{
|
||||
extern camI2cCfg_t gc6153_1sdrRegInfo[];
|
||||
*regInfo = gc6153_1sdrRegInfo;
|
||||
*slaveAddr = GC6153_I2C_ADDR;
|
||||
*regCnt = gc6153GetRegCnt(regName);
|
||||
}
|
||||
}
|
||||
|
||||
void camI2cInit()
|
||||
{
|
||||
halI2cInit(true);
|
||||
|
||||
// Backup some info about this sensor
|
||||
findRegInfo(regName, &slaveAddr, ®Cnt, ®Info);
|
||||
}
|
||||
|
||||
void camI2cWrite(uint8_t slaveAddr, uint8_t regAddr, uint8_t regData, uint32_t num)
|
||||
{
|
||||
uint8_t tempBuffer[2];
|
||||
|
||||
tempBuffer[0] = regAddr;
|
||||
tempBuffer[1] = regData;
|
||||
|
||||
uint8_t rxNack = 0;
|
||||
halI2cWrite(slaveAddr, tempBuffer, num, &rxNack, true);
|
||||
|
||||
if (rxNack == 1)
|
||||
{
|
||||
// if fail , write again
|
||||
halI2cWrite(slaveAddr, tempBuffer, num, &rxNack, true);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t camI2cRead(uint8_t slaveAddr, uint8_t regAddr)
|
||||
{
|
||||
uint8_t readData;
|
||||
halI2cRead(slaveAddr, regAddr, &readData, true);
|
||||
return readData;
|
||||
}
|
||||
|
||||
uint8_t camReadReg(uint8_t regAddr)
|
||||
{
|
||||
uint8_t recvData;
|
||||
|
||||
recvData = camI2cRead(slaveAddr, regAddr);
|
||||
return recvData;
|
||||
}
|
||||
|
||||
void camWriteReg(camI2cCfg_t* regInfo)
|
||||
{
|
||||
camI2cWrite(slaveAddr, regInfo->regAddr, regInfo->regVal, 2);
|
||||
}
|
||||
|
||||
void camRegCfg()
|
||||
{
|
||||
//uint8_t dataRead;
|
||||
|
||||
camI2cInit();
|
||||
|
||||
// Configure all the registers about this sensor
|
||||
for (int i=0; i < regCnt; i++)
|
||||
{
|
||||
camI2cWrite(slaveAddr, regInfo[i].regAddr, regInfo[i].regVal, 2);
|
||||
delay_us(10000); // delay 10ms
|
||||
|
||||
#if 0
|
||||
dataRead = camI2cRead(slaveAddr, regInfo[i].regAddr);
|
||||
printf("reg addr=0x%02x, reg val=0x%02x\n", regInfo[i].regAddr, dataRead);
|
||||
delay_us(15000);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void camInterfaceCfg(camParamCfg_t* config)
|
||||
{
|
||||
cspiDataFmt.endianMode = config->endianMode;
|
||||
cspiCtrl.rxWid = config->wireNum;
|
||||
cspiCtrl.rxdSeq = config->rxSeq;
|
||||
cspiCtrl.cpol = config->cpol;
|
||||
cspiCtrl.cpha = config->cpha;
|
||||
cspiCtrl.ddrMode = config->ddrMode;
|
||||
cspiBinaryCtrl.wordIdSeq = config->wordIdSeq;
|
||||
cspiBinaryCtrl.dummyAllowed = config->dummyAllowed;
|
||||
cspiCtrl.fillYonly = config->yOnly;
|
||||
cspiCtrl.rowScaleRatio = config->rowScaleRatio;
|
||||
cspiCtrl.colScaleRatio = config->colScaleRatio;
|
||||
cspiCtrl.scaleBytes = config->scaleBytes;
|
||||
}
|
||||
|
||||
void camSetMemAddr(uint32_t dataAddr)
|
||||
{
|
||||
cspiDrv->ctrl(CSPI_CTRL_MEM_ADDR , dataAddr); // register the recv memory
|
||||
}
|
||||
|
||||
#if (ENABLE_CAMERA_LDO == 1)
|
||||
void camPowerOn(uint8_t ioInitVal)
|
||||
{
|
||||
PadConfig_t padConfig;
|
||||
PAD_getDefaultConfig(&padConfig);
|
||||
padConfig.pullUpEnable = PAD_PULL_UP_DISABLE;
|
||||
padConfig.pullDownEnable = PAD_PULL_DOWN_DISABLE;
|
||||
padConfig.mux = CAM_PD_PAD_ALT_FUNC;
|
||||
PAD_setPinConfig(CAM_PD_PAD_INDEX, &padConfig);
|
||||
|
||||
GpioPinConfig_t config;
|
||||
config.pinDirection = GPIO_DIRECTION_OUTPUT;
|
||||
config.misc.initOutput = ioInitVal;
|
||||
GPIO_pinConfig(CAM_PD_GPIO_INSTANCE, CAM_PD_GPIO_PIN, &config);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void camUspCb()
|
||||
{
|
||||
uint32_t cspiStatus;
|
||||
|
||||
cspiStatus = camGetCspiStats();
|
||||
|
||||
if (cspiStatus & ICL_STATS_FRAME_END_Msk)
|
||||
{
|
||||
CSPI1->STAS |= 0x3<<3;
|
||||
CSPI1->STAS |= 0xf<<7;
|
||||
CSPI1->STAS |= 0x3<<11;
|
||||
CSPI1->DMACTL |= 1<<24;
|
||||
|
||||
if (userCamUspCb)
|
||||
{
|
||||
userCamUspCb(cspiStatus);
|
||||
}
|
||||
|
||||
CSPI1->CBCTRL |= 2<<25;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void camInit(void* dataAddr, cspiCbEvent_fn uspCb, void* dmaCb,camErrCb errCb)
|
||||
{
|
||||
camResolution_e camResolution;
|
||||
camParamCfg_t camParamCfg;
|
||||
IRQn_Type irqNum;
|
||||
|
||||
#if (RTE_CSPI0 == 1)
|
||||
irqNum = PXIC0_USP0_IRQn;
|
||||
#elif (RTE_CSPI1 == 1)
|
||||
irqNum = PXIC0_USP1_IRQn;
|
||||
#endif
|
||||
|
||||
camBuffBak = dataAddr;
|
||||
camBuffBak[0].enableForCamera = 1;
|
||||
camBuffBak[0].enableForUsr = 0;
|
||||
camBuffBak[0].workingForUsr = 0;
|
||||
|
||||
if(uspCb)
|
||||
{
|
||||
userCamUspCb = uspCb;
|
||||
}
|
||||
|
||||
if(errCb)
|
||||
{
|
||||
camErrStatsFunc = errCb;
|
||||
}
|
||||
|
||||
if(dmaCb)
|
||||
{
|
||||
userCamDmaCb = dmaCb;
|
||||
}
|
||||
|
||||
XIC_SetVector(irqNum, camUspCb);
|
||||
XIC_EnableIRQ(irqNum);
|
||||
|
||||
#if (CAMERA_ENABLE_GC032A)
|
||||
#if (GC032A_2SDR)
|
||||
camParamCfg.wireNum = WIRE_2;
|
||||
camParamCfg.endianMode = CAM_LSB_MODE;
|
||||
camParamCfg.rxSeq = SEQ_0;
|
||||
camParamCfg.cpha = 0;
|
||||
camParamCfg.cpol = 0;
|
||||
camParamCfg.ddrMode = 0;
|
||||
camParamCfg.wordIdSeq = 0;
|
||||
camParamCfg.dummyAllowed = 0;
|
||||
camResolution = CAM_CHAIN_COUNT;
|
||||
#elif (GC032A_1SDR)
|
||||
camParamCfg.wireNum = WIRE_1;
|
||||
camParamCfg.endianMode = CAM_LSB_MODE;
|
||||
camParamCfg.rxSeq = SEQ_0;
|
||||
camParamCfg.cpha = 0;
|
||||
camParamCfg.cpol = 0;
|
||||
camParamCfg.ddrMode = 0;
|
||||
camParamCfg.wordIdSeq = 0;
|
||||
camParamCfg.dummyAllowed = 0;
|
||||
camResolution = CAM_CHAIN_COUNT;
|
||||
#elif (GC032A_2DDR)
|
||||
camParamCfg.wireNum = WIRE_2;
|
||||
camParamCfg.endianMode = CAM_MSB_MODE;
|
||||
camParamCfg.rxSeq = SEQ_1;
|
||||
camParamCfg.cpha = 1;
|
||||
camParamCfg.cpol = 0;
|
||||
camParamCfg.ddrMode = 1;
|
||||
camParamCfg.wordIdSeq = 1;
|
||||
camParamCfg.dummyAllowed = 1;
|
||||
camResolution = CAM_CHAIN_COUNT;
|
||||
#endif
|
||||
|
||||
if (CAM_CHAIN_COUNT == CAM_8W_COLOR)
|
||||
{
|
||||
camParamCfg.yOnly = 0;
|
||||
camParamCfg.rowScaleRatio = 1;
|
||||
camParamCfg.colScaleRatio = 1;
|
||||
camParamCfg.scaleBytes = 3;
|
||||
}
|
||||
else if (CAM_CHAIN_COUNT == CAM_8W_Y)
|
||||
{
|
||||
camParamCfg.yOnly = 1;
|
||||
camParamCfg.rowScaleRatio = 1;
|
||||
camParamCfg.colScaleRatio = 1;
|
||||
camParamCfg.scaleBytes = 1;
|
||||
}
|
||||
else if (CAM_CHAIN_COUNT == CAM_30W_Y)
|
||||
{
|
||||
camParamCfg.yOnly = 1;
|
||||
camParamCfg.rowScaleRatio = 0;
|
||||
camParamCfg.colScaleRatio = 0;
|
||||
camParamCfg.scaleBytes = 0;
|
||||
}
|
||||
else if (CAM_CHAIN_COUNT == CAM_30W_COLOR)
|
||||
{
|
||||
camParamCfg.yOnly = 0;
|
||||
camParamCfg.rowScaleRatio = 0;
|
||||
camParamCfg.colScaleRatio = 0;
|
||||
camParamCfg.scaleBytes = 0;
|
||||
}
|
||||
#elif (CAMERA_ENABLE_GC6153)
|
||||
#if (GC6153_1SDR)
|
||||
camParamCfg.wireNum = WIRE_1;
|
||||
#endif
|
||||
camParamCfg.endianMode = CAM_LSB_MODE;
|
||||
camParamCfg.rxSeq = SEQ_1;
|
||||
camParamCfg.cpha = 1;
|
||||
camParamCfg.cpol = 0;
|
||||
camParamCfg.yOnly = 1;
|
||||
camParamCfg.ddrMode = 0;
|
||||
camParamCfg.wordIdSeq = 0;
|
||||
camParamCfg.rowScaleRatio = 0;
|
||||
camParamCfg.colScaleRatio = 0;
|
||||
camParamCfg.scaleBytes = 0;
|
||||
camResolution = CAM_CHAIN_COUNT;
|
||||
#endif
|
||||
|
||||
camInterfaceCfg(&camParamCfg);
|
||||
|
||||
cspiDrv->ctrl(CSPI_CTRL_MEM_ADDR , (uint32_t)dataAddr); // register the recv memory
|
||||
cspiDrv->powerCtrl(CSPI_POWER_FULL);
|
||||
cspiDrv->init(camDmaCb);
|
||||
cspiDrv->ctrl(CSPI_CTRL_DATA_FORMAT , 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_RXTOR , 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_FRAME_INFO0 , 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_INT_CTRL , 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_CSPICTL , 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_DMA_CTRL , 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_RESOLUTION_SET , camResolution);
|
||||
cspiDrv->ctrl(CSPI_CTRL_BUS_SPEED, (camFrequence_e)CAM_25_5_M);
|
||||
cspiDrv->ctrl(CSPI_BINARY_CTRL, 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_AUTO_CG_CTRL, 0);
|
||||
cspiDrv->ctrl(CSPI_FRAME_PROC_LSPI, 0);
|
||||
cspiDrv->ctrl(CSPI_DELAY_CTRL, 0);
|
||||
}
|
||||
|
||||
void camStartStop(cspiStartStop_e startStop)
|
||||
{
|
||||
cspiDrv->ctrl(CSPI_CTRL_START_STOP , (uint32_t)startStop);
|
||||
}
|
||||
|
||||
void cspiStartIntEnable(cspiIntEnable_e intEnable)
|
||||
{
|
||||
if (intEnable)
|
||||
{
|
||||
cspiIntCtrl.frameStartIntEn |= intEnable;
|
||||
}
|
||||
else
|
||||
{
|
||||
cspiIntCtrl.frameStartIntEn &= intEnable;
|
||||
}
|
||||
cspiDrv->ctrl(CSPI_CTRL_INT_CTRL , 0); // cspi interrupt enable or disable
|
||||
}
|
||||
|
||||
void cspiEndIntEnable(cspiIntEnable_e endIntEnable)
|
||||
{
|
||||
if (endIntEnable)
|
||||
{
|
||||
cspiIntCtrl.frameEndIntEn |= endIntEnable;
|
||||
}
|
||||
else
|
||||
{
|
||||
cspiIntCtrl.frameEndIntEn &= endIntEnable;
|
||||
}
|
||||
|
||||
cspiDrv->ctrl(CSPI_CTRL_INT_CTRL , 0);
|
||||
}
|
||||
|
||||
void cspi2LspiEnable(uint8_t enable)
|
||||
{
|
||||
cspiFrameProcLspi.outEnLspi = enable;
|
||||
cspiDrv->ctrl(CSPI_FRAME_PROC_LSPI, 0);
|
||||
}
|
||||
|
||||
void camFlush()
|
||||
{
|
||||
cspiDrv->ctrl(CSPI_CTRL_FLUSH_RX_FIFO , 0);
|
||||
}
|
||||
|
||||
void camRegisterIRQ(cspiInstance_e instance, camIrq_fn irqCb)
|
||||
{
|
||||
IRQn_Type irqNum;
|
||||
|
||||
if (instance == CSPI_0)
|
||||
{
|
||||
irqNum = PXIC0_USP0_IRQn;
|
||||
}
|
||||
else
|
||||
{
|
||||
irqNum = PXIC0_USP1_IRQn;
|
||||
}
|
||||
|
||||
XIC_SetVector(irqNum, irqCb);
|
||||
XIC_EnableIRQ(irqNum);
|
||||
}
|
||||
|
||||
PLAT_FM_RAMCODE void camRecv(uint8_t * dataAddr)
|
||||
{
|
||||
cspiDrv->ctrl(CSPI_CTRL_MEM_ADDR , (uint32_t)dataAddr);
|
||||
cspiDrv->recv();
|
||||
}
|
||||
|
||||
uint32_t camGetCspiInt(cspiInstance_e instance)
|
||||
{
|
||||
return EIGEN_CSPI(instance)->INTCTL;
|
||||
}
|
||||
|
||||
void camClearIntStats(cspiInstance_e instance, uint32_t mask)
|
||||
{
|
||||
EIGEN_CSPI(instance)->STAS = mask;
|
||||
}
|
||||
|
||||
void camRegisterErrStatsCb(camErrCb errCb)
|
||||
{
|
||||
camErrStatsFunc = errCb;
|
||||
}
|
||||
|
||||
uint32_t camGetCspiStats()
|
||||
{
|
||||
uint32_t status = 0;
|
||||
|
||||
#if (RTE_CSPI1 == 1)
|
||||
status = EIGEN_CSPI(CSPI_1)->STAS;
|
||||
#else
|
||||
status = EIGEN_CSPI(CSPI_0)->STAS;
|
||||
#endif
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void camClearErrStats()
|
||||
{
|
||||
#if (RTE_CSPI == 1)
|
||||
CSPI1->STAS |= 0x3 << 3;
|
||||
CSPI1->STAS |= 0xf << 7;
|
||||
CSPI1->DMACTL |= 1 << 24;
|
||||
CSPI1->CBCTRL |= 2 << 25;
|
||||
#else
|
||||
CSPI0->STAS |= 0x3 << 3;
|
||||
CSPI0->STAS |= 0xf << 7;
|
||||
CSPI0->DMACTL |= 1 << 24;
|
||||
CSPI0->CBCTRL |= 2 << 25;
|
||||
#endif
|
||||
}
|
||||
|
||||
int camCheckErrStats()
|
||||
{
|
||||
uint32_t status = camGetCspiStats();
|
||||
|
||||
if ((status >> ICL_STATS_RX_OVERFLOW_Pos & 1) ||
|
||||
(status >> ICL_STATS_RX_DMA_ERR_Pos & 1) ||
|
||||
(status >> ICL_STATS_FS_ERR_Pos & 1)) {
|
||||
|
||||
if (camErrStatsFunc) {
|
||||
camErrStatsFunc(status);
|
||||
}
|
||||
|
||||
return -1; // has cspi error
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void camGpioPulseCfg(uint8_t padAddr, uint8_t pinInstance, uint8_t pinNum)
|
||||
{
|
||||
PadConfig_t padConfig;
|
||||
PAD_getDefaultConfig(&padConfig);
|
||||
|
||||
padConfig.mux = PAD_MUX_ALT0;
|
||||
PAD_setPinConfig(padAddr, &padConfig);
|
||||
|
||||
GpioPinConfig_t config;
|
||||
config.pinDirection = GPIO_DIRECTION_OUTPUT;
|
||||
config.misc.initOutput = 0;
|
||||
|
||||
GPIO_pinConfig(pinInstance, pinNum, &config);
|
||||
}
|
||||
|
||||
void camGpioPulse(uint8_t pinInstance, uint8_t pinNum, uint32_t pulseDurationUs, uint8_t initialState, bool needLoop)
|
||||
{
|
||||
GPIO_TypeDef *gpio = (GPIO_TypeDef*)(RMI_GPIO_BASE_ADDR + 0x1000*pinInstance);
|
||||
|
||||
if (needLoop)
|
||||
{
|
||||
// for test gpio is good or not
|
||||
while (1)
|
||||
{
|
||||
gpio->DATAOUT = ((~(1<<pinNum)) << 16) | (1<<pinNum);
|
||||
delay_us(pulseDurationUs);
|
||||
gpio->DATAOUT = ((~(1<<pinNum)) << 16);
|
||||
delay_us(pulseDurationUs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// inititalState: 0=low level; 1=high level
|
||||
if (initialState == 0)
|
||||
{
|
||||
// pulse 0->1
|
||||
gpio->DATAOUT = ((~(1<<pinNum)) << 16) | (1<<pinNum);
|
||||
delay_us(pulseDurationUs);
|
||||
gpio->DATAOUT = ((~(1<<pinNum)) << 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
// pulse 1->0
|
||||
gpio->DATAOUT = ((~(1<<pinNum)) << 16);
|
||||
delay_us(pulseDurationUs);
|
||||
gpio->DATAOUT = ((~(1<<pinNum)) << 16) | (1<<pinNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void camRegisterSlp1Cb(cspiSlp1Cb_fn cb)
|
||||
{
|
||||
cspiSlp1CbFn = cb;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
PLAT_PA_RAMCODE void timeRead(UINT32 *sysTime)
|
||||
{
|
||||
// T_TMU_BC_RD *bcRd = HW_TmuBcRd; 4f0700c4
|
||||
UINT32 mask;
|
||||
UINT32 hfnsfnshn;
|
||||
|
||||
mask = SaveAndSetIRQMask();
|
||||
// CLOCK_clockEnable(PCLK_TMU);
|
||||
|
||||
hfnsfnshn = *(uint32_t *)0x4f0700c4; // bcRd->dbg_bc_h;
|
||||
*sysTime = (hfnsfnshn >> 4) * 10 + (hfnsfnshn & 0xf);
|
||||
|
||||
// CLOCK_clockDisable(PCLK_TMU);
|
||||
RestoreIRQMask(mask);
|
||||
}
|
||||
|
||||
static uint8_t findNextCamBuf()
|
||||
{
|
||||
int bypassIndex = -1;
|
||||
uint8_t minIndex = 0;
|
||||
uint32_t minValue = 0;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (camBuffBak[i].workingForUsr == 1)
|
||||
{
|
||||
bypassIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
minIndex = (bypassIndex == 0) ? 1 : 0;
|
||||
minValue = camBuffBak[minIndex].timeStamp;
|
||||
|
||||
for (int i = (minIndex + 1); i < 3; i++)
|
||||
{
|
||||
if ((camBuffBak[i].timeStamp < minValue) && (camBuffBak[i].workingForUsr == 0))
|
||||
{
|
||||
minValue = camBuffBak[i].timeStamp;
|
||||
minIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
return minIndex;
|
||||
}
|
||||
|
||||
void camDmaCb(uint32_t dmastatus)
|
||||
{
|
||||
#if 1
|
||||
// #if (ENABLE_CAMERA_RING_BUF == 1)
|
||||
int ret = 0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if ((camBuffBak[i].enableForCamera == 1) && (camBuffBak[i].workingForUsr == 0))
|
||||
{
|
||||
// find out the current working buffer
|
||||
if (camCheckErrStats() == 0) // qspi right
|
||||
{
|
||||
timeRead(&camBuffBak[i].timeStamp);
|
||||
camBuffBak[i].enableForCamera = 0;
|
||||
camBuffBak[i].enableForUsr = 1;
|
||||
camBuffBak[i].workingForUsr = 0;
|
||||
camBuffBak[i].camErrCnt = 0;
|
||||
|
||||
ret = findNextCamBuf();
|
||||
// printf("next cam buf: %d\n", ret);
|
||||
|
||||
#if (RTE_CSPI1 == 1)
|
||||
CSPI1->CBCTRL |= 2 << 25;
|
||||
#else
|
||||
CSPI0->CBCTRL |= 2 << 25;
|
||||
#endif
|
||||
|
||||
camRecv(camBuffBak[ret].data);
|
||||
camBuffBak[ret].enableForCamera = 1;
|
||||
camBuffBak[ret].enableForUsr = 0;
|
||||
camBuffBak[ret].workingForUsr = 0;
|
||||
camBuffBak[ret].camErrCnt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 1. clear cspl status
|
||||
camClearErrStats();
|
||||
// 2. recv again
|
||||
camRecv(camBuffBak[i].data);
|
||||
camBuffBak[i].enableForCamera = 1;
|
||||
camBuffBak[i].camErrCnt++;
|
||||
camBuffBak[i].enableForUsr = 0;
|
||||
camBuffBak[i].workingForUsr = 0;
|
||||
|
||||
if (camBuffBak[i].camErrCnt == 5)
|
||||
{
|
||||
// send a msg
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(userCamDmaCb){
|
||||
userCamDmaCb(dmastatus);
|
||||
}
|
||||
}
|
||||
|
||||
static int8_t findUserEnableBuf()
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (camBuffBak[i].enableForUsr == 1)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int camPicTake()
|
||||
{
|
||||
int minIndex = findUserEnableBuf();
|
||||
if (minIndex < 0)
|
||||
return minIndex;
|
||||
else
|
||||
{
|
||||
uint32_t minVal = camBuffBak[minIndex].timeStamp;
|
||||
for (int i = (minIndex + 1); i < 3; i++)
|
||||
{
|
||||
if ((camBuffBak[i].timeStamp > 0) && (camBuffBak[i].timeStamp < minVal) && (camBuffBak[i].enableForUsr == 1))
|
||||
{
|
||||
minVal = camBuffBak[i].timeStamp;
|
||||
minIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t mask = SaveAndSetIRQMask();
|
||||
camBuffBak[minIndex].workingForUsr = 1;
|
||||
RestoreIRQMask(mask);
|
||||
|
||||
return minIndex;
|
||||
}
|
||||
}
|
||||
|
||||
void camPicGive(uint8_t index)
|
||||
{
|
||||
uint32_t mask = SaveAndSetIRQMask();
|
||||
camBuffBak[index].workingForUsr = 0;
|
||||
camBuffBak[index].enableForUsr = 1;
|
||||
RestoreIRQMask(mask);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,767 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2019-, Copyrigths of EigenComm Ltd.
|
||||
* File name: es8374.c
|
||||
* Description: EC7xx es8374 file
|
||||
* History: Rev1.0 2021-9-18
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "es8374.h"
|
||||
#include "sctdef.h"
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
//adcInput 单声道ADC输入通道选择是CH1(MIC1P/1N)还是CH2(MIC2P/2N)
|
||||
//dacOutput 单声道DAC输出通道选择:默认选择0:L声道,1:R声道
|
||||
//mode 产品主从模式选择:默认选择0为SlaveMode,打开为1选择MasterMode
|
||||
//fmt 数据格式选择,需要和实际时序匹配
|
||||
//bits 数据长度选择,需要和实际时序匹配
|
||||
#define ES8374_DEFAULT_CONFIG() \
|
||||
{ \
|
||||
.adcInput = CODEC_ADC_INPUT_LINE2, \
|
||||
.dacOutput = CODEC_DAC_OUTPUT_LINE1, \
|
||||
.codecMode = CODEC_MODE_BOTH, \
|
||||
.codecIface = { \
|
||||
.mode = CODEC_MODE_SLAVE, \
|
||||
.fmt = CODEC_I2S_MODE, \
|
||||
.samples = CODEC_16K_SAMPLES, \
|
||||
.bits = CODEC_BIT_LENGTH_16BITS, \
|
||||
.channel = CODEC_MONO, \
|
||||
.polarity = 1, \
|
||||
}, \
|
||||
};
|
||||
|
||||
#define VDDSPK_5V0 0x2B
|
||||
#define VDDSPK_4V2 0x2A
|
||||
#define VDDSPK_3V3 0x29
|
||||
|
||||
#define RATIO 256 //实际Ratio=MCLK/LRCK比率,需要和实际时钟比例匹配
|
||||
#define SCLK_DIV 4 //SCLK分频选择:(选择范围1~18),SCLK=MCLK/SCLK_DIV,超过后非等比增加具体对应关系见相应DS说明
|
||||
#define SCLK_INV 0 //默认对齐方式为下降沿,1为上升沿对齐,需要和实际时序匹配
|
||||
#define VDDSPK_VOLTAGE VDDSPK_4V2 //SPK拟电压选择为4V2还是5V0,需要和实际硬件匹配
|
||||
#define ADC_PGA_DF2SE_15DB 1 //ADC模拟固定15dB增益:默认选择关闭0,打开为1
|
||||
#define ADC_PGA_GAIN 3 //ADC模拟增益:(选择范围0~7),具体对应关系见相应DS说明
|
||||
#define ADC_VOLUME_MAX 0 //ADC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define ADC_VOLUME_MIN 50 //ADC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define ADC_VOLUME_MUTE 192 //ADC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define ADC_VOLUME_DEFAULT ADC_VOLUME_MAX //ADC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define DAC_VOLUME_MAX 0 //DAC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define DAC_VOLUME_MIN 50 //DAC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define DAC_VOLUME_MUTE 192 //DAC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define DAC_VOLUME_DEFAULT DAC_VOLUME_MAX //DAC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define DMIC_SELON 0 //DMIC选择:默认选择关闭0,立体声打开为1,单声道需要选择2为H,3为L
|
||||
#define DMIC_GAIN 0 //DMIC增益:(选择范围0~1),6dB/Step
|
||||
#define MICBIASOFF 0 //内部MICBIAS偏置:默认选择关闭1,开启配置为0
|
||||
#define PA_VOLUME_DEFAULT 7 //(0~7),(0db,1.5db,3db,4db,5db,6db,6.75db,7.5db)
|
||||
//16K,8K采样率下配置PLL_SET_12288 = 1 可以改善音质,目前只支持256Ratio,其他待更新
|
||||
#define PLL_SET_12288 1 //PLL选择输入频率,单位为KHZ:外部输入XXXXKHZ内部PLL锁成12M288
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCTION DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
// 8374 func list
|
||||
AP_PLAT_COMMON_DATA HalCodecFuncList_t es8374DefaultHandle =
|
||||
{
|
||||
.codecType = ES8374,
|
||||
.halCodecInitFunc = es8374Init,
|
||||
.halCodecDeinitFunc = es8374DeInit,
|
||||
.halCodecCtrlStateFunc = es8374StartStop,
|
||||
.halCodecCfgIfaceFunc = es8374Config,
|
||||
.halCodecSetMuteFunc = es8374SetMute,
|
||||
.halCodecSetVolumeFunc = es8374SetVolume,
|
||||
.halCodecGetVolumeFunc = es8374GetVolume,
|
||||
//.halCodecEnablePAFunc = es8374EnablePA,
|
||||
.halCodecSetMicVolumeFunc = es8374SetMicVolume,
|
||||
.halCodecGetMicVolumeFunc = NULL,
|
||||
.halCodecLock = NULL,
|
||||
.handle = NULL,
|
||||
.halCodecGetDefaultCfg = es8374GetDefaultCfg,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
AP_PLAT_COMMON_BSS static uint8_t dacVolBak, adcVolBak;
|
||||
AP_PLAT_COMMON_BSS static bool isHasPA;
|
||||
AP_PLAT_COMMON_DATA static uint8_t adcInput = 2;
|
||||
AP_PLAT_COMMON_BSS static uint8_t dacOutput = 0;
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static int32_t es8374WriteReg(uint8_t regAddr, uint16_t data)
|
||||
{
|
||||
int32_t ret = 0;
|
||||
uint8_t rxNack = 0;
|
||||
|
||||
uint8_t cmd[2] = {0};
|
||||
cmd[0] = regAddr;
|
||||
cmd[1] = data & 0xff;
|
||||
|
||||
ret = halI2cWrite(ES8374_IICADDR, cmd, 2, &rxNack, false);
|
||||
|
||||
#if 0
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374WriteReg, P_DEBUG, "[ES8374] [%x] %x", regAddr, data);
|
||||
#else
|
||||
printf("[ES8374] [%02X] %02X\r\n", regAddr, data);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t es8374ReadReg(uint8_t regAddr, uint8_t* retData)
|
||||
{
|
||||
return halI2cRead(ES8374_IICADDR, regAddr, retData, false);
|
||||
}
|
||||
|
||||
// enable pa power
|
||||
void es8374EnablePA(bool enable)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374EnablePA, P_DEBUG, "[ES8374] es8374EnablePA: enable=%d", enable);
|
||||
|
||||
#if 0
|
||||
if (enable)
|
||||
{
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20); // spk on
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1E, 0xa0); // spk on
|
||||
}
|
||||
else
|
||||
{
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20);
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1C, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1D, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x40); // spk off
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// set es8374 into suspend mode
|
||||
void es8374Standby(uint8_t* dacVolB, uint8_t* adcVolB)//待机配置--搭配es8374AllResume(void)//恢复配置
|
||||
{
|
||||
es8374ReadReg(ES8374_REG_38, dacVolB);
|
||||
es8374ReadReg(ES8374_REG_25, adcVolB);
|
||||
|
||||
es8374WriteReg(ES8374_REG_38, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_25, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_28, 0x1C);
|
||||
es8374WriteReg(ES8374_REG_36, 0x20);
|
||||
es8374WriteReg(ES8374_REG_37, 0x20);
|
||||
es8374WriteReg(ES8374_REG_6D, 0x00);
|
||||
es8374WriteReg(ES8374_REG_09, 0x80);
|
||||
es8374WriteReg(ES8374_REG_1A, 0x08);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20);
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1C, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1D, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x40);
|
||||
es8374WriteReg(ES8374_REG_24, 0x20);
|
||||
es8374WriteReg(ES8374_REG_22, 0x00);
|
||||
es8374WriteReg(ES8374_REG_21, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_15, 0xFF);
|
||||
es8374WriteReg(ES8374_REG_14, 0x82);
|
||||
es8374WriteReg(ES8374_REG_01, 0x03);
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Standby, P_DEBUG, "[ES8374] es8374Standby: dacVolB=%d, adcVolB=%d", *dacVolB, *adcVolB);
|
||||
}
|
||||
|
||||
#if 1
|
||||
// set es8374 ADC into suspend mode
|
||||
void es8374AdcStandby(uint8_t* adcVolB)//ADC待机配置--搭配es8374AdcResume
|
||||
{
|
||||
es8374ReadReg(ES8374_REG_25, adcVolB);
|
||||
|
||||
es8374WriteReg(ES8374_REG_25, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_15, 0x00);
|
||||
es8374WriteReg(ES8374_REG_28, 0x1C);
|
||||
es8374WriteReg(ES8374_REG_09, 0x80);
|
||||
delay_us(5000);
|
||||
es8374WriteReg(ES8374_REG_24, 0x20);
|
||||
es8374WriteReg(ES8374_REG_21, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_15, 0x0C);
|
||||
es8374WriteReg(ES8374_REG_01, 0x75);
|
||||
|
||||
}
|
||||
|
||||
// set es8374 DAC into suspend mode
|
||||
void es8374DacStandby(uint8_t* dacVolB)//DAC待机配置--搭配es8374DacResume
|
||||
{
|
||||
es8374ReadReg(ES8374_REG_38, dacVolB);
|
||||
|
||||
es8374WriteReg(ES8374_REG_38, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_15, 0x00);
|
||||
es8374WriteReg(ES8374_REG_36, 0x20);
|
||||
es8374WriteReg(ES8374_REG_37, 0x20);
|
||||
es8374WriteReg(ES8374_REG_6D, 0x00);
|
||||
es8374WriteReg(ES8374_REG_09, 0x80);
|
||||
es8374WriteReg(ES8374_REG_1A, 0x08);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20);
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1C, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1D, 0x10);
|
||||
//es8374WriteReg(ES8374_REG_1E, 0x40); // spk off
|
||||
es8374WriteReg(ES8374_REG_15, 0x62);
|
||||
es8374WriteReg(ES8374_REG_01, 0x7A);
|
||||
|
||||
}
|
||||
#endif
|
||||
#if 1
|
||||
// set es8374 adc into resume mode
|
||||
static HalCodecSts_e es8374AdcResume(void)//ADC恢复配置--搭配es8374AdcStandby
|
||||
{
|
||||
|
||||
es8374WriteReg(ES8374_REG_01, 0x7F);
|
||||
es8374WriteReg(ES8374_REG_15, 0x00);
|
||||
es8374WriteReg(ES8374_REG_21, (adcInput << 4) + (ADC_PGA_DF2SE_15DB << 2));
|
||||
es8374WriteReg(ES8374_REG_24, 0x08 + (DMIC_GAIN << 7) + DMIC_SELON);
|
||||
es8374WriteReg(ES8374_REG_09, 0x41);
|
||||
es8374WriteReg(ES8374_REG_28, 0x00);
|
||||
es8374WriteReg(ES8374_REG_15, 0x40);
|
||||
es8374WriteReg(ES8374_REG_25, adcVolBak);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
// set es8374 dac into resume mode
|
||||
static HalCodecSts_e es8374DacResume(void)//DAC恢复配置--搭配es8374DacStandby
|
||||
{
|
||||
|
||||
es8374WriteReg(ES8374_REG_01, 0x7F);
|
||||
es8374WriteReg(ES8374_REG_15, 0x00);
|
||||
es8374WriteReg(ES8374_REG_21, 0x50);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20); // spk on
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1E, 0xa0); // spk on
|
||||
es8374WriteReg(ES8374_REG_1D, VDDSPK_VOLTAGE);
|
||||
es8374WriteReg(ES8374_REG_1C, 0x90);
|
||||
es8374WriteReg(ES8374_REG_1A, 0xA0);
|
||||
es8374WriteReg(ES8374_REG_09, 0x41);
|
||||
es8374WriteReg(ES8374_REG_6D, 0x60);
|
||||
es8374WriteReg(ES8374_REG_37, 0x00);
|
||||
es8374WriteReg(ES8374_REG_36, (dacOutput << 6));
|
||||
es8374WriteReg(ES8374_REG_15, 0x40);
|
||||
es8374WriteReg(ES8374_REG_38, dacVolBak);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// set es8374 into resume mode
|
||||
static HalCodecSts_e es8374AllResume(void)//恢复配置(未下电)--搭配es8374Standby(void)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374AllResume, P_DEBUG, "[ES8374] es8374AllResume: dacVolBak=%d, adcVolBak=%d", dacVolBak, adcVolBak);
|
||||
|
||||
es8374WriteReg(ES8374_REG_01, 0x7F);
|
||||
es8374WriteReg(ES8374_REG_14, 0x8A + (MICBIASOFF << 4));
|
||||
es8374WriteReg(ES8374_REG_15, 0x00);
|
||||
es8374WriteReg(ES8374_REG_21, 0x50);
|
||||
es8374WriteReg(ES8374_REG_22, ADC_PGA_GAIN + (ADC_PGA_GAIN << 4));
|
||||
es8374WriteReg(ES8374_REG_21, (adcInput << 4) + (ADC_PGA_DF2SE_15DB << 2));
|
||||
es8374WriteReg(ES8374_REG_24, 0x08 + (DMIC_GAIN << 7) + DMIC_SELON);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20); // spk on
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1E, 0xa0); // spk on
|
||||
es8374WriteReg(ES8374_REG_1D, VDDSPK_VOLTAGE);
|
||||
es8374WriteReg(ES8374_REG_1C, 0x90);
|
||||
es8374WriteReg(ES8374_REG_1A, 0xA0);
|
||||
es8374WriteReg(ES8374_REG_09, 0x41);
|
||||
es8374WriteReg(ES8374_REG_6D, 0x60);
|
||||
es8374WriteReg(ES8374_REG_37, 0x00);
|
||||
es8374WriteReg(ES8374_REG_36, (dacOutput << 6));
|
||||
es8374WriteReg(ES8374_REG_28, 0x00);
|
||||
es8374WriteReg(ES8374_REG_15, 0x40);
|
||||
es8374WriteReg(ES8374_REG_38, dacVolBak);
|
||||
es8374WriteReg(ES8374_REG_25, adcVolBak);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// set es8374 into powerdown mode
|
||||
static HalCodecSts_e es8374PwrDown(HalCodecModule_e mode)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374PwrDown, P_DEBUG, "[ES8374] es8374PwrDown: mode=%d", mode);
|
||||
|
||||
es8374WriteReg(ES8374_REG_38, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_25, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_15, 0x00);
|
||||
es8374WriteReg(ES8374_REG_28, 0x1C);
|
||||
es8374WriteReg(ES8374_REG_36, 0x20);
|
||||
es8374WriteReg(ES8374_REG_37, 0x20);
|
||||
es8374WriteReg(ES8374_REG_6D, 0x00);
|
||||
es8374WriteReg(ES8374_REG_09, 0x80);
|
||||
es8374WriteReg(ES8374_REG_1A, 0x08);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20);
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1C, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1D, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x40);
|
||||
es8374WriteReg(ES8374_REG_24, 0x20);
|
||||
es8374WriteReg(ES8374_REG_22, 0x00);
|
||||
es8374WriteReg(ES8374_REG_21, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_15, 0xFF);
|
||||
es8374WriteReg(ES8374_REG_14, 0x16);
|
||||
es8374WriteReg(ES8374_REG_01, 0x03);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
HalCodecSts_e es8374Init(HalCodecCfg_t *codecCfg)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Init_1, P_DEBUG, "[ES8374] es8374Init_1: adcInput=%d, dacOutput=%d, codecMode=%d, hasPA=%d",
|
||||
codecCfg->adcInput, codecCfg->dacOutput, codecCfg->codecMode, codecCfg->hasPA);
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Init_2, P_DEBUG, "[ES8374] es8374Init_2: mode=%d, fmt=%d, samples=%d, bits=%d, channel=%d, polarity=%d",
|
||||
codecCfg->codecIface.mode, codecCfg->codecIface.fmt, codecCfg->codecIface.samples, codecCfg->codecIface.bits, codecCfg->codecIface.channel, codecCfg->codecIface.polarity);
|
||||
|
||||
//codecI2cInit();
|
||||
halI2cInit(false);
|
||||
|
||||
switch (codecCfg->adcInput)
|
||||
{
|
||||
case CODEC_ADC_INPUT_LINE1:
|
||||
adcInput = 1;
|
||||
break;
|
||||
|
||||
case CODEC_ADC_INPUT_LINE2:
|
||||
adcInput = 2;
|
||||
break;
|
||||
|
||||
case CODEC_ADC_INPUT_ALL:
|
||||
adcInput = 3;
|
||||
break;
|
||||
|
||||
case CODEC_ADC_INPUT_DIFFERENCE:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (codecCfg->dacOutput)
|
||||
{
|
||||
case CODEC_DAC_OUTPUT_LINE1:
|
||||
dacOutput = 0;
|
||||
break;
|
||||
|
||||
case CODEC_DAC_OUTPUT_LINE2:
|
||||
dacOutput = 1;
|
||||
break;
|
||||
|
||||
case CODEC_DAC_OUTPUT_ALL:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
es8374WriteReg(ES8374_REG_00, 0x3F); //IC Rst start
|
||||
es8374WriteReg(ES8374_REG_00, 0x03); //IC Rst stop
|
||||
es8374WriteReg(ES8374_REG_01, 0x7F); //IC clk on
|
||||
es8374WriteReg(ES8374_REG_02, 0x00);
|
||||
es8374WriteReg(ES8374_REG_03, 0x20);
|
||||
es8374WriteReg(ES8374_REG_04, 0x00);
|
||||
es8374WriteReg(ES8374_REG_05, 0x11); //clk div set
|
||||
if(PLL_SET_12288 == 1)
|
||||
{
|
||||
es8374WriteReg(ES8374_REG_6F, 0xA0); //pll set:mode enable
|
||||
es8374WriteReg(ES8374_REG_72, 0x41); //pll set:mode set
|
||||
es8374WriteReg(ES8374_REG_09, 0x01); //pll set:reset on ,set start
|
||||
es8374WriteReg(ES8374_REG_0A, 0x8A);
|
||||
es8374WriteReg(ES8374_REG_0B, 0x0C);
|
||||
es8374WriteReg(ES8374_REG_0C, 0x00);
|
||||
es8374WriteReg(ES8374_REG_0D, 0x00);
|
||||
es8374WriteReg(ES8374_REG_0E, 0x00);
|
||||
es8374WriteReg(ES8374_REG_09, 0x41); //pll set:reset off ,set stop
|
||||
es8374WriteReg(ES8374_REG_02, 0x08); //pll set:use pll
|
||||
es8374WriteReg(ES8374_REG_03, 0x30); //384 OSR
|
||||
es8374WriteReg(ES8374_REG_04, 0x20); //384 OSR
|
||||
}
|
||||
es8374WriteReg(ES8374_REG_06, (RATIO >> 8)); //LRCK DIV
|
||||
es8374WriteReg(ES8374_REG_07, (RATIO & 0xFF)); //LRCK DIV
|
||||
es8374SetBitsPerSample(codecCfg->codecIface.bits);
|
||||
es8374ConfigFmt(codecCfg->codecIface.fmt);
|
||||
es8374WriteReg(ES8374_REG_0F, (((codecCfg->codecIface.mode == CODEC_MODE_SLAVE) ? 0 : 1) << 7) + (SCLK_INV<<5) + SCLK_DIV);
|
||||
es8374WriteReg(ES8374_REG_24, 0x08 + (DMIC_GAIN << 7) + DMIC_SELON); //adc set
|
||||
es8374WriteReg(ES8374_REG_36, (dacOutput << 6)); //dac set
|
||||
es8374WriteReg(ES8374_REG_12, 0x30); //timming set
|
||||
es8374WriteReg(ES8374_REG_13, 0x20); //timming set
|
||||
es8374WriteReg(ES8374_REG_18, 0xFF);
|
||||
es8374WriteReg(ES8374_REG_21, 0x50);
|
||||
es8374WriteReg(ES8374_REG_22, ADC_PGA_GAIN + (ADC_PGA_GAIN << 4)); //adc set
|
||||
es8374WriteReg(ES8374_REG_21, (adcInput << 4) + (ADC_PGA_DF2SE_15DB << 2));
|
||||
es8374WriteReg(ES8374_REG_00, 0x80); // IC START
|
||||
delay_us(10000);
|
||||
es8374WriteReg(ES8374_REG_14, 0x8A + (MICBIASOFF << 4));
|
||||
es8374WriteReg(ES8374_REG_15, 0x40);
|
||||
es8374WriteReg(ES8374_REG_1A, 0xA0); // monoout set
|
||||
es8374WriteReg(ES8374_REG_1B, 0x19); //5V 0DB
|
||||
es8374WriteReg(ES8374_REG_1C, 0x90);
|
||||
es8374WriteReg(ES8374_REG_1D, VDDSPK_VOLTAGE); //5V 0DB 8R=>1W
|
||||
es8374WriteReg(ES8374_REG_1F, 0x00); // spk set
|
||||
es8374WriteReg(ES8374_REG_20, 0x00); // spk set
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20); // spk on
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1E, 0xa0); // spk on
|
||||
es8374WriteReg(ES8374_REG_28, 0x00); // alc set
|
||||
es8374WriteReg(ES8374_REG_25, ADC_VOLUME_DEFAULT); // ADCVOLUME on
|
||||
es8374WriteReg(ES8374_REG_38, DAC_VOLUME_DEFAULT); // DACVOLUMEL on
|
||||
es8374WriteReg(ES8374_REG_37, 0x00); // dac set
|
||||
es8374WriteReg(ES8374_REG_6D, 0x60); // SEL:GPIO1=DMIC CLK OUT+SEL:GPIO2=PLL CLK OUT
|
||||
|
||||
isHasPA = codecCfg->hasPA;
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
void es8374DeInit()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374DeInit, P_DEBUG, "[ES8374] es8374DeInit");
|
||||
|
||||
halI2cDeInit(false);
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374ConfigFmt(HalCodecIfaceFormat_e fmt)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
uint8_t adc = 0, dac = 0;
|
||||
es8374ReadReg(ES8374_REG_10, &adc);
|
||||
es8374ReadReg(ES8374_REG_11, &dac);
|
||||
adc = adc & 0xdc;
|
||||
dac = dac & 0xdc;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374ConfigFmt, P_DEBUG, "[ES8374] es8374ConfigFmt: fmt=%d", fmt);
|
||||
|
||||
switch (fmt)
|
||||
{
|
||||
case CODEC_MSB_MODE:
|
||||
case CODEC_LSB_MODE:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374fmt_1, P_DEBUG, "[ES8374] left/right Format");
|
||||
adc |= 0x01;
|
||||
dac |= 0x01;
|
||||
break;
|
||||
|
||||
case CODEC_I2S_MODE:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374fmt_2, P_DEBUG, "[ES8374] I2S Format");
|
||||
adc |= 0x00;
|
||||
dac |= 0x00;
|
||||
break;
|
||||
|
||||
case CODEC_PCM_MODE:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374fmt_3, P_DEBUG, "[ES8374] pcm Format");
|
||||
adc |= 0x03;
|
||||
dac |= 0x03;
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374fmt_5, P_DEBUG, "[ES8374] default Format (I2S)");
|
||||
adc |= 0x00;
|
||||
dac |= 0x00;
|
||||
break;
|
||||
}
|
||||
|
||||
ret |= es8374WriteReg(ES8374_REG_10, adc);
|
||||
ret |= es8374WriteReg(ES8374_REG_11, dac);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374SetBitsPerSample(HalCodecIfaceBits_e bits)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
uint8_t adc = 0, dac = 0;
|
||||
es8374ReadReg(ES8374_REG_10, &adc);
|
||||
es8374ReadReg(ES8374_REG_11, &dac);
|
||||
adc = adc & 0xe3;
|
||||
dac = dac & 0xe3;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetBitsPerSample, P_DEBUG, "[ES8374] es8374SetBitsPerSample: bits=%d", bits);
|
||||
|
||||
switch (bits)
|
||||
{
|
||||
case CODEC_BIT_LENGTH_16BITS:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetBitsPerSample_1, P_DEBUG, "[ES8374] 16 bits");
|
||||
adc |= 0x0C;
|
||||
dac |= 0x0C;
|
||||
break;
|
||||
|
||||
case CODEC_BIT_LENGTH_24BITS:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetBitsPerSample_2, P_DEBUG, "[ES8374] 24 bits");
|
||||
adc |= 0x00;
|
||||
dac |= 0x00;
|
||||
break;
|
||||
|
||||
case CODEC_BIT_LENGTH_32BITS:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetBitsPerSample_3, P_DEBUG, "[ES8374] 32 bits");
|
||||
adc |= 0x10;
|
||||
dac |= 0x10;
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetBitsPerSample_5, P_DEBUG, "[ES8374] default bit length (16 bits)");
|
||||
adc |= 0x0C;
|
||||
dac |= 0x0C;
|
||||
break;
|
||||
}
|
||||
|
||||
ret |= es8374WriteReg(ES8374_REG_10, adc);
|
||||
ret |= es8374WriteReg(ES8374_REG_11, dac);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374Config(HalCodecMode_e mode, HalCodecIface_t *iface)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Config, P_DEBUG, "[ES8374] es8374Config: mode=%d, bits=%d, fmt=%d", mode, iface->bits, iface->fmt);
|
||||
|
||||
ret |= es8374SetBitsPerSample(iface->bits);
|
||||
ret |= es8374ConfigFmt(iface->fmt);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374StartStop(HalCodecMode_e mode, HalCodecCtrlState_e ctrlState)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374StartStop, P_DEBUG, "[ES8374] es8374StartStop: mode=%d, ctrlState=%d", mode, ctrlState);
|
||||
switch(ctrlState)
|
||||
{
|
||||
case CODEC_CTRL_START:
|
||||
ret |= es8374Start(mode);
|
||||
if (isHasPA)
|
||||
{
|
||||
//es8374EnablePA(true);
|
||||
}
|
||||
break;
|
||||
case CODEC_CTRL_STOP:
|
||||
ret |= es8374Stop(mode);
|
||||
break;
|
||||
case CODEC_CTRL_RESUME:
|
||||
ret |= es8374Resume(mode);
|
||||
break;
|
||||
case CODEC_CTRL_POWERDONW:
|
||||
ret |= es8374PwrDown(mode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374Start(HalCodecModule_e mode)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Start, P_DEBUG, "[ES8374] es8374Start: mode=%d", mode);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374Stop(HalCodecModule_e mode)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Stop, P_DEBUG, "[ES8374] es8374Stop: mode=%d", mode);
|
||||
switch(mode)
|
||||
{
|
||||
case CODEC_MODE_ENCODE:
|
||||
es8374AdcStandby(&adcVolBak);
|
||||
break;
|
||||
|
||||
case CODEC_MODE_DECODE:
|
||||
es8374DacStandby(&dacVolBak);
|
||||
if (isHasPA)
|
||||
{
|
||||
delay_us(2000);
|
||||
//es8374EnablePA(false);
|
||||
}
|
||||
break;
|
||||
|
||||
case CODEC_MODE_BOTH:
|
||||
es8374Standby(&dacVolBak, &adcVolBak);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374Resume(HalCodecMode_e mode)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Resume, P_DEBUG, "[ES8374] es8374Resume: mode=%d", mode);
|
||||
switch(mode)
|
||||
{
|
||||
case CODEC_MODE_ENCODE:
|
||||
//es8374AllResume();
|
||||
|
||||
es8374AdcResume();
|
||||
break;
|
||||
|
||||
case CODEC_MODE_DECODE:
|
||||
//es8374AllResume();
|
||||
|
||||
es8374DacResume();
|
||||
if (isHasPA)
|
||||
{
|
||||
//es8374EnablePA(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case CODEC_MODE_BOTH:
|
||||
es8374AllResume();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374SetVolume(HalCodecCfg_t* codecHalCfg, int volume)
|
||||
{
|
||||
uint8_t level = volume;
|
||||
uint8_t value = DAC_VOLUME_MUTE;
|
||||
|
||||
if (level > 0)
|
||||
{
|
||||
level = (level > 100) ? 100 : level;
|
||||
value = DAC_VOLUME_MIN - (level * DAC_VOLUME_MIN / 100);
|
||||
}
|
||||
|
||||
es8374WriteReg(ES8374_REG_38, value);
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetVolume, P_DEBUG, "[ES8374] es8374SetVolume: volume=%d, level=%d, value=%d", volume, level, value);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374GetVolume(HalCodecCfg_t* codecHalCfg, int *volume)
|
||||
{
|
||||
uint8_t level = 0;
|
||||
uint8_t value = 0;
|
||||
es8374ReadReg(ES8374_REG_38, &value);
|
||||
|
||||
if (value <= DAC_VOLUME_MIN)
|
||||
{
|
||||
level = 100 - (value * 100 / DAC_VOLUME_MIN);
|
||||
level = (level == 0) ? 1 : level;
|
||||
}
|
||||
|
||||
*volume = level;
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374GetVolume, P_DEBUG, "[ES8374] es8374GetVolume: value=%d, level=%d", value, level);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374SetMute(HalCodecCfg_t* codecHalCfg, bool enable)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetMute, P_DEBUG, "[ES8374] es8374SetMute: enable=%d", enable);
|
||||
|
||||
if (enable == true)
|
||||
{
|
||||
es8374WriteReg(ES8374_REG_36, 0x20);
|
||||
}
|
||||
else
|
||||
{
|
||||
es8374WriteReg(ES8374_REG_36, (dacOutput << 6));
|
||||
}
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374GetVoiceMute(uint8_t *mute)
|
||||
{
|
||||
//*mute = (es8374ReadReg(ES8374_REG_36) >> 5) & 0x01;
|
||||
es8374ReadReg(ES8374_REG_36, mute);
|
||||
*mute = (*mute >> 5) & 0x01;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374GetVoiceMute, P_DEBUG, "[ES8374] es8374GetVoiceMute: mute=%d", *mute);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374SetMicVolume(HalCodecCfg_t* codecHalCfg, uint8_t micGain, int micVolume)
|
||||
{
|
||||
uint8_t level = micVolume;
|
||||
uint8_t value = ADC_VOLUME_MUTE;
|
||||
|
||||
if (level > 0)
|
||||
{
|
||||
level = (level > 100) ? 100 : level;
|
||||
value = ADC_VOLUME_MIN - (level * ADC_VOLUME_MIN / 100);
|
||||
}
|
||||
|
||||
es8374WriteReg(ES8374_REG_25, value);
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetMicVolume, P_DEBUG, "[ES8374] es8374SetMicVolume: micVolume=%d, level=%d, value=%d", micVolume, level, value);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
void es8374ReadAll()
|
||||
{
|
||||
uint8_t reg = 0;
|
||||
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374ReadAll_1, P_DEBUG, "[ES8374] es8374ReadAll Begin");
|
||||
#else
|
||||
printf("[ES8374] es8374ReadAll Begin\r\n");
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < 0x6E; i++)
|
||||
{
|
||||
es8374ReadReg(i, ®);
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374ReadAll_2, P_DEBUG, "[ES8374] [%x] %x", reg, i);
|
||||
#else
|
||||
printf("[ES8374] [%02X] %02X\r\n", i, reg);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374ReadAll_3, P_DEBUG, "[ES8374] es8374ReadAll End");
|
||||
#else
|
||||
printf("[ES8374] es8374ReadAll End\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
HalCodecCfg_t es8374GetDefaultCfg()
|
||||
{
|
||||
HalCodecCfg_t codecCfg = ES8374_DEFAULT_CONFIG();
|
||||
|
||||
return codecCfg;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,238 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2019-, Copyrigths of EigenComm Ltd.
|
||||
* File name: hal_codec.c
|
||||
* Description: EC7XX codec hal
|
||||
* History: Rev1.0 2021-9-18
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "codecDrv.h"
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCTION DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
const AudioParaCfgCodec_t codecTlvDefaultVal =
|
||||
{
|
||||
.isDmic = false,
|
||||
.isExPa = true,
|
||||
.exPaGain = 0,
|
||||
.txDigGain = 0xbf,
|
||||
.txAnaGain = 0x8,
|
||||
|
||||
.rxDigGain0 = 0,
|
||||
.rxAnaGain0 = 0,
|
||||
.rxDigGain50 = 0,
|
||||
.rxAnaGain50 = 0,
|
||||
.rxDigGain100 = 0xff,
|
||||
.rxAnaGain100 = 0xff,
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCTIONS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
|
||||
HalCodecSts_e halCodecLock(void* arg)
|
||||
{
|
||||
osSemaphoreId_t codecLock = (osSemaphoreId_t)arg;
|
||||
|
||||
if (osSemaphoreAcquire(codecLock, 1000) != osOK)
|
||||
{
|
||||
return CODEC_TIMEOUT;
|
||||
}
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecUnlock(void* arg)
|
||||
{
|
||||
osSemaphoreId_t codecLock = (osSemaphoreId_t)arg;
|
||||
|
||||
if (osSemaphoreRelease(codecLock) != osOK)
|
||||
{
|
||||
return CODEC_TIMEOUT;
|
||||
}
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecLockDestroy(void *arg)
|
||||
{
|
||||
osSemaphoreId_t codecLock = (osSemaphoreId_t)arg;
|
||||
|
||||
if (osSemaphoreDelete(codecLock) != osOK)
|
||||
{
|
||||
return CODEC_TIMEOUT;
|
||||
}
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
HalCodecSts_e halCodecLock(void* arg)
|
||||
{
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecUnlock(void* arg)
|
||||
{
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecLockDestroy(void *arg)
|
||||
{
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
HalCodecCfg_t halCodecGetDefaultCfg(HalCodecFuncList_t* codecHalFunc)
|
||||
{
|
||||
return codecHalFunc->halCodecGetDefaultCfg();
|
||||
}
|
||||
|
||||
HalCodecFuncList_t* halCodecInit(HalCodecCfg_t* codecHalCfg, HalCodecFuncList_t* codecHalFunc, bool needLock)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
HalCodecFuncList_t* codecHal = codecHalFunc;
|
||||
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
if (codecHal->halCodecLock == NULL)
|
||||
{
|
||||
codecHal->halCodecLock = osSemaphoreNew(1, 1, NULL);
|
||||
if (codecHal->halCodecLock == PNULL)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, halCodecInit_0, P_WARNING, "codec hal can't create semaphore");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
|
||||
ret |= codecHal->halCodecInitFunc(codecHalCfg);
|
||||
if (ret != CODEC_EOK)
|
||||
{
|
||||
halCodecUnlock(codecHal->halCodecLock);
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, halCodecInit_2, P_DEBUG, "codec init fail. ret=%d", ret);
|
||||
EC_ASSERT(false, 0, 0, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
codecHal->halCodecCfgIfaceFunc(codecHalCfg->codecMode, &codecHalCfg->codecIface);
|
||||
|
||||
codecHal->handle = codecHal;
|
||||
codecHalFunc->handle = codecHal;
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return codecHal;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecDeinit(HalCodecFuncList_t* codecHal)
|
||||
{
|
||||
int32_t ret = CODEC_EOK;
|
||||
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
halCodecLockDestroy(codecHal->halCodecLock);
|
||||
codecHal->halCodecDeinitFunc();
|
||||
codecHal->halCodecLock = NULL;
|
||||
codecHal->handle = NULL;
|
||||
codecHal = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecCtrlState(HalCodecFuncList_t* codecHal, HalCodecMode_e mode, HalCodecCtrlState_e codecStartStop, bool needLock)
|
||||
{
|
||||
int32_t ret;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, halCodecCtrl_1, P_DEBUG, "codec mode=%d, startStop=%d", mode, codecStartStop);
|
||||
ret = codecHal->halCodecCtrlStateFunc(mode, codecStartStop);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecIfaceCfg(HalCodecFuncList_t* codecHal, HalCodecMode_e mode, HalCodecIface_t *iface, bool needLock)
|
||||
{
|
||||
int32_t ret = CODEC_EOK;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
HAL_CODEC_CHECK_NULL(iface, "Get volume para is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
ret = codecHal->halCodecCfgIfaceFunc(mode, iface);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecSetMute(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, bool mute, bool needLock)
|
||||
{
|
||||
int32_t ret;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
ret = codecHal->halCodecSetMuteFunc(codecHalCfg, mute);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if 1
|
||||
HalCodecSts_e halCodecEnablePA(HalCodecFuncList_t* codecHal, bool enable, bool needLock)
|
||||
{
|
||||
int32_t ret = CODEC_EOK;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
codecHal->halCodecEnablePAFunc(enable);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
HalCodecSts_e halCodecSetVolume(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, int volume, bool needLock)
|
||||
{
|
||||
int32_t ret;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
ret = codecHal->halCodecSetVolumeFunc(codecHalCfg, volume);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecGetVolume(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, int *volume, bool needLock)
|
||||
{
|
||||
int32_t ret;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
HAL_CODEC_CHECK_NULL(volume, "Get volume para is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
ret = codecHal->halCodecGetVolumeFunc(codecHalCfg, volume);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecSetMicVolume(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, uint8_t micGain, int volume, bool needLock)
|
||||
{
|
||||
int32_t ret;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
ret = codecHal->halCodecSetMicVolumeFunc(codecHalCfg, micGain, volume);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1,315 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2020-, Copyrigths of EigenComm Ltd.
|
||||
* File name: eepRom.c
|
||||
* Description: EC618 eepRom ds2431 driver source file
|
||||
* History: Rev1.0 2020-12-17
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "ec7xx.h"
|
||||
#include "bsp.h"
|
||||
#include "eepRom.h"
|
||||
#include "oneWire.h"
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
|
||||
extern void delay_us(uint32_t us);
|
||||
|
||||
static uint16_t crc16Maxim(uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t i;
|
||||
uint16_t crc = 0;
|
||||
while (len--)
|
||||
{
|
||||
crc ^= *data++;
|
||||
for (i=0; i<8; ++i)
|
||||
{
|
||||
if (crc&1)
|
||||
{
|
||||
crc = (crc>>1) ^ 0xA001;
|
||||
}
|
||||
else
|
||||
{
|
||||
crc = crc>>1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
|
||||
int32_t writeScratchpad(uint8_t addr, uint8_t data[8])
|
||||
{
|
||||
uint8_t crcSrcData[11];
|
||||
uint16_t crcCalResult;
|
||||
uint8_t crcReadData[2];
|
||||
|
||||
if ((data == NULL) || (addr > 0x8F))
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
if (owResetPd() != 0)
|
||||
{
|
||||
return EEPROMDRV_RESET_ERR;
|
||||
}
|
||||
|
||||
delay_us(140); // delay 200us
|
||||
|
||||
owWriteByte(ROM_SKIP_CMD);
|
||||
owWriteByte(SCRATCHPAD_WRITE_CMD);
|
||||
owWriteByte(addr);
|
||||
owWriteByte(0x00);
|
||||
|
||||
crcSrcData[0] = SCRATCHPAD_WRITE_CMD; // before are right
|
||||
crcSrcData[1] = addr;
|
||||
crcSrcData[2] = 0x00;
|
||||
for (int i=0; i<8; i++)
|
||||
{
|
||||
owWriteByte(data[i]);
|
||||
crcSrcData[i+3] = data[i];
|
||||
}
|
||||
|
||||
crcCalResult = crc16Maxim(crcSrcData, 11); // before are right
|
||||
|
||||
owReadByte(crcReadData);
|
||||
owReadByte(crcReadData+1);
|
||||
|
||||
if (((crcReadData[1]<<8) | crcReadData[0]) != crcCalResult)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
return EEPROMDRV_OK;
|
||||
}
|
||||
|
||||
void readScratchpad(uint8_t dataBack[13])
|
||||
{
|
||||
if (owResetPd() != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
delay_us(140); // delay 200us
|
||||
|
||||
owWriteByte(ROM_SKIP_CMD);
|
||||
owWriteByte(SCRATCHPAD_READ_CMD);
|
||||
|
||||
// first 3 bytes are: TA1, TA2, ES; Then 8 bytes data; Last are 2 bytes crc
|
||||
for (int i=0; i<13; i++)
|
||||
{
|
||||
owReadByte(dataBack+i);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t copyScratchpad2Mem(uint16_t addr)
|
||||
{
|
||||
uint8_t readData;
|
||||
|
||||
if (owResetPd() != 0)
|
||||
{
|
||||
return EEPROMDRV_RESET_ERR;
|
||||
}
|
||||
|
||||
delay_us(140); // delay 200us
|
||||
|
||||
owWriteByte(ROM_SKIP_CMD);
|
||||
owWriteByte(SCRATCHPAD_COPY_CMD);
|
||||
owWriteByte(addr);
|
||||
owWriteByte(0x00);
|
||||
owWriteByte(0x07);
|
||||
|
||||
delay_us(140); // delay 200us
|
||||
|
||||
owReadByte(&readData);
|
||||
if (readData != 0xAA)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADCOPY_ERR;
|
||||
}
|
||||
|
||||
return EEPROMDRV_OK;
|
||||
}
|
||||
|
||||
AP_PLAT_COMMON_BSS uint8_t dataBack[13]={0};
|
||||
int32_t dataCmp(uint8_t targetAddr, uint8_t* buffer, uint8_t len)
|
||||
{
|
||||
// compare the data read from scratchpad
|
||||
if (dataBack[0] != targetAddr)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
if (dataBack[1] != 0)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
if (dataBack[2] != 0x7)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
for (int j=0; j<len; j++)
|
||||
{
|
||||
if (dataBack[j+3] != buffer[j])
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
return EEPROMDRV_OK;
|
||||
}
|
||||
|
||||
int32_t eePromReadRom(uint8_t* romCode)
|
||||
{
|
||||
if (owResetPd() !=0)
|
||||
{
|
||||
return EEPROMDRV_RESET_ERR;
|
||||
}
|
||||
|
||||
delay_us(140); // delay 200us
|
||||
|
||||
#if 0
|
||||
uint8_t data = ROM_READ_CMD;
|
||||
int i;
|
||||
for (i=0; i<8; i++)
|
||||
{
|
||||
owWriteBit(data&0x01);
|
||||
data >>=1;
|
||||
}
|
||||
|
||||
uint8_t dataRead;
|
||||
for (i=0; i<8; i++)
|
||||
{
|
||||
owReadBit(&dataRead);
|
||||
dataRead <<=1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
int32_t result = owWriteByte(ROM_READ_CMD);
|
||||
if (result < 0)
|
||||
{
|
||||
return EEPROMDRV_ROMREAD_ERR;
|
||||
}
|
||||
|
||||
for (int32_t i=0; i<8; i++)
|
||||
{
|
||||
owReadByte(romCode+i);
|
||||
}
|
||||
#endif
|
||||
|
||||
return EEPROMDRV_OK;
|
||||
}
|
||||
|
||||
int32_t eePromReadMem(uint8_t targetAddr, uint8_t len, uint8_t* buffer)
|
||||
{
|
||||
delay_us(3000); // wait unitl former write operations finish
|
||||
|
||||
if (owResetPd() != 0)
|
||||
{
|
||||
return EEPROMDRV_RESET_ERR;
|
||||
}
|
||||
|
||||
delay_us(140); // delay 200us
|
||||
|
||||
if (owWriteByte(ROM_SKIP_CMD) < 0)
|
||||
{
|
||||
return EEPROMDRV_ROMREAD_ERR;
|
||||
}
|
||||
|
||||
if (owWriteByte(MEM_READ_CMD) < 0)
|
||||
{
|
||||
return EEPROMDRV_ROMREAD_ERR;
|
||||
}
|
||||
|
||||
// write addr low byte
|
||||
if (owWriteByte(targetAddr) < 0)
|
||||
{
|
||||
return EEPROMDRV_ROMREAD_ERR;
|
||||
}
|
||||
|
||||
// write addr high byte
|
||||
if (owWriteByte(0) < 0)
|
||||
{
|
||||
return EEPROMDRV_ROMREAD_ERR;
|
||||
}
|
||||
|
||||
for (int i=0; i<len; i++)
|
||||
{
|
||||
owReadByte(buffer+i);
|
||||
}
|
||||
|
||||
return owResetPd();
|
||||
}
|
||||
|
||||
AP_PLAT_COMMON_BSS int32_t writeSctStats;
|
||||
int32_t eePromWriteMem(uint8_t targetAddr, uint8_t len, uint8_t* buffer)
|
||||
{
|
||||
uint8_t tmp[8];
|
||||
int i, index=0;
|
||||
|
||||
if (owResetPd() != 0)
|
||||
{
|
||||
return EEPROMDRV_RESET_ERR;
|
||||
}
|
||||
|
||||
if (targetAddr > 0x88)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
while (len > 8)
|
||||
{
|
||||
for (i=0; i<8; i++)
|
||||
{
|
||||
tmp[i] = buffer[i+index];
|
||||
}
|
||||
|
||||
len -= 8;
|
||||
writeSctStats = writeScratchpad(targetAddr+index, tmp);
|
||||
delay_us(3000);
|
||||
readScratchpad(dataBack);
|
||||
if (dataCmp(targetAddr+index, buffer+index, 8) != 0)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
copyScratchpad2Mem(targetAddr+index);
|
||||
delay_us(3000);
|
||||
memset(dataBack, 0, 13);
|
||||
|
||||
index += 8;
|
||||
}
|
||||
|
||||
for (i=0; i<len; i++)
|
||||
{
|
||||
tmp[i] = buffer[i+index];
|
||||
}
|
||||
|
||||
memset(tmp+i, 1, 8-len);
|
||||
delay_us(3000); // wait until eeprom store data finish
|
||||
writeSctStats = writeScratchpad(targetAddr+index, tmp);
|
||||
delay_us(3000);
|
||||
readScratchpad(dataBack);
|
||||
if (dataCmp(targetAddr+index, buffer+index, len) != 0)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
copyScratchpad2Mem(targetAddr+index);
|
||||
delay_us(30000); // wait until eeprom store data finish
|
||||
|
||||
if (owResetPd() != 0)
|
||||
{
|
||||
return EEPROMDRV_RESET_ERR;
|
||||
}
|
||||
|
||||
return EEPROMDRV_OK;
|
||||
}
|
||||
|
||||
void eepRomInit(OwModeSel_e mode)
|
||||
{
|
||||
owInit();
|
||||
owSetMode(mode);
|
||||
}
|
@ -1,485 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: initiated by xxxx
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bsp.h"
|
||||
#include "ex_flash.h"
|
||||
#include "sctdef.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define TRANSFER_DATA_WIDTH (8)
|
||||
#define SPI_SSN_GPIO_INSTANCE RTE_SPI0_SSN_GPIO_INSTANCE
|
||||
#define SPI_SSN_GPIO_INDEX RTE_SPI0_SSN_GPIO_INDEX
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \brief driver instance declare */
|
||||
extern ARM_DRIVER_SPI Driver_SPI0;
|
||||
AP_PLAT_COMMON_DATA static ARM_DRIVER_SPI *spiMasterDrv = &CREATE_SYMBOL(Driver_SPI, 0);
|
||||
//volatile uint16_t gFid = 0;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCTION DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\fn exSpiFlashIoIint(void)
|
||||
\brief init SPI interface
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exSpiFlashIoIint(void)
|
||||
{
|
||||
// Initialize master spi
|
||||
spiMasterDrv->Initialize(NULL);
|
||||
// Power on
|
||||
spiMasterDrv->PowerControl(ARM_POWER_FULL);
|
||||
|
||||
// Configure master spi bus
|
||||
spiMasterDrv->Control(ARM_SPI_MODE_MASTER | ARM_SPI_CPOL0_CPHA0 | ARM_SPI_DATA_BITS(TRANSFER_DATA_WIDTH) |
|
||||
ARM_SPI_MSB_LSB | ARM_SPI_SS_MASTER_SW, 26000000U);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn exSpiFlashIoDeIint(void)
|
||||
\brief deinit SPI interface
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exSpiFlashIoDeIint(void)
|
||||
{
|
||||
// Initialize master spi
|
||||
spiMasterDrv->Uninitialize();
|
||||
// Power on
|
||||
spiMasterDrv->PowerControl(ARM_POWER_OFF);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashSetSpiCsHigh(void)
|
||||
\brief manual control CS PIN
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exFlashSetSpiCsHigh(void)
|
||||
{
|
||||
GPIO_pinWrite(SPI_SSN_GPIO_INSTANCE, 1 << SPI_SSN_GPIO_INDEX, 1 << SPI_SSN_GPIO_INDEX);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashSetSpiCsLow(void)
|
||||
\brief manual control CS PIN
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exFlashSetSpiCsLow(void)
|
||||
{
|
||||
GPIO_pinWrite(SPI_SSN_GPIO_INSTANCE, 1 << SPI_SSN_GPIO_INDEX, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn exflashWrByte(void)
|
||||
\brief Software SPI_Flash bus driver basic function, send a single byte to MOSI,
|
||||
* and accept MISO data at the same time. used for both cmd/data send
|
||||
\param[in] u8Data:Data sent on the MOSI data line
|
||||
\note
|
||||
*/
|
||||
static uint8_t exflashWrByte(uint8_t u8Data)
|
||||
{
|
||||
uint8_t u8Out = 0;
|
||||
|
||||
spiMasterDrv->Transfer(&u8Data, &u8Out, 1);
|
||||
|
||||
return u8Out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashWrEn(void)
|
||||
\brief send wr en cmd to flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exFlashWrEn(void)
|
||||
{
|
||||
exFlashSetSpiCsLow();
|
||||
exflashWrByte(WRITE_ENABLE_CMD);
|
||||
exFlashSetSpiCsHigh();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashWrDisen(void)
|
||||
\brief send wr disen cmd to flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exFlashWrDisen(void)
|
||||
{
|
||||
exFlashSetSpiCsLow();
|
||||
exflashWrByte(WRITE_DISABLE_CMD);
|
||||
exFlashSetSpiCsHigh();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashPollingBusyFlag(void)
|
||||
\brief read the BUSY field in flash reg and loop until done
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exFlashPollingBusyFlag(void)
|
||||
{
|
||||
uint8_t u8test;
|
||||
exFlashSetSpiCsLow();
|
||||
|
||||
do
|
||||
{
|
||||
exflashWrByte(READ_STATUS_REG1_CMD);
|
||||
u8test = exflashWrByte(Dummy_Byte1);
|
||||
} while ((u8test & 0x01) == 0x01);
|
||||
|
||||
exFlashSetSpiCsHigh();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashChipErase(void)
|
||||
\brief perform chip level erase, use with caution!!
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
void exFlashChipErase(void)
|
||||
{
|
||||
exFlashWrEn();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashSetSpiCsLow();
|
||||
exflashWrByte(CHIP_ERASE_CMD);
|
||||
exFlashSetSpiCsHigh();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashWrDisen();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashBlockErase(uint32_t u32Erase_Addr, uint8_t u8mode)
|
||||
\brief perform block level erase
|
||||
\param[in] u32Data_Addr :Block first address to start erasing
|
||||
u8mode :Erase mode 1=32K other=64K
|
||||
\note
|
||||
*/
|
||||
void exFlashBlockErase(uint32_t u32Erase_Addr, uint8_t u8mode)
|
||||
{
|
||||
exFlashWrEn();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashSetSpiCsLow();
|
||||
|
||||
if (u8mode == 1)
|
||||
{
|
||||
exflashWrByte(BLOCK_ERASE_32K_CMD);
|
||||
}
|
||||
else
|
||||
{
|
||||
exflashWrByte(BLOCK_ERASE_64K_CMD);
|
||||
}
|
||||
|
||||
exflashWrByte(u32Erase_Addr >> 16);
|
||||
exflashWrByte(u32Erase_Addr >> 8);
|
||||
exflashWrByte(u32Erase_Addr);
|
||||
exFlashSetSpiCsHigh();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashWrDisen();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashSectorErase(uint32_t u32Erase_Addr)
|
||||
\brief perform sector level erase, normally sector is 4K
|
||||
\param[in] u32Data_Addr :Block first address to start erasing
|
||||
\note
|
||||
*/
|
||||
void exFlashSectorErase(uint32_t u32Erase_Addr)
|
||||
{
|
||||
exFlashWrEn();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashSetSpiCsLow();
|
||||
|
||||
exflashWrByte(SECTOR_ERASE_CMD);
|
||||
|
||||
exflashWrByte(u32Erase_Addr >> 16);
|
||||
exflashWrByte(u32Erase_Addr >> 8);
|
||||
exflashWrByte(u32Erase_Addr);
|
||||
exFlashSetSpiCsHigh();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashWrDisen();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashPagePro(void)
|
||||
\brief starts writing data of up to 256 bytes at a specified address on one page (0~65535)
|
||||
\param[in] u32ReadAddr Start reading address(24bit)
|
||||
pu8Buffer:Data storage buffer
|
||||
u16NumByteToWrite:The number of bytes to write (maximum 256),
|
||||
* the number should not exceed the number of remaining bytes on the page!!!
|
||||
\note
|
||||
*/
|
||||
void exFlashPagePro(uint32_t u32WriteAddr, uint8_t *pu8Buffer, uint16_t u16NumByteToWrite)
|
||||
{
|
||||
uint16_t i;
|
||||
exFlashWrEn();
|
||||
exFlashSetSpiCsLow();
|
||||
exflashWrByte(PAGE_PROG_CMD);
|
||||
exflashWrByte((uint8_t)((u32WriteAddr) >> 16));
|
||||
exflashWrByte((uint8_t)((u32WriteAddr) >> 8));
|
||||
exflashWrByte((uint8_t)u32WriteAddr);
|
||||
|
||||
for (i = 0; i < u16NumByteToWrite; i++)exflashWrByte(pu8Buffer[i]);
|
||||
|
||||
exFlashSetSpiCsHigh();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashWrDisen();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashReadMDID(void)
|
||||
\brief reading device ID from flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
uint16_t exFlashReadMDID(void)
|
||||
{
|
||||
uint16_t u16Temp = 0;
|
||||
/* Enable chip select */
|
||||
exFlashSetSpiCsLow();
|
||||
/* Send "RDID " instruction */
|
||||
exflashWrByte(READ_ID_CMD);
|
||||
exflashWrByte(0x00);
|
||||
exflashWrByte(0x00);
|
||||
exflashWrByte(0x00);
|
||||
/* Read a byte from the FLASH */
|
||||
u16Temp |= exflashWrByte(Dummy_Byte1) << 8;
|
||||
u16Temp |= exflashWrByte(Dummy_Byte1);
|
||||
/* Disable chip select */
|
||||
exFlashSetSpiCsHigh();
|
||||
return u16Temp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn uint8_t exFlashRead(uint8_t *pu8Buffer, uint32_t u32ReadAddr, uint16_t u16NumByteToRead)
|
||||
\brief reading data of the specified length at the specified address
|
||||
\param[in] u32ReadAddr Start reading address(24bit)
|
||||
pu8Buffer Data storage buffer
|
||||
u16NumByteToRead The number of bytes to read(max 65535)
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashRead(uint8_t *pu8Buffer, uint32_t u32ReadAddr, uint16_t u16NumByteToRead)
|
||||
{
|
||||
uint16_t i;
|
||||
exFlashSetSpiCsLow();/* Enable chip select */
|
||||
exflashWrByte(READ_CMD);
|
||||
exflashWrByte(u32ReadAddr >> 16);
|
||||
exflashWrByte(u32ReadAddr >> 8);
|
||||
exflashWrByte(u32ReadAddr);
|
||||
|
||||
for (i = 0; i < u16NumByteToRead; i++)
|
||||
{
|
||||
pu8Buffer[i] = exflashWrByte(Dummy_Byte1); //Read one byte
|
||||
}
|
||||
|
||||
exFlashSetSpiCsHigh();/* Disable chip select */
|
||||
|
||||
return EXFLASH_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashErase(uint32_t eAddr, uint32_t size)
|
||||
\brief Erases the flash region. use different erase cmd according to size
|
||||
\param[in] eAddr addr to erase
|
||||
size erase len
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashErase(uint32_t eAddr, uint32_t size)
|
||||
{
|
||||
uint32_t offsetAddress;
|
||||
uint32_t remainLen;
|
||||
uint32_t currEraseSize;
|
||||
|
||||
|
||||
if ((eAddr&0xfff) !=0)
|
||||
{
|
||||
return EXFLASH_ERROR;
|
||||
}
|
||||
|
||||
offsetAddress = eAddr;
|
||||
remainLen = size;
|
||||
|
||||
while(remainLen > 0)
|
||||
{
|
||||
if (((offsetAddress&0xffff) ==0) && (remainLen >=0x10000))
|
||||
{
|
||||
exFlashBlockErase(offsetAddress,0);
|
||||
remainLen -= 0x10000;
|
||||
currEraseSize = 0x10000;
|
||||
}
|
||||
else if (((offsetAddress&0x7fff) ==0)&& (remainLen >=0x8000))
|
||||
{
|
||||
exFlashBlockErase(offsetAddress,1);
|
||||
remainLen-=0x8000;
|
||||
currEraseSize = 0x8000;
|
||||
}
|
||||
else
|
||||
{
|
||||
exFlashSectorErase(offsetAddress);
|
||||
currEraseSize = (remainLen >= 0x1000) ? 0x1000 : remainLen;
|
||||
remainLen -= currEraseSize;
|
||||
}
|
||||
|
||||
offsetAddress += currEraseSize;
|
||||
}
|
||||
|
||||
return EXFLASH_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashWrite(uint8_t* pData, uint32_t WriteAddr, uint32_t size)
|
||||
\brief Writes an amount of data to the QSPI flash.
|
||||
\param[in] pData: Data Pointer to write
|
||||
WriteAddr: Write start address
|
||||
Size: Size of data to write
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashWrite(uint8_t* pData, uint32_t WriteAddr, uint32_t size)
|
||||
{
|
||||
uint32_t end_addr, current_size, current_addr;
|
||||
//uint32_t irqMask;
|
||||
|
||||
// Calculation of the size between the write address and the end of the page
|
||||
//write non-aligned bytes first
|
||||
current_size = PAGE_SIZE - (WriteAddr%PAGE_SIZE);
|
||||
|
||||
// Check if the size of the data is less than the remaining place in the page
|
||||
if (current_size > size)
|
||||
{
|
||||
current_size = size;
|
||||
}
|
||||
|
||||
// Initialize the adress variables
|
||||
current_addr = WriteAddr;
|
||||
end_addr = WriteAddr + size;
|
||||
|
||||
// Perform the write page by page
|
||||
do
|
||||
{
|
||||
//irqMask = SaveAndSetIRQMask();
|
||||
|
||||
exFlashPagePro(current_addr,pData,current_size);
|
||||
|
||||
// Update the address and size variables for next page programming
|
||||
current_addr += current_size;
|
||||
pData += current_size;
|
||||
current_size = ((current_addr + PAGE_SIZE) > end_addr) ? (end_addr - current_addr) : PAGE_SIZE;
|
||||
|
||||
//RestoreIRQMask(irqMask);
|
||||
} while (current_addr < end_addr);
|
||||
|
||||
return EXFLASH_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashInit(void)
|
||||
\brief init the external spi flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashInit(void)
|
||||
{
|
||||
|
||||
exSpiFlashIoIint();
|
||||
//gFid = exFlashReadMDID();
|
||||
|
||||
return EXFLASH_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashDeinit(void)
|
||||
\brief deinit the external spi flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashDeinit(void)
|
||||
{
|
||||
exSpiFlashIoDeIint();
|
||||
return EXFLASH_OK;
|
||||
}
|
||||
|
@ -1,530 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: initiated by xxxx
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include DEBUG_LOG_HEADER_FILE
|
||||
|
||||
#include "mem_map.h"
|
||||
#include "bsp.h"
|
||||
#include "ex_flash.h"
|
||||
#include "ex_storage.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "mw_aal_hash.h"
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define EXSTO_EF_DATA_ADDR (EF_DATA_LOAD_ADDR)
|
||||
#define EXSTO_EF_DATA_SIZE (EF_DATA_LOAD_SIZE)
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t handle; /* starting addr @NFS, otherwise fd @FS */
|
||||
uint32_t size;
|
||||
uint32_t overhead; /* reserved zone size for a special purpose */
|
||||
uint32_t extras; /* some supplementary info */
|
||||
}ExStoZone_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ExStoZoneId_bm bmZoneId;
|
||||
ExStoZone_t zone[EXSTO_ZONE_MAXNUM];
|
||||
}ExStoZoneMan_t;
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
AP_PLAT_COMMON_BSS static ExStoZoneMan_t gExStoZoneMan;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCTION DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
\fn uint8_t exStorageInit(void)
|
||||
\brief init the external storage
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageInit(void)
|
||||
{
|
||||
gExStoZoneMan.bmZoneId |= EXSTO_BM_ZONE_EF_DATA;
|
||||
gExStoZoneMan.zone[EXSTO_ZONE_EF_DATA].handle = EXSTO_EF_DATA_ADDR;
|
||||
gExStoZoneMan.zone[EXSTO_ZONE_EF_DATA].size = EXSTO_EF_DATA_SIZE;
|
||||
gExStoZoneMan.zone[EXSTO_ZONE_EF_DATA].overhead = 0;
|
||||
gExStoZoneMan.zone[EXSTO_ZONE_EF_DATA].extras = 0;
|
||||
|
||||
if(exFlashInit() == EXFLASH_OK)
|
||||
return EXSTO_OK;
|
||||
else
|
||||
return EXSTO_EINIT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageDeinit(void)
|
||||
\brief deinit the external storage
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageDeinit(void)
|
||||
{
|
||||
memset(&gExStoZoneMan, 0, sizeof(ExStoZoneMan_t));
|
||||
|
||||
if(exFlashDeinit() == EXFLASH_OK)
|
||||
return EXSTO_OK;
|
||||
else
|
||||
return EXSTO_EDEINIT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageClear(uint32_t zid, uint32_t offset, uint32_t len)
|
||||
\brief erase the area to be write
|
||||
\param[in] zid resv for future use
|
||||
offset erase start addr
|
||||
len erase len
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageClear(uint32_t zid, uint32_t offset, uint32_t len)
|
||||
{
|
||||
uint32_t currLen = len;
|
||||
|
||||
if(zid >= EXSTO_ZONE_MAXNUM)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_CLEAR_0, P_WARNING, "clr: invalid zoneId(%d)! max(%d)\n",
|
||||
zid, EXSTO_ZONE_MAXNUM);
|
||||
#endif
|
||||
return EXSTO_EUNDEF;
|
||||
}
|
||||
|
||||
if(!(gExStoZoneMan.bmZoneId & (1 << zid)))
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_CLEAR_1, P_WARNING, "clr: no exSto zone(%d)! bmZoneId(0x%x)\n",
|
||||
zid, gExStoZoneMan.bmZoneId);
|
||||
#endif
|
||||
return EXSTO_EERASE;
|
||||
}
|
||||
|
||||
if(currLen > gExStoZoneMan.zone[zid].size)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_CLEAR_2, P_WARNING, "clr zone(%d): len(%d) overflowed! set it max(%d)!\n",
|
||||
zid, currLen, gExStoZoneMan.zone[zid].size);
|
||||
#endif
|
||||
currLen = gExStoZoneMan.zone[zid].size;
|
||||
}
|
||||
|
||||
if(offset >= gExStoZoneMan.zone[zid].size)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_CLEAR_3, P_ERROR, "clr zone(%d): invalid offset(%d)! max(%d)\n",
|
||||
zid, offset, gExStoZoneMan.zone[zid].size);
|
||||
#endif
|
||||
return EXSTO_EOVRFLOW;
|
||||
}
|
||||
|
||||
if(exFlashErase(gExStoZoneMan.zone[zid].handle + offset, len) == EXFLASH_OK)
|
||||
return EXSTO_OK;
|
||||
else
|
||||
return EXSTO_EERASE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageWrite(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen)
|
||||
\brief write data of the specified length at the specified address
|
||||
\param[in] zid resv for future use
|
||||
offset write start addr
|
||||
buf write buf
|
||||
bufLen write len
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageWrite(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen)
|
||||
{
|
||||
uint32_t currLen = bufLen;
|
||||
uint8_t *rdPtr = NULL;
|
||||
int32_t ret = 0;
|
||||
|
||||
if(zid >= EXSTO_ZONE_MAXNUM)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_WRITE_0, P_WARNING, "wr: invalid zoneId(%d)! max(%d)\n",
|
||||
zid, EXSTO_ZONE_MAXNUM);
|
||||
#endif
|
||||
return EXSTO_EUNDEF;
|
||||
}
|
||||
|
||||
if(!(gExStoZoneMan.bmZoneId & (1 << zid)))
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_WRITE_1, P_WARNING, "wr: no exSto zone(%d)! bmZoneId(0x%x)\n",
|
||||
zid, gExStoZoneMan.bmZoneId);
|
||||
#endif
|
||||
return EXSTO_EWRITE;
|
||||
}
|
||||
|
||||
if(currLen > gExStoZoneMan.zone[zid].size)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_WRITE_2, P_WARNING, "wr zone(%d): len(%d) overflowed! set it max(%d)!\n",
|
||||
zid, currLen, gExStoZoneMan.zone[zid].size);
|
||||
#endif
|
||||
currLen = gExStoZoneMan.zone[zid].size;
|
||||
}
|
||||
|
||||
if(offset >= gExStoZoneMan.zone[zid].size)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_WRITE_3, P_ERROR, "wr zone(%d): invalid offset(%d)! max(%d)\n",
|
||||
zid, offset, gExStoZoneMan.zone[zid].size);
|
||||
#endif
|
||||
return EXSTO_EOVRFLOW;
|
||||
}
|
||||
|
||||
//step1 write to flash
|
||||
if(exFlashWrite(buf, gExStoZoneMan.zone[zid].handle + offset, currLen) != EXFLASH_OK)
|
||||
return EXSTO_EWRITE;
|
||||
|
||||
//step2 read back and check
|
||||
rdPtr = mallocEc(currLen);
|
||||
if(rdPtr == NULL)
|
||||
{
|
||||
return EXSTO_EMALLOC;
|
||||
}
|
||||
|
||||
if(exFlashRead(rdPtr, gExStoZoneMan.zone[zid].handle + offset, currLen) != EXFLASH_OK)
|
||||
return EXSTO_EREAD;
|
||||
|
||||
ret = memcmp(buf,rdPtr,currLen);
|
||||
freeEc(rdPtr);
|
||||
|
||||
return ret ? EXSTO_EWRITE : EXSTO_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageRead(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen)
|
||||
\brief reading data of the specified length at the specified address
|
||||
\param[in] zid resv for future use
|
||||
offset read start addr
|
||||
buf read buf
|
||||
bufLen read len
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageRead(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen)
|
||||
{
|
||||
uint32_t currLen = bufLen;
|
||||
|
||||
if(zid >= EXSTO_ZONE_MAXNUM)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_READ_0, P_WARNING, "rd: invalid zoneId(%d)! max(%d)\n",
|
||||
zid, EXSTO_ZONE_MAXNUM);
|
||||
#endif
|
||||
return EXSTO_EUNDEF;
|
||||
}
|
||||
|
||||
if(!(gExStoZoneMan.bmZoneId & (1 << zid)))
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_READ_1, P_WARNING, "rd: no exSto zone(%d)! bmZoneId(0x%x)\n",
|
||||
zid, gExStoZoneMan.bmZoneId);
|
||||
#endif
|
||||
return EXSTO_EWRITE;
|
||||
}
|
||||
|
||||
if(currLen > gExStoZoneMan.zone[zid].size)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_READ_2, P_WARNING, "rd zone(%d): len(%d) overflowed! set it max(%d)!\n",
|
||||
zid, currLen, gExStoZoneMan.zone[zid].size);
|
||||
#endif
|
||||
currLen = gExStoZoneMan.zone[zid].size;
|
||||
}
|
||||
|
||||
if(offset >= gExStoZoneMan.zone[zid].size)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_READ_3, P_ERROR, "rd zone(%d): invalid offset(%d)! max(%d)\n",
|
||||
zid, offset, gExStoZoneMan.zone[zid].size);
|
||||
#endif
|
||||
return EXSTO_EOVRFLOW;
|
||||
}
|
||||
|
||||
if(exFlashRead(buf, gExStoZoneMan.zone[zid].handle + offset, currLen) == EXFLASH_OK)
|
||||
return EXSTO_OK;
|
||||
else
|
||||
return EXSTO_EREAD;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief exStorageGetZid(uint32_t addr, uint32_t *size, uint32_t *offset);
|
||||
* @details get the es zid according starting address and size of the zone
|
||||
*
|
||||
* @param addr the starting addr of the zone
|
||||
* @param size the size of the zone
|
||||
* @param offset the offset to starting addr of the zone
|
||||
* @return the zone ID.
|
||||
*/
|
||||
uint32_t exStorageGetZid(uint32_t addr, uint32_t *size, uint32_t *offset)
|
||||
{
|
||||
uint32_t zid = EXSTO_ZONE_EF_DATA;
|
||||
uint32_t zsz = EXSTO_EF_DATA_SIZE;
|
||||
|
||||
if(!size)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_GET_ZID_1, P_ERROR, "get zid: null size ptr!\n");
|
||||
#endif
|
||||
goto GET_ZID_END;
|
||||
}
|
||||
|
||||
if(!addr && !(*size))
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_GET_ZID_2, P_SIG, "get zid: set it default(%d: %d)!\n", zid, zsz);
|
||||
#endif
|
||||
goto GET_ZID_END;
|
||||
}
|
||||
|
||||
switch(addr)
|
||||
{
|
||||
case EXSTO_EF_DATA_ADDR:
|
||||
{
|
||||
zid = EXSTO_ZONE_EF_DATA;
|
||||
zsz = EXSTO_EF_DATA_SIZE;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_GET_ZID_3, P_WARNING, "get zid: unknown starting addr(0x%x)!\n", addr);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GET_ZID_END:
|
||||
if(!(*size))
|
||||
{
|
||||
*size = zsz;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(*size != zsz)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_GET_ZID_4, P_WARNING, "get zid: in_size(%d) != zone_size(%d)!\n", *size, zsz);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if(offset) *offset = 0;
|
||||
|
||||
return zid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief exStorageGetSize(uint32_t zid, uint8_t isOvhdExcl)
|
||||
* @details get the nvm size of specific exstorage zone
|
||||
*
|
||||
* @param zid zone Id of exstorage zone
|
||||
* @param isOvhdExcl overhead size of the zone is excluded or not
|
||||
* @return the size of zone.
|
||||
*/
|
||||
uint32_t exStorageGetSize(uint32_t zid, uint8_t isOvhdExcl)
|
||||
{
|
||||
if(zid >= EXSTO_ZONE_MAXNUM)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_GET_SZ_0, P_WARNING, "get size: invalid zoneId(%d)! max(%d)\n",
|
||||
zid, EXSTO_ZONE_MAXNUM);
|
||||
#endif
|
||||
return EXSTO_EUNDEF;
|
||||
}
|
||||
|
||||
if(!(gExStoZoneMan.bmZoneId & (1 << zid)))
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_GET_SZ_1, P_WARNING, "get size: no exSto zone(%d)! bmZoneId(0x%x)\n",
|
||||
zid, gExStoZoneMan.bmZoneId);
|
||||
#endif
|
||||
return EXSTO_EWRITE;
|
||||
}
|
||||
|
||||
return (gExStoZoneMan.zone[zid].size - (isOvhdExcl ? gExStoZoneMan.zone[zid].overhead : 0));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief exStorageVerifyPkg(uint32_t *pkgState)
|
||||
* @details validate the data pkg
|
||||
*
|
||||
* @param pkgState the last state of data pkg
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t exStorageVerifyPkg(uint32_t zid, uint8_t *hash, uint32_t pkgSize, uint32_t *pkgState)
|
||||
{
|
||||
int32_t retCode = EXSTO_EUNDEF;
|
||||
uint8_t *buffer = NULL;
|
||||
uint8_t isLast = 0;
|
||||
uint32_t offset = 0;
|
||||
uint32_t readSize = 0;
|
||||
uint32_t remnSize = pkgSize;
|
||||
uint32_t stepSize = 4096;
|
||||
uint8_t outHash[32] = {0};
|
||||
MwAalSha256Ctx_t sha256;
|
||||
|
||||
/* no need to verify the pkg */
|
||||
if(!hash) return EXSTO_OK;
|
||||
|
||||
if(zid >= EXSTO_ZONE_MAXNUM)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_1, P_WARNING, "verify pkg: invalid zoneId(%d)! max(%d)\n",
|
||||
zid, EXSTO_ZONE_MAXNUM);
|
||||
#endif
|
||||
return EXSTO_EUNDEF;
|
||||
}
|
||||
|
||||
if(!(gExStoZoneMan.bmZoneId & (1 << zid)))
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_2, P_WARNING, "verify pkg: no exSto zone(%d)! bmZoneId(0x%x)\n",
|
||||
zid, gExStoZoneMan.bmZoneId);
|
||||
#endif
|
||||
return EXSTO_EWRITE;
|
||||
}
|
||||
|
||||
mwAalInitSha256(&sha256, 0);
|
||||
|
||||
buffer = (uint8_t*)mallocEc(stepSize);
|
||||
if(buffer == NULL)
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_3, P_WARNING, "verify pkg: zone(%d) malloc(%d) failure!\n",
|
||||
zid, stepSize);
|
||||
#endif
|
||||
goto VERIFY_PKG_END;
|
||||
}
|
||||
|
||||
|
||||
for(offset = 0; offset < pkgSize; offset += readSize)
|
||||
{
|
||||
if(remnSize > stepSize)
|
||||
{
|
||||
isLast = 0;
|
||||
readSize = stepSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
isLast = 1;
|
||||
readSize = remnSize;
|
||||
}
|
||||
remnSize -= readSize;
|
||||
|
||||
if(EXSTO_OK != exStorageRead(zid, offset, buffer, readSize))
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_4, P_WARNING, "zid(%d) flash read failure!\n", zid);
|
||||
#endif
|
||||
goto VERIFY_PKG_END;
|
||||
}
|
||||
|
||||
if(0 != mwAalUpdateSha256(&sha256, buffer, outHash, readSize, isLast))
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_5, P_ERROR, "zid(%d) flash sha256sum fail!\n", zid);
|
||||
#endif
|
||||
goto VERIFY_PKG_END;
|
||||
}
|
||||
}
|
||||
|
||||
if(memcmp(outHash, hash, 32))
|
||||
{
|
||||
#ifndef BL_FOTA_USE_EXT_STORAGE
|
||||
ECPLAT_DUMP(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_6, P_WARNING, "input hash: ", 32, hash);
|
||||
ECPLAT_DUMP(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_7, P_WARNING, "calc hash : ", 32, outHash);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
retCode = EXSTO_OK;
|
||||
}
|
||||
|
||||
VERIFY_PKG_END:
|
||||
if(buffer) freeEc(buffer);
|
||||
|
||||
mwAalDeinitSha256(&sha256);
|
||||
|
||||
if(pkgState)
|
||||
{
|
||||
*pkgState = 0;
|
||||
}
|
||||
|
||||
return retCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief exStorageGetUpdResult(uint32_t zid, int32_t *pkgState)
|
||||
* @details get the updated result
|
||||
*
|
||||
* @param pkgState the last state of data pkg
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t exStorageGetUpdResult(uint32_t zid, int32_t *pkgState)
|
||||
{
|
||||
if(pkgState)
|
||||
{
|
||||
*pkgState = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,231 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2020-, Copyrigths of EigenComm Ltd.
|
||||
* File name: keypad.c
|
||||
* Description: EC618 keypad driver source file
|
||||
* History: Rev1.0 2020-12-17
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "ostask.h"
|
||||
#include "osasys.h"
|
||||
#include "bsp.h"
|
||||
#include "bsp_custom.h"
|
||||
#include "ec7xx.h"
|
||||
#include "keypad.h"
|
||||
#include "kpc.h"
|
||||
#include "timer.h"
|
||||
#ifdef FEATURE_SUBSYS_SYSLOG_ENABLE
|
||||
#include "syslog.h"
|
||||
#endif
|
||||
#define KPC_TRACE(subId, argLen, format, ...) \
|
||||
ECOMM_TRACE(UNILOG_KPC, subId, P_VALUE, argLen, format, ##__VA_ARGS__)
|
||||
|
||||
#define KPC_EVENT_QUEUE_SIZE (64)
|
||||
osSemaphoreId_t kpcSemaphore = NULL;
|
||||
|
||||
const uint8_t keyCodes[ROWS][COLUMNS] =
|
||||
{
|
||||
{FUNC_CODE_YES, FUNC_CODE_DIR_U, FUNC_CODE_DIR_D,FUNC_CODE_DIR_L},
|
||||
{'1', '2', '3', FUNC_CODE_MENU},
|
||||
{'4', '5', '6', FUNC_CODE_BACK},
|
||||
{'7', '8', '9', FUNC_CODE_DIAL},
|
||||
{'*', '0', '#', FUNC_CODE_DIR_R}, // '*' '#'是非打印字符
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief KPC event report queue typedef
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
KpcReportEvent_t events[KPC_EVENT_QUEUE_SIZE];
|
||||
uint32_t head;
|
||||
uint32_t tail;
|
||||
} KpcEventQueue_t;
|
||||
|
||||
static KpcEventQueue_t gKpcEventQueue;
|
||||
|
||||
static void KPC_eventQueueInit(void)
|
||||
{
|
||||
memset(&gKpcEventQueue, 0, sizeof(gKpcEventQueue));
|
||||
}
|
||||
|
||||
int32_t KPC_eventQueueRead(KpcReportEvent_t *eventPtr)
|
||||
{
|
||||
uint32_t mask;
|
||||
|
||||
mask = SaveAndSetIRQMask();
|
||||
|
||||
if(gKpcEventQueue.tail == gKpcEventQueue.head)
|
||||
{
|
||||
// queue is empty
|
||||
RestoreIRQMask(mask);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
*eventPtr = gKpcEventQueue.events[gKpcEventQueue.head];
|
||||
gKpcEventQueue.head = (gKpcEventQueue.head + 1) % KPC_EVENT_QUEUE_SIZE;
|
||||
|
||||
RestoreIRQMask(mask);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// no need to perform atomic access since this function is called only in ISR
|
||||
static int32_t KPC_eventQueueWrite(KpcReportEvent_t* eventPtr)
|
||||
{
|
||||
if(((gKpcEventQueue.tail + 1) % KPC_EVENT_QUEUE_SIZE) == gKpcEventQueue.head)
|
||||
{
|
||||
// queue is full, need to handle
|
||||
return -1;
|
||||
}
|
||||
|
||||
gKpcEventQueue.events[gKpcEventQueue.tail] = *eventPtr;
|
||||
gKpcEventQueue.tail = (gKpcEventQueue.tail + 1) % KPC_EVENT_QUEUE_SIZE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn void KPC_callback()
|
||||
\brief KPC interrupt service routine
|
||||
\return
|
||||
*/
|
||||
void KPC_callback(KpcReportEvent_t event)
|
||||
{
|
||||
if(KPC_eventQueueWrite(&event) == -1)
|
||||
{
|
||||
// Queue is full
|
||||
}
|
||||
#ifdef FEATURE_SUBSYS_INPUT_ENABLE
|
||||
inputNotify();
|
||||
#endif
|
||||
if (kpcSemaphore != NULL)
|
||||
{
|
||||
osSemaphoreRelease(kpcSemaphore);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void keypadScan(void)
|
||||
{
|
||||
if(kpcSemaphore!=NULL)
|
||||
{
|
||||
KpcReportEvent_t event;
|
||||
if(KPC_eventQueueRead(&event) != -1)
|
||||
{
|
||||
// SYSLOG_INFO("r%d,c%d,%c\r\n",event.row,event.column,keyCodes[event.row][event.column]);
|
||||
if(event.value == KPC_REPORT_KEY_RELEASE)
|
||||
{
|
||||
printf("key R-%c\r\n", keyCodes[event.row][event.column]);
|
||||
// KPC_TRACE(keyPadRelease, 3, "r%d,c%d,%c",event.row,event.column,keyCodes[event.row][event.column]);
|
||||
}
|
||||
else if(event.value == KPC_REPORT_KEY_PRESS)
|
||||
{
|
||||
printf("key P-%c\r\n", keyCodes[event.row][event.column]);
|
||||
// KPC_TRACE(keyPadPressed, 3, "r%d,c%d,%c",event.row,event.column,keyCodes[event.row][event.column]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void keypadLoop(void)
|
||||
{
|
||||
osSemaphoreAcquire(kpcSemaphore, osWaitForever);
|
||||
keypadScan();
|
||||
}
|
||||
|
||||
void keypadInit(void)
|
||||
{
|
||||
if(kpcSemaphore != NULL){
|
||||
osSemaphoreDelete(kpcSemaphore);
|
||||
}
|
||||
kpcSemaphore = osSemaphoreNew(1, 1, NULL);
|
||||
|
||||
PadConfig_t padConfig;
|
||||
PAD_getDefaultConfig(&padConfig);
|
||||
padConfig.pullSelect = PAD_PULL_AUTO;
|
||||
padConfig.pullUpEnable = PAD_PULL_UP_DISABLE;
|
||||
padConfig.pullDownEnable = PAD_PULL_DOWN_DISABLE;
|
||||
|
||||
padConfig.mux = KEYPAD_ROW_0_ALT_FUNC;
|
||||
PAD_setPinConfig(KEYPAD_ROW_0_PAD_INDEX, &padConfig);
|
||||
|
||||
padConfig.mux = KEYPAD_ROW_1_ALT_FUNC;
|
||||
PAD_setPinConfig(KEYPAD_ROW_1_PAD_INDEX, &padConfig);
|
||||
|
||||
padConfig.mux = KEYPAD_ROW_2_ALT_FUNC;
|
||||
PAD_setPinConfig(KEYPAD_ROW_2_PAD_INDEX, &padConfig);
|
||||
|
||||
padConfig.mux = KEYPAD_ROW_3_ALT_FUNC;
|
||||
PAD_setPinConfig(KEYPAD_ROW_3_PAD_INDEX, &padConfig);
|
||||
|
||||
padConfig.mux = KEYPAD_ROW_4_ALT_FUNC;
|
||||
PAD_setPinConfig(KEYPAD_ROW_4_PAD_INDEX, &padConfig);
|
||||
|
||||
padConfig.pullSelect = PAD_PULL_INTERNAL;
|
||||
padConfig.pullUpEnable = PAD_PULL_UP_ENABLE;
|
||||
padConfig.pullDownEnable = PAD_PULL_DOWN_DISABLE;
|
||||
|
||||
padConfig.mux = KEYPAD_COLUMN_0_ALT_FUNC;
|
||||
PAD_setPinConfig(KEYPAD_COLUMN_0_PAD_INDEX, &padConfig);
|
||||
|
||||
padConfig.mux = KEYPAD_COLUMN_1_ALT_FUNC;
|
||||
PAD_setPinConfig(KEYPAD_COLUMN_1_PAD_INDEX, &padConfig);
|
||||
|
||||
padConfig.mux = KEYPAD_COLUMN_2_ALT_FUNC;
|
||||
PAD_setPinConfig(KEYPAD_COLUMN_2_PAD_INDEX, &padConfig);
|
||||
|
||||
padConfig.mux = KEYPAD_COLUMN_3_ALT_FUNC;
|
||||
PAD_setPinConfig(KEYPAD_COLUMN_3_PAD_INDEX, &padConfig);
|
||||
|
||||
// KpcReportEvent_t event;
|
||||
KpcConfig_t kpcConfig;
|
||||
KPC_getDefaultConfig(&kpcConfig);
|
||||
//kpcConfig.debounceConfig.debounceClkDivRatio = KPC_DEBOUNCE_CLK_DIV_RATIO_16;
|
||||
kpcConfig.validRowMask = KPC_ROW_ALL;
|
||||
//KPC_ROW_4 | KPC_ROW_3 | KPC_ROW_2 | KPC_ROW_1 | KPC_ROW_0;
|
||||
kpcConfig.validColumnMask = KPC_COLUMN_3 | KPC_COLUMN_2 | KPC_COLUMN_1 | KPC_COLUMN_0;
|
||||
|
||||
// 240ms (6*40ms) autorepeat delay
|
||||
kpcConfig.autoRepeat.delay = 6;
|
||||
KPC_deInit();
|
||||
KPC_init(&kpcConfig, KPC_callback);
|
||||
KPC_eventQueueInit();
|
||||
KPC_startScan();
|
||||
}
|
||||
#ifdef FEATURE_SUBSYS_GUI_LVGL_ENABLE
|
||||
#include "lv_port_indev.h"
|
||||
void keypad_read(lv_indev_drv_t * drv, lv_indev_data_t * data) {
|
||||
KpcReportEvent_t event;
|
||||
if(KPC_eventQueueRead(&event) != -1)
|
||||
{
|
||||
if(event.value == KPC_REPORT_KEY_RELEASE)
|
||||
{
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
else if(event.value == KPC_REPORT_KEY_PRESS){
|
||||
data->state = LV_INDEV_STATE_PR ;
|
||||
switch(keyCodes[event.row][event.column]) {
|
||||
case FUNC_CODE_DIR_U:
|
||||
data->key = LV_KEY_UP;
|
||||
break;
|
||||
case FUNC_CODE_DIR_D:
|
||||
data->key = LV_KEY_DOWN;
|
||||
break;
|
||||
case FUNC_CODE_DIR_L:
|
||||
data->key = LV_KEY_LEFT;
|
||||
break;
|
||||
case FUNC_CODE_DIR_R:
|
||||
data->key = LV_KEY_RIGHT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// SYSLOG_INFO("%d,%d,%c\r\n",data->state,data->key,keyCodes[event.row][event.column]);
|
||||
}
|
||||
}
|
||||
#endif
|
@ -1,284 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include "bsp.h"
|
||||
#include "bsp_custom.h"
|
||||
#include "lcdDrv.h"
|
||||
#include "lcdComm.h"
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
void yuv422ToRgb565(const void* inbuf, void* outbuf, int width, int height)
|
||||
{
|
||||
const uint8_t* yuv422_buf = (const uint8_t*)inbuf;
|
||||
uint16_t* rgb565_buf = (uint16_t*)outbuf;
|
||||
|
||||
for (int row = 0; row < height; row++) {
|
||||
for (int col = 0; col < width; col++) {
|
||||
// Extract Y, U, and V components
|
||||
int y = *yuv422_buf++;
|
||||
int u = *yuv422_buf++;
|
||||
int v = *yuv422_buf++;
|
||||
|
||||
// Convert YUV to RGB
|
||||
int r = y + ((v - 128) * 1404) / 1000;
|
||||
int g = y - ((u - 128) * 343) / 1000 - ((v - 128) * 711) / 1000;
|
||||
int b = y + ((u - 128) * 1772) / 1000;
|
||||
|
||||
// Clamp RGB values to the valid range
|
||||
r = (r < 0) ? 0 : ((r > 255) ? 255 : r);
|
||||
g = (g < 0) ? 0 : ((g > 255) ? 255 : g);
|
||||
b = (b < 0) ? 0 : ((b > 255) ? 255 : b);
|
||||
|
||||
// Convert RGB to 565 format
|
||||
uint16_t r5 = (r * 249 + 1014) >> 11;
|
||||
uint16_t g6 = (g * 253 + 505) >> 10;
|
||||
uint16_t b5 = (b * 249 + 1014) >> 11;
|
||||
|
||||
// Combine RGB components into a 16-bit value
|
||||
uint16_t rgb565 = (r5 << 11) | (g6 << 5) | b5;
|
||||
|
||||
// Store the RGB565 value in the output buffer
|
||||
*rgb565_buf++ = rgb565;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
void yuv420ToRgb565(const void* inbuf, void* outbuf, int width, int height) {
|
||||
const uint8_t* yuv420_buf = (const uint8_t*)inbuf;
|
||||
uint16_t* rgb565_buf = (uint16_t*)outbuf;
|
||||
|
||||
int y_size = width * height;
|
||||
int uv_size = y_size / 4;
|
||||
const uint8_t* y_plane = yuv420_buf;
|
||||
const uint8_t* u_plane = yuv420_buf + y_size;
|
||||
const uint8_t* v_plane = u_plane + uv_size;
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
int y_index = y * width + x;
|
||||
int uv_index = (y / 2) * (width / 2) + (x / 2);
|
||||
|
||||
// Extract Y, U, and V components
|
||||
int yy = y_plane[y_index];
|
||||
int uu = u_plane[uv_index] - 128;
|
||||
int vv = v_plane[uv_index] - 128;
|
||||
|
||||
// Convert YUV to RGB
|
||||
int r = yy + vv + ((vv * 103) >> 8);
|
||||
int g = yy - ((uu * 88) >> 8) - ((vv * 183) >> 8);
|
||||
int b = yy + uu + ((uu * 198) >> 8);
|
||||
|
||||
// Clamp RGB values to the valid range
|
||||
r = (r < 0) ? 0 : ((r > 255) ? 255 : r);
|
||||
g = (g < 0) ? 0 : ((g > 255) ? 255 : g);
|
||||
b = (b < 0) ? 0 : ((b > 255) ? 255 : b);
|
||||
|
||||
// Convert RGB to 565 format
|
||||
uint16_t r5 = (r * 249 + 1014) >> 11;
|
||||
uint16_t g6 = (g * 253 + 505) >> 10;
|
||||
uint16_t b5 = (b * 249 + 1014) >> 11;
|
||||
|
||||
// Combine RGB components into a 16-bit value
|
||||
uint16_t rgb565 = (r5 << 11) | (g6 << 5) | b5;
|
||||
|
||||
// Store the RGB565 value in the output buffer
|
||||
*rgb565_buf++ = rgb565;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
void rgb565ToYuv422(const void* inbuf, void* outbuf, int width, int height) {
|
||||
const uint16_t* rgb565 = (const uint16_t*)inbuf;
|
||||
uint8_t* yuv422 = (uint8_t*)outbuf;
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
uint16_t rgb = *rgb565++;
|
||||
uint8_t r = (rgb >> 11) & 0x1F;
|
||||
uint8_t g = (rgb >> 5) & 0x3F;
|
||||
uint8_t b = rgb & 0x1F;
|
||||
|
||||
// Convert RGB to YUV
|
||||
int yy = ((66 * r + 129 * g + 25 * b + 128) >> 8) + 16;
|
||||
int uu = ((-38 * r - 74 * g + 112 * b + 128) >> 8) + 128;
|
||||
int vv = ((112 * r - 94 * g - 18 * b + 128) >> 8) + 128;
|
||||
|
||||
// Clamp YUV values to the valid range
|
||||
yy = (yy < 0) ? 0 : ((yy > 255) ? 255 : yy);
|
||||
uu = (uu < 0) ? 0 : ((uu > 255) ? 255 : uu);
|
||||
vv = (vv < 0) ? 0 : ((vv > 255) ? 255 : vv);
|
||||
|
||||
// Store YUV values
|
||||
*yuv422++ = yy;
|
||||
if (x % 2 == 0) {
|
||||
*yuv422++ = uu;
|
||||
*yuv422++ = vv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
void rgb565ToYuv420(const void* inbuf, void* outbuf, int width, int height) {
|
||||
const uint16_t* rgb565 = (const uint16_t*)inbuf;
|
||||
uint8_t* yuv420 = (uint8_t*)outbuf;
|
||||
uint8_t* yplane = yuv420;
|
||||
uint8_t* uplane = yuv420 + width * height;
|
||||
uint8_t* vplane = uplane + ((width + 1) / 2) * ((height + 1) / 2);
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
uint16_t rgb = *rgb565++;
|
||||
uint8_t r = (rgb >> 11) & 0x1F;
|
||||
uint8_t g = (rgb >> 5) & 0x3F;
|
||||
uint8_t b = rgb & 0x1F;
|
||||
|
||||
// Convert RGB to YUV
|
||||
int yy = ((66 * r + 129 * g + 25 * b + 128) >> 8) + 16;
|
||||
int uu = ((-38 * r - 74 * g + 112 * b + 128) >> 8) + 128;
|
||||
int vv = ((112 * r - 94 * g - 18 * b + 128) >> 8) + 128;
|
||||
|
||||
// Clamp YUV values to the valid range
|
||||
yy = (yy < 0) ? 0 : ((yy > 255) ? 255 : yy);
|
||||
uu = (uu < 0) ? 0 : ((uu > 255) ? 255 : uu);
|
||||
vv = (vv < 0) ? 0 : ((vv > 255) ? 255 : vv);
|
||||
|
||||
// Store YUV values
|
||||
*yplane++ = yy;
|
||||
if (y % 2 == 0 && x % 2 == 0) {
|
||||
*uplane++ = uu;
|
||||
if (x < width - 1) {
|
||||
*vplane++ = vv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
|
||||
// Define RGB565 and YCbCr pixel structures
|
||||
typedef struct {
|
||||
uint16_t rgb; // 5 bits for R, 6 bits for G, 5 bits for B
|
||||
} RGB565Pixel;
|
||||
|
||||
// Define RGB888 and YCbCr pixel structures
|
||||
typedef struct {
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
} RGB888Pixel;
|
||||
|
||||
typedef struct {
|
||||
uint8_t y;
|
||||
uint8_t cb;
|
||||
uint8_t cr;
|
||||
} YCbCrPixel;
|
||||
|
||||
// Function to convert RGB565 to RGB888
|
||||
RGB888Pixel rgb565ToRgb888(RGB565Pixel rgb565) {
|
||||
RGB888Pixel rgb888;
|
||||
rgb888.r = (rgb565.rgb >> 11) & 0x1F; // Red component
|
||||
rgb888.g = (rgb565.rgb >> 5) & 0x3F; // Green component
|
||||
rgb888.b = rgb565.rgb & 0x1F; // Blue component
|
||||
|
||||
// Scale up to 8 bits
|
||||
rgb888.r = (rgb888.r << 3) | (rgb888.r >> 2);
|
||||
rgb888.g = (rgb888.g << 2) | (rgb888.g >> 4);
|
||||
rgb888.b = (rgb888.b << 3) | (rgb888.b >> 2);
|
||||
|
||||
return rgb888;
|
||||
}
|
||||
|
||||
// Function to convert RGB888 to YCbCr
|
||||
YCbCrPixel rgb888ToYCbCr(RGB888Pixel rgb888) {
|
||||
YCbCrPixel ycbcr;
|
||||
ycbcr.y = (uint8_t)( 0.299 * rgb888.r + 0.587 * rgb888.g + 0.114 * rgb888.b);
|
||||
ycbcr.cb = (uint8_t)(-0.169 * rgb888.r - 0.331 * rgb888.g + 0.500 * rgb888.b + 128);
|
||||
ycbcr.cr = (uint8_t)( 0.500 * rgb888.r - 0.419 * rgb888.g - 0.081 * rgb888.b + 128);
|
||||
return ycbcr;
|
||||
}
|
||||
|
||||
// Function to convert RGB565 to YCbCr
|
||||
void rgb565ToYCbCr(const void* inbuf, void* outbuf, int width, int height) {
|
||||
const RGB565Pixel* inRGB565 = (const RGB565Pixel*)inbuf;
|
||||
YCbCrPixel* outYCbCr = (YCbCrPixel*)outbuf;
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
RGB565Pixel rgb565 = inRGB565[y * width + x];
|
||||
|
||||
// Convert RGB565 to RGB888
|
||||
RGB888Pixel rgb888 = rgb565ToRgb888(rgb565);
|
||||
|
||||
// Convert RGB888 to YCbCr
|
||||
YCbCrPixel ycbcr = rgb888ToYCbCr(rgb888);
|
||||
|
||||
// Store YCbCr in the output buffer
|
||||
outYCbCr[y * width + x] = ycbcr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Function to convert YCbCr to RGB888
|
||||
RGB888Pixel yCbCrToRgb888(YCbCrPixel ycbcr) {
|
||||
RGB888Pixel rgb888;
|
||||
int r = ycbcr.y + ((ycbcr.cr - 128) * 1.402);
|
||||
int g = ycbcr.y - ((ycbcr.cb - 128) * 0.344) - ((ycbcr.cr - 128) * 0.714);
|
||||
int b = ycbcr.y + ((ycbcr.cb - 128) * 1.772);
|
||||
|
||||
// Clamp the RGB values to the valid range [0, 255]
|
||||
rgb888.r = (r < 0) ? 0 : ((r > 255) ? 255 : r);
|
||||
rgb888.g = (g < 0) ? 0 : ((g > 255) ? 255 : g);
|
||||
rgb888.b = (b < 0) ? 0 : ((b > 255) ? 255 : b);
|
||||
|
||||
return rgb888;
|
||||
}
|
||||
|
||||
// Function to convert RGB888 to RGB565
|
||||
RGB565Pixel rgb888ToRgb565(RGB888Pixel rgb888) {
|
||||
RGB565Pixel rgb565;
|
||||
rgb565.rgb = ((rgb888.r >> 3) << 11) | ((rgb888.g >> 2) << 5) | (rgb888.b >> 3);
|
||||
return rgb565;
|
||||
}
|
||||
|
||||
// Function to convert YCbCr to RGB565
|
||||
void yCbCrToRgb565(const void* inbuf, void* outbuf, int width, int height) {
|
||||
const YCbCrPixel* inYCbCr = (const YCbCrPixel*)inbuf;
|
||||
RGB565Pixel* outRGB565 = (RGB565Pixel*)outbuf;
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
YCbCrPixel ycbcr = inYCbCr[y * width + x];
|
||||
|
||||
// Convert YCbCr to RGB888
|
||||
RGB888Pixel rgb888 = yCbCrToRgb888(ycbcr);
|
||||
|
||||
// Convert RGB888 to RGB565
|
||||
RGB565Pixel rgb565 = rgb888ToRgb565(rgb888);
|
||||
|
||||
// Store RGB565 in the output buffer
|
||||
outRGB565[y * width + x] = rgb565;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,754 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "bsp.h"
|
||||
#include "bsp_custom.h"
|
||||
#include "lspi.h"
|
||||
#include "lcdDrv.h"
|
||||
#include "lcdComm.h"
|
||||
#include "timer.h"
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
#include "osasys.h"
|
||||
#include "cmsis_os2.h"
|
||||
#endif
|
||||
#include "sctdef.h"
|
||||
|
||||
|
||||
extern void slpManAONIOPowerOn(void);
|
||||
AP_PLAT_COMMON_DATA lspiDrvInterface_t *lcdDrv = &lspiDrvInterface2;
|
||||
AP_PLAT_COMMON_BSS int32_t lcdDmaTxCh = 0;
|
||||
AP_PLAT_COMMON_BSS static lcdUspCb userUspCb = NULL;
|
||||
AP_PLAT_COMMON_BSS static lcdUspCb userDmaCb = NULL;
|
||||
PLAT_FM_ZI DmaDescriptor_t __ALIGNED(16) lcdDmaTxDesc[DMA_DESC_MAX];
|
||||
extern lcdDrvFunc_t* lcdDevHandle;
|
||||
AP_PLAT_COMMON_DATA DmaTransferConfig_t lcdDmaTxCfg =
|
||||
{
|
||||
NULL,
|
||||
(void *)&(LSPI2->TFIFO),
|
||||
DMA_FLOW_CONTROL_TARGET,
|
||||
DMA_ADDRESS_INCREMENT_SOURCE,
|
||||
DMA_DATA_WIDTH_FOUR_BYTES,
|
||||
DMA_BURST_32_BYTES,
|
||||
DMA_BULK_NUM
|
||||
};
|
||||
|
||||
void lcdDrvDelay(uint32_t ms)
|
||||
{
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
if (ms < 1)
|
||||
{
|
||||
osDelay(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
osDelay(ms);
|
||||
}
|
||||
#else
|
||||
extern void delay_us(uint32_t us);
|
||||
delay_us(ms*1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void uspIrqCb(void)
|
||||
{
|
||||
LSPI2->STAS |= (1<<31);
|
||||
if (lcdDevHandle->uspIrq4CamCb)
|
||||
{
|
||||
lcdDevHandle->uspIrq4CamCb(lcdDevHandle);
|
||||
}
|
||||
|
||||
if (lcdDevHandle->uspIrq4FillCb)
|
||||
{
|
||||
lcdDevHandle->uspIrq4FillCb(lcdDevHandle);
|
||||
}
|
||||
|
||||
if (userUspCb)
|
||||
{
|
||||
userUspCb();
|
||||
}
|
||||
}
|
||||
|
||||
static void dmaIrqCb(uint32_t event)
|
||||
{
|
||||
switch(event)
|
||||
{
|
||||
case DMA_EVENT_END:
|
||||
{
|
||||
//isFrameDmaWaiting = false;
|
||||
|
||||
if(userDmaCb)
|
||||
{
|
||||
userDmaCb(event);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DMA_EVENT_ERROR:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int dmaInit(lcdDmaCb cb)
|
||||
{
|
||||
if (lcdDmaTxCh)
|
||||
{
|
||||
DMA_closeChannel(DMA_INSTANCE_MP,lcdDmaTxCh);
|
||||
}
|
||||
|
||||
lcdDmaTxCh = DMA_openChannel(DMA_INSTANCE_MP);
|
||||
if (ARM_DMA_ERROR_CHANNEL_ALLOC == lcdDmaTxCh)
|
||||
{
|
||||
EC_ASSERT(0,0,0,0);
|
||||
}
|
||||
|
||||
if(cb)
|
||||
{
|
||||
userDmaCb = cb;
|
||||
}
|
||||
|
||||
DMA_setChannelRequestSource(DMA_INSTANCE_MP, lcdDmaTxCh, DMA_REQUEST_USP2_TX);
|
||||
DMA_rigisterChannelCallback(DMA_INSTANCE_MP, lcdDmaTxCh, dmaIrqCb);
|
||||
DMA_enableChannelInterrupts(DMA_INSTANCE_MP, lcdDmaTxCh, DMA_END_INTERRUPT_ENABLE);
|
||||
return lcdDmaTxCh;
|
||||
}
|
||||
|
||||
void dmaStartStop(bool start)
|
||||
{
|
||||
if(start)
|
||||
{
|
||||
DMA_loadChannelDescriptorAndRun(DMA_INSTANCE_MP, lcdDmaTxCh, lcdDmaTxDesc);
|
||||
}
|
||||
else
|
||||
{
|
||||
DMA_stopChannel(DMA_INSTANCE_MP, lcdDmaTxCh, false);
|
||||
}
|
||||
}
|
||||
|
||||
void lcdEnable()
|
||||
{
|
||||
lspiBusSel.lspiBusEn = 1; // choose lspi bus
|
||||
lspiCtrl.enable = 1;
|
||||
lcdDrv->ctrl(LSPI_CTRL_BUS_SEL, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
}
|
||||
|
||||
|
||||
#if defined TYPE_EC718M
|
||||
|
||||
void lcdMspiSet(uint8_t enable, uint8_t addrLane, uint8_t dataLane, uint8_t instruction)
|
||||
{
|
||||
lspiMspiCtrl.mspiEn = enable;
|
||||
lspiMspiCtrl.mspiAddrLane = addrLane;
|
||||
lspiMspiCtrl.mspiDataLane = dataLane;
|
||||
lspiMspiCtrl.mspiInst = instruction;
|
||||
lcdDrv->ctrl(LSPI_MSPI_CTRL, 0);
|
||||
}
|
||||
|
||||
void lcdMspiHsyncSet(uint8_t hsyncAddr, uint8_t hsyncInst, uint16_t vbpNum, uint16_t vfpNum)
|
||||
{
|
||||
lspiVsyncCtrl.hsyncAddr = hsyncAddr;
|
||||
lspiVsyncCtrl.hsyncInst = hsyncInst;
|
||||
lspiVsyncCtrl.vbp = vbpNum;
|
||||
lspi8080Ctrl.vfp = vfpNum;
|
||||
lcdDrv->ctrl(LSPI_VSYNC_CTRL, 0);
|
||||
lcdDrv->ctrl(LSPI_8080_CTRL, 0);
|
||||
}
|
||||
|
||||
void lcdMspiVsyncSet(uint8_t vsyncEnable, uint8_t vsyncInst, uint8_t lspiDiv)
|
||||
{
|
||||
lspiMspiCtrl.mspiVsyncEn = vsyncEnable;
|
||||
lspiMspiCtrl.mspiInst = vsyncInst;
|
||||
lspiMspiCtrl.vsyncLineCycle = (40000*70)/(1000*lspiDiv) + 100;
|
||||
lcdDrv->ctrl(LSPI_MSPI_CTRL, 0);
|
||||
}
|
||||
|
||||
void lcdCsnHighCycleMin(uint8_t lspiDiv)
|
||||
{
|
||||
lspiCmdAddr.csnHighCycleMin = (500*70)/(1000*lspiDiv) + 10;
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_ADDR, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void lcdInterfaceType(uint8_t type)
|
||||
{
|
||||
#if ((defined CHIP_EC718) && !(defined TYPE_EC718M)) || (defined CHIP_EC716)
|
||||
switch(type)
|
||||
{
|
||||
case SPI_3W_I:
|
||||
lspiCtrl.busType = 0;
|
||||
lspiCtrl.line4 = 0;
|
||||
break;
|
||||
case SPI_3W_II:
|
||||
lspiCtrl.busType = 1;
|
||||
lspiCtrl.line4 = 0;
|
||||
break;
|
||||
case SPI_4W_I:
|
||||
lspiCtrl.busType = 0;
|
||||
lspiCtrl.line4 = 1;
|
||||
break;
|
||||
case SPI_4W_II:
|
||||
lspiCtrl.busType = 1;
|
||||
lspiCtrl.line4 = 1;
|
||||
break;
|
||||
default:
|
||||
lspiCtrl.busType = 1;
|
||||
lspiCtrl.line4 = 1;
|
||||
}
|
||||
|
||||
#if (SPI_2_DATA_LANE == 1)
|
||||
lspiCtrl.data2Lane = 1;
|
||||
#endif
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
|
||||
#else // CHIP 719
|
||||
switch(type)
|
||||
{
|
||||
case SPI_3W_I:
|
||||
lspiCmdAddr.busType = 0;
|
||||
lspiCtrl.line4 = 0;
|
||||
break;
|
||||
case SPI_3W_II:
|
||||
lspiCmdAddr.busType = 1;
|
||||
lspiCtrl.line4 = 0;
|
||||
break;
|
||||
case SPI_4W_I:
|
||||
lspiCmdAddr.busType = 0;
|
||||
lspiCtrl.line4 = 1;
|
||||
break;
|
||||
case SPI_4W_II:
|
||||
lspiCmdAddr.busType = 1;
|
||||
lspiCtrl.line4 = 1;
|
||||
break;
|
||||
case MSPI_4W_II:
|
||||
#if (LCD_INTERFACE_MSPI == 1)
|
||||
lcdMspiSet(1, 0, 0, DEFAULT_INST);
|
||||
#endif
|
||||
break;
|
||||
case INTERFACE_8080:
|
||||
// config cpol cpha
|
||||
*(uint32_t*)0x4d042028 |= (1<<4) | (1<<5);
|
||||
lspi8080Ctrl.lspi8080En = 1;
|
||||
break;
|
||||
default:
|
||||
lspiCmdAddr.busType = 1;
|
||||
lspiCtrl.line4 = 1;
|
||||
}
|
||||
|
||||
#if (SPI_2_DATA_LANE == 1)
|
||||
lspiCtrl.dspiEn = 1;
|
||||
lspiCtrl.dspiCfg = 2;
|
||||
#endif
|
||||
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_ADDR, 0);
|
||||
lcdDrv->ctrl(LSPI_8080_CTRL, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
int lspiDefaultCfg(lcdDrvFunc_t *lcd, lcdUspCb cb, uint32_t freq, uint8_t bpp)
|
||||
{
|
||||
lcdDrv->init();
|
||||
lcdDrv->powerCtrl(LSPI_POWER_FULL);
|
||||
|
||||
lcdDrv->ctrl(LSPI_CTRL_BUS_SPEED, freq);
|
||||
lspiCtrl.datSrc = 1; // 0: data from camera; 1: data from memory
|
||||
|
||||
switch (bpp)
|
||||
{
|
||||
case 12: // rgb444
|
||||
{
|
||||
lspiCtrl.colorModeIn = 3; // RGB565
|
||||
lspiCtrl.colorModeOut = 0; // RGB444
|
||||
}
|
||||
break;
|
||||
|
||||
case 16: // rgb565
|
||||
{
|
||||
lspiCtrl.colorModeIn = 3; // RGB565
|
||||
lspiCtrl.colorModeOut = 1; // RGB565
|
||||
}
|
||||
break;
|
||||
|
||||
case 18: // rgb666
|
||||
{
|
||||
lspiCtrl.colorModeIn = 3; // RGB565
|
||||
lspiCtrl.colorModeOut = 2; // RGB565
|
||||
}
|
||||
break;
|
||||
|
||||
#if defined TYPE_EC718M
|
||||
case 24: // rgb888
|
||||
{
|
||||
lspiCtrl.colorModeIn = 4; // RGB888
|
||||
lspiCtrl.colorModeOut = 6; // RGB888
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case 1:
|
||||
break;
|
||||
|
||||
case 2:
|
||||
break;
|
||||
|
||||
case 8:
|
||||
break;
|
||||
|
||||
default:
|
||||
EC_ASSERT(0,0,0,0);
|
||||
break;
|
||||
}
|
||||
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
#if defined TYPE_EC718M
|
||||
lcdDrv->ctrl(LSPI_PRE_PARA0_CTRL, 0);
|
||||
lcdDrv->ctrl(LSPI_POST_PARA0_CTRL, 0);
|
||||
#endif
|
||||
lcdEnable();
|
||||
|
||||
if(cb)
|
||||
{
|
||||
userUspCb = cb;
|
||||
lspiIntCtrl.lspiRamWrEndEn = 1;
|
||||
lcdDrv->ctrl(LSPI_CTRL_INT_CTRL, 0);
|
||||
XIC_SetVector(PXIC0_USP2_IRQn, uspIrqCb);
|
||||
XIC_EnableIRQ(PXIC0_USP2_IRQn);
|
||||
}
|
||||
|
||||
lspiDataFmt.wordSize = 31;
|
||||
lspiDataFmt.txPack = 0;
|
||||
lspiInfo.frameHeight = lcd->height; // frame input height
|
||||
lspiInfo.frameWidth = lcd->width; // frame input width
|
||||
lspiFrameInfoOut.frameHeightOut = lcd->height; // frame output height
|
||||
lspiFrameInfoOut.frameWidthOut = lcd->width; // frame output width
|
||||
lcdDrv->ctrl(LSPI_CTRL_DATA_FORMAT, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO_OUT, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lcdDmaTrans(lcdDrvFunc_t *lcd, void *sourceAddress, uint32_t totalLength)
|
||||
{
|
||||
uint32_t res = 0, patch = 0;
|
||||
int dmaChainCnt = 0, ret = 0;
|
||||
|
||||
if(lcd == NULL || sourceAddress == NULL)
|
||||
{
|
||||
EC_ASSERT(0,0,0,0);
|
||||
}
|
||||
|
||||
res = totalLength;
|
||||
|
||||
if( totalLength % 4)
|
||||
{
|
||||
res += (4 - totalLength%4);
|
||||
}
|
||||
|
||||
// step1: config lspi
|
||||
lspiDmaCtrl.txDmaReqEn = 1;
|
||||
lspiDmaCtrl.dmaWorkWaitCycle = 15;
|
||||
lcdDrv->ctrl(LSPI_CTRL_DMA_CTRL, 0);
|
||||
lspiCmdCtrl.wrRdn = 1; // 1: wr 0: rd
|
||||
lspiCmdCtrl.ramWr = 1; // start ramwr
|
||||
#if (defined TYPE_EC718M)
|
||||
#if (SPI_2_DATA_LANE == 1)
|
||||
lspiCmdCtrl.ramWrHaltMode = 0;
|
||||
#else
|
||||
lspiCmdCtrl.ramWrHaltMode = 1; // maintain cs as low between cmd and data
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ((defined CHIP_EC718) && !(defined TYPE_EC718M)) || (defined CHIP_EC716)
|
||||
uint32_t tmp = 0;
|
||||
|
||||
#if (SPI_2_DATA_LANE == 1)
|
||||
tmp = res/2;
|
||||
#endif
|
||||
|
||||
if (tmp >= 0x3ffff)
|
||||
{
|
||||
lspiCmdCtrl.dataLen = 0x3ffff; // infinate
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (SPI_2_DATA_LANE == 1)
|
||||
lspiCmdCtrl.dataLen = res/2;
|
||||
#else
|
||||
lspiCmdCtrl.dataLen = res;
|
||||
#endif
|
||||
}
|
||||
#elif (defined TYPE_EC718M)
|
||||
if (totalLength >= 0x3fffff)
|
||||
{
|
||||
lspiCmdCtrl.dataLen = 0x3fffff; // infinate
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (SPI_2_DATA_LANE == 1)
|
||||
lspiCmdCtrl.dataLen = res/2;
|
||||
#else
|
||||
if (lcd->bpp == 24)
|
||||
{
|
||||
lspiCmdCtrl.dataLen = res/(lcd->bpp/8+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
lspiCmdCtrl.dataLen = res/(lcd->bpp/8);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_CTRL, 0);
|
||||
|
||||
// step2: config DMA
|
||||
lcdDmaTxCfg.totalLength = DMA_BULK_NUM;
|
||||
lcdDmaTxCfg.addressIncrement = DMA_ADDRESS_INCREMENT_SOURCE;
|
||||
lcdDmaTxCfg.targetAddress = (void *)&(LSPI2->TFIFO);
|
||||
lcdDmaTxCfg.sourceAddress = (void *)sourceAddress;
|
||||
|
||||
patch = DMA_BULK_NUM - res%DMA_BULK_NUM;
|
||||
dmaChainCnt = (res + patch) / DMA_BULK_NUM;
|
||||
uint32_t package = DMA_BULK_NUM;
|
||||
|
||||
if (patch % dmaChainCnt == 0)
|
||||
{
|
||||
package -= (patch / dmaChainCnt);
|
||||
lcdDmaTxCfg.totalLength = package;
|
||||
DMA_buildDescriptorChain(lcdDmaTxDesc, &lcdDmaTxCfg, dmaChainCnt, true, true, true);
|
||||
ret += dmaChainCnt;
|
||||
res -= dmaChainCnt * package;
|
||||
}
|
||||
else
|
||||
{
|
||||
dmaChainCnt -= 1;
|
||||
res -= dmaChainCnt * DMA_BULK_NUM;
|
||||
lcdDmaTxCfg.totalLength = res;
|
||||
DMA_buildDescriptorChain(lcdDmaTxDesc, &lcdDmaTxCfg, 1, false, false, false);
|
||||
|
||||
lcdDmaTxCfg.sourceAddress = (void *)sourceAddress + ret * DMA_BULK_NUM + res;
|
||||
lcdDmaTxCfg.totalLength = DMA_BULK_NUM;
|
||||
DMA_buildDescriptorChain(lcdDmaTxDesc+1, &lcdDmaTxCfg, dmaChainCnt, true, true, true);
|
||||
ret += dmaChainCnt;
|
||||
}
|
||||
|
||||
//GPIO_pinWrite(0, 1 << 12, 0);
|
||||
dmaStartStop(true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void lspiFifoWrite(uint32_t data)
|
||||
{
|
||||
lspiDmaCtrl.txDmaReqEn = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_DMA_CTRL, 0);
|
||||
|
||||
lspiCmdCtrl.wrRdn = 1; // 1: wr 0: rd
|
||||
lspiCmdCtrl.ramWr = 1;
|
||||
lspiCmdCtrl.dataLen = 2;
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_CTRL, 0);
|
||||
LSPI2->STAS |= (1<<31);
|
||||
|
||||
if(lspiDataFmt.txFifoEndianMode)
|
||||
{
|
||||
LSPI2->TFIFO = (data >> 16)|(data << 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
LSPI2->TFIFO = data;
|
||||
}
|
||||
}
|
||||
|
||||
#if ((defined CHIP_EC718) && !(defined TYPE_EC718M)) || (defined CHIP_EC716)
|
||||
static void leftShift1Bit(uint8_t *data, uint8_t dataLen)
|
||||
{
|
||||
#define READ_REG_MSB 0x80
|
||||
#define READ_REG_LSB 0x01
|
||||
|
||||
for (int i = 1; i <= dataLen; i++)
|
||||
{
|
||||
data[i-1] = data[i-1] << 1;
|
||||
|
||||
if (i < dataLen && data[i] & READ_REG_MSB)
|
||||
{
|
||||
data[i-1] = data[i-1] | READ_REG_LSB;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// dataLen includes dummyLen
|
||||
void lspiReadReg(uint8_t addr, uint8_t *data, uint16_t dataLen, uint8_t dummyCycleLen)
|
||||
{
|
||||
if( data == NULL) return;
|
||||
|
||||
#if ((defined CHIP_EC718) && !(defined TYPE_EC718M)) || (defined CHIP_EC716)
|
||||
uint8_t index=0, remainder=0, outputLen=dataLen, tmp1[20]={0};
|
||||
|
||||
#if (LCD_AXS15231_ENABLE == 1)
|
||||
PadConfig_t config1;
|
||||
// config gpio36
|
||||
PAD_getDefaultConfig(&config1);
|
||||
config1.mux = RTE_USP2_DIN_FUNC;
|
||||
PAD_setPinConfig(RTE_USP2_DIN_PAD_ADDR, &config1);
|
||||
lspiCtrl.busType = 1; // 0: type1, sda inout; 1:type2, sda input, sdo output
|
||||
#endif
|
||||
|
||||
lspiCmdAddr.addr = addr;
|
||||
lspiCmdCtrl.wrRdn = 0; // 1: wr 0: rd
|
||||
lspiCmdCtrl.dataLen = dataLen;
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_ADDR, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_CTRL, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
while (!LSPI2->LSPI_STAT);
|
||||
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
tmp1[i] = LSPI2->RFIFO;
|
||||
}
|
||||
|
||||
if (dummyCycleLen > 0)
|
||||
{
|
||||
index = dummyCycleLen / 8;
|
||||
remainder = dummyCycleLen % 8;
|
||||
outputLen = dataLen - (index + ((remainder > 0)? 1 : 0));
|
||||
|
||||
memcpy(&tmp1[0], &tmp1[index], outputLen + ((remainder > 0)? 1 : 0));
|
||||
|
||||
for (int j = 0; j < remainder; j++)
|
||||
{
|
||||
leftShift1Bit(tmp1, outputLen+1);
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(data, tmp1, outputLen);
|
||||
|
||||
#elif (defined TYPE_EC718M)
|
||||
uint32_t dummyRead;
|
||||
|
||||
if (LCD_INTERFACE == MSPI_4W_II)
|
||||
{
|
||||
#if (LCD_INTERFACE_MSPI == 1)
|
||||
// read test
|
||||
lcdMspiSet(1, 0, 0, 0x03); // 1wire read: 0x03
|
||||
|
||||
// config gpio36
|
||||
//PadConfig_t config;
|
||||
PadConfig_t config2;
|
||||
PAD_getDefaultConfig(&config2);
|
||||
config2.mux = RTE_USP2_SDI_FUNC;
|
||||
PAD_setPinConfig(RTE_USP2_SDI_PAD_ADDR, &config2);
|
||||
|
||||
lspiCmdAddr.addr = addr;
|
||||
//lspiCmdAddr.busType = 1;
|
||||
lspiCmdCtrl.wrRdn = 0; // 1: wr 0: rd
|
||||
lspiCmdCtrl.rdatDummyCycle = dummyCycleLen;
|
||||
lspiCmdCtrl.dataLen = 1;
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_ADDR, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_CTRL, 0);
|
||||
|
||||
while ((LSPI2->LSPI_STAT & LSPI_STATS_RX_FIFO_LEVEL_Msk) == 0);
|
||||
|
||||
for (int j = 0; j < dummyCycleLen/8; j++)
|
||||
{
|
||||
dummyRead = LSPI2->RFIFO;
|
||||
(void)dummyRead;
|
||||
}
|
||||
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
data[i] = LSPI2->RFIFO;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
lspiCmdAddr.addr = addr;
|
||||
lspiCmdCtrl.wrRdn = 0; // 1: wr 0: rd
|
||||
lspiCmdCtrl.rdatDummyCycle = dummyCycleLen;
|
||||
lspiCmdCtrl.dataLen = dataLen;
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_ADDR, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_CTRL, 0);
|
||||
while (!LSPI2->LSPI_STAT);
|
||||
|
||||
for (int j = 0; j < dummyCycleLen/8; j++)
|
||||
{
|
||||
dummyRead = LSPI2->RFIFO;
|
||||
(void)dummyRead;
|
||||
}
|
||||
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
data[i] = LSPI2->RFIFO;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void lspiReadRam(uint32_t *data, uint32_t dataLen)
|
||||
{
|
||||
if (data == NULL) return;
|
||||
|
||||
#if ((defined CHIP_EC718) && !(defined TYPE_EC718M)) || (defined CHIP_EC716)
|
||||
|
||||
lspiCmdAddr.addr = 0x3E; // RDMEMC
|
||||
lspiCmdCtrl.wrRdn = 0;
|
||||
lspiCmdCtrl.rdatDummyCycle = 1;
|
||||
lspiCmdCtrl.dataLen = dataLen+1;
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_ADDR, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_CTRL, 0);
|
||||
while (!LSPI2->LSPI_STAT);
|
||||
uint32_t dummy = LSPI2->RFIFO;
|
||||
(void)dummy;
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
data[i] = LSPI2->RFIFO;
|
||||
}
|
||||
#elif (defined TYPE_EC718M)
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void lcdWriteData(uint8_t data)
|
||||
{
|
||||
lcdDrv->prepareSend(data);
|
||||
}
|
||||
|
||||
void lcdWriteCmd(uint8_t cmd)
|
||||
{
|
||||
lspiCmdAddr.addr = cmd;
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_ADDR, 0);
|
||||
}
|
||||
|
||||
void lspiCmdSend(uint8_t cmd, uint8_t *data, uint8_t dataLen)
|
||||
{
|
||||
lspiCmdAddr.addr = cmd;
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_ADDR, 0);
|
||||
|
||||
for (uint8_t i = 0; i < dataLen; i++)
|
||||
{
|
||||
lcdDrv->prepareSend(data[i]);
|
||||
}
|
||||
lcdDrv->send(NULL, 0);
|
||||
}
|
||||
|
||||
void lcdRst(uint32_t highMs, uint32_t lowMs)
|
||||
{
|
||||
LCD_RST_LOW;
|
||||
lcdDrvDelay(lowMs);
|
||||
LCD_RST_HIGH;
|
||||
lcdDrvDelay(highMs);
|
||||
}
|
||||
|
||||
|
||||
#if (BK_USE_GPIO == 1)
|
||||
void lcdGpioBkLevel(uint8_t level)
|
||||
{
|
||||
if (level > 0)
|
||||
{
|
||||
GPIO_pinWrite(LCD_BK_GPIO_INSTANCE, 1 << LCD_BK_GPIO_PIN, 1 << LCD_BK_GPIO_PIN);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
GPIO_pinWrite(LCD_BK_GPIO_INSTANCE, 1 << LCD_BK_GPIO_PIN, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (BK_USE_PWM == 1)
|
||||
AP_PLAT_COMMON_BSS volatile static uint32_t gpwmCnt = 0;
|
||||
AP_PLAT_COMMON_BSS static bool isPwmOn = false;
|
||||
|
||||
uint32_t millis(void)
|
||||
{
|
||||
return gpwmCnt;
|
||||
}
|
||||
|
||||
static void pwmISR(void)
|
||||
{
|
||||
if (TIMER_getInterruptFlags(LCD_PWM_INSTANCE) & TIMER_MATCH0_INTERRUPT_FLAG)
|
||||
{
|
||||
TIMER_clearInterruptFlags(LCD_PWM_INSTANCE, TIMER_MATCH0_INTERRUPT_FLAG);
|
||||
gpwmCnt++;
|
||||
|
||||
#ifdef FEATURE_SUBSYS_GUI_LVGL_ENABLE
|
||||
lv_tick_inc(1);
|
||||
#elif FEATURE_SUBSYS_GUI_LVGL9_ENABLE
|
||||
lv_tick_inc(1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// level: 0~100
|
||||
uint8_t lcdPwmBkLevel(uint8_t level)
|
||||
{
|
||||
if (level == 0)
|
||||
{
|
||||
TIMER_stop(LCD_PWM_INSTANCE);
|
||||
isPwmOn = false;
|
||||
goto END;
|
||||
}
|
||||
|
||||
if (level > 100)
|
||||
{
|
||||
level = 100;
|
||||
}
|
||||
|
||||
// turn on TIMER first
|
||||
if (!isPwmOn)
|
||||
{
|
||||
TIMER_start(LCD_PWM_INSTANCE);
|
||||
isPwmOn = true;
|
||||
}
|
||||
|
||||
TIMER_updatePwmDutyCycle(LCD_PWM_INSTANCE, level);
|
||||
|
||||
END:
|
||||
return level;
|
||||
}
|
||||
|
||||
void lcdPwmBkInit(void)
|
||||
{
|
||||
PadConfig_t config;
|
||||
PAD_getDefaultConfig(&config);
|
||||
config.mux = LCD_PWM_PAD_ALT_SEL;
|
||||
config.driveStrength = PAD_DRIVE_STRENGTH_LOW;
|
||||
PAD_setPinConfig(LCD_PWM_OUT_PAD, &config);
|
||||
CLOCK_setClockSrc(LCD_PWM_CLOCK_ID, LCD_PWM_CLOCK_SOURCE);
|
||||
CLOCK_setClockDiv(LCD_PWM_CLOCK_ID, 1);
|
||||
TIMER_driverInit();
|
||||
TimerPwmConfig_t gLcdPwmConfig;
|
||||
gLcdPwmConfig.pwmFreq_HZ = 1000;
|
||||
gLcdPwmConfig.srcClock_HZ = GPR_getClockFreq(LCD_PWM_CLOCK_ID);
|
||||
gLcdPwmConfig.stopOption = TIMER_PWM_STOP_LOW;
|
||||
gLcdPwmConfig.dutyCyclePercent = 0;
|
||||
|
||||
TIMER_setupPwm(LCD_PWM_INSTANCE, &gLcdPwmConfig);
|
||||
|
||||
TIMER_interruptConfig(LCD_PWM_INSTANCE, TIMER_MATCH0_INTERRUPT, TIMER_INTERRUPT_LEVEL);
|
||||
TIMER_interruptConfig(LCD_PWM_INSTANCE, TIMER_MATCH1_INTERRUPT, TIMER_INTERRUPT_DISABLE);
|
||||
TIMER_interruptConfig(LCD_PWM_INSTANCE, TIMER_MATCH2_INTERRUPT, TIMER_INTERRUPT_DISABLE);
|
||||
|
||||
XIC_SetVector(LCD_PWM_INSTANCE_IRQ, pwmISR);
|
||||
XIC_EnableIRQ(LCD_PWM_INSTANCE_IRQ);
|
||||
}
|
||||
|
||||
void lcdPwmBkDeInit(void)
|
||||
{
|
||||
TIMER_stop(LCD_PWM_INSTANCE);
|
||||
TIMER_deInit(LCD_PWM_INSTANCE);
|
||||
}
|
||||
#else
|
||||
uint32_t millis(void)
|
||||
{
|
||||
return osKernelGetTickCount();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,483 +0,0 @@
|
||||
#include "bsp.h"
|
||||
#include "lcdDrv.h"
|
||||
#include "lcdComm.h"
|
||||
#include "lcdDev_15231.h"
|
||||
#include "sctdef.h"
|
||||
|
||||
#define LCD_MADCTL 0x36
|
||||
|
||||
|
||||
extern lspiDrvInterface_t *lcdDrv;
|
||||
//static uint8_t s_MADCTL = 0x0;
|
||||
AP_PLAT_COMMON_BSS static uint16_t previewWidth;
|
||||
AP_PLAT_COMMON_BSS static uint16_t previewHeight;
|
||||
AP_PLAT_COMMON_BSS static uint32_t fillLen;
|
||||
extern lcdIoCtrl_t lcdIoCtrlParam;
|
||||
|
||||
AP_PLAT_COMMON_DATA static initLine_t initTable15231[] =
|
||||
{
|
||||
#if 1
|
||||
{0xBB, 8, {0x00,0x00,0x00,0x00,0x00,0x00,0x5A,0xA5}},
|
||||
{0xA0, 17, {0xC0,0x10,0x00,0x02,0x00,0x00,0x64,0x3F,0x20,0x05,0x3F,0x3F,0x00,0x00,0x00,0x00,0x00}},
|
||||
{0xA2, 31, {0x31,0x3C,0x29,0x14,0xFF,0xA6,0xCB,0xE0,0x40,0x19,0x80,0x80,0x80,0x20,0xf9,0x10,0x02,0xff,0xff,0xF0,0x90,0x01,0x32,0xA0,0x91,0x40,0x20,0x7F,0xFF,0x00,0x14}},
|
||||
{0xD0, 30, {0xE0,0x40,0x51,0x24,0x08,0x05,0x10,0x01,0x04,0x14,0xC2,0x42,0x22,0x22,0xAA,0x03,0x10,0x12,0x60,0x14,0x1E,0x51,0x15,0x00,0xFF,0x10,0x00,0x03,0x3D,0x12}},
|
||||
{0xA3, 22, {0xA0,0x06,0xAa,0x00,0x08,0x02,0x0A,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x55,0x55}},
|
||||
{0xA4, 16, {0x85,0x85,0x95,0x82,0xAF,0xED,0xED,0x80,0x10,0x30,0x40,0x40,0x20,0x50,0x60,0x35}},
|
||||
{0xC1, 30, {0x33,0x04,0x02,0x02,0x71,0x05,0x27,0x55,0x02,0x00,0x41,0x00,0x53,0xFF,0xFF,0xFF,0x4F,0x52,0x00,0x4F,0x52,0x00,0x45,0x3B,0x0B,0x02,0x0D,0x00,0xFF,0x40}},
|
||||
{0xC3, 11, {0x00,0x00,0x00,0x50,0x03,0x00,0x00,0x00,0x01,0x80,0x01}},
|
||||
{0xC4, 29, {0x00,0x24,0x33,0x80,0x00,0xea,0x64,0x32,0xC8,0x64,0xC8,0x32,0x90,0x90,0x11,0x06,0xDC,0xFA,0x00,0x00,0x80,0xFE,0x10,0x10,0x00,0x0A,0x0A,0x44,0x50}},
|
||||
{0xC5, 23, {0x18,0x00,0x00,0x03,0xFE,0x50,0x38,0x20,0x30,0x10,0x88,0xDE,0x0D,0x08,0x0F,0x0F,0x01,0x50,0x38,0x20,0x10,0x10,0x00}},
|
||||
{0xC6, 20, {0x05,0x0A,0x05,0x0A,0x00,0xE0,0x2E,0x0B,0x12,0x22,0x12,0x22,0x01,0x03,0x00,0x02,0x6A,0x18,0xC8,0x22}},
|
||||
{0xC7, 27, {0x50,0x32,0x28,0x00,0xa2,0x80,0x8f,0x00,0x80,0xff,0x07,0x11,0x9c,0x67,0xff,0x28,0x0c,0x0d,0x0e,0x0f,0x01,0x01,0x01,0x01,0x3F,0x07,0xFF}},
|
||||
{0xC9, 4, {0x33,0x44,0x44,0x01}},
|
||||
{0xCF, 27, {0x2C,0x1E,0x88,0x58,0x13,0x18,0x56,0x18,0x1E,0x68,0x88,0x00,0x65,0x09,0x22,0xC4,0x0C,0x77,0x22,0x44,0xAA,0x55,0x08,0x08,0x12,0xA0,0x08}},
|
||||
{0xD5, 30, {0x38,0x38,0x89,0x01,0x35,0x04,0x92,0x6F,0x04,0x92,0x6F,0x04,0x08,0x6A,0x04,0x46,0x03,0x03,0x03,0x03,0x00,0x01,0x03,0x00,0xE0,0x51,0xa1,0x00,0x00,0x00}},
|
||||
{0xD6, 30, {0x10,0x32,0x54,0x76,0x98,0xBA,0xDC,0xFE,0x93,0x00,0x01,0x83,0x07,0x07,0x00,0x07,0x07,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x00,0x84,0x00,0x20,0x01,0x00}},
|
||||
{0xD7, 19, {0x03,0x01,0x0b,0x09,0x0f,0x0d,0x1E,0x1F,0x18,0x1d,0x1f,0x19,0x38,0x38,0x04,0x00,0x1d,0x40,0x1F}},
|
||||
{0xD8, 12, {0x02,0x00,0x0a,0x08,0x0e,0x0c,0x1E,0x1F,0x18,0x1d,0x1f,0x19}},
|
||||
{0xD9, 12, {0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F}},
|
||||
{0xDD, 12, {0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F}},
|
||||
{0xDF, 8, {0x44,0x73,0x4B,0x69,0x00,0x0A,0x02,0x90}},
|
||||
{0xE0, 17, {0x3B,0x00,0x0f,0x14,0x0c,0x03,0x11,0x26,0x4b,0x21,0x0d,0x36,0x13,0x2a,0x2f,0x28,0x0D}},
|
||||
{0xE1, 17, {0x37,0x00,0x0f,0x14,0x0b,0x03,0x11,0x26,0x4b,0x21,0x0d,0x36,0x13,0x2a,0x2D,0x28,0x0F}},
|
||||
{0xE2, 17, {0x3B,0x07,0x12,0x18,0x0E,0x0D,0x17,0x35,0x44,0x32,0x0C,0x14,0x14,0x36,0x3A,0x0F,0x0D}},
|
||||
{0xE3, 17, {0x37,0x07,0x12,0x18,0x0E,0x0D,0x17,0x35,0x44,0x32,0x0C,0x14,0x14,0x36,0x32,0x2F,0x0F}},
|
||||
{0xE4, 17, {0x3B,0x07,0x12,0x18,0x0E,0x0D,0x17,0x39,0x44,0x2E,0x0C,0x14,0x14,0x36,0x3A,0x2F,0x0D}},
|
||||
{0xE5, 17, {0x37,0x07,0x12,0x18,0x0E,0x0D,0x17,0x39,0x44,0x2E,0x0C,0x14,0x14,0x36,0x3A,0x2F,0x0F}},
|
||||
{0xBB, 8, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
|
||||
{0x11, 1, {0}},
|
||||
{0x29, 1, {0}},
|
||||
#endif
|
||||
{0xff, 1, {120}},
|
||||
|
||||
//{0xbb, 8, {0x00,0x00,0x00,0x00,0x00,0x00,0x5a,0xa5}},
|
||||
//{0xa0, 1, {0x29}},
|
||||
};
|
||||
|
||||
/*
|
||||
sx: start x
|
||||
sy: start y
|
||||
ex: end x
|
||||
ey: end y
|
||||
*/
|
||||
static uint32_t axs15231AddrSet(lcdDrvFunc_t *lcd, uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey)
|
||||
{
|
||||
uint8_t set_x_cmd[] = {sx>>8, sx, ex>>8, ex};
|
||||
lspiCmdSend(0x2A, set_x_cmd, sizeof(set_x_cmd));
|
||||
previewWidth = ex - sx + 1;
|
||||
|
||||
uint8_t set_y_cmd[] = {sy>>8, sy, ey>>8, ey};
|
||||
lspiCmdSend(0x2B, set_y_cmd, sizeof(set_y_cmd));
|
||||
previewHeight = ey - sy + 1;
|
||||
|
||||
lcdWriteCmd(0x2C);
|
||||
|
||||
fillLen = (ey-sy+1) * (ex-sx+1) * (AXS15231_BPP/8);
|
||||
return fillLen;
|
||||
}
|
||||
|
||||
|
||||
void axs15231HandleUspIrq4Cam(lcdDrvFunc_t *lcd)
|
||||
{
|
||||
lspiCtrl.enable = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
|
||||
LSPI2->DMACTL |= 1<<25; // tx fifo
|
||||
|
||||
lspiCtrl.enable = 1;
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
|
||||
lspiCmdCtrl.wrRdn = 1; // 1: wr 0: rd
|
||||
lspiCmdCtrl.ramWr = 1; // start ramwr
|
||||
#if (SPI_2_DATA_LANE == 1)
|
||||
lspiCmdCtrl.dataLen = fillLen/2; // 2 datalane is pixel num
|
||||
#else
|
||||
lspiCmdCtrl.dataLen = AXS15231_WIDTH*AXS15231_HEIGHT*2; // pixel * bpp/8
|
||||
#endif
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_CTRL, 0);
|
||||
}
|
||||
|
||||
void axs15231HandleUspIrq4Fill(lcdDrvFunc_t *lcd)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static int axs15231Init(lcdDrvFunc_t *lcd, void* uspCb, void *dmaCb, uint32_t freq, uint8_t bpp)
|
||||
{
|
||||
lcdIoInit(true);
|
||||
dmaInit(dmaCb);
|
||||
lspiDefaultCfg(lcd, uspCb, freq, bpp);
|
||||
lcdRst(100, 100);
|
||||
lcdInterfaceType(AXS15231_INTERFACE);
|
||||
lcdRegInit(0x15231);
|
||||
|
||||
#if 0 // test read id
|
||||
uint8_t data = 0x29;
|
||||
uint32_t read1523113[40] = {0x1, 0x2, 0x3};
|
||||
lspiReadReg(0xda, read1523113, 3, 0);
|
||||
|
||||
uint32_t read15231[5] = {0x1, 0x2, 0x3};
|
||||
|
||||
lspiCmdSend(0xa0, &data, 1);
|
||||
lspiReadReg(0x0c, read15231, 4, 0);
|
||||
|
||||
uint32_t read1523112[5] = {0x1, 0x2, 0x3};
|
||||
lspiCmdSend(0xa0, &data, 1);
|
||||
lspiReadReg(0x52, read1523112, 5, 0);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int axs15231Direction(lcdDrvFunc_t *lcd,DisDirection_e Dir)
|
||||
{
|
||||
switch(Dir)
|
||||
{
|
||||
case DIS_MIRROR_X:
|
||||
s_MADCTL ^= BIT(6);
|
||||
break;
|
||||
case DIS_MIRROR_Y:
|
||||
s_MADCTL ^= BIT(7);
|
||||
break;
|
||||
case DIS_SWAP_XY:
|
||||
s_MADCTL ^= 0xC0;
|
||||
break;
|
||||
case DIS_DIR_LRTB:
|
||||
s_MADCTL &= ~(BIT(2));
|
||||
s_MADCTL &= ~(BIT(4));
|
||||
s_MADCTL &= ~(BIT(5));
|
||||
break;
|
||||
case DIS_DIR_LRBT:
|
||||
s_MADCTL &= ~(BIT(2));
|
||||
s_MADCTL &= ~(BIT(5));
|
||||
s_MADCTL |= BIT(4);
|
||||
break;
|
||||
case DIS_DIR_RLTB:
|
||||
s_MADCTL &= ~(BIT(4));
|
||||
s_MADCTL &= ~(BIT(5));
|
||||
s_MADCTL |= BIT(2);
|
||||
break;
|
||||
case DIS_DIR_RLBT:
|
||||
s_MADCTL &= ~(BIT(5));
|
||||
s_MADCTL |= BIT(4);
|
||||
s_MADCTL |= BIT(2);
|
||||
break;
|
||||
case DIS_DIR_TBLR:
|
||||
s_MADCTL &= ~(BIT(2));
|
||||
s_MADCTL &= ~(BIT(4));
|
||||
s_MADCTL |= BIT(5);
|
||||
break;
|
||||
case DIS_DIR_BTLR:
|
||||
s_MADCTL &= ~(BIT(2));
|
||||
s_MADCTL |= BIT(4);
|
||||
s_MADCTL |= BIT(5);
|
||||
break;
|
||||
case DIS_DIR_TBRL:
|
||||
s_MADCTL &= ~(BIT(4));
|
||||
s_MADCTL |= BIT(2);
|
||||
s_MADCTL |= BIT(5);
|
||||
break;
|
||||
case DIS_DIR_BTRL:
|
||||
s_MADCTL |= BIT(2);
|
||||
s_MADCTL |= BIT(4);
|
||||
s_MADCTL |= BIT(5);
|
||||
break;
|
||||
}
|
||||
|
||||
lspiCmdSend(LCD_MADCTL, &s_MADCTL, 1);
|
||||
return s_MADCTL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void axs15231BackLight(lcdDrvFunc_t *lcd, uint8_t level)
|
||||
{
|
||||
#if (BK_USE_GPIO == 1)
|
||||
lcdGpioBkLevel(level);
|
||||
#elif (BK_USE_PWM == 1)
|
||||
lcdPwmBkLevel(level);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void axs15231PowerOnOff(lcdDrvFunc_t *lcd, lcdPowerOnOff_e onoff)
|
||||
{
|
||||
#if (ENABLE_LDO == 1)
|
||||
if (onoff == LCD_POWER_ON)
|
||||
{
|
||||
// power on
|
||||
GPIO_pinWrite(LCD_EN_GPIO_INSTANCE, 1 << LCD_EN_GPIO_PIN, 1 << LCD_EN_GPIO_PIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
// power off
|
||||
GPIO_pinWrite(LCD_EN_GPIO_INSTANCE, 1 << LCD_EN_GPIO_PIN, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void axs15231StartStop(lcdDrvFunc_t *lcd, bool startOrStop)
|
||||
{
|
||||
dmaStartStop(startOrStop);
|
||||
}
|
||||
|
||||
static int axs15231Fill(lcdDrvFunc_t *lcd, uint32_t fillLen, uint8_t *buf)
|
||||
{
|
||||
return lcdDmaTrans(lcd, buf, fillLen);
|
||||
}
|
||||
|
||||
static void axs15231DrawPoint(lcdDrvFunc_t *lcd, uint16_t x, uint16_t y, uint32_t dataWrite)
|
||||
{
|
||||
axs15231AddrSet(lcd, x, y, x, y);
|
||||
lspiFifoWrite(dataWrite);
|
||||
return;
|
||||
}
|
||||
|
||||
static void axs15231RegisterUspIrqCb(lcdDrvFunc_t *lcd, uspCbRole_e who)
|
||||
{
|
||||
(who == cbForCam)? (lcd->uspIrq4CamCb = axs15231HandleUspIrq4Cam) : (lcd->uspIrq4FillCb = axs15231HandleUspIrq4Fill);
|
||||
}
|
||||
|
||||
static void axs15231UnRegisterUspIrqCb(lcdDrvFunc_t *lcd, uspCbRole_e who)
|
||||
{
|
||||
(who == cbForCam)? (lcd->uspIrq4CamCb = NULL) : (lcd->uspIrq4FillCb = NULL);
|
||||
}
|
||||
|
||||
|
||||
static void axs15231CamPreviewStartStop(lcdDrvFunc_t *lcd, camPreviewStartStop_e previewStartStop)
|
||||
{
|
||||
uint8_t divVal = 0;
|
||||
uint16_t divRemain = 0;
|
||||
|
||||
#if (defined TYPE_EC718M) // chip 719
|
||||
if (previewStartStop)
|
||||
{
|
||||
axs15231UnRegisterUspIrqCb(lcd, cbForFill);
|
||||
axs15231RegisterUspIrqCb(lcd, cbForCam);
|
||||
|
||||
lspiDataFmt.wordSize = 7;
|
||||
lspiDataFmt.txPack = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_DATA_FORMAT, 0);
|
||||
|
||||
lspiInfo.frameHeight = PIC_SRC_HEIGHT; // frame input height
|
||||
lspiInfo.frameWidth = PIC_SRC_WIDTH; // frame input width
|
||||
lspiFrameInfoOut.frameHeightOut = previewHeight; // frame output height
|
||||
lspiFrameInfoOut.frameWidthOut = previewWidth; // frame output width
|
||||
|
||||
if ((previewHeight > PIC_SRC_HEIGHT) || (previewWidth > PIC_SRC_WIDTH))
|
||||
{
|
||||
EC_ASSERT(0,0,0,0);
|
||||
}
|
||||
|
||||
if (lcdIoCtrlParam.previewModeSel == CAM_PREVIEW_SET_AUTO)
|
||||
{
|
||||
divVal = lspiInfo.frameHeight / lspiFrameInfoOut.frameHeightOut;
|
||||
divRemain = lspiInfo.frameHeight % lspiFrameInfoOut.frameHeightOut;
|
||||
lspiTailorInfo0.tailorTop = divRemain/2;
|
||||
lspiTailorInfo0.tailorBottom = divRemain/2;
|
||||
EC_ASSERT(divVal, lspiInfo.frameHeight, lspiFrameInfoOut.frameHeightOut, 0);
|
||||
lspiScaleInfo.colScaleFrac = (divVal==1)? 0 : (128/divVal);
|
||||
|
||||
divVal = lspiInfo.frameWidth / lspiFrameInfoOut.frameWidthOut;
|
||||
divRemain = lspiInfo.frameWidth % lspiFrameInfoOut.frameWidthOut;
|
||||
lspiTailorInfo.tailorLeft = divRemain/2;
|
||||
lspiTailorInfo.tailorRight = divRemain/2;
|
||||
EC_ASSERT(divVal, lspiInfo.frameWidth, lspiFrameInfoOut.frameWidthOut, 0);
|
||||
lspiScaleInfo.rowScaleFrac = (divVal==1)? 0 : (128/divVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
lspiScaleInfo.rowScaleFrac = lcdIoCtrlParam.previewManulSet.rowScaleFrac;
|
||||
lspiScaleInfo.colScaleFrac = lcdIoCtrlParam.previewManulSet.colScaleFrac;
|
||||
lspiTailorInfo.tailorLeft = lcdIoCtrlParam.previewManulSet.tailorLeft;
|
||||
lspiTailorInfo.tailorRight = lcdIoCtrlParam.previewManulSet.tailorRight;
|
||||
lspiTailorInfo0.tailorBottom = lcdIoCtrlParam.previewManulSet.tailorBottom;
|
||||
lspiTailorInfo0.tailorTop = lcdIoCtrlParam.previewManulSet.tailorTop;
|
||||
}
|
||||
|
||||
lcdDrv->ctrl(LSPI_CTRL_SCALE_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_TAILOR_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO_OUT, 0);
|
||||
|
||||
lspiCtrl.datSrc = 0; // 0: data from camera; 1: data from memory
|
||||
lspiCtrl.colorModeIn = 0; // YUV422, every item is 8bit
|
||||
lspiCtrl.colorModeOut = 1; // RGB565
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
|
||||
lspiCmdCtrl.wrRdn = 1; // 1: wr 0: rd
|
||||
lspiCmdCtrl.ramWr = 1; // start ramwr
|
||||
#if (SPI_2_DATA_LANE == 1)
|
||||
lspiCmdCtrl.dataLen = fillLen/2; // 2 datalane is pixel num
|
||||
#else
|
||||
lspiCmdCtrl.dataLen = AXS15231_WIDTH*AXS15231_HEIGHT*2; // pixel * bpp/8
|
||||
#endif
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_CTRL, 0);
|
||||
}
|
||||
#else // chip 718
|
||||
if (previewStartStop)
|
||||
{
|
||||
axs15231UnRegisterUspIrqCb(lcd, cbForFill);
|
||||
axs15231RegisterUspIrqCb(lcd, cbForCam);
|
||||
|
||||
lspiDataFmt.wordSize = 7;
|
||||
lspiDataFmt.txPack = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_DATA_FORMAT, 0);
|
||||
|
||||
lspiInfo.frameHeight = PIC_SRC_HEIGHT; // frame input height
|
||||
lspiInfo.frameWidth = PIC_SRC_WIDTH; // frame input width
|
||||
lspiFrameInfoOut.frameHeightOut = previewHeight; // frame output height
|
||||
lspiFrameInfoOut.frameWidthOut = previewWidth; // frame output width
|
||||
|
||||
if ((previewHeight > PIC_SRC_HEIGHT) || (previewWidth > PIC_SRC_WIDTH))
|
||||
{
|
||||
EC_ASSERT(0,0,0,0);
|
||||
}
|
||||
|
||||
if (lcdIoCtrlParam.previewModeSel == CAM_PREVIEW_SET_AUTO)
|
||||
{
|
||||
divVal = lspiInfo.frameHeight / lspiFrameInfoOut.frameHeightOut;
|
||||
divRemain = lspiInfo.frameHeight % lspiFrameInfoOut.frameHeightOut;
|
||||
lspiTailorInfo0.tailorTop = divRemain/2;
|
||||
lspiTailorInfo0.tailorBottom = divRemain/2;
|
||||
EC_ASSERT(divVal, lspiInfo.frameHeight, lspiFrameInfoOut.frameHeightOut, 0);
|
||||
lspiScaleInfo.colScaleFrac = (divVal==1)? 0 : (128/divVal);
|
||||
|
||||
divVal = lspiInfo.frameWidth / lspiFrameInfoOut.frameWidthOut;
|
||||
divRemain = lspiInfo.frameWidth % lspiFrameInfoOut.frameWidthOut;
|
||||
lspiTailorInfo.tailorLeft = divRemain/2;
|
||||
lspiTailorInfo.tailorRight = divRemain/2;
|
||||
EC_ASSERT(divVal, lspiInfo.frameWidth, lspiFrameInfoOut.frameWidthOut, 0);
|
||||
lspiScaleInfo.rowScaleFrac = (divVal==1)? 0 : (128/divVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
lspiScaleInfo.rowScaleFrac = lcdIoCtrlParam.previewManulSet.rowScaleFrac;
|
||||
lspiScaleInfo.colScaleFrac = lcdIoCtrlParam.previewManulSet.colScaleFrac;
|
||||
lspiTailorInfo.tailorLeft = lcdIoCtrlParam.previewManulSet.tailorLeft;
|
||||
lspiTailorInfo.tailorRight = lcdIoCtrlParam.previewManulSet.tailorRight;
|
||||
lspiTailorInfo0.tailorBottom = lcdIoCtrlParam.previewManulSet.tailorBottom;
|
||||
lspiTailorInfo0.tailorTop = lcdIoCtrlParam.previewManulSet.tailorTop;
|
||||
}
|
||||
|
||||
lcdDrv->ctrl(LSPI_CTRL_SCALE_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_TAILOR_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO_OUT, 0);
|
||||
|
||||
lspiCtrl.datSrc = 0; // 0: data from camera; 1: data from memory
|
||||
lspiCtrl.colorModeIn = 0; // YUV422, every item is 8bit
|
||||
lspiCtrl.colorModeOut = 1; // RGB565
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
|
||||
lspiCmdCtrl.wrRdn = 1; // 1: wr 0: rd
|
||||
lspiCmdCtrl.ramWr = 1; // start ramwr
|
||||
#if (SPI_2_DATA_LANE == 1)
|
||||
lspiCmdCtrl.dataLen = fillLen/2; // 2 datalane is pixel num
|
||||
#else
|
||||
lspiCmdCtrl.dataLen = AXS15231_WIDTH*AXS15231_HEIGHT*2; // pixel * bpp/8
|
||||
#endif
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_CTRL, 0);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
axs15231UnRegisterUspIrqCb(lcd, cbForCam);
|
||||
axs15231RegisterUspIrqCb(lcd, cbForFill);
|
||||
|
||||
lspiDmaCtrl.txDmaReqEn = 0;
|
||||
lspiDataFmt.wordSize = 31;
|
||||
lspiDataFmt.txPack = 0;
|
||||
lspiInfo.frameHeight = lcd->height; // frame input height
|
||||
lspiInfo.frameWidth = lcd->width; // frame input width
|
||||
lspiFrameInfoOut.frameHeightOut = lcd->height; // frame output height
|
||||
lspiFrameInfoOut.frameWidthOut = lcd->width; // frame output width
|
||||
lspiCtrl.colorModeIn = 3; // rgb565
|
||||
lspiCtrl.colorModeOut = 1; // rgb565
|
||||
lspiCtrl.datSrc = 1; // 0: data from camera; 1: data from memory
|
||||
lspiScaleInfo.rowScaleFrac = 0;
|
||||
lspiScaleInfo.colScaleFrac = 0;
|
||||
lspiTailorInfo.tailorLeft = 0; // frame output height
|
||||
lspiTailorInfo.tailorRight = 0; // frame output width
|
||||
lspiTailorInfo0.tailorBottom = 0;
|
||||
lspiTailorInfo0.tailorTop = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_SCALE_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_TAILOR_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_DATA_FORMAT, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_DMA_CTRL, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO_OUT, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_TAILOR_INFO0, 0);
|
||||
|
||||
// before send first cmd/data to lcd, clear unnessary status
|
||||
if (((LSPI2->STAS >> 27)& 0x1) > 0)
|
||||
{
|
||||
LSPI2->STAS |= 1<<27;
|
||||
}
|
||||
|
||||
if (((LSPI2->STAS >> 28)& 0x1) > 0)
|
||||
{
|
||||
LSPI2->STAS |= 1<<28;
|
||||
}
|
||||
|
||||
#if ((defined CHIP_EC718) && !(defined TYPE_EC718M)) || (defined CHIP_EC716)
|
||||
if (((LSPI2->STAS >> 13)& 0x3f) > 0)
|
||||
#else // 719
|
||||
if (((LSPI2->LSPI_STAT >> 8)& 0x3f) > 0)
|
||||
#endif
|
||||
{
|
||||
LSPI2->DMACTL |= 1<<25;
|
||||
}
|
||||
|
||||
LSPI2->DMACTL |= 1<<24; // clear rx fifo
|
||||
|
||||
// write first dummy cmd to lcd. It's nessary to clear lspi fifo
|
||||
lcdWriteCmd(0xff);
|
||||
lcdWriteData(0x00);
|
||||
lcdDrv->send(NULL, 0);
|
||||
|
||||
#if ((defined CHIP_EC718) && !(defined TYPE_EC718M)) || (defined CHIP_EC716)
|
||||
if (((LSPI2->STAS >> 13)& 0x3f) > 0)
|
||||
#else // 719
|
||||
if (((LSPI2->LSPI_STAT >> 8)& 0x3f) > 0)
|
||||
#endif
|
||||
{
|
||||
LSPI2->DMACTL |= 1<<25;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int axs15231Close(lcdDrvFunc_t *lcd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
AP_PLAT_COMMON_DATA lcdDrvFunc_t axs15231Drv =
|
||||
{
|
||||
.id = 0x15231,
|
||||
.width = AXS15231_WIDTH,
|
||||
.height = AXS15231_HEIGHT,
|
||||
.freq = AXS15231_FREQ,
|
||||
.bpp = AXS15231_BPP,
|
||||
.initRegTbl = initTable15231,
|
||||
.initRegTblLen = sizeof(initTable15231)/sizeof(initLine_t),
|
||||
.dir = 0,
|
||||
|
||||
.init = axs15231Init,
|
||||
.drawPoint = axs15231DrawPoint,
|
||||
.setWindow = axs15231AddrSet,
|
||||
.fill = axs15231Fill,
|
||||
.backLight = axs15231BackLight,
|
||||
.powerOnOff = axs15231PowerOnOff,
|
||||
.startStop = axs15231StartStop,
|
||||
.startStopPreview = axs15231CamPreviewStartStop,
|
||||
.uspIrq4CamCb = NULL,
|
||||
.uspIrq4FillCb = NULL,
|
||||
.registerUspIrqCb = axs15231RegisterUspIrqCb,
|
||||
.unregisterUspIrqCb = axs15231UnRegisterUspIrqCb,
|
||||
.direction = NULL,
|
||||
.close = axs15231Close,
|
||||
};
|
||||
|
@ -1,324 +0,0 @@
|
||||
#include "bsp.h"
|
||||
#include "lcdDrv.h"
|
||||
#include "lcdComm.h"
|
||||
#include "lcdDev_5300.h"
|
||||
#include "sctdef.h"
|
||||
|
||||
extern lspiDrvInterface_t *lcdDrv;
|
||||
AP_PLAT_COMMON_BSS static uint8_t co5300SetXCmd[4] = {0};
|
||||
AP_PLAT_COMMON_BSS static uint8_t co5300SetYCmd[4] = {0};
|
||||
|
||||
#define PRE_CMD_ENABLE 0
|
||||
#define TEST_IRQ_NUM 1
|
||||
|
||||
|
||||
static const initLine_t initTable5300[] =
|
||||
{
|
||||
{0xfe, 0, {}},
|
||||
{0xc4, 1, {0x80}},
|
||||
#if (CO5300_BPP == 16)
|
||||
{0x3a, 1, {0x55}}, // rgb565
|
||||
#elif (CO5300_BPP == 18)
|
||||
{0x3a, 1, {0x6}}, // rgb666
|
||||
#elif (CO5300_BPP == 24)
|
||||
{0x3a, 1, {0x77}}, // rgb888
|
||||
#endif
|
||||
{0xff, 1, {20}},
|
||||
{0x35, 1, {0x00}},
|
||||
{0xff, 1, {20}},
|
||||
{0x53, 1, {0x20}},
|
||||
{0xff, 1, {20}},
|
||||
{0x51, 1, {0xff}},
|
||||
{0xff, 1, {20}},
|
||||
{0x63, 1, {0xff}},
|
||||
{0xff, 1, {20}},
|
||||
{0x2a, 4, {0x0, 0x0a, 0x01, 0xd5}},
|
||||
{0xff, 1, {20}},
|
||||
{0x2b, 4, {0x0, 0x0, 0x01, 0xcb}},
|
||||
{0xff, 1, {20}},
|
||||
{0x11, 0, {}},
|
||||
{0xff, 1, {60}},
|
||||
{0x29, 0, {}},
|
||||
};
|
||||
|
||||
void co5300HandleUspIrq4Cam(lcdDrvFunc_t *lcd)
|
||||
{
|
||||
#if (PRE_CMD_ENABLE)
|
||||
LSPI2->STAS |= (1<<13);
|
||||
#endif
|
||||
|
||||
#if (!PRE_CMD_ENABLE)
|
||||
lspiCtrl.enable = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
|
||||
LSPI2->DMACTL |= 1<<25; // tx fifo
|
||||
|
||||
lspiCtrl.enable = 1;
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
|
||||
lspiCmdCtrl.wrRdn = 1; // 1: wr 0: rd
|
||||
lspiCmdCtrl.ramWr = 1; // start ramwr
|
||||
lspiCmdCtrl.ramWrHaltMode = 1; // maintain cs as low between cmd and data
|
||||
lspiCmdCtrl.dataLen = LCD_WIDTH*LCD_HEIGHT; // infinite data, used in camera to lspi
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_CTRL, 0);
|
||||
|
||||
if (LSPI2->STAS & LSPI_STATS_TX_FIFO_LEVEL_Msk)
|
||||
{
|
||||
printf("tx error");
|
||||
}
|
||||
|
||||
if ((LSPI2->STAS & 1<<1) != 0)
|
||||
{
|
||||
printf("tx overflow");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void co5300HandleUspIrq4Fill(lcdDrvFunc_t *lcd)
|
||||
{
|
||||
//GPIO_pinWrite(0, 1 << 3, 0);
|
||||
//GPIO_pinWrite(0, 1 << 3, 1 << 3);
|
||||
|
||||
printf("enter fill\n");
|
||||
}
|
||||
|
||||
|
||||
static int co5300Init(lcdDrvFunc_t *lcd, void* uspCb, void *dmaCb, uint32_t freq, uint8_t bpp)
|
||||
{
|
||||
lcdIoInit(false);
|
||||
lcdRst(200, 200);
|
||||
dmaInit(dmaCb);
|
||||
lspiDefaultCfg(lcd, uspCb, freq, bpp);
|
||||
lcdInterfaceType(CO5300_INTERFACE);
|
||||
lcdRegInit(0x5300);
|
||||
|
||||
#if (TEST_IRQ_NUM)
|
||||
lspiIntCtrl.ramWrIntCtrl = 1;
|
||||
lspiIntCtrl.ramWrIntCtrlEn = 1;
|
||||
#endif
|
||||
lcdDrv->ctrl(LSPI_CTRL_INT_CTRL, 0);
|
||||
|
||||
|
||||
#if 0 // test read id
|
||||
uint32_t read5300[3] = {0};
|
||||
lspiReadReg(0xda, read5300, 1, 0);
|
||||
lspiReadReg(0xdb, read5300+1, 1, 0);
|
||||
lspiReadReg(0xdc, read5300+2, 1, 0);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void co5300BackLight(lcdDrvFunc_t *lcd, uint8_t level)
|
||||
{
|
||||
#if (BK_USE_GPIO == 1)
|
||||
lcdGpioBkLevel(level);
|
||||
#elif (BK_USE_PWM == 1)
|
||||
lcdPwmBkLevel(level);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
sx: start x
|
||||
sy: start y
|
||||
ex: end x
|
||||
ey: end y
|
||||
*/
|
||||
static uint32_t co5300AddrSet(lcdDrvFunc_t *lcd, uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey)
|
||||
{
|
||||
uint32_t len = 0;
|
||||
|
||||
lcdMspiSet(1, 0, 0, 0x02); // 1wire: 0x02; 4wire: 0x32
|
||||
|
||||
sx += LCD_X_OFFSET;
|
||||
ex += LCD_X_OFFSET;
|
||||
sy += LCD_Y_OFFSET;
|
||||
ey += LCD_Y_OFFSET;
|
||||
|
||||
co5300SetXCmd[0] = sx>>8;
|
||||
co5300SetXCmd[1] = sx;
|
||||
co5300SetXCmd[2] = ex>>8;
|
||||
co5300SetXCmd[3] = ex;
|
||||
lspiCmdSend(0x2A, co5300SetXCmd, sizeof(co5300SetXCmd));
|
||||
|
||||
co5300SetYCmd[0] = sy>>8;
|
||||
co5300SetYCmd[1] = sy;
|
||||
co5300SetYCmd[2] = ey>>8;
|
||||
co5300SetYCmd[3] = ey;
|
||||
lspiCmdSend(0x2B, co5300SetYCmd, sizeof(co5300SetYCmd));
|
||||
|
||||
if (CO5300_BPP == 24)
|
||||
{
|
||||
len = (ey-sy+1) * (ex-sx+1) * (CO5300_BPP/8+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
len = (ey-sy+1) * (ex-sx+1) * (CO5300_BPP/8);
|
||||
}
|
||||
|
||||
// send 0x2c
|
||||
lcdMspiSet(1, 0, 2, 0x32); // 1wire: 0x02; 4wire: 0x32
|
||||
lcdWriteCmd(0x2c);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static void co5300StartStop(lcdDrvFunc_t *lcd, bool startOrStop)
|
||||
{
|
||||
dmaStartStop(startOrStop);
|
||||
}
|
||||
|
||||
static void co5300RegisterUspIrqCb(lcdDrvFunc_t *lcd, uspCbRole_e who)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
EC_ASSERT(0,0,0,0);
|
||||
}
|
||||
|
||||
(who == cbForCam)? (lcd->uspIrq4CamCb = co5300HandleUspIrq4Cam) : (lcd->uspIrq4FillCb = co5300HandleUspIrq4Fill);
|
||||
}
|
||||
|
||||
static void co5300UnRegisterUspIrqCb(lcdDrvFunc_t *lcd, uspCbRole_e who)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
EC_ASSERT(0,0,0,0);
|
||||
}
|
||||
|
||||
(who == cbForCam)? (lcd->uspIrq4CamCb = NULL) : (lcd->uspIrq4FillCb = NULL);
|
||||
}
|
||||
|
||||
static int co5300Fill(lcdDrvFunc_t *lcd, uint32_t fillLen, uint8_t *buf)
|
||||
{
|
||||
return lcdDmaTrans(lcd, buf, fillLen);
|
||||
}
|
||||
|
||||
static void co5300DrawPoint(lcdDrvFunc_t *lcd, uint16_t x, uint16_t y, uint32_t dataWrite)
|
||||
{
|
||||
co5300AddrSet(lcd, x, y, x, y);
|
||||
lspiFifoWrite(dataWrite);
|
||||
return;
|
||||
}
|
||||
|
||||
static void co5300CamPreviewStartStop(lcdDrvFunc_t *lcd, camPreviewStartStop_e previewStartStop)
|
||||
{
|
||||
if (previewStartStop)
|
||||
{
|
||||
co5300UnRegisterUspIrqCb(lcd, cbForFill);
|
||||
co5300RegisterUspIrqCb(lcd, cbForCam);
|
||||
|
||||
#if (CAMERA_ENABLE_BF30A2)
|
||||
|
||||
#elif (CAMERA_ENABLE_GC032A)
|
||||
lspiScaleInfo.rowScaleFrac = 0;
|
||||
lspiScaleInfo.colScaleFrac = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_SCALE_INFO, 0);
|
||||
|
||||
lspiTailorInfo.tailorLeft = (PIC_SRC_WIDTH - CO5300_WIDTH)/2;
|
||||
lspiTailorInfo.tailorRight = (PIC_SRC_WIDTH - CO5300_WIDTH)/2;
|
||||
lspiTailorInfo0.tailorBottom = (PIC_SRC_HEIGHT - CO5300_HEIGHT)/2;
|
||||
lspiTailorInfo0.tailorTop = (PIC_SRC_HEIGHT - CO5300_HEIGHT)/2;
|
||||
lcdDrv->ctrl(LSPI_CTRL_TAILOR_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_TAILOR_INFO0, 0);
|
||||
|
||||
lspiDataFmt.wordSize = 7;
|
||||
lspiDataFmt.txPack = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_DATA_FORMAT, 0);
|
||||
|
||||
// lcd size
|
||||
lspiInfo.frameHeight = PIC_SRC_HEIGHT; // frame input height
|
||||
lspiInfo.frameWidth = PIC_SRC_WIDTH; // frame input width
|
||||
lspiFrameInfoOut.frameHeightOut = CO5300_HEIGHT; // frame output height
|
||||
lspiFrameInfoOut.frameWidthOut = CO5300_WIDTH; // frame output width
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO_OUT, 0);
|
||||
|
||||
lspiScaleInfo.rowScaleFrac = 0;
|
||||
lspiScaleInfo.colScaleFrac = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_SCALE_INFO, 0);
|
||||
|
||||
lspiDmaCtrl.txDmaReqEn = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_DMA_CTRL, 0);
|
||||
|
||||
#if (PRE_CMD_ENABLE)
|
||||
//lspiIntCtrl.ramWrIntCtrlEn = 1;
|
||||
#else
|
||||
lspiIntCtrl.lspiRamWrEndEn = 1;
|
||||
#endif
|
||||
lcdDrv->ctrl(LSPI_CTRL_INT_CTRL, 0);
|
||||
|
||||
LSPI2->DMACTL |= 1<<24; // flush dma
|
||||
LSPI2->DMACTL |= 1<<25;
|
||||
|
||||
lspiMspiCtrl.mspiInst = 0x32; // 1wire: 0x02; 4wire: 0x32
|
||||
lspiMspiCtrl.mspiAddrLane = 0;
|
||||
lspiMspiCtrl.mspiDataLane = 2;
|
||||
lcdDrv->ctrl(LSPI_MSPI_CTRL, 0);
|
||||
|
||||
lspiCtrl.enable = 1;
|
||||
lspiCtrl.datSrc = 0; // 0: data from camera; 1: data from memory
|
||||
lspiCtrl.colorModeIn = 0; // YUV422, every item is 8bit. 1:y only
|
||||
lspiCtrl.colorModeOut = 1; // RGB565
|
||||
lspiCmdAddr.busType = 1; // Interface II
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
|
||||
#if PRE_CMD_ENABLE
|
||||
lspiCmdAddr.addr = 0x2c;
|
||||
lspiCmdAddr.csnHighCycleMin = 0xa;
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_ADDR, 0);
|
||||
|
||||
lspiPreParam0.lspiCmd0PreEn = 1;
|
||||
lspiPreParam0.lspiCmd1PreEn = 1;
|
||||
lspiPreParam0.lspiCmd0PreParaLen = 4;
|
||||
lspiPreParam0.lspiCmd1PreParaLen = 4;
|
||||
lspiPreParam2.lspiCmd0PrePara = set_x_cmd[0] | (set_x_cmd[1]<<8) | (set_x_cmd[2]<<16) | (set_x_cmd[3]<<24);
|
||||
lspiPreParam3.lspiCmd1PrePara = set_y_cmd[0] | (set_y_cmd[1]<<8) | (set_y_cmd[2]<<16) | (set_y_cmd[3]<<24);
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_ADDR, 0);
|
||||
#endif
|
||||
|
||||
lspiCmdCtrl.wrRdn = 1; // 1: wr 0: rd
|
||||
lspiCmdCtrl.ramWr = 1; // start ramwr
|
||||
lspiCmdCtrl.ramWrHaltMode = 1; // maintain cs as low between cmd and data
|
||||
#if PRE_CMD_ENABLE
|
||||
lspiCmdCtrl.dataLen = 0x3fffff;
|
||||
#else
|
||||
lspiCmdCtrl.dataLen = CO5300_HEIGHT * CO5300_WIDTH;
|
||||
#endif
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_CTRL, 0);
|
||||
|
||||
#elif (CAMERA_ENABLE_GC6153)
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static int co5300Close(lcdDrvFunc_t *lcd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
AP_PLAT_COMMON_DATA lcdDrvFunc_t co5300Drv =
|
||||
{
|
||||
.id = 0x5300,
|
||||
.width = CO5300_WIDTH,
|
||||
.height = CO5300_HEIGHT,
|
||||
.freq = CO5300_FREQ,
|
||||
.bpp = CO5300_BPP,
|
||||
.initRegTbl = initTable5300,
|
||||
.initRegTblLen = sizeof(initTable5300)/sizeof(initLine_t),
|
||||
.dir = 0,
|
||||
|
||||
.init = co5300Init,
|
||||
.drawPoint = co5300DrawPoint,
|
||||
.setWindow = co5300AddrSet,
|
||||
.fill = co5300Fill,
|
||||
.backLight = co5300BackLight,
|
||||
.startStop = co5300StartStop,
|
||||
.startStopPreview = co5300CamPreviewStartStop,
|
||||
.uspIrq4CamCb = NULL,
|
||||
.uspIrq4FillCb = NULL,
|
||||
.registerUspIrqCb = co5300RegisterUspIrqCb,
|
||||
.unregisterUspIrqCb = co5300UnRegisterUspIrqCb,
|
||||
.direction = NULL,
|
||||
.close = co5300Close,
|
||||
};
|
||||
|
@ -1,431 +0,0 @@
|
||||
#include "bsp.h"
|
||||
#include "lcdDrv.h"
|
||||
#include "lcdComm.h"
|
||||
#include "lcdDev_7789.h"
|
||||
#include "sctdef.h"
|
||||
|
||||
#define LCD_MADCTL 0x36
|
||||
|
||||
extern lspiDrvInterface_t *lcdDrv;
|
||||
//static uint8_t s_MADCTL = 0x0;
|
||||
AP_PLAT_COMMON_BSS static uint16_t previewWidth;
|
||||
AP_PLAT_COMMON_BSS static uint16_t previewHeight;
|
||||
extern lcdIoCtrl_t lcdIoCtrlParam;
|
||||
|
||||
AP_PLAT_COMMON_DATA static initLine_t initTable7789[] =
|
||||
{
|
||||
{0x11, 1, {0}},
|
||||
{0xff, 1, {120}},
|
||||
#if FEATURE_SUBSYS_WATCH_ENABLE
|
||||
{0x36, 1, {0x08}},
|
||||
#else
|
||||
{0x36, 1, {0}},
|
||||
#endif
|
||||
{0x21, 1, {0}}, // display inverse
|
||||
#if (ST7789_BPP == 16)
|
||||
{0x3a, 1, {5}}, // rgb565
|
||||
#elif (ST7789_BPP == 12)
|
||||
{0x3a, 1, {3}}, // rgb444
|
||||
#elif (ST7789_BPP == 18)
|
||||
{0x3a, 1, {6}}, // rgb666
|
||||
#endif
|
||||
{0x35, 1, {0}}, // te on
|
||||
#if (SPI_2_DATA_LANE == 1)
|
||||
{0xe7, 1, {0x10}},
|
||||
#endif
|
||||
{0xb2, 5, {0x0c, 0x0c, 0x00, 0x33, 0x33}}, // rate
|
||||
{0xb7, 1, {0x35}},
|
||||
{0xbb, 1, {0x20}},
|
||||
{0xc0, 1, {0x2c}},
|
||||
{0xc2, 1, {0x01}},
|
||||
{0xc3, 1, {0x0b}},
|
||||
{0xc4, 1, {0x20}},
|
||||
{0xc6, 1, {0x0f}},
|
||||
{0xd0, 2, {0xa4, 0xa1}}, // pwctr
|
||||
{0xe0, 14, {0xd0,0x03,0x09,0x0e,0x11,0x3d,0x47,0x55,0x53,0x1a,0x16,0x14,0x1f,0x22}}, //Positive voltage gamma
|
||||
{0xe1, 14, {0xd0,0x02,0x08,0x0d,0x12,0x2c,0x43,0x55,0x53,0x1e,0x1b,0x19,0x20,0x22}}, //Negative voltage gamma
|
||||
{0x29, 1, {0x00}},
|
||||
};
|
||||
|
||||
void st7789HandleUspIrq4Cam(lcdDrvFunc_t *lcd)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void st7789HandleUspIrq4Fill(lcdDrvFunc_t *lcd)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static int st7789Init(lcdDrvFunc_t *lcd, void* uspCb, void *dmaCb, uint32_t freq, uint8_t bpp)
|
||||
{
|
||||
lcdIoInit(false);
|
||||
lcdRst(10, 10);
|
||||
dmaInit(dmaCb);
|
||||
lspiDefaultCfg(lcd, uspCb, freq, bpp);
|
||||
lcdInterfaceType(ST7789_INTERFACE);
|
||||
lcdRegInit(0x7789);
|
||||
|
||||
#if 0 // test read id
|
||||
uint32_t read7789[3] = {0};
|
||||
lspiReadReg(0x04, read7789, 3, 0);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int st7789Direction(lcdDrvFunc_t *lcd,DisDirection_e Dir)
|
||||
{
|
||||
switch(Dir)
|
||||
{
|
||||
case DIS_MIRROR_X:
|
||||
s_MADCTL ^= BIT(6);
|
||||
break;
|
||||
case DIS_MIRROR_Y:
|
||||
s_MADCTL ^= BIT(7);
|
||||
break;
|
||||
case DIS_SWAP_XY:
|
||||
s_MADCTL ^= 0xC0;
|
||||
break;
|
||||
case DIS_DIR_LRTB:
|
||||
s_MADCTL &= ~(BIT(2));
|
||||
s_MADCTL &= ~(BIT(4));
|
||||
s_MADCTL &= ~(BIT(5));
|
||||
break;
|
||||
case DIS_DIR_LRBT:
|
||||
s_MADCTL &= ~(BIT(2));
|
||||
s_MADCTL &= ~(BIT(5));
|
||||
s_MADCTL |= BIT(4);
|
||||
break;
|
||||
case DIS_DIR_RLTB:
|
||||
s_MADCTL &= ~(BIT(4));
|
||||
s_MADCTL &= ~(BIT(5));
|
||||
s_MADCTL |= BIT(2);
|
||||
break;
|
||||
case DIS_DIR_RLBT:
|
||||
s_MADCTL &= ~(BIT(5));
|
||||
s_MADCTL |= BIT(4);
|
||||
s_MADCTL |= BIT(2);
|
||||
break;
|
||||
case DIS_DIR_TBLR:
|
||||
s_MADCTL &= ~(BIT(2));
|
||||
s_MADCTL &= ~(BIT(4));
|
||||
s_MADCTL |= BIT(5);
|
||||
break;
|
||||
case DIS_DIR_BTLR:
|
||||
s_MADCTL &= ~(BIT(2));
|
||||
s_MADCTL |= BIT(4);
|
||||
s_MADCTL |= BIT(5);
|
||||
break;
|
||||
case DIS_DIR_TBRL:
|
||||
s_MADCTL &= ~(BIT(4));
|
||||
s_MADCTL |= BIT(2);
|
||||
s_MADCTL |= BIT(5);
|
||||
break;
|
||||
case DIS_DIR_BTRL:
|
||||
s_MADCTL |= BIT(2);
|
||||
s_MADCTL |= BIT(4);
|
||||
s_MADCTL |= BIT(5);
|
||||
break;
|
||||
case DIS_DIR_MAX:
|
||||
break;
|
||||
}
|
||||
|
||||
lspiCmdSend(LCD_MADCTL, &s_MADCTL, 1);
|
||||
return s_MADCTL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void st7789BackLight(lcdDrvFunc_t *lcd, uint8_t level)
|
||||
{
|
||||
#if (BK_USE_GPIO == 1)
|
||||
lcdGpioBkLevel(level);
|
||||
#elif (BK_USE_PWM == 1)
|
||||
lcdPwmBkLevel(level);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
sx: start x
|
||||
sy: start y
|
||||
ex: end x
|
||||
ey: end y
|
||||
*/
|
||||
static uint32_t st7789AddrSet(lcdDrvFunc_t *lcd, uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey)
|
||||
{
|
||||
uint8_t set_x_cmd[] = {sx>>8, sx, ex>>8, ex};
|
||||
lspiCmdSend(0x2A, set_x_cmd, sizeof(set_x_cmd));
|
||||
previewWidth = ex - sx + 1;
|
||||
|
||||
uint8_t set_y_cmd[] = {sy>>8, sy, ey>>8, ey};
|
||||
lspiCmdSend(0x2B, set_y_cmd, sizeof(set_y_cmd));
|
||||
previewHeight = ey - sy + 1;
|
||||
|
||||
lcdWriteCmd(0x2C);
|
||||
|
||||
return (ey-sy+1) * (ex-sx+1) * (ST7789_BPP/8);
|
||||
}
|
||||
|
||||
static void st7789StartStop(lcdDrvFunc_t *lcd, bool startOrStop)
|
||||
{
|
||||
dmaStartStop(startOrStop);
|
||||
}
|
||||
|
||||
static int st7789Fill(lcdDrvFunc_t *lcd, uint32_t fillLen, uint8_t *buf)
|
||||
{
|
||||
return lcdDmaTrans(lcd, buf, fillLen);
|
||||
}
|
||||
|
||||
static void st7789DrawPoint(lcdDrvFunc_t *lcd, uint16_t x, uint16_t y, uint32_t dataWrite)
|
||||
{
|
||||
lspiFifoWrite(dataWrite);
|
||||
return;
|
||||
}
|
||||
|
||||
static void st7789RegisterUspIrqCb(lcdDrvFunc_t *lcd, uspCbRole_e who)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
EC_ASSERT(0,0,0,0);
|
||||
}
|
||||
|
||||
(who == cbForCam)? (lcd->uspIrq4CamCb = st7789HandleUspIrq4Cam) : (lcd->uspIrq4FillCb = st7789HandleUspIrq4Fill);
|
||||
}
|
||||
|
||||
static void st7789UnRegisterUspIrqCb(lcdDrvFunc_t *lcd, uspCbRole_e who)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
EC_ASSERT(0,0,0,0);
|
||||
}
|
||||
|
||||
(who == cbForCam)? (lcd->uspIrq4CamCb = NULL) : (lcd->uspIrq4FillCb = NULL);
|
||||
}
|
||||
|
||||
static void st7789CamPreviewStartStop(lcdDrvFunc_t *lcd, camPreviewStartStop_e previewStartStop)
|
||||
{
|
||||
uint8_t divVal = 0;
|
||||
uint16_t divRemain = 0;
|
||||
|
||||
#if defined TYPE_EC718M
|
||||
if (previewStartStop)
|
||||
{
|
||||
st7789RegisterUspIrqCb(lcd, cbForCam);
|
||||
st7789UnRegisterUspIrqCb(lcd, cbForFill);
|
||||
|
||||
lspiDataFmt.wordSize = 7;
|
||||
lspiDataFmt.txPack = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_DATA_FORMAT, 0);
|
||||
|
||||
lspiDmaCtrl.txDmaReqEn = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_DMA_CTRL, 0);
|
||||
|
||||
lspiInfo.frameHeight = PIC_SRC_HEIGHT; // frame input height
|
||||
lspiInfo.frameWidth = PIC_SRC_WIDTH; // frame input width
|
||||
lspiFrameInfoOut.frameHeightOut = previewHeight; // frame output height
|
||||
lspiFrameInfoOut.frameWidthOut = previewWidth; // frame output width
|
||||
|
||||
if ((previewHeight > PIC_SRC_HEIGHT) || (previewWidth > PIC_SRC_WIDTH))
|
||||
{
|
||||
EC_ASSERT(0,0,0,0);
|
||||
}
|
||||
|
||||
if (lcdIoCtrlParam.previewModeSel == CAM_PREVIEW_SET_AUTO)
|
||||
{
|
||||
divVal = lspiInfo.frameHeight / lspiFrameInfoOut.frameHeightOut;
|
||||
divRemain = lspiInfo.frameHeight % lspiFrameInfoOut.frameHeightOut;
|
||||
lspiTailorInfo0.tailorTop = divRemain/2;
|
||||
lspiTailorInfo0.tailorBottom = divRemain/2;
|
||||
EC_ASSERT(divVal, lspiInfo.frameHeight, lspiFrameInfoOut.frameHeightOut, 0);
|
||||
lspiScaleInfo.colScaleFrac = (divVal==1)? 0 : (128/divVal);
|
||||
|
||||
divVal = lspiInfo.frameWidth / lspiFrameInfoOut.frameWidthOut;
|
||||
divRemain = lspiInfo.frameWidth % lspiFrameInfoOut.frameWidthOut;
|
||||
lspiTailorInfo.tailorLeft = divRemain/2;
|
||||
lspiTailorInfo.tailorRight = divRemain/2;
|
||||
EC_ASSERT(divVal, lspiInfo.frameWidth, lspiFrameInfoOut.frameWidthOut, 0);
|
||||
lspiScaleInfo.rowScaleFrac = (divVal==1)? 0 : (128/divVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
lspiScaleInfo.rowScaleFrac = lcdIoCtrlParam.previewManulSet.rowScaleFrac;
|
||||
lspiScaleInfo.colScaleFrac = lcdIoCtrlParam.previewManulSet.colScaleFrac;
|
||||
lspiTailorInfo.tailorLeft = lcdIoCtrlParam.previewManulSet.tailorLeft;
|
||||
lspiTailorInfo.tailorRight = lcdIoCtrlParam.previewManulSet.tailorRight;
|
||||
lspiTailorInfo0.tailorBottom = lcdIoCtrlParam.previewManulSet.tailorBottom;
|
||||
lspiTailorInfo0.tailorTop = lcdIoCtrlParam.previewManulSet.tailorTop;
|
||||
}
|
||||
|
||||
lcdDrv->ctrl(LSPI_CTRL_SCALE_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_TAILOR_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO_OUT, 0);
|
||||
|
||||
lspiCtrl.datSrc = 0; // 0: data from camera; 1: data from memory
|
||||
lspiCtrl.colorModeIn = 0; // YUV422, every item is 8bit
|
||||
lspiCtrl.colorModeOut = 1; // RGB565
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
|
||||
lspiCmdCtrl.wrRdn = 1; // 1: wr 0: rd
|
||||
lspiCmdCtrl.ramWr = 1; // start ramwr
|
||||
lspiCmdCtrl.dataLen = 0x3fffff; // infinite data, used in camera to lspi
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_CTRL, 0);
|
||||
}
|
||||
#else // CHIP 718
|
||||
if (previewStartStop)
|
||||
{
|
||||
st7789RegisterUspIrqCb(lcd, cbForCam);
|
||||
st7789UnRegisterUspIrqCb(lcd, cbForFill);
|
||||
|
||||
lspiDataFmt.wordSize = 7;
|
||||
lspiDataFmt.txPack = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_DATA_FORMAT, 0);
|
||||
|
||||
lspiDmaCtrl.txDmaReqEn = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_DMA_CTRL, 0);
|
||||
|
||||
lspiInfo.frameHeight = PIC_SRC_HEIGHT; // frame input height
|
||||
lspiInfo.frameWidth = PIC_SRC_WIDTH; // frame input width
|
||||
lspiFrameInfoOut.frameHeightOut = previewHeight; // frame output height
|
||||
lspiFrameInfoOut.frameWidthOut = previewWidth; // frame output width
|
||||
|
||||
if ((previewHeight > PIC_SRC_HEIGHT) || (previewWidth > PIC_SRC_WIDTH))
|
||||
{
|
||||
EC_ASSERT(0,0,0,0);
|
||||
}
|
||||
|
||||
if (lcdIoCtrlParam.previewModeSel == CAM_PREVIEW_SET_AUTO)
|
||||
{
|
||||
divVal = lspiInfo.frameHeight / lspiFrameInfoOut.frameHeightOut;
|
||||
divRemain = lspiInfo.frameHeight % lspiFrameInfoOut.frameHeightOut;
|
||||
lspiTailorInfo0.tailorTop = divRemain/2;
|
||||
lspiTailorInfo0.tailorBottom = divRemain/2;
|
||||
EC_ASSERT(divVal, lspiInfo.frameHeight, lspiFrameInfoOut.frameHeightOut, 0);
|
||||
lspiScaleInfo.colScaleFrac = (divVal==1)? 0 : (128/divVal);
|
||||
|
||||
divVal = lspiInfo.frameWidth / lspiFrameInfoOut.frameWidthOut;
|
||||
divRemain = lspiInfo.frameWidth % lspiFrameInfoOut.frameWidthOut;
|
||||
lspiTailorInfo.tailorLeft = divRemain/2;
|
||||
lspiTailorInfo.tailorRight = divRemain/2;
|
||||
EC_ASSERT(divVal, lspiInfo.frameWidth, lspiFrameInfoOut.frameWidthOut, 0);
|
||||
lspiScaleInfo.rowScaleFrac = (divVal==1)? 0 : (128/divVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
lspiScaleInfo.rowScaleFrac = lcdIoCtrlParam.previewManulSet.rowScaleFrac;
|
||||
lspiScaleInfo.colScaleFrac = lcdIoCtrlParam.previewManulSet.colScaleFrac;
|
||||
lspiTailorInfo.tailorLeft = lcdIoCtrlParam.previewManulSet.tailorLeft;
|
||||
lspiTailorInfo.tailorRight = lcdIoCtrlParam.previewManulSet.tailorRight;
|
||||
lspiTailorInfo0.tailorBottom = lcdIoCtrlParam.previewManulSet.tailorBottom;
|
||||
lspiTailorInfo0.tailorTop = lcdIoCtrlParam.previewManulSet.tailorTop;
|
||||
}
|
||||
|
||||
lcdDrv->ctrl(LSPI_CTRL_SCALE_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_TAILOR_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO_OUT, 0);
|
||||
|
||||
lspiCtrl.datSrc = 0; // 0: data from camera; 1: data from memory
|
||||
lspiCtrl.colorModeIn = 0; // YUV422, every item is 8bit
|
||||
lspiCtrl.colorModeOut = 1; // RGB565
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
|
||||
lspiCmdCtrl.wrRdn = 1; // 1: wr 0: rd
|
||||
lspiCmdCtrl.ramWr = 1; // start ramwr
|
||||
lspiCmdCtrl.dataLen = 0x3fffff; // infinite data, used in camera to lspi
|
||||
lcdDrv->ctrl(LSPI_CTRL_CMD_CTRL, 0);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
lspiDmaCtrl.txDmaReqEn = 0;
|
||||
lspiDataFmt.wordSize = 31;
|
||||
lspiDataFmt.txPack = 0;
|
||||
lspiInfo.frameHeight = lcd->height; // frame input height
|
||||
lspiInfo.frameWidth = lcd->width; // frame input width
|
||||
lspiFrameInfoOut.frameHeightOut = lcd->height; // frame output height
|
||||
lspiFrameInfoOut.frameWidthOut = lcd->width; // frame output width
|
||||
lspiCtrl.colorModeIn = 3; // rgb565
|
||||
lspiCtrl.colorModeOut = 1; // rgb565
|
||||
lspiCtrl.datSrc = 1; // 0: data from camera; 1: data from memory
|
||||
lspiScaleInfo.rowScaleFrac = 0;
|
||||
lspiScaleInfo.colScaleFrac = 0;
|
||||
lspiTailorInfo.tailorLeft = 0; // frame output height
|
||||
lspiTailorInfo.tailorRight = 0; // frame output width
|
||||
lcdDrv->ctrl(LSPI_CTRL_SCALE_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_TAILOR_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_DATA_FORMAT, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_DMA_CTRL, 0);
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO_OUT, 0);
|
||||
|
||||
// before send first cmd/data to lcd, clear unnessary status
|
||||
if (((LSPI2->STAS >> 27)& 0x1) > 0)
|
||||
{
|
||||
LSPI2->STAS |= 1<<27;
|
||||
}
|
||||
|
||||
if (((LSPI2->STAS >> 28)& 0x1) > 0)
|
||||
{
|
||||
LSPI2->STAS |= 1<<28;
|
||||
}
|
||||
|
||||
#if ((defined CHIP_EC718) && !(defined TYPE_EC718M)) || (defined CHIP_EC716)
|
||||
if (((LSPI2->STAS >> 13)& 0x3f) > 0)
|
||||
#else // 719
|
||||
if (((LSPI2->LSPI_STAT >> 8)& 0x3f) > 0)
|
||||
#endif
|
||||
{
|
||||
LSPI2->DMACTL |= 1<<25;
|
||||
}
|
||||
|
||||
LSPI2->DMACTL |= 1<<24; // clear rx fifo
|
||||
|
||||
// write first dummy cmd to lcd. It's nessary to clear lspi fifo
|
||||
lcdWriteCmd(0xff);
|
||||
lcdWriteData(0x00);
|
||||
lcdDrv->send(NULL, 0);
|
||||
|
||||
#if ((defined CHIP_EC718) && !(defined TYPE_EC718M)) || (defined CHIP_EC716)
|
||||
if (((LSPI2->STAS >> 13)& 0x3f) > 0)
|
||||
#else // 719
|
||||
if (((LSPI2->LSPI_STAT >> 8)& 0x3f) > 0)
|
||||
#endif
|
||||
{
|
||||
LSPI2->DMACTL |= 1<<25;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int st7789Close(lcdDrvFunc_t *lcd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
AP_PLAT_COMMON_DATA lcdDrvFunc_t st7789Drv =
|
||||
{
|
||||
.id = 0x7789,
|
||||
.width = ST7789_WIDTH,
|
||||
.height = ST7789_HEIGHT,
|
||||
.freq = ST7789_FREQ,
|
||||
.bpp = ST7789_BPP,
|
||||
.initRegTbl = initTable7789,
|
||||
.initRegTblLen = sizeof(initTable7789)/sizeof(initLine_t),
|
||||
.dir = 0,
|
||||
|
||||
.init = st7789Init,
|
||||
.drawPoint = st7789DrawPoint,
|
||||
.setWindow = st7789AddrSet,
|
||||
.fill = st7789Fill,
|
||||
.backLight = st7789BackLight,
|
||||
.startStop = st7789StartStop,
|
||||
.startStopPreview = st7789CamPreviewStartStop,
|
||||
.uspIrq4CamCb = NULL,
|
||||
.uspIrq4FillCb = NULL,
|
||||
.registerUspIrqCb = st7789RegisterUspIrqCb,
|
||||
.unregisterUspIrqCb = st7789UnRegisterUspIrqCb,
|
||||
.direction = NULL,
|
||||
.close = st7789Close,
|
||||
};
|
||||
|
@ -1,238 +0,0 @@
|
||||
#include "bsp.h"
|
||||
#include "lcdDrv.h"
|
||||
#include "lcdComm.h"
|
||||
#include "lcdDev_77903.h"
|
||||
#include "sctdef.h"
|
||||
|
||||
extern lspiDrvInterface_t *lcdDrv;
|
||||
|
||||
static const initLine_t initTable77903[] =
|
||||
{
|
||||
{0xf0, 1, {0xc3}},
|
||||
{0xf0, 1, {0x96}},
|
||||
{0xf0, 1, {0xa5}},
|
||||
{0xc1, 4, {0x00,0x08,0xae,0x13}},
|
||||
{0xc2, 4, {0x00,0x08,0xa5,0x13}},
|
||||
{0xc3, 4, {0x44,0x04,0x44,0x04}},
|
||||
{0xc4, 4, {0x44,0x04,0x44,0x04}},
|
||||
{0xc5, 1, {0x51}},
|
||||
{0xd6, 1, {0x0}},
|
||||
{0xd7, 1, {0x0}},
|
||||
{0xe0, 14,{0xd2,0x07,0x0c,0x0a,0x09,0x26,0x34,0x44,0x4b,0x19,0x14,0x14,0x2d,0x33}},
|
||||
{0xe1, 14,{0xd2,0x07,0x0c,0x09,0x08,0x25,0x33,0x44,0x4a,0x19,0x14,0x13,0x2d,0x33}},
|
||||
{0xe5, 14,{0xbd,0xf5,0xc1,0x33,0x22,0x25,0x10,0x55,0x55,0x55,0x55,0x55,0x55,0x55}},
|
||||
{0xe6, 14,{0xbd,0xf5,0xc1,0x33,0x22,0x25,0x10,0x55,0x55,0x55,0x55,0x55,0x55,0x55}},
|
||||
{0xec, 6, {0x00,0x55,0x00,0x00,0x00,0x08}},
|
||||
{0x36, 1, {0x0c}},
|
||||
#if (ST77903_BPP == 16)
|
||||
{0x3a, 1, {5}}, // rgb565
|
||||
#elif (ST77903_BPP == 24)
|
||||
{0x3a, 1, {7}}, // rgb888
|
||||
#elif (ST77903_BPP == 18)
|
||||
{0x3a, 1, {6}}, // rgb666
|
||||
#endif
|
||||
{0xb2, 1, {0x09}},
|
||||
{0xb3, 1, {0x01}},
|
||||
{0xb4, 1, {0x01}},
|
||||
{0xb5, 4, {0x00,0x08,0x00,0x08}},
|
||||
{0xb6, 2, {0xc7,0x31}},
|
||||
{0xa4, 2, {0xc0,0x63}},
|
||||
{0xa5, 9, {0x00,0x00,0x00,0x00,0x00,0x15,0x2a,0xba,0x02}},
|
||||
{0xa6, 9, {0x00,0x00,0x00,0x00,0x00,0x15,0x2a,0xba,0x02}},
|
||||
{0xba, 7, {0x1a,0x0a,0x45,0x00,0x23,0x01,0x00}},
|
||||
{0xbb, 8, {0x00,0x24,0x00,0x2f,0x83,0x07,0x18,0x00}},
|
||||
{0xbd, 11,{0x22,0x11,0xff,0xff,0x55,0x44,0x77,0x66,0xff,0xff,0x0f}},
|
||||
{0xff, 1, {200}},
|
||||
{0xed, 1, {0xc3}},
|
||||
{0xe4, 3, {0x40,0x0f,0x2f}},
|
||||
{0x21, 0, {}},
|
||||
{0x11, 0, {}},
|
||||
{0x29, 0, {}},
|
||||
|
||||
{0xf0, 1, {0xc3}},
|
||||
{0xf0, 1, {0x96}},
|
||||
|
||||
#if (BIST_TEST == 1)
|
||||
{0xb0, 1, {0xa5}},
|
||||
{0xcc, 9, {0x40,0x00,0x3f,0x00,0x14,0x14,0x20,0x20,0x03}},
|
||||
#endif
|
||||
};
|
||||
|
||||
void st77903HandleUspIrq4Cam(lcdDrvFunc_t *lcd)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void st77903HandleUspIrq4Fill(lcdDrvFunc_t *lcd)
|
||||
{
|
||||
}
|
||||
|
||||
static int st77903Init(lcdDrvFunc_t *lcd, void* uspCb, void *dmaCb, uint32_t freq, uint8_t bpp)
|
||||
{
|
||||
lcdIoInit(false);
|
||||
lcdRst(10, 10);
|
||||
dmaInit(dmaCb);
|
||||
lspiDefaultCfg(lcd, uspCb, freq, bpp);
|
||||
lcdInterfaceType(ST77903_INTERFACE);
|
||||
lcdRegInit(0x77903);
|
||||
lcdMspiHsyncSet(0x60, 0xde, 6, 6);
|
||||
lcdWriteCmd(0x61);
|
||||
lcdMspiSet(1, 0, 2, DEFAULT_INST);
|
||||
lcdMspiVsyncSet(1, 0xde, lspiDiv);
|
||||
lcdCsnHighCycleMin(lspiDiv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void st77903BackLight(lcdDrvFunc_t *lcd, uint8_t level)
|
||||
{
|
||||
#if (BK_USE_GPIO == 1)
|
||||
lcdGpioBkLevel(level);
|
||||
#elif (BK_USE_PWM == 1)
|
||||
lcdPwmBkLevel(level);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
sx: start x
|
||||
sy: start y
|
||||
ex: end x
|
||||
ey: end y
|
||||
*/
|
||||
static uint32_t st77903AddrSet(lcdDrvFunc_t *lcd, uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey)
|
||||
{
|
||||
uint32_t len = 0;
|
||||
#if 0 // how to set the coordinate?
|
||||
uint8_t set_x_cmd[] = {sx>>8, sx, ex>>8, ex};
|
||||
lspiCmdSend(0x2A, set_x_cmd, sizeof(set_x_cmd));
|
||||
|
||||
uint8_t set_y_cmd[] = {sy>>8, sy, ey>>8, ey};
|
||||
lspiCmdSend(0x2B, set_y_cmd, sizeof(set_y_cmd));
|
||||
|
||||
lcdWriteCmd(0x2C);
|
||||
#endif
|
||||
|
||||
if (ST77903_BPP == 24)
|
||||
{
|
||||
len = (ey-sy+1) * (ex-sx+1) * (ST77903_BPP/8+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
len = (ey-sy+1) * (ex-sx+1) * (ST77903_BPP/8);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static void st77903StartStop(lcdDrvFunc_t *lcd, bool startOrStop)
|
||||
{
|
||||
dmaStartStop(startOrStop);
|
||||
}
|
||||
|
||||
static int st77903Fill(lcdDrvFunc_t *lcd, uint32_t fillLen, uint8_t *buf)
|
||||
{
|
||||
return lcdDmaTrans(lcd, buf, fillLen);
|
||||
}
|
||||
|
||||
static void st77903DrawPoint(lcdDrvFunc_t *lcd, uint16_t x, uint16_t y, uint32_t dataWrite)
|
||||
{
|
||||
st77903AddrSet(lcd, x, y, x, y);
|
||||
lspiFifoWrite(dataWrite);
|
||||
return;
|
||||
}
|
||||
|
||||
static void st77903RegisterUspIrqCb(lcdDrvFunc_t *lcd, uspCbRole_e who)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
EC_ASSERT(0,0,0,0);
|
||||
}
|
||||
|
||||
(who == cbForCam)? (lcd->uspIrq4CamCb = st77903HandleUspIrq4Cam) : (lcd->uspIrq4FillCb = st77903HandleUspIrq4Fill);
|
||||
}
|
||||
|
||||
static void st77903UnRegisterUspIrqCb(lcdDrvFunc_t *lcd, uspCbRole_e who)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
EC_ASSERT(0,0,0,0);
|
||||
}
|
||||
|
||||
(who == cbForCam)? (lcd->uspIrq4CamCb = NULL) : (lcd->uspIrq4FillCb = NULL);
|
||||
}
|
||||
|
||||
static void st77903CamPreviewStartStop(lcdDrvFunc_t *lcd, camPreviewStartStop_e previewStartStop)
|
||||
{
|
||||
if (previewStartStop)
|
||||
{
|
||||
st77903UnRegisterUspIrqCb(lcd, cbForFill);
|
||||
st77903RegisterUspIrqCb(lcd, cbForCam);
|
||||
|
||||
#if (CAMERA_ENABLE_BF30A2)
|
||||
|
||||
#elif (CAMERA_ENABLE_GC032A)
|
||||
// preview
|
||||
lcdWriteCmd(0x36);
|
||||
// lcdWriteData(0x00);// 0: normal; 0x20: reverse, mirror image 0x40: x mirror
|
||||
lcdWriteData(0xa0);
|
||||
lcdDrv->send(NULL, 0);
|
||||
|
||||
lcdWriteCmd(0x2C);
|
||||
st77903AddrSet(lcd, 0, 0, 320-1, 240-1);
|
||||
|
||||
lspiDataFmt.wordSize = 7;
|
||||
lspiDataFmt.txPack = 0;
|
||||
lcdDrv->ctrl(LSPI_CTRL_DATA_FORMAT, 0);
|
||||
|
||||
// lcd size
|
||||
lspiInfo.frameHeight = 480; // frame input height
|
||||
lspiInfo.frameWidth = 640; // frame input width
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO, 0);
|
||||
|
||||
lspiFrameInfoOut.frameHeightOut =320;//lcd->pra->height;//320; // frame output height
|
||||
lspiFrameInfoOut.frameWidthOut = 240;//lcd->pra->width;//240; // frame output width
|
||||
lcdDrv->ctrl(LSPI_CTRL_FRAME_INFO_OUT, 0);
|
||||
|
||||
// lspiScaleInfo.rowScaleFrac =128;
|
||||
// lspiScaleInfo.colScaleFrac = 128;
|
||||
|
||||
lspiScaleInfo.rowScaleFrac =64;
|
||||
lspiScaleInfo.colScaleFrac = 64;
|
||||
lcdDrv->ctrl(LSPI_CTRL_SCALE_INFO, 0);
|
||||
#elif (CAMERA_ENABLE_GC6153)
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static int st77903Close(lcdDrvFunc_t *lcd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
AP_PLAT_COMMON_DATA lcdDrvFunc_t st77903Drv =
|
||||
{
|
||||
.id = 0x77903,
|
||||
.width = ST77903_WIDTH,
|
||||
.height = ST77903_HEIGHT,
|
||||
.freq = ST77903_FREQ,
|
||||
.bpp = ST77903_BPP,
|
||||
.initRegTbl = initTable77903,
|
||||
.initRegTblLen = sizeof(initTable77903)/sizeof(initLine_t),
|
||||
.dir = 0,
|
||||
|
||||
.init = st77903Init,
|
||||
.drawPoint = st77903DrawPoint,
|
||||
.setWindow = st77903AddrSet,
|
||||
.fill = st77903Fill,
|
||||
.backLight = st77903BackLight,
|
||||
.startStop = st77903StartStop,
|
||||
.startStopPreview = st77903CamPreviewStartStop,
|
||||
.uspIrq4CamCb = NULL,
|
||||
.uspIrq4FillCb = NULL,
|
||||
.registerUspIrqCb = st77903RegisterUspIrqCb,
|
||||
.unregisterUspIrqCb = st77903UnRegisterUspIrqCb,
|
||||
.direction = NULL,
|
||||
.close = st77903Close,
|
||||
};
|
||||
|
@ -1,560 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "bsp.h"
|
||||
#include "bsp_custom.h"
|
||||
#include "lcdDrv.h"
|
||||
#ifdef FEATURE_SUBSYS_SYSLOG_ENABLE
|
||||
#include "syslog.h"
|
||||
#endif
|
||||
#include "sctdef.h"
|
||||
|
||||
extern void lcdDrvDelay(uint32_t us);
|
||||
extern void lspiCmdSend(uint8_t cmd,uint8_t *data,uint8_t allbytes);
|
||||
AP_PLAT_COMMON_DATA static lspiDrvInterface_t *lcdDrv1 = &lspiDrvInterface2;
|
||||
AP_PLAT_COMMON_BSS static lspiErrCb lspiErrStatsFunc;
|
||||
AP_PLAT_COMMON_BSS lcdDrvFunc_t* lcdDevHandle;
|
||||
AP_PLAT_COMMON_BSS lcdIoCtrl_t lcdIoCtrlParam;
|
||||
|
||||
|
||||
AP_PLAT_COMMON_DATA lcdDrvFunc_t* lcdDrvList[] =
|
||||
{
|
||||
#if (LCD_ST7789_ENABLE == 1)
|
||||
&st7789Drv,
|
||||
#elif (LCD_ST77903_ENABLE == 1)
|
||||
&st77903Drv,
|
||||
#elif (LCD_AXS15231_ENABLE == 1)
|
||||
&axs15231Drv,
|
||||
#elif (LCD_CO5300_ENABLE == 1)
|
||||
&co5300Drv,
|
||||
#endif
|
||||
};
|
||||
|
||||
lcdDrvFunc_t* lcdOpen(uint32_t id, void* uspCb, void* dmaCb)
|
||||
{
|
||||
lcdDrvFunc_t *pDrvFunc = NULL;
|
||||
|
||||
uint8_t drvListLen = sizeof(lcdDrvList) / sizeof(lcdDrvFunc_t*);
|
||||
if (drvListLen > 0)
|
||||
{
|
||||
for (uint8_t i = 0; i < drvListLen; i++)
|
||||
{
|
||||
if (id == lcdDrvList[i]->id)
|
||||
{
|
||||
pDrvFunc = lcdDrvList[i];
|
||||
pDrvFunc->init(pDrvFunc, uspCb, dmaCb, pDrvFunc->freq, pDrvFunc->bpp);
|
||||
lcdDevHandle = pDrvFunc;
|
||||
#ifdef PHONE_APP
|
||||
static bool firstBoot = true;
|
||||
if (firstBoot == true)
|
||||
{
|
||||
firstBoot = false;
|
||||
pDrvFunc->fill(pDrvFunc, pDrvFunc->setWindow(pDrvFunc, 0, 0, LCD_WIDTH-1, LCD_HEIGHT-1), (uint8_t *)(PKGFLXRAW1_LOGO_LNA + 4));
|
||||
osDelay(30);
|
||||
}
|
||||
#else
|
||||
#ifdef LCD_INIT_PAGE_LNA
|
||||
pDrvFunc->fill(pDrvFunc, pDrvFunc->setWindow(pDrvFunc, 0, 0, LCD_WIDTH-1, LCD_HEIGHT-1), (uint8_t *)(LCD_INIT_PAGE_LNA + 4));
|
||||
osDelay(30);
|
||||
#endif
|
||||
#endif
|
||||
return pDrvFunc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void lcdRegisterSlp1Cb(lcdSlp1Cb_fn cb)
|
||||
{
|
||||
lcdSlp1CbFn = cb;
|
||||
}
|
||||
|
||||
|
||||
void lcdIoInit(bool isAonIO)
|
||||
{
|
||||
if (isAonIO)
|
||||
{
|
||||
slpManAONIOPowerOn();
|
||||
}
|
||||
|
||||
PadConfig_t config;
|
||||
GpioPinConfig_t gpioCfg;
|
||||
PAD_getDefaultConfig(&config);
|
||||
|
||||
// 1. rst pin init
|
||||
config.mux = LSPI_RST_PAD_ALT_FUNC;
|
||||
PAD_setPinConfig(LSPI_RST_GPIO_ADDR, &config);
|
||||
gpioCfg.pinDirection = GPIO_DIRECTION_OUTPUT;
|
||||
gpioCfg.misc.initOutput = 1;
|
||||
GPIO_pinConfig(LSPI_RST_GPIO_INSTANCE, LSPI_RST_GPIO_PIN, &gpioCfg);
|
||||
|
||||
// 2. backLight init
|
||||
#if (BK_USE_GPIO == 1)
|
||||
config.mux = LCD_BK_PAD_ALT_FUNC;
|
||||
PAD_setPinConfig(LCD_BK_PAD_INDEX, &config);
|
||||
gpioCfg.pinDirection = GPIO_DIRECTION_OUTPUT;
|
||||
gpioCfg.misc.initOutput = 0;
|
||||
GPIO_pinConfig(LCD_BK_GPIO_INSTANCE, LCD_BK_GPIO_PIN, &gpioCfg);
|
||||
#elif (BK_USE_PWM == 1)
|
||||
lcdPwmBkInit();
|
||||
#endif
|
||||
|
||||
// 3. ldo pin init
|
||||
#if (ENABLE_LDO == 1)
|
||||
config.mux = LCD_EN_PAD_ALT_FUNC;
|
||||
PAD_setPinConfig(LCD_EN_PAD_INDEX, &config);
|
||||
gpioCfg.pinDirection = GPIO_DIRECTION_OUTPUT;
|
||||
gpioCfg.misc.initOutput = 1;
|
||||
GPIO_pinConfig(LCD_EN_GPIO_INSTANCE, LCD_EN_GPIO_PIN, &gpioCfg);
|
||||
#endif
|
||||
|
||||
// 4. te init
|
||||
#if ((defined CHIP_EC718) && !(defined TYPE_EC718M)) || (defined CHIP_EC716)
|
||||
// 4.1 718 te init
|
||||
#else
|
||||
// 4.2 719 te init
|
||||
#ifdef LCD_TE_GPIO_PIN
|
||||
config.mux = LCD_TE_PAD_ALT_FUNC;
|
||||
PAD_setPinConfig(LCD_TE_PAD_INDEX, &config);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// test fill one frame need how much time
|
||||
#if 0
|
||||
config.mux = PAD_MUX_ALT0;
|
||||
PAD_setPinConfig(27, &config);
|
||||
gpioCfg.pinDirection = GPIO_DIRECTION_OUTPUT;
|
||||
gpioCfg.misc.initOutput = 1;
|
||||
GPIO_pinConfig(0, 12, &gpioCfg);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void lcdRegInit(uint32_t id)
|
||||
{
|
||||
initLine_t *init = NULL;
|
||||
uint8_t drvListLen = sizeof(lcdDrvList) / sizeof(lcdDrvFunc_t*);
|
||||
|
||||
if (drvListLen > 0)
|
||||
{
|
||||
for (uint8_t i = 0; i < drvListLen; i++)
|
||||
{
|
||||
if (id == lcdDrvList[i]->id)
|
||||
{
|
||||
init = lcdDrvList[i]->initRegTbl;
|
||||
|
||||
for (int j = 0; j < lcdDrvList[i]->initRegTblLen; j++)
|
||||
{
|
||||
if (init->cmd == 0xff)
|
||||
{
|
||||
lcdDrvDelay(init->data[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
lspiCmdSend(init->cmd, init->data, init->len);
|
||||
}
|
||||
|
||||
init++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int lcdClose(lcdDrvFunc_t *pdev)
|
||||
{
|
||||
if (pdev == NULL) return 1;
|
||||
|
||||
pdev->close(pdev);
|
||||
pdev = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int lcdDirection(lcdDrvFunc_t *lcd, DisDirection_e dir)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return lcd->direction(lcd,dir);
|
||||
}
|
||||
|
||||
void camPreview(lcdDrvFunc_t *lcd, camPreviewStartStop_e previewStartStop)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lcd->startStopPreview(lcd, previewStartStop);
|
||||
}
|
||||
|
||||
|
||||
void lcdDrawPoint(lcdDrvFunc_t *lcd, uint16_t x, uint16_t y, uint32_t dataWrite)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return lcd->drawPoint(lcd, x, y, dataWrite);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Fills an area of the LCD with the data from a buffer.
|
||||
*
|
||||
* This function fills an area of the LCD specified by the start and end coordinates
|
||||
* with the data from a buffer. The DMA trunk length parameter is not used in this
|
||||
* function and is mentioned in the comment as not being used.
|
||||
*
|
||||
* \param lcd A pointer to the LCD device structure.
|
||||
* \param sx The starting x-coordinate for the fill operation.
|
||||
* \param sy The starting y-coordinate for the fill operation.
|
||||
* \param ex The ending x-coordinate for the fill operation.
|
||||
* \param ey The ending y-coordinate for the fill operation.
|
||||
* \param buf A pointer to the buffer containing the data to be filled into the LCD.
|
||||
* \param dmaTrunkLength The length of the DMA trunk, which is not used in this function.
|
||||
*
|
||||
* \return Returns the result of the fill operation from the LCD driver.
|
||||
* Returns 0xffffffff if the `lcd` pointer is `NULL`.
|
||||
*/
|
||||
uint32_t lcdSetWindow(lcdDrvFunc_t *lcd, uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
return lcd->setWindow(lcd, sx, sy, ex, ey);
|
||||
}
|
||||
|
||||
int lcdFill(lcdDrvFunc_t *lcd, uint32_t fillLen, uint8_t* buf)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return lcd->fill(lcd, fillLen, buf);
|
||||
}
|
||||
|
||||
// level: 0 ~ 100
|
||||
void lcdBackLight(lcdDrvFunc_t *lcd, uint8_t level)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
return lcd->backLight(lcd, level);
|
||||
}
|
||||
|
||||
void lcdPowerOnOff(lcdDrvFunc_t *lcd, lcdPowerOnOff_e onoff)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
return lcd->powerOnOff(lcd, onoff);
|
||||
}
|
||||
|
||||
|
||||
void lspiRstAndClearFifo()
|
||||
{
|
||||
lspiCtrl.enable = 0;
|
||||
lcdDrv1->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
|
||||
GPR_swReset(RST_FCLK_USP2);
|
||||
LSPI2->DMACTL |= 1<<25; // clear tx fifo
|
||||
LSPI2->STAS |= 1;
|
||||
|
||||
lspiCtrl.enable = 1;
|
||||
lcdDrv1->ctrl(LSPI_CTRL_CTRL, 0);
|
||||
}
|
||||
|
||||
void lspiRegisterErrStatsCb(lspiErrCb errCb)
|
||||
{
|
||||
lspiErrStatsFunc = errCb;
|
||||
}
|
||||
|
||||
void lspiCheckErrStats()
|
||||
{
|
||||
if (!lspiErrStatsFunc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// check lspi error status and give cb to user
|
||||
uint32_t status = LSPI2->STAS;
|
||||
|
||||
if ( (status | ICL_STATS_TX_UNDERRUN_RUN_Msk) ||
|
||||
(status | ICL_STATS_TX_DMA_ERR_Msk) ||
|
||||
(status | ICL_STATS_RX_OVERFLOW_Msk) ||
|
||||
(status | ICL_STATS_RX_DMA_ERR_Msk) ||
|
||||
(status | ICL_STATS_RX_FIFO_TIMEOUT_Msk) ||
|
||||
(status | ICL_STATS_FS_ERR_Msk) ||
|
||||
(status | ICL_STATS_CSPI_BUS_TIMEOUT_Msk) ||
|
||||
(status | ICL_STATS_RX_FIFO_TIMEOUT_Msk)
|
||||
)
|
||||
{
|
||||
lspiErrStatsFunc(status);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void imageRotateColor(uint8_t* src, uint32_t width, uint32_t height, uint8_t* dst, uint8_t bpp)
|
||||
{
|
||||
int i, j, bytePerLine, tmp, i2;
|
||||
|
||||
bytePerLine = width * bpp / 8;
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
i2 = i*bpp / 8;
|
||||
for (j = 0; j < height; j++)
|
||||
{
|
||||
tmp = (height - 1 - j) * bytePerLine + i2;
|
||||
*dst++ = src[tmp];
|
||||
*dst++ = src[tmp+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void imageRotateGray(uint8_t* src, uint32_t width, uint32_t height, uint8_t* dst)
|
||||
{
|
||||
for (int i= 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
dst[i*height + j] = src[(height-1-j) * width + i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define RANGE_LIMIT(x) (x > 255 ? 255 : (x < 0 ? 0 : x))
|
||||
void yuv422ToRgb565_2(const void* inbuf, void* outbuf, int width, int height)
|
||||
{
|
||||
int rows, cols;
|
||||
int y, u, v, r, g, b;
|
||||
unsigned char *yuv_buf;
|
||||
unsigned short *rgb_buf;
|
||||
int y_pos,u_pos,v_pos;
|
||||
|
||||
yuv_buf = (unsigned char *)inbuf;
|
||||
rgb_buf = (unsigned short *)outbuf;
|
||||
|
||||
y_pos = 0;
|
||||
u_pos = 1;
|
||||
v_pos = 3;
|
||||
|
||||
for (rows = 0; rows < height; rows++)
|
||||
{
|
||||
for (cols = 0; cols < width; cols++)
|
||||
{
|
||||
y = yuv_buf[y_pos];
|
||||
u = yuv_buf[u_pos] - 128;
|
||||
v = yuv_buf[v_pos] - 128;
|
||||
|
||||
// R = Y + 1.402*(V-128)
|
||||
// G = Y - 0.34414*(U-128)
|
||||
// B = Y + 1.772*(U-128)
|
||||
r = RANGE_LIMIT(y + v + ((v * 103) >> 8));
|
||||
g = RANGE_LIMIT(y - ((u * 88) >> 8) - ((v * 183) >> 8));
|
||||
b = RANGE_LIMIT(y + u + ((u * 198) >> 8));
|
||||
|
||||
*rgb_buf++ = (((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3));
|
||||
|
||||
y_pos += 2;
|
||||
|
||||
if (cols & 0x01)
|
||||
{
|
||||
u_pos += 4;
|
||||
v_pos += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if ((defined CHIP_EC718) && !(defined TYPE_EC718M)) || (defined CHIP_EC716)
|
||||
void calTe(uint32_t totalBytes, uint16_t sy)
|
||||
{
|
||||
//uint32_t timeStampApp= 0;
|
||||
uint32_t teRunTimeMs = 0;
|
||||
uint16_t yte = 0;
|
||||
//uint32_t controllerBytesPerMs = 480*320*2/28;
|
||||
uint16_t waitTimeMs = 0;
|
||||
|
||||
// cal te
|
||||
#if 0
|
||||
timeStampApp = TIMER_getCount(0);
|
||||
|
||||
if (timeStampApp < timeStampTe)
|
||||
{
|
||||
teRunTimeMs = (26000 - timeStampTe + timeStampApp) / 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
teRunTimeMs = (timeStampApp - timeStampTe) / 1000;
|
||||
}
|
||||
#else
|
||||
#if (BK_USE_PWM == 1)
|
||||
teRunTimeMs = millis();
|
||||
#endif
|
||||
#endif
|
||||
if (teRunTimeMs > 16)
|
||||
{
|
||||
teRunTimeMs = 0;
|
||||
}
|
||||
|
||||
yte = teRunTimeMs * 40 - 1;
|
||||
|
||||
|
||||
|
||||
if (teRunTimeMs > 6)
|
||||
{
|
||||
if (sy > yte)
|
||||
{
|
||||
waitTimeMs = (sy-yte)/40;
|
||||
if (waitTimeMs == 0)
|
||||
{
|
||||
waitTimeMs = 1; // at least 1ms
|
||||
}
|
||||
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
osDelay(waitTimeMs);
|
||||
#endif
|
||||
dmaStartStop(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sy >= (480/2))
|
||||
{
|
||||
dmaStartStop(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
waitTimeMs = 16 - teRunTimeMs + sy/40; // +1
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
osDelay(waitTimeMs);
|
||||
#endif
|
||||
dmaStartStop(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sy > yte)
|
||||
{
|
||||
waitTimeMs = (sy-yte)/40;
|
||||
if (waitTimeMs == 0)
|
||||
{
|
||||
waitTimeMs = 1; // at least 1ms
|
||||
}
|
||||
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
osDelay(waitTimeMs);
|
||||
#endif
|
||||
dmaStartStop(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (totalBytes > ((16-teRunTimeMs+12)*40*320*2))
|
||||
{
|
||||
// must wait te irq
|
||||
//osDelay(16-teRunTimeMs);
|
||||
//osEventFlagsWait(lcdEvtHandle, 0x4, osFlagsWaitAll, osWaitForever); // in te gpio isr release
|
||||
dmaStartStop(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
dmaStartStop(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else // chip 719
|
||||
void calTe(teEdgeSel_e teEdge, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye)
|
||||
{
|
||||
uint32_t tlspi=0, te=0, tw=0, tlcd=0, ta=0, tgaps=0, tgape=0, pos0=0, pos1=0;
|
||||
xs += LCD_X_OFFSET;
|
||||
xe += LCD_X_OFFSET;
|
||||
ys += LCD_Y_OFFSET;
|
||||
ye += LCD_Y_OFFSET;
|
||||
|
||||
#if (LCD_INTERFACE_SPI == 1)
|
||||
tlspi = 24 * (LCD_FREQ / (51*1024*1024)) * (LCD_PIXEL / (320*240)) * 1000; // us
|
||||
#elif (LCD_INTERFACE_MSPI == 1)
|
||||
if (LCD_FREQ == 51*1024*1024)
|
||||
{
|
||||
tlspi = 16600; // 51M, 16.6ms
|
||||
}
|
||||
else if (LCD_FREQ == 6*1024*1024)
|
||||
{
|
||||
tlspi = 148000; // 6M, 148ms
|
||||
}
|
||||
#elif (LCD_INTERFACE_8080 == 1)
|
||||
|
||||
#endif
|
||||
|
||||
te = LCD_TE_CYCLE;
|
||||
tw = LCD_TE_WAIT_TIME;
|
||||
tlcd = te - tw;
|
||||
ta = (ye - ys + 1) * (xe - xs + 1) / LCD_PIXEL * tlspi ;
|
||||
tgaps = ys * tlcd / LCD_HEIGHT;
|
||||
tgape = ye * tlcd / LCD_HEIGHT;
|
||||
|
||||
if (ta < (tgape - tgaps))
|
||||
{
|
||||
pos1 = tgaps;
|
||||
pos0 = tgape - ta;
|
||||
}
|
||||
else if (((tgape - tgaps) <= ta) && (ta <= tgape))
|
||||
{
|
||||
pos1 = tgape - ta;
|
||||
pos0 = tgaps;
|
||||
}
|
||||
else if ((tgape < ta) && (ta <= tgape + tw))
|
||||
{
|
||||
pos1 = 0;
|
||||
pos0 = tgaps;
|
||||
}
|
||||
else if (((tgape + tw) < ta) && (ta <= (tgape + tw + tlcd - tgaps)))
|
||||
{
|
||||
pos0 = tgaps;
|
||||
pos1 = tlcd + tgape + tw - ta;
|
||||
}
|
||||
else if (ta > (tgape + tw + tlcd - tgaps))
|
||||
{
|
||||
EC_ASSERT(0,0,0,0);
|
||||
}
|
||||
|
||||
lspiTeParam0.lspiTeEn = 1;
|
||||
lspiTeParam0.lspiTeEdgeSel = teEdge;
|
||||
lspiTeParam0.lspiTePos0 = pos0*LCD_FREQ/1000000;
|
||||
lspiTeParam1.lspiTePos1 = pos1*LCD_FREQ/1000000;
|
||||
lcdDrv1->ctrl(LSPI_TE_CTRL, 0);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void lcdIoCtrl(lcdDrvFunc_t *lcd, lcdIoCtrl_t ioCtrl)
|
||||
{
|
||||
if (lcd == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lcdIoCtrlParam = ioCtrl;
|
||||
}
|
||||
|
||||
void lcdConfigReg(lcdDrvFunc_t *lcd, uint8_t cmd, uint8_t *data, uint8_t dataLen)
|
||||
{
|
||||
lspiCmdSend(cmd, data, dataLen);
|
||||
}
|
||||
|
@ -1,170 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2018 Copyrigths of EigenComm Ltd.
|
||||
* File name: ntc.c
|
||||
* Description:
|
||||
* History:
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <stdint.h>
|
||||
#include "ntc.h"
|
||||
|
||||
#define NCP15XH103F03RC
|
||||
|
||||
#if defined(NCP15XH103F03RC)
|
||||
static const int32_t gNTCLut[65] = {
|
||||
253347, // T:253.35 Rntc:0.0k ADC code:0 Input voltage:0uV
|
||||
187444, // T:187.44 Rntc:0.159k ADC code:64 Input voltage:18750uV
|
||||
149195, // T:149.2 Rntc:0.323k ADC code:128 Input voltage:37500uV
|
||||
128368, // T:128.37 Rntc:0.492k ADC code:192 Input voltage:56250uV
|
||||
115301, // T:115.3 Rntc:0.667k ADC code:256 Input voltage:75000uV
|
||||
105493, // T:105.49 Rntc:0.847k ADC code:320 Input voltage:93750uV
|
||||
97670, // T:97.67 Rntc:1.034k ADC code:384 Input voltage:112500uV
|
||||
91187, // T:91.19 Rntc:1.228k ADC code:448 Input voltage:131250uV
|
||||
85596, // T:85.6 Rntc:1.429k ADC code:512 Input voltage:150000uV
|
||||
80693, // T:80.69 Rntc:1.636k ADC code:576 Input voltage:168750uV
|
||||
76336, // T:76.34 Rntc:1.852k ADC code:640 Input voltage:187500uV
|
||||
72403, // T:72.4 Rntc:2.075k ADC code:704 Input voltage:206250uV
|
||||
68803, // T:68.8 Rntc:2.308k ADC code:768 Input voltage:225000uV
|
||||
65478, // T:65.48 Rntc:2.549k ADC code:832 Input voltage:243750uV
|
||||
62389, // T:62.39 Rntc:2.8k ADC code:896 Input voltage:262500uV
|
||||
59508, // T:59.51 Rntc:3.061k ADC code:960 Input voltage:281250uV
|
||||
56829, // T:56.83 Rntc:3.333k ADC code:1024 Input voltage:300000uV
|
||||
54289, // T:54.29 Rntc:3.617k ADC code:1088 Input voltage:318750uV
|
||||
51869, // T:51.87 Rntc:3.913k ADC code:1152 Input voltage:337500uV
|
||||
49556, // T:49.56 Rntc:4.222k ADC code:1216 Input voltage:356250uV
|
||||
47337, // T:47.34 Rntc:4.545k ADC code:1280 Input voltage:375000uV
|
||||
45200, // T:45.2 Rntc:4.884k ADC code:1344 Input voltage:393750uV
|
||||
43135, // T:43.14 Rntc:5.238k ADC code:1408 Input voltage:412500uV
|
||||
41134, // T:41.13 Rntc:5.61k ADC code:1472 Input voltage:431250uV
|
||||
39186, // T:39.19 Rntc:6.0k ADC code:1536 Input voltage:450000uV
|
||||
37287, // T:37.29 Rntc:6.41k ADC code:1600 Input voltage:468750uV
|
||||
35433, // T:35.43 Rntc:6.842k ADC code:1664 Input voltage:487500uV
|
||||
33620, // T:33.62 Rntc:7.297k ADC code:1728 Input voltage:506250uV
|
||||
31842, // T:31.84 Rntc:7.778k ADC code:1792 Input voltage:525000uV
|
||||
30095, // T:30.1 Rntc:8.286k ADC code:1856 Input voltage:543750uV
|
||||
28377, // T:28.38 Rntc:8.824k ADC code:1920 Input voltage:562500uV
|
||||
26680, // T:26.68 Rntc:9.394k ADC code:1984 Input voltage:581250uV
|
||||
25000, // T:25.0 Rntc:10.0k ADC code:2048 Input voltage:600000uV
|
||||
23332, // T:23.33 Rntc:10.645k ADC code:2112 Input voltage:618750uV
|
||||
21675, // T:21.68 Rntc:11.333k ADC code:2176 Input voltage:637500uV
|
||||
20024, // T:20.02 Rntc:12.069k ADC code:2240 Input voltage:656250uV
|
||||
18382, // T:18.38 Rntc:12.857k ADC code:2304 Input voltage:675000uV
|
||||
16741, // T:16.74 Rntc:13.704k ADC code:2368 Input voltage:693750uV
|
||||
15100, // T:15.1 Rntc:14.615k ADC code:2432 Input voltage:712500uV
|
||||
13455, // T:13.46 Rntc:15.6k ADC code:2496 Input voltage:731250uV
|
||||
11801, // T:11.8 Rntc:16.667k ADC code:2560 Input voltage:750000uV
|
||||
10137, // T:10.14 Rntc:17.826k ADC code:2624 Input voltage:768750uV
|
||||
8454, // T:8.45 Rntc:19.091k ADC code:2688 Input voltage:787500uV
|
||||
6750, // T:6.75 Rntc:20.476k ADC code:2752 Input voltage:806250uV
|
||||
5022, // T:5.02 Rntc:22.0k ADC code:2816 Input voltage:825000uV
|
||||
3265, // T:3.27 Rntc:23.684k ADC code:2880 Input voltage:843750uV
|
||||
1472, // T:1.47 Rntc:25.556k ADC code:2944 Input voltage:862500uV
|
||||
-361, // T:-0.36 Rntc:27.647k ADC code:3008 Input voltage:881250uV
|
||||
-2238, // T:-2.24 Rntc:30.0k ADC code:3072 Input voltage:900000uV
|
||||
-4171, // T:-4.17 Rntc:32.667k ADC code:3136 Input voltage:918750uV
|
||||
-6170, // T:-6.17 Rntc:35.714k ADC code:3200 Input voltage:937500uV
|
||||
-8248, // T:-8.25 Rntc:39.231k ADC code:3264 Input voltage:956250uV
|
||||
-10419, // T:-10.42 Rntc:43.333k ADC code:3328 Input voltage:975000uV
|
||||
-12711, // T:-12.71 Rntc:48.182k ADC code:3392 Input voltage:993750uV
|
||||
-15137, // T:-15.14 Rntc:54.0k ADC code:3456 Input voltage:1012500uV
|
||||
-17727, // T:-17.73 Rntc:61.111k ADC code:3520 Input voltage:1031250uV
|
||||
-20519, // T:-20.52 Rntc:70.0k ADC code:3584 Input voltage:1050000uV
|
||||
-23562, // T:-23.56 Rntc:81.429k ADC code:3648 Input voltage:1068750uV
|
||||
-26937, // T:-26.94 Rntc:96.667k ADC code:3712 Input voltage:1087500uV
|
||||
-30762, // T:-30.76 Rntc:118.0k ADC code:3776 Input voltage:1106250uV
|
||||
-35224, // T:-35.22 Rntc:150.0k ADC code:3840 Input voltage:1125000uV
|
||||
-40677, // T:-40.68 Rntc:203.333k ADC code:3904 Input voltage:1143750uV
|
||||
-47755, // T:-47.76 Rntc:310.0k ADC code:3968 Input voltage:1162500uV
|
||||
-57225, // T:-57.23 Rntc:630.0k ADC code:4032 Input voltage:1181250uV
|
||||
-69859, // T:-69.86 Rntc:10000.0k ADC code:4096 Input voltage:1200000uV
|
||||
};
|
||||
#elif defined(NCP15WF104F03RC)
|
||||
static const int32_t gNTCLut[65] = {
|
||||
175093, // T:175.09 Rntc:0.0k ADC code:0 Input voltage:0uV
|
||||
140197, // T:140.2 Rntc:1.587k ADC code:64 Input voltage:18750uV
|
||||
116573, // T:116.57 Rntc:3.226k ADC code:128 Input voltage:37500uV
|
||||
102838, // T:102.84 Rntc:4.918k ADC code:192 Input voltage:56250uV
|
||||
93457, // T:93.46 Rntc:6.667k ADC code:256 Input voltage:75000uV
|
||||
86333, // T:86.33 Rntc:8.475k ADC code:320 Input voltage:93750uV
|
||||
80598, // T:80.6 Rntc:10.345k ADC code:384 Input voltage:112500uV
|
||||
75787, // T:75.79 Rntc:12.281k ADC code:448 Input voltage:131250uV
|
||||
71646, // T:71.65 Rntc:14.286k ADC code:512 Input voltage:150000uV
|
||||
67994, // T:67.99 Rntc:16.364k ADC code:576 Input voltage:168750uV
|
||||
64720, // T:64.72 Rntc:18.519k ADC code:640 Input voltage:187500uV
|
||||
61757, // T:61.76 Rntc:20.755k ADC code:704 Input voltage:206250uV
|
||||
59039, // T:59.04 Rntc:23.077k ADC code:768 Input voltage:225000uV
|
||||
56524, // T:56.52 Rntc:25.49k ADC code:832 Input voltage:243750uV
|
||||
54178, // T:54.18 Rntc:28.0k ADC code:896 Input voltage:262500uV
|
||||
51977, // T:51.98 Rntc:30.612k ADC code:960 Input voltage:281250uV
|
||||
49898, // T:49.9 Rntc:33.333k ADC code:1024 Input voltage:300000uV
|
||||
47928, // T:47.93 Rntc:36.17k ADC code:1088 Input voltage:318750uV
|
||||
46050, // T:46.05 Rntc:39.13k ADC code:1152 Input voltage:337500uV
|
||||
44250, // T:44.25 Rntc:42.222k ADC code:1216 Input voltage:356250uV
|
||||
42521, // T:42.52 Rntc:45.455k ADC code:1280 Input voltage:375000uV
|
||||
40853, // T:40.85 Rntc:48.837k ADC code:1344 Input voltage:393750uV
|
||||
39240, // T:39.24 Rntc:52.381k ADC code:1408 Input voltage:412500uV
|
||||
37676, // T:37.68 Rntc:56.098k ADC code:1472 Input voltage:431250uV
|
||||
36155, // T:36.16 Rntc:60.0k ADC code:1536 Input voltage:450000uV
|
||||
34671, // T:34.67 Rntc:64.103k ADC code:1600 Input voltage:468750uV
|
||||
33220, // T:33.22 Rntc:68.421k ADC code:1664 Input voltage:487500uV
|
||||
31797, // T:31.8 Rntc:72.973k ADC code:1728 Input voltage:506250uV
|
||||
30400, // T:30.4 Rntc:77.778k ADC code:1792 Input voltage:525000uV
|
||||
29025, // T:29.03 Rntc:82.857k ADC code:1856 Input voltage:543750uV
|
||||
27669, // T:27.67 Rntc:88.235k ADC code:1920 Input voltage:562500uV
|
||||
26328, // T:26.33 Rntc:93.939k ADC code:1984 Input voltage:581250uV
|
||||
24999, // T:25.0 Rntc:100.0k ADC code:2048 Input voltage:600000uV
|
||||
23681, // T:23.68 Rntc:106.452k ADC code:2112 Input voltage:618750uV
|
||||
22370, // T:22.37 Rntc:113.333k ADC code:2176 Input voltage:637500uV
|
||||
21064, // T:21.06 Rntc:120.69k ADC code:2240 Input voltage:656250uV
|
||||
19760, // T:19.76 Rntc:128.571k ADC code:2304 Input voltage:675000uV
|
||||
18455, // T:18.46 Rntc:137.037k ADC code:2368 Input voltage:693750uV
|
||||
17148, // T:17.15 Rntc:146.154k ADC code:2432 Input voltage:712500uV
|
||||
15835, // T:15.84 Rntc:156.0k ADC code:2496 Input voltage:731250uV
|
||||
14513, // T:14.51 Rntc:166.667k ADC code:2560 Input voltage:750000uV
|
||||
13179, // T:13.18 Rntc:178.261k ADC code:2624 Input voltage:768750uV
|
||||
11830, // T:11.83 Rntc:190.909k ADC code:2688 Input voltage:787500uV
|
||||
10463, // T:10.46 Rntc:204.762k ADC code:2752 Input voltage:806250uV
|
||||
9074, // T:9.07 Rntc:220.0k ADC code:2816 Input voltage:825000uV
|
||||
7658, // T:7.66 Rntc:236.842k ADC code:2880 Input voltage:843750uV
|
||||
6211, // T:6.21 Rntc:255.556k ADC code:2944 Input voltage:862500uV
|
||||
4728, // T:4.73 Rntc:276.471k ADC code:3008 Input voltage:881250uV
|
||||
3202, // T:3.2 Rntc:300.0k ADC code:3072 Input voltage:900000uV
|
||||
1626, // T:1.63 Rntc:326.667k ADC code:3136 Input voltage:918750uV
|
||||
-6, // T:-0.01 Rntc:357.143k ADC code:3200 Input voltage:937500uV
|
||||
-1710, // T:-1.71 Rntc:392.308k ADC code:3264 Input voltage:956250uV
|
||||
-3495, // T:-3.5 Rntc:433.333k ADC code:3328 Input voltage:975000uV
|
||||
-5376, // T:-5.38 Rntc:481.818k ADC code:3392 Input voltage:993750uV
|
||||
-7371, // T:-7.37 Rntc:540.0k ADC code:3456 Input voltage:1012500uV
|
||||
-9506, // T:-9.51 Rntc:611.111k ADC code:3520 Input voltage:1031250uV
|
||||
-11819, // T:-11.82 Rntc:700.0k ADC code:3584 Input voltage:1050000uV
|
||||
-14354, // T:-14.35 Rntc:814.286k ADC code:3648 Input voltage:1068750uV
|
||||
-17179, // T:-17.18 Rntc:966.667k ADC code:3712 Input voltage:1087500uV
|
||||
-20397, // T:-20.4 Rntc:1180.0k ADC code:3776 Input voltage:1106250uV
|
||||
-24176, // T:-24.18 Rntc:1500.0k ADC code:3840 Input voltage:1125000uV
|
||||
-28836, // T:-28.84 Rntc:2033.333k ADC code:3904 Input voltage:1143750uV
|
||||
-35053, // T:-35.05 Rntc:3100.0k ADC code:3968 Input voltage:1162500uV
|
||||
-44840, // T:-44.84 Rntc:6300.0k ADC code:4032 Input voltage:1181250uV
|
||||
-63302, // T:-63.3 Rntc:100000.0k ADC code:4096 Input voltage:1200000uV
|
||||
};
|
||||
|
||||
#else
|
||||
#error "NTC type is not defined"
|
||||
#endif
|
||||
|
||||
|
||||
int32_t ntcGetTemperature(int32_t adcInputVoltage)
|
||||
{
|
||||
if(adcInputVoltage <= 1200000)
|
||||
{
|
||||
int32_t step = 1200000 >> 6;
|
||||
int32_t i = adcInputVoltage / step;
|
||||
return gNTCLut[i] + ((int32_t)((gNTCLut[i + 1] - gNTCLut[i]) * (adcInputVoltage - (i * step))) / step);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -256000;
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,158 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2023-, Copyrigths of EigenComm Ltd.
|
||||
* File name: tpComm.c
|
||||
* Description: ec7xx tpComm driver source file
|
||||
* History: Rev1.0 2023-11-13
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifdef FEATURE_DRIVER_TP_ENABLE
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "bsp.h"
|
||||
#include "bsp_custom.h"
|
||||
#include "osasys.h"
|
||||
#include "ostask.h"
|
||||
#include "slpman.h"
|
||||
#include "tpComm.h"
|
||||
#include "sctdef.h"
|
||||
#ifdef FEATURE_SUBSYS_SYSLOG_ENABLE
|
||||
#include "syslog.h"
|
||||
#endif
|
||||
#ifdef FEATURE_SUBSYS_OPENHAL_ENABLE
|
||||
#include "api_comm.h"
|
||||
AP_PLAT_COMMON_BSS uint32_t tp_irq_padId = 0;
|
||||
AP_PLAT_COMMON_BSS uint32_t tp_irq_PinId = 0;
|
||||
AP_PLAT_COMMON_BSS uint32_t tp_i2c_usrId = 0;
|
||||
#endif
|
||||
extern ARM_DRIVER_I2C Driver_I2C0;
|
||||
AP_PLAT_COMMON_DATA ARM_DRIVER_I2C *i2cMasterDrv = &CREATE_SYMBOL(Driver_I2C, 0);
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
#ifndef FEATURE_SUBSYS_OPENHAL_ENABLE
|
||||
AP_PLAT_COMMON_BSS static tpIsrFunc tpIsrCb = NULL;
|
||||
void tpGpioIsr(uint32_t index)
|
||||
{
|
||||
uint16_t portIrqMask = GPIO_saveAndSetIrqMask(TP_IRQ_GPIO_INSTANCE);
|
||||
if (GPIO_getInterruptFlags(TP_IRQ_GPIO_INSTANCE) & (1 << TP_IRQ_GPIO_PIN)){
|
||||
GPIO_clearInterruptFlags(TP_IRQ_GPIO_INSTANCE, 1 << TP_IRQ_GPIO_PIN);
|
||||
if(tpIsrCb != NULL){
|
||||
tpIsrCb(index);
|
||||
}
|
||||
}
|
||||
GPIO_restoreIrqMask(TP_IRQ_GPIO_INSTANCE, portIrqMask);
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
void tpIsrInit(void *cb)
|
||||
{
|
||||
PadConfig_t padConfig = {0};
|
||||
PAD_getDefaultConfig(&padConfig);
|
||||
padConfig.pullUpEnable = PAD_PULL_UP_DISABLE;
|
||||
padConfig.pullDownEnable = PAD_PULL_DOWN_DISABLE;
|
||||
padConfig.mux = TP_IRQ_PAD_ALT_FUNC;
|
||||
#ifdef FEATURE_SUBSYS_OPENHAL_ENABLE
|
||||
tp_irq_padId = api_pad_create(TP_IRQ_PAD_INDEX, &padConfig);
|
||||
api_pad_open(tp_irq_padId,NULL,0);
|
||||
#else
|
||||
PAD_setPinConfig(TP_IRQ_PAD_INDEX, &padConfig);
|
||||
#endif
|
||||
GpioPinConfig_t pinConfig = {0};
|
||||
pinConfig.pinDirection = GPIO_DIRECTION_INPUT;
|
||||
pinConfig.misc.interruptConfig = GPIO_INTERRUPT_RISING_EDGE;
|
||||
#ifdef FEATURE_SUBSYS_OPENHAL_ENABLE
|
||||
tp_irq_PinId = api_gpio_create((TP_IRQ_GPIO_INSTANCE*16+TP_IRQ_GPIO_PIN), &pinConfig);
|
||||
api_gpio_open(tp_irq_PinId,NULL,0);
|
||||
api_gpio_ioctl(tp_irq_PinId,OPEN_GPIO_IOCTL_ISR_CB,cb);
|
||||
#else
|
||||
tpIsrCb = cb;
|
||||
GPIO_pinConfig(TP_IRQ_GPIO_INSTANCE, TP_IRQ_GPIO_PIN, &pinConfig);
|
||||
XIC_SetVector(PXIC1_GPIO_IRQn, tpGpioIsr);
|
||||
XIC_EnableIRQ(PXIC1_GPIO_IRQn);
|
||||
#endif
|
||||
// SYSLOG_PRINT(SL_INFO, "tpirq[%x],[%x]\r\n",tp_irq_PinId,tp_i2c_usrId);
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
void tpRstInit(void)
|
||||
{
|
||||
#ifdef TP_RST_GPIO_PIN
|
||||
PadConfig_t padConfig = {0};
|
||||
PAD_getDefaultConfig(&padConfig);
|
||||
padConfig.pullUpEnable = PAD_PULL_UP_DISABLE;
|
||||
padConfig.pullDownEnable = PAD_PULL_DOWN_DISABLE;
|
||||
padConfig.mux = TP_RST_PAD_ALT_FUNC;
|
||||
PAD_setPinConfig(TP_RST_PAD_INDEX, &padConfig);
|
||||
|
||||
GpioPinConfig_t gpioCfg = {0};
|
||||
gpioCfg.pinDirection = GPIO_DIRECTION_OUTPUT;
|
||||
gpioCfg.misc.initOutput = 1;
|
||||
GPIO_pinConfig(TP_RST_GPIO_INSTANCE, TP_RST_GPIO_PIN, &gpioCfg);
|
||||
#endif
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
void tpBusInit(void)
|
||||
{
|
||||
#ifdef FEATURE_SUBSYS_OPENHAL_ENABLE
|
||||
tp_i2c_usrId = api_i2c_create(0,NULL);
|
||||
api_i2c_open(tp_i2c_usrId,NULL,0);
|
||||
// SYSLOG_PRINT(SL_INFO, "0x%X\r\n",tp_i2c_usrId);
|
||||
#else
|
||||
i2cMasterDrv->Uninitialize();
|
||||
i2cMasterDrv->Initialize(NULL);
|
||||
i2cMasterDrv->PowerControl(ARM_POWER_FULL);
|
||||
i2cMasterDrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
|
||||
i2cMasterDrv->Control(ARM_I2C_BUS_CLEAR, 0);
|
||||
#endif
|
||||
// TP_TRACE(tpBusInit, 1, "I2C_IO_MODE:%d",I2C_IO_MODE);
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
void tpBusDeInit(void)
|
||||
{
|
||||
i2cMasterDrv->Uninitialize();
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
uint8_t tp_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint16_t len, uint8_t *data)
|
||||
{
|
||||
i2cMasterDrv->MasterTransmit(dev_id, ®_addr, 1, true);
|
||||
i2cMasterDrv->MasterReceive(dev_id, data, len, false);
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
uint8_t tp_i2c_send(uint8_t dev_id, uint8_t reg_addr, uint16_t len, uint8_t *data)
|
||||
{
|
||||
uint8_t * tempBuffer = callocEc(len+1,sizeof(char));
|
||||
memcpy(tempBuffer+1,data,len);
|
||||
tempBuffer[0] = reg_addr;
|
||||
i2cMasterDrv->MasterTransmit(dev_id, tempBuffer, len+1, false);
|
||||
freeEc(tempBuffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,98 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2024-, Copyrigths of EigenComm Ltd.
|
||||
* File name: ft6336.c
|
||||
* Description: ec7xx ft6336 driver source file
|
||||
* History: Rev1.1 2024-03-08
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifdef FEATURE_TP_FT6336_ENABLE
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "tpDrv.h"
|
||||
#include "tpComm.h"
|
||||
#include "ft6336.h"
|
||||
#ifdef FEATURE_SUBSYS_SYSLOG_ENABLE
|
||||
#include "syslog.h"
|
||||
#endif
|
||||
#include "sctdef.h"
|
||||
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
int tp_ft6336_send(uint8_t regAddr, uint8_t* buf,uint8_t len)
|
||||
{
|
||||
return tp_i2c_send(FT6336_ADDR, regAddr, len, buf);
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
int tp_ft6336_read(uint8_t regAddr, uint8_t* buf,uint8_t len)
|
||||
{
|
||||
return tp_i2c_read(FT6336_ADDR, regAddr, len, buf);
|
||||
}
|
||||
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
uint8_t tp_ft6336_scan(int16_t *pos)
|
||||
{
|
||||
uint8_t temp[8]={0};
|
||||
uint8_t fingerNum = 0;
|
||||
tp_ft6336_read(FT6336_GET_FINGERNUM,&fingerNum,1);
|
||||
if(fingerNum)
|
||||
{
|
||||
tp_ft6336_read(FT6336_GET_LOC0,temp,4);
|
||||
pos[0]=((uint16_t)(temp[0]&0x0F)<<8)+temp[1];
|
||||
pos[1]=(((uint16_t)(temp[2]&0x0F)<<8)+temp[3]);
|
||||
// printf("x1:%d,y1:%d\r\n",pos[0], pos[1]);
|
||||
if(fingerNum>1)
|
||||
{
|
||||
tp_ft6336_read(FT6336_GET_LOC1,&temp[4],4);
|
||||
pos[2]=((uint16_t)(temp[4]&0x0F)<<8)+temp[5];
|
||||
pos[3]=(((uint16_t)(temp[6]&0x0F)<<8)+temp[7]);
|
||||
}
|
||||
}
|
||||
return fingerNum;
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
|
||||
static int tp_ft6336_init(void* cb)
|
||||
{
|
||||
SYSLOG_INFO("ID\r\n");
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
AP_PLAT_COMMON_DATA tpDrvFunc_t ft6336Drv =
|
||||
{
|
||||
.init = tp_ft6336_init,
|
||||
.send = tp_ft6336_send,
|
||||
.read = tp_ft6336_read,
|
||||
.scan = tp_ft6336_scan,
|
||||
};
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
AP_PLAT_COMMON_DATA tpDrvPra_t ft6336Pra =
|
||||
{
|
||||
.id = 0x6336,
|
||||
.width = 240,
|
||||
.height = 320,
|
||||
};
|
||||
#endif
|
@ -1,232 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2023-, Copyrigths of EigenComm Ltd.
|
||||
* File name: tpDrv.c
|
||||
* Description: ec7xx tpDrv driver source file
|
||||
* History: Rev1.0 2023-09-18
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifdef FEATURE_DRIVER_TP_ENABLE
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "bsp.h"
|
||||
#include "bsp_custom.h"
|
||||
#include "osasys.h"
|
||||
#include "ostask.h"
|
||||
#include "slpman.h"
|
||||
#include "tpDrv.h"
|
||||
|
||||
#ifdef FEATURE_SUBSYS_SYSLOG_ENABLE
|
||||
#include "syslog.h"
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_TP_FT6336_ENABLE
|
||||
#include "ft6336.h"
|
||||
extern tpDrvFunc_t ft6336Drv;
|
||||
extern tpDrvPra_t ft6336Pra;
|
||||
#endif
|
||||
#ifdef FEATURE_TP_CST816_ENABLE
|
||||
#include "cst816.h"
|
||||
extern tpDrvFunc_t cst816Drv;
|
||||
extern tpDrvPra_t cst816Pra;
|
||||
#endif
|
||||
#ifdef FEATURE_TP_GT911_ENABLE
|
||||
#include "gt911.h"
|
||||
extern tpDrvFunc_t gt911Drv;
|
||||
extern tpDrvPra_t gt911Pra;
|
||||
#endif
|
||||
#include "sctdef.h"
|
||||
|
||||
AP_PLAT_COMMON_BSS static tpDev_t tpDevList[SUPPORT_TP_NUM] ;
|
||||
AP_PLAT_COMMON_DATA static tpObj_t tpObjList[SUPPORT_TP_NUM] =
|
||||
{
|
||||
{"ft6336", 0x6336},
|
||||
{"cst816", 0x816},
|
||||
{"gt911", 0x911},
|
||||
};
|
||||
|
||||
AP_PLAT_COMMON_BSS int16_t xy_pos[4]={0};
|
||||
AP_PLAT_COMMON_BSS int16_t last_xy_pos[4]={0};
|
||||
AP_PLAT_COMMON_BSS static bool is_pressed = false;
|
||||
#ifndef FEATURE_SUBSYS_INPUT_ENABLE
|
||||
AP_PLAT_COMMON_BSS static osSemaphoreId_t tpSemaphore = NULL;
|
||||
#endif
|
||||
|
||||
#define TP_TRACE(subId, argLen, format, ...) \
|
||||
ECOMM_TRACE(UNILOG_TP, subId, P_VALUE, argLen, format, ##__VA_ARGS__)
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
void tpIsrCallback(uint32_t data)
|
||||
{
|
||||
#ifdef FEATURE_SUBSYS_INPUT_ENABLE
|
||||
inputNotify();
|
||||
#else
|
||||
if (tpSemaphore != NULL)
|
||||
{
|
||||
osSemaphoreRelease(tpSemaphore);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
bool tpPressed(void)
|
||||
{
|
||||
// SYSLOG_INFO("get\r\n");
|
||||
return is_pressed;
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
uint8_t tpScan(tpDev_t* tpDev)
|
||||
{
|
||||
uint8_t fingers = 0;
|
||||
if (tpDev!=NULL) fingers = tpDev->drv->scan(xy_pos);
|
||||
if(fingers)
|
||||
{
|
||||
if(xy_pos[0]!=last_xy_pos[0] || xy_pos[1]!=last_xy_pos[1])
|
||||
{
|
||||
is_pressed = true;
|
||||
TP_TRACE(tpScan, 5, "%d,%d->%d,%d->%d",fingers,last_xy_pos[0],xy_pos[0],last_xy_pos[1],xy_pos[1]);
|
||||
SYSLOG_INFO("[%d]%d->%d,%d->%d\r\n",fingers,last_xy_pos[0],xy_pos[0],last_xy_pos[1],xy_pos[1]);
|
||||
memcpy(last_xy_pos,xy_pos,sizeof(xy_pos));
|
||||
}
|
||||
}
|
||||
return fingers;
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
void tpData(int16_t* x,int16_t* y)
|
||||
{
|
||||
if(is_pressed)
|
||||
{
|
||||
*x=xy_pos[0];
|
||||
*y=xy_pos[1];
|
||||
is_pressed = false;
|
||||
// SYSLOG_INFO("clean\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
void tpLoop(tpDev_t* tpDev,uint32_t timeout)
|
||||
{
|
||||
#ifndef FEATURE_SUBSYS_INPUT_ENABLE
|
||||
osSemaphoreAcquire(tpSemaphore, timeout);
|
||||
#else
|
||||
osDelay(timeout);
|
||||
#endif
|
||||
tpScan(tpDev);
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
static uint8_t tpFind(tpDev_t *tpList)
|
||||
{
|
||||
uint8_t cnt = 0;
|
||||
if (tpList == NULL) return SUPPORT_TP_NUM;
|
||||
for (uint8_t i = 0; i < SUPPORT_TP_NUM; i++)
|
||||
{
|
||||
tpDev_t *pdev = NULL;
|
||||
memset(tpList + cnt, 0, sizeof(tpDev_t));
|
||||
#ifdef FEATURE_TP_FT6336_ENABLE
|
||||
if (tpObjList[i].id == ft6336Pra.id)
|
||||
{
|
||||
pdev = tpList + cnt;
|
||||
cnt++;
|
||||
pdev->pra = &ft6336Pra;
|
||||
pdev->drv = &ft6336Drv;
|
||||
pdev->obj = &tpObjList[i];
|
||||
}
|
||||
#endif
|
||||
#ifdef FEATURE_TP_CST816_ENABLE
|
||||
if (tpObjList[i].id == cst816Pra.id)
|
||||
{
|
||||
pdev = tpList + cnt;
|
||||
cnt++;
|
||||
pdev->pra = &cst816Pra;
|
||||
pdev->drv = &cst816Drv;
|
||||
pdev->obj = &tpObjList[i];
|
||||
}
|
||||
#endif
|
||||
#ifdef FEATURE_TP_GT911_ENABLE
|
||||
if (tpObjList[i].id == gt911Pra.id)
|
||||
{
|
||||
pdev = tpList + cnt;
|
||||
cnt++;
|
||||
pdev->pra = >911Pra;
|
||||
pdev->drv = >911Drv;
|
||||
pdev->obj = &tpObjList[i];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// Return the count of populated LCD devices
|
||||
return cnt;
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
int tpInit(void* tp_cb)
|
||||
{
|
||||
uint8_t num = tpFind(tpDevList);
|
||||
if (num > INSTALL_TP_NUM) num = INSTALL_TP_NUM;
|
||||
if(num){
|
||||
#ifndef FEATURE_SUBSYS_INPUT_ENABLE
|
||||
if(tpSemaphore != NULL){
|
||||
osSemaphoreDelete(tpSemaphore);
|
||||
}
|
||||
tpSemaphore = osSemaphoreNew(1, 1, NULL);
|
||||
#endif
|
||||
tpBusInit();
|
||||
tpRstInit();
|
||||
}
|
||||
for (uint8_t i = 0; i < num; i++)
|
||||
{
|
||||
if (tpDevList[i].obj->id)
|
||||
{
|
||||
tpDev_t *pdev = &tpDevList[i];
|
||||
pdev->drv->init(tp_cb);
|
||||
}
|
||||
}
|
||||
if(num) tpIsrInit(tpIsrCallback);
|
||||
return num;
|
||||
}
|
||||
/**
|
||||
\fn
|
||||
\brief
|
||||
\return
|
||||
*/
|
||||
tpDev_t* tpOpen(char* name)
|
||||
{
|
||||
if(name == NULL) return NULL;
|
||||
for (uint8_t i = 0; i < INSTALL_TP_NUM; i++)
|
||||
{
|
||||
tpDev_t *pdev = &tpDevList[i];
|
||||
// SYSLOG_INFO("0x%X,%s,%s\r\n",pdev->obj->id,pdev->obj->name,name);
|
||||
if (pdev->obj->id != 0 && strcasecmp(name, pdev->obj->name) == 0)
|
||||
{
|
||||
SYSLOG_INFO("%d:0x%X,%s\r\n",i,pdev->obj->id,pdev->obj->name);
|
||||
return pdev;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
@ -1,50 +0,0 @@
|
||||
CFLAGS_INC += -I$(TOP)/PLAT/driver/board/$(TARGET)/inc \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/eeprom \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/camera \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/camera/cameraDev \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/codec \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/codec/codecDev \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/lcd/lcdDev \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/lcd \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/tp/tpDev \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/tp \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/ntc \
|
||||
-I$(TOP)/PLAT/driver/board/$(TARGET)/inc/exstorage
|
||||
|
||||
libdriver-$(DRIVER_PLATCFG_ENABLE) += PLAT/driver/board/$(TARGET)/src/plat_config.o
|
||||
libdriver-$(DRIVER_ECMAIN_ENABLE) += PLAT/driver/board/$(TARGET)/src/bsp.o
|
||||
libdriverprivate-$(DRIVER_ECMAIN_ENABLE) += PLAT/driver/board/$(TARGET)/src/ec_main.o
|
||||
libdriver-$(DRIVER_EEPROM_ENABLE) += PLAT/driver/board/$(TARGET)/src/eeprom/eepRom.o
|
||||
libdriver-$(DRIVER_CAMERA_ENABLE) += PLAT/driver/board/$(TARGET)/src/camera/cameraDrv.o \
|
||||
PLAT/driver/board/$(TARGET)/src/camera/cameraDev/gc032A.o \
|
||||
PLAT/driver/board/$(TARGET)/src/camera/cameraDev/gc6153.o
|
||||
|
||||
ifeq ($(DRIVER_CODEC_ENABLE), y)
|
||||
libdriver-$(DRIVER_CODEC8311_ENABLE) += PLAT/driver/board/$(TARGET)/src/codec/codecDev/es8311.o
|
||||
libdriver-$(DRIVER_CODEC8374_ENABLE) += PLAT/driver/board/$(TARGET)/src/codec/codecDev/es8374.o
|
||||
libdriver-$(DRIVER_CODEC8211_ENABLE) += PLAT/driver/board/$(TARGET)/src/codec/codecDev/tm8211.o
|
||||
libdriver-$(DRIVER_CODEC7111_ENABLE) += PLAT/driver/board/$(TARGET)/src/codec/codecDev/es7111.o
|
||||
libdriver-$(DRIVER_CODEC7149_ENABLE) += PLAT/driver/board/$(TARGET)/src/codec/codecDev/es7149.o
|
||||
libdriver-y +=PLAT/driver/board/$(TARGET)/src/codec/codecDrv.o
|
||||
endif
|
||||
|
||||
libdriver-$(DRIVER_LCD_ENABLE) += PLAT/driver/board/$(TARGET)/src/lcd/lcdComm.o \
|
||||
PLAT/driver/board/$(TARGET)/src/lcd/disFormat.o \
|
||||
PLAT/driver/board/$(TARGET)/src/lcd/lcdDrv.o
|
||||
|
||||
ifeq ($(DRIVER_LCD_ENABLE), y)
|
||||
libdriver-$(DRIVER_LCD_ST7789_ENABLE) += PLAT/driver/board/$(TARGET)/src/lcd/lcdDev/lcdDev_7789.o
|
||||
libdriver-$(DRIVER_LCD_ST77903_ENABLE) += PLAT/driver/board/$(TARGET)/src/lcd/lcdDev/lcdDev_77903.o
|
||||
libdriver-$(DRIVER_LCD_AXS15231_ENABLE) += PLAT/driver/board/$(TARGET)/src/lcd/lcdDev/lcdDev_15231.o
|
||||
libdriver-$(DRIVER_LCD_CO5300_ENABLE) += PLAT/driver/board/$(TARGET)/src/lcd/lcdDev/lcdDev_5300.o
|
||||
endif
|
||||
|
||||
libdriver-$(DRIVER_TP_ENABLE) += PLAT/driver/board/$(TARGET)/src/tp/tpDrv.o \
|
||||
PLAT/driver/board/$(TARGET)/src/tp/tpComm.o
|
||||
|
||||
libdriver-$(DRIVER_EXSTORAGE_ENABLE) += PLAT/driver/board/$(TARGET)/src/exstorage/ex_flash.o \
|
||||
PLAT/driver/board/$(TARGET)/src/exstorage/ex_storage.o
|
||||
|
||||
ifeq ($(DRIVER_TP_ENABLE), y)
|
||||
libdriver-$(DRIVER_TP_FT6336_ENABLE) += PLAT/driver/board/$(TARGET)/src/tp/tpDev/ft6336.o
|
||||
endif
|
@ -1,104 +0,0 @@
|
||||
#ifndef BSP_H
|
||||
#define BSP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "version.h"
|
||||
#include "Driver_Common.h"
|
||||
#include "Driver_I2C.h"
|
||||
#include "Driver_SPI.h"
|
||||
#include "Driver_USART.h"
|
||||
#include "RTE_Device.h"
|
||||
#include "pad.h"
|
||||
#include "gpio.h"
|
||||
#include "ic.h"
|
||||
#include "dma.h"
|
||||
#include "clock.h"
|
||||
|
||||
#define STRING_EOL "\r\n"
|
||||
|
||||
#if (defined TYPE_EC718S)
|
||||
#define CHIP_TYPE "EC718S"
|
||||
#elif (defined TYPE_EC718H)
|
||||
#define CHIP_TYPE "EC718H"
|
||||
#elif (defined TYPE_EC718P)
|
||||
#define CHIP_TYPE "EC718P"
|
||||
#elif (defined TYPE_EC718U)
|
||||
#define CHIP_TYPE "EC718U"
|
||||
#elif (defined TYPE_EC718PM)
|
||||
#define CHIP_TYPE "EC718PM"
|
||||
#elif (defined TYPE_EC718UM)
|
||||
#define CHIP_TYPE "EC718UM"
|
||||
#elif (defined TYPE_EC718SM)
|
||||
#define CHIP_TYPE "EC718SM"
|
||||
#elif (defined TYPE_EC718HM)
|
||||
#define CHIP_TYPE "EC718HM"
|
||||
#elif (defined TYPE_EC716S)
|
||||
#define CHIP_TYPE "EC716S"
|
||||
#elif (defined TYPE_EC716E)
|
||||
#define CHIP_TYPE "EC716E"
|
||||
#endif
|
||||
|
||||
#define BOARD_NAME CHIP_TYPE"_EVK"
|
||||
|
||||
|
||||
#define SDK_VERSION CHIP_TYPE"_SW_V"SDK_MAJOR_VERSION"."SDK_MINOR_VERSION"."SDK_PATCH_VERSION
|
||||
#define EVB_VERSION CHIP_TYPE"_HW_V"EVB_MAJOR_VERSION"."EVB_MINOR_VERSION
|
||||
#define VERSION_INFO "-- SDK Version: "SDK_VERSION" -- "STRING_EOL"-- EVB Version: "EVB_VERSION" -- "STRING_EOL
|
||||
|
||||
#define BSP_HEADER STRING_EOL"-- Board: "BOARD_NAME " -- "STRING_EOL \
|
||||
VERSION_INFO \
|
||||
"-- Compiled: "__DATE__" "__TIME__" -- "STRING_EOL
|
||||
|
||||
#define ATI_VERSION_INFO STRING_EOL"-- Board: "BOARD_NAME " -- "STRING_EOL \
|
||||
"-- SDK Version: "SDK_VERSION" -- "STRING_EOL
|
||||
|
||||
#define SOFTVERSION "V"SDK_MAJOR_VERSION"."SDK_MINOR_VERSION"."SDK_PATCH_VERSION
|
||||
|
||||
|
||||
#define CREATE_SYMBOL(name, port) name##port
|
||||
|
||||
/** @brief UART port index
|
||||
* | UART port | Hardware Flow Control |
|
||||
* |-----------|-----------------------|
|
||||
* | UART0 | Y |
|
||||
* | UART1 | Y |
|
||||
* | UART2 | N |
|
||||
*/
|
||||
typedef enum usart_port
|
||||
{
|
||||
PORT_USART_0, /**< USART port 0. */
|
||||
PORT_USART_1, /**< USART port 1. */
|
||||
PORT_USART_2, /**< USART port 2. */
|
||||
PORT_USART_3, /**< USART port 3. */
|
||||
PORT_USART_MAX, /**< The total number of USART ports (invalid UART port number). */
|
||||
PORT_USART_INVALID /**< USART invalid. */
|
||||
} usart_port_t;
|
||||
|
||||
extern ARM_DRIVER_USART *UsartPrintHandle;
|
||||
extern ARM_DRIVER_USART *UsartUnilogHandle;
|
||||
extern ARM_DRIVER_USART *UsartAtCmdHandle;
|
||||
|
||||
/** @brief IRQ Callback functions
|
||||
*/
|
||||
typedef void (*IRQ_Callback_t)();
|
||||
|
||||
|
||||
uint8_t* getBuildInfo(void);
|
||||
uint8_t* getATIVersionInfo(void);
|
||||
uint8_t* getVersionInfo(void);
|
||||
uint32_t getUnilogUartPort(void);
|
||||
void getUnilogRamLogBuff(uint32_t *addr, uint32_t *len);
|
||||
void FlushUnilogOutput(void);
|
||||
void SetUnilogUart(usart_port_t port, uint32_t baudrate, bool startRecv);
|
||||
void BSP_CommonInit(void);
|
||||
void setOSState(uint8_t state);
|
||||
uint8_t * getDebugDVersion(void);
|
||||
void delay_us(uint32_t us);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BSP_H */
|
@ -1,9 +0,0 @@
|
||||
#ifndef GC032A_H
|
||||
#define GC032A_H
|
||||
|
||||
#define GC032A_I2C_ADDR 0x21
|
||||
|
||||
uint16_t gc032aGetRegCnt(char* regName);
|
||||
|
||||
#endif
|
||||
|
@ -1,9 +0,0 @@
|
||||
#ifndef GC6153_H
|
||||
#define GC6153_H
|
||||
|
||||
#define GC6153_I2C_ADDR 0x40
|
||||
|
||||
uint16_t gc6153GetRegCnt(char* regName);
|
||||
|
||||
#endif
|
||||
|
@ -1,173 +0,0 @@
|
||||
#ifndef __CAMERA_DRV_H__
|
||||
#define __CAMERA_DRV_H__
|
||||
|
||||
#include "cspi.h"
|
||||
#include "gc032A.h"
|
||||
#include "gc6153.h"
|
||||
|
||||
/**
|
||||
\addtogroup cam_interface_gr
|
||||
\{
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t regAddr; ///< Sensor I2C register address
|
||||
uint8_t regVal; ///< Sensor I2C register value
|
||||
}camI2cCfg_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CAM_LSB_MODE = 0, ///< Little endian
|
||||
CAM_MSB_MODE = 1, ///< Big endian
|
||||
}endianMode_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
WIRE_1 = 0, ///< 1 wire
|
||||
WIRE_2 = 1, ///< 2 wire
|
||||
}wireNum_e;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SEQ_0 = 0, ///< rxd[0] 6 4 2 0
|
||||
///< rxd[1] 7 5 3 1
|
||||
SEQ_1 = 1, ///< rxd[1] 6 4 2 0
|
||||
///< rxd[0] 7 5 3 1
|
||||
}rxSeq_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CSPI_0 = 0,
|
||||
CSPI_1 = 1,
|
||||
}cspiInstance_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CSPI_START = 1, ///< cspi enable
|
||||
CSPI_STOP = 0, ///< Cspi disable
|
||||
}cspiStartStop_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CSPI_INT_ENABLE = 1, ///< cspi interrupt enable
|
||||
CSPI_INT_DISABLE = 0, ///< Cspi interrupt disable
|
||||
}cspiIntEnable_e;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
endianMode_e endianMode; ///< Endian mode
|
||||
wireNum_e wireNum; ///< Wire numbers
|
||||
rxSeq_e rxSeq; ///< Bit sequence in 2 wire mode
|
||||
uint8_t cpol;
|
||||
uint8_t cpha;
|
||||
uint8_t ddrMode;
|
||||
uint8_t wordIdSeq;
|
||||
uint8_t yOnly;
|
||||
uint8_t rowScaleRatio;
|
||||
uint8_t colScaleRatio;
|
||||
uint8_t scaleBytes;
|
||||
uint8_t dummyAllowed;
|
||||
}camParamCfg_t;
|
||||
|
||||
typedef void (*camCbEvent_fn) (uint32_t event); ///< Camera callback event.
|
||||
typedef void (*camIrq_fn)(void); ///< Camera irq
|
||||
typedef void (*camErrCb)(uint32_t stats);
|
||||
|
||||
|
||||
/**
|
||||
\brief Init camera, include pinMux, and enable clock.
|
||||
\param[in] dataAddr Mem addr to store picture.
|
||||
\param[in] uspCb usp cb.
|
||||
\param[in] dmaCb dma cb.
|
||||
\return
|
||||
*/
|
||||
void camInit(void* dataAddr, cspiCbEvent_fn uspCb, void* dmaCb);
|
||||
|
||||
/**
|
||||
\brief Receive the picture has been taken.
|
||||
\param[out] dataIn The buffer which is used to store the picture.
|
||||
\return
|
||||
*/
|
||||
void camRecv(uint8_t * dataIn);
|
||||
|
||||
/**
|
||||
\brief Init sensor's registers.
|
||||
\return
|
||||
*/
|
||||
void camRegCfg(void);
|
||||
|
||||
/**
|
||||
\brief Write some parameters into the sensor.
|
||||
\param[in] regInfo Sensor I2C addr and value.
|
||||
\return
|
||||
*/
|
||||
void camWriteReg(camI2cCfg_t* regInfo);
|
||||
|
||||
/**
|
||||
\brief Read from the sensor's I2C address.
|
||||
\param[in] regAddr Sensor's I2C register address.
|
||||
\return
|
||||
*/
|
||||
uint8_t camReadReg(uint8_t regAddr);
|
||||
|
||||
/**
|
||||
\brief Start or stop Camera controller.
|
||||
\param[in] startStop If true, start camera controller. If false, stop camera controller.
|
||||
\return
|
||||
*/
|
||||
void camStartStop(cspiStartStop_e startStop);
|
||||
|
||||
/**
|
||||
\brief Register irq for cspi.
|
||||
\param[in] instance cspi0 or cspi1.
|
||||
\param[in] irqCb irq cb.
|
||||
\return
|
||||
*/
|
||||
void camRegisterIRQ(cspiInstance_e instance, camIrq_fn irqCb);
|
||||
|
||||
/**
|
||||
\brief Get cspi status.
|
||||
\param[in] instance cspi0 or cspi1.
|
||||
\return
|
||||
*/
|
||||
uint32_t camGetCspiStats(cspiInstance_e instance);
|
||||
|
||||
/**
|
||||
\brief Clear cspi interrupt status.
|
||||
\param[in] instance cspi0 or cspi1.
|
||||
\param[in] mask which bit needs to clear.
|
||||
\return
|
||||
*/
|
||||
void camClearIntStats(cspiInstance_e instance, uint32_t mask);
|
||||
|
||||
/**
|
||||
\brief Set memory addr which is used to store picture of camera.
|
||||
\param[in] dataAddr data addr.
|
||||
\return
|
||||
*/
|
||||
void camSetMemAddr(uint32_t dataAddr);
|
||||
|
||||
/**
|
||||
\brief Enable or disable interrupt of cspi.
|
||||
\param[in] intEnable interrupt enable or not.
|
||||
\return
|
||||
*/
|
||||
void cspiStartIntEnable(cspiIntEnable_e intEnable);
|
||||
void cspiEndIntEnable(cspiIntEnable_e endIntEnable);
|
||||
uint32_t camGetCspiInt(cspiInstance_e instance);
|
||||
void cspi2LspiEnable(uint8_t enable);
|
||||
void camRegisterErrStatsCb(camErrCb errCb);
|
||||
void camCheckErrStats();
|
||||
#if (ENABLE_CAMERA_LDO == 1)
|
||||
void camPowerOn(uint8_t ioInitVal);
|
||||
#endif
|
||||
void camGpioPulseCfg(uint8_t padAddr, uint8_t pinInstance, uint8_t pinNum);
|
||||
void camGpioPulse(uint8_t pinInstance, uint8_t pinNum, uint32_t pulseDurationUs, uint8_t initialState, bool needLoop);
|
||||
void camRegisterSlp1Cb(cspiSlp1Cb_fn cb);
|
||||
|
||||
/** \} */
|
||||
|
||||
#endif
|
@ -1,191 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: es7111.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: Rev1.0 2020-02-24
|
||||
*
|
||||
* Notes: es7111 interface
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _CODEC_ES7111_H
|
||||
#define _CODEC_ES7111_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "codecDrv.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern HalCodecFuncList_t es7111DefaultHandle;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\brief Enables or disables PA
|
||||
\param[in] enable true/false
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es7111EnablePA(bool enable);
|
||||
|
||||
/**
|
||||
\brief Initialize ES7111 codec chip
|
||||
\param[in] codec_cfg configuration of ES7111
|
||||
\return -CODEC_EOK -CODEC_INIT_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7111Init(HalCodecCfg_t *codecCfg);
|
||||
|
||||
/**
|
||||
\brief Deinitialize ES7111 codec chip
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es7111DeInit(void);
|
||||
|
||||
/**
|
||||
\brief start/stop ES7111 codec chip
|
||||
\param[in] mode codec mode
|
||||
\param[in] ctrlState start or stop decode or encode progress
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7111StartStop(HalCodecMode_e mode, HalCodecCtrlState_e ctrlState);
|
||||
|
||||
/**
|
||||
\brief Configure ES7111 codec mode and I2S interface
|
||||
\param[in] mode codec mode
|
||||
\param[in] iface I2S config
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7111Config(HalCodecMode_e mode, HalCodecIface_t *iface);
|
||||
|
||||
/**
|
||||
\brief Configure ES7111 DAC mute or not. Basically you can use this function to mute the output or unmute
|
||||
\param[in] enable enable(1) or disable(0)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7111SetMute(bool enable);
|
||||
|
||||
/**
|
||||
\brief Set voice volume
|
||||
\param[in] volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7111SetVolume(int volume);
|
||||
|
||||
/**
|
||||
\brief Get voice volume
|
||||
\param[out] *volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7111GetVolume(int *volume);
|
||||
|
||||
/**
|
||||
\brief Configure ES7111 I2S format
|
||||
\param[in] mod: set ADC or DAC or both
|
||||
\param[in] cfg: ES8388 I2S format
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7111ConfigFmt(HalCodecIfaceFormat_e fmt);
|
||||
|
||||
/**
|
||||
\brief Configure ES7111 data sample bits
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\param[in] bits: bit number of per sample
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7111SetBitsPerSample(HalCodecIfaceBits_e bits);
|
||||
|
||||
/**
|
||||
\brief Start ES7111 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7111Start(HalCodecMode_e mode);
|
||||
|
||||
/**
|
||||
\brief Stop ES7111 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7111Stop(HalCodecMode_e mode);
|
||||
|
||||
/**
|
||||
\brief Get ES7111 DAC mute status
|
||||
\param[out] mute get mute
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7111GetVoiceMute(int *mute);
|
||||
|
||||
/**
|
||||
\brief Set ES7111 mic gain and volume
|
||||
\param[in] micGain db of mic gain, varies from 0~10, default is 8
|
||||
\param[in] micVolume micVolume, varies from 0~100, default is 75
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7111SetMicVolume(uint8_t micGain, int micVolume);
|
||||
|
||||
/**
|
||||
* @brief Print all ES7111 registers
|
||||
*
|
||||
* @return
|
||||
* - void
|
||||
*/
|
||||
/**
|
||||
\brief Print all ES7111 registers
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es7111ReadAll();
|
||||
|
||||
/**
|
||||
\brief get es7111 default config
|
||||
\param[in] NULL
|
||||
\return HalCodecCfg_t codecCfg
|
||||
\note
|
||||
*/
|
||||
HalCodecCfg_t es7111GetDefaultCfg();
|
||||
|
||||
HalCodecSts_e es7111Resume(HalCodecMode_e mode);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CODEC_ES7111_H */
|
||||
|
@ -1,191 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: es7149.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: Rev1.0 2020-02-24
|
||||
*
|
||||
* Notes: es7149 interface
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _CODEC_ES7149_H
|
||||
#define _CODEC_ES7149_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "codecDrv.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern HalCodecFuncList_t es7149DefaultHandle;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\brief Enables or disables PA
|
||||
\param[in] enable true/false
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es7149EnablePA(bool enable);
|
||||
|
||||
/**
|
||||
\brief Initialize ES7149 codec chip
|
||||
\param[in] codec_cfg configuration of ES7149
|
||||
\return -CODEC_EOK -CODEC_INIT_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7149Init(HalCodecCfg_t *codecCfg);
|
||||
|
||||
/**
|
||||
\brief Deinitialize ES7149 codec chip
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es7149DeInit(void);
|
||||
|
||||
/**
|
||||
\brief start/stop ES7149 codec chip
|
||||
\param[in] mode codec mode
|
||||
\param[in] ctrlState start or stop decode or encode progress
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7149StartStop(HalCodecMode_e mode, HalCodecCtrlState_e ctrlState);
|
||||
|
||||
/**
|
||||
\brief Configure ES7149 codec mode and I2S interface
|
||||
\param[in] mode codec mode
|
||||
\param[in] iface I2S config
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7149Config(HalCodecMode_e mode, HalCodecIface_t *iface);
|
||||
|
||||
/**
|
||||
\brief Configure ES7149 DAC mute or not. Basically you can use this function to mute the output or unmute
|
||||
\param[in] enable enable(1) or disable(0)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7149SetMute(bool enable);
|
||||
|
||||
/**
|
||||
\brief Set voice volume
|
||||
\param[in] volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7149SetVolume(int volume);
|
||||
|
||||
/**
|
||||
\brief Get voice volume
|
||||
\param[out] *volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7149GetVolume(int *volume);
|
||||
|
||||
/**
|
||||
\brief Configure ES7149 I2S format
|
||||
\param[in] mod: set ADC or DAC or both
|
||||
\param[in] cfg: ES8388 I2S format
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7149ConfigFmt(HalCodecIfaceFormat_e fmt);
|
||||
|
||||
/**
|
||||
\brief Configure ES7149 data sample bits
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\param[in] bits: bit number of per sample
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7149SetBitsPerSample(HalCodecIfaceBits_e bits);
|
||||
|
||||
/**
|
||||
\brief Start ES7149 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7149Start(HalCodecMode_e mode);
|
||||
|
||||
/**
|
||||
\brief Stop ES7149 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7149Stop(HalCodecMode_e mode);
|
||||
|
||||
/**
|
||||
\brief Get ES7149 DAC mute status
|
||||
\param[out] mute get mute
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7149GetVoiceMute(int *mute);
|
||||
|
||||
/**
|
||||
\brief Set ES7149 mic gain and volume
|
||||
\param[in] micGain db of mic gain, varies from 0~10, default is 8
|
||||
\param[in] micVolume micVolume, varies from 0~100, default is 75
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es7149SetMicVolume(uint8_t micGain, int micVolume);
|
||||
|
||||
/**
|
||||
* @brief Print all ES7149 registers
|
||||
*
|
||||
* @return
|
||||
* - void
|
||||
*/
|
||||
/**
|
||||
\brief Print all ES7149 registers
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es7149ReadAll();
|
||||
|
||||
/**
|
||||
\brief get es7149 default config
|
||||
\param[in] NULL
|
||||
\return HalCodecCfg_t codecCfg
|
||||
\note
|
||||
*/
|
||||
HalCodecCfg_t es7149GetDefaultCfg();
|
||||
|
||||
HalCodecSts_e es7149Resume(HalCodecMode_e mode);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CODEC_ES7149_H */
|
||||
|
@ -1,280 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: es8311.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: Rev1.0 2020-02-24
|
||||
*
|
||||
* Notes: es8311 interface
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _CODEC_ES8311_H
|
||||
#define _CODEC_ES8311_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "codecDrv.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
// ES8311_REGISTER NAME_REG_REGISTER ADDRESS
|
||||
#define ES8311_RESET_REG00 0x00 /*reset digital,csm,clock manager etc.*/
|
||||
|
||||
// Clock Scheme Register definition
|
||||
#define ES8311_CLK_MANAGER_REG01 0x01 // select clk src for mclk, enable clock for codec
|
||||
#define ES8311_CLK_MANAGER_REG02 0x02 // clk divider and clk multiplier
|
||||
#define ES8311_CLK_MANAGER_REG03 0x03 // adc fsmode and osr
|
||||
#define ES8311_CLK_MANAGER_REG04 0x04 // dac osr
|
||||
#define ES8311_CLK_MANAGER_REG05 0x05 // clk divier for adc and dac
|
||||
#define ES8311_CLK_MANAGER_REG06 0x06 // bclk inverter and divider
|
||||
#define ES8311_CLK_MANAGER_REG07 0x07 // tri-state, lrck divider
|
||||
#define ES8311_CLK_MANAGER_REG08 0x08 // lrck divider
|
||||
|
||||
// SDP
|
||||
#define ES8311_SDPIN_REG09 0x09 // dac serial digital port */
|
||||
#define ES8311_SDPOUT_REG0A 0x0A // adc serial digital port */
|
||||
|
||||
// SYSTEM
|
||||
#define ES8311_SYSTEM_REG0B 0x0B // system
|
||||
#define ES8311_SYSTEM_REG0C 0x0C // system
|
||||
#define ES8311_SYSTEM_REG0D 0x0D // system, power up/down
|
||||
#define ES8311_SYSTEM_REG0E 0x0E // system, power up/down
|
||||
#define ES8311_SYSTEM_REG0F 0x0F // system, low power
|
||||
#define ES8311_SYSTEM_REG10 0x10 // system
|
||||
#define ES8311_SYSTEM_REG11 0x11 // system
|
||||
#define ES8311_SYSTEM_REG12 0x12 // system, Enable DAC
|
||||
#define ES8311_SYSTEM_REG13 0x13 // system
|
||||
#define ES8311_SYSTEM_REG14 0x14 // system, mic gain, select DMIC, select analog pga gain
|
||||
|
||||
// ADC
|
||||
#define ES8311_ADC_REG15 0x15 // ADC, adc ramp rate, dmic sense
|
||||
#define ES8311_ADC_REG16 0x16 // ADC
|
||||
#define ES8311_ADC_REG17 0x17 // ADC, mic volume
|
||||
#define ES8311_ADC_REG18 0x18 // ADC, alc enable and winsize
|
||||
#define ES8311_ADC_REG19 0x19 // ADC, alc maxlevel
|
||||
#define ES8311_ADC_REG1A 0x1A // ADC, alc automute
|
||||
#define ES8311_ADC_REG1B 0x1B // ADC, alc automute, adc hpf s1
|
||||
#define ES8311_ADC_REG1C 0x1C // ADC, equalizer, hpf s2
|
||||
#define ES8311_ADC_REG1D 0x1D // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG1E 0x1E // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG1F 0x1F // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG20 0x20 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG21 0x21 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG22 0x22 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG23 0x23 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG24 0x24 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG25 0x25 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG26 0x26 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG27 0x27 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG28 0x28 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG29 0x29 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG2A 0x2A // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG2B 0x2B // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG2C 0x2C // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG2D 0x2D // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG2E 0x2E // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG2F 0x2F // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
#define ES8311_ADC_REG30 0x30 // ADC, 30-bit B0 coefficient for ADCEQ
|
||||
|
||||
// DAC
|
||||
#define ES8311_DAC_REG31 0x31 // DAC, mute
|
||||
#define ES8311_DAC_REG32 0x32 // DAC, volume
|
||||
#define ES8311_DAC_REG33 0x33 // DAC, offset
|
||||
#define ES8311_DAC_REG34 0x34 // DAC, drc enable, drc winsize
|
||||
#define ES8311_DAC_REG35 0x35 // DAC, drc maxlevel, minilevel
|
||||
#define ES8311_DAC_REG37 0x37 // DAC, ramprate
|
||||
|
||||
// GPIO
|
||||
#define ES8311_GPIO_REG44 0x44 // GPIO, dac2adc for test
|
||||
#define ES8311_GP_REG45 0x45 // GP CONTROL
|
||||
|
||||
// CHIP
|
||||
#define ES8311_CHD1_REGFD 0xFD // CHIP ID1
|
||||
#define ES8311_CHD2_REGFE 0xFE // CHIP ID2
|
||||
#define ES8311_CHVER_REGFF 0xFF // VERSION
|
||||
#define ES8311_CHD1_REGFD 0xFD // CHIP ID1
|
||||
|
||||
#define ES8311_MAX_REGISTER 0xFF
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern HalCodecFuncList_t es8311DefaultHandle;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\brief Enables or disables PA
|
||||
\param[in] enable true/false
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es8311EnablePA(bool enable);
|
||||
|
||||
/**
|
||||
\brief Initialize ES8311 codec chip
|
||||
\param[in] codec_cfg configuration of ES8311
|
||||
\return -CODEC_EOK -CODEC_INIT_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311Init(HalCodecCfg_t *codecCfg);
|
||||
|
||||
/**
|
||||
\brief Deinitialize ES8311 codec chip
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es8311DeInit(void);
|
||||
|
||||
/**
|
||||
\brief start/stop ES8311 codec chip
|
||||
\param[in] mode codec mode
|
||||
\param[in] ctrlState start or stop decode or encode progress
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311StartStop(HalCodecMode_e mode, HalCodecCtrlState_e ctrlState);
|
||||
|
||||
/**
|
||||
\brief Configure ES8311 codec mode and I2S interface
|
||||
\param[in] mode codec mode
|
||||
\param[in] iface I2S config
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311Config(HalCodecMode_e mode, HalCodecIface_t *iface);
|
||||
|
||||
/**
|
||||
\brief Configure ES8311 DAC mute or not. Basically you can use this function to mute the output or unmute
|
||||
\param[in] enable enable(1) or disable(0)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311SetMute(HalCodecCfg_t* codecHalCfg, bool enable);
|
||||
|
||||
/**
|
||||
\brief Set voice volume
|
||||
\param[in] volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311SetVolume(HalCodecCfg_t* codecHalCfg, int volume);
|
||||
|
||||
/**
|
||||
\brief Get voice volume
|
||||
\param[out] *volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311GetVolume(HalCodecCfg_t* codecHalCfg, int *volume);
|
||||
|
||||
/**
|
||||
\brief Configure ES8311 I2S format
|
||||
\param[in] mod: set ADC or DAC or both
|
||||
\param[in] cfg: ES8388 I2S format
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311ConfigFmt(HalCodecIfaceFormat_e fmt);
|
||||
|
||||
/**
|
||||
\brief Configure ES8311 data sample bits
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\param[in] bits: bit number of per sample
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311SetBitsPerSample(HalCodecIfaceBits_e bits);
|
||||
|
||||
/**
|
||||
\brief Start ES8311 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311Start(HalCodecMode_e mode);
|
||||
|
||||
/**
|
||||
\brief Stop ES8311 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311Stop(HalCodecMode_e mode);
|
||||
|
||||
/**
|
||||
\brief Get ES8311 DAC mute status
|
||||
\param[out] mute get mute
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311GetVoiceMute(int *mute);
|
||||
|
||||
/**
|
||||
\brief Set ES8311 mic gain and volume
|
||||
\param[in] micGain db of mic gain, varies from 0~10, default is 8
|
||||
\param[in] micVolume micVolume, varies from 0~100, default is 75
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8311SetMicVolume(HalCodecCfg_t* codecHalCfg, uint8_t micGain, int micVolume);
|
||||
|
||||
HalCodecSts_e es8311GetMicVolume(HalCodecCfg_t* codecHalCfg, uint8_t *micGain, int *micVolume);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Print all ES8311 registers
|
||||
*
|
||||
* @return
|
||||
* - void
|
||||
*/
|
||||
/**
|
||||
\brief Print all ES8311 registers
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es8311ReadAll();
|
||||
|
||||
/**
|
||||
\brief get es8311 default config
|
||||
\param[in] NULL
|
||||
\return HalCodecCfg_t codecCfg
|
||||
\note
|
||||
*/
|
||||
HalCodecCfg_t es8311GetDefaultCfg();
|
||||
|
||||
HalCodecSts_e es8311Resume(HalCodecMode_e mode);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CODEC_ES8311_H */
|
||||
|
@ -1,262 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: es8374.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: Rev1.0 2020-02-24
|
||||
*
|
||||
* Notes: es8374 interface
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _CODEC_ES8374_H
|
||||
#define _CODEC_ES8374_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "codecDrv.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern HalCodecFuncList_t es8374DefaultHandle;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
// ES8374_REG_ISTER NAME_REG_REGISTER ADDRESS
|
||||
#define ES8374_REG_00 0x00
|
||||
#define ES8374_REG_01 0x01
|
||||
#define ES8374_REG_02 0x02
|
||||
#define ES8374_REG_03 0x03
|
||||
#define ES8374_REG_04 0x04
|
||||
#define ES8374_REG_05 0x05
|
||||
#define ES8374_REG_06 0x06
|
||||
#define ES8374_REG_07 0x07
|
||||
#define ES8374_REG_08 0x08
|
||||
#define ES8374_REG_09 0x09
|
||||
#define ES8374_REG_0A 0x0A
|
||||
#define ES8374_REG_0B 0x0B
|
||||
#define ES8374_REG_0C 0x0C
|
||||
#define ES8374_REG_0D 0x0D
|
||||
#define ES8374_REG_0E 0x0E
|
||||
#define ES8374_REG_0F 0x0F
|
||||
#define ES8374_REG_10 0x10
|
||||
#define ES8374_REG_11 0x11
|
||||
#define ES8374_REG_12 0x12
|
||||
#define ES8374_REG_13 0x13
|
||||
#define ES8374_REG_14 0x14
|
||||
#define ES8374_REG_15 0x15
|
||||
#define ES8374_REG_16 0x16
|
||||
#define ES8374_REG_17 0x17
|
||||
#define ES8374_REG_18 0x18
|
||||
#define ES8374_REG_19 0x19
|
||||
#define ES8374_REG_1A 0x1A
|
||||
#define ES8374_REG_1B 0x1B
|
||||
#define ES8374_REG_1C 0x1C
|
||||
#define ES8374_REG_1D 0x1D
|
||||
#define ES8374_REG_1E 0x1E
|
||||
#define ES8374_REG_1F 0x1F
|
||||
#define ES8374_REG_20 0x20
|
||||
#define ES8374_REG_21 0x21
|
||||
#define ES8374_REG_22 0x22
|
||||
#define ES8374_REG_23 0x23
|
||||
#define ES8374_REG_24 0x24
|
||||
#define ES8374_REG_25 0x25
|
||||
#define ES8374_REG_26 0x26
|
||||
#define ES8374_REG_27 0x27
|
||||
#define ES8374_REG_28 0x28
|
||||
#define ES8374_REG_29 0x29
|
||||
#define ES8374_REG_2A 0x2A
|
||||
#define ES8374_REG_2B 0x2B
|
||||
#define ES8374_REG_2C 0x2C
|
||||
#define ES8374_REG_2D 0x2D
|
||||
#define ES8374_REG_2E 0x2E
|
||||
#define ES8374_REG_2F 0x2F
|
||||
#define ES8374_REG_30 0x30
|
||||
#define ES8374_REG_31 0x31
|
||||
#define ES8374_REG_32 0x32
|
||||
#define ES8374_REG_33 0x33
|
||||
#define ES8374_REG_34 0x34
|
||||
#define ES8374_REG_35 0x35
|
||||
#define ES8374_REG_36 0x36
|
||||
#define ES8374_REG_37 0x37
|
||||
#define ES8374_REG_38 0x38
|
||||
#define ES8374_REG_6D 0x6D
|
||||
#define ES8374_REG_6F 0x6F
|
||||
#define ES8374_REG_72 0x72
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern HalCodecFuncList_t es8374DefaultHandle;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\brief Enables or disables PA
|
||||
\param[in] enable true/false
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es8374EnablePA(bool enable);
|
||||
|
||||
/**
|
||||
\brief Initialize ES8374 codec chip
|
||||
\param[in] codec_cfg configuration of ES8374
|
||||
\return -CODEC_EOK -CODEC_INIT_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374Init(HalCodecCfg_t *codecCfg);
|
||||
|
||||
/**
|
||||
\brief Deinitialize ES8374 codec chip
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es8374DeInit(void);
|
||||
|
||||
/**
|
||||
\brief start/stop ES8374 codec chip
|
||||
\param[in] mode codec mode
|
||||
\param[in] ctrlState start or stop decode or encode progress
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374StartStop(HalCodecMode_e mode, HalCodecCtrlState_e ctrlState);
|
||||
|
||||
/**
|
||||
\brief Configure ES8374 codec mode and I2S interface
|
||||
\param[in] mode codec mode
|
||||
\param[in] iface I2S config
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374Config(HalCodecMode_e mode, HalCodecIface_t *iface);
|
||||
|
||||
/**
|
||||
\brief Configure ES8374 DAC mute or not. Basically you can use this function to mute the output or unmute
|
||||
\param[in] enable enable(1) or disable(0)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374SetMute(HalCodecCfg_t* codecHalCfg, bool enable);
|
||||
|
||||
/**
|
||||
\brief Set voice volume
|
||||
\param[in] volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374SetVolume(HalCodecCfg_t* codecHalCfg, int volume);
|
||||
|
||||
/**
|
||||
\brief Get voice volume
|
||||
\param[out] *volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374GetVolume(HalCodecCfg_t* codecHalCfg, int *volume);
|
||||
|
||||
/**
|
||||
\brief Configure ES8374 I2S format
|
||||
\param[in] mod: set ADC or DAC or both
|
||||
\param[in] cfg: ES8388 I2S format
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374ConfigFmt(HalCodecIfaceFormat_e fmt);
|
||||
|
||||
/**
|
||||
\brief Configure ES8374 data sample bits
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\param[in] bits: bit number of per sample
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374SetBitsPerSample(HalCodecIfaceBits_e bits);
|
||||
|
||||
/**
|
||||
\brief Start ES8374 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374Start(HalCodecModule_e mode);
|
||||
|
||||
/**
|
||||
\brief Stop ES8374 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374Stop(HalCodecModule_e mode);
|
||||
|
||||
/**
|
||||
\brief Get ES8374 DAC mute status
|
||||
\param[out] mute get mute
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374GetVoiceMute(uint8_t *mute);
|
||||
|
||||
/**
|
||||
\brief Set ES8374 mic gain and volume
|
||||
\param[in] not used
|
||||
\param[in] micVolume micVolume, varies from 0~100, default is 75
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e es8374SetMicVolume(HalCodecCfg_t* codecHalCfg, uint8_t micGain, int micVolume);
|
||||
|
||||
/**
|
||||
* @brief Print all ES8374 registers
|
||||
*
|
||||
* @return
|
||||
* - void
|
||||
*/
|
||||
/**
|
||||
\brief Print all ES8374 registers
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void es8374ReadAll();
|
||||
|
||||
/**
|
||||
\brief get es8374 default config
|
||||
\param[in] NULL
|
||||
\return HalCodecCfg_t codecCfg
|
||||
\note
|
||||
*/
|
||||
HalCodecCfg_t es8374GetDefaultCfg();
|
||||
|
||||
HalCodecSts_e es8374Resume(HalCodecMode_e mode);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CODEC_ES8374_H */
|
||||
|
@ -1,191 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: tm8211.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: Rev1.0 2020-02-24
|
||||
*
|
||||
* Notes: tm8211 interface
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _CODEC_TM8211_H
|
||||
#define _CODEC_TM8211_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "codecDrv.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern HalCodecFuncList_t tm8211DefaultHandle;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\brief Enables or disables PA
|
||||
\param[in] enable true/false
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void tm8211EnablePA(bool enable);
|
||||
|
||||
/**
|
||||
\brief Initialize TM8211 codec chip
|
||||
\param[in] codec_cfg configuration of TM8211
|
||||
\return -CODEC_EOK -CODEC_INIT_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e tm8211Init(HalCodecCfg_t *codecCfg);
|
||||
|
||||
/**
|
||||
\brief Deinitialize TM8211 codec chip
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void tm8211DeInit(void);
|
||||
|
||||
/**
|
||||
\brief start/stop TM8211 codec chip
|
||||
\param[in] mode codec mode
|
||||
\param[in] ctrlState start or stop decode or encode progress
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e tm8211StartStop(HalCodecMode_e mode, HalCodecCtrlState_e ctrlState);
|
||||
|
||||
/**
|
||||
\brief Configure TM8211 codec mode and I2S interface
|
||||
\param[in] mode codec mode
|
||||
\param[in] iface I2S config
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e tm8211Config(HalCodecMode_e mode, HalCodecIface_t *iface);
|
||||
|
||||
/**
|
||||
\brief Configure TM8211 DAC mute or not. Basically you can use this function to mute the output or unmute
|
||||
\param[in] enable enable(1) or disable(0)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e tm8211SetMute(bool enable);
|
||||
|
||||
/**
|
||||
\brief Set voice volume
|
||||
\param[in] volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e tm8211SetVolume(int volume);
|
||||
|
||||
/**
|
||||
\brief Get voice volume
|
||||
\param[out] *volume: voice volume (0~100)
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e tm8211GetVolume(int *volume);
|
||||
|
||||
/**
|
||||
\brief Configure TM8211 I2S format
|
||||
\param[in] mod: set ADC or DAC or both
|
||||
\param[in] cfg: ES8388 I2S format
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e tm8211ConfigFmt(HalCodecIfaceFormat_e fmt);
|
||||
|
||||
/**
|
||||
\brief Configure TM8211 data sample bits
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\param[in] bits: bit number of per sample
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e tm8211SetBitsPerSample(HalCodecIfaceBits_e bits);
|
||||
|
||||
/**
|
||||
\brief Start TM8211 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e tm8211Start(HalCodecMode_e mode);
|
||||
|
||||
/**
|
||||
\brief Stop TM8211 codec chip
|
||||
\param[in] mode: set ADC or DAC or both
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e tm8211Stop(HalCodecMode_e mode);
|
||||
|
||||
/**
|
||||
\brief Get TM8211 DAC mute status
|
||||
\param[out] mute get mute
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e tm8211GetVoiceMute(int *mute);
|
||||
|
||||
/**
|
||||
\brief Set TM8211 mic gain and volume
|
||||
\param[in] micGain db of mic gain, varies from 0~10, default is 8
|
||||
\param[in] micVolume micVolume, varies from 0~100, default is 75
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e tm8211SetMicVolume(uint8_t micGain, int micVolume);
|
||||
|
||||
/**
|
||||
* @brief Print all TM8211 registers
|
||||
*
|
||||
* @return
|
||||
* - void
|
||||
*/
|
||||
/**
|
||||
\brief Print all TM8211 registers
|
||||
\param[in] NULL
|
||||
\return NULL
|
||||
\note
|
||||
*/
|
||||
void tm8211ReadAll();
|
||||
|
||||
/**
|
||||
\brief get tm8211 default config
|
||||
\param[in] NULL
|
||||
\return HalCodecCfg_t codecCfg
|
||||
\note
|
||||
*/
|
||||
HalCodecCfg_t tm8211GetDefaultCfg();
|
||||
|
||||
HalCodecSts_e tm8211Resume(HalCodecMode_e mode);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CODEC_TM8211_H */
|
||||
|
@ -1,424 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: hal_codec.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: Rev1.0 2020-02-24
|
||||
*
|
||||
* Notes: codec interface
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _CODEC_DRV_H
|
||||
#define _CODEC_DRV_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "ec7xx.h"
|
||||
#include "string.h"
|
||||
#include "Driver_Common.h"
|
||||
#include "bsp.h"
|
||||
#include "hal_i2c.h"
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
#include "osasys.h"
|
||||
#include "cmsis_os2.h"
|
||||
#endif
|
||||
#include "slpman.h"
|
||||
#include "exception_process.h"
|
||||
#ifndef CHIP_EC618
|
||||
#include "mw_nvm_audio.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define HAL_CODEC_VOL_SPEAKER_DEFAULT 65
|
||||
#define HAL_CODEC_MIC_GAIN_DEFAULT 8
|
||||
#define HAL_CODEC_VOL_MIC_DEFAULT 191
|
||||
#define HAL_CODEC_VOL_SPEAKER_GAIN_DEFAULT 8
|
||||
|
||||
// Codec I2C address
|
||||
#define ES8388_IICADDR 0x11
|
||||
#define ES8311_IICADDR 0x18
|
||||
#define ES8374_IICADDR 0x10
|
||||
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
#define HAL_CODEC_CHECK_NULL(a, format, b, ...) \
|
||||
if ((a) == 0) { \
|
||||
return b;\
|
||||
}
|
||||
|
||||
#define DEBUG_PRINT(moduleId, subId, debugLevel, format, ...) ECPLAT_PRINTF(moduleId, subId, debugLevel, format, ##__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_PRINT(moduleId, subId, debugLevel, format, ...)
|
||||
#define HAL_CODEC_CHECK_NULL(a, format, b, ...)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/** \brief CODEC_PA location */
|
||||
#define CODEC_PA_GPIO_INSTANCE (0)
|
||||
#define CODEC_PA_GPIO_PIN (2)
|
||||
#define CODEC_PA_PAD_INDEX (17)
|
||||
#define CODEC_PA_PAD_ALT_FUNC (PAD_MUX_ALT0)
|
||||
|
||||
#define DIRECTION_TX (0)
|
||||
#define DIRECTION_RX (1)
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
bool isDmic;
|
||||
bool isExPa;
|
||||
int16_t exPaGain;
|
||||
int16_t txDigGain;
|
||||
int16_t txAnaGain;
|
||||
|
||||
int16_t rxDigGain0;
|
||||
int16_t rxAnaGain0;
|
||||
int16_t rxDigGain50;
|
||||
int16_t rxAnaGain50;
|
||||
int16_t rxDigGain100;
|
||||
int16_t rxAnaGain100;
|
||||
}HalCodecTlvDefault_t;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* usr set codec volumn parameter
|
||||
*/
|
||||
typedef struct _USR_SET_CODEC_VOLUMN
|
||||
{
|
||||
UINT16 rxDigUsrSet; // bit15: flag; bit14~bit8: 1level; bit7~bit0: 2level
|
||||
UINT16 rxAnaUsrSet; // bit15: flag; bit14~bit8: 1level; bit7~bit0: 2level
|
||||
}MWNvmCfgUsrSetCodecVolumn;
|
||||
|
||||
/*
|
||||
* indicate usr whether set volumn in nv
|
||||
*/
|
||||
typedef struct _VOLUMN_SET_FLAG
|
||||
{
|
||||
UINT8 rxDigUsrSetFlag;
|
||||
UINT8 rxAnaUsrSetFlag;
|
||||
UINT8 txDigGainFlag;
|
||||
UINT8 txAnaGainFlag;
|
||||
}MWNvmCfgVolumnSetFlag;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int slope;
|
||||
int offset;
|
||||
HalCodecTlvDefault_t defaultVal;
|
||||
}HalCodecVolParam_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ES8311 = 0,
|
||||
ES8374,
|
||||
ES8388,
|
||||
ES7148,
|
||||
ES7149,
|
||||
ES7111,
|
||||
TM8211
|
||||
}HalCodecType_e;
|
||||
|
||||
// codec status
|
||||
typedef enum
|
||||
{
|
||||
CODEC_EOK = 0, // operation completed successfull
|
||||
CODEC_ERR = -1, // unspecified error: no other errno fits
|
||||
CODEC_TIMEOUT = -2, // invalid argument(s)
|
||||
CODEC_INIT_ERR = -3, // invalid argument(s)
|
||||
CODEC_CFG_ERR = -4, // invalid argument(s)
|
||||
CODEC_SET_VOLUME_ERR = -5, // invalid argument(s)
|
||||
CODEC_START_ERR = -6, // invalid argument(s)
|
||||
CODEC_START_I2C_ERR = -7, // invalid argument(s)
|
||||
|
||||
CODEC_STATUS_RSVD = 0x7FFFFFFF
|
||||
}HalCodecSts_e;
|
||||
|
||||
// module gain
|
||||
typedef enum
|
||||
{
|
||||
MODULE_MIN = -1,
|
||||
MODULE_ADC = 0x01,
|
||||
MODULE_DAC = 0x02,
|
||||
MODULE_ADC_DAC = 0x03,
|
||||
MODULE_LINE = 0x04,
|
||||
MODULE_MAX
|
||||
}HalCodecModule_e;
|
||||
|
||||
// Select media hal codec mode
|
||||
typedef enum
|
||||
{
|
||||
CODEC_MODE_ENCODE = 1, // select adc
|
||||
CODEC_MODE_DECODE, // select dac
|
||||
CODEC_MODE_BOTH, // select both adc and dac
|
||||
CODEC_MODE_LINE_IN, // set adc channel
|
||||
}HalCodecMode_e;
|
||||
|
||||
|
||||
// Select adc channel for input mic signal
|
||||
typedef enum
|
||||
{
|
||||
CODEC_ADC_INPUT_LINE1 = 0x00, // mic input to adc channel 1
|
||||
CODEC_ADC_INPUT_LINE2, // mic input to adc channel 2
|
||||
CODEC_ADC_INPUT_ALL, // mic input to both channels of adc
|
||||
CODEC_ADC_INPUT_DIFFERENCE, // mic input to adc difference channel
|
||||
}HalAdcInput_e;
|
||||
|
||||
// Select channel for dac output
|
||||
typedef enum
|
||||
{
|
||||
CODEC_DAC_OUTPUT_LINE1 = 0x00, // dac output signal to channel 1
|
||||
CODEC_DAC_OUTPUT_LINE2, // dac output signal to channel 2
|
||||
CODEC_DAC_OUTPUT_ALL, // dac output signal to both channels
|
||||
}HalDacOutput_e;
|
||||
|
||||
|
||||
// Select operating mode i.e. start or stop for audio codec chip
|
||||
typedef enum
|
||||
{
|
||||
CODEC_CTRL_STOP = 0x00, // set stop mode
|
||||
CODEC_CTRL_START = 0x01, // set start mode
|
||||
CODEC_CTRL_RESUME = 0x02, // set resume mode
|
||||
CODEC_CTRL_POWERDONW = 0x03, // set powerdown mode
|
||||
}HalCodecCtrlState_e;
|
||||
|
||||
// Select I2S interface operating mode i.e. master or slave for audio codec chip
|
||||
typedef enum
|
||||
{
|
||||
CODEC_MODE_MASTER = 0x00, // set master mode
|
||||
CODEC_MODE_SLAVE = 0x01, // set slave mode
|
||||
}HalCodecIfaceMode_e;
|
||||
|
||||
// Select I2S interface samples per second
|
||||
typedef enum
|
||||
{
|
||||
CODEC_08K_SAMPLES, // set to 8k samples per second
|
||||
CODEC_16K_SAMPLES, // set to 16k samples in per second
|
||||
CODEC_22K_SAMPLES, // set to 22.050k samples per second
|
||||
CODEC_32K_SAMPLES, // set to 32k samples in per second
|
||||
CODEC_44K_SAMPLES, // set to 44.1k samples per second
|
||||
CODEC_48K_SAMPLES, // set to 48k samples per second
|
||||
}HalCodecIfaceSample_e;
|
||||
|
||||
// Select I2S interface number of bits per sample
|
||||
typedef enum
|
||||
{
|
||||
CODEC_BIT_LENGTH_16BITS = 0, // set 16 bits per sample
|
||||
CODEC_BIT_LENGTH_24BITS = 2, // set 24 bits per sample
|
||||
CODEC_BIT_LENGTH_32BITS = 3, // set 32 bits per sample
|
||||
}HalCodecIfaceBits_e;
|
||||
|
||||
// Select I2S interface format for audio codec chip
|
||||
typedef enum
|
||||
{
|
||||
CODEC_MSB_MODE, // set all left format */
|
||||
CODEC_LSB_MODE, // set all right format */
|
||||
CODEC_I2S_MODE, // set normal I2S format */
|
||||
CODEC_PCM_MODE, // set dsp/pcm format */
|
||||
}HalCodecIfaceFormat_e;
|
||||
|
||||
// codec channel
|
||||
typedef enum
|
||||
{
|
||||
CODEC_MONO,
|
||||
CODEC_DUAL,
|
||||
}HalCodecChannel_e;
|
||||
|
||||
// I2s interface configuration for audio codec chip
|
||||
typedef struct
|
||||
{
|
||||
HalCodecIfaceMode_e mode; // audio codec chip mode
|
||||
HalCodecIfaceFormat_e fmt; // I2S interface format
|
||||
HalCodecIfaceSample_e samples; // I2S interface samples per second
|
||||
HalCodecIfaceBits_e bits; // i2s interface number of bits per sample
|
||||
HalCodecChannel_e channel; // mono or dual channel
|
||||
uint8_t polarity;
|
||||
}HalCodecIface_t;
|
||||
|
||||
// Configure media hal for initialization of audio codec chip
|
||||
typedef struct
|
||||
{
|
||||
HalAdcInput_e adcInput; // set adc channel
|
||||
HalDacOutput_e dacOutput; // set dac channel
|
||||
HalCodecMode_e codecMode; // select codec mode: adc, dac or both
|
||||
HalCodecIface_t codecIface; // set I2S interface configuration
|
||||
bool hasPA;
|
||||
uint8_t codecDeviceType;// 0:HAND_SET 1:HEAD_SET_3_4_POLE 2:HEAD_SET 3:HANDS_OFF
|
||||
uint8_t deviceMode; // 0: NB 1: WB
|
||||
uint8_t direction; // 0: TX 1: RX
|
||||
HalCodecVolParam_t codecVolParam; // each codec volume param, include slope and offset
|
||||
}HalCodecCfg_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CODEC_NONE = 0,
|
||||
CODEC_INIT = 1,
|
||||
CODEC_START = 2,
|
||||
CODEC_STANDBY = 3,
|
||||
CODEC_RESUME = 4,
|
||||
CODEC_POWER_DOWN = 5
|
||||
}HalCodecState_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t playState : 4;
|
||||
uint16_t recordState : 4;
|
||||
uint16_t playCnt : 4;
|
||||
uint16_t recordCnt : 4;
|
||||
}HalCodecState_t;
|
||||
|
||||
// HAL codec func list
|
||||
typedef struct
|
||||
{
|
||||
uint8_t codecType;
|
||||
HalCodecSts_e (*halCodecInitFunc)(HalCodecCfg_t *codec_cfg); // initialize codec
|
||||
void (*halCodecDeinitFunc)(void); // deinitialize codec
|
||||
HalCodecSts_e (*halCodecCtrlStateFunc)(HalCodecMode_e mode, HalCodecCtrlState_e ctrl_state); // control codec mode and state
|
||||
HalCodecSts_e (*halCodecCfgIfaceFunc)(HalCodecMode_e mode, HalCodecIface_t *iface); // configure i2s interface
|
||||
HalCodecSts_e (*halCodecSetMuteFunc) (HalCodecCfg_t* codecHalCfg, bool mute); // set codec mute
|
||||
HalCodecSts_e (*halCodecSetVolumeFunc)(HalCodecCfg_t* codecHalCfg, int volume); // set codec volume
|
||||
HalCodecSts_e (*halCodecGetVolumeFunc)(HalCodecCfg_t* codecHalCfg, int *volume); // get codec volume
|
||||
HalCodecSts_e (*halCodecSetMicVolumeFunc)(HalCodecCfg_t* codecHalCfg, uint8_t micGain, int volume); // set codec mic gain and volume
|
||||
HalCodecSts_e (*halCodecGetMicVolumeFunc)(HalCodecCfg_t* codecHalCfg, uint8_t* micGain, int *volume); // get codec mic gain and volume
|
||||
void (*halCodecEnablePAFunc) (bool enable); // enable pa
|
||||
void *halCodecLock; // semaphore of codec
|
||||
void *handle; // handle of audio codec
|
||||
HalCodecCfg_t (*halCodecGetDefaultCfg)();
|
||||
}HalCodecFuncList_t;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
\brief Hal codec init
|
||||
\param[in] codecHalCfg codec config
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return HalCodecFuncList_t* codec funclist
|
||||
\note
|
||||
*/
|
||||
HalCodecFuncList_t* halCodecInit(HalCodecCfg_t* codecHalCfg, HalCodecFuncList_t* codecHalFunc, bool needLock);
|
||||
|
||||
/**
|
||||
\brief HAL CODEC Deinit
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecDeinit(HalCodecFuncList_t* codecHal);
|
||||
|
||||
/**
|
||||
\brief Hal codec start/stop control
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] mode codec mode
|
||||
\param[in] codecStartStop codec start or stop
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecCtrlState(HalCodecFuncList_t* codecHal, HalCodecMode_e mode, HalCodecCtrlState_e codecStartStop, bool needLock);
|
||||
|
||||
/**
|
||||
\brief Hal codec interface config
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] mode codec mode
|
||||
\param[in] iface codec interface
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecIfaceCfg(HalCodecFuncList_t* codecHal, HalCodecMode_e mode, HalCodecIface_t *iface, bool needLock);
|
||||
|
||||
/**
|
||||
\brief Hal codec set mute
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] mute codec set mute
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecSetMute(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, bool mute, bool needLock);
|
||||
|
||||
#if 0
|
||||
/**
|
||||
\brief Hal codec enable pa
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] enable codec enable/disable pa
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecEnablePA(HalCodecFuncList_t* codecHal, bool enable, bool needLock);
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Hal codec set volume
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] volume codec set volume
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecSetVolume(HalCodecFuncList_t* codecHal,HalCodecCfg_t* codecHalCfg, int volume, bool needLock);
|
||||
|
||||
/**
|
||||
\brief Hal codec get volume
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[out] volume codec get volume
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecGetVolume(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, int *volume, bool needLock);
|
||||
|
||||
/**
|
||||
\brief Hal codec set mic volume
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\param[in] micGain codec set mic gain
|
||||
\param[in] micVolume codec set volume
|
||||
\param[in] needLock need semaphore lock or not in codec HAL layer
|
||||
\return -CODEC_EOK -CODEC_ERR
|
||||
\note
|
||||
*/
|
||||
HalCodecSts_e halCodecSetMicVolume(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, uint8_t micGain, int micVolume, bool needLock);
|
||||
|
||||
/**
|
||||
\brief Hal codec get default config
|
||||
\param[in] codecHalFunc codecHal func list
|
||||
\return HalCodecCfg_t codec defalt config
|
||||
\note
|
||||
*/
|
||||
HalCodecCfg_t halCodecGetDefaultCfg(HalCodecFuncList_t* codecHalFunc);
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CODEC_DRV_H */
|
@ -1,96 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2020-, Copyrigths of EigenComm Ltd.
|
||||
* File name: eepRom.h
|
||||
* Description: EC618 eepRom driver file
|
||||
* History: Rev1.0 2020-12-17
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _EEPROM_EC618_H
|
||||
#define _EEPROM_EC618_H
|
||||
|
||||
#include "ec7xx.h"
|
||||
#include "Driver_Common.h"
|
||||
#include "oneWire.h"
|
||||
|
||||
/**
|
||||
\addtogroup eepRom_interface_gr
|
||||
\{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/** \brief ROM Operation Command */
|
||||
#define ROM_READ_CMD 0x33
|
||||
#define ROM_MATCH_CMD 0x55
|
||||
#define ROM_SKIP_CMD 0xCC
|
||||
#define ROM_SEARCH_CMD 0xF0
|
||||
|
||||
/** \brief Memory Operation Command */
|
||||
#define MEM_READ_CMD 0xF0
|
||||
#define SCRATCHPAD_READ_CMD 0xAA
|
||||
#define SCRATCHPAD_WRITE_CMD 0x0F
|
||||
#define SCRATCHPAD_COPY_CMD 0x55
|
||||
|
||||
/** \brief EEPROM Status */
|
||||
#define EEPROMDRV_OK (0)
|
||||
#define EEPROMDRV_RESET_ERR (-1)
|
||||
#define EEPROMDRV_RESETPD_ERR (-2)
|
||||
#define EEPROMDRV_ROMREAD_ERR (-3)
|
||||
#define EEPROMDRV_ROMMATCH_ERR (-4)
|
||||
#define EEPROMDRV_ROMSKIP_ERR (-5)
|
||||
#define EEPROMDRV_ROMSEARCH_ERR (-6)
|
||||
#define EEPROMDRV_MEMREAD_ERR (-7)
|
||||
#define EEPROMDRV_SCRATCHPADREAD_ERR (-8)
|
||||
#define EEPROMDRV_SCRATCHPADWRITE_ERR (-9)
|
||||
#define EEPROMDRV_SCRATCHPADCOPY_ERR (-10)
|
||||
|
||||
/**
|
||||
\fn int32_t eePromReadRom(uint8_t* romCode)
|
||||
\brief EEPROM read ROM code
|
||||
\param[out] romCode ROM infomation read back.
|
||||
\return read ROM status
|
||||
*/
|
||||
int32_t eePromReadRom(uint8_t* romCode);
|
||||
|
||||
/**
|
||||
\fn eePromReadMem(uint8_t targetAddr, uint8_t len, uint8_t* buffer)
|
||||
\brief EEPROM read memory.
|
||||
\param[in] targetAddr The target address of EEPROM.
|
||||
\param[in] len Length of this read.
|
||||
\param[out] buffer Data read back.
|
||||
\return read memory status
|
||||
*/
|
||||
int32_t eePromReadMem(uint8_t targetAddr, uint8_t len, uint8_t* buffer);
|
||||
|
||||
/**
|
||||
\fn int32_t eePromWriteMem(uint8_t targetAddr, uint8_t len, uint8_t* buffer)
|
||||
\brief EEPROM write memory
|
||||
\param[in] targetAddr The target address of EEPROM.
|
||||
\param[in] len Length of this write.
|
||||
\param[in] buffer Data needs to write into memory.
|
||||
\return Write memory status
|
||||
*/
|
||||
int32_t eePromWriteMem(uint8_t targetAddr, uint8_t len, uint8_t* buffer);
|
||||
|
||||
void eepRomInit(OwModeSel_e mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,202 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __EX_FLASH_H__
|
||||
#define __EX_FLASH_H__
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* EXFLASH Error codes */
|
||||
#define EXFLASH_OK ((uint8_t)0x00)
|
||||
#define EXFLASH_ERROR ((uint8_t)0x01)
|
||||
#define EXFLASH_BUSY ((uint8_t)0x02)
|
||||
#define EXFLASH_NOT_SUPPORTED ((uint8_t)0x04)
|
||||
|
||||
|
||||
#define PAGE_SIZE 256
|
||||
#define SECTOR_SIZE 4096
|
||||
|
||||
#define Dummy_Byte1 0xFF
|
||||
|
||||
|
||||
|
||||
|
||||
/*********commands*******************************************/
|
||||
|
||||
/* Read Operations */
|
||||
#define READ_CMD 0x03
|
||||
#define FAST_READ_CMD 0x0B
|
||||
|
||||
|
||||
/* Write Operations */
|
||||
#define WRITE_ENABLE_CMD 0x06
|
||||
#define WRITE_DISABLE_CMD 0x04
|
||||
|
||||
#define WRITE_VOLATILE_REG_CMD 0x50
|
||||
|
||||
/* Register Operations */
|
||||
#define READ_STATUS_REG1_CMD 0x05
|
||||
#define READ_STATUS_REG2_CMD 0x35
|
||||
#define WRITE_STATUS_REG1_CMD 0x01
|
||||
#define WRITE_STATUS_REG2_CMD 0x31
|
||||
|
||||
/* Program Operations */
|
||||
#define PAGE_PROG_CMD 0x02
|
||||
#define QUAD_INPUT_PAGE_PROG_CMD 0x32
|
||||
|
||||
/* Erase Operations */
|
||||
#define SECTOR_ERASE_CMD 0x20
|
||||
#define BLOCK_ERASE_32K_CMD 0x52
|
||||
#define BLOCK_ERASE_64K_CMD 0xD8
|
||||
#define CHIP_ERASE_CMD 0xC7//or 0x60
|
||||
|
||||
|
||||
/* Identification Operations */
|
||||
#define READ_ID_CMD 0x90
|
||||
#define DUAL_READ_ID_CMD 0x92
|
||||
#define QUAD_READ_ID_CMD 0x94
|
||||
#define READ_JEDEC_ID_CMD 0x9F
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashChipErase(void)
|
||||
\brief perform chip level erase, use with caution!!
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
void exFlashChipErase(void);
|
||||
|
||||
/**
|
||||
\fn exFlashBlockErase(void)
|
||||
\brief perform block level erase
|
||||
\param[in] u32Data_Addr :Block first address to start erasing
|
||||
u8mode :Erase mode 1=32K other=64K
|
||||
\note
|
||||
*/
|
||||
void exFlashBlockErase(uint32_t u32Erase_Addr, uint8_t u8mode);
|
||||
|
||||
/**
|
||||
\fn exFlashSectorErase(void)
|
||||
\brief perform sector level erase, normally sector is 4K
|
||||
\param[in] u32Data_Addr :Block first address to start erasing
|
||||
\note
|
||||
*/
|
||||
void exFlashSectorErase(uint32_t u32Erase_Addr);
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashRead(void)
|
||||
\brief reading data of the specified length at the specified address
|
||||
\param[in] u32ReadAddr Start reading address(24bit)
|
||||
pu8Buffer Data storage buffer
|
||||
u16NumByteToRead The number of bytes to read(max 65535)
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashRead(uint8_t *pu8Buffer, uint32_t u32ReadAddr, uint16_t u16NumByteToRead);
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashPagePro(void)
|
||||
\brief starts writing data of up to 256 bytes at a specified address on one page (0~65535)
|
||||
\param[in] u32ReadAddr Start reading address(24bit)
|
||||
pu8Buffer:Data storage buffer
|
||||
u16NumByteToWrite:The number of bytes to write (maximum 256),
|
||||
* the number should not exceed the number of remaining bytes on the page!!!
|
||||
\note
|
||||
*/
|
||||
void exFlashPagePro(uint32_t u32WriteAddr, uint8_t *pu8Buffer, uint16_t u16NumByteToWrite);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashReadMDID(void)
|
||||
\brief reading device ID from flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
uint16_t exFlashReadMDID(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashErase(uint32_t eAddr, uint32_t size)
|
||||
\brief Erases the flash region. use different erase cmd according to size
|
||||
\param[in] eAddr addr to erase
|
||||
size erase len
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashErase(uint32_t eAddr, uint32_t size);
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashWrite(uint8_t* pData, uint32_t WriteAddr, uint32_t Size)
|
||||
\brief Writes an amount of data to the QSPI flash.
|
||||
\param[in] pData: Data Pointer to write
|
||||
WriteAddr: Write start address
|
||||
Size: Size of data to write
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashWrite(uint8_t* pData, uint32_t WriteAddr, uint32_t Size);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashInit(void)
|
||||
\brief init the external spi flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashInit(void);
|
||||
|
||||
/**
|
||||
\fn exFlashDeinit(void)
|
||||
\brief deinit the external spi flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashDeinit(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,176 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __EX_STORAGE_H__
|
||||
#define __EX_STORAGE_H__
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define EXSTO_OK 0
|
||||
#define EXSTO_EUNDEF -1 /* undefined error */
|
||||
#define EXSTO_EINIT -2 /* ex-storage init fail */
|
||||
#define EXSTO_EDEINIT -3 /* ex-storage deinit fail */
|
||||
#define EXSTO_EERASE -4 /* flash erase fail */
|
||||
#define EXSTO_EWRITE -5 /* flash write fail */
|
||||
#define EXSTO_EREAD -6 /* flash read fail */
|
||||
#define EXSTO_EMALLOC -7 /* memory alloc fail*/
|
||||
#define EXSTO_EOVRFLOW -8 /* data overflow */
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EXSTO_ZONE_BEGIN = 0,
|
||||
EXSTO_ZONE_EF_DATA = EXSTO_ZONE_BEGIN,
|
||||
EXSTO_ZONE_EF_RSVD,
|
||||
EXSTO_ZONE_SD_DATA,
|
||||
EXSTO_ZONE_SD_RSVD,
|
||||
|
||||
EXSTO_ZONE_MAXNUM,
|
||||
EXSTO_ZONE_UNDEF = 0xff
|
||||
}ExStoZoneId_e;
|
||||
|
||||
typedef uint32_t ExStoZoneId_bm;
|
||||
#define EXSTO_BM_ZONE_EF_DATA (1 << EXSTO_ZONE_EF_DATA)
|
||||
#define EXSTO_BM_ZONE_EF_RSVD (1 << EXSTO_ZONE_EF_RSVD)
|
||||
#define EXSTO_BM_ZONE_SD_DATA (1 << EXSTO_ZONE_SD_DATA)
|
||||
#define EXSTO_BM_ZONE_SD_RSVD (1 << EXSTO_ZONE_SD_RSVD)
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\fn uint8_t exStorageInit(void)
|
||||
\brief init the external storage
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageInit(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageDeinit(void)
|
||||
\brief deinit the external storage
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageDeinit(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageClear(uint32_t zid, uint32_t offset, uint32_t len)
|
||||
\brief erase the area to be write
|
||||
\param[in] zid resv for future use
|
||||
offset erase start addr
|
||||
len erase len
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageClear(uint32_t zid, uint32_t offset, uint32_t len);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageWrite(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen)
|
||||
\brief write data of the specified length at the specified address
|
||||
\param[in] zid resv for future use
|
||||
offset write start addr
|
||||
buf write buf
|
||||
bufLen write len
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageWrite(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageRead(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen)
|
||||
\brief reading data of the specified length at the specified address
|
||||
\param[in] zid resv for future use
|
||||
offset read start addr
|
||||
buf read buf
|
||||
bufLen read len
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageRead(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen);
|
||||
|
||||
/**
|
||||
* @brief exStorageGetZid(uint32_t addr, uint32_t *size, uint32_t *offset);
|
||||
* @details get the es zid according starting address and size of the zone
|
||||
*
|
||||
* @param addr the starting addr of the zone
|
||||
* @param size the size of the zone
|
||||
* @param offset the offset to starting addr of the zone
|
||||
* @return the zone ID.
|
||||
*/
|
||||
uint32_t exStorageGetZid(uint32_t addr, uint32_t *size, uint32_t *offset);
|
||||
|
||||
/**
|
||||
* @brief exStorageGetSize(uint32_t zid, uint8_t isOvhdExcl)
|
||||
* @details get the nvm size of specific fota zone
|
||||
*
|
||||
* @param zid zone Id of fota nvm
|
||||
* @param isOvhdExcl overhead size of the zone is excluded or not
|
||||
* @return the size of zone.
|
||||
*/
|
||||
uint32_t exStorageGetSize(uint32_t zid, uint8_t isOvhdExcl);
|
||||
|
||||
/**
|
||||
* @brief exStorageVerifyPkg(uint32_t zid, uint8_t *hash, uint32_t pkgSize, uint32_t *pkgState)
|
||||
* @details validate the data pkg
|
||||
*
|
||||
* @param pkgState the last state of data pkg
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t exStorageVerifyPkg(uint32_t zid, uint8_t *hash, uint32_t pkgSize, uint32_t *pkgState);
|
||||
|
||||
/**
|
||||
* @brief exStorageGetUpdResult(uint32_t zid, int32_t *pkgState)
|
||||
* @details get the updated result
|
||||
*
|
||||
* @param pkgState the last state of data pkg
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t exStorageGetUpdResult(uint32_t zid, int32_t *pkgState);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,109 +0,0 @@
|
||||
# LCD
|
||||
|
||||
```bash
|
||||
├── lcdDev
|
||||
| ├── disFormat.c
|
||||
| ├── lcdComm.c
|
||||
| ├── lcdDev_7796.c
|
||||
| ├── lcdDev_3037.c
|
||||
| └── lcdDev_7789.c
|
||||
└── lcdDrv.c
|
||||
```
|
||||
|
||||
* 时钟测量接口用于分析执行耗时,并将所有耗时存储到外部flash导出(格式为csv)
|
||||
|
||||
```bash
|
||||
uint32_t measure_execution(void (*func)(va_list), ...)
|
||||
```
|
||||
|
||||
## LSPI
|
||||
|
||||
## Interface
|
||||
|
||||
* 3线I型 – SCL、CS、SDA - 3线1data 9bit SPI – 半双工,只有一根双向的数据线
|
||||
* 3线II型 –SCL、CS、SDI、SDO - 3线2data 9bit SPI – 全双工,有独立的MOSI、MISO
|
||||
* 4线I型 – SCL、DCX、CS、SDA - 4线1data 8bit SPI – 半双工,只有一根双向的数据线
|
||||
* 4线II型 – SCL、DCX、CS、SDI、SDO - 4线2data 8bit SPI –全双工,有独立的MOSI、MISO
|
||||
|
||||
**SCL对应LSPI CLK,DCX对应LSPI WRX,多数LCD没有SDO**
|
||||
|
||||
```bash
|
||||
lspiCtrl.busType = 1; // Interface II
|
||||
lspiCtrl.line4 = 1;
|
||||
lspiCtrl.data2Lane = 0;
|
||||
```
|
||||
|
||||
## DataFormat
|
||||
|
||||
* 相较很多LCD的接收数据格式,LSPI默认先发送放低位(大端模式,bit0在低位),所以会导致颜色反转,读出的数据也会大小端反转。
|
||||
* 如果采用32位寄存器长度,不进行数据压缩,是无法修法数据顺序的。
|
||||
|
||||
```bash
|
||||
lspiDataFmt.wordSize = 15;
|
||||
lspiDataFmt.txPack = 1;
|
||||
lspiDataFmt.rxPack = 1;
|
||||
lspiDataFmt.endianMode = 1;
|
||||
lspiDataFmt.rxFifoEndianMode = 1;
|
||||
lcdDrv->ctrl(LSPI_CTRL_DATA_FORMAT, 0);
|
||||
```
|
||||
|
||||
在转换编码时,典型流程如将RGB565转换为YUV420的步骤:
|
||||
|
||||
* 将RGB565转换为RGB888
|
||||
* 将RGB888转换为YUV444
|
||||
* 将YUV444转换为YUV420
|
||||
|
||||
### 注意事项
|
||||
|
||||
* 1)使用DMA->LSPI需要使能相关时钟
|
||||
```bash
|
||||
PSRAM_dmaAccessClkCtrl(true);
|
||||
```
|
||||
|
||||
* 2)DMA传输RGB565奇数像素时最后一个像素无法输出,需要在填充DMA数据时补一个像素(RGB565 - 2bytes),而LSPI的传输长度不需要补,这样实际传输的像素不会多出一个。
|
||||
|
||||
## LCD
|
||||
|
||||
| Driver | Interface | DataLane | Resolution | TransTime | FrameRate
|
||||
| ------- | ------- | ------- | ------- | ------- | ------- |
|
||||
| ST7789 | 4Wire-II | 1 | 240x320 | 24ms | 41 fps
|
||||
| ST7789 | 4Wire-II | 2 | 240x320 | 14ms | 72 fps
|
||||
| NV3037 | 4Wire-II | 2 | 320x480 | 27ms | 37 fps
|
||||
| ST7796 | 4Wire-II | 1 | 320x480 | 41ms | 24 fps
|
||||
|
||||
* 最高速率在LSPI配置51MHz时钟条件下测得,相关配置**lspi.c**
|
||||
|
||||
### ST7796S
|
||||
|
||||
* 读数据的时钟推荐12MHz,时钟太高会出现数据无法对齐
|
||||
* 读取LCD RAM数据使用0x3E寄存器
|
||||
* MADCTL 0x36 / MADCTR影响RGB排列顺序
|
||||
* RDDST 0x09 (0x53) 写入和读出的数据反色
|
||||
|
||||
MADCTL寄存器控制显示方向
|
||||
```bash
|
||||
Bit D7 MY
|
||||
0:Top to Bottom
|
||||
1:Bottom to Top
|
||||
|
||||
Bit D6 MX
|
||||
0:Left to Right (MX=0 MEM RGB)
|
||||
1:Right to Left (MX=1 MEM BGR)
|
||||
|
||||
Bit D5 MV
|
||||
1: Row/column exchange
|
||||
|
||||
Bit D4 ML (Vertical Refresh Order)
|
||||
0:LCD refresh Top to Bottom
|
||||
1:LCD refresh Bottom to Top
|
||||
|
||||
Bit D3 RGB
|
||||
0:RGB
|
||||
1:BGR
|
||||
|
||||
Bit D2 MH (Horizontal Refresh Order)
|
||||
0:Left to Right
|
||||
1:Right to Left
|
||||
```
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
#ifndef _DIS_FMT_H_
|
||||
#define _DIS_FMT_H_
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void yuv422ToRgb565(const void *inbuf, void *outbuf, int width, int height);
|
||||
void yuv420ToRgb565(const void* inbuf, void* outbuf, int width, int height);
|
||||
void rgb565ToYuv422(const void *inbuf, void *outbuf, int width, int height);
|
||||
void rgb565ToYuv420(const void* inbuf, void* outbuf, int width, int height);
|
||||
void rgb565ToYCbCr(const void *inbuf, void *outbuf, int width, int height);
|
||||
void yCbCrToRgb565(const void *inbuf, void *outbuf, int width, int height);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _DIS_FMT_H_ */
|
||||
|
@ -1,52 +0,0 @@
|
||||
#ifndef _LCD_COMM_H
|
||||
#define _LCD_COMM_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "ec7xx.h"
|
||||
#include "bsp.h"
|
||||
#include "lspi.h"
|
||||
|
||||
#define DMA_BULK_NUM (1023*8)
|
||||
#define DMA_DESC_MAX (160) // RGB888 man need big desc chain
|
||||
|
||||
|
||||
void lcdWriteCmd(uint8_t cmd);
|
||||
void lcdWriteData(uint8_t data);
|
||||
void lcdInterfaceType(uint8_t type);
|
||||
void lspiCmdSend(uint8_t cmd, uint8_t *data, uint8_t num);
|
||||
void lspiReadReg(uint8_t addr,uint8_t *data,uint16_t num, uint8_t dummyCycleLen);
|
||||
void lspiReadRam(uint32_t *data,uint32_t num);
|
||||
void lcdDrvDelay(uint32_t ms);
|
||||
void lspiFifoWrite(uint32_t data);
|
||||
|
||||
#if (BK_USE_PWM == 1)
|
||||
uint32_t millis(void);
|
||||
uint8_t lcdPwmBkLevel(uint8_t level);
|
||||
#endif
|
||||
|
||||
#if (BK_USE_GPIO == 1)
|
||||
void lcdGpioBkLevel(uint8_t level);
|
||||
#endif
|
||||
|
||||
typedef void (*lcdDmaCb)(uint32_t event);
|
||||
typedef void (*lcdUspCb)();
|
||||
|
||||
int dmaInit(lcdDmaCb cb);
|
||||
void lcdRst(uint32_t highUs, uint32_t lowUs);
|
||||
void dmaStartStop(bool start);
|
||||
int lspiDefaultCfg(lcdDrvFunc_t *lcd, lcdUspCb cb, uint32_t freq, uint8_t bpp);
|
||||
int lcdDmaTrans(lcdDrvFunc_t *lcd, void *sourceAddress, uint32_t totalLength);
|
||||
void lcdMspiSet(uint8_t enable, uint8_t addrLane, uint8_t dataLane, uint8_t instruction);
|
||||
void lcdMspiHsyncSet(uint8_t hsyncAddr, uint8_t hsyncInst, uint16_t vbpNum, uint16_t vfpNum);
|
||||
void lcdMspiVsyncSet(uint8_t vsyncEnable, uint8_t vsyncInst, uint8_t lspiDiv);
|
||||
void lcdCsnHighCycleMin(uint8_t lspiDiv);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* LCDCOMM_H */
|
||||
|
@ -1,41 +0,0 @@
|
||||
#ifndef LCD_AXS15231_
|
||||
#define LCD_AXS15231_
|
||||
|
||||
#define AXS15231_BPP (16) // 12: 444; 16:565; 18:666
|
||||
#define AXS15231_WIDTH (320)
|
||||
#define AXS15231_HEIGHT (480)
|
||||
#define AXS15231_FREQ (51*1024*1024)
|
||||
#define AXS15231_INTERFACE (SPI_3W_I)
|
||||
#define AXS15231_TIME_OF_FRAME (149356) // us
|
||||
#define AXS15231_TE_CYCLE (16742) // us
|
||||
#define AXS15231_TE_WAIT_TIME (623) // us
|
||||
#define AXS15231_X_OFFSET (0)
|
||||
#define AXS15231_Y_OFFSET (0)
|
||||
|
||||
#if (LCD_INTERFACE_8080 == 1)
|
||||
#if (AXS15231_INTERFACE != INTERFACE_8080)
|
||||
#error "Please choose 8080 interface for AXS15231_INTERFACE"
|
||||
#endif
|
||||
#elif (LCD_INTERFACE_SPI == 1)
|
||||
#if ((AXS15231_INTERFACE != SPI_3W_I) && (AXS15231_INTERFACE != SPI_3W_II) && (AXS15231_INTERFACE != SPI_4W_I) && (AXS15231_INTERFACE != SPI_4W_II))
|
||||
#error "Please choose SPI interface for AXS15231_INTERFACE"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#undef LCD_WIDTH
|
||||
#undef LCD_HEIGHT
|
||||
#define LCD_HEIGHT (AXS15231_HEIGHT)
|
||||
#define LCD_WIDTH (AXS15231_WIDTH)
|
||||
#define LCD_BPP_USE (AXS15231_BPP)
|
||||
#define LCD_INTERFACE (AXS15231_INTERFACE)
|
||||
#define LCD_FREQ (AXS15231_FREQ)
|
||||
#define LCD_X_OFFSET (AXS15231_X_OFFSET)
|
||||
#define LCD_Y_OFFSET (AXS15231_Y_OFFSET)
|
||||
|
||||
#define LCD_PIXEL (LCD_HEIGHT*LCD_WIDTH)
|
||||
#define LCD_TIME_OF_FRAME (AXS15231_TIME_OF_FRAME) // us
|
||||
#define LCD_TE_CYCLE (AXS15231_TE_CYCLE) // us
|
||||
#define LCD_TE_WAIT_TIME (AXS15231_TE_WAIT_TIME) // us
|
||||
|
||||
#endif
|
@ -1,23 +0,0 @@
|
||||
#ifndef LCD_NV3037_H_
|
||||
#define LCD_NV3037_H_
|
||||
|
||||
#define LCD_NV3037
|
||||
#define LCD_NAME "NV3037"
|
||||
#define LCD_BPP 16
|
||||
|
||||
#ifndef LCD_WIDTH_3037
|
||||
#define LCD_WIDTH_3037 320
|
||||
#undef LCD_WIDTH
|
||||
#define LCD_WIDTH LCD_WIDTH_3037
|
||||
#endif
|
||||
|
||||
#ifndef LCD_HEIGHT_3037
|
||||
#define LCD_HEIGHT_3037 480
|
||||
#undef LCD_HEIGHT
|
||||
#define LCD_HEIGHT LCD_HEIGHT_3037
|
||||
#endif
|
||||
|
||||
#ifndef LCD_SPI_DATA_LANE
|
||||
#define LCD_SPI_DATA_LANE 2
|
||||
#endif
|
||||
#endif
|
@ -1,36 +0,0 @@
|
||||
#ifndef LCD_CO5300_
|
||||
#define LCD_CO5300_
|
||||
|
||||
#define CO5300_BPP (16) // 16:565; 18:666 24:888
|
||||
#define CO5300_WIDTH (460)
|
||||
#define CO5300_HEIGHT (460)
|
||||
#define CO5300_FREQ (51*1024*1024)
|
||||
#define CO5300_INTERFACE (MSPI_4W_II)
|
||||
#define CO5300_TE_CYCLE (16327) // us
|
||||
#define CO5300_TE_WAIT_TIME (425) // us
|
||||
#define CO5300_X_OFFSET (0xa)
|
||||
#define CO5300_Y_OFFSET (0)
|
||||
|
||||
#if (ST8601_INTERFACE == MSPI_4W_II)
|
||||
#if (LCD_INTERFACE_MSPI != 1)
|
||||
#error "Please choose MSPI interface in RTE_Device.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#undef LCD_WIDTH
|
||||
#undef LCD_HEIGHT
|
||||
#define LCD_HEIGHT (CO5300_HEIGHT)
|
||||
#define LCD_WIDTH (CO5300_WIDTH)
|
||||
#define DEFAULT_INST (0x2)
|
||||
#define LCD_BPP_USE (CO5300_BPP)
|
||||
#define LCD_INTERFACE (CO5300_INTERFACE)
|
||||
#define LCD_FREQ (CO5300_FREQ)
|
||||
#define LCD_X_OFFSET (CO5300_X_OFFSET)
|
||||
#define LCD_Y_OFFSET (CO5300_Y_OFFSET)
|
||||
|
||||
#define LCD_PIXEL (LCD_HEIGHT*LCD_WIDTH)
|
||||
#define LCD_TE_CYCLE (CO5300_TE_CYCLE) // us
|
||||
#define LCD_TE_WAIT_TIME (CO5300_TE_WAIT_TIME) // us
|
||||
|
||||
#endif
|
@ -1,12 +0,0 @@
|
||||
#ifndef LCDDEV_7567_H
|
||||
#define LCDDEV_7567_H
|
||||
|
||||
|
||||
#include "lcdDrv.h"
|
||||
|
||||
#define HEIGHT_7567 (64)
|
||||
#define WIDTH_7567 (128)
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,12 +0,0 @@
|
||||
#ifndef LCDDEV_7571_H
|
||||
#define LCDDEV_7571_H
|
||||
|
||||
|
||||
#include "lcdDrv.h"
|
||||
|
||||
#define HEIGHT_7571 (128)
|
||||
#define WIDTH_7571 (128)
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,42 +0,0 @@
|
||||
#ifndef LCD_ST7789_
|
||||
#define LCD_ST7789_
|
||||
|
||||
#define ST7789_BPP (16) // 12: 444; 16:565; 18:666
|
||||
#define ST7789_WIDTH (240)
|
||||
#define ST7789_HEIGHT (320)
|
||||
#define ST7789_FREQ (51*1024*1024)
|
||||
#define ST7789_INTERFACE (SPI_4W_II)
|
||||
#define ST7789_TIME_OF_FRAME (149356) // us
|
||||
#define ST7789_TE_CYCLE (16742) // us
|
||||
#define ST7789_TE_WAIT_TIME (623) // us
|
||||
#define ST7789_X_OFFSET (0)
|
||||
#define ST7789_Y_OFFSET (0)
|
||||
|
||||
#if (LCD_INTERFACE_8080 == 1)
|
||||
#if (ST7789_INTERFACE != INTERFACE_8080)
|
||||
#error "Please choose 8080 interface for ST7789_INTERFACE"
|
||||
#endif
|
||||
#elif (LCD_INTERFACE_SPI == 1)
|
||||
#if ((ST7789_INTERFACE != SPI_3W_I) && (ST7789_INTERFACE != SPI_3W_II) && (ST7789_INTERFACE != SPI_4W_I) && (ST7789_INTERFACE != SPI_4W_II))
|
||||
#error "Please choose SPI interface for ST7789_INTERFACE"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#undef LCD_WIDTH
|
||||
#undef LCD_HEIGHT
|
||||
#define LCD_HEIGHT (ST7789_HEIGHT)
|
||||
#define LCD_WIDTH (ST7789_WIDTH)
|
||||
#define LCD_BPP_USE (ST7789_BPP)
|
||||
#define LCD_INTERFACE (ST7789_INTERFACE)
|
||||
#define LCD_FREQ (ST7789_FREQ)
|
||||
#define LCD_X_OFFSET (ST7789_X_OFFSET)
|
||||
#define LCD_Y_OFFSET (ST7789_Y_OFFSET)
|
||||
|
||||
#define LCD_PIXEL (LCD_HEIGHT*LCD_WIDTH)
|
||||
#define LCD_FREQ (ST7789_FREQ)
|
||||
#define LCD_TIME_OF_FRAME (ST7789_TIME_OF_FRAME) // us
|
||||
#define LCD_TE_CYCLE (ST7789_TE_CYCLE) // us
|
||||
#define LCD_TE_WAIT_TIME (ST7789_TE_WAIT_TIME) // us
|
||||
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
#ifndef LCD_ST77903_
|
||||
#define LCD_ST77903_
|
||||
|
||||
#define ST77903_BPP (16) // 16:565; 18:666 24:888
|
||||
#define ST77903_WIDTH (400)
|
||||
#define ST77903_HEIGHT (400)
|
||||
#define ST77903_FREQ (8*1024*1024)
|
||||
#define ST77903_INTERFACE (MSPI_4W_II)
|
||||
#define BIST_TEST (0)
|
||||
#define ST77903_TIME_OF_FRAME (149356) // us
|
||||
#define ST77903_TE_CYCLE (16742) // us
|
||||
#define ST77903_TE_WAIT_TIME (623) // us
|
||||
#define ST77903_X_OFFSET (0)
|
||||
#define ST77903_Y_OFFSET (0)
|
||||
|
||||
#if (ST77903_INTERFACE == MSPI_4W_II)
|
||||
#if (LCD_INTERFACE_MSPI != 1)
|
||||
#error "Please choose MSPI interface in RTE_Device.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#undef LCD_WIDTH
|
||||
#undef LCD_HEIGHT
|
||||
#define LCD_HEIGHT (ST77903_HEIGHT)
|
||||
#define LCD_WIDTH (ST77903_WIDTH)
|
||||
#define DEFAULT_INST (0xde)
|
||||
#define LCD_BPP_USE (ST77903_BPP)
|
||||
#define LCD_INTERFACE (ST77903_INTERFACE)
|
||||
#define LCD_FREQ (ST77903_FREQ)
|
||||
#define LCD_X_OFFSET (ST77903_X_OFFSET)
|
||||
#define LCD_Y_OFFSET (ST77903_Y_OFFSET)
|
||||
|
||||
#define LCD_PIXEL (LCD_HEIGHT*LCD_WIDTH)
|
||||
#define LCD_TIME_OF_FRAME (ST77903_TIME_OF_FRAME) // us
|
||||
#define LCD_TE_CYCLE (ST77903_TE_CYCLE) // us
|
||||
#define LCD_TE_WAIT_TIME (ST77903_TE_WAIT_TIME) // us
|
||||
|
||||
|
||||
#endif
|
@ -1,20 +0,0 @@
|
||||
#ifndef LCD_ST7796_H
|
||||
#define LCD_ST7796_H
|
||||
|
||||
#define LCD_ST7796
|
||||
#define LCD_NAME "ST7796"
|
||||
#define LCD_BPP 16
|
||||
|
||||
#ifndef LCD_WIDTH_7796
|
||||
#define LCD_WIDTH_7796 320
|
||||
#undef LCD_WIDTH
|
||||
#define LCD_WIDTH LCD_WIDTH_7796
|
||||
#endif
|
||||
|
||||
#ifndef LCD_HEIGHT_7796
|
||||
#define LCD_HEIGHT_7796 480
|
||||
#undef LCD_HEIGHT
|
||||
#define LCD_HEIGHT LCD_HEIGHT_7796
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,38 +0,0 @@
|
||||
#ifndef LCD_SH8601_
|
||||
#define LCD_SH8601_
|
||||
|
||||
#define SH8601_BPP (16) // 16:565; 18:666 24:888
|
||||
#define SH8601_WIDTH (466)
|
||||
#define SH8601_HEIGHT (466)
|
||||
#define SH8601_FREQ (8*1024*1024)
|
||||
#define SH8601_INTERFACE (MSPI_4W_II)
|
||||
#define SH8601_TIME_OF_FRAME (167331) // us
|
||||
#define SH8601_TE_CYCLE (16742) // us
|
||||
#define SH8601_TE_WAIT_TIME (623) // us
|
||||
#define SH8601_X_OFFSET (0)
|
||||
#define SH8601_Y_OFFSET (0)
|
||||
|
||||
#if (ST8601_INTERFACE == MSPI_4W_II)
|
||||
#if (LCD_INTERFACE_MSPI != 1)
|
||||
#error "Please choose MSPI interface in RTE_Device.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#undef LCD_WIDTH
|
||||
#undef LCD_HEIGHT
|
||||
#define LCD_HEIGHT (SH8601_HEIGHT)
|
||||
#define LCD_WIDTH (SH8601_WIDTH)
|
||||
#define DEFAULT_INST (0x2)
|
||||
#define LCD_BPP_USE (SH8601_BPP)
|
||||
#define LCD_INTERFACE (SH8601_INTERFACE)
|
||||
#define LCD_FREQ (SH8601_FREQ)
|
||||
#define LCD_X_OFFSET (SH8601_X_OFFSET)
|
||||
#define LCD_Y_OFFSET (SH8601_Y_OFFSET)
|
||||
|
||||
#define LCD_PIXEL (LCD_HEIGHT*LCD_WIDTH)
|
||||
#define LCD_TIME_OF_FRAME (SH8601_TIME_OF_FRAME) // us
|
||||
#define LCD_TE_CYCLE (SH8601_TE_CYCLE) // us
|
||||
#define LCD_TE_WAIT_TIME (SH8601_TE_WAIT_TIME) // us
|
||||
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
#ifndef LCD_GC9307_
|
||||
#define LCD_GC9307_
|
||||
|
||||
#define GC9307_BPP (16) // 12: 444; 16:565; 18:666
|
||||
#define GC9307_WIDTH (240)
|
||||
#define GC9307_HEIGHT (320)
|
||||
#define GC9307_FREQ (51*1024*1024)
|
||||
#define GC9307_INTERFACE (SPI_4W_I)
|
||||
#define GC9307_TIME_OF_FRAME (149356) // us
|
||||
#define GC9307_TE_CYCLE (16742) // us
|
||||
#define GC9307_TE_WAIT_TIME (623) // us
|
||||
#define GC9307_X_OFFSET (0)
|
||||
#define GC9307_Y_OFFSET (0)
|
||||
|
||||
#if (LCD_INTERFACE_8080 == 1)
|
||||
#if (GC9307_INTERFACE != INTERFACE_8080)
|
||||
#error "Please choose 8080 interface for GC9307_INTERFACE"
|
||||
#endif
|
||||
#elif (LCD_INTERFACE_SPI == 1)
|
||||
#if ((GC9307_INTERFACE != SPI_3W_I) && (GC9307_INTERFACE != SPI_3W_II) && (GC9307_INTERFACE != SPI_4W_I) && (GC9307_INTERFACE != SPI_4W_II))
|
||||
#error "Please choose SPI interface for GC9307_INTERFACE"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#undef LCD_WIDTH
|
||||
#undef LCD_HEIGHT
|
||||
#define LCD_HEIGHT (GC9307_HEIGHT)
|
||||
#define LCD_WIDTH (GC9307_WIDTH)
|
||||
#define LCD_BPP_USE (GC9307_BPP)
|
||||
#define LCD_INTERFACE (GC9307_INTERFACE)
|
||||
#define LCD_X_OFFSET (GC9307_X_OFFSET)
|
||||
#define LCD_Y_OFFSET (GC9307_Y_OFFSET)
|
||||
|
||||
#define LCD_PIXEL (LCD_HEIGHT*LCD_WIDTH)
|
||||
#define LCD_TIME_OF_FRAME (GC9307_TIME_OF_FRAME) // us
|
||||
#define LCD_TE_CYCLE (GC9307_TE_CYCLE) // us
|
||||
#define LCD_TE_WAIT_TIME (GC9307_TE_WAIT_TIME) // us
|
||||
|
||||
#endif
|
@ -1,236 +0,0 @@
|
||||
#ifndef _LCD_DRV_H
|
||||
#define _LCD_DRV_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "ec7xx.h"
|
||||
#include "bsp.h"
|
||||
#include "lspi.h"
|
||||
#include "disFormat.h"
|
||||
|
||||
#define LCD_COLOR565(r, g, b) (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3))
|
||||
|
||||
#define RED (0x001f)
|
||||
#define GREEN (0x07e0)
|
||||
#define BLUE (0xf800)
|
||||
#define WHITE (0xffff)
|
||||
#define BLACK (0x0000)
|
||||
#define YELLOW (0xffe0)
|
||||
#define PURPLE (0x8010)
|
||||
#define GOLDEN (0xFEA0)
|
||||
|
||||
#define SPI_3W_I (0)
|
||||
#define SPI_3W_II (1)
|
||||
#define SPI_4W_I (2)
|
||||
#define SPI_4W_II (3)
|
||||
#define MSPI_4W_II (4)
|
||||
#define INTERFACE_8080 (5)
|
||||
|
||||
|
||||
#define LCD_RST_LOW do {GPIO_pinWrite(LSPI_RST_GPIO_INSTANCE, 1 << LSPI_RST_GPIO_PIN, 0);}while(0)
|
||||
#define LCD_RST_HIGH do {GPIO_pinWrite(LSPI_RST_GPIO_INSTANCE, 1 << LSPI_RST_GPIO_PIN, 1 << LSPI_RST_GPIO_PIN);}while(0)
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t cmd;
|
||||
uint8_t len;
|
||||
uint8_t data[32];
|
||||
}initLine_t;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
stopPreview = 0,
|
||||
startPreview = 1,
|
||||
}camPreviewStartStop_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
cbForCam = 0,
|
||||
cbForFill = 1,
|
||||
}uspCbRole_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TE_RISE_EDGE = 0,
|
||||
TE_FALL_EDGE = 1,
|
||||
}teEdgeSel_e;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/* @---> X
|
||||
|
|
||||
Y
|
||||
*/
|
||||
DIS_DIR_LRTB, /**< From left to right then from top to bottom, this consider as the original direction of the screen */
|
||||
|
||||
/* Y
|
||||
|
|
||||
@---> X
|
||||
*/
|
||||
DIS_DIR_LRBT, /**< From left to right then from bottom to top */
|
||||
|
||||
/* X <---@
|
||||
|
|
||||
Y
|
||||
*/
|
||||
DIS_DIR_RLTB, /**< From right to left then from top to bottom */
|
||||
|
||||
/* Y
|
||||
|
|
||||
X <---@
|
||||
*/
|
||||
DIS_DIR_RLBT, /**< From right to left then from bottom to top */
|
||||
|
||||
/* @---> Y
|
||||
|
|
||||
X
|
||||
*/
|
||||
DIS_DIR_TBLR, /**< From top to bottom then from left to right */
|
||||
|
||||
/* X
|
||||
|
|
||||
@---> Y
|
||||
*/
|
||||
DIS_DIR_BTLR, /**< From bottom to top then from left to right */
|
||||
|
||||
/* Y <---@
|
||||
|
|
||||
X
|
||||
*/
|
||||
DIS_DIR_TBRL, /**< From top to bottom then from right to left */
|
||||
|
||||
/* X
|
||||
|
|
||||
Y <---@
|
||||
*/
|
||||
DIS_DIR_BTRL, /**< From bottom to top then from right to left */
|
||||
|
||||
DIS_DIR_MAX,
|
||||
/* Another way to represent rotation with 3 bit*/
|
||||
DIS_MIRROR_X = 0x40, /**< Mirror X-axis */
|
||||
DIS_MIRROR_Y = 0x20, /**< Mirror Y-axis */
|
||||
DIS_SWAP_XY = 0x80, /**< Swap XY axis */
|
||||
} DisDirection_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LCD_POWER_OFF = 0,
|
||||
LCD_POWER_ON = 1
|
||||
}lcdPowerOnOff_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CAM_PREVIEW_SET_AUTO = 0,
|
||||
CAM_PREVIEW_SET_MANUAL = 1
|
||||
}lcdPreviewModeSel_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t rowScaleFrac;
|
||||
uint16_t colScaleFrac;
|
||||
uint16_t tailorLeft;
|
||||
uint16_t tailorRight;
|
||||
uint16_t tailorTop;
|
||||
uint16_t tailorBottom;
|
||||
}lcdPreviewManulItem_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
lcdPreviewModeSel_e previewModeSel;
|
||||
lcdPreviewManulItem_t previewManulSet;
|
||||
}lcdIoCtrl_t;
|
||||
|
||||
typedef struct _lcdDrvFunc_t lcdDrvFunc_t;
|
||||
typedef void (*lspiErrCb)(uint32_t stats);
|
||||
|
||||
typedef struct _lcdDrvFunc_t
|
||||
{
|
||||
uint32_t id;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint32_t freq;
|
||||
uint8_t bpp;
|
||||
initLine_t *initRegTbl;
|
||||
uint32_t initRegTblLen;
|
||||
uint8_t dir; // vertical: 0; horizontal: 1;
|
||||
|
||||
int (*init) (lcdDrvFunc_t *lcd, void* uspCb, void* dmaCb, uint32_t freq, uint8_t bpp);
|
||||
void (*drawPoint) (lcdDrvFunc_t *lcd, uint16_t x, uint16_t y, uint32_t dataWrite);
|
||||
uint32_t (*setWindow) (lcdDrvFunc_t *lcd, uint16_t sx, uint16_t ex, uint16_t sy, uint16_t ey);
|
||||
int (*fill) (lcdDrvFunc_t *lcd, uint32_t fillLen, uint8_t *buf);
|
||||
void (*backLight) (lcdDrvFunc_t *lcd, uint8_t level);
|
||||
void (*powerOnOff) (lcdDrvFunc_t *lcd, lcdPowerOnOff_e onoff);
|
||||
void (*startStop) (lcdDrvFunc_t *lcd, bool startOrStop);
|
||||
void (*startStopPreview) (lcdDrvFunc_t *lcd, camPreviewStartStop_e previewStartStop);
|
||||
void (*uspIrq4CamCb) (lcdDrvFunc_t *lcd);
|
||||
void (*uspIrq4FillCb) (lcdDrvFunc_t *lcd);
|
||||
void (*registerUspIrqCb) (lcdDrvFunc_t *lcd, uspCbRole_e who);
|
||||
void (*unregisterUspIrqCb) (lcdDrvFunc_t *lcd, uspCbRole_e who);
|
||||
int (*direction) (lcdDrvFunc_t *lcd, DisDirection_e dir);
|
||||
int (*close) (lcdDrvFunc_t *lcd);
|
||||
}lcdDrvFunc_t;
|
||||
|
||||
|
||||
#if (LCD_ST7789_ENABLE == 1)
|
||||
#include "lcdDev_7789.h"
|
||||
extern lcdDrvFunc_t st7789Drv;
|
||||
#elif (LCD_SH8601_ENABLE == 1)
|
||||
#include "lcdDev_8601.h"
|
||||
extern lcdDrvFunc_t sh8601Drv;
|
||||
#elif (LCD_ST7571_ENABLE == 1)
|
||||
#include "lcdDev_7571.h"
|
||||
extern lcdDrvFunc_t st7571Drv;
|
||||
#elif (LCD_ST7567_ENABLE == 1)
|
||||
#include "lcdDev_7567.h"
|
||||
extern lcdDrvFunc_t st7567Drv;
|
||||
#elif (LCD_ST77903_ENABLE == 1)
|
||||
#include "lcdDev_77903.h"
|
||||
extern lcdDrvFunc_t st77903Drv;
|
||||
#elif (LCD_GC9307_ENABLE == 1)
|
||||
#include "lcdDev_9307.h"
|
||||
extern lcdDrvFunc_t gc9307Drv;
|
||||
#elif (LCD_AXS15231_ENABLE == 1)
|
||||
#include "lcdDev_15231.h"
|
||||
extern lcdDrvFunc_t axs15231Drv;
|
||||
#elif (LCD_CO5300_ENABLE == 1)
|
||||
#include "lcdDev_5300.h"
|
||||
extern lcdDrvFunc_t co5300Drv;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void lcdRegInit(uint32_t id);
|
||||
lcdDrvFunc_t* lcdOpen(uint32_t id, void* uspCb, void* dmaCb);
|
||||
int lcdClose(lcdDrvFunc_t *pdrv);
|
||||
void lcdIoInit(bool isAonIO);
|
||||
void lcdRegisterSlp1Cb(lcdSlp1Cb_fn cb);
|
||||
int lcdDirection(lcdDrvFunc_t *pdrv, DisDirection_e dir);
|
||||
int lcdFill(lcdDrvFunc_t *pdrv, uint32_t fillLen, uint8_t* buf);
|
||||
void lcdDrawPoint(lcdDrvFunc_t *pdrv, uint16_t x, uint16_t y, uint32_t dataWrite);
|
||||
void camPreview(lcdDrvFunc_t *pdrv, camPreviewStartStop_e previewStartStop);
|
||||
void lcdBackLight(lcdDrvFunc_t *pdrv, uint8_t level);
|
||||
uint32_t lcdSetWindow(lcdDrvFunc_t *pdrv, uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey);
|
||||
void lspiRstAndClearFifo();
|
||||
void lspiRegisterErrStatsCb(lspiErrCb errCb);
|
||||
void lspiCheckErrStats();
|
||||
void imageRotateColor(uint8_t* src, uint32_t width, uint32_t height, uint8_t* dst, uint8_t bpp);
|
||||
void imageRotateGray(uint8_t* src, uint32_t width, uint32_t height, uint8_t* dst);
|
||||
void yuv422ToRgb565_2(const void* inbuf, void* outbuf, int width, int height);
|
||||
void lcdIoCtrl(lcdDrvFunc_t *lcd, lcdIoCtrl_t ioCtrl);
|
||||
void lcdConfigReg(lcdDrvFunc_t *lcd, uint8_t cmd, uint8_t *data, uint8_t dataLen);
|
||||
#if ((defined CHIP_EC718) && !(defined TYPE_EC718M)) || (defined CHIP_EC716)
|
||||
void calTe(uint32_t totalBytes, uint16_t sy);
|
||||
#else // 719
|
||||
void calTe(teEdgeSel_e teEdge, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
#ifndef _NTC_H
|
||||
#define _NTC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Get NTC temperature
|
||||
|
||||
Vref(AIO1 output 1200000 uV)
|
||||
v
|
||||
|
|
||||
|
|
||||
+-+
|
||||
| |
|
||||
| | R = 10 Kohm
|
||||
| |
|
||||
+-+
|
||||
|--------->(AIO2)
|
||||
+-+
|
||||
| |
|
||||
| | Rntc
|
||||
| |
|
||||
+-+
|
||||
|
|
||||
-----
|
||||
--- (GND)
|
||||
-
|
||||
|
||||
\param[in] adcInputVoltage ADC input voltage in unit of uV
|
||||
\return temperature in unit of mili degree centigrade
|
||||
*/
|
||||
int32_t ntcGetTemperature(int32_t adcInputVoltage);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NTC_H */
|
@ -1,852 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2019-, Copyrigths of EigenComm Ltd.
|
||||
* File name: plat_config.h
|
||||
* Description: platform configuration header file
|
||||
* History: Rev1.0 2019-01-18
|
||||
* Rev1.1 2019-11-27 Reimplement file operations with OSA APIs(LFS wrapper), not directly using LFS APIs in case of file system replacement
|
||||
* Rev1.2 2020-01-01 Separate plat config into two parts, FS and raw flash
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _PLAT_CONFIG_H
|
||||
#define _PLAT_CONFIG_H
|
||||
|
||||
#include "Driver_Common.h"
|
||||
#include "cmsis_compiler.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
//use FEATURE_PLAT_CFG_FS_SUP_USBNET_ATA not DFEATURE_USBNET_ATA_FOR_AP, the plat cfgfs structure is same for bootloader and ap
|
||||
#ifndef FEATURE_PLAT_CFG_FS_SUP_USBNET_ATA
|
||||
|
||||
#define FS_PLAT_CONFIG_FILE_CURRENT_VERSION (0)
|
||||
#else
|
||||
// the version 1 use scalable plat cfg fs data structure, it's more useful when then data config grows dynamically
|
||||
#define FS_PLAT_CONFIG_FILE_CURRENT_VERSION (1)
|
||||
#endif
|
||||
|
||||
#define RAW_FLASH_PLAT_CONFIG_FILE_CURRENT_VERSION (1)
|
||||
|
||||
|
||||
/** \brief config file header typedef */
|
||||
__PACKED_STRUCT _config_file_header
|
||||
{
|
||||
uint16_t fileBodySize; /**< size of file body, in unit of byte */
|
||||
uint8_t version; /**< file version, this field shall be updated when file structure is changed */
|
||||
uint8_t checkSum; /**< check sum value of file body */
|
||||
};
|
||||
typedef struct _config_file_header config_file_header_t;
|
||||
|
||||
/** \brief typedef of platform configuration stored in fs */
|
||||
typedef __PACKED_UNION _EPAT_atPortFrameFormat
|
||||
{
|
||||
uint32_t wholeValue;
|
||||
__PACKED_STRUCT _config
|
||||
{
|
||||
uint32_t dataBits : 3;
|
||||
uint32_t parity : 2;
|
||||
uint32_t stopBits : 2;
|
||||
uint32_t flowControl : 3;
|
||||
} config;
|
||||
} atPortFrameFormat_t;
|
||||
|
||||
|
||||
|
||||
// ulg port enum
|
||||
typedef enum
|
||||
{
|
||||
PLAT_CFG_ULG_PORT_USB=0,
|
||||
PLAT_CFG_ULG_PORT_UART,
|
||||
PLAT_CFG_ULG_PORT_MIX,
|
||||
PLAT_CFG_ULG_PORT_SRAM,
|
||||
PLAT_CFG_ULG_PORT_MAX
|
||||
} PlatCfgUlgPort_e;
|
||||
|
||||
|
||||
|
||||
#if (FS_PLAT_CONFIG_FILE_CURRENT_VERSION==0)
|
||||
/*verion 0 orignal plat cfg, no change the data structure compare to released sdk,
|
||||
so no merge needed when new sdk release, and plat cfg fs will also not change
|
||||
when new sdk burned. */
|
||||
|
||||
/** \brief typedef of platform configuration stored in fs */
|
||||
typedef __PACKED_STRUCT _NVM_EPAT_plat_config
|
||||
{
|
||||
/** PM on/off flag
|
||||
* valid value:
|
||||
* 0x504D5544 -- PM is disabled, "PMUD"
|
||||
* 0x504D5545 -- PM is enabled, "PMUE"
|
||||
*/
|
||||
uint32_t enablePM;
|
||||
|
||||
/** sleep mode
|
||||
* valid value:
|
||||
* 0 -- dummy
|
||||
* 1 -- dummy
|
||||
*/
|
||||
uint8_t sleepMode;
|
||||
|
||||
/** wait n ms before sleep, when wakeup from pad
|
||||
* valid value:
|
||||
* 0 -- do not wait
|
||||
* x -- wait x ms
|
||||
*/
|
||||
uint32_t slpWaitTime;
|
||||
|
||||
/** AT baudrate,for AP only
|
||||
* should be equal to 'atPortBaudRate' in struct plat_config_raw_flash_t
|
||||
*/
|
||||
uint32_t atPortBaudRate;
|
||||
|
||||
/** AT port frame format*/
|
||||
atPortFrameFormat_t atPortFrameFormat;
|
||||
|
||||
/** ECQSCLK config
|
||||
* valid value:
|
||||
* 0 -- ECQSCLK set to 0
|
||||
* 1 -- ECQSCLK set to 1
|
||||
*/
|
||||
uint8_t ecSclkCfg;
|
||||
|
||||
|
||||
} plat_config_fs_t;
|
||||
|
||||
#else
|
||||
/*version 1, scalable plat cfg, two method to update the config data structure
|
||||
1.The total data size for scalable area does not change when some new config data added, the reserved data array still have some bytes spare,
|
||||
the added data just use one or some bytes of the reserved data array.
|
||||
When the new config data added the upgrade is compatitble. and downgrade is also compatitble too.
|
||||
If the new config data added is a automatical parameter, such as the usbNetAdaptResult, it's automatically setted by the UE connected with different Host Windows or Ubuntu.
|
||||
If the new config data added is not a automatical parameter, it should be setted to a meaningful value otherwise when upgrade ,it may not work correctly as required by the default 0.
|
||||
|
||||
In this case, the plat cfg fs data will not be overwrited to fs when both upgarde or downgrade initlal between the old/new sdk versions that plat cfg fs data size same .
|
||||
it's more convenient for lightly upgrade or downgrade.
|
||||
|
||||
2.The total data size for scalable area is increased when some new config data added. because the reserved data array has no some bytes spare,
|
||||
Increase the scalable area with some bytes each time, such as each time 16 bytes(_NVM_PLATCFG_SCALE_UNIT_SZ) for example. use one or some of the increased bytes by new added parameter,
|
||||
some other bytes defined as reserverd data array.
|
||||
In this case, the plat cfg fs data will be writed when upgrade or downgrade ocurrs.
|
||||
|
||||
Set recPrevArAllSzForUpg = scaleAreaAllSize - SCALE_AREA_SCALE_UNIT_SIZE
|
||||
|
||||
|
||||
2.1 Upgarde from previous plat cfg fs structure to a new added parameter new plat cfg fs structure.
|
||||
Provided condition: readed scalable area total size from plat cfg fs is not same with current scaleAreaAllSize real size
|
||||
|
||||
|
||||
If the readed scalable area total size from plat cfg fs is same with recPrevArAllSzForUpg, then it's upgradable.
|
||||
If not same with recPrevArAllSzForUpg, then it's not upgardable because may have a lot of difference between old/new versions.
|
||||
|
||||
2.2 Downgrade from a new added parameter new plat cfg fs structure to an old plat cfg fs structure.
|
||||
Provided condition: readed scalable area total size from plat cfg fs is not same with current scaleAreaAllSize var
|
||||
|
||||
If the readed recPrevArAllSzForUpg from plat cfg fs is current scaleAreaAllSize real size, then it's downgradable.
|
||||
If recPrevArAllSzForUpg not same with current scaleAreaAllSize real size, then it's not downgradable because may have a lot of difference between old/new versions.
|
||||
*/
|
||||
|
||||
#define _NVM_PLATCFG_SCALE_UNIT_SZ 16
|
||||
|
||||
|
||||
// S 53 C 43 A 41 L 4C
|
||||
#define PLAT_CFG_SCALE_START_MARK 0x4353
|
||||
#define PLAT_CFG_SCALE_END_MARK 0x4C41
|
||||
|
||||
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP_CNT 1
|
||||
#define PLAT_CFG_FIX_BASE_SIZE 18
|
||||
|
||||
#define SCALE_AREA_GRP_UNIT_SIZE 16
|
||||
#define PLAT_CFG_GRP0_RSVBYTES_NUM 15
|
||||
#define PLAT_CFG_GRP0_TOKBYTES_NUM (SCALE_AREA_GRP_UNIT_SIZE-PLAT_CFG_GRP0_RSVBYTES_NUM)
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP_DATA_X(_TYPE_XX, __NAME_XX) _TYPE_XX __NAME_XX
|
||||
#define PLAT_CFG_DATA_0(_TYPE_XX, __NAME_XX) PLAT_CFG_DATA_X(_TYPE_XX, __NAME_XX)
|
||||
|
||||
#define PLAT_CFG_GRP_RSV_BYTE_X(__GRP_XX, __IDX_XX) uint8_t rsvBytes_##__GRP_XX##__IDX_XX
|
||||
|
||||
#define PLAT_CFG_GRP0_ALL_TOK_BYTES() \
|
||||
uint8_t usbNetAdaptResult;
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_0() PLAT_CFG_GRP_RSV_BYTE_X(0, 0);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_1() PLAT_CFG_GRP_RSV_BYTE_X(0, 1);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_2() PLAT_CFG_GRP_RSV_BYTE_X(0, 2);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_3() PLAT_CFG_GRP_RSV_BYTE_X(0, 3);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_4() PLAT_CFG_GRP_RSV_BYTE_X(0, 4);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_5() PLAT_CFG_GRP_RSV_BYTE_X(0, 5);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_6() PLAT_CFG_GRP_RSV_BYTE_X(0, 6);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_7() PLAT_CFG_GRP_RSV_BYTE_X(0, 7);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_8() PLAT_CFG_GRP_RSV_BYTE_X(0, 8);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_9() PLAT_CFG_GRP_RSV_BYTE_X(0, 9);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_10() PLAT_CFG_GRP_RSV_BYTE_X(0, 10);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_11() PLAT_CFG_GRP_RSV_BYTE_X(0, 11);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_12() PLAT_CFG_GRP_RSV_BYTE_X(0, 12);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_13() PLAT_CFG_GRP_RSV_BYTE_X(0, 13);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_14() PLAT_CFG_GRP_RSV_BYTE_X(0, 14);
|
||||
#define PLAT_CFG_GRP0_RSVBYTE_15() PLAT_CFG_GRP_RSV_BYTE_X(0, 15);
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_0() PLAT_CFG_GRP0_RSVBYTE_0()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_1() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_0() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_1()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_2() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_1() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_2()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_3() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_2() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_3()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_4() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_3() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_4()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_5() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_4 ()\
|
||||
PLAT_CFG_GRP0_RSVBYTE_5()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_6() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_5() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_6()
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_7() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_6() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_7()
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_8() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_7() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_8()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_9() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_8() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_9()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_10() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_9() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_10()
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_11() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_10() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_11()
|
||||
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_12() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_11() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_12()
|
||||
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_13() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_12() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_13()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_14() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_13() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_14()
|
||||
|
||||
#define PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_15() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_14() \
|
||||
PLAT_CFG_GRP0_RSVBYTE_15()
|
||||
|
||||
|
||||
#if (PLAT_CFG_GRP0_RSVBYTES_NUM== 0)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==1)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_0()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==2)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_1()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==3)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_2()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==4)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_3()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==5)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_4()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==6)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_5()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==7)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_6()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==8)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_7()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM== 9)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_8()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==10)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_9()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==11)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_10)
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==12)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_11)
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==13)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_12()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==14)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_13()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==15)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_14()
|
||||
#elif (PLAT_CFG_GRP0_RSVBYTES_NUM==16)
|
||||
#define PLAT_CFG_GRP0_ALL_RSV_BYTES() PLAT_CFG_GRP0_RANGE_RSV_BYTES_0_15()
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef __PACKED_STRUCT plat_cfg_sc_grp0_tok_tag {
|
||||
PLAT_CFG_GRP0_ALL_TOK_BYTES()
|
||||
}plat_cfg_sc_grp0_tok_st;
|
||||
|
||||
|
||||
typedef __PACKED_STRUCT plat_cfg_sc_grp0_all_data_tag {
|
||||
PLAT_CFG_GRP0_ALL_TOK_BYTES()
|
||||
PLAT_CFG_GRP0_ALL_RSV_BYTES()
|
||||
}plat_cfg_sc_grp0_all_data_st;
|
||||
|
||||
|
||||
#define SIZE_OF_TYPE_EQUAL_TO_SZX(type_x, size_x) \
|
||||
static inline char size_of##type_x##_equal_to_##size_x(void) { \
|
||||
char __dummy1[sizeof(type_x) - size_x]; \
|
||||
char __dummy2[size_x-sizeof(type_x)]; \
|
||||
return __dummy1[-1]+__dummy2[-1]; \
|
||||
}
|
||||
|
||||
#define SIZE_OF_TYPE_EQUAL_TO_CALX(type_x, cal_sz_x) \
|
||||
static inline char size_of##type_x##_equal_to_cal_sz_x(void) { \
|
||||
char __dummy1[sizeof(type_x) - (cal_sz_x)]; \
|
||||
char __dummy2[(cal_sz_x)-sizeof(type_x)]; \
|
||||
return __dummy1[-1]+__dummy2[-1]; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef __PACKED_STRUCT _NVM_EPAT_plat_config
|
||||
{
|
||||
/*do not change any variable function or name of base fix area if want to upgrade ,
|
||||
because when sync para from prev plat config scale fs the para may be syncd unmatched and used uncorrectly*/
|
||||
|
||||
/** PM on/off flag
|
||||
* valid value:
|
||||
* 0x504D5544 -- PM is disabled, "PMUD"
|
||||
* 0x504D5545 -- PM is enabled, "PMUE"
|
||||
*/
|
||||
uint32_t enablePM;
|
||||
|
||||
/** sleep mode
|
||||
* valid value:
|
||||
* 0 -- dummy
|
||||
* 1 -- dummy
|
||||
*/
|
||||
uint8_t sleepMode;
|
||||
|
||||
/** wait n ms before sleep, when wakeup from pad
|
||||
* valid value:
|
||||
* 0 -- do not wait
|
||||
* x -- wait x ms
|
||||
*/
|
||||
uint32_t slpWaitTime;
|
||||
|
||||
/** AT baudrate,for AP only
|
||||
* should be equal to 'atPortBaudRate' in struct plat_config_raw_flash_t
|
||||
*/
|
||||
uint32_t atPortBaudRate;
|
||||
|
||||
/** AT port frame format*/
|
||||
atPortFrameFormat_t atPortFrameFormat;
|
||||
|
||||
/** ECQSCLK config
|
||||
* valid value:
|
||||
* 0 -- ECQSCLK set to 0
|
||||
* 1 -- ECQSCLK set to 1
|
||||
*/
|
||||
uint8_t ecSclkCfg;
|
||||
|
||||
|
||||
/*Mark for reserve bytes area*/
|
||||
uint16_t scaleAreaStartMark;
|
||||
|
||||
/*scalable area data define*/
|
||||
/*do not change any variable function or name of used scale area data,
|
||||
because when sync para from prev plat config scale fs the para may be syncd unmatched and used uncorrectly*/
|
||||
//scaleAreaPureData0
|
||||
//uint8_t usbNetAdaptResult;/* 7-4: Adapt valid, 3-0:adapt result*/
|
||||
|
||||
|
||||
//scaleAreaPureData1- scaleAreaPureDataX X=(SCALE_AREA_SCALE_UNIT_SIZE-1)
|
||||
//uint8_t scaleAreaSpareBytes[SCALE_AREA_SCALED_SPARE_SZ];
|
||||
PLAT_CFG_GRP0_ALL_TOK_BYTES()
|
||||
PLAT_CFG_GRP0_ALL_RSV_BYTES()
|
||||
|
||||
uint16_t scaleAreaEndMark;
|
||||
|
||||
//scalable area data structure version, added 1 by customer if sometimes need to upgrade from specific scalable area verson to another specific scalable area version,
|
||||
//if not need specific upgrade, set to defautl 0 ro add 1 just for record
|
||||
uint16_t recScaleAreaGrpNum;
|
||||
|
||||
uint16_t recPrevArAllSzForUpg;
|
||||
|
||||
//uint16_t scaleTimers;
|
||||
uint16_t scaleAreaAllSize;
|
||||
} plat_config_fs_t;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/** \brief typedef of platform configuration stored in raw flash --old v0*/
|
||||
__PACKED_STRUCT _plat_config_raw_flash_v0
|
||||
{
|
||||
/** action to perform when assert or hard fault occurs
|
||||
* valid value:
|
||||
* 0 -- dump full exception info to flash and EPAT tool then trapped in endless loop(while(1))
|
||||
* 1 -- print necessary exception info then reset
|
||||
* 2 -- dump full exception info to flash then reset
|
||||
* 3 -- dump full exception info to flash and EPAT tool then reset
|
||||
* 4 -- reset directly
|
||||
* 10 -- enable uart help dump and dump full exception info to flash and EPAT tool then trapped in endless loop(while(1))
|
||||
* 13 -- enable uart help dump and dump full exception info to flash and EPAT tool, and then reset
|
||||
*/
|
||||
uint8_t faultAction;
|
||||
|
||||
/** port select for dump info output when exception occurs
|
||||
* valid value:
|
||||
* 0,1,2,3,(4) -- specify which port
|
||||
* 0xff -- disable this function
|
||||
*/
|
||||
uint8_t uartDumpPort;
|
||||
|
||||
/** WDT start/stop control
|
||||
* valid value:
|
||||
* 0 -- stop WDT
|
||||
* 1 -- start WDT
|
||||
*/
|
||||
uint8_t startWDT;
|
||||
|
||||
/** unilog on/off flag
|
||||
* valid value:
|
||||
* 0 -- unilog is disabled
|
||||
* 1 -- only sw log is enabled
|
||||
* 2 -- All log is enabled
|
||||
*/
|
||||
uint8_t logControl;
|
||||
|
||||
/** uart baudrate for unilog output */
|
||||
uint32_t uartBaudRate;
|
||||
|
||||
/** debug trace log level setting, refer to 'DebugTraceLevelType_e' */
|
||||
uint32_t logLevel;
|
||||
|
||||
/** unilog output port select
|
||||
* valid value:
|
||||
* 0 -- USB
|
||||
* 1 -- UART
|
||||
* 2 -- MIX(for future use UART/USB dynamic select)
|
||||
**/
|
||||
PlatCfgUlgPort_e logPortSel;
|
||||
|
||||
/** RNDIS enum control
|
||||
* valid value:
|
||||
* 0 -- enable USB init and enum RNDIS
|
||||
* 1 -- enable USB init but not enum RNDIS
|
||||
* 2 -- disable USB init
|
||||
*/
|
||||
uint8_t usbCtrl;
|
||||
|
||||
/** usb software trace control
|
||||
* valid value:
|
||||
* 0 -- disable all usb software trace
|
||||
* 1 -- enable all usb software trace
|
||||
* others -- misc usb software trace
|
||||
*/
|
||||
uint8_t usbSwTrace;
|
||||
|
||||
|
||||
|
||||
/** USB sleep mask
|
||||
* valid value:
|
||||
* 0 -- usb should vote to enter sleep
|
||||
* 1 -- do not consider usb vote before sleep
|
||||
*/
|
||||
uint8_t usbSlpMask;
|
||||
|
||||
/** USB sleep thd
|
||||
* valid value:
|
||||
* set the minimal time to sleep, when usbSlpMask=1
|
||||
*/
|
||||
uint16_t usbSlpThd;
|
||||
|
||||
/** pwrkey mode
|
||||
* valid value:
|
||||
* 1 power key mode
|
||||
* 0 normal key mode
|
||||
*/
|
||||
uint8_t pwrKeyMode;
|
||||
};
|
||||
|
||||
// fota urc port type
|
||||
typedef enum
|
||||
{
|
||||
PLAT_CFG_FOTA_URC_PORT_USB=0,
|
||||
PLAT_CFG_FOTA_URC_PORT_UART,
|
||||
PLAT_CFG_FOTA_URC_PORT_MAXTYPE
|
||||
} PlatCfgFotaUrcPortType_e;
|
||||
|
||||
#define PLAT_CFG_FOTA_URC_USB_PORT_IDX_MIN 0
|
||||
#define PLAT_CFG_FOTA_URC_USB_PORT_IDX_MAX 2
|
||||
|
||||
#define PLAT_CFG_FOTA_URC_UART_PORT_IDX_MIN 0
|
||||
#define PLAT_CFG_FOTA_URC_UART_PORT_IDX_MAX 1
|
||||
|
||||
|
||||
#define PLAT_CFG_RAW_FLASH_RSVD_SIZE 16
|
||||
|
||||
/** \brief typedef of platform configuration stored in raw flash */
|
||||
__PACKED_STRUCT _plat_config_raw_flash
|
||||
{
|
||||
/** action to perform when assert or hard fault occurs
|
||||
* valid value:
|
||||
* 0 -- dump full exception info to flash and EPAT tool then trapped in endless loop(while(1))
|
||||
* 1 -- print necessary exception info then reset
|
||||
* 2 -- dump full exception info to flash then reset
|
||||
* 3 -- dump full exception info to flash and EPAT tool then reset
|
||||
* 4 -- reset directly
|
||||
* 10 -- enable uart help dump and dump full exception info to flash and EPAT tool then trapped in endless loop(while(1))
|
||||
* 13 -- enable uart help dump and dump full exception info to flash and EPAT tool, and then reset
|
||||
*/
|
||||
uint8_t faultAction;
|
||||
|
||||
/** port select for dump info output when exception occurs
|
||||
* valid value:
|
||||
* 0,1,2,3,(4) -- specify which port
|
||||
* 0xff -- disable this function
|
||||
*/
|
||||
uint8_t uartDumpPort;
|
||||
|
||||
|
||||
/** WDT start/stop control
|
||||
* valid value:
|
||||
* 0 -- stop WDT
|
||||
* 1 -- start WDT
|
||||
*/
|
||||
uint8_t startWDT;
|
||||
|
||||
/** unilog on/off flag
|
||||
* valid value:
|
||||
* 0 -- unilog is disabled
|
||||
* 1 -- only sw log is enabled
|
||||
* 2 -- All log is enabled
|
||||
*/
|
||||
uint8_t logControl;
|
||||
|
||||
/** uart baudrate for unilog output */
|
||||
uint32_t uartBaudRate;
|
||||
|
||||
/** debug trace log level setting, refer to 'DebugTraceLevelType_e' */
|
||||
uint32_t logLevel;
|
||||
|
||||
/** unilog output port select
|
||||
* valid value:
|
||||
* 0 -- USB
|
||||
* 1 -- UART
|
||||
* 2 -- MIX(for future use UART/USB dynamic select)
|
||||
**/
|
||||
PlatCfgUlgPort_e logPortSel;
|
||||
|
||||
/** RNDIS enum control
|
||||
* valid value:
|
||||
* 0 -- enable USB init and enum RNDIS
|
||||
* 1 -- enable USB init but not enum RNDIS
|
||||
* 2 -- disable USB init
|
||||
*/
|
||||
uint8_t usbCtrl;
|
||||
|
||||
/** usb software trace control
|
||||
* valid value:
|
||||
* 0 -- disable all usb software trace
|
||||
* 1 -- enable all usb software trace
|
||||
* others -- misc usb software trace
|
||||
*/
|
||||
uint8_t usbSwTrace;
|
||||
|
||||
|
||||
|
||||
/** USB sleep mask
|
||||
* valid value:
|
||||
* 0 -- usb should vote to enter sleep
|
||||
* 1 -- do not consider usb vote before sleep
|
||||
*/
|
||||
uint8_t usbSlpMask;
|
||||
|
||||
/** USB sleep thd
|
||||
* valid value:
|
||||
* set the minimal time to sleep, when usbSlpMask=1
|
||||
*/
|
||||
uint16_t usbSlpThd;
|
||||
|
||||
/** pwrkey mode
|
||||
* valid value:
|
||||
* 1 power key mode
|
||||
* 0 normal key mode
|
||||
*/
|
||||
uint8_t pwrKeyMode;
|
||||
|
||||
/** USB VBUS MODE Enable,Disable Flag
|
||||
* valid value:
|
||||
* 0 -- usb vbus mode disable
|
||||
* 1 -- usb vbus mode enable
|
||||
*/
|
||||
uint8_t usbVBUSModeEn;
|
||||
|
||||
/** USB VBUS MODE Wakup Pad Index
|
||||
* valid value:
|
||||
* 0,1,2,3,4,5 PAD IDX FOR USB VBUS WKUP PAD
|
||||
*/
|
||||
uint8_t usbVBUSWkupPad;
|
||||
|
||||
/** USB NET IF SEL
|
||||
* valid value:
|
||||
* 0----RNDIS,default
|
||||
* 1----ECM
|
||||
*/
|
||||
uint8_t usbNet;
|
||||
|
||||
/** USB VCOM EN bitmap
|
||||
* valid value:
|
||||
* bit0---vcom0
|
||||
* bit1---vcom1
|
||||
* ----
|
||||
* ----
|
||||
*/
|
||||
uint8_t usbVcomEnBitMap;
|
||||
|
||||
/** AT/fotaURC baudrate, for AP & BL*/
|
||||
uint32_t atPortBaudRate;
|
||||
|
||||
/** FOTA control
|
||||
* 0 -- disable FOTA
|
||||
* 1 -- enable FOTA
|
||||
**/
|
||||
uint8_t fotaCtrl;
|
||||
|
||||
/** FOTA URC output port select
|
||||
* valid value(Bit4-7):
|
||||
* 0 -- USB
|
||||
* 1 -- UART
|
||||
**
|
||||
* valid value(Bit0-3):
|
||||
* 0-2 -- USB
|
||||
* 0-1 -- UART
|
||||
**/
|
||||
uint8_t fotaUrcPortSel;
|
||||
|
||||
/** FOTA USB URC output port control
|
||||
* 0 -- disable USB URC output
|
||||
* 1 -- enable USB URC output
|
||||
**/
|
||||
uint8_t fotaUsbUrcCtrl;
|
||||
|
||||
/** pmuInCdrx
|
||||
* valid value:
|
||||
* 0----
|
||||
* 1----
|
||||
*/
|
||||
uint8_t pmuInCdrx;
|
||||
|
||||
/** slpLimitEn
|
||||
* valid value:
|
||||
* 0---- disable
|
||||
* 1---- enable
|
||||
*/
|
||||
uint8_t slpLimitEn;
|
||||
|
||||
/** slpLimitTime
|
||||
* valid value:
|
||||
* 0---0xFFFFFFFF
|
||||
*/
|
||||
uint32_t slpLimitTime;
|
||||
|
||||
/** logOwnerAndLevel
|
||||
* valid value:
|
||||
* 0---0xFFFFFFFF
|
||||
*/
|
||||
uint32_t logOwnerAndLevel;
|
||||
|
||||
/** wfi mode, do not enter doze */
|
||||
uint8_t wfiMode;
|
||||
|
||||
/** ECIDLEP config
|
||||
* valid value:
|
||||
* 0 -- print flag set to 0
|
||||
* 1 -- print flag set to 1
|
||||
*/
|
||||
uint8_t apIdlePercentPrintMode;
|
||||
|
||||
/** cpSlpTest
|
||||
* 0: disable sleep test
|
||||
* 1: CP deepslp
|
||||
* 2: Doze+pll vote disable
|
||||
* 3. Doze+pll vote enable
|
||||
* 4: DFC+WFI
|
||||
* 5: WFI DFC disable
|
||||
* 6. while
|
||||
*/
|
||||
uint8_t cpSlpTest;
|
||||
|
||||
/* 'PLAT_CFG_RAW_FLASH_RSVD_SIZE' bytes rsvd for future */
|
||||
uint8_t resv[PLAT_CFG_RAW_FLASH_RSVD_SIZE];
|
||||
};
|
||||
|
||||
typedef struct _plat_config_raw_flash plat_config_raw_flash_t;//current
|
||||
typedef struct _plat_config_raw_flash_v0 plat_config_raw_flash_v0_t;//old v0
|
||||
|
||||
/** \brief typedef of platform info layout stored in raw flash */
|
||||
__PACKED_STRUCT _plat_info_layout
|
||||
{
|
||||
config_file_header_t header; /**< raw flash plat config header */
|
||||
plat_config_raw_flash_t config; /**< raw flash plat config body */
|
||||
uint32_t fsAssertCount; /**< count for monitoring FS assert, when it reaches specific number, FS region will be re-formated */
|
||||
};
|
||||
typedef struct _plat_info_layout plat_info_layout_t;
|
||||
|
||||
/** @brief List of platform configuration items used to set/get sepecific setting */
|
||||
typedef enum _plat_config_id
|
||||
{
|
||||
PLAT_CONFIG_ITEM_FAULT_ACTION = 0, /**< faultAction item */
|
||||
PLAT_CONFIG_ITEM_UART_DUMP_PORT, /**< uartDumpPort item */
|
||||
PLAT_CONFIG_ITEM_START_WDT, /**< startWDT item */
|
||||
PLAT_CONFIG_ITEM_LOG_CONTROL, /**< logControl item */
|
||||
PLAT_CONFIG_ITEM_LOG_BAUDRATE, /**< uart baudrate for log output */
|
||||
PLAT_CONFIG_ITEM_LOG_LEVEL, /**< logLevel item */
|
||||
PLAT_CONFIG_ITEM_ENABLE_PM, /**< enablePM item */
|
||||
PLAT_CONFIG_ITEM_SLEEP_MODE, /**< sleepMode item */
|
||||
PLAT_CONFIG_ITEM_WAIT_SLEEP, /**< wait ms before sleep */
|
||||
PLAT_CONFIG_ITEM_AT_PORT_BAUDRATE, /**< AT port baudrate */
|
||||
PLAT_CONFIG_ITEM_AT_PORT_FRAME_FORMAT, /**< AT port frame format */
|
||||
PLAT_CONFIG_ITEM_ECSCLK_CFG, /**< ECSCLK config */
|
||||
PLAT_CONFIG_ITEM_LOG_PORT_SEL, /**< ULG output port select */
|
||||
PLAT_CONFIG_ITEM_USB_CTRL, /**< USB control */
|
||||
PLAT_CONFIG_ITEM_USB_SW_TRACE_FLAG, /**< USB control */
|
||||
PLAT_CONFIG_ITEM_USB_SLEEP_MASK, /**< USB Sleep Vote Mask */
|
||||
PLAT_CONFIG_ITEM_USB_SLEEP_THD, /**< USB Sleep Thread */
|
||||
PLAT_CONFIG_ITEM_PWRKEY_MODE, /**< PWRKEY Mode */
|
||||
PLAT_CONFIG_ITEM_USB_VBUS_MODE_EN, /**< USB VBUS MODE ENABLE, DISABLE*/
|
||||
PLAT_CONFIG_ITEM_USB_VBUS_WKUP_PAD, /**< USB VBUS MODE WKUP PAD INDEX*/
|
||||
PLAT_CONFIG_ITEM_USB_NET, /**< USB NET Select*/
|
||||
PLAT_CONFIG_ITEM_USBNET_ATA_RESULT, /*USB NET Autoadapt result */
|
||||
PLAT_CONFIG_ITEM_USB_VCOM_EN_BMP, /**< USB VCOM Enabled Bitmap*/
|
||||
PLAT_CONFIG_ITEM_FOTA_CONTROL, /**< FOTA URC Port control*/
|
||||
PLAT_CONFIG_ITEM_FOTA_URC_PORT_SEL, /**< FOTA URC Port Select*/
|
||||
PLAT_CONFIG_ITEM_FOTA_USB_URC_CONTROL, /**< FOTA USB URC control*/
|
||||
PLAT_CONFIG_ITEM_PMUINCDRX, /**< PMUINCDRX Select*/
|
||||
PLAT_CONFIG_ITEM_SLP_LIMIT_EN, /**< enable sleep time limit*/
|
||||
PLAT_CONFIG_ITEM_SLP_LIMIT_TIME, /**< set maximum sleep time in mili second*/
|
||||
PLAT_CONFIG_ITEM_WFI_MODE, /**< WFI Mode */
|
||||
PLAT_CONFIG_ITEM_IDLEPERCENT_PRINT_MODE, /**< PRINT IDLE PERCENT MODE */
|
||||
PLAT_CONFIG_ITEM_CPSLPTEST_MODE, /**< CP Sleep Mode Test */
|
||||
PLAT_CONFIG_ITEM_TOTAL_NUMBER, /**< total number of items */
|
||||
PLAT_CONFIG_ITEM_LOG_OWNER_AND_LEVEL, /**< log Owner and logLevel for this Owner item */
|
||||
} plat_config_id_t;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
\fn void BSP_SavePlatConfigToFs(void)
|
||||
\brief Save platform configuration into FS
|
||||
\return void
|
||||
*/
|
||||
void BSP_SavePlatConfigToFs(void);
|
||||
|
||||
/**
|
||||
\fn void BSP_LoadPlatConfigFromFs(void)
|
||||
\brief Load platform configuration from FS
|
||||
\return void
|
||||
*/
|
||||
void BSP_LoadPlatConfigFromFs(void);
|
||||
|
||||
/**
|
||||
\fn plat_config_fs_t* BSP_GetFsPlatConfig(void)
|
||||
\brief Get FS platform configuration variable pointer
|
||||
\return pointer to internal platform configuration loaded from FS
|
||||
*/
|
||||
plat_config_fs_t* BSP_GetFsPlatConfig(void);
|
||||
|
||||
/**
|
||||
\fn void BSP_SavePlatConfigToRawFlash(void)
|
||||
\brief Save platform configuration into raw flash
|
||||
\return void
|
||||
*/
|
||||
void BSP_SavePlatConfigToRawFlash(void);
|
||||
|
||||
/**
|
||||
\fn void BSP_LoadPlatConfigFromRawFlash(void)
|
||||
\brief Load platform configuration from raw flash
|
||||
\return void
|
||||
*/
|
||||
void BSP_LoadPlatConfigFromRawFlash(void);
|
||||
|
||||
/**
|
||||
\fn plat_config_raw_flash_t* BSP_GetRawFlashPlatConfig(void)
|
||||
\brief Get raw flash platform configuration variable pointer
|
||||
\return pointer to internal platform configuration loaded from raw flash
|
||||
*/
|
||||
plat_config_raw_flash_t* BSP_GetRawFlashPlatConfig(void);
|
||||
|
||||
/**
|
||||
\fn uint32_t BSP_GetPlatConfigItemValue(plat_config_id_t id)
|
||||
\brief Get value of specific platform configuration item
|
||||
\param[in] id id of platform configuration item, \ref plat_config_id_t
|
||||
\return value of current configuration item
|
||||
*/
|
||||
uint32_t BSP_GetPlatConfigItemValue(plat_config_id_t id);
|
||||
|
||||
/**
|
||||
\fn void BSP_SetPlatConfigItemValue(plat_config_id_t id, uint32_t value)
|
||||
\brief Set value of specific platform configuration item
|
||||
\param[in] id id of platform configuration item, \ref plat_config_id_t
|
||||
\param[in] value value of configuration item to set
|
||||
\return void
|
||||
*/
|
||||
void BSP_SetPlatConfigItemValue(plat_config_id_t id, uint32_t value);
|
||||
|
||||
/**
|
||||
\fn uint32_t BSP_GetFSAssertCount(void)
|
||||
\brief Fetch current 'fsAssertCount' value from PLAT_INFO region
|
||||
\return current fsAssertCount value
|
||||
*/
|
||||
uint32_t BSP_GetFSAssertCount(void);
|
||||
|
||||
/**
|
||||
\fn void BSP_SetFSAssertCount(uint32_t value);
|
||||
\brief Update 'fsAssertCount' value
|
||||
\param[in] value new value assigned to 'fsAssertCount'
|
||||
\return void
|
||||
\note Internal use only on FS assert occurs
|
||||
*/
|
||||
void BSP_SetFSAssertCount(uint32_t value);
|
||||
|
||||
/**
|
||||
\fn void BSP_SetFsPorDefaultValue(void);
|
||||
\brief when por happened some data may retore to it's default
|
||||
\return void
|
||||
*/
|
||||
void BSP_SetFsPorDefaultValue(void);
|
||||
|
||||
/**
|
||||
\fn void BSP_SetPlatCfgUsbNetATAItemVal(void);
|
||||
\brief when USB net auto adapt enabled, to store the adapt result usb net type
|
||||
\return void
|
||||
*/
|
||||
void BSP_SetPlatCfgUsbNetATAItemVal(uint32_t val);
|
||||
|
||||
/**
|
||||
\fn void BSP_GetPlatCfgUsbNetATAEnabled(void);
|
||||
\brief when USB net type config equal to ATC_ECPCFG_USBNET_VAL_AUTOADAPT_TYPE auto adapt enabled, return 1, other return 0
|
||||
\return void
|
||||
*/
|
||||
uint32_t BSP_GetPlatCfgUsbNetATAEnabled(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _PLAT_CONFIG_H */
|
@ -1,32 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2023-, Copyrigths of EigenComm Ltd.
|
||||
* File name: tpComm.h
|
||||
* Description: ec7xx tpComm.h
|
||||
* History: Rev1.0 2023-11-13
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _TP_COMM_H
|
||||
#define _TP_COMM_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ec7xx.h"
|
||||
#include "Driver_Common.h"
|
||||
#include "bsp.h"
|
||||
|
||||
typedef void (*tpIsrFunc)(uint32_t);
|
||||
#define I2C_IO_MODE RTE_I2C0_IO_MODE
|
||||
|
||||
extern ARM_DRIVER_I2C *i2cMasterDrv;
|
||||
|
||||
void tpBusInit(void);
|
||||
void tpRstInit(void);
|
||||
void tpIsrInit(void *cb);
|
||||
uint8_t tp_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint16_t len, uint8_t *data);
|
||||
uint8_t tp_i2c_send(uint8_t dev_id, uint8_t reg_addr, uint16_t len, uint8_t *data);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,36 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2023-, Copyrigths of EigenComm Ltd.
|
||||
* File name: CST816.h
|
||||
* Description: CST816 driver file
|
||||
* History: Rev1.0 2023-09-18
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _TP_CST816_H
|
||||
#define _TP_CST816_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ec7xx.h"
|
||||
#include "Driver_Common.h"
|
||||
|
||||
|
||||
#define CST816_ADDR 0X15
|
||||
|
||||
#define CST816_GET_GESTUREID 0x01
|
||||
#define CST816_GET_FINGERNUM 0x02
|
||||
#define CST816_GET_LOC0 0x03
|
||||
#define CST816_GET_CHIPID 0xA7
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
uint8_t tp_cst816_scan(int16_t *pos);
|
||||
void tp_cst816_init(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,31 +0,0 @@
|
||||
#ifndef _TP_FT6336_H
|
||||
#define _TP_FT6336_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "tpComm.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
//I2C读写命令
|
||||
#define FT6336_ADDR 0x38
|
||||
|
||||
/********************************FT6336 部分寄存器定义***************************/
|
||||
|
||||
#define FT6336_GET_FINGERNUM 0x02
|
||||
#define FT6336_GET_LOC0 0x03
|
||||
#define FT6336_GET_LOC1 0x09
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,53 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2020-, Copyrigths of EigenComm Ltd.
|
||||
* File name: GT911.h
|
||||
* Description: EC7xx touchpanel driver file
|
||||
* History: Rev1.0 2023-09-18
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _TP_GT911_H
|
||||
#define _TP_GT911_H
|
||||
|
||||
#include "ec7xx.h"
|
||||
#include "Driver_Common.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
//I2C读写命令
|
||||
// #define GT911_ADDR 0X5D
|
||||
#define GT911_ADDR 0x14 //由初始化INT输出状态决定
|
||||
/********************************GT911部分寄存器定义***************************/
|
||||
#define GT_CTRL_REG 0X8040 //GT911控制寄存器
|
||||
#define GT_CFGS_REG 0X8047 //配置版本
|
||||
#define GT_X_MAX_LOW 0X8048 //X轴低字节
|
||||
#define GT_X_MAX_HOW 0X8049 //X轴高字节
|
||||
#define GT_Y_MAX_LOW 0X804A //Y轴低字节
|
||||
#define GT_Y_MAX_HOW 0X804B //Y轴高字节
|
||||
#define GT_TOUCH_NUM 0X804C //输出触摸点数1--10
|
||||
|
||||
|
||||
#define GT_CHECK_REG 0X80FF //GT911校验和寄存器
|
||||
#define GT_PID_REG 0X8140 //GT911产品ID寄存器
|
||||
|
||||
#define GT_GSTID_REG 0X814E //当前检测到的触摸情况
|
||||
#define GT_TP1_REG 0X8150 //第一个触摸点数据地址
|
||||
#define GT_TP2_REG 0X8158 //第二个触摸点数据地址
|
||||
#define GT_TP3_REG 0X8160 //第三个触摸点数据地址
|
||||
#define GT_TP4_REG 0X8168 //第四个触摸点数据地址
|
||||
#define GT_TP5_REG 0X8170 //第五个触摸点数据地址
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,60 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2023-, Copyrigths of EigenComm Ltd.
|
||||
* File name: tpDrv.h
|
||||
* Description: ec7xx tpDrv
|
||||
* History: Rev1.0 2023-09-18
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _TP_DRV_H
|
||||
#define _TP_DRV_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "tpComm.h"
|
||||
|
||||
#define SUPPORT_TP_NUM (3)
|
||||
#define INSTALL_TP_NUM (1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t chipID;
|
||||
int (*init)(void *cb);
|
||||
int (*send)(void *tp);
|
||||
int (*read)(void *tp);
|
||||
int (*scan)(void *tp);
|
||||
}tpDrvFunc_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t id;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
}tpDrvPra_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *name; ///< lcd's name used to configure its id, then use id to find its info, including driver function
|
||||
uint16_t id; ///< every lcd's id should be different, no matter lcd's type is the same or not
|
||||
}tpObj_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int handle;
|
||||
tpObj_t *obj;
|
||||
tpDrvPra_t *pra;
|
||||
tpDrvFunc_t *drv;
|
||||
}tpDev_t;
|
||||
|
||||
int tpInit(void* tp_cb);
|
||||
tpDev_t* tpOpen(char* name);
|
||||
uint8_t tpScan(tpDev_t* tpDev);
|
||||
void tpLoop(tpDev_t* tpDev,uint32_t timeout);
|
||||
void tpData(int16_t* x,int16_t* y);
|
||||
bool tpPressed(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,505 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2018 Copyrigths of EigenComm Ltd.
|
||||
* File name: bsp.c
|
||||
* Description:
|
||||
* History:
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "Driver_Common.h"
|
||||
#include "clock.h"
|
||||
#include "bsp.h"
|
||||
#include "system_ec7xx.h"
|
||||
#include DEBUG_LOG_HEADER_FILE
|
||||
#include "ec_string.h"
|
||||
#include "mem_map.h"
|
||||
#ifdef FEATURE_CCIO_ENABLE
|
||||
#include "uart_device.h"
|
||||
#endif
|
||||
#include "dbversion.h"
|
||||
#include "clock.h"
|
||||
#include "hal_adcproxy.h"
|
||||
#include "apmu_external.h"
|
||||
#include "slpman.h"
|
||||
|
||||
#define BSP_TEXT_SECTION SECTION_DEF_IMPL(.sect_bsp_text)
|
||||
#define BSP_RODATA_SECTION SECTION_DEF_IMPL(.sect_bsp_rodata)
|
||||
#define BSP_DATA_SECTION SECTION_DEF_IMPL(.sect_bsp_data)
|
||||
#define BSP_BSS_SECTION SECTION_DEF_IMPL(.sect_bsp_bss)
|
||||
#define FLASH_READ_GRANT_SIZE (16)
|
||||
#define FLASH_READ_MAX_DELAY (10000)//10ms
|
||||
|
||||
|
||||
extern ARM_DRIVER_USART Driver_USART0;
|
||||
extern ARM_DRIVER_USART Driver_USART1;
|
||||
|
||||
BSP_BSS_SECTION ARM_DRIVER_USART *UsartPrintHandle = NULL;
|
||||
BSP_BSS_SECTION ARM_DRIVER_USART *UsartUnilogHandle = NULL;
|
||||
BSP_BSS_SECTION ARM_DRIVER_USART *UsartAtCmdHandle = NULL;
|
||||
|
||||
BSP_BSS_SECTION static uint8_t OSState = 0; // OSState = 0 os not start, OSState = 1 os started
|
||||
BSP_BSS_SECTION static uint32_t gUartBaudrate[3]; // a copy for uart baud rate
|
||||
extern void trimAdcSetGolbalVar(void);
|
||||
#if defined CHIP_EC718 || defined CHIP_EC716
|
||||
extern void trimLdoAIOVadjSetGolbalVar(void);
|
||||
#endif
|
||||
#if defined CHIP_EC718
|
||||
extern void trimVadjVbatSenseSetGolbalVar(void);
|
||||
#endif
|
||||
extern void GPR_RmiErrCfg(bool en);
|
||||
extern uint32_t GPR_RmiErrAddrGet(void);
|
||||
extern uint8_t FLASH_XIPRead(uint8_t* pData, uint32_t ReadAddr, uint32_t Size);
|
||||
extern uint8_t ShareInfoAPGetCPBusyFlag( void );
|
||||
|
||||
|
||||
void BSP_InitUartDriver(ARM_DRIVER_USART *drvHandler,
|
||||
ARM_POWER_STATE powerMode,
|
||||
uint32_t settings,
|
||||
uint32_t baudRate,
|
||||
ARM_USART_SignalEvent_t cb_event)
|
||||
{
|
||||
if(drvHandler)
|
||||
{
|
||||
drvHandler->Initialize(cb_event);
|
||||
drvHandler->PowerControl(powerMode);
|
||||
drvHandler->Control(settings, baudRate);
|
||||
}
|
||||
}
|
||||
|
||||
void BSP_DeinitUartDriver(ARM_DRIVER_USART *drvHandler)
|
||||
{
|
||||
if(drvHandler)
|
||||
{
|
||||
drvHandler->PowerControl(ARM_POWER_OFF);
|
||||
drvHandler->Uninitialize();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined ( __GNUC__ )
|
||||
|
||||
/*
|
||||
* retarget for _write implementation
|
||||
* Parameter: ch: character will be out
|
||||
*/
|
||||
int io_putchar(int ch)
|
||||
{
|
||||
if (UsartPrintHandle != NULL)
|
||||
UsartPrintHandle->SendPolling((uint8_t*)&ch, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* retarget for _read implementation
|
||||
* Parameter: ch: character will be read
|
||||
*/
|
||||
int io_getchar()
|
||||
{
|
||||
uint8_t ch = 0;
|
||||
if (UsartPrintHandle != NULL)
|
||||
UsartPrintHandle->Receive(&ch, 1);
|
||||
return (ch);
|
||||
}
|
||||
|
||||
|
||||
int fgetc(FILE *f)
|
||||
{
|
||||
uint8_t ch = 0;
|
||||
if (UsartPrintHandle != NULL)
|
||||
UsartPrintHandle->Receive(&ch, 1);
|
||||
return (ch);
|
||||
}
|
||||
|
||||
__attribute__((weak,noreturn))
|
||||
void __aeabi_assert (const char *expr, const char *file, int line) {
|
||||
printf("Assert, expr:%s, file: %s, line: %d\r\n", expr, file, line);
|
||||
while(1);
|
||||
}
|
||||
|
||||
|
||||
void __assert_func(const char *filename, int line, const char *assert_func, const char *expr)
|
||||
{
|
||||
for(uint8_t i = 0; i<5; i++)
|
||||
{
|
||||
uniLogFlushOut();
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, assert_func_1, P_ERROR, "Assert, expr:%s, file: %s, line: %d\r\n", expr, filename, line);
|
||||
}
|
||||
while(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#elif defined (__CC_ARM)
|
||||
|
||||
/*
|
||||
* retarget for printf implementation
|
||||
* Parameter: ch: character will be out
|
||||
* f: not used
|
||||
*/
|
||||
int fputc(int ch, FILE *f)
|
||||
{
|
||||
if (UsartPrintHandle != NULL)
|
||||
UsartPrintHandle->SendPolling((uint8_t*)&ch,1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* retarget for scanf implementation
|
||||
* Parameter: f: not used
|
||||
*/
|
||||
int fgetc(FILE *f)
|
||||
{
|
||||
uint8_t ch = 0;
|
||||
if (UsartPrintHandle != NULL)
|
||||
UsartPrintHandle->Receive(&ch,1);
|
||||
return (ch);
|
||||
}
|
||||
|
||||
__attribute__((weak,noreturn))
|
||||
void __aeabi_assert (const char *expr, const char *file, int line) {
|
||||
printf("Assert, expr:%s, file: %s, line: %d\r\n", expr, file, line);
|
||||
while(1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
uint32_t GET_PMU_RAWFLASH_OFFSET(void)
|
||||
{
|
||||
return FLASH_MEM_BACKUP_ADDR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setOSState(uint8_t state)
|
||||
{
|
||||
OSState = state;
|
||||
}
|
||||
|
||||
PLAT_PA_RAMCODE uint8_t getOSState(void) //1 os started. 0 no OS or OS not started yet
|
||||
{
|
||||
return OSState;
|
||||
}
|
||||
|
||||
|
||||
uint8_t* getBuildInfo(void)
|
||||
{
|
||||
return (uint8_t *)BSP_HEADER;
|
||||
}
|
||||
|
||||
uint8_t* getVersionInfo(void)
|
||||
{
|
||||
return (uint8_t *)VERSION_INFO;
|
||||
}
|
||||
|
||||
uint8_t* getATIVersionInfo(void)
|
||||
{
|
||||
return (uint8_t *)ATI_VERSION_INFO;
|
||||
}
|
||||
|
||||
//move here since this is an common and opensource place
|
||||
uint8_t* getDebugDVersion(void)
|
||||
{
|
||||
return (uint8_t*)DB_VERSION_UNIQ_ID;
|
||||
}
|
||||
|
||||
extern void excepDump(uint32_t* start, uint32_t len);
|
||||
|
||||
void cpCoreRegsDumpCheckHook(void)
|
||||
{
|
||||
excepDump((uint32_t*)0x4f000000, 40);
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) uint32_t getUnilogUartPort(void)
|
||||
{
|
||||
return UART_0_FOR_UNILOG; // Swith to UART_x_FOR_UNILOG if need to use other uart for unilog
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) void getUnilogRamLogBuff(uint32_t *addr, uint32_t *len)
|
||||
{
|
||||
#ifdef FEATURE_EXCEPTION_FLASH_DUMP_ENABLE
|
||||
ecGetUnilogDumpAddrAndLen(addr, len);
|
||||
#else
|
||||
*addr = 0; // suggest to be 16 bytes aligned, note this area shall not be initialized in boot phase
|
||||
*len = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void setUartBaudRate(uint8_t idx, uint32_t baudRate)
|
||||
{
|
||||
gUartBaudrate[idx] = baudRate;
|
||||
|
||||
ECPLAT_PRINTF(UNILOG_PMU, setUartBaudRate_1, P_WARNING, "Set BaudRate = %d, %d, %d", gUartBaudrate[0], gUartBaudrate[1], gUartBaudrate[2]);
|
||||
}
|
||||
|
||||
|
||||
void FLASH_appRead(uint8_t *pData, uint32_t ReadAddr, uint32_t Size)
|
||||
{
|
||||
uint32_t numOfReadTrunk = 0, i=0;
|
||||
uint32_t waitLoop =0;
|
||||
|
||||
numOfReadTrunk = (Size/FLASH_READ_GRANT_SIZE);
|
||||
if(Size <= FLASH_READ_GRANT_SIZE)
|
||||
{
|
||||
FLASH_XIPRead(pData, ReadAddr, Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0; i<numOfReadTrunk; i++)
|
||||
{
|
||||
while(ShareInfoAPGetCPBusyFlag() == 1)
|
||||
{
|
||||
delay_us(1);
|
||||
waitLoop ++;
|
||||
if(waitLoop >=FLASH_READ_MAX_DELAY)
|
||||
{
|
||||
waitLoop = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
FLASH_XIPRead(pData+i*FLASH_READ_GRANT_SIZE, ReadAddr+i*FLASH_READ_GRANT_SIZE, FLASH_READ_GRANT_SIZE);
|
||||
|
||||
}
|
||||
if((Size - i*FLASH_READ_GRANT_SIZE) != 0)
|
||||
{
|
||||
while(ShareInfoAPGetCPBusyFlag() == 1)
|
||||
{
|
||||
delay_us(1);
|
||||
waitLoop ++;
|
||||
if(waitLoop >=FLASH_READ_MAX_DELAY)
|
||||
{
|
||||
waitLoop = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
FLASH_XIPRead(pData+i*FLASH_READ_GRANT_SIZE, ReadAddr+i*FLASH_READ_GRANT_SIZE, Size-i*FLASH_READ_GRANT_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn bool getCPWakeupType(void)
|
||||
\brief wakeup cp in polling mode or int mode
|
||||
in polling mode interrupt mask for 700us at most which may cause uart fifo overflow @ 921600.
|
||||
in int mode, interrupt mask for less than 200us
|
||||
\returns true: cp wakeup in int mode false: cp wakeup in polling mode
|
||||
*/
|
||||
bool getCPWakeupType(void) // true: cp wakeup in int mode false: cp wakeup in polling mode
|
||||
{
|
||||
#if 0 // just an example for customer to enable int mode
|
||||
if((gUartBaudrate[0] == 921600) || (gUartBaudrate[1] == 921600) || (gUartBaudrate[2] == 921600))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t getAPFlashLoadAddr(void)
|
||||
{
|
||||
return AP_FLASH_LOAD_ADDR;
|
||||
}
|
||||
|
||||
/**
|
||||
\fn void apmuNeedSlpWaitTimeInWakeupFlow(bool *bUartDelay, bool *bSlp1ExtIntDelay)
|
||||
\brief give pmu module information to restart slpWaitTime in pmu flow
|
||||
\param[out] bUartDelay: give a result to pmu module whether we need restart sleep wait timer when, (1)sleep failed with uart pending in all sleep mode (2)receive uart in sleep1 wakeup flow
|
||||
\param[out] bSlp1ExtIntDelay: give a result to pmu module whether we need restart sleep wait timer when, (1) wakeup from sleep1 with external int pending
|
||||
for sleep2/hib mode, restart slpWaitTime in BSP_CustomInit
|
||||
\returns void
|
||||
*/
|
||||
void apmuNeedSlpWaitTimeInWakeupFlow(bool *bUartDelay, bool *bSlp1ExtIntDelay)
|
||||
{
|
||||
uint32_t xic0_latch = XIC_LatchIRQ(APXIC_0);
|
||||
slpManWakeSrc_e wakeSrc = slpManGetWakeupSrc();
|
||||
|
||||
*bUartDelay = true;
|
||||
*bSlp1ExtIntDelay = false;
|
||||
|
||||
if((xic0_latch & (1<<(PXIC0_UART2_IRQn-32))) == 0)
|
||||
{
|
||||
if((xic0_latch & (1<<(PXIC0_UART1_IRQn-32))) == 0)
|
||||
{
|
||||
if((xic0_latch & (1<<(PXIC0_UART0_IRQn-32))) == 0)
|
||||
{
|
||||
*bUartDelay = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if((WAKEUP_FROM_PAD == wakeSrc) || (WAKEUP_FROM_LPUART == wakeSrc))
|
||||
{
|
||||
*bSlp1ExtIntDelay = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef UINILOG_FEATURE_ENABLE
|
||||
/**
|
||||
\fn void logToolCommandHandle(uint8_t *atcmd_buffer, uint32_t len)
|
||||
\brief handle downlink command sent from unilog tool EPAT
|
||||
if need to handle more command in future, add command-handler table
|
||||
\param[in] event UART event, note used in this function
|
||||
\param[in] cmd_buffer command received from UART
|
||||
\param[in] len command length
|
||||
\returns void
|
||||
*/
|
||||
void logToolCommandHandle(uint32_t event, uint8_t *cmd_buffer, uint32_t len)
|
||||
{
|
||||
(void)event;
|
||||
|
||||
uint8_t * LogDbVserion=getDebugDVersion();
|
||||
|
||||
if(ec_strnstr((const char *)cmd_buffer, "^logversion", len))
|
||||
{
|
||||
|
||||
ECPLAT_PRINTF(UNILOG_PLA_INTERNAL_CMD, get_log_version, P_SIG, "LOGVERSION:%s",LogDbVserion);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ECPLAT_PRINTF(UNILOG_PLA_STRING, get_log_version_1, P_ERROR, "%s", "invalid command from EPAT");
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* unilog entity is removed for the reason of BSP small image.
|
||||
* for more implementation details, pls refer to
|
||||
* gCustSerlEntity[CUST_ENTITY_UNILOG] in ccio_provider.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* set unilog uart port
|
||||
* Parameter: port: for unilog
|
||||
* Parameter: baudrate: uart baudrate
|
||||
*/
|
||||
void SetUnilogUart(usart_port_t port, uint32_t baudrate, bool startRecv)
|
||||
{
|
||||
ARM_POWER_STATE powerMode = ARM_POWER_FULL;
|
||||
uint32_t ctrlSetting = ARM_USART_MODE_ASYNCHRONOUS | ARM_USART_DATA_BITS_8 | \
|
||||
ARM_USART_PARITY_NONE | ARM_USART_STOP_BITS_1 | \
|
||||
ARM_USART_FLOW_CONTROL_NONE;
|
||||
|
||||
if (port == PORT_USART_0)
|
||||
{
|
||||
#if (RTE_UART0)
|
||||
UsartUnilogHandle = &CREATE_SYMBOL(Driver_USART, 0);
|
||||
#endif
|
||||
}
|
||||
else if (port == PORT_USART_1)
|
||||
{
|
||||
#if (RTE_UART1)
|
||||
UsartUnilogHandle = &CREATE_SYMBOL(Driver_USART, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (UsartUnilogHandle == NULL) return;
|
||||
|
||||
#ifdef FEATURE_CCIO_ENABLE
|
||||
UartDevConf_t uartDevConf;
|
||||
UartHwConf_t *uartHwConf = &uartDevConf.hwConf;
|
||||
|
||||
memset(&uartDevConf, 0, sizeof(UartDevConf_t));
|
||||
|
||||
uartHwConf->powerMode = powerMode;
|
||||
uartHwConf->ctrlSetting = ctrlSetting;
|
||||
uartHwConf->baudRate = baudrate;
|
||||
|
||||
uartDevConf.drvHandler = UsartUnilogHandle;
|
||||
uartDevConf.mainUsage = CSIO_DT_DIAG;
|
||||
uartDevConf.speedType = CCIO_ST_HIGH;
|
||||
uartDevConf.rbufFlags = CUST_RBUF_FOR_DIAG;
|
||||
if(startRecv)
|
||||
{
|
||||
uartDevConf.bmCreateFlag = CCIO_TASK_FLAG_RX;
|
||||
}
|
||||
else
|
||||
{
|
||||
uartDevConf.bmCreateFlag = CCIO_TASK_FLAG_NONE;
|
||||
}
|
||||
|
||||
uartDevCreate(port, &uartDevConf);
|
||||
#else
|
||||
BSP_InitUartDriver(UsartUnilogHandle, powerMode, ctrlSetting, baudrate, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void GPR_rmiErrDetectIsr(void)
|
||||
{
|
||||
volatile uint32_t rmiErrAddr;
|
||||
rmiErrAddr = GPR_RmiErrAddrGet();
|
||||
|
||||
ECPLAT_PRINTF(UNILOG_PMU, GPR_rmiErrDetectIsr_1, P_WARNING, "Rmi Err Detect Address=0x%x", rmiErrAddr);
|
||||
}
|
||||
|
||||
|
||||
void GPR_rmiErrDetectInit(void)
|
||||
{
|
||||
XIC_SetVector(PXIC0_RMIIF_TOERR_IRQn, &GPR_rmiErrDetectIsr);
|
||||
XIC_EnableIRQ(PXIC0_RMIIF_TOERR_IRQn);
|
||||
GPR_RmiErrCfg(true);
|
||||
}
|
||||
|
||||
|
||||
void FlushUnilogOutput(void)
|
||||
{
|
||||
uniLogFlushOut();
|
||||
|
||||
if(UsartUnilogHandle == NULL)
|
||||
return;
|
||||
UsartUnilogHandle->Control(ARM_USART_CONTROL_FLUSH_TX, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void BSP_CommonInit(void)
|
||||
{
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
PAD_driverInit();
|
||||
|
||||
GPR_initialize();
|
||||
|
||||
trimAdcSetGolbalVar();
|
||||
|
||||
#if defined CHIP_EC718 || defined CHIP_EC716
|
||||
trimLdoAIOVadjSetGolbalVar();
|
||||
#endif
|
||||
|
||||
#if defined CHIP_EC718
|
||||
trimVadjVbatSenseSetGolbalVar();
|
||||
#endif
|
||||
|
||||
apmuInit();
|
||||
|
||||
//interrupt config
|
||||
IC_PowupInit();
|
||||
|
||||
if(apmuGetAPBootFlag() == 0) // power on
|
||||
{
|
||||
apmuSetCPFastBoot(false); // set cp fast boot in case of cp dap wakeup
|
||||
}
|
||||
|
||||
cpADCInit(); // enable adc ref output, need stable time
|
||||
|
||||
GPR_rmiErrDetectInit();
|
||||
|
||||
BOOT_TIMESTAMP_SET(1, 3);
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,172 +0,0 @@
|
||||
#include "cameraDrv.h"
|
||||
#include "sctdef.h"
|
||||
|
||||
AP_PLAT_COMMON_DATA camI2cCfg_t gc6153_1sdrRegInfo[] =
|
||||
{
|
||||
// SYS
|
||||
{0xfe, 0xa0},
|
||||
{0xfe, 0xa0},
|
||||
{0xfe, 0xa0},
|
||||
{0xfa, 0x11},
|
||||
{0xfc, 0x00},
|
||||
{0xf6, 0x00},
|
||||
{0xfc, 0x12},
|
||||
|
||||
// ANALOG & CISCTL
|
||||
{0xfe, 0x00},
|
||||
{0x01, 0x40},
|
||||
{0x02, 0x12},
|
||||
{0x0d, 0x40},
|
||||
{0x14, 0x7c}, // 0x7e
|
||||
{0x16, 0x05}, // 0x05
|
||||
{0x17, 0x18}, // 0x18
|
||||
{0x1c, 0x31},
|
||||
{0x1d, 0xbb},
|
||||
{0x1f, 0x3f},
|
||||
{0x73, 0x20},
|
||||
{0x74, 0x71},
|
||||
{0x77, 0x22},
|
||||
{0x7a, 0x08},
|
||||
{0x11, 0x18},
|
||||
{0x13, 0x48},
|
||||
{0x12, 0xc8},
|
||||
{0x70, 0xc8},
|
||||
{0x7b, 0x18},
|
||||
{0x7d, 0x30},
|
||||
{0x7e, 0x02},
|
||||
|
||||
{0xfe, 0x10},
|
||||
{0xfe, 0x00},
|
||||
{0xfe, 0x00},
|
||||
{0xfe, 0x00},
|
||||
{0xfe, 0x00},
|
||||
{0xfe, 0x00},
|
||||
{0xfe, 0x10},
|
||||
{0xfe, 0x00},
|
||||
|
||||
{0x49, 0x61},
|
||||
{0x4a, 0x40},
|
||||
{0x4b, 0x58},
|
||||
|
||||
/*ISP*/
|
||||
{0xfe, 0x00},
|
||||
{0x39, 0x02},
|
||||
{0x3a, 0x80},
|
||||
{0x20, 0x7e},
|
||||
{0x26, 0xa7},
|
||||
|
||||
/*BLK*/
|
||||
{0x33, 0x10},
|
||||
{0x37, 0x06},
|
||||
{0x2a, 0x21},
|
||||
|
||||
/*GAIN*/
|
||||
{0x3f, 0x16},
|
||||
|
||||
/*DNDD*/
|
||||
{0x52, 0xa6},
|
||||
{0x53, 0x81},
|
||||
{0x54, 0x43},
|
||||
{0x56, 0x78},
|
||||
{0x57, 0xaa},
|
||||
{0x58, 0xff},
|
||||
|
||||
/*ASDE*/
|
||||
{0x5b, 0x60},
|
||||
{0x5c, 0x50},
|
||||
{0xab, 0x2a},
|
||||
{0xac, 0xb5},
|
||||
|
||||
/*INTPEE*/
|
||||
{0x5e, 0x06},
|
||||
{0x5f, 0x06},
|
||||
{0x60, 0x44},
|
||||
{0x61, 0xff},
|
||||
{0x62, 0x69},
|
||||
{0x63, 0x13},
|
||||
|
||||
/*CC*/
|
||||
{0x65, 0x13},
|
||||
{0x66, 0x26},
|
||||
{0x67, 0x07},
|
||||
{0x68, 0xf5},
|
||||
{0x69, 0xea},
|
||||
{0x6a, 0x21},
|
||||
{0x6b, 0x21},
|
||||
{0x6c, 0xe4},
|
||||
{0x6d, 0xfb},
|
||||
|
||||
/*YCP*/
|
||||
{0x81, 0x3b}, // 0
|
||||
{0x82, 0x3b}, // 0 : uyvy コレーラ
|
||||
{0x83, 0x4b},
|
||||
{0x84, 0x90},
|
||||
{0x86, 0xf0},
|
||||
{0x87, 0x1d},
|
||||
{0x88, 0x16},
|
||||
{0x8d, 0x74},
|
||||
{0x8e, 0x25},
|
||||
|
||||
/*AEC*/
|
||||
{0x90, 0x36},
|
||||
{0x92, 0x43},
|
||||
{0x9d, 0x32},
|
||||
{0x9e, 0x81},
|
||||
{0x9f, 0xf4},
|
||||
{0xa0, 0xa0},
|
||||
{0xa1, 0x04},
|
||||
{0xa3, 0x2d},
|
||||
{0xa4, 0x01},
|
||||
|
||||
/*AWB*/
|
||||
{0xb0, 0xc2},
|
||||
{0xb1, 0x1e},
|
||||
{0xb2, 0x10},
|
||||
{0xb3, 0x20},
|
||||
{0xb4, 0x2d},
|
||||
{0xb5, 0x1b},
|
||||
{0xb6, 0x2e},
|
||||
{0xb8, 0x13},
|
||||
{0xba, 0x60},
|
||||
{0xbb, 0x62},
|
||||
{0xbd, 0x78},
|
||||
{0xbe, 0x55},
|
||||
{0xbf, 0xa0},
|
||||
{0xc4, 0xe7},
|
||||
{0xc5, 0x15},
|
||||
{0xc6, 0x16},
|
||||
{0xc7, 0xeb},
|
||||
{0xc8, 0xe4},
|
||||
{0xc9, 0x16},
|
||||
{0xca, 0x16},
|
||||
{0xcb, 0xe9},
|
||||
{0x22, 0xf8},
|
||||
|
||||
/*SPI*/
|
||||
{0xfe, 0x02},
|
||||
{0x01, 0x01},
|
||||
{0x02, 0x02},
|
||||
{0x03, 0x20},
|
||||
{0x04, 0x20},
|
||||
{0x0a, 0x00},
|
||||
{0x13, 0x10},
|
||||
{0x24, 0x00},
|
||||
{0x28, 0x03},
|
||||
{0xfe, 0x00},
|
||||
|
||||
/*OUTPUT*/
|
||||
{0xf2, 0x03},
|
||||
{0xfe, 0x00},
|
||||
};
|
||||
|
||||
uint16_t gc6153GetRegCnt(char* regName)
|
||||
{
|
||||
if (strcmp(regName, "gc6153_1sdr") == 0)
|
||||
{
|
||||
return (sizeof(gc6153_1sdrRegInfo) / sizeof(gc6153_1sdrRegInfo[0]));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,495 +0,0 @@
|
||||
#include "cameraDrv.h"
|
||||
#include "hal_i2c.h"
|
||||
#include "sctdef.h"
|
||||
|
||||
extern cspiDrvInterface_t cspiDrvInterface0;
|
||||
extern cspiDrvInterface_t cspiDrvInterface1;
|
||||
|
||||
extern camI2cCfg_t sp0A39Cfg[];
|
||||
extern camI2cCfg_t sp0821Cfg[];
|
||||
extern camI2cCfg_t gc6123Cfg[];
|
||||
extern camI2cCfg_t gc032ACfg[];
|
||||
extern camI2cCfg_t bf30a2Cfg[];
|
||||
extern cspiCtrl_t cspiCtrl;
|
||||
extern cspiBinaryCtrl_t cspiBinaryCtrl;
|
||||
extern cspiIntCtrl_t cspiIntCtrl;
|
||||
extern cspiDataFmt_t cspiDataFmt;
|
||||
extern cspiFrameProcLspi_t cspiFrameProcLspi;
|
||||
|
||||
#define EIGEN_CSPI(n) ((CSPI_TypeDef *) (MP_USP0_BASE_ADDR + 0x1000*n))
|
||||
AP_PLAT_COMMON_BSS static camErrCb camErrStatsFunc;
|
||||
AP_PLAT_COMMON_BSS static cspiCbEvent_fn userCamUspCb = NULL;
|
||||
|
||||
|
||||
#if (CAMERA_ENABLE_GC032A)
|
||||
#if (GC032A_2SDR)
|
||||
char* regName = "gc032a_2sdr";
|
||||
#elif (GC032A_1SDR)
|
||||
char* regName = "gc032a_1sdr";
|
||||
#elif (GC032A_2DDR)
|
||||
char* regName = "gc032a_2ddr";
|
||||
#endif
|
||||
#elif (CAMERA_ENABLE_GC6153)
|
||||
#if (GC6153_1SDR)
|
||||
char* regName = "gc6153_1sdr";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
AP_PLAT_COMMON_BSS static uint8_t slaveAddr;
|
||||
AP_PLAT_COMMON_BSS static uint16_t regCnt;
|
||||
AP_PLAT_COMMON_BSS static camI2cCfg_t* regInfo = NULL;
|
||||
|
||||
#if (RTE_CSPI1 == 1)
|
||||
AP_PLAT_COMMON_DATA static cspiDrvInterface_t *cspiDrv = &CREATE_SYMBOL(cspiDrvInterface, 1);
|
||||
#else
|
||||
AP_PLAT_COMMON_DATA static cspiDrvInterface_t *cspiDrv = &CREATE_SYMBOL(cspiDrvInterface, 0);
|
||||
#endif
|
||||
extern void delay_us(uint32_t us);
|
||||
|
||||
void findRegInfo(char* regName, uint8_t* slaveAddr, uint16_t* regCnt, camI2cCfg_t** regInfo)
|
||||
{
|
||||
if (strcmp(regName, "gc032a_2sdr") == 0)
|
||||
{
|
||||
extern camI2cCfg_t gc032A_2sdrRegInfo[];
|
||||
*regInfo = gc032A_2sdrRegInfo;
|
||||
*slaveAddr = GC032A_I2C_ADDR;
|
||||
*regCnt = gc032aGetRegCnt(regName);
|
||||
}
|
||||
else if (strcmp(regName, "gc032a_1sdr") == 0)
|
||||
{
|
||||
extern camI2cCfg_t gc032A_1sdrRegInfo[];
|
||||
*regInfo = gc032A_1sdrRegInfo;
|
||||
*slaveAddr = GC032A_I2C_ADDR;
|
||||
*regCnt = gc032aGetRegCnt(regName);
|
||||
}
|
||||
else if (strcmp(regName, "gc032a_2ddr") == 0)
|
||||
{
|
||||
extern camI2cCfg_t gc032A_2ddrRegInfo[];
|
||||
*regInfo = gc032A_2ddrRegInfo;
|
||||
*slaveAddr = GC032A_I2C_ADDR;
|
||||
*regCnt = gc032aGetRegCnt(regName);
|
||||
}
|
||||
else if (strcmp(regName, "gc6153_1sdr") == 0)
|
||||
{
|
||||
extern camI2cCfg_t gc6153_1sdrRegInfo[];
|
||||
*regInfo = gc6153_1sdrRegInfo;
|
||||
*slaveAddr = GC6153_I2C_ADDR;
|
||||
*regCnt = gc6153GetRegCnt(regName);
|
||||
}
|
||||
}
|
||||
|
||||
void camI2cInit()
|
||||
{
|
||||
halI2cInit(true);
|
||||
|
||||
// Backup some info about this sensor
|
||||
findRegInfo(regName, &slaveAddr, ®Cnt, ®Info);
|
||||
}
|
||||
|
||||
void camI2cWrite(uint8_t slaveAddr, uint8_t regAddr, uint8_t regData, uint32_t num)
|
||||
{
|
||||
uint8_t tempBuffer[2];
|
||||
|
||||
tempBuffer[0] = regAddr;
|
||||
tempBuffer[1] = regData;
|
||||
|
||||
uint8_t rxNack = 0;
|
||||
halI2cWrite(slaveAddr, tempBuffer, num, &rxNack, true);
|
||||
|
||||
if (rxNack == 1)
|
||||
{
|
||||
// if fail , write again
|
||||
halI2cWrite(slaveAddr, tempBuffer, num, &rxNack, true);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t camI2cRead(uint8_t slaveAddr, uint8_t regAddr)
|
||||
{
|
||||
uint8_t readData;
|
||||
halI2cRead(slaveAddr, regAddr, &readData, true);
|
||||
return readData;
|
||||
}
|
||||
|
||||
uint8_t camReadReg(uint8_t regAddr)
|
||||
{
|
||||
uint8_t recvData;
|
||||
|
||||
recvData = camI2cRead(slaveAddr, regAddr);
|
||||
return recvData;
|
||||
}
|
||||
|
||||
void camWriteReg(camI2cCfg_t* regInfo)
|
||||
{
|
||||
camI2cWrite(slaveAddr, regInfo->regAddr, regInfo->regVal, 2);
|
||||
}
|
||||
|
||||
void camRegCfg()
|
||||
{
|
||||
//uint8_t dataRead;
|
||||
|
||||
camI2cInit();
|
||||
|
||||
// Configure all the registers about this sensor
|
||||
for (int i=0; i < regCnt; i++)
|
||||
{
|
||||
camI2cWrite(slaveAddr, regInfo[i].regAddr, regInfo[i].regVal, 2);
|
||||
delay_us(10000); // delay 10ms
|
||||
|
||||
#if 0
|
||||
dataRead = camI2cRead(slaveAddr, regInfo[i].regAddr);
|
||||
printf("reg addr=0x%02x, reg val=0x%02x\n", regInfo[i].regAddr, dataRead);
|
||||
delay_us(15000);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void camInterfaceCfg(camParamCfg_t* config)
|
||||
{
|
||||
cspiDataFmt.endianMode = config->endianMode;
|
||||
cspiCtrl.rxWid = config->wireNum;
|
||||
cspiCtrl.rxdSeq = config->rxSeq;
|
||||
cspiCtrl.cpol = config->cpol;
|
||||
cspiCtrl.cpha = config->cpha;
|
||||
cspiCtrl.ddrMode = config->ddrMode;
|
||||
cspiBinaryCtrl.wordIdSeq = config->wordIdSeq;
|
||||
cspiBinaryCtrl.dummyAllowed = config->dummyAllowed;
|
||||
cspiCtrl.fillYonly = config->yOnly;
|
||||
cspiCtrl.rowScaleRatio = config->rowScaleRatio;
|
||||
cspiCtrl.colScaleRatio = config->colScaleRatio;
|
||||
cspiCtrl.scaleBytes = config->scaleBytes;
|
||||
}
|
||||
|
||||
void camSetMemAddr(uint32_t dataAddr)
|
||||
{
|
||||
cspiDrv->ctrl(CSPI_CTRL_MEM_ADDR , dataAddr); // register the recv memory
|
||||
}
|
||||
|
||||
#if (ENABLE_CAMERA_LDO == 1)
|
||||
void camPowerOn(uint8_t ioInitVal)
|
||||
{
|
||||
PadConfig_t padConfig;
|
||||
PAD_getDefaultConfig(&padConfig);
|
||||
padConfig.pullUpEnable = PAD_PULL_UP_DISABLE;
|
||||
padConfig.pullDownEnable = PAD_PULL_DOWN_DISABLE;
|
||||
padConfig.mux = CAM_PD_PAD_ALT_FUNC;
|
||||
PAD_setPinConfig(CAM_PD_PAD_INDEX, &padConfig);
|
||||
|
||||
GpioPinConfig_t config;
|
||||
config.pinDirection = GPIO_DIRECTION_OUTPUT;
|
||||
config.misc.initOutput = ioInitVal;
|
||||
GPIO_pinConfig(CAM_PD_GPIO_INSTANCE, CAM_PD_GPIO_PIN, &config);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void camUspCb()
|
||||
{
|
||||
uint32_t cspiStatus;
|
||||
|
||||
#if (RTE_CSPI0 == 1)
|
||||
cspiStatus = camGetCspiStats(CSPI_0);
|
||||
#elif (RTE_CSPI1 == 1)
|
||||
cspiStatus = camGetCspiStats(CSPI_1);
|
||||
#endif
|
||||
|
||||
if (cspiStatus & ICL_STATS_FRAME_END_Msk)
|
||||
{
|
||||
CSPI1->STAS |= 0x3<<3;
|
||||
CSPI1->STAS |= 0xf<<7;
|
||||
CSPI1->STAS |= 0x3<<11;
|
||||
CSPI1->DMACTL |= 1<<24;
|
||||
|
||||
if (userCamUspCb)
|
||||
{
|
||||
userCamUspCb(cspiStatus);
|
||||
}
|
||||
|
||||
CSPI1->CBCTRL |= 2<<25;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void camInit(void* dataAddr, cspiCbEvent_fn uspCb, void* dmaCb)
|
||||
{
|
||||
camResolution_e camResolution;
|
||||
camParamCfg_t camParamCfg;
|
||||
IRQn_Type irqNum;
|
||||
|
||||
#if (RTE_CSPI0 == 1)
|
||||
irqNum = PXIC0_USP0_IRQn;
|
||||
#elif (RTE_CSPI1 == 1)
|
||||
irqNum = PXIC0_USP1_IRQn;
|
||||
#endif
|
||||
|
||||
if(uspCb)
|
||||
{
|
||||
userCamUspCb = uspCb;
|
||||
}
|
||||
|
||||
XIC_SetVector(irqNum, camUspCb);
|
||||
XIC_EnableIRQ(irqNum);
|
||||
|
||||
#if (CAMERA_ENABLE_GC032A)
|
||||
#if (GC032A_2SDR)
|
||||
camParamCfg.wireNum = WIRE_2;
|
||||
camParamCfg.endianMode = CAM_LSB_MODE;
|
||||
camParamCfg.rxSeq = SEQ_0;
|
||||
camParamCfg.cpha = 0;
|
||||
camParamCfg.cpol = 0;
|
||||
camParamCfg.ddrMode = 0;
|
||||
camParamCfg.wordIdSeq = 0;
|
||||
camParamCfg.dummyAllowed = 0;
|
||||
camResolution = CAM_CHAIN_COUNT;
|
||||
#elif (GC032A_1SDR)
|
||||
camParamCfg.wireNum = WIRE_1;
|
||||
camParamCfg.endianMode = CAM_LSB_MODE;
|
||||
camParamCfg.rxSeq = SEQ_0;
|
||||
camParamCfg.cpha = 0;
|
||||
camParamCfg.cpol = 0;
|
||||
camParamCfg.ddrMode = 0;
|
||||
camParamCfg.wordIdSeq = 0;
|
||||
camParamCfg.dummyAllowed = 0;
|
||||
camResolution = CAM_CHAIN_COUNT;
|
||||
#elif (GC032A_2DDR)
|
||||
camParamCfg.wireNum = WIRE_2;
|
||||
camParamCfg.endianMode = CAM_MSB_MODE;
|
||||
camParamCfg.rxSeq = SEQ_1;
|
||||
camParamCfg.cpha = 1;
|
||||
camParamCfg.cpol = 0;
|
||||
camParamCfg.ddrMode = 1;
|
||||
camParamCfg.wordIdSeq = 1;
|
||||
camParamCfg.dummyAllowed = 1;
|
||||
camResolution = CAM_CHAIN_COUNT;
|
||||
#endif
|
||||
|
||||
if (CAM_CHAIN_COUNT == CAM_8W_COLOR)
|
||||
{
|
||||
camParamCfg.yOnly = 0;
|
||||
camParamCfg.rowScaleRatio = 1;
|
||||
camParamCfg.colScaleRatio = 1;
|
||||
camParamCfg.scaleBytes = 3;
|
||||
}
|
||||
else if (CAM_CHAIN_COUNT == CAM_8W_Y)
|
||||
{
|
||||
camParamCfg.yOnly = 1;
|
||||
camParamCfg.rowScaleRatio = 1;
|
||||
camParamCfg.colScaleRatio = 1;
|
||||
camParamCfg.scaleBytes = 1;
|
||||
}
|
||||
else if (CAM_CHAIN_COUNT == CAM_30W_Y)
|
||||
{
|
||||
camParamCfg.yOnly = 1;
|
||||
camParamCfg.rowScaleRatio = 0;
|
||||
camParamCfg.colScaleRatio = 0;
|
||||
camParamCfg.scaleBytes = 0;
|
||||
}
|
||||
else if (CAM_CHAIN_COUNT == CAM_30W_COLOR)
|
||||
{
|
||||
camParamCfg.yOnly = 0;
|
||||
camParamCfg.rowScaleRatio = 0;
|
||||
camParamCfg.colScaleRatio = 0;
|
||||
camParamCfg.scaleBytes = 0;
|
||||
}
|
||||
#elif (CAMERA_ENABLE_GC6153)
|
||||
#if (GC6153_1SDR)
|
||||
camParamCfg.wireNum = WIRE_1;
|
||||
#endif
|
||||
camParamCfg.endianMode = CAM_LSB_MODE;
|
||||
camParamCfg.rxSeq = SEQ_1;
|
||||
camParamCfg.cpha = 1;
|
||||
camParamCfg.cpol = 0;
|
||||
camParamCfg.yOnly = 1;
|
||||
camParamCfg.ddrMode = 0;
|
||||
camParamCfg.wordIdSeq = 0;
|
||||
camParamCfg.rowScaleRatio = 0;
|
||||
camParamCfg.colScaleRatio = 0;
|
||||
camParamCfg.scaleBytes = 0;
|
||||
camResolution = CAM_CHAIN_COUNT;
|
||||
#endif
|
||||
|
||||
camInterfaceCfg(&camParamCfg);
|
||||
|
||||
cspiDrv->ctrl(CSPI_CTRL_MEM_ADDR , (uint32_t)dataAddr); // register the recv memory
|
||||
cspiDrv->powerCtrl(CSPI_POWER_FULL);
|
||||
cspiDrv->init(dmaCb);
|
||||
cspiDrv->ctrl(CSPI_CTRL_DATA_FORMAT , 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_RXTOR , 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_FRAME_INFO0 , 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_INT_CTRL , 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_CSPICTL , 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_DMA_CTRL , 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_RESOLUTION_SET , camResolution);
|
||||
cspiDrv->ctrl(CSPI_CTRL_BUS_SPEED, (camFrequence_e)CAM_25_5_M);
|
||||
cspiDrv->ctrl(CSPI_BINARY_CTRL, 0);
|
||||
cspiDrv->ctrl(CSPI_CTRL_AUTO_CG_CTRL, 0);
|
||||
cspiDrv->ctrl(CSPI_FRAME_PROC_LSPI, 0);
|
||||
cspiDrv->ctrl(CSPI_DELAY_CTRL, 0);
|
||||
}
|
||||
|
||||
void camStartStop(cspiStartStop_e startStop)
|
||||
{
|
||||
cspiDrv->ctrl(CSPI_CTRL_START_STOP , (uint32_t)startStop);
|
||||
}
|
||||
|
||||
void cspiStartIntEnable(cspiIntEnable_e intEnable)
|
||||
{
|
||||
if (intEnable)
|
||||
{
|
||||
cspiIntCtrl.frameStartIntEn |= intEnable;
|
||||
}
|
||||
else
|
||||
{
|
||||
cspiIntCtrl.frameStartIntEn &= intEnable;
|
||||
}
|
||||
cspiDrv->ctrl(CSPI_CTRL_INT_CTRL , 0); // cspi interrupt enable or disable
|
||||
}
|
||||
|
||||
void cspiEndIntEnable(cspiIntEnable_e endIntEnable)
|
||||
{
|
||||
if (endIntEnable)
|
||||
{
|
||||
cspiIntCtrl.frameEndIntEn |= endIntEnable;
|
||||
}
|
||||
else
|
||||
{
|
||||
cspiIntCtrl.frameEndIntEn &= endIntEnable;
|
||||
}
|
||||
|
||||
cspiDrv->ctrl(CSPI_CTRL_INT_CTRL , 0);
|
||||
}
|
||||
|
||||
void cspi2LspiEnable(uint8_t enable)
|
||||
{
|
||||
cspiFrameProcLspi.outEnLspi = enable;
|
||||
cspiDrv->ctrl(CSPI_FRAME_PROC_LSPI, 0);
|
||||
}
|
||||
|
||||
void camFlush()
|
||||
{
|
||||
cspiDrv->ctrl(CSPI_CTRL_FLUSH_RX_FIFO , 0);
|
||||
}
|
||||
|
||||
void camRegisterIRQ(cspiInstance_e instance, camIrq_fn irqCb)
|
||||
{
|
||||
IRQn_Type irqNum;
|
||||
|
||||
if (instance == CSPI_0)
|
||||
{
|
||||
irqNum = PXIC0_USP0_IRQn;
|
||||
}
|
||||
else
|
||||
{
|
||||
irqNum = PXIC0_USP1_IRQn;
|
||||
}
|
||||
|
||||
XIC_SetVector(irqNum, irqCb);
|
||||
XIC_EnableIRQ(irqNum);
|
||||
}
|
||||
|
||||
PLAT_FM_RAMCODE void camRecv(uint8_t * dataAddr)
|
||||
{
|
||||
cspiDrv->ctrl(CSPI_CTRL_MEM_ADDR , (uint32_t)dataAddr);
|
||||
cspiDrv->recv();
|
||||
}
|
||||
|
||||
uint32_t camGetCspiStats(cspiInstance_e instance)
|
||||
{
|
||||
return EIGEN_CSPI(instance)->STAS;
|
||||
}
|
||||
|
||||
uint32_t camGetCspiInt(cspiInstance_e instance)
|
||||
{
|
||||
return EIGEN_CSPI(instance)->INTCTL;
|
||||
}
|
||||
|
||||
|
||||
void camClearIntStats(cspiInstance_e instance, uint32_t mask)
|
||||
{
|
||||
EIGEN_CSPI(instance)->STAS = mask;
|
||||
}
|
||||
|
||||
void camRegisterErrStatsCb(camErrCb errCb)
|
||||
{
|
||||
camErrStatsFunc = errCb;
|
||||
}
|
||||
|
||||
void camCheckErrStats()
|
||||
{
|
||||
if (!camErrStatsFunc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// check lspi error status and give cb to user
|
||||
uint32_t status = LSPI2->STAS;
|
||||
|
||||
if ( (status | ICL_STATS_TX_UNDERRUN_RUN_Msk) ||
|
||||
(status | ICL_STATS_TX_DMA_ERR_Msk) ||
|
||||
(status | ICL_STATS_RX_OVERFLOW_Msk) ||
|
||||
(status | ICL_STATS_RX_DMA_ERR_Msk) ||
|
||||
(status | ICL_STATS_RX_FIFO_TIMEOUT_Msk) ||
|
||||
(status | ICL_STATS_FS_ERR_Msk) ||
|
||||
(status | ICL_STATS_CSPI_BUS_TIMEOUT_Msk) ||
|
||||
(status | ICL_STATS_RX_FIFO_TIMEOUT_Msk)
|
||||
)
|
||||
{
|
||||
camErrStatsFunc(status);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void camGpioPulseCfg(uint8_t padAddr, uint8_t pinInstance, uint8_t pinNum)
|
||||
{
|
||||
PadConfig_t padConfig;
|
||||
PAD_getDefaultConfig(&padConfig);
|
||||
|
||||
padConfig.mux = PAD_MUX_ALT0;
|
||||
PAD_setPinConfig(padAddr, &padConfig);
|
||||
|
||||
GpioPinConfig_t config;
|
||||
config.pinDirection = GPIO_DIRECTION_OUTPUT;
|
||||
config.misc.initOutput = 0;
|
||||
|
||||
GPIO_pinConfig(pinInstance, pinNum, &config);
|
||||
}
|
||||
|
||||
void camGpioPulse(uint8_t pinInstance, uint8_t pinNum, uint32_t pulseDurationUs, uint8_t initialState, bool needLoop)
|
||||
{
|
||||
GPIO_TypeDef *gpio = (GPIO_TypeDef*)(RMI_GPIO_BASE_ADDR + 0x1000*pinInstance);
|
||||
|
||||
if (needLoop)
|
||||
{
|
||||
// for test gpio is good or not
|
||||
while (1)
|
||||
{
|
||||
gpio->DATAOUT = ((~(1<<pinNum)) << 16) | (1<<pinNum);
|
||||
delay_us(pulseDurationUs);
|
||||
gpio->DATAOUT = ((~(1<<pinNum)) << 16);
|
||||
delay_us(pulseDurationUs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// inititalState: 0=low level; 1=high level
|
||||
if (initialState == 0)
|
||||
{
|
||||
// pulse 0->1
|
||||
gpio->DATAOUT = ((~(1<<pinNum)) << 16) | (1<<pinNum);
|
||||
delay_us(pulseDurationUs);
|
||||
gpio->DATAOUT = ((~(1<<pinNum)) << 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
// pulse 1->0
|
||||
gpio->DATAOUT = ((~(1<<pinNum)) << 16);
|
||||
delay_us(pulseDurationUs);
|
||||
gpio->DATAOUT = ((~(1<<pinNum)) << 16) | (1<<pinNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void camRegisterSlp1Cb(cspiSlp1Cb_fn cb)
|
||||
{
|
||||
cspiSlp1CbFn = cb;
|
||||
}
|
||||
|
@ -1,319 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2019-, Copyrigths of EigenComm Ltd.
|
||||
* File name: es7111.c
|
||||
* Description: EC7xx es7111 file
|
||||
* History: Rev1.0 2021-9-18
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "es7111.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define ES7111_DEFAULT_CONFIG() \
|
||||
{ \
|
||||
.codecIface = { \
|
||||
.mode = CODEC_MODE_SLAVE, \
|
||||
.fmt = CODEC_MSB_MODE, \
|
||||
.samples = CODEC_16K_SAMPLES, \
|
||||
.bits = CODEC_BIT_LENGTH_16BITS, \
|
||||
.channel = CODEC_MONO, \
|
||||
.polarity = 1, \
|
||||
}, \
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCTION DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
// 7111 func list
|
||||
HalCodecFuncList_t es7111DefaultHandle =
|
||||
{
|
||||
.codecType = ES7111,
|
||||
.halCodecInitFunc = es7111Init,
|
||||
.halCodecDeinitFunc = es7111DeInit,
|
||||
.halCodecCtrlStateFunc = es7111StartStop,
|
||||
.halCodecCfgIfaceFunc = es7111Config,
|
||||
.halCodecSetMuteFunc = es7111SetMute,
|
||||
.halCodecSetVolumeFunc = es7111SetVolume,
|
||||
.halCodecGetVolumeFunc = es7111GetVolume,
|
||||
//.halCodecEnablePAFunc = es7111EnablePA,
|
||||
.halCodecSetMicVolumeFunc = es7111SetMicVolume,
|
||||
.halCodecLock = NULL,
|
||||
.handle = NULL,
|
||||
.halCodecGetDefaultCfg = es7111GetDefaultCfg,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static uint8_t dacVolBak, adcVolBak;
|
||||
static bool isHasPA;
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
// set es7111 into suspend mode
|
||||
static void es7111Standby(uint8_t* dacVolB, uint8_t* adcVolB)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111Standby, P_DEBUG, "[ES7111] tn8211Standby: dacVolB=%d, adcVolB=%d", *dacVolB, *adcVolB);
|
||||
}
|
||||
|
||||
// set es7111 ADC into suspend mode
|
||||
static void es7111AdcStandby(uint8_t* adcVolB)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111AdcStandby, P_DEBUG, "[ES7111] es7111AdcStandby");
|
||||
}
|
||||
|
||||
// set es7111 DAC into suspend mode
|
||||
static void es7111DacStandby(uint8_t* dacVolB)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111DacStandby, P_DEBUG, "[ES7111] es7111DacStandby");
|
||||
}
|
||||
|
||||
// set es7111 into resume mode
|
||||
static HalCodecSts_e es7111AllResume()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111AllResume, P_DEBUG, "[ES7111] es7111AllResume: dacVolBak=%d, adcVolBak=%d", dacVolBak, adcVolBak);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
// set es7111 adc into resume mode
|
||||
static HalCodecSts_e es7111AdcResume()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111AdcResume, P_DEBUG, "[ES7111] es7111AdcResume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
// set es7111 dac into resume mode
|
||||
static HalCodecSts_e es7111DacResume()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111DacResume, P_DEBUG, "[ES7111] es7111DacResume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
// set es7111 into powerdown mode
|
||||
static HalCodecSts_e es7111PwrDown()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111PwrDown, P_DEBUG, "[ES7111] es7111PwrDown");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
// enable pa power
|
||||
void es7111EnablePA(bool enable)
|
||||
{
|
||||
GPIO_pinWrite(CODEC_PA_GPIO_INSTANCE, 1 << CODEC_PA_GPIO_PIN, (enable == true) ? (1 << CODEC_PA_GPIO_PIN) : 0);
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111EnablePA, P_DEBUG, "[ES7111] Set PA: %d", enable);
|
||||
}
|
||||
|
||||
HalCodecSts_e es7111Init(HalCodecCfg_t *codecCfg)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111Init, P_DEBUG, "[ES7111] es7111Init: hasPA=%d", codecCfg->hasPA);
|
||||
printf("[ES7111] es7111Init: hasPA=%d\r\n", codecCfg->hasPA);
|
||||
if (codecCfg->hasPA)
|
||||
{
|
||||
isHasPA = codecCfg->hasPA;
|
||||
|
||||
// GPIO function select
|
||||
PadConfig_t padConfig = {0};
|
||||
GpioPinConfig_t pinConfig = {0};
|
||||
|
||||
PAD_getDefaultConfig(&padConfig);
|
||||
padConfig.mux = PAD_MUX_ALT0;
|
||||
PAD_setPinConfig(CODEC_PA_PAD_INDEX, &padConfig);
|
||||
|
||||
// CODEC_PA pin config
|
||||
pinConfig.pinDirection = GPIO_DIRECTION_OUTPUT;
|
||||
pinConfig.misc.initOutput = 1; // when codec has been init, PA should open
|
||||
GPIO_pinConfig(CODEC_PA_GPIO_INSTANCE, CODEC_PA_GPIO_PIN, &pinConfig);
|
||||
}
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
void es7111DeInit()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111DeInit, P_DEBUG, "[ES7111] es7111DeInit");
|
||||
}
|
||||
|
||||
HalCodecSts_e es7111Config(HalCodecMode_e mode, HalCodecIface_t *iface)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111Config, P_DEBUG, "[ES7111] es7111Config");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7111StartStop(HalCodecMode_e mode, HalCodecCtrlState_e ctrlState)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
|
||||
switch(ctrlState)
|
||||
{
|
||||
case CODEC_CTRL_START:
|
||||
{
|
||||
ret |= es7111Start(mode);
|
||||
if (isHasPA)
|
||||
{
|
||||
es7111EnablePA(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CODEC_CTRL_STOP:
|
||||
ret |= es7111Stop(mode);
|
||||
break;
|
||||
case CODEC_CTRL_RESUME:
|
||||
ret |= es7111Resume(mode);
|
||||
break;
|
||||
case CODEC_CTRL_POWERDONW:
|
||||
ret |= es7111PwrDown(mode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7111Start(HalCodecMode_e mode)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111Start, P_DEBUG, "[ES7111] es7111Start");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7111Stop(HalCodecMode_e mode)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
switch(mode)
|
||||
{
|
||||
case CODEC_MODE_ENCODE:
|
||||
es7111AdcStandby(&adcVolBak);
|
||||
break;
|
||||
|
||||
case CODEC_MODE_DECODE:
|
||||
{
|
||||
es7111DacStandby(&dacVolBak);
|
||||
|
||||
// disable PA
|
||||
if (isHasPA)
|
||||
{
|
||||
es7111EnablePA(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CODEC_MODE_BOTH:
|
||||
es7111Standby(&dacVolBak, &adcVolBak);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7111Resume(HalCodecMode_e mode)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
switch(mode)
|
||||
{
|
||||
case CODEC_MODE_ENCODE:
|
||||
es7111AdcResume();
|
||||
break;
|
||||
|
||||
case CODEC_MODE_DECODE:
|
||||
{
|
||||
es7111DacResume();
|
||||
|
||||
// enable PA
|
||||
if (isHasPA)
|
||||
{
|
||||
es7111EnablePA(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CODEC_MODE_BOTH:
|
||||
es7111AllResume();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
HalCodecSts_e es7111SetVolume(int volume)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111SetVolume, P_DEBUG, "[ES7111] es7111SetVolume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7111GetVolume(int *volume)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111GetVolume, P_DEBUG, "[ES7111] es7111GetVolume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7111SetMute(bool enable)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111SetMute, P_DEBUG, "[ES7111] es7111SetMute");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7111GetVoiceMute(int *mute)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111GetVoiceMute, P_DEBUG, "[ES7111] es7111GetVoiceMute");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7111SetMicVolume(uint8_t micGain, int micVolume)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7111SetMicVolume, P_DEBUG, "[ES7111] es7111SetMicVolume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecCfg_t es7111GetDefaultCfg()
|
||||
{
|
||||
HalCodecCfg_t codecCfg = ES7111_DEFAULT_CONFIG();
|
||||
|
||||
return codecCfg;
|
||||
}
|
||||
|
||||
|
@ -1,317 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2019-, Copyrigths of EigenComm Ltd.
|
||||
* File name: es7149.c
|
||||
* Description: EC7xx es7149 file
|
||||
* History: Rev1.0 2021-9-18
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "es7149.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define ES7149_DEFAULT_CONFIG() \
|
||||
{ \
|
||||
.codecIface = { \
|
||||
.mode = CODEC_MODE_SLAVE, \
|
||||
.fmt = CODEC_MSB_MODE, \
|
||||
.samples = CODEC_16K_SAMPLES, \
|
||||
.bits = CODEC_BIT_LENGTH_16BITS, \
|
||||
.channel = CODEC_MONO, \
|
||||
.polarity = 1, \
|
||||
}, \
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCTION DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
// 7149 func list
|
||||
HalCodecFuncList_t es7149DefaultHandle =
|
||||
{
|
||||
.codecType = ES7149,
|
||||
.halCodecInitFunc = es7149Init,
|
||||
.halCodecDeinitFunc = es7149DeInit,
|
||||
.halCodecCtrlStateFunc = es7149StartStop,
|
||||
.halCodecCfgIfaceFunc = es7149Config,
|
||||
.halCodecSetMuteFunc = es7149SetMute,
|
||||
.halCodecSetVolumeFunc = es7149SetVolume,
|
||||
.halCodecGetVolumeFunc = es7149GetVolume,
|
||||
//.halCodecEnablePAFunc = es7149EnablePA,
|
||||
.halCodecSetMicVolumeFunc = es7149SetMicVolume,
|
||||
.halCodecLock = NULL,
|
||||
.handle = NULL,
|
||||
.halCodecGetDefaultCfg = es7149GetDefaultCfg,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static uint8_t dacVolBak, adcVolBak;
|
||||
static bool isHasPA;
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
// set es7149 into suspend mode
|
||||
static void es7149Standby(uint8_t* dacVolB, uint8_t* adcVolB)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149Standby, P_DEBUG, "[ES7149] tn8211Standby: dacVolB=%d, adcVolB=%d", *dacVolB, *adcVolB);
|
||||
}
|
||||
|
||||
// set es7149 ADC into suspend mode
|
||||
static void es7149AdcStandby(uint8_t* adcVolB)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149AdcStandby, P_DEBUG, "[ES7149] es7149AdcStandby");
|
||||
}
|
||||
|
||||
// set es7149 DAC into suspend mode
|
||||
static void es7149DacStandby(uint8_t* dacVolB)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149DacStandby, P_DEBUG, "[ES7149] es7149DacStandby");
|
||||
}
|
||||
|
||||
// set es7149 into resume mode
|
||||
static HalCodecSts_e es7149AllResume()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149AllResume, P_DEBUG, "[ES7149] es7149AllResume: dacVolBak=%d, adcVolBak=%d", dacVolBak, adcVolBak);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
// set es7149 adc into resume mode
|
||||
static HalCodecSts_e es7149AdcResume()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149AdcResume, P_DEBUG, "[ES7149] es7149AdcResume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
// set es7149 dac into resume mode
|
||||
static HalCodecSts_e es7149DacResume()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149DacResume, P_DEBUG, "[ES7149] es7149DacResume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
// set es7149 into powerdown mode
|
||||
static HalCodecSts_e es7149PwrDown()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149PwrDown, P_DEBUG, "[ES7149] es7149PwrDown");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
// enable pa power
|
||||
void es7149EnablePA(bool enable)
|
||||
{
|
||||
GPIO_pinWrite(CODEC_PA_GPIO_INSTANCE, 1 << CODEC_PA_GPIO_PIN, (enable == true) ? (1 << CODEC_PA_GPIO_PIN) : 0);
|
||||
// DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149EnablePA, P_DEBUG, "[ES7149] Set PA: %d", enable);
|
||||
}
|
||||
|
||||
HalCodecSts_e es7149Init(HalCodecCfg_t *codecCfg)
|
||||
{
|
||||
if (codecCfg->hasPA)
|
||||
{
|
||||
isHasPA = codecCfg->hasPA;
|
||||
|
||||
// GPIO function select
|
||||
PadConfig_t padConfig = {0};
|
||||
GpioPinConfig_t pinConfig = {0};
|
||||
|
||||
PAD_getDefaultConfig(&padConfig);
|
||||
padConfig.mux = PAD_MUX_ALT0;
|
||||
PAD_setPinConfig(CODEC_PA_PAD_INDEX, &padConfig);
|
||||
|
||||
// CODEC_PA pin config
|
||||
pinConfig.pinDirection = GPIO_DIRECTION_OUTPUT;
|
||||
pinConfig.misc.initOutput = 1; // when codec has been init, PA should open
|
||||
GPIO_pinConfig(CODEC_PA_GPIO_INSTANCE, CODEC_PA_GPIO_PIN, &pinConfig);
|
||||
}
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
void es7149DeInit()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149DeInit, P_DEBUG, "[ES7149] es7149DeInit");
|
||||
}
|
||||
|
||||
HalCodecSts_e es7149Config(HalCodecMode_e mode, HalCodecIface_t *iface)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149Config, P_DEBUG, "[ES7149] es7149Config");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7149StartStop(HalCodecMode_e mode, HalCodecCtrlState_e ctrlState)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
|
||||
switch(ctrlState)
|
||||
{
|
||||
case CODEC_CTRL_START:
|
||||
{
|
||||
ret |= es7149Start(mode);
|
||||
if (isHasPA)
|
||||
{
|
||||
es7149EnablePA(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CODEC_CTRL_STOP:
|
||||
ret |= es7149Stop(mode);
|
||||
break;
|
||||
case CODEC_CTRL_RESUME:
|
||||
ret |= es7149Resume(mode);
|
||||
break;
|
||||
case CODEC_CTRL_POWERDONW:
|
||||
ret |= es7149PwrDown(mode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7149Start(HalCodecMode_e mode)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149Start, P_DEBUG, "[ES7149] es7149Start");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7149Stop(HalCodecMode_e mode)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
switch(mode)
|
||||
{
|
||||
case CODEC_MODE_ENCODE:
|
||||
es7149AdcStandby(&adcVolBak);
|
||||
break;
|
||||
|
||||
case CODEC_MODE_DECODE:
|
||||
{
|
||||
es7149DacStandby(&dacVolBak);
|
||||
|
||||
// disable PA
|
||||
if (isHasPA)
|
||||
{
|
||||
es7149EnablePA(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CODEC_MODE_BOTH:
|
||||
es7149Standby(&dacVolBak, &adcVolBak);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7149Resume(HalCodecMode_e mode)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
switch(mode)
|
||||
{
|
||||
case CODEC_MODE_ENCODE:
|
||||
es7149AdcResume();
|
||||
break;
|
||||
|
||||
case CODEC_MODE_DECODE:
|
||||
{
|
||||
es7149DacResume();
|
||||
|
||||
// enable PA
|
||||
if (isHasPA)
|
||||
{
|
||||
es7149EnablePA(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CODEC_MODE_BOTH:
|
||||
es7149AllResume();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
HalCodecSts_e es7149SetVolume(int volume)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149SetVolume, P_DEBUG, "[ES7149] es7149SetVolume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7149GetVolume(int *volume)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149GetVolume, P_DEBUG, "[ES7149] es7149GetVolume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7149SetMute(bool enable)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149SetMute, P_DEBUG, "[ES7149] es7149SetMute");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7149GetVoiceMute(int *mute)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149GetVoiceMute, P_DEBUG, "[ES7149] es7149GetVoiceMute");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es7149SetMicVolume(uint8_t micGain, int micVolume)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es7149SetMicVolume, P_DEBUG, "[ES7149] es7149SetMicVolume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecCfg_t es7149GetDefaultCfg()
|
||||
{
|
||||
HalCodecCfg_t codecCfg = ES7149_DEFAULT_CONFIG();
|
||||
|
||||
return codecCfg;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,767 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2019-, Copyrigths of EigenComm Ltd.
|
||||
* File name: es8374.c
|
||||
* Description: EC7xx es8374 file
|
||||
* History: Rev1.0 2021-9-18
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "es8374.h"
|
||||
#include "sctdef.h"
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
//adcInput 单声道ADC输入通道选择是CH1(MIC1P/1N)还是CH2(MIC2P/2N)
|
||||
//dacOutput 单声道DAC输出通道选择:默认选择0:L声道,1:R声道
|
||||
//mode 产品主从模式选择:默认选择0为SlaveMode,打开为1选择MasterMode
|
||||
//fmt 数据格式选择,需要和实际时序匹配
|
||||
//bits 数据长度选择,需要和实际时序匹配
|
||||
#define ES8374_DEFAULT_CONFIG() \
|
||||
{ \
|
||||
.adcInput = CODEC_ADC_INPUT_LINE2, \
|
||||
.dacOutput = CODEC_DAC_OUTPUT_LINE1, \
|
||||
.codecMode = CODEC_MODE_BOTH, \
|
||||
.codecIface = { \
|
||||
.mode = CODEC_MODE_SLAVE, \
|
||||
.fmt = CODEC_I2S_MODE, \
|
||||
.samples = CODEC_16K_SAMPLES, \
|
||||
.bits = CODEC_BIT_LENGTH_16BITS, \
|
||||
.channel = CODEC_MONO, \
|
||||
.polarity = 1, \
|
||||
}, \
|
||||
};
|
||||
|
||||
#define VDDSPK_5V0 0x2B
|
||||
#define VDDSPK_4V2 0x2A
|
||||
#define VDDSPK_3V3 0x29
|
||||
|
||||
#define RATIO 256 //实际Ratio=MCLK/LRCK比率,需要和实际时钟比例匹配
|
||||
#define SCLK_DIV 4 //SCLK分频选择:(选择范围1~18),SCLK=MCLK/SCLK_DIV,超过后非等比增加具体对应关系见相应DS说明
|
||||
#define SCLK_INV 0 //默认对齐方式为下降沿,1为上升沿对齐,需要和实际时序匹配
|
||||
#define VDDSPK_VOLTAGE VDDSPK_4V2 //SPK拟电压选择为4V2还是5V0,需要和实际硬件匹配
|
||||
#define ADC_PGA_DF2SE_15DB 1 //ADC模拟固定15dB增益:默认选择关闭0,打开为1
|
||||
#define ADC_PGA_GAIN 3 //ADC模拟增益:(选择范围0~7),具体对应关系见相应DS说明
|
||||
#define ADC_VOLUME_MAX 0 //ADC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define ADC_VOLUME_MIN 50 //ADC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define ADC_VOLUME_MUTE 192 //ADC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define ADC_VOLUME_DEFAULT ADC_VOLUME_MAX //ADC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define DAC_VOLUME_MAX 0 //DAC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define DAC_VOLUME_MIN 50 //DAC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define DAC_VOLUME_MUTE 192 //DAC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define DAC_VOLUME_DEFAULT DAC_VOLUME_MAX //DAC数字增益:(选择范围0~192),0:0DB,-0.5dB/Step
|
||||
#define DMIC_SELON 0 //DMIC选择:默认选择关闭0,立体声打开为1,单声道需要选择2为H,3为L
|
||||
#define DMIC_GAIN 0 //DMIC增益:(选择范围0~1),6dB/Step
|
||||
#define MICBIASOFF 0 //内部MICBIAS偏置:默认选择关闭1,开启配置为0
|
||||
#define PA_VOLUME_DEFAULT 7 //(0~7),(0db,1.5db,3db,4db,5db,6db,6.75db,7.5db)
|
||||
//16K,8K采样率下配置PLL_SET_12288 = 1 可以改善音质,目前只支持256Ratio,其他待更新
|
||||
#define PLL_SET_12288 1 //PLL选择输入频率,单位为KHZ:外部输入XXXXKHZ内部PLL锁成12M288
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCTION DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
// 8374 func list
|
||||
AP_PLAT_COMMON_DATA HalCodecFuncList_t es8374DefaultHandle =
|
||||
{
|
||||
.codecType = ES8374,
|
||||
.halCodecInitFunc = es8374Init,
|
||||
.halCodecDeinitFunc = es8374DeInit,
|
||||
.halCodecCtrlStateFunc = es8374StartStop,
|
||||
.halCodecCfgIfaceFunc = es8374Config,
|
||||
.halCodecSetMuteFunc = es8374SetMute,
|
||||
.halCodecSetVolumeFunc = es8374SetVolume,
|
||||
.halCodecGetVolumeFunc = es8374GetVolume,
|
||||
//.halCodecEnablePAFunc = es8374EnablePA,
|
||||
.halCodecSetMicVolumeFunc = es8374SetMicVolume,
|
||||
.halCodecGetMicVolumeFunc = NULL,
|
||||
.halCodecLock = NULL,
|
||||
.handle = NULL,
|
||||
.halCodecGetDefaultCfg = es8374GetDefaultCfg,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
AP_PLAT_COMMON_BSS static uint8_t dacVolBak, adcVolBak;
|
||||
AP_PLAT_COMMON_BSS static bool isHasPA;
|
||||
AP_PLAT_COMMON_DATA static uint8_t adcInput = 2;
|
||||
AP_PLAT_COMMON_BSS static uint8_t dacOutput = 0;
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static int32_t es8374WriteReg(uint8_t regAddr, uint16_t data)
|
||||
{
|
||||
int32_t ret = 0;
|
||||
uint8_t rxNack = 0;
|
||||
|
||||
uint8_t cmd[2] = {0};
|
||||
cmd[0] = regAddr;
|
||||
cmd[1] = data & 0xff;
|
||||
|
||||
ret = halI2cWrite(ES8374_IICADDR, cmd, 2, &rxNack, false);
|
||||
|
||||
#if 0
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374WriteReg, P_DEBUG, "[ES8374] [%x] %x", regAddr, data);
|
||||
#else
|
||||
printf("[ES8374] [%02X] %02X\r\n", regAddr, data);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t es8374ReadReg(uint8_t regAddr, uint8_t* retData)
|
||||
{
|
||||
return halI2cRead(ES8374_IICADDR, regAddr, retData, false);
|
||||
}
|
||||
|
||||
// enable pa power
|
||||
void es8374EnablePA(bool enable)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374EnablePA, P_DEBUG, "[ES8374] es8374EnablePA: enable=%d", enable);
|
||||
|
||||
#if 0
|
||||
if (enable)
|
||||
{
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20); // spk on
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1E, 0xa0); // spk on
|
||||
}
|
||||
else
|
||||
{
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20);
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1C, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1D, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x40); // spk off
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// set es8374 into suspend mode
|
||||
void es8374Standby(uint8_t* dacVolB, uint8_t* adcVolB)//待机配置--搭配es8374AllResume(void)//恢复配置
|
||||
{
|
||||
es8374ReadReg(ES8374_REG_38, dacVolB);
|
||||
es8374ReadReg(ES8374_REG_25, adcVolB);
|
||||
|
||||
es8374WriteReg(ES8374_REG_38, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_25, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_28, 0x1C);
|
||||
es8374WriteReg(ES8374_REG_36, 0x20);
|
||||
es8374WriteReg(ES8374_REG_37, 0x20);
|
||||
es8374WriteReg(ES8374_REG_6D, 0x00);
|
||||
es8374WriteReg(ES8374_REG_09, 0x80);
|
||||
es8374WriteReg(ES8374_REG_1A, 0x08);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20);
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1C, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1D, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x40);
|
||||
es8374WriteReg(ES8374_REG_24, 0x20);
|
||||
es8374WriteReg(ES8374_REG_22, 0x00);
|
||||
es8374WriteReg(ES8374_REG_21, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_15, 0xFF);
|
||||
es8374WriteReg(ES8374_REG_14, 0x82);
|
||||
es8374WriteReg(ES8374_REG_01, 0x03);
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Standby, P_DEBUG, "[ES8374] es8374Standby: dacVolB=%d, adcVolB=%d", *dacVolB, *adcVolB);
|
||||
}
|
||||
|
||||
#if 1
|
||||
// set es8374 ADC into suspend mode
|
||||
void es8374AdcStandby(uint8_t* adcVolB)//ADC待机配置--搭配es8374AdcResume
|
||||
{
|
||||
es8374ReadReg(ES8374_REG_25, adcVolB);
|
||||
|
||||
es8374WriteReg(ES8374_REG_25, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_15, 0x00);
|
||||
es8374WriteReg(ES8374_REG_28, 0x1C);
|
||||
es8374WriteReg(ES8374_REG_09, 0x80);
|
||||
delay_us(5000);
|
||||
es8374WriteReg(ES8374_REG_24, 0x20);
|
||||
es8374WriteReg(ES8374_REG_21, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_15, 0x0C);
|
||||
es8374WriteReg(ES8374_REG_01, 0x75);
|
||||
|
||||
}
|
||||
|
||||
// set es8374 DAC into suspend mode
|
||||
void es8374DacStandby(uint8_t* dacVolB)//DAC待机配置--搭配es8374DacResume
|
||||
{
|
||||
es8374ReadReg(ES8374_REG_38, dacVolB);
|
||||
|
||||
es8374WriteReg(ES8374_REG_38, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_15, 0x00);
|
||||
es8374WriteReg(ES8374_REG_36, 0x20);
|
||||
es8374WriteReg(ES8374_REG_37, 0x20);
|
||||
es8374WriteReg(ES8374_REG_6D, 0x00);
|
||||
es8374WriteReg(ES8374_REG_09, 0x80);
|
||||
es8374WriteReg(ES8374_REG_1A, 0x08);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20);
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1C, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1D, 0x10);
|
||||
//es8374WriteReg(ES8374_REG_1E, 0x40); // spk off
|
||||
es8374WriteReg(ES8374_REG_15, 0x62);
|
||||
es8374WriteReg(ES8374_REG_01, 0x7A);
|
||||
|
||||
}
|
||||
#endif
|
||||
#if 1
|
||||
// set es8374 adc into resume mode
|
||||
static HalCodecSts_e es8374AdcResume(void)//ADC恢复配置--搭配es8374AdcStandby
|
||||
{
|
||||
|
||||
es8374WriteReg(ES8374_REG_01, 0x7F);
|
||||
es8374WriteReg(ES8374_REG_15, 0x00);
|
||||
es8374WriteReg(ES8374_REG_21, (adcInput << 4) + (ADC_PGA_DF2SE_15DB << 2));
|
||||
es8374WriteReg(ES8374_REG_24, 0x08 + (DMIC_GAIN << 7) + DMIC_SELON);
|
||||
es8374WriteReg(ES8374_REG_09, 0x41);
|
||||
es8374WriteReg(ES8374_REG_28, 0x00);
|
||||
es8374WriteReg(ES8374_REG_15, 0x40);
|
||||
es8374WriteReg(ES8374_REG_25, adcVolBak);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
// set es8374 dac into resume mode
|
||||
static HalCodecSts_e es8374DacResume(void)//DAC恢复配置--搭配es8374DacStandby
|
||||
{
|
||||
|
||||
es8374WriteReg(ES8374_REG_01, 0x7F);
|
||||
es8374WriteReg(ES8374_REG_15, 0x00);
|
||||
es8374WriteReg(ES8374_REG_21, 0x50);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20); // spk on
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1E, 0xa0); // spk on
|
||||
es8374WriteReg(ES8374_REG_1D, VDDSPK_VOLTAGE);
|
||||
es8374WriteReg(ES8374_REG_1C, 0x90);
|
||||
es8374WriteReg(ES8374_REG_1A, 0xA0);
|
||||
es8374WriteReg(ES8374_REG_09, 0x41);
|
||||
es8374WriteReg(ES8374_REG_6D, 0x60);
|
||||
es8374WriteReg(ES8374_REG_37, 0x00);
|
||||
es8374WriteReg(ES8374_REG_36, (dacOutput << 6));
|
||||
es8374WriteReg(ES8374_REG_15, 0x40);
|
||||
es8374WriteReg(ES8374_REG_38, dacVolBak);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// set es8374 into resume mode
|
||||
static HalCodecSts_e es8374AllResume(void)//恢复配置(未下电)--搭配es8374Standby(void)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374AllResume, P_DEBUG, "[ES8374] es8374AllResume: dacVolBak=%d, adcVolBak=%d", dacVolBak, adcVolBak);
|
||||
|
||||
es8374WriteReg(ES8374_REG_01, 0x7F);
|
||||
es8374WriteReg(ES8374_REG_14, 0x8A + (MICBIASOFF << 4));
|
||||
es8374WriteReg(ES8374_REG_15, 0x00);
|
||||
es8374WriteReg(ES8374_REG_21, 0x50);
|
||||
es8374WriteReg(ES8374_REG_22, ADC_PGA_GAIN + (ADC_PGA_GAIN << 4));
|
||||
es8374WriteReg(ES8374_REG_21, (adcInput << 4) + (ADC_PGA_DF2SE_15DB << 2));
|
||||
es8374WriteReg(ES8374_REG_24, 0x08 + (DMIC_GAIN << 7) + DMIC_SELON);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20); // spk on
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1E, 0xa0); // spk on
|
||||
es8374WriteReg(ES8374_REG_1D, VDDSPK_VOLTAGE);
|
||||
es8374WriteReg(ES8374_REG_1C, 0x90);
|
||||
es8374WriteReg(ES8374_REG_1A, 0xA0);
|
||||
es8374WriteReg(ES8374_REG_09, 0x41);
|
||||
es8374WriteReg(ES8374_REG_6D, 0x60);
|
||||
es8374WriteReg(ES8374_REG_37, 0x00);
|
||||
es8374WriteReg(ES8374_REG_36, (dacOutput << 6));
|
||||
es8374WriteReg(ES8374_REG_28, 0x00);
|
||||
es8374WriteReg(ES8374_REG_15, 0x40);
|
||||
es8374WriteReg(ES8374_REG_38, dacVolBak);
|
||||
es8374WriteReg(ES8374_REG_25, adcVolBak);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// set es8374 into powerdown mode
|
||||
static HalCodecSts_e es8374PwrDown(HalCodecModule_e mode)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374PwrDown, P_DEBUG, "[ES8374] es8374PwrDown: mode=%d", mode);
|
||||
|
||||
es8374WriteReg(ES8374_REG_38, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_25, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_15, 0x00);
|
||||
es8374WriteReg(ES8374_REG_28, 0x1C);
|
||||
es8374WriteReg(ES8374_REG_36, 0x20);
|
||||
es8374WriteReg(ES8374_REG_37, 0x20);
|
||||
es8374WriteReg(ES8374_REG_6D, 0x00);
|
||||
es8374WriteReg(ES8374_REG_09, 0x80);
|
||||
es8374WriteReg(ES8374_REG_1A, 0x08);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20);
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1C, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1D, 0x10);
|
||||
es8374WriteReg(ES8374_REG_1E, 0x40);
|
||||
es8374WriteReg(ES8374_REG_24, 0x20);
|
||||
es8374WriteReg(ES8374_REG_22, 0x00);
|
||||
es8374WriteReg(ES8374_REG_21, 0xC0);
|
||||
es8374WriteReg(ES8374_REG_15, 0xFF);
|
||||
es8374WriteReg(ES8374_REG_14, 0x16);
|
||||
es8374WriteReg(ES8374_REG_01, 0x03);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
HalCodecSts_e es8374Init(HalCodecCfg_t *codecCfg)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Init_1, P_DEBUG, "[ES8374] es8374Init_1: adcInput=%d, dacOutput=%d, codecMode=%d, hasPA=%d",
|
||||
codecCfg->adcInput, codecCfg->dacOutput, codecCfg->codecMode, codecCfg->hasPA);
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Init_2, P_DEBUG, "[ES8374] es8374Init_2: mode=%d, fmt=%d, samples=%d, bits=%d, channel=%d, polarity=%d",
|
||||
codecCfg->codecIface.mode, codecCfg->codecIface.fmt, codecCfg->codecIface.samples, codecCfg->codecIface.bits, codecCfg->codecIface.channel, codecCfg->codecIface.polarity);
|
||||
|
||||
//codecI2cInit();
|
||||
halI2cInit(false);
|
||||
|
||||
switch (codecCfg->adcInput)
|
||||
{
|
||||
case CODEC_ADC_INPUT_LINE1:
|
||||
adcInput = 1;
|
||||
break;
|
||||
|
||||
case CODEC_ADC_INPUT_LINE2:
|
||||
adcInput = 2;
|
||||
break;
|
||||
|
||||
case CODEC_ADC_INPUT_ALL:
|
||||
adcInput = 3;
|
||||
break;
|
||||
|
||||
case CODEC_ADC_INPUT_DIFFERENCE:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (codecCfg->dacOutput)
|
||||
{
|
||||
case CODEC_DAC_OUTPUT_LINE1:
|
||||
dacOutput = 0;
|
||||
break;
|
||||
|
||||
case CODEC_DAC_OUTPUT_LINE2:
|
||||
dacOutput = 1;
|
||||
break;
|
||||
|
||||
case CODEC_DAC_OUTPUT_ALL:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
es8374WriteReg(ES8374_REG_00, 0x3F); //IC Rst start
|
||||
es8374WriteReg(ES8374_REG_00, 0x03); //IC Rst stop
|
||||
es8374WriteReg(ES8374_REG_01, 0x7F); //IC clk on
|
||||
es8374WriteReg(ES8374_REG_02, 0x00);
|
||||
es8374WriteReg(ES8374_REG_03, 0x20);
|
||||
es8374WriteReg(ES8374_REG_04, 0x00);
|
||||
es8374WriteReg(ES8374_REG_05, 0x11); //clk div set
|
||||
if(PLL_SET_12288 == 1)
|
||||
{
|
||||
es8374WriteReg(ES8374_REG_6F, 0xA0); //pll set:mode enable
|
||||
es8374WriteReg(ES8374_REG_72, 0x41); //pll set:mode set
|
||||
es8374WriteReg(ES8374_REG_09, 0x01); //pll set:reset on ,set start
|
||||
es8374WriteReg(ES8374_REG_0A, 0x8A);
|
||||
es8374WriteReg(ES8374_REG_0B, 0x0C);
|
||||
es8374WriteReg(ES8374_REG_0C, 0x00);
|
||||
es8374WriteReg(ES8374_REG_0D, 0x00);
|
||||
es8374WriteReg(ES8374_REG_0E, 0x00);
|
||||
es8374WriteReg(ES8374_REG_09, 0x41); //pll set:reset off ,set stop
|
||||
es8374WriteReg(ES8374_REG_02, 0x08); //pll set:use pll
|
||||
es8374WriteReg(ES8374_REG_03, 0x30); //384 OSR
|
||||
es8374WriteReg(ES8374_REG_04, 0x20); //384 OSR
|
||||
}
|
||||
es8374WriteReg(ES8374_REG_06, (RATIO >> 8)); //LRCK DIV
|
||||
es8374WriteReg(ES8374_REG_07, (RATIO & 0xFF)); //LRCK DIV
|
||||
es8374SetBitsPerSample(codecCfg->codecIface.bits);
|
||||
es8374ConfigFmt(codecCfg->codecIface.fmt);
|
||||
es8374WriteReg(ES8374_REG_0F, (((codecCfg->codecIface.mode == CODEC_MODE_SLAVE) ? 0 : 1) << 7) + (SCLK_INV<<5) + SCLK_DIV);
|
||||
es8374WriteReg(ES8374_REG_24, 0x08 + (DMIC_GAIN << 7) + DMIC_SELON); //adc set
|
||||
es8374WriteReg(ES8374_REG_36, (dacOutput << 6)); //dac set
|
||||
es8374WriteReg(ES8374_REG_12, 0x30); //timming set
|
||||
es8374WriteReg(ES8374_REG_13, 0x20); //timming set
|
||||
es8374WriteReg(ES8374_REG_18, 0xFF);
|
||||
es8374WriteReg(ES8374_REG_21, 0x50);
|
||||
es8374WriteReg(ES8374_REG_22, ADC_PGA_GAIN + (ADC_PGA_GAIN << 4)); //adc set
|
||||
es8374WriteReg(ES8374_REG_21, (adcInput << 4) + (ADC_PGA_DF2SE_15DB << 2));
|
||||
es8374WriteReg(ES8374_REG_00, 0x80); // IC START
|
||||
delay_us(10000);
|
||||
es8374WriteReg(ES8374_REG_14, 0x8A + (MICBIASOFF << 4));
|
||||
es8374WriteReg(ES8374_REG_15, 0x40);
|
||||
es8374WriteReg(ES8374_REG_1A, 0xA0); // monoout set
|
||||
es8374WriteReg(ES8374_REG_1B, 0x19); //5V 0DB
|
||||
es8374WriteReg(ES8374_REG_1C, 0x90);
|
||||
es8374WriteReg(ES8374_REG_1D, VDDSPK_VOLTAGE); //5V 0DB 8R=>1W
|
||||
es8374WriteReg(ES8374_REG_1F, 0x00); // spk set
|
||||
es8374WriteReg(ES8374_REG_20, 0x00); // spk set
|
||||
es8374WriteReg(ES8374_REG_1E, 0x20); // spk on
|
||||
delay_us(1000);
|
||||
es8374WriteReg(ES8374_REG_1E, 0xa0); // spk on
|
||||
es8374WriteReg(ES8374_REG_28, 0x00); // alc set
|
||||
es8374WriteReg(ES8374_REG_25, ADC_VOLUME_DEFAULT); // ADCVOLUME on
|
||||
es8374WriteReg(ES8374_REG_38, DAC_VOLUME_DEFAULT); // DACVOLUMEL on
|
||||
es8374WriteReg(ES8374_REG_37, 0x00); // dac set
|
||||
es8374WriteReg(ES8374_REG_6D, 0x60); // SEL:GPIO1=DMIC CLK OUT+SEL:GPIO2=PLL CLK OUT
|
||||
|
||||
isHasPA = codecCfg->hasPA;
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
void es8374DeInit()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374DeInit, P_DEBUG, "[ES8374] es8374DeInit");
|
||||
|
||||
halI2cDeInit(false);
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374ConfigFmt(HalCodecIfaceFormat_e fmt)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
uint8_t adc = 0, dac = 0;
|
||||
es8374ReadReg(ES8374_REG_10, &adc);
|
||||
es8374ReadReg(ES8374_REG_11, &dac);
|
||||
adc = adc & 0xdc;
|
||||
dac = dac & 0xdc;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374ConfigFmt, P_DEBUG, "[ES8374] es8374ConfigFmt: fmt=%d", fmt);
|
||||
|
||||
switch (fmt)
|
||||
{
|
||||
case CODEC_MSB_MODE:
|
||||
case CODEC_LSB_MODE:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374fmt_1, P_DEBUG, "[ES8374] left/right Format");
|
||||
adc |= 0x01;
|
||||
dac |= 0x01;
|
||||
break;
|
||||
|
||||
case CODEC_I2S_MODE:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374fmt_2, P_DEBUG, "[ES8374] I2S Format");
|
||||
adc |= 0x00;
|
||||
dac |= 0x00;
|
||||
break;
|
||||
|
||||
case CODEC_PCM_MODE:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374fmt_3, P_DEBUG, "[ES8374] pcm Format");
|
||||
adc |= 0x03;
|
||||
dac |= 0x03;
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374fmt_5, P_DEBUG, "[ES8374] default Format (I2S)");
|
||||
adc |= 0x00;
|
||||
dac |= 0x00;
|
||||
break;
|
||||
}
|
||||
|
||||
ret |= es8374WriteReg(ES8374_REG_10, adc);
|
||||
ret |= es8374WriteReg(ES8374_REG_11, dac);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374SetBitsPerSample(HalCodecIfaceBits_e bits)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
uint8_t adc = 0, dac = 0;
|
||||
es8374ReadReg(ES8374_REG_10, &adc);
|
||||
es8374ReadReg(ES8374_REG_11, &dac);
|
||||
adc = adc & 0xe3;
|
||||
dac = dac & 0xe3;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetBitsPerSample, P_DEBUG, "[ES8374] es8374SetBitsPerSample: bits=%d", bits);
|
||||
|
||||
switch (bits)
|
||||
{
|
||||
case CODEC_BIT_LENGTH_16BITS:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetBitsPerSample_1, P_DEBUG, "[ES8374] 16 bits");
|
||||
adc |= 0x0C;
|
||||
dac |= 0x0C;
|
||||
break;
|
||||
|
||||
case CODEC_BIT_LENGTH_24BITS:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetBitsPerSample_2, P_DEBUG, "[ES8374] 24 bits");
|
||||
adc |= 0x00;
|
||||
dac |= 0x00;
|
||||
break;
|
||||
|
||||
case CODEC_BIT_LENGTH_32BITS:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetBitsPerSample_3, P_DEBUG, "[ES8374] 32 bits");
|
||||
adc |= 0x10;
|
||||
dac |= 0x10;
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetBitsPerSample_5, P_DEBUG, "[ES8374] default bit length (16 bits)");
|
||||
adc |= 0x0C;
|
||||
dac |= 0x0C;
|
||||
break;
|
||||
}
|
||||
|
||||
ret |= es8374WriteReg(ES8374_REG_10, adc);
|
||||
ret |= es8374WriteReg(ES8374_REG_11, dac);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374Config(HalCodecMode_e mode, HalCodecIface_t *iface)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Config, P_DEBUG, "[ES8374] es8374Config: mode=%d, bits=%d, fmt=%d", mode, iface->bits, iface->fmt);
|
||||
|
||||
ret |= es8374SetBitsPerSample(iface->bits);
|
||||
ret |= es8374ConfigFmt(iface->fmt);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374StartStop(HalCodecMode_e mode, HalCodecCtrlState_e ctrlState)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374StartStop, P_DEBUG, "[ES8374] es8374StartStop: mode=%d, ctrlState=%d", mode, ctrlState);
|
||||
switch(ctrlState)
|
||||
{
|
||||
case CODEC_CTRL_START:
|
||||
ret |= es8374Start(mode);
|
||||
if (isHasPA)
|
||||
{
|
||||
//es8374EnablePA(true);
|
||||
}
|
||||
break;
|
||||
case CODEC_CTRL_STOP:
|
||||
ret |= es8374Stop(mode);
|
||||
break;
|
||||
case CODEC_CTRL_RESUME:
|
||||
ret |= es8374Resume(mode);
|
||||
break;
|
||||
case CODEC_CTRL_POWERDONW:
|
||||
ret |= es8374PwrDown(mode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374Start(HalCodecModule_e mode)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Start, P_DEBUG, "[ES8374] es8374Start: mode=%d", mode);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374Stop(HalCodecModule_e mode)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Stop, P_DEBUG, "[ES8374] es8374Stop: mode=%d", mode);
|
||||
switch(mode)
|
||||
{
|
||||
case CODEC_MODE_ENCODE:
|
||||
es8374AdcStandby(&adcVolBak);
|
||||
break;
|
||||
|
||||
case CODEC_MODE_DECODE:
|
||||
es8374DacStandby(&dacVolBak);
|
||||
if (isHasPA)
|
||||
{
|
||||
delay_us(2000);
|
||||
//es8374EnablePA(false);
|
||||
}
|
||||
break;
|
||||
|
||||
case CODEC_MODE_BOTH:
|
||||
es8374Standby(&dacVolBak, &adcVolBak);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374Resume(HalCodecMode_e mode)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374Resume, P_DEBUG, "[ES8374] es8374Resume: mode=%d", mode);
|
||||
switch(mode)
|
||||
{
|
||||
case CODEC_MODE_ENCODE:
|
||||
//es8374AllResume();
|
||||
|
||||
es8374AdcResume();
|
||||
break;
|
||||
|
||||
case CODEC_MODE_DECODE:
|
||||
//es8374AllResume();
|
||||
|
||||
es8374DacResume();
|
||||
if (isHasPA)
|
||||
{
|
||||
//es8374EnablePA(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case CODEC_MODE_BOTH:
|
||||
es8374AllResume();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374SetVolume(HalCodecCfg_t* codecHalCfg, int volume)
|
||||
{
|
||||
uint8_t level = volume;
|
||||
uint8_t value = DAC_VOLUME_MUTE;
|
||||
|
||||
if (level > 0)
|
||||
{
|
||||
level = (level > 100) ? 100 : level;
|
||||
value = DAC_VOLUME_MIN - (level * DAC_VOLUME_MIN / 100);
|
||||
}
|
||||
|
||||
es8374WriteReg(ES8374_REG_38, value);
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetVolume, P_DEBUG, "[ES8374] es8374SetVolume: volume=%d, level=%d, value=%d", volume, level, value);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374GetVolume(HalCodecCfg_t* codecHalCfg, int *volume)
|
||||
{
|
||||
uint8_t level = 0;
|
||||
uint8_t value = 0;
|
||||
es8374ReadReg(ES8374_REG_38, &value);
|
||||
|
||||
if (value <= DAC_VOLUME_MIN)
|
||||
{
|
||||
level = 100 - (value * 100 / DAC_VOLUME_MIN);
|
||||
level = (level == 0) ? 1 : level;
|
||||
}
|
||||
|
||||
*volume = level;
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374GetVolume, P_DEBUG, "[ES8374] es8374GetVolume: value=%d, level=%d", value, level);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374SetMute(HalCodecCfg_t* codecHalCfg, bool enable)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetMute, P_DEBUG, "[ES8374] es8374SetMute: enable=%d", enable);
|
||||
|
||||
if (enable == true)
|
||||
{
|
||||
es8374WriteReg(ES8374_REG_36, 0x20);
|
||||
}
|
||||
else
|
||||
{
|
||||
es8374WriteReg(ES8374_REG_36, (dacOutput << 6));
|
||||
}
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374GetVoiceMute(uint8_t *mute)
|
||||
{
|
||||
//*mute = (es8374ReadReg(ES8374_REG_36) >> 5) & 0x01;
|
||||
es8374ReadReg(ES8374_REG_36, mute);
|
||||
*mute = (*mute >> 5) & 0x01;
|
||||
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374GetVoiceMute, P_DEBUG, "[ES8374] es8374GetVoiceMute: mute=%d", *mute);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e es8374SetMicVolume(HalCodecCfg_t* codecHalCfg, uint8_t micGain, int micVolume)
|
||||
{
|
||||
uint8_t level = micVolume;
|
||||
uint8_t value = ADC_VOLUME_MUTE;
|
||||
|
||||
if (level > 0)
|
||||
{
|
||||
level = (level > 100) ? 100 : level;
|
||||
value = ADC_VOLUME_MIN - (level * ADC_VOLUME_MIN / 100);
|
||||
}
|
||||
|
||||
es8374WriteReg(ES8374_REG_25, value);
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374SetMicVolume, P_DEBUG, "[ES8374] es8374SetMicVolume: micVolume=%d, level=%d, value=%d", micVolume, level, value);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
void es8374ReadAll()
|
||||
{
|
||||
uint8_t reg = 0;
|
||||
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374ReadAll_1, P_DEBUG, "[ES8374] es8374ReadAll Begin");
|
||||
#else
|
||||
printf("[ES8374] es8374ReadAll Begin\r\n");
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < 0x6E; i++)
|
||||
{
|
||||
es8374ReadReg(i, ®);
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374ReadAll_2, P_DEBUG, "[ES8374] [%x] %x", reg, i);
|
||||
#else
|
||||
printf("[ES8374] [%02X] %02X\r\n", i, reg);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, es8374ReadAll_3, P_DEBUG, "[ES8374] es8374ReadAll End");
|
||||
#else
|
||||
printf("[ES8374] es8374ReadAll End\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
HalCodecCfg_t es8374GetDefaultCfg()
|
||||
{
|
||||
HalCodecCfg_t codecCfg = ES8374_DEFAULT_CONFIG();
|
||||
|
||||
return codecCfg;
|
||||
}
|
@ -1,319 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2019-, Copyrigths of EigenComm Ltd.
|
||||
* File name: tm8211.c
|
||||
* Description: EC7xx tm8211 file
|
||||
* History: Rev1.0 2021-9-18
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "tm8211.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define TM8211_DEFAULT_CONFIG() \
|
||||
{ \
|
||||
.codecIface = { \
|
||||
.mode = CODEC_MODE_SLAVE, \
|
||||
.fmt = CODEC_MSB_MODE, \
|
||||
.samples = CODEC_16K_SAMPLES, \
|
||||
.bits = CODEC_BIT_LENGTH_16BITS, \
|
||||
.channel = CODEC_MONO, \
|
||||
.polarity = 1, \
|
||||
}, \
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCTION DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
// 8311 func list
|
||||
HalCodecFuncList_t tm8211DefaultHandle =
|
||||
{
|
||||
.codecType = TM8211,
|
||||
.halCodecInitFunc = tm8211Init,
|
||||
.halCodecDeinitFunc = tm8211DeInit,
|
||||
.halCodecCtrlStateFunc = tm8211StartStop,
|
||||
.halCodecCfgIfaceFunc = tm8211Config,
|
||||
.halCodecSetMuteFunc = tm8211SetMute,
|
||||
.halCodecSetVolumeFunc = tm8211SetVolume,
|
||||
.halCodecGetVolumeFunc = tm8211GetVolume,
|
||||
//.halCodecEnablePAFunc = tm8211EnablePA,
|
||||
.halCodecSetMicVolumeFunc = tm8211SetMicVolume,
|
||||
.halCodecLock = NULL,
|
||||
.handle = NULL,
|
||||
.halCodecGetDefaultCfg = tm8211GetDefaultCfg,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static uint8_t dacVolBak, adcVolBak;
|
||||
static bool isHasPA;
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
// set tm8211 into suspend mode
|
||||
static void tm8211Standby(uint8_t* dacVolB, uint8_t* adcVolB)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211Standby, P_DEBUG, "[TM8211] tn8211Standby: dacVolB=%d, adcVolB=%d", *dacVolB, *adcVolB);
|
||||
}
|
||||
|
||||
// set tm8211 ADC into suspend mode
|
||||
static void tm8211AdcStandby(uint8_t* adcVolB)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211AdcStandby, P_DEBUG, "[TM8211] tm8211AdcStandby");
|
||||
}
|
||||
|
||||
// set tm8211 DAC into suspend mode
|
||||
static void tm8211DacStandby(uint8_t* dacVolB)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211DacStandby, P_DEBUG, "[TM8211] tm8211DacStandby");
|
||||
}
|
||||
|
||||
// set tm8211 into resume mode
|
||||
static HalCodecSts_e tm8211AllResume()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211AllResume, P_DEBUG, "[TM8211] tm8211AllResume: dacVolBak=%d, adcVolBak=%d", dacVolBak, adcVolBak);
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
// set tm8211 adc into resume mode
|
||||
static HalCodecSts_e tm8211AdcResume()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211AdcResume, P_DEBUG, "[TM8211] tm8211AdcResume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
// set tm8211 dac into resume mode
|
||||
static HalCodecSts_e tm8211DacResume()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211DacResume, P_DEBUG, "[TM8211] tm8211DacResume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
// set tm8211 into powerdown mode
|
||||
static HalCodecSts_e tm8211PwrDown()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211PwrDown, P_DEBUG, "[TM8211] tm8211PwrDown");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
// enable pa power
|
||||
void tm8211EnablePA(bool enable)
|
||||
{
|
||||
GPIO_pinWrite(CODEC_PA_GPIO_INSTANCE, 1 << CODEC_PA_GPIO_PIN, (enable == true) ? (1 << CODEC_PA_GPIO_PIN) : 0);
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211EnablePA, P_DEBUG, "[TM8211] Set PA: %d", enable);
|
||||
}
|
||||
|
||||
HalCodecSts_e tm8211Init(HalCodecCfg_t *codecCfg)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211Init, P_DEBUG, "[TM8211] tm8211Init: hasPA=%d", codecCfg->hasPA);
|
||||
|
||||
if (codecCfg->hasPA)
|
||||
{
|
||||
isHasPA = codecCfg->hasPA;
|
||||
|
||||
// GPIO function select
|
||||
PadConfig_t padConfig = {0};
|
||||
GpioPinConfig_t pinConfig = {0};
|
||||
|
||||
PAD_getDefaultConfig(&padConfig);
|
||||
padConfig.mux = PAD_MUX_ALT0;
|
||||
PAD_setPinConfig(CODEC_PA_PAD_INDEX, &padConfig);
|
||||
|
||||
// CODEC_PA pin config
|
||||
pinConfig.pinDirection = GPIO_DIRECTION_OUTPUT;
|
||||
pinConfig.misc.initOutput = 0; // when codec has been init, PA should open
|
||||
GPIO_pinConfig(CODEC_PA_GPIO_INSTANCE, CODEC_PA_GPIO_PIN, &pinConfig);
|
||||
}
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
void tm8211DeInit()
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211DeInit, P_DEBUG, "[TM8211] tm8211DeInit");
|
||||
}
|
||||
|
||||
HalCodecSts_e tm8211Config(HalCodecMode_e mode, HalCodecIface_t *iface)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211Config, P_DEBUG, "[TM8211] tm8211Config");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e tm8211StartStop(HalCodecMode_e mode, HalCodecCtrlState_e ctrlState)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
|
||||
switch(ctrlState)
|
||||
{
|
||||
case CODEC_CTRL_START:
|
||||
{
|
||||
ret |= tm8211Start(mode);
|
||||
if (isHasPA)
|
||||
{
|
||||
tm8211EnablePA(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CODEC_CTRL_STOP:
|
||||
ret |= tm8211Stop(mode);
|
||||
break;
|
||||
case CODEC_CTRL_RESUME:
|
||||
ret |= tm8211Resume(mode);
|
||||
break;
|
||||
case CODEC_CTRL_POWERDONW:
|
||||
ret |= tm8211PwrDown(mode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e tm8211Start(HalCodecMode_e mode)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211Start, P_DEBUG, "[TM8211] tm8211Start");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e tm8211Stop(HalCodecMode_e mode)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
switch(mode)
|
||||
{
|
||||
case CODEC_MODE_ENCODE:
|
||||
tm8211AdcStandby(&adcVolBak);
|
||||
break;
|
||||
|
||||
case CODEC_MODE_DECODE:
|
||||
{
|
||||
tm8211DacStandby(&dacVolBak);
|
||||
|
||||
// disable PA
|
||||
if (isHasPA)
|
||||
{
|
||||
tm8211EnablePA(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CODEC_MODE_BOTH:
|
||||
tm8211Standby(&dacVolBak, &adcVolBak);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e tm8211Resume(HalCodecMode_e mode)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
switch(mode)
|
||||
{
|
||||
case CODEC_MODE_ENCODE:
|
||||
tm8211AdcResume();
|
||||
break;
|
||||
|
||||
case CODEC_MODE_DECODE:
|
||||
{
|
||||
tm8211DacResume();
|
||||
|
||||
// enable PA
|
||||
if (isHasPA)
|
||||
{
|
||||
tm8211EnablePA(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CODEC_MODE_BOTH:
|
||||
tm8211AllResume();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
HalCodecSts_e tm8211SetVolume(int volume)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211SetVolume, P_DEBUG, "[TM8211] tm8211SetVolume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e tm8211GetVolume(int *volume)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211GetVolume, P_DEBUG, "[TM8211] tm8211GetVolume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e tm8211SetMute(bool enable)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211SetMute, P_DEBUG, "[TM8211] tm8211SetMute");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e tm8211GetVoiceMute(int *mute)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211GetVoiceMute, P_DEBUG, "[TM8211] tm8211GetVoiceMute");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e tm8211SetMicVolume(uint8_t micGain, int micVolume)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, tm8211SetMicVolume, P_DEBUG, "[TM8211] tm8211SetMicVolume");
|
||||
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecCfg_t tm8211GetDefaultCfg()
|
||||
{
|
||||
HalCodecCfg_t codecCfg = TM8211_DEFAULT_CONFIG();
|
||||
|
||||
return codecCfg;
|
||||
}
|
||||
|
||||
|
@ -1,238 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2019-, Copyrigths of EigenComm Ltd.
|
||||
* File name: hal_codec.c
|
||||
* Description: EC7XX codec hal
|
||||
* History: Rev1.0 2021-9-18
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "codecDrv.h"
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCTION DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
const AudioParaCfgCodec_t codecTlvDefaultVal =
|
||||
{
|
||||
.isDmic = false,
|
||||
.isExPa = true,
|
||||
.exPaGain = 0,
|
||||
.txDigGain = 0xbf,
|
||||
.txAnaGain = 0x8,
|
||||
|
||||
.rxDigGain0 = 0,
|
||||
.rxAnaGain0 = 0,
|
||||
.rxDigGain50 = 0,
|
||||
.rxAnaGain50 = 0,
|
||||
.rxDigGain100 = 0xff,
|
||||
.rxAnaGain100 = 0xff,
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCTIONS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
|
||||
HalCodecSts_e halCodecLock(void* arg)
|
||||
{
|
||||
osSemaphoreId_t codecLock = (osSemaphoreId_t)arg;
|
||||
|
||||
if (osSemaphoreAcquire(codecLock, 1000) != osOK)
|
||||
{
|
||||
return CODEC_TIMEOUT;
|
||||
}
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecUnlock(void* arg)
|
||||
{
|
||||
osSemaphoreId_t codecLock = (osSemaphoreId_t)arg;
|
||||
|
||||
if (osSemaphoreRelease(codecLock) != osOK)
|
||||
{
|
||||
return CODEC_TIMEOUT;
|
||||
}
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecLockDestroy(void *arg)
|
||||
{
|
||||
osSemaphoreId_t codecLock = (osSemaphoreId_t)arg;
|
||||
|
||||
if (osSemaphoreDelete(codecLock) != osOK)
|
||||
{
|
||||
return CODEC_TIMEOUT;
|
||||
}
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
HalCodecSts_e halCodecLock(void* arg)
|
||||
{
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecUnlock(void* arg)
|
||||
{
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecLockDestroy(void *arg)
|
||||
{
|
||||
return CODEC_EOK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
HalCodecCfg_t halCodecGetDefaultCfg(HalCodecFuncList_t* codecHalFunc)
|
||||
{
|
||||
return codecHalFunc->halCodecGetDefaultCfg();
|
||||
}
|
||||
|
||||
HalCodecFuncList_t* halCodecInit(HalCodecCfg_t* codecHalCfg, HalCodecFuncList_t* codecHalFunc, bool needLock)
|
||||
{
|
||||
HalCodecSts_e ret = CODEC_EOK;
|
||||
HalCodecFuncList_t* codecHal = codecHalFunc;
|
||||
|
||||
#ifdef FEATURE_OS_ENABLE
|
||||
if (codecHal->halCodecLock == NULL)
|
||||
{
|
||||
codecHal->halCodecLock = osSemaphoreNew(1, 1, NULL);
|
||||
if (codecHal->halCodecLock == PNULL)
|
||||
{
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, halCodecInit_0, P_WARNING, "codec hal can't create semaphore");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
|
||||
ret |= codecHal->halCodecInitFunc(codecHalCfg);
|
||||
if (ret != CODEC_EOK)
|
||||
{
|
||||
halCodecUnlock(codecHal->halCodecLock);
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, halCodecInit_2, P_DEBUG, "codec init fail. ret=%d", ret);
|
||||
EC_ASSERT(false, 0, 0, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
codecHal->halCodecCfgIfaceFunc(codecHalCfg->codecMode, &codecHalCfg->codecIface);
|
||||
|
||||
codecHal->handle = codecHal;
|
||||
codecHalFunc->handle = codecHal;
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return codecHal;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecDeinit(HalCodecFuncList_t* codecHal)
|
||||
{
|
||||
int32_t ret = CODEC_EOK;
|
||||
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
halCodecLockDestroy(codecHal->halCodecLock);
|
||||
codecHal->halCodecDeinitFunc();
|
||||
codecHal->halCodecLock = NULL;
|
||||
codecHal->handle = NULL;
|
||||
codecHal = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecCtrlState(HalCodecFuncList_t* codecHal, HalCodecMode_e mode, HalCodecCtrlState_e codecStartStop, bool needLock)
|
||||
{
|
||||
int32_t ret;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
DEBUG_PRINT(UNILOG_PLA_DRIVER, halCodecCtrl_1, P_DEBUG, "codec mode=%d, startStop=%d", mode, codecStartStop);
|
||||
ret = codecHal->halCodecCtrlStateFunc(mode, codecStartStop);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecIfaceCfg(HalCodecFuncList_t* codecHal, HalCodecMode_e mode, HalCodecIface_t *iface, bool needLock)
|
||||
{
|
||||
int32_t ret = CODEC_EOK;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
HAL_CODEC_CHECK_NULL(iface, "Get volume para is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
ret = codecHal->halCodecCfgIfaceFunc(mode, iface);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecSetMute(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, bool mute, bool needLock)
|
||||
{
|
||||
int32_t ret;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
ret = codecHal->halCodecSetMuteFunc(codecHalCfg, mute);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if 1
|
||||
HalCodecSts_e halCodecEnablePA(HalCodecFuncList_t* codecHal, bool enable, bool needLock)
|
||||
{
|
||||
int32_t ret = CODEC_EOK;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
codecHal->halCodecEnablePAFunc(enable);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
HalCodecSts_e halCodecSetVolume(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, int volume, bool needLock)
|
||||
{
|
||||
int32_t ret;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
ret = codecHal->halCodecSetVolumeFunc(codecHalCfg, volume);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecGetVolume(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, int *volume, bool needLock)
|
||||
{
|
||||
int32_t ret;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
HAL_CODEC_CHECK_NULL(volume, "Get volume para is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
ret = codecHal->halCodecGetVolumeFunc(codecHalCfg, volume);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HalCodecSts_e halCodecSetMicVolume(HalCodecFuncList_t* codecHal, HalCodecCfg_t* codecHalCfg, uint8_t micGain, int volume, bool needLock)
|
||||
{
|
||||
int32_t ret;
|
||||
HAL_CODEC_CHECK_NULL(codecHal, "audio_hal handle is null", -1);
|
||||
if (needLock) halCodecLock(codecHal->halCodecLock);
|
||||
ret = codecHal->halCodecSetMicVolumeFunc(codecHalCfg, micGain, volume);
|
||||
if (needLock) halCodecUnlock(codecHal->halCodecLock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1,315 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2020-, Copyrigths of EigenComm Ltd.
|
||||
* File name: eepRom.c
|
||||
* Description: EC618 eepRom ds2431 driver source file
|
||||
* History: Rev1.0 2020-12-17
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "ec7xx.h"
|
||||
#include "bsp.h"
|
||||
#include "eepRom.h"
|
||||
#include "oneWire.h"
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
|
||||
extern void delay_us(uint32_t us);
|
||||
|
||||
static uint16_t crc16Maxim(uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t i;
|
||||
uint16_t crc = 0;
|
||||
while (len--)
|
||||
{
|
||||
crc ^= *data++;
|
||||
for (i=0; i<8; ++i)
|
||||
{
|
||||
if (crc&1)
|
||||
{
|
||||
crc = (crc>>1) ^ 0xA001;
|
||||
}
|
||||
else
|
||||
{
|
||||
crc = crc>>1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
|
||||
int32_t writeScratchpad(uint8_t addr, uint8_t data[8])
|
||||
{
|
||||
uint8_t crcSrcData[11];
|
||||
uint16_t crcCalResult;
|
||||
uint8_t crcReadData[2];
|
||||
|
||||
if ((data == NULL) || (addr > 0x8F))
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
if (owResetPd() != 0)
|
||||
{
|
||||
return EEPROMDRV_RESET_ERR;
|
||||
}
|
||||
|
||||
delay_us(140); // delay 200us
|
||||
|
||||
owWriteByte(ROM_SKIP_CMD);
|
||||
owWriteByte(SCRATCHPAD_WRITE_CMD);
|
||||
owWriteByte(addr);
|
||||
owWriteByte(0x00);
|
||||
|
||||
crcSrcData[0] = SCRATCHPAD_WRITE_CMD; // before are right
|
||||
crcSrcData[1] = addr;
|
||||
crcSrcData[2] = 0x00;
|
||||
for (int i=0; i<8; i++)
|
||||
{
|
||||
owWriteByte(data[i]);
|
||||
crcSrcData[i+3] = data[i];
|
||||
}
|
||||
|
||||
crcCalResult = crc16Maxim(crcSrcData, 11); // before are right
|
||||
|
||||
owReadByte(crcReadData);
|
||||
owReadByte(crcReadData+1);
|
||||
|
||||
if (((crcReadData[1]<<8) | crcReadData[0]) != crcCalResult)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
return EEPROMDRV_OK;
|
||||
}
|
||||
|
||||
void readScratchpad(uint8_t dataBack[13])
|
||||
{
|
||||
if (owResetPd() != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
delay_us(140); // delay 200us
|
||||
|
||||
owWriteByte(ROM_SKIP_CMD);
|
||||
owWriteByte(SCRATCHPAD_READ_CMD);
|
||||
|
||||
// first 3 bytes are: TA1, TA2, ES; Then 8 bytes data; Last are 2 bytes crc
|
||||
for (int i=0; i<13; i++)
|
||||
{
|
||||
owReadByte(dataBack+i);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t copyScratchpad2Mem(uint16_t addr)
|
||||
{
|
||||
uint8_t readData;
|
||||
|
||||
if (owResetPd() != 0)
|
||||
{
|
||||
return EEPROMDRV_RESET_ERR;
|
||||
}
|
||||
|
||||
delay_us(140); // delay 200us
|
||||
|
||||
owWriteByte(ROM_SKIP_CMD);
|
||||
owWriteByte(SCRATCHPAD_COPY_CMD);
|
||||
owWriteByte(addr);
|
||||
owWriteByte(0x00);
|
||||
owWriteByte(0x07);
|
||||
|
||||
delay_us(140); // delay 200us
|
||||
|
||||
owReadByte(&readData);
|
||||
if (readData != 0xAA)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADCOPY_ERR;
|
||||
}
|
||||
|
||||
return EEPROMDRV_OK;
|
||||
}
|
||||
|
||||
AP_PLAT_COMMON_BSS uint8_t dataBack[13]={0};
|
||||
int32_t dataCmp(uint8_t targetAddr, uint8_t* buffer, uint8_t len)
|
||||
{
|
||||
// compare the data read from scratchpad
|
||||
if (dataBack[0] != targetAddr)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
if (dataBack[1] != 0)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
if (dataBack[2] != 0x7)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
for (int j=0; j<len; j++)
|
||||
{
|
||||
if (dataBack[j+3] != buffer[j])
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
return EEPROMDRV_OK;
|
||||
}
|
||||
|
||||
int32_t eePromReadRom(uint8_t* romCode)
|
||||
{
|
||||
if (owResetPd() !=0)
|
||||
{
|
||||
return EEPROMDRV_RESET_ERR;
|
||||
}
|
||||
|
||||
delay_us(140); // delay 200us
|
||||
|
||||
#if 0
|
||||
uint8_t data = ROM_READ_CMD;
|
||||
int i;
|
||||
for (i=0; i<8; i++)
|
||||
{
|
||||
owWriteBit(data&0x01);
|
||||
data >>=1;
|
||||
}
|
||||
|
||||
uint8_t dataRead;
|
||||
for (i=0; i<8; i++)
|
||||
{
|
||||
owReadBit(&dataRead);
|
||||
dataRead <<=1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
int32_t result = owWriteByte(ROM_READ_CMD);
|
||||
if (result < 0)
|
||||
{
|
||||
return EEPROMDRV_ROMREAD_ERR;
|
||||
}
|
||||
|
||||
for (int32_t i=0; i<8; i++)
|
||||
{
|
||||
owReadByte(romCode+i);
|
||||
}
|
||||
#endif
|
||||
|
||||
return EEPROMDRV_OK;
|
||||
}
|
||||
|
||||
int32_t eePromReadMem(uint8_t targetAddr, uint8_t len, uint8_t* buffer)
|
||||
{
|
||||
delay_us(3000); // wait unitl former write operations finish
|
||||
|
||||
if (owResetPd() != 0)
|
||||
{
|
||||
return EEPROMDRV_RESET_ERR;
|
||||
}
|
||||
|
||||
delay_us(140); // delay 200us
|
||||
|
||||
if (owWriteByte(ROM_SKIP_CMD) < 0)
|
||||
{
|
||||
return EEPROMDRV_ROMREAD_ERR;
|
||||
}
|
||||
|
||||
if (owWriteByte(MEM_READ_CMD) < 0)
|
||||
{
|
||||
return EEPROMDRV_ROMREAD_ERR;
|
||||
}
|
||||
|
||||
// write addr low byte
|
||||
if (owWriteByte(targetAddr) < 0)
|
||||
{
|
||||
return EEPROMDRV_ROMREAD_ERR;
|
||||
}
|
||||
|
||||
// write addr high byte
|
||||
if (owWriteByte(0) < 0)
|
||||
{
|
||||
return EEPROMDRV_ROMREAD_ERR;
|
||||
}
|
||||
|
||||
for (int i=0; i<len; i++)
|
||||
{
|
||||
owReadByte(buffer+i);
|
||||
}
|
||||
|
||||
return owResetPd();
|
||||
}
|
||||
|
||||
AP_PLAT_COMMON_BSS int32_t writeSctStats;
|
||||
int32_t eePromWriteMem(uint8_t targetAddr, uint8_t len, uint8_t* buffer)
|
||||
{
|
||||
uint8_t tmp[8];
|
||||
int i, index=0;
|
||||
|
||||
if (owResetPd() != 0)
|
||||
{
|
||||
return EEPROMDRV_RESET_ERR;
|
||||
}
|
||||
|
||||
if (targetAddr > 0x88)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
while (len > 8)
|
||||
{
|
||||
for (i=0; i<8; i++)
|
||||
{
|
||||
tmp[i] = buffer[i+index];
|
||||
}
|
||||
|
||||
len -= 8;
|
||||
writeSctStats = writeScratchpad(targetAddr+index, tmp);
|
||||
delay_us(3000);
|
||||
readScratchpad(dataBack);
|
||||
if (dataCmp(targetAddr+index, buffer+index, 8) != 0)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
copyScratchpad2Mem(targetAddr+index);
|
||||
delay_us(3000);
|
||||
memset(dataBack, 0, 13);
|
||||
|
||||
index += 8;
|
||||
}
|
||||
|
||||
for (i=0; i<len; i++)
|
||||
{
|
||||
tmp[i] = buffer[i+index];
|
||||
}
|
||||
|
||||
memset(tmp+i, 1, 8-len);
|
||||
delay_us(3000); // wait until eeprom store data finish
|
||||
writeSctStats = writeScratchpad(targetAddr+index, tmp);
|
||||
delay_us(3000);
|
||||
readScratchpad(dataBack);
|
||||
if (dataCmp(targetAddr+index, buffer+index, len) != 0)
|
||||
{
|
||||
return EEPROMDRV_SCRATCHPADWRITE_ERR;
|
||||
}
|
||||
|
||||
copyScratchpad2Mem(targetAddr+index);
|
||||
delay_us(30000); // wait until eeprom store data finish
|
||||
|
||||
if (owResetPd() != 0)
|
||||
{
|
||||
return EEPROMDRV_RESET_ERR;
|
||||
}
|
||||
|
||||
return EEPROMDRV_OK;
|
||||
}
|
||||
|
||||
void eepRomInit(OwModeSel_e mode)
|
||||
{
|
||||
owInit();
|
||||
owSetMode(mode);
|
||||
}
|
@ -1,485 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: initiated by xxxx
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bsp.h"
|
||||
#include "ex_flash.h"
|
||||
#include "sctdef.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define TRANSFER_DATA_WIDTH (8)
|
||||
#define SPI_SSN_GPIO_INSTANCE RTE_SPI0_SSN_GPIO_INSTANCE
|
||||
#define SPI_SSN_GPIO_INDEX RTE_SPI0_SSN_GPIO_INDEX
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \brief driver instance declare */
|
||||
extern ARM_DRIVER_SPI Driver_SPI0;
|
||||
AP_PLAT_COMMON_DATA static ARM_DRIVER_SPI *spiMasterDrv = &CREATE_SYMBOL(Driver_SPI, 0);
|
||||
//volatile uint16_t gFid = 0;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCTION DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\fn exSpiFlashIoIint(void)
|
||||
\brief init SPI interface
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exSpiFlashIoIint(void)
|
||||
{
|
||||
// Initialize master spi
|
||||
spiMasterDrv->Initialize(NULL);
|
||||
// Power on
|
||||
spiMasterDrv->PowerControl(ARM_POWER_FULL);
|
||||
|
||||
// Configure master spi bus
|
||||
spiMasterDrv->Control(ARM_SPI_MODE_MASTER | ARM_SPI_CPOL0_CPHA0 | ARM_SPI_DATA_BITS(TRANSFER_DATA_WIDTH) |
|
||||
ARM_SPI_MSB_LSB | ARM_SPI_SS_MASTER_SW, 26000000U);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn exSpiFlashIoDeIint(void)
|
||||
\brief deinit SPI interface
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exSpiFlashIoDeIint(void)
|
||||
{
|
||||
// Initialize master spi
|
||||
spiMasterDrv->Uninitialize();
|
||||
// Power on
|
||||
spiMasterDrv->PowerControl(ARM_POWER_OFF);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashSetSpiCsHigh(void)
|
||||
\brief manual control CS PIN
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exFlashSetSpiCsHigh(void)
|
||||
{
|
||||
GPIO_pinWrite(SPI_SSN_GPIO_INSTANCE, 1 << SPI_SSN_GPIO_INDEX, 1 << SPI_SSN_GPIO_INDEX);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashSetSpiCsLow(void)
|
||||
\brief manual control CS PIN
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exFlashSetSpiCsLow(void)
|
||||
{
|
||||
GPIO_pinWrite(SPI_SSN_GPIO_INSTANCE, 1 << SPI_SSN_GPIO_INDEX, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn exflashWrByte(void)
|
||||
\brief Software SPI_Flash bus driver basic function, send a single byte to MOSI,
|
||||
* and accept MISO data at the same time. used for both cmd/data send
|
||||
\param[in] u8Data:Data sent on the MOSI data line
|
||||
\note
|
||||
*/
|
||||
static uint8_t exflashWrByte(uint8_t u8Data)
|
||||
{
|
||||
uint8_t u8Out = 0;
|
||||
|
||||
spiMasterDrv->Transfer(&u8Data, &u8Out, 1);
|
||||
|
||||
return u8Out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashWrEn(void)
|
||||
\brief send wr en cmd to flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exFlashWrEn(void)
|
||||
{
|
||||
exFlashSetSpiCsLow();
|
||||
exflashWrByte(WRITE_ENABLE_CMD);
|
||||
exFlashSetSpiCsHigh();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashWrDisen(void)
|
||||
\brief send wr disen cmd to flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exFlashWrDisen(void)
|
||||
{
|
||||
exFlashSetSpiCsLow();
|
||||
exflashWrByte(WRITE_DISABLE_CMD);
|
||||
exFlashSetSpiCsHigh();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashPollingBusyFlag(void)
|
||||
\brief read the BUSY field in flash reg and loop until done
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
static void exFlashPollingBusyFlag(void)
|
||||
{
|
||||
uint8_t u8test;
|
||||
exFlashSetSpiCsLow();
|
||||
|
||||
do
|
||||
{
|
||||
exflashWrByte(READ_STATUS_REG1_CMD);
|
||||
u8test = exflashWrByte(Dummy_Byte1);
|
||||
} while ((u8test & 0x01) == 0x01);
|
||||
|
||||
exFlashSetSpiCsHigh();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashChipErase(void)
|
||||
\brief perform chip level erase, use with caution!!
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
void exFlashChipErase(void)
|
||||
{
|
||||
exFlashWrEn();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashSetSpiCsLow();
|
||||
exflashWrByte(CHIP_ERASE_CMD);
|
||||
exFlashSetSpiCsHigh();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashWrDisen();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashBlockErase(uint32_t u32Erase_Addr, uint8_t u8mode)
|
||||
\brief perform block level erase
|
||||
\param[in] u32Data_Addr :Block first address to start erasing
|
||||
u8mode :Erase mode 1=32K other=64K
|
||||
\note
|
||||
*/
|
||||
void exFlashBlockErase(uint32_t u32Erase_Addr, uint8_t u8mode)
|
||||
{
|
||||
exFlashWrEn();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashSetSpiCsLow();
|
||||
|
||||
if (u8mode == 1)
|
||||
{
|
||||
exflashWrByte(BLOCK_ERASE_32K_CMD);
|
||||
}
|
||||
else
|
||||
{
|
||||
exflashWrByte(BLOCK_ERASE_64K_CMD);
|
||||
}
|
||||
|
||||
exflashWrByte(u32Erase_Addr >> 16);
|
||||
exflashWrByte(u32Erase_Addr >> 8);
|
||||
exflashWrByte(u32Erase_Addr);
|
||||
exFlashSetSpiCsHigh();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashWrDisen();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashSectorErase(uint32_t u32Erase_Addr)
|
||||
\brief perform sector level erase, normally sector is 4K
|
||||
\param[in] u32Data_Addr :Block first address to start erasing
|
||||
\note
|
||||
*/
|
||||
void exFlashSectorErase(uint32_t u32Erase_Addr)
|
||||
{
|
||||
exFlashWrEn();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashSetSpiCsLow();
|
||||
|
||||
exflashWrByte(SECTOR_ERASE_CMD);
|
||||
|
||||
exflashWrByte(u32Erase_Addr >> 16);
|
||||
exflashWrByte(u32Erase_Addr >> 8);
|
||||
exflashWrByte(u32Erase_Addr);
|
||||
exFlashSetSpiCsHigh();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashWrDisen();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashPagePro(void)
|
||||
\brief starts writing data of up to 256 bytes at a specified address on one page (0~65535)
|
||||
\param[in] u32ReadAddr Start reading address(24bit)
|
||||
pu8Buffer:Data storage buffer
|
||||
u16NumByteToWrite:The number of bytes to write (maximum 256),
|
||||
* the number should not exceed the number of remaining bytes on the page!!!
|
||||
\note
|
||||
*/
|
||||
void exFlashPagePro(uint32_t u32WriteAddr, uint8_t *pu8Buffer, uint16_t u16NumByteToWrite)
|
||||
{
|
||||
uint16_t i;
|
||||
exFlashWrEn();
|
||||
exFlashSetSpiCsLow();
|
||||
exflashWrByte(PAGE_PROG_CMD);
|
||||
exflashWrByte((uint8_t)((u32WriteAddr) >> 16));
|
||||
exflashWrByte((uint8_t)((u32WriteAddr) >> 8));
|
||||
exflashWrByte((uint8_t)u32WriteAddr);
|
||||
|
||||
for (i = 0; i < u16NumByteToWrite; i++)exflashWrByte(pu8Buffer[i]);
|
||||
|
||||
exFlashSetSpiCsHigh();
|
||||
exFlashPollingBusyFlag();
|
||||
exFlashWrDisen();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashReadMDID(void)
|
||||
\brief reading device ID from flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
uint16_t exFlashReadMDID(void)
|
||||
{
|
||||
uint16_t u16Temp = 0;
|
||||
/* Enable chip select */
|
||||
exFlashSetSpiCsLow();
|
||||
/* Send "RDID " instruction */
|
||||
exflashWrByte(READ_ID_CMD);
|
||||
exflashWrByte(0x00);
|
||||
exflashWrByte(0x00);
|
||||
exflashWrByte(0x00);
|
||||
/* Read a byte from the FLASH */
|
||||
u16Temp |= exflashWrByte(Dummy_Byte1) << 8;
|
||||
u16Temp |= exflashWrByte(Dummy_Byte1);
|
||||
/* Disable chip select */
|
||||
exFlashSetSpiCsHigh();
|
||||
return u16Temp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn uint8_t exFlashRead(uint8_t *pu8Buffer, uint32_t u32ReadAddr, uint16_t u16NumByteToRead)
|
||||
\brief reading data of the specified length at the specified address
|
||||
\param[in] u32ReadAddr Start reading address(24bit)
|
||||
pu8Buffer Data storage buffer
|
||||
u16NumByteToRead The number of bytes to read(max 65535)
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashRead(uint8_t *pu8Buffer, uint32_t u32ReadAddr, uint16_t u16NumByteToRead)
|
||||
{
|
||||
uint16_t i;
|
||||
exFlashSetSpiCsLow();/* Enable chip select */
|
||||
exflashWrByte(READ_CMD);
|
||||
exflashWrByte(u32ReadAddr >> 16);
|
||||
exflashWrByte(u32ReadAddr >> 8);
|
||||
exflashWrByte(u32ReadAddr);
|
||||
|
||||
for (i = 0; i < u16NumByteToRead; i++)
|
||||
{
|
||||
pu8Buffer[i] = exflashWrByte(Dummy_Byte1); //Read one byte
|
||||
}
|
||||
|
||||
exFlashSetSpiCsHigh();/* Disable chip select */
|
||||
|
||||
return EXFLASH_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashErase(uint32_t eAddr, uint32_t size)
|
||||
\brief Erases the flash region. use different erase cmd according to size
|
||||
\param[in] eAddr addr to erase
|
||||
size erase len
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashErase(uint32_t eAddr, uint32_t size)
|
||||
{
|
||||
uint32_t offsetAddress;
|
||||
uint32_t remainLen;
|
||||
uint32_t currEraseSize;
|
||||
|
||||
|
||||
if ((eAddr&0xfff) !=0)
|
||||
{
|
||||
return EXFLASH_ERROR;
|
||||
}
|
||||
|
||||
offsetAddress = eAddr;
|
||||
remainLen = size;
|
||||
|
||||
while(remainLen > 0)
|
||||
{
|
||||
if (((offsetAddress&0xffff) ==0) && (remainLen >=0x10000))
|
||||
{
|
||||
exFlashBlockErase(offsetAddress,0);
|
||||
remainLen -= 0x10000;
|
||||
currEraseSize = 0x10000;
|
||||
}
|
||||
else if (((offsetAddress&0x7fff) ==0)&& (remainLen >=0x8000))
|
||||
{
|
||||
exFlashBlockErase(offsetAddress,1);
|
||||
remainLen-=0x8000;
|
||||
currEraseSize = 0x8000;
|
||||
}
|
||||
else
|
||||
{
|
||||
exFlashSectorErase(offsetAddress);
|
||||
currEraseSize = (remainLen >= 0x1000) ? 0x1000 : remainLen;
|
||||
remainLen -= currEraseSize;
|
||||
}
|
||||
|
||||
offsetAddress += currEraseSize;
|
||||
}
|
||||
|
||||
return EXFLASH_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashWrite(uint8_t* pData, uint32_t WriteAddr, uint32_t size)
|
||||
\brief Writes an amount of data to the QSPI flash.
|
||||
\param[in] pData: Data Pointer to write
|
||||
WriteAddr: Write start address
|
||||
Size: Size of data to write
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashWrite(uint8_t* pData, uint32_t WriteAddr, uint32_t size)
|
||||
{
|
||||
uint32_t end_addr, current_size, current_addr;
|
||||
//uint32_t irqMask;
|
||||
|
||||
// Calculation of the size between the write address and the end of the page
|
||||
//write non-aligned bytes first
|
||||
current_size = PAGE_SIZE - (WriteAddr%PAGE_SIZE);
|
||||
|
||||
// Check if the size of the data is less than the remaining place in the page
|
||||
if (current_size > size)
|
||||
{
|
||||
current_size = size;
|
||||
}
|
||||
|
||||
// Initialize the adress variables
|
||||
current_addr = WriteAddr;
|
||||
end_addr = WriteAddr + size;
|
||||
|
||||
// Perform the write page by page
|
||||
do
|
||||
{
|
||||
//irqMask = SaveAndSetIRQMask();
|
||||
|
||||
exFlashPagePro(current_addr,pData,current_size);
|
||||
|
||||
// Update the address and size variables for next page programming
|
||||
current_addr += current_size;
|
||||
pData += current_size;
|
||||
current_size = ((current_addr + PAGE_SIZE) > end_addr) ? (end_addr - current_addr) : PAGE_SIZE;
|
||||
|
||||
//RestoreIRQMask(irqMask);
|
||||
} while (current_addr < end_addr);
|
||||
|
||||
return EXFLASH_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashInit(void)
|
||||
\brief init the external spi flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashInit(void)
|
||||
{
|
||||
|
||||
exSpiFlashIoIint();
|
||||
//gFid = exFlashReadMDID();
|
||||
|
||||
return EXFLASH_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn exFlashDeinit(void)
|
||||
\brief deinit the external spi flash
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
uint8_t exFlashDeinit(void)
|
||||
{
|
||||
exSpiFlashIoDeIint();
|
||||
return EXFLASH_OK;
|
||||
}
|
||||
|
@ -1,482 +0,0 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 EIGENCOMM International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: initiated by xxxx
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include DEBUG_LOG_HEADER_FILE
|
||||
|
||||
#include "mem_map.h"
|
||||
#include "bsp.h"
|
||||
#include "ex_flash.h"
|
||||
#include "ex_storage.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "mw_aal_hash.h"
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define EXSTO_EF_DATA_ADDR (EF_DATA_LOAD_ADDR)
|
||||
#define EXSTO_EF_DATA_SIZE (EF_DATA_LOAD_SIZE)
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t handle; /* starting addr @NFS, otherwise fd @FS */
|
||||
uint32_t size;
|
||||
uint32_t overhead; /* reserved zone size for a special purpose */
|
||||
uint32_t extras; /* some supplementary info */
|
||||
}ExStoZone_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ExStoZoneId_bm bmZoneId;
|
||||
ExStoZone_t zone[EXSTO_ZONE_MAXNUM];
|
||||
}ExStoZoneMan_t;
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL VARIABLES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
AP_PLAT_COMMON_BSS static ExStoZoneMan_t gExStoZoneMan;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* PRIVATE FUNCTION DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
\fn uint8_t exStorageInit(void)
|
||||
\brief init the external storage
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageInit(void)
|
||||
{
|
||||
gExStoZoneMan.bmZoneId |= EXSTO_BM_ZONE_EF_DATA;
|
||||
gExStoZoneMan.zone[EXSTO_ZONE_EF_DATA].handle = EXSTO_EF_DATA_ADDR;
|
||||
gExStoZoneMan.zone[EXSTO_ZONE_EF_DATA].size = EXSTO_EF_DATA_SIZE;
|
||||
gExStoZoneMan.zone[EXSTO_ZONE_EF_DATA].overhead = 0;
|
||||
gExStoZoneMan.zone[EXSTO_ZONE_EF_DATA].extras = 0;
|
||||
|
||||
if(exFlashInit() == EXFLASH_OK)
|
||||
return EXSTO_OK;
|
||||
else
|
||||
return EXSTO_EINIT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageDeinit(void)
|
||||
\brief deinit the external storage
|
||||
\param[in]
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageDeinit(void)
|
||||
{
|
||||
memset(&gExStoZoneMan, 0, sizeof(ExStoZoneMan_t));
|
||||
|
||||
if(exFlashDeinit() == EXFLASH_OK)
|
||||
return EXSTO_OK;
|
||||
else
|
||||
return EXSTO_EDEINIT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageClear(uint32_t zid, uint32_t offset, uint32_t len)
|
||||
\brief erase the area to be write
|
||||
\param[in] zid resv for future use
|
||||
offset erase start addr
|
||||
len erase len
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageClear(uint32_t zid, uint32_t offset, uint32_t len)
|
||||
{
|
||||
uint32_t currLen = len;
|
||||
|
||||
if(zid >= EXSTO_ZONE_MAXNUM)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_CLEAR_0, P_WARNING, "clr: invalid zoneId(%d)! max(%d)\n",
|
||||
zid, EXSTO_ZONE_MAXNUM);
|
||||
return EXSTO_EUNDEF;
|
||||
}
|
||||
|
||||
if(!(gExStoZoneMan.bmZoneId & (1 << zid)))
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_CLEAR_1, P_WARNING, "clr: no exSto zone(%d)! bmZoneId(0x%x)\n",
|
||||
zid, gExStoZoneMan.bmZoneId);
|
||||
return EXSTO_EERASE;
|
||||
}
|
||||
|
||||
if(currLen > gExStoZoneMan.zone[zid].size)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_CLEAR_2, P_WARNING, "clr zone(%d): len(%d) overflowed! set it max(%d)!\n",
|
||||
zid, currLen, gExStoZoneMan.zone[zid].size);
|
||||
currLen = gExStoZoneMan.zone[zid].size;
|
||||
}
|
||||
|
||||
if(offset >= gExStoZoneMan.zone[zid].size)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_CLEAR_3, P_ERROR, "clr zone(%d): invalid offset(%d)! max(%d)\n",
|
||||
zid, offset, gExStoZoneMan.zone[zid].size);
|
||||
return EXSTO_EOVRFLOW;
|
||||
}
|
||||
|
||||
if(exFlashErase(gExStoZoneMan.zone[zid].handle + offset, len) == EXFLASH_OK)
|
||||
return EXSTO_OK;
|
||||
else
|
||||
return EXSTO_EERASE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageWrite(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen)
|
||||
\brief write data of the specified length at the specified address
|
||||
\param[in] zid resv for future use
|
||||
offset write start addr
|
||||
buf write buf
|
||||
bufLen write len
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageWrite(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen)
|
||||
{
|
||||
uint32_t currLen = bufLen;
|
||||
uint8_t *rdPtr = NULL;
|
||||
int32_t ret = 0;
|
||||
|
||||
if(zid >= EXSTO_ZONE_MAXNUM)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_WRITE_0, P_WARNING, "wr: invalid zoneId(%d)! max(%d)\n",
|
||||
zid, EXSTO_ZONE_MAXNUM);
|
||||
return EXSTO_EUNDEF;
|
||||
}
|
||||
|
||||
if(!(gExStoZoneMan.bmZoneId & (1 << zid)))
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_WRITE_1, P_WARNING, "wr: no exSto zone(%d)! bmZoneId(0x%x)\n",
|
||||
zid, gExStoZoneMan.bmZoneId);
|
||||
return EXSTO_EWRITE;
|
||||
}
|
||||
|
||||
if(currLen > gExStoZoneMan.zone[zid].size)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_WRITE_2, P_WARNING, "wr zone(%d): len(%d) overflowed! set it max(%d)!\n",
|
||||
zid, currLen, gExStoZoneMan.zone[zid].size);
|
||||
currLen = gExStoZoneMan.zone[zid].size;
|
||||
}
|
||||
|
||||
if(offset >= gExStoZoneMan.zone[zid].size)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_WRITE_3, P_ERROR, "wr zone(%d): invalid offset(%d)! max(%d)\n",
|
||||
zid, offset, gExStoZoneMan.zone[zid].size);
|
||||
return EXSTO_EOVRFLOW;
|
||||
}
|
||||
|
||||
//step1 write to flash
|
||||
if(exFlashWrite(buf, gExStoZoneMan.zone[zid].handle + offset, currLen) != EXFLASH_OK)
|
||||
return EXSTO_EWRITE;
|
||||
|
||||
//step2 read back and check
|
||||
rdPtr = mallocEc(currLen);
|
||||
if(rdPtr == NULL)
|
||||
{
|
||||
return EXSTO_EMALLOC;
|
||||
}
|
||||
|
||||
if(exFlashRead(rdPtr, gExStoZoneMan.zone[zid].handle + offset, currLen) != EXFLASH_OK)
|
||||
return EXSTO_EREAD;
|
||||
|
||||
ret = memcmp(buf,rdPtr,currLen);
|
||||
freeEc(rdPtr);
|
||||
|
||||
return ret ? EXSTO_EWRITE : EXSTO_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t exStorageRead(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen)
|
||||
\brief reading data of the specified length at the specified address
|
||||
\param[in] zid resv for future use
|
||||
offset read start addr
|
||||
buf read buf
|
||||
bufLen read len
|
||||
\note
|
||||
*/
|
||||
int32_t exStorageRead(uint32_t zid, uint32_t offset, uint8_t *buf, uint32_t bufLen)
|
||||
{
|
||||
uint32_t currLen = bufLen;
|
||||
|
||||
if(zid >= EXSTO_ZONE_MAXNUM)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_READ_0, P_WARNING, "rd: invalid zoneId(%d)! max(%d)\n",
|
||||
zid, EXSTO_ZONE_MAXNUM);
|
||||
return EXSTO_EUNDEF;
|
||||
}
|
||||
|
||||
if(!(gExStoZoneMan.bmZoneId & (1 << zid)))
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_READ_1, P_WARNING, "rd: no exSto zone(%d)! bmZoneId(0x%x)\n",
|
||||
zid, gExStoZoneMan.bmZoneId);
|
||||
return EXSTO_EWRITE;
|
||||
}
|
||||
|
||||
if(currLen > gExStoZoneMan.zone[zid].size)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_READ_2, P_WARNING, "rd zone(%d): len(%d) overflowed! set it max(%d)!\n",
|
||||
zid, currLen, gExStoZoneMan.zone[zid].size);
|
||||
currLen = gExStoZoneMan.zone[zid].size;
|
||||
}
|
||||
|
||||
if(offset >= gExStoZoneMan.zone[zid].size)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_READ_3, P_ERROR, "rd zone(%d): invalid offset(%d)! max(%d)\n",
|
||||
zid, offset, gExStoZoneMan.zone[zid].size);
|
||||
return EXSTO_EOVRFLOW;
|
||||
}
|
||||
|
||||
if(exFlashRead(buf, gExStoZoneMan.zone[zid].handle + offset, currLen) == EXFLASH_OK)
|
||||
return EXSTO_OK;
|
||||
else
|
||||
return EXSTO_EREAD;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief exStorageGetZid(uint32_t addr, uint32_t *size, uint32_t *offset);
|
||||
* @details get the es zid according starting address and size of the zone
|
||||
*
|
||||
* @param addr the starting addr of the zone
|
||||
* @param size the size of the zone
|
||||
* @param offset the offset to starting addr of the zone
|
||||
* @return the zone ID.
|
||||
*/
|
||||
uint32_t exStorageGetZid(uint32_t addr, uint32_t *size, uint32_t *offset)
|
||||
{
|
||||
uint32_t zid = EXSTO_ZONE_EF_DATA;
|
||||
uint32_t zsz = EXSTO_EF_DATA_SIZE;
|
||||
|
||||
if(!size)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_GET_ZID_1, P_ERROR, "get zid: null size ptr!\n");
|
||||
goto GET_ZID_END;
|
||||
}
|
||||
|
||||
if(!addr && !(*size))
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_GET_ZID_2, P_SIG, "get zid: set it default(%d: %d)!\n", zid, zsz);
|
||||
goto GET_ZID_END;
|
||||
}
|
||||
|
||||
switch(addr)
|
||||
{
|
||||
case EXSTO_EF_DATA_ADDR:
|
||||
{
|
||||
zid = EXSTO_ZONE_EF_DATA;
|
||||
zsz = EXSTO_EF_DATA_SIZE;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_GET_ZID_3, P_WARNING, "get zid: unknown starting addr(0x%x)!\n", addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GET_ZID_END:
|
||||
if(!(*size))
|
||||
{
|
||||
*size = zsz;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(*size != zsz)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_STO_GET_ZID_4, P_WARNING, "get zid: in_size(%d) != zone_size(%d)!\n", *size, zsz);
|
||||
}
|
||||
}
|
||||
|
||||
if(offset) *offset = 0;
|
||||
|
||||
return zid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief exStorageGetSize(uint32_t zid, uint8_t isOvhdExcl)
|
||||
* @details get the nvm size of specific exstorage zone
|
||||
*
|
||||
* @param zid zone Id of exstorage zone
|
||||
* @param isOvhdExcl overhead size of the zone is excluded or not
|
||||
* @return the size of zone.
|
||||
*/
|
||||
uint32_t exStorageGetSize(uint32_t zid, uint8_t isOvhdExcl)
|
||||
{
|
||||
if(zid >= EXSTO_ZONE_MAXNUM)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_GET_SZ_0, P_WARNING, "get size: invalid zoneId(%d)! max(%d)\n",
|
||||
zid, EXSTO_ZONE_MAXNUM);
|
||||
return EXSTO_EUNDEF;
|
||||
}
|
||||
|
||||
if(!(gExStoZoneMan.bmZoneId & (1 << zid)))
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_GET_SZ_1, P_WARNING, "get size: no exSto zone(%d)! bmZoneId(0x%x)\n",
|
||||
zid, gExStoZoneMan.bmZoneId);
|
||||
return EXSTO_EWRITE;
|
||||
}
|
||||
|
||||
return (gExStoZoneMan.zone[zid].size - (isOvhdExcl ? gExStoZoneMan.zone[zid].overhead : 0));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief exStorageVerifyPkg(uint32_t *pkgState)
|
||||
* @details validate the data pkg
|
||||
*
|
||||
* @param pkgState the last state of data pkg
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t exStorageVerifyPkg(uint32_t zid, uint8_t *hash, uint32_t pkgSize, uint32_t *pkgState)
|
||||
{
|
||||
int32_t retCode = EXSTO_EUNDEF;
|
||||
uint8_t *buffer = NULL;
|
||||
uint8_t isLast = 0;
|
||||
uint32_t offset = 0;
|
||||
uint32_t readSize = 0;
|
||||
uint32_t remnSize = pkgSize;
|
||||
uint32_t stepSize = 4096;
|
||||
uint8_t outHash[32] = {0};
|
||||
MwAalSha256Ctx_t sha256;
|
||||
|
||||
/* no need to verify the pkg */
|
||||
if(!hash) return EXSTO_OK;
|
||||
|
||||
if(zid >= EXSTO_ZONE_MAXNUM)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_1, P_WARNING, "verify pkg: invalid zoneId(%d)! max(%d)\n",
|
||||
zid, EXSTO_ZONE_MAXNUM);
|
||||
return EXSTO_EUNDEF;
|
||||
}
|
||||
|
||||
if(!(gExStoZoneMan.bmZoneId & (1 << zid)))
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_2, P_WARNING, "verify pkg: no exSto zone(%d)! bmZoneId(0x%x)\n",
|
||||
zid, gExStoZoneMan.bmZoneId);
|
||||
return EXSTO_EWRITE;
|
||||
}
|
||||
|
||||
mwAalInitSha256(&sha256, 0);
|
||||
|
||||
buffer = (uint8_t*)mallocEc(stepSize);
|
||||
if(buffer == NULL)
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_3, P_WARNING, "verify pkg: zone(%d) malloc(%d) failure!\n",
|
||||
zid, stepSize);
|
||||
goto VERIFY_PKG_END;
|
||||
}
|
||||
|
||||
|
||||
for(offset = 0; offset < pkgSize; offset += readSize)
|
||||
{
|
||||
if(remnSize > stepSize)
|
||||
{
|
||||
isLast = 0;
|
||||
readSize = stepSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
isLast = 1;
|
||||
readSize = remnSize;
|
||||
}
|
||||
remnSize -= readSize;
|
||||
|
||||
if(EXSTO_OK != exStorageRead(zid, offset, buffer, readSize))
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_4, P_WARNING, "zid(%d) flash read failure!\n", zid);
|
||||
goto VERIFY_PKG_END;
|
||||
}
|
||||
|
||||
if(0 != mwAalUpdateSha256(&sha256, buffer, outHash, readSize, isLast))
|
||||
{
|
||||
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_5, P_ERROR, "zid(%d) flash sha256sum fail!\n", zid);
|
||||
goto VERIFY_PKG_END;
|
||||
}
|
||||
}
|
||||
|
||||
if(memcmp(outHash, hash, 32))
|
||||
{
|
||||
ECPLAT_DUMP(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_6, P_WARNING, "input hash: ", 32, hash);
|
||||
ECPLAT_DUMP(UNILOG_PLA_DRIVER, EX_VERIFY_PKG_7, P_WARNING, "calc hash : ", 32, outHash);
|
||||
}
|
||||
else
|
||||
{
|
||||
retCode = EXSTO_OK;
|
||||
}
|
||||
|
||||
VERIFY_PKG_END:
|
||||
if(buffer) freeEc(buffer);
|
||||
|
||||
mwAalDeinitSha256(&sha256);
|
||||
|
||||
if(pkgState)
|
||||
{
|
||||
*pkgState = 0;
|
||||
}
|
||||
|
||||
return retCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief exStorageGetUpdResult(uint32_t zid, int32_t *pkgState)
|
||||
* @details get the updated result
|
||||
*
|
||||
* @param pkgState the last state of data pkg
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t exStorageGetUpdResult(uint32_t zid, int32_t *pkgState)
|
||||
{
|
||||
if(pkgState)
|
||||
{
|
||||
*pkgState = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user