From 0557a41f1ad0738c74555ad31ddd67a8c4a51cd7 Mon Sep 17 00:00:00 2001 From: pvvx Date: Wed, 1 Feb 2017 14:37:57 +0300 Subject: [PATCH] update --- Makefile | 4 +- .../component/common/mbed/common/wait_api.c | 4 +- .../component/common/mbed/hal_ext/ex_api.h | 1 + .../component/common/mbed/hal_ext/flash_api.h | 9 ++--- .../component/common/mbed/hal_ext/flash_eep.h | 16 ++++++-- .../component/common/mbed/hal_ext/sys_api.h | 6 +-- .../mbed/targets/hal/rtl8195a/i2c_api.c | 5 +-- .../mbed/targets/hal/rtl8195a/serial_api.c | 36 +++++++++--------- .../mbed/targets/hal/rtl8195a/spdio_api.c | 18 ++++++++- .../mbed/targets/hal/rtl8195a/spi_api.c | 2 +- .../mbed/targets/hal/rtl8195a/sys_api.c | 27 ++++++++----- .../mbed/targets/hal/rtl8195a/us_ticker.c | 38 +++++++++---------- .../mbed/targets/hal/rtl8195a/wdt_api.c | 2 +- 13 files changed, 99 insertions(+), 69 deletions(-) diff --git a/Makefile b/Makefile index b5cdd0b..9a22419 100644 --- a/Makefile +++ b/Makefile @@ -50,4 +50,6 @@ readfullflash: .PHONY: prerequirement prerequirement: # @$(file >DEPENDENCY_LIST.txt,$(DEPENDENCY_LIST)) - \ No newline at end of file + +TARGETTYPE := APP +TARGETNAME := build\obj\build.axf diff --git a/RTL00_SDKV35a/component/common/mbed/common/wait_api.c b/RTL00_SDKV35a/component/common/mbed/common/wait_api.c index 9cfc40f..174c97a 100644 --- a/RTL00_SDKV35a/component/common/mbed/common/wait_api.c +++ b/RTL00_SDKV35a/component/common/mbed/common/wait_api.c @@ -79,12 +79,12 @@ typedef struct #define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ #endif -void wait(float s) { +void wait(float s) { // До 1073741 секунд? 298 часов // wait_us((int)(s * 1000000.0f)); vTaskDelay((int)(s * 1000.0f)); } -void wait_ms(int ms) { +void wait_ms(int ms) { // До 1073741 секунд? 298 часов if(ms > 0) vTaskDelay(ms); // wait_us(ms * 1000); } diff --git a/RTL00_SDKV35a/component/common/mbed/hal_ext/ex_api.h b/RTL00_SDKV35a/component/common/mbed/hal_ext/ex_api.h index 0524373..8a4fe79 100644 --- a/RTL00_SDKV35a/component/common/mbed/hal_ext/ex_api.h +++ b/RTL00_SDKV35a/component/common/mbed/hal_ext/ex_api.h @@ -21,6 +21,7 @@ #include "spi_api.h" #include "dma_api.h" #include "flash_api.h" +#include "flash_eep.h" #include "gpio_ex_api.h" #include "gpio_irq_ex_api.h" #include "i2c_ex_api.h" diff --git a/RTL00_SDKV35a/component/common/mbed/hal_ext/flash_api.h b/RTL00_SDKV35a/component/common/mbed/hal_ext/flash_api.h index b00eb19..00ab5d2 100644 --- a/RTL00_SDKV35a/component/common/mbed/hal_ext/flash_api.h +++ b/RTL00_SDKV35a/component/common/mbed/hal_ext/flash_api.h @@ -7,8 +7,7 @@ * possession or use of this module requires written permission of RealTek. ******************************************************************************* */ - - #ifndef MBED_EXT_FLASH_API_EXT_H +#ifndef MBED_EXT_FLASH_API_EXT_H #define MBED_EXT_FLASH_API_EXT_H #include "device.h" @@ -22,8 +21,7 @@ typedef struct flash_s flash_t; /** * global data structure */ -//extern flash_t flash; -extern flash_t flashobj; +extern flash_t flashobj; extern bool fspic_isinit; enum { @@ -47,10 +45,11 @@ int flash_burst_write (flash_t * obj, uint32_t address, uint32_t Length, uint8 int flash_burst_read (flash_t * obj, uint32_t address, uint32_t Length, uint8_t * data); int flash_set_extend_addr (flash_t * obj, uint32_t data); int flash_get_extend_addr (flash_t * obj); +unsigned int flash_get_size (flash_t *obj); +int flash_otp_read (flash_t *obj, uint32_t address, uint32_t Length, uint8_t * data); #ifdef __cplusplus } #endif - #endif diff --git a/RTL00_SDKV35a/component/common/mbed/hal_ext/flash_eep.h b/RTL00_SDKV35a/component/common/mbed/hal_ext/flash_eep.h index 1eb280e..4a2d7a9 100644 --- a/RTL00_SDKV35a/component/common/mbed/hal_ext/flash_eep.h +++ b/RTL00_SDKV35a/component/common/mbed/hal_ext/flash_eep.h @@ -8,9 +8,14 @@ #ifndef __FLASH_EEP_H_ #define __FLASH_EEP_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include + //----------------------------------------------------------------------------- #ifndef FLASH_SECTOR_SIZE #define FLASH_SECTOR_SIZE 4096 @@ -19,7 +24,7 @@ #define FLASH_CHIP_SIZE (FLASH_SECTORS * FLASH_SECTOR_SIZE) #define FMEMORY_SCFG_BANK_SIZE FLASH_SECTOR_SIZE // размер сектора, 4096 bytes #define FMEMORY_SCFG_BANKS 2 // кол-во секторов для работы 2... -#define FMEMORY_SCFG_BASE_ADDR (FLASH_CHIP_SIZE - (FMEMORY_SCFG_BANKS*FMEMORY_SCFG_BANK_SIZE)) +#define FMEMORY_SCFG_BASE_ADDR (FLASH_CHIP_SIZE - (FMEMORY_SCFG_BANKS*FMEMORY_SCFG_BANK_SIZE)) // = 0xFE000 //----------------------------------------------------------------------------- #define FLASH_EEP_ATTR //----------------------------------------------------------------------------- @@ -32,11 +37,16 @@ enum eFMEMORY_ERRORS { }; //----------------------------------------------------------------------------- // extern QueueHandle_t flash_mutex; -sint16 flash_read_cfg(void *ptr, uint16 id, uint16 maxsize) FLASH_EEP_ATTR; // возврат: размер объекта последнего сохранения, -1 - не найден, -2 - error -bool flash_write_cfg(void *ptr, uint16 id, uint16 size) FLASH_EEP_ATTR; +signed short flash_read_cfg(void *ptr, unsigned short id, unsigned short maxsize) FLASH_EEP_ATTR; // возврат: размер объекта последнего сохранения, -1 - не найден, -2 - error +bool flash_write_cfg(void *ptr, unsigned short id, unsigned short size) FLASH_EEP_ATTR; //----------------------------------------------------------------------------- #ifndef USE_FLASH_EEP #define USE_FLASH_EEP 1 #endif +#ifdef __cplusplus +} +#endif + + #endif /* __FLASH_EEP_H_ */ diff --git a/RTL00_SDKV35a/component/common/mbed/hal_ext/sys_api.h b/RTL00_SDKV35a/component/common/mbed/hal_ext/sys_api.h index f0f7cbd..46fbabb 100644 --- a/RTL00_SDKV35a/component/common/mbed/hal_ext/sys_api.h +++ b/RTL00_SDKV35a/component/common/mbed/hal_ext/sys_api.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MBED_WATCHDOG_API_H -#define MBED_WATCHDOG_API_H +#ifndef MBED_SYS_API_H +#define MBED_SYS_API_H #include "device.h" @@ -49,4 +49,4 @@ void sys_reset(void); } #endif -#endif +#endif // MBED_SYS_API_H diff --git a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/i2c_api.c b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/i2c_api.c index 262ffdd..ae6b31c 100644 --- a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/i2c_api.c +++ b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/i2c_api.c @@ -235,10 +235,7 @@ inline int i2c_stop(i2c_t *obj) { return 0; } -extern u32 -HalDelayUs( - IN u32 us -); +// extern u32 HalDelayUs(IN u32 us); int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) { diff --git a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/serial_api.c b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/serial_api.c index 28166c9..af21347 100644 --- a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/serial_api.c +++ b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/serial_api.c @@ -23,41 +23,41 @@ static const PinMap PinMap_UART_TX[] = { {PC_3, RTL_PIN_PERI(UART0, 0, S0), RTL_PIN_FUNC(UART0, S0)}, {PE_0, RTL_PIN_PERI(UART0, 0, S1), RTL_PIN_FUNC(UART0, S1)}, {PA_7, RTL_PIN_PERI(UART0, 0, S2), RTL_PIN_FUNC(UART0, S2)}, // None RTL8710AF - {PD_3, RTL_PIN_PERI(UART1, 1, S0), RTL_PIN_FUNC(UART1, S0)}, // None RTL8710AF + {PD_3, RTL_PIN_PERI(UART1, 1, S0), RTL_PIN_FUNC(UART1, S0)}, // None RTL8710AF, RTL8711AM {PE_4, RTL_PIN_PERI(UART1, 1, S1), RTL_PIN_FUNC(UART1, S1)}, - {PB_5, RTL_PIN_PERI(UART1, 1, S2), RTL_PIN_FUNC(UART1, S2)}, // None RTL8710AF - {PA_4, RTL_PIN_PERI(UART2, 2, S0), RTL_PIN_FUNC(UART2, S0)}, - {PC_9, RTL_PIN_PERI(UART2, 2, S1), RTL_PIN_FUNC(UART2, S1)}, // None RTL8710AF - {PD_7, RTL_PIN_PERI(UART2, 2, S2), RTL_PIN_FUNC(UART2, S2)}, // None RTL8710AF + {PB_5, RTL_PIN_PERI(UART1, 1, S2), RTL_PIN_FUNC(UART1, S2)}, // None RTL8710AF, RTL8711AM + {PA_4, RTL_PIN_PERI(UART2, 2, S0), RTL_PIN_FUNC(UART2, S0)}, // None RTL8711AM + {PC_9, RTL_PIN_PERI(UART2, 2, S1), RTL_PIN_FUNC(UART2, S1)}, // None RTL8710AF, RTL8711AM + {PD_7, RTL_PIN_PERI(UART2, 2, S2), RTL_PIN_FUNC(UART2, S2)}, // None RTL8710AF, RTL8711AM {NC, NC, 0} }; static const PinMap PinMap_UART_RX[] = { - {PC_0, RTL_PIN_PERI(UART0, 0, S0), RTL_PIN_FUNC(UART0, S0)}, - {PE_3, RTL_PIN_PERI(UART0, 0, S1), RTL_PIN_FUNC(UART0, S1)}, - {PA_6, RTL_PIN_PERI(UART0, 0, S2), RTL_PIN_FUNC(UART0, S2)}, // None RTL8710AF - {PD_0, RTL_PIN_PERI(UART1, 1, S0), RTL_PIN_FUNC(UART1, S0)}, // None RTL8710AF - {PE_7, RTL_PIN_PERI(UART1, 1, S1), RTL_PIN_FUNC(UART1, S1)}, // None RTL8710AF - {PB_4, RTL_PIN_PERI(UART1, 1, S2), RTL_PIN_FUNC(UART1, S2)}, // None RTL8710AF - {PA_0, RTL_PIN_PERI(UART2, 2, S0), RTL_PIN_FUNC(UART2, S0)}, - {PC_6, RTL_PIN_PERI(UART2, 2, S1), RTL_PIN_FUNC(UART2, S1)}, // None RTL8710AF - {PD_4, RTL_PIN_PERI(UART2, 2, S2), RTL_PIN_FUNC(UART2, S2)}, // None RTL8710AF + {PC_0, RTL_PIN_PERI(UART0, 0, S0), RTL_PIN_FUNC(UART0, S0)}, // No Interrupt Source? + {PE_3, RTL_PIN_PERI(UART0, 0, S1), RTL_PIN_FUNC(UART0, S1)}, + {PA_6, RTL_PIN_PERI(UART0, 0, S2), RTL_PIN_FUNC(UART0, S2)}, // None RTL8710AF, // No Interrupt Source? + {PD_0, RTL_PIN_PERI(UART1, 1, S0), RTL_PIN_FUNC(UART1, S0)}, // None RTL8710AF, RTL8711AM + {PE_7, RTL_PIN_PERI(UART1, 1, S1), RTL_PIN_FUNC(UART1, S1)}, // None RTL8710AF, RTL8711AM + {PB_4, RTL_PIN_PERI(UART1, 1, S2), RTL_PIN_FUNC(UART1, S2)}, // None RTL8710AF, RTL8711AM + {PA_0, RTL_PIN_PERI(UART2, 2, S0), RTL_PIN_FUNC(UART2, S0)}, // None RTL8711AM + {PC_6, RTL_PIN_PERI(UART2, 2, S1), RTL_PIN_FUNC(UART2, S1)}, // None RTL8710AF, RTL8711AM + {PD_4, RTL_PIN_PERI(UART2, 2, S2), RTL_PIN_FUNC(UART2, S2)}, // None RTL8710AF, RTL8711AM {NC, NC, 0} }; -#define UART_NUM (2) //pvvx! RTL8710 ! +#define UART_NUM (3) #define SERIAL_TX_IRQ_EN 0x01 #define SERIAL_RX_IRQ_EN 0x02 #define SERIAL_TX_DMA_EN 0x01 #define SERIAL_RX_DMA_EN 0x02 -static uint32_t serial_irq_ids[UART_NUM] = {0, 0}; // , 0 +static uint32_t serial_irq_ids[UART_NUM] = {0, 0, 0}; // , 0 static uart_irq_handler irq_handler[UART_NUM]; -static uint32_t serial_irq_en[UART_NUM] = {0, 0}; // , 0 +static uint32_t serial_irq_en[UART_NUM] = {0, 0, 0}; // , 0 #ifdef CONFIG_GDMA_EN -static uint32_t serial_dma_en[UART_NUM] = {0, 0}; // , 0 +static uint32_t serial_dma_en[UART_NUM] = {0, 0, 0}; // , 0 static HAL_GDMA_OP UartGdmaOp; #endif diff --git a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/spdio_api.c b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/spdio_api.c index 4552aba..2a432c3 100644 --- a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/spdio_api.c +++ b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/spdio_api.c @@ -42,6 +42,20 @@ void spdio_structinit(struct spdio_t *obj){ obj->tx_done_cb = NULL; } +///////// Add pvvx, no ... +void HalSdioRegisterRxCallback(char (*rx_done_cb)(void *priv, void* pbuf, u8 *pdata, u16 size, u8 type), void *obj) +{ + struct spdio_t * sp = (struct spdio_t *) obj; + sp->rx_done_cb = rx_done_cb; +} + +void HalSdioRegisterTxDoneCallback(char (*tx_done_cb)(void *priv, void* pbuf), void *obj) +{ + struct spdio_t * sp = (struct spdio_t *) obj; + sp->tx_done_cb = tx_done_cb; +} +/////// + void spdio_init(struct spdio_t *obj) { if(obj == NULL){ @@ -56,8 +70,8 @@ void spdio_init(struct spdio_t *obj) } g_spdio_priv = obj; HalSdioInit(); - HalSdioRegisterTxCallback(spdio_rx_done_cb, (void *)obj); // ?????????? - HalSdioRegisterRxDoneCallback(spdio_tx_done_cb, (void *)obj); // ????????? + HalSdioRegisterRxCallback(spdio_rx_done_cb, (void *)obj); // ?????????? + HalSdioRegisterTxDoneCallback(spdio_tx_done_cb, (void *)obj); // ????????? } void spdio_deinit(struct spdio_t *obj) diff --git a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/spi_api.c b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/spi_api.c index 3a4cd5b..85471cd 100644 --- a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/spi_api.c +++ b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/spi_api.c @@ -360,7 +360,7 @@ void spi_slave_select_bypin(spi_t *obj, PinName pinname) } } else - DBG_SSI_ERR("Wrong Chip Seleect Pin.\n"); + DBG_SSI_ERR("Wrong Chip Select Pin.\n"); } else{ diff --git a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/sys_api.c b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/sys_api.c index 90e67f7..ef90f22 100644 --- a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/sys_api.c +++ b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/sys_api.c @@ -39,10 +39,11 @@ extern VOID HalJtagPinOff(VOID); extern void HalInitLogUart(void); extern void HalDeinitLogUart(void); -#if defined ( __ICCARM__ ) +#ifdef CONFIG_SDR_EN +//#if defined ( __ICCARM__ ) extern u8 IsSdrPowerOn(); +//#endif #endif - /** * @brief Turn off the JTAG function * @@ -206,20 +207,26 @@ void sys_reset(void) u8 sys_is_sdram_power_on(void) { - u8 ison = 0; +#ifdef CONFIG_SDR_EN +// u8 ison = 0; -#if defined ( __ICCARM__ ) - ison = IsSdrPowerOn(); +//#if defined ( __ICCARM__ ) + return IsSdrPowerOn(); +//#endif + +// return ison; +#else + return 0; #endif - - return ison; } void sys_sdram_off(void) { -#if defined ( __ICCARM__ ) - if (sys_is_sdram_power_on()) { +#ifdef CONFIG_SDR_EN +//#if defined ( __ICCARM__ ) + if (IsSdrPowerOn()) { SdrPowerOff(); } +//#endif #endif -} \ No newline at end of file +} diff --git a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/us_ticker.c b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/us_ticker.c index 34d1cb4..b41dfbc 100644 --- a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/us_ticker.c +++ b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/us_ticker.c @@ -17,15 +17,15 @@ #define APP_TIM_ID 6 // the G-Timer ID for Application static int us_ticker_inited = 0; -static TIMER_ADAPTER TimerAdapter; +static TIMER_ADAPTER Timer6Adapter; extern HAL_TIMER_OP HalTimerOp; - +/* VOID _us_ticker_irq_handler(IN VOID *Data) { us_ticker_irq_handler(); } - +*/ void us_ticker_init(void) { @@ -33,17 +33,17 @@ void us_ticker_init(void) us_ticker_inited = 1; // Initial a G-Timer - TimerAdapter.IrqDis = 1; // Disable Irq - TimerAdapter.IrqHandle.IrqFun = (IRQ_FUN) _us_ticker_irq_handler; - TimerAdapter.IrqHandle.IrqNum = TIMER2_7_IRQ; - TimerAdapter.IrqHandle.Priority = 10; - TimerAdapter.IrqHandle.Data = (u32)NULL; - TimerAdapter.TimerId = APP_TIM_ID; - TimerAdapter.TimerIrqPriority = 0; - TimerAdapter.TimerLoadValueUs = 1; - TimerAdapter.TimerMode = FREE_RUN_MODE; // Countdown Free Run + Timer6Adapter.IrqDis = 1; // Disable Irq + Timer6Adapter.IrqHandle.IrqFun = (IRQ_FUN) us_ticker_irq_handler; + Timer6Adapter.IrqHandle.IrqNum = TIMER2_7_IRQ; + Timer6Adapter.IrqHandle.Priority = 10; + Timer6Adapter.IrqHandle.Data = (u32)NULL; + Timer6Adapter.TimerId = APP_TIM_ID; + Timer6Adapter.TimerIrqPriority = 0; + Timer6Adapter.TimerLoadValueUs = 1; + Timer6Adapter.TimerMode = FREE_RUN_MODE; // Countdown Free Run - HalTimerOp.HalTimerInit((VOID*) &TimerAdapter); + HalTimerOp.HalTimerInit((VOID*) &Timer6Adapter); DBG_TIMER_INFO("%s: Timer_Id=%d\n", __FUNCTION__, APP_TIM_ID); } @@ -119,19 +119,19 @@ void us_ticker_set_interrupt(timestamp_t timestamp) time_def = TIMER_TICK_US; // at least 1 tick } - TimerAdapter.IrqDis = 0; // Enable Irq - TimerAdapter.TimerLoadValueUs = time_def; - TimerAdapter.TimerMode = USER_DEFINED; // Countdown Free Run + Timer6Adapter.IrqDis = 0; // Enable Irq + Timer6Adapter.TimerLoadValueUs = time_def; + Timer6Adapter.TimerMode = USER_DEFINED; // Countdown Free Run - HalTimerOp.HalTimerInit((VOID*) &TimerAdapter); + HalTimerOp.HalTimerInit((VOID*) &Timer6Adapter); } void us_ticker_disable_interrupt(void) { - HalTimerOp.HalTimerDis((u32)TimerAdapter.TimerId); + HalTimerOp.HalTimerDis((u32)Timer6Adapter.TimerId); } void us_ticker_clear_interrupt(void) { - HalTimerOp.HalTimerIrqClear((u32)TimerAdapter.TimerId); + HalTimerOp.HalTimerIrqClear((u32)Timer6Adapter.TimerId); } diff --git a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/wdt_api.c b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/wdt_api.c index bb24caf..eaca62c 100644 --- a/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/wdt_api.c +++ b/RTL00_SDKV35a/component/common/mbed/targets/hal/rtl8195a/wdt_api.c @@ -15,8 +15,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ -#include "wdt_api.h" #include "cmsis.h" +#include "wdt_api.h" extern VOID WDGInitial(u32 Period); extern VOID WDGStart(VOID);