diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d4b6afa..f72e2d3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,6 @@ PROJECT(${BOARD} C CXX ASM) # set(CMAKE_VERBOSE_MAKEFILE ON) ENABLE_LANGUAGE(ASM) -include_directories(${CMAKE_SOURCE_DIR}/common/misc) -include_directories(${CMAKE_SOURCE_DIR}/drivers/${CHIP}_driver/risc-v/Core/Include) include_directories(${CMAKE_SOURCE_DIR}/bsp/bsp_common/platform) if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/bsp/board/${CHIP}) diff --git a/bsp/board/bl602/board.c b/bsp/board/bl602/board.c index a4891820..d4c572ea 100644 --- a/bsp/board/bl602/board.c +++ b/bsp/board/bl602/board.c @@ -25,6 +25,7 @@ #include "hal_clock.h" #include "bl602_glb.h" #include "bl602_config.h" +#include "bflb_platform.h" struct pin_mux_cfg { uint8_t pin; diff --git a/bsp/board/bl702/board.c b/bsp/board/bl702/board.c index 7728d722..7774387a 100644 --- a/bsp/board/bl702/board.c +++ b/bsp/board/bl702/board.c @@ -25,6 +25,7 @@ #include "hal_clock.h" #include "bl702_glb.h" #include "bl702_config.h" +#include "bflb_platform.h" struct pin_mux_cfg { uint8_t pin; diff --git a/bsp/bsp_common/es8388/bsp_es8388.c b/bsp/bsp_common/es8388/bsp_es8388.c index 13a235f2..2fd03f2d 100644 --- a/bsp/bsp_common/es8388/bsp_es8388.c +++ b/bsp/bsp_common/es8388/bsp_es8388.c @@ -433,7 +433,7 @@ void ES8388_I2C_Init(void) * @return None * *******************************************************************************/ -BL_Err_Type ES8388_Reg_Dump(void) +void ES8388_Reg_Dump(void) { int i; uint8_t tmp; @@ -446,7 +446,6 @@ BL_Err_Type ES8388_Reg_Dump(void) bflb_platform_printf("Reg[%02d]=0x%02x \n", i, tmp); } - return SUCCESS; } /*@} end of group ES8388_Private_Functions */ diff --git a/bsp/bsp_common/es8388/bsp_es8388.h b/bsp/bsp_common/es8388/bsp_es8388.h index ba30d1e4..74ba4b8f 100644 --- a/bsp/bsp_common/es8388/bsp_es8388.h +++ b/bsp/bsp_common/es8388/bsp_es8388.h @@ -181,7 +181,7 @@ typedef struct * @{ */ void ES8388_Init(ES8388_Cfg_Type *cfg); -BL_Err_Type ES8388_Reg_Dump(void); +void ES8388_Reg_Dump(void); int ES8388_Set_Voice_Volume(int volume); /*@} end of group ES8388_Public_Functions */ diff --git a/bsp/bsp_common/ethernet/ethernetif.c b/bsp/bsp_common/ethernet/ethernetif.c index d7a8edca..f350ca94 100644 --- a/bsp/bsp_common/ethernet/ethernetif.c +++ b/bsp/bsp_common/ethernet/ethernetif.c @@ -34,7 +34,7 @@ #include "hal_emac.h" #include #include "semphr.h" - +#include "bflb_platform.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Network interface name */ diff --git a/bsp/bsp_common/il9341/bsp_il9341.c b/bsp/bsp_common/il9341/bsp_il9341.c index 5b75c9e5..95117899 100644 --- a/bsp/bsp_common/il9341/bsp_il9341.c +++ b/bsp/bsp_common/il9341/bsp_il9341.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "bsp_il9341.h" #include "hal_spi.h" #include "hal_dma.h" @@ -625,7 +625,7 @@ void LCD_DrawChinese(uint16_t x, uint16_t y, uint8_t *character, uint16_t bk_col // color为字体颜色,bk_color为背景颜色,num为最大显示数量(汉字算两个) void LCD_DrawFont(uint16_t x, uint16_t y, uint16_t color, uint16_t bk_color, uint8_t *str, uint8_t num) { - uint8_t i, j, k, l, x0 = x; + uint8_t i, j, k, x0 = x; uint8_t temp, m; for (i = 0; i < num && *str; i++, str++) { @@ -701,7 +701,7 @@ void LCD_DrawFont(uint16_t x, uint16_t y, uint16_t color, uint16_t bk_color, uin void LCD_DrawFont_64x32(uint16_t x, uint16_t y, uint16_t color, uint16_t bk_color, uint8_t *str, uint8_t num) { - uint16_t i, j, k, l, x0 = x; + uint16_t i, j, k, x0 = x; uint8_t temp, m; for (i = 0; i < num && *str; i++, str++) { diff --git a/bsp/bsp_common/image_sensor/bsp_image_sensor.c b/bsp/bsp_common/image_sensor/bsp_image_sensor.c index b51d554d..31fbf8c9 100644 --- a/bsp/bsp_common/image_sensor/bsp_image_sensor.c +++ b/bsp/bsp_common/image_sensor/bsp_image_sensor.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "bsp_image_sensor.h" #include "bl702_glb.h" #include "hal_gpio.h" diff --git a/bsp/bsp_common/mcu_lcd/mcu_lcd.c b/bsp/bsp_common/mcu_lcd/mcu_lcd.c index 8104c9a6..902a9fd0 100644 --- a/bsp/bsp_common/mcu_lcd/mcu_lcd.c +++ b/bsp/bsp_common/mcu_lcd/mcu_lcd.c @@ -52,7 +52,7 @@ int lcd_auto_swap_set(uint8_t flag) * @param color_num color num * @return int */ -int lcd_swap_color_data16(uint16_t *dst, uint16_t *src, size_t color_num) +int lcd_swap_color_data16(uint16_t *dst, uint16_t *src, uint32_t color_num) { for (size_t i = 0; i < color_num; i++) { dst[i] = (src[i] << 8) | (src[i] >> 8); diff --git a/bsp/bsp_common/mcu_lcd/mcu_lcd.h b/bsp/bsp_common/mcu_lcd/mcu_lcd.h index 9d431af3..b0c1adbb 100644 --- a/bsp/bsp_common/mcu_lcd/mcu_lcd.h +++ b/bsp/bsp_common/mcu_lcd/mcu_lcd.h @@ -61,7 +61,7 @@ extern struct device *lcd_dev_ifs; extern uint8_t lcd_auto_swap_flag; int lcd_auto_swap_set(uint8_t flag); -int lcd_swap_color_data16(uint16_t *dst, uint16_t *src, size_t num); +int lcd_swap_color_data16(uint16_t *dst, uint16_t *src, uint32_t num); int lcd_init(void); int lcd_set_dir(uint8_t dir, uint8_t mir_flag); int lcd_get_dir(); diff --git a/bsp/bsp_common/mcu_lcd/ssd1306.c b/bsp/bsp_common/mcu_lcd/ssd1306.c index ca968b95..99b3641b 100644 --- a/bsp/bsp_common/mcu_lcd/ssd1306.c +++ b/bsp/bsp_common/mcu_lcd/ssd1306.c @@ -3,6 +3,7 @@ #include "hal_spi.h" #include "hal_gpio.h" #include "font.h" +#include "bflb_platform.h" #define SSD1306_USING_I2C 0 #define SSD1306_USING_SPI 1 diff --git a/bsp/bsp_common/platform/bflb_platform.c b/bsp/bsp_common/platform/bflb_platform.c index b9f0cc7a..3394b479 100644 --- a/bsp/bsp_common/platform/bflb_platform.c +++ b/bsp/bsp_common/platform/bflb_platform.c @@ -25,6 +25,7 @@ #include "drv_mmheap.h" #include "hal_common.h" #include "ring_buffer.h" +#include "bflb_platform.h" extern uint32_t __HeapBase; extern uint32_t __HeapLimit; diff --git a/bsp/bsp_common/platform/bflb_platform.h b/bsp/bsp_common/platform/bflb_platform.h index 9b3ea0e0..eaa1ef8f 100644 --- a/bsp/bsp_common/platform/bflb_platform.h +++ b/bsp/bsp_common/platform/bflb_platform.h @@ -28,8 +28,12 @@ extern "C" { #endif -#include "misc.h" -//#include "mcu_sdk_version.h" +#include +#include +#include +#include +#include +#include #define MSG(a, ...) bflb_platform_printf(a, ##__VA_ARGS__) #define MSG_DBG(a, ...) bflb_platform_printf(a, ##__VA_ARGS__) @@ -78,13 +82,6 @@ extern "C" { #define LOG_E(fmt, ...) dbg_log_line("E", 31, fmt, ##__VA_ARGS__) #define LOG_RAW(...) bflb_platform_printf(__VA_ARGS__) -#ifdef DEBUG -void check_failed(uint8_t *file, uint32_t line); -#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__)) -#else -#define CHECK_PARAM(expr) ((void)0) -#endif /* DEBUG */ - void bflb_platform_init(uint32_t baudrate); void bflb_platform_printf(char *fmt, ...); void bflb_platform_print_set(uint8_t disable); diff --git a/bsp/bsp_common/spi_sd/bsp_spi_sd.c b/bsp/bsp_common/spi_sd/bsp_spi_sd.c index 0be3b5a0..2444a216 100644 --- a/bsp/bsp_common/spi_sd/bsp_spi_sd.c +++ b/bsp/bsp_common/spi_sd/bsp_spi_sd.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_spi.h" #include "hal_gpio.h" #include "hal_dma.h" diff --git a/bsp/bsp_common/usb/uart_interface.c b/bsp/bsp_common/usb/uart_interface.c index fd4e8057..7cecf551 100644 --- a/bsp/bsp_common/usb/uart_interface.c +++ b/bsp/bsp_common/usb/uart_interface.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_gpio.h" #include "uart_interface.h" #include "hal_usb.h" diff --git a/bsp/bsp_common/wm8978/wm8978.c b/bsp/bsp_common/wm8978/bsp_wm8978.c similarity index 95% rename from bsp/bsp_common/wm8978/wm8978.c rename to bsp/bsp_common/wm8978/bsp_wm8978.c index 72fa50d4..7328292d 100644 --- a/bsp/bsp_common/wm8978/wm8978.c +++ b/bsp/bsp_common/wm8978/bsp_wm8978.c @@ -20,9 +20,9 @@ * under the License. * */ - -#include "wm8978.h" +#include "bflb_platform.h" #include "hal_i2c.h" +#include "bsp_wm8978.h" struct device *wm8978_i2c = NULL; diff --git a/bsp/bsp_common/wm8978/wm8978.h b/bsp/bsp_common/wm8978/bsp_wm8978.h similarity index 95% rename from bsp/bsp_common/wm8978/wm8978.h rename to bsp/bsp_common/wm8978/bsp_wm8978.h index 85c713ea..ff367d36 100644 --- a/bsp/bsp_common/wm8978/wm8978.h +++ b/bsp/bsp_common/wm8978/bsp_wm8978.h @@ -23,7 +23,8 @@ #ifndef __WM8978_H #define __WM8978_H -#include "bflb_platform.h" + +#include "stdint.h" #define WM8978_ADDR 0X1A diff --git a/common/memheap/drv_mmheap.c b/common/memheap/drv_mmheap.c index 842525a3..cc05589f 100644 --- a/common/memheap/drv_mmheap.c +++ b/common/memheap/drv_mmheap.c @@ -302,7 +302,26 @@ void *mmheap_realloc(struct heap_info *pRoot, void *src_addr, size_t want_size) } return pReturn; } +/** + * @brief + * + * @param pRoot + * @param num + * @param size + * @return void* + */ +void *mmheap_calloc(struct heap_info *pRoot, size_t num, size_t size) +{ + void *pReturn = NULL; + pReturn = (void *)mmheap_alloc(pRoot, size * num); + + if (pReturn) { + memset(pReturn, 0, num * size); + } + + return pReturn; +} /** * @brief mmheap_free * diff --git a/common/memheap/drv_mmheap.h b/common/memheap/drv_mmheap.h index cf4595da..3509af18 100644 --- a/common/memheap/drv_mmheap.h +++ b/common/memheap/drv_mmheap.h @@ -26,7 +26,6 @@ #include #include #include -#include "bflb_platform.h" #ifndef MMHEAP_LOCK #define MMHEAP_LOCK() @@ -39,12 +38,12 @@ #ifndef MMHEAP_ASSERT #define MMHEAP_ASSERT(A) \ if (!(A)) \ - bflb_platform_printf("mmheap malloc error:drv_mmheap,%d\r\n", __LINE__) + printf("mmheap malloc error:drv_mmheap,%d\r\n", __LINE__) #endif #ifndef MMHEAP_MALLOC_FAIL -#define MMHEAP_MALLOC_FAIL() bflb_platform_printf("mmheap malloc fail:drv_mmheap,%d\r\n", __LINE__) +#define MMHEAP_MALLOC_FAIL() printf("mmheap malloc fail:drv_mmheap,%d\r\n", __LINE__) #endif #ifdef __cplusplus @@ -117,6 +116,23 @@ void *mmheap_alloc(struct heap_info *pRoot, size_t want_size); * @return the new pointer to the allocated memory. */ void *mmheap_realloc(struct heap_info *pRoot, void *src_addr, size_t want_size); +/** + * @brief Cealloc memory from the heap. + * Change the size of the memory block pointed to by ptr to size bytes. + * + * @attention + *
    + *
  • if ptr is NULL, then the call is equivalent to mmheap_alloc(size), for all values of size. + *
  • if ptr is if size is equal to zero, and ptr is not NULL, then the call is equivalent to mmheap_free(ptr). + *
+ * + * @param[in] pRoot heap info. + * @param[in] num size number. + * @param[in] size new size of the memory space. + * + * @return the new pointer to the allocated memory. + */ +void *mmheap_calloc(struct heap_info *pRoot, size_t num, size_t size); /** * @brief Free the memory. * Free the memory space pointed to by ptr, which must have been returned by a previous call to mmheap_alloc(), mmheap_aligned_alloc(), or mmheap_realloc(). diff --git a/common/misc/compiler/common.h b/common/misc/compiler/common.h index 8032bf89..29489e3c 100644 --- a/common/misc/compiler/common.h +++ b/common/misc/compiler/common.h @@ -40,7 +40,7 @@ } /* Std driver attribute macro*/ - #ifndef BFLB_USE_CUSTOM_LD_SECTIONS +#ifndef BFLB_USE_CUSTOM_LD_SECTIONS //#define ATTR_UNI_SYMBOL #define ATTR_STRINGIFY(x) #x #define ATTR_TOSTRING(x) ATTR_STRINGIFY(x) diff --git a/common/misc/misc.h b/common/misc/misc.h index 9a5f1ea7..b00c039b 100644 --- a/common/misc/misc.h +++ b/common/misc/misc.h @@ -43,6 +43,13 @@ #define CHECK_PARAM(expr) ((void)0) #endif +/** + * @brief Null Type definition + */ +#ifndef NULL +#define NULL 0 +#endif + /** * @brief Error type definition */ @@ -100,27 +107,6 @@ typedef enum { typedef void(intCallback_Type)(void); typedef void (*pFunc)(void); -/** - * @brief Null Type definition - */ -#ifndef NULL -#define NULL 0 -#endif - -#define BL602_MemCpy arch_memcpy -#define BL602_MemSet arch_memset -#define BL602_MemCmp arch_memcmp -#define BL602_MemCpy4 arch_memcpy4 -#define BL602_MemCpy_Fast arch_memcpy_fast -#define BL602_MemSet4 arch_memset4 - -#define BL702_MemCpy arch_memcpy -#define BL702_MemSet arch_memset -#define BL702_MemCmp arch_memcmp -#define BL702_MemCpy4 arch_memcpy4 -#define BL702_MemCpy_Fast arch_memcpy_fast -#define BL702_MemSet4 arch_memset4 - #define ARCH_MemCpy arch_memcpy #define ARCH_MemSet arch_memset #define ARCH_MemCmp arch_memcmp @@ -128,6 +114,13 @@ typedef void (*pFunc)(void); #define ARCH_MemCpy_Fast arch_memcpy_fast #define ARCH_MemSet4 arch_memset4 +#ifdef DEBUG +void check_failed(uint8_t *file, uint32_t line); +#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__)) +#else +#define CHECK_PARAM(expr) ((void)0) +#endif /* DEBUG */ + void *arch_memcpy(void *dst, const void *src, uint32_t n); void *arch_memset(void *s, uint8_t c, uint32_t n); int arch_memcmp(const void *s1, const void *s2, uint32_t n); diff --git a/common/partition/partition.h b/common/partition/partition.h index 9446436c..f20332dc 100644 --- a/common/partition/partition.h +++ b/common/partition/partition.h @@ -36,10 +36,7 @@ #ifndef __PARTITION_H__ #define __PARTITION_H__ -#include "stdint.h" -#include "string.h" #include "misc.h" -//#include "bflb_bsp_driver_glue.h" /** @addtogroup BFLB_Common_Driver * @{ diff --git a/common/pid/pid.h b/common/pid/pid.h index 9a6927e9..eb3b77f0 100644 --- a/common/pid/pid.h +++ b/common/pid/pid.h @@ -24,7 +24,7 @@ #ifndef __PID_H__ #define __PID_H__ -#include "stdio.h" +#include "stdint.h" typedef struct pid_alg { float set_val; diff --git a/common/timestamp/timestamp.c b/common/timestamp/timestamp.c index 606bafd1..3454ff47 100644 --- a/common/timestamp/timestamp.c +++ b/common/timestamp/timestamp.c @@ -22,7 +22,6 @@ */ #include "timestamp.h" -#include "misc.h" #define FOUR_YEAR_DAY ((365 << 2) + 1) //The total number of days in a 4-year cycle #define TIMEZONE (8) //Beijing time Zone adjustment @@ -127,7 +126,7 @@ void unixtime2bejingtime(uint32_t unixtime, rtc_time *beijing_time) beijing_time->day = remain_day; - + /*利用基姆拉尔森计算日期公式 w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)*/ beijing_time->week = beijing_time->day + 2*beijing_time->month + 3*(beijing_time->month+1)/5 + \ diff --git a/common/timestamp/timestamp.h b/common/timestamp/timestamp.h index 2522d0f3..dfa95e2d 100644 --- a/common/timestamp/timestamp.h +++ b/common/timestamp/timestamp.h @@ -24,7 +24,8 @@ #define _TIMESTAMP_ #include "stdint.h" -#include "stdbool.h" +#include "stddef.h" +#include "stdbool.h" typedef struct _rtc_time_t { @@ -36,6 +37,7 @@ typedef struct _rtc_time_t uint8_t minute; uint8_t second; }rtc_time; + void unixtime2bejingtime(uint32_t unixtime,rtc_time* beijing_time); #endif diff --git a/components/lvgl/lv_conf_internal.h b/components/lvgl/lv_conf_internal.h index ca3182d1..7dbf6586 100644 --- a/components/lvgl/lv_conf_internal.h +++ b/components/lvgl/lv_conf_internal.h @@ -99,7 +99,7 @@ /* Automatically defrag. on free. Defrag. means joining the adjacent free cells. */ #define LV_MEM_AUTO_DEFRAG 1 #else /*LV_MEM_CUSTOM*/ - #define LV_MEM_CUSTOM_INCLUDE "stdio.h" /*Header for the dynamic memory function*/ + #define LV_MEM_CUSTOM_INCLUDE "stdlib.h" /*Header for the dynamic memory function*/ #define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/ #define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/ #endif /*LV_MEM_CUSTOM*/ diff --git a/components/rt-thread/bsp/bouffalolab/bl602/board/board.c b/components/rt-thread/bsp/bouffalolab/bl602/board/board.c index 780fee1f..492f9556 100644 --- a/components/rt-thread/bsp/bouffalolab/bl602/board/board.c +++ b/components/rt-thread/bsp/bouffalolab/bl602/board/board.c @@ -6,7 +6,7 @@ * Change Logs: * Date Author Notes */ - +#include "bflb_platform.h" #include #include "board.h" #include "hal_uart.h" diff --git a/components/rt-thread/bsp/bouffalolab/bl702/board/board.c b/components/rt-thread/bsp/bouffalolab/bl702/board/board.c index 780fee1f..492f9556 100644 --- a/components/rt-thread/bsp/bouffalolab/bl702/board/board.c +++ b/components/rt-thread/bsp/bouffalolab/bl702/board/board.c @@ -6,7 +6,7 @@ * Change Logs: * Date Author Notes */ - +#include "bflb_platform.h" #include #include "board.h" #include "hal_uart.h" diff --git a/components/usb_stack/common/usb_dc.h b/components/usb_stack/common/usb_dc.h index ea57fcde..29997c11 100644 --- a/components/usb_stack/common/usb_dc.h +++ b/components/usb_stack/common/usb_dc.h @@ -2,7 +2,6 @@ #define _USB_DC_H #include "stdint.h" -#include "bflb_platform.h" #ifdef __cplusplus extern "C" { diff --git a/components/usb_stack/common/usb_util.h b/components/usb_stack/common/usb_util.h index eebd3401..11a0eaac 100644 --- a/components/usb_stack/common/usb_util.h +++ b/components/usb_stack/common/usb_util.h @@ -5,7 +5,9 @@ #include "string.h" #include "stdint.h" #include "stdio.h" +#include "stdlib.h" #include "usb_slist.h" +#include "bflb_platform.h" #ifndef __packed #define __packed __attribute__((__packed__)) diff --git a/components/xz/xz_port.c b/components/xz/xz_port.c index d4686f8d..9cfea7d8 100644 --- a/components/xz/xz_port.c +++ b/components/xz/xz_port.c @@ -1,4 +1,6 @@ #include "bflb_platform.h" +#include + static uint8_t *mallocBuf = NULL; static uint32_t malloced = 0; static uint32_t bufsize = 0; diff --git a/drivers/bl602_driver/hal_drv/inc/hal_clock.h b/drivers/bl602_driver/hal_drv/inc/hal_clock.h index e6b4181d..0c08b277 100644 --- a/drivers/bl602_driver/hal_drv/inc/hal_clock.h +++ b/drivers/bl602_driver/hal_drv/inc/hal_clock.h @@ -24,6 +24,7 @@ #define __HAL_CLOCK__H__ #include "hal_common.h" +#include "bl602_config.h" /*XTAL_TYPE*/ #define XTAL_NONE 0 diff --git a/drivers/bl602_driver/hal_drv/inc/hal_common.h b/drivers/bl602_driver/hal_drv/inc/hal_common.h index a94f9844..e7aa5251 100644 --- a/drivers/bl602_driver/hal_drv/inc/hal_common.h +++ b/drivers/bl602_driver/hal_drv/inc/hal_common.h @@ -23,9 +23,7 @@ #ifndef __HAL_COMMON__H__ #define __HAL_COMMON__H__ -#include "drv_device.h" #include "bl602_common.h" -#include "bl602_config.h" void cpu_global_irq_enable(void); void cpu_global_irq_disable(void); diff --git a/drivers/bl602_driver/hal_drv/inc/hal_dma.h b/drivers/bl602_driver/hal_drv/inc/hal_dma.h index 0178f606..6c3970af 100644 --- a/drivers/bl602_driver/hal_drv/inc/hal_dma.h +++ b/drivers/bl602_driver/hal_drv/inc/hal_dma.h @@ -24,6 +24,8 @@ #define __HAL_DMA__H__ #include "hal_common.h" +#include "drv_device.h" +#include "bl602_config.h" #define DMA_CHANNEL_GET_STATUS 0x10 #define DMA_CHANNEL_START 0x11 diff --git a/drivers/bl602_driver/hal_drv/inc/hal_gpio.h b/drivers/bl602_driver/hal_drv/inc/hal_gpio.h index 48707c3c..61d4d43d 100644 --- a/drivers/bl602_driver/hal_drv/inc/hal_gpio.h +++ b/drivers/bl602_driver/hal_drv/inc/hal_gpio.h @@ -37,6 +37,8 @@ #define __HAL_GPIO__H__ #include "hal_common.h" +#include "drv_device.h" +#include "bl602_config.h" typedef enum { GPIO_PIN_0 = 0, diff --git a/drivers/bl602_driver/hal_drv/inc/hal_sec_hash.h b/drivers/bl602_driver/hal_drv/inc/hal_sec_hash.h index d8175524..8d545ba2 100644 --- a/drivers/bl602_driver/hal_drv/inc/hal_sec_hash.h +++ b/drivers/bl602_driver/hal_drv/inc/hal_sec_hash.h @@ -24,6 +24,8 @@ #define __HAL_SEC_HASH__H__ #include "hal_common.h" +#include "drv_device.h" +#include "bl602_config.h" enum sec_hash_index_type { SEC_HASH0_INDEX, diff --git a/drivers/bl602_driver/hal_drv/inc/hal_uart.h b/drivers/bl602_driver/hal_drv/inc/hal_uart.h index 6c28f671..e48e24ad 100644 --- a/drivers/bl602_driver/hal_drv/inc/hal_uart.h +++ b/drivers/bl602_driver/hal_drv/inc/hal_uart.h @@ -37,6 +37,8 @@ #define __HAL_UART__H__ #include "hal_common.h" +#include "drv_device.h" +#include "bl602_config.h" #define UART_FIFO_LEN 32 diff --git a/drivers/bl602_driver/hal_drv/src/hal_flash.c b/drivers/bl602_driver/hal_drv/src/hal_flash.c index cfc98818..a0422ebc 100644 --- a/drivers/bl602_driver/hal_drv/src/hal_flash.c +++ b/drivers/bl602_driver/hal_drv/src/hal_flash.c @@ -133,11 +133,13 @@ BL_Err_Type ATTR_TCM_SECTION flash_init(void) g_flash_cfg.ioMode = g_flash_cfg.ioMode & 0x0f; ret = flash_config_init(&g_flash_cfg, (uint8_t *)&jedec_id); +#if 0 MSG("flash ID = %08x\r\n", jedec_id); bflb_platform_dump((uint8_t *)&g_flash_cfg, sizeof(g_flash_cfg)); if (ret != SUCCESS) { MSG("flash config init fail!\r\n"); } +#endif g_flash_cfg.clkDelay = clkDelay; g_flash_cfg.clkInvert = clkInvert; diff --git a/drivers/bl602_driver/hal_drv/src/hal_sec_ecdsa.c b/drivers/bl602_driver/hal_drv/src/hal_sec_ecdsa.c index 57080048..a6e61baa 100644 --- a/drivers/bl602_driver/hal_drv/src/hal_sec_ecdsa.c +++ b/drivers/bl602_driver/hal_drv/src/hal_sec_ecdsa.c @@ -449,7 +449,7 @@ static int sec_ecdsa_verify_point_mul(uint8_t id, const uint32_t *m) #endif } else if (pka_p1_eq_inf == 0 && pka_p2_eq_inf == 1) { //sum = X1 - MSG("sum = X1\r\n"); + //MSG("sum = X1\r\n"); } else if (pka_p1_eq_inf == 0 && pka_p2_eq_inf == 0) { //sum = X1 + X2 sec_ecdsa_point_add(id); @@ -458,7 +458,7 @@ static int sec_ecdsa_verify_point_mul(uint8_t id, const uint32_t *m) sec_ecdsa_dump_temp_result(); #endif } else { - MSG("Error! infinite point + infinite point\r\n"); + //MSG("Error! infinite point + infinite point\r\n"); return -1; } } diff --git a/drivers/bl602_driver/hal_drv/src/hal_uart.c b/drivers/bl602_driver/hal_drv/src/hal_uart.c index dbddf3f8..912ca6d2 100644 --- a/drivers/bl602_driver/hal_drv/src/hal_uart.c +++ b/drivers/bl602_driver/hal_drv/src/hal_uart.c @@ -41,6 +41,8 @@ #include "bl602_glb.h" #include "uart_config.h" +#define UART_CLOCK (40000000) + #ifdef BSP_USING_UART0 void UART0_IRQ(void); #endif @@ -74,17 +76,18 @@ int uart_open(struct device *dev, uint16_t oflag) /* disable uart before config */ UART_Disable(uart_device->id, UART_TXRX); - uint32_t uart_clk = peripheral_clock_get(PERIPHERAL_CLOCK_UART); + //uint32_t uart_clk = peripheral_clock_get(PERIPHERAL_CLOCK_UART); uart_cfg.baudRate = uart_device->baudrate; uart_cfg.dataBits = uart_device->databits; uart_cfg.stopBits = uart_device->stopbits; uart_cfg.parity = uart_device->parity; - uart_cfg.uartClk = uart_clk; + uart_cfg.uartClk = UART_CLOCK; uart_cfg.ctsFlowControl = UART_CTS_FLOWCONTROL_ENABLE; uart_cfg.rtsSoftwareControl = UART_RTS_FLOWCONTROL_ENABLE; uart_cfg.byteBitInverse = UART_MSB_FIRST_ENABLE; + GLB_Set_UART_CLK(ENABLE, HBN_UART_CLK_160M, 160000000 / UART_CLOCK - 1); /* uart init with default configuration */ UART_Init(uart_device->id, &uart_cfg); @@ -170,8 +173,10 @@ int uart_control(struct device *dev, int cmd, void *args) } if (uart_device->id == UART0_ID) { + Interrupt_Handler_Register(UART0_IRQn, UART0_IRQ); CPU_Interrupt_Enable(UART0_IRQn); } else if (uart_device->id == UART1_ID) { + Interrupt_Handler_Register(UART1_IRQn, UART1_IRQ); CPU_Interrupt_Enable(UART1_IRQn); } diff --git a/drivers/bl602_driver/startup/interrupt.c b/drivers/bl602_driver/startup/interrupt.c index b2a21102..038156f9 100644 --- a/drivers/bl602_driver/startup/interrupt.c +++ b/drivers/bl602_driver/startup/interrupt.c @@ -20,7 +20,7 @@ * under the License. * */ -#include "bl602.h" +#include "bl602_common.h" #include "bflb_platform.h" pFunc __Interrupt_Handlers[IRQn_LAST] = { 0 }; @@ -305,6 +305,10 @@ void Interrupt_Handler_Register(IRQn_Type irq, pFunc interruptFun) } } +void System_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority) +{ +} + void clic_enable_interrupt(uint32_t source) { *(volatile uint8_t *)(CLIC_HART0_ADDR + CLIC_INTIE + source) = 1; diff --git a/drivers/bl602_driver/startup/system_bl602.c b/drivers/bl602_driver/startup/system_bl602.c index 364280b5..d3d737e2 100644 --- a/drivers/bl602_driver/startup/system_bl602.c +++ b/drivers/bl602_driver/startup/system_bl602.c @@ -80,16 +80,9 @@ void SystemInit(void) /*identify flash config automaticly*/ extern BL_Err_Type flash_init(void); -extern void bflb_platform_print_set(uint8_t disable); void System_Post_Init(void) { PDS_Trim_RC32M(); HBN_Trim_RC32K(); - bflb_platform_print_set(1); flash_init(); - bflb_platform_print_set(0); -} - -void System_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority) -{ -} +} \ No newline at end of file diff --git a/drivers/bl602_driver/std_drv/inc/bl602_common.h b/drivers/bl602_driver/std_drv/inc/bl602_common.h index 2b1a3ff3..29be4245 100644 --- a/drivers/bl602_driver/std_drv/inc/bl602_common.h +++ b/drivers/bl602_driver/std_drv/inc/bl602_common.h @@ -2,7 +2,7 @@ #define __BL602_COMMON_H__ #include "bl602.h" -#include "bflb_platform.h" +#include "misc.h" #ifndef __NOP #define __NOP() __ASM volatile("nop") /* This implementation generates debug information */ @@ -57,6 +57,32 @@ __ALWAYS_STATIC_INLINE void __disable_irq(void) __ASM volatile("csrc mstatus, 8"); } +/** @defgroup COMMON_Public_Constants + * @{ + */ + +/** @defgroup DRIVER_INT_PERIPH + * @{ + */ +#define IS_INT_PERIPH(INT_PERIPH) ((INT_PERIPH) < IRQn_LAST) + +/*@} end of group DRIVER_INT_PERIPH */ + +/** @defgroup DRIVER_INT_MASK + * @{ + */ +#define IS_BL_MASK_TYPE(type) (((type) == MASK) || ((type) == UNMASK)) + +/*@} end of group COMMON_Public_Constants */ + +/*@} end of group DRIVER_Public_Macro */ +#define BL602_MemCpy arch_memcpy +#define BL602_MemSet arch_memset +#define BL602_MemCmp arch_memcmp +#define BL602_MemCpy4 arch_memcpy4 +#define BL602_MemCpy_Fast arch_memcpy_fast +#define BL602_MemSet4 arch_memset4 + #define arch_delay_us BL602_Delay_US #define arch_delay_ms BL602_Delay_MS diff --git a/drivers/bl602_driver/std_drv/inc/bl602_it.h b/drivers/bl602_driver/std_drv/inc/bl602_it.h deleted file mode 100644 index fd81b204..00000000 --- a/drivers/bl602_driver/std_drv/inc/bl602_it.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef __BL602_IT_H__ -#define __BL602_IT_H__ - -#include "bl602.h" -#include "bl_common.h" - -/** @addtogroup BL606_Peripheral_Driver - * @{ - */ - -/** @addtogroup COMMON - * @{ - */ - -/** @defgroup COMMON_Public_Types - * @{ - */ - -/*@} end of group COMMON_Public_Types */ - -/** @defgroup COMMON_Public_Constants - * @{ - */ - -/** @defgroup DRIVER_INT_PERIPH - * @{ - */ -#define IS_INT_PERIPH(INT_PERIPH) ((INT_PERIPH) < IRQn_LAST) - -/*@} end of group DRIVER_INT_PERIPH */ - -/** @defgroup DRIVER_INT_MASK - * @{ - */ -#define IS_BL_MASK_TYPE(type) (((type) == MASK) || ((type) == UNMASK)) - -/*@} end of group COMMON_Public_Constants */ - -/*@} end of group DRIVER_Public_Macro */ - -/** @defgroup DRIVER_Public_FunctionDeclaration - * @brief DRIVER functions declaration - * @{ - */ -void Interrupt_Handler_Register(IRQn_Type irq, pFunc interruptFun); - -/*@} end of group DRIVER_COMMON */ - -#endif /* __BL602_COMMON_H__ */ diff --git a/drivers/bl602_driver/std_drv/src/bl602_sf_cfg_ext.c b/drivers/bl602_driver/std_drv/src/bl602_sf_cfg_ext.c index 4fb3a483..5107eba4 100644 --- a/drivers/bl602_driver/std_drv/src/bl602_sf_cfg_ext.c +++ b/drivers/bl602_driver/std_drv/src/bl602_sf_cfg_ext.c @@ -665,6 +665,11 @@ static const ATTR_TCM_CONST_SECTION Flash_Info_t flashInfos[]={ //.name="ZD_25Q16B", .cfg=&flashCfg_ZD_25Q16B, }, + { + .jedecID=0x1460CD, + //.name="TH_25Q80HB", + .cfg=&flashCfg_FM_25Q08, + }, }; /*@} end of group SF_CFG_EXT_Private_Variables */ diff --git a/drivers/bl602_driver/std_drv/src/bl602_uart.c b/drivers/bl602_driver/std_drv/src/bl602_uart.c index 422249e3..847c8b41 100644 --- a/drivers/bl602_driver/std_drv/src/bl602_uart.c +++ b/drivers/bl602_driver/std_drv/src/bl602_uart.c @@ -284,7 +284,7 @@ BL_Err_Type UART_Init(UART_ID_Type uartId, UART_CFG_Type *uartCfg) BL_WR_REG(UARTx, UART_DATA_CONFIG, tmpValTxCfg); -#if 1 //#ifndef BFLB_USE_HAL_DRIVER +#ifndef BFLB_USE_HAL_DRIVER Interrupt_Handler_Register(UART0_IRQn, UART0_IRQHandler); Interrupt_Handler_Register(UART1_IRQn, UART1_IRQHandler); #endif diff --git a/drivers/bl702_driver/hal_drv/inc/hal_acomp.h b/drivers/bl702_driver/hal_drv/inc/hal_acomp.h index fba0082b..20f3ba3d 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_acomp.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_acomp.h @@ -6,6 +6,7 @@ extern "C"{ #endif #include "hal_common.h" +#include "drv_device.h" enum acomp_channel_type { ACOMP_CHANNEL_ADC_CHANNEL0, /*!< Analog compare channel,ADC input channel 0 */ diff --git a/drivers/bl702_driver/hal_drv/inc/hal_adc.h b/drivers/bl702_driver/hal_drv/inc/hal_adc.h index 5d2ab97e..cdd3421c 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_adc.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_adc.h @@ -28,6 +28,8 @@ extern "C" { #endif #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" #define DEVICE_CTRL_ADC_CHANNEL_START 0x10 #define DEVICE_CTRL_ADC_CHANNEL_STOP 0x11 diff --git a/drivers/bl702_driver/hal_drv/inc/hal_cam.h b/drivers/bl702_driver/hal_drv/inc/hal_cam.h index 93525f55..c9d7502b 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_cam.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_cam.h @@ -29,6 +29,8 @@ extern "C"{ #endif #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" #include "bl702_cam.h" #define DEVICE_OFLAG_INT 0x01 diff --git a/drivers/bl702_driver/hal_drv/inc/hal_clock.h b/drivers/bl702_driver/hal_drv/inc/hal_clock.h index 5df2954c..33c8e6f8 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_clock.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_clock.h @@ -28,6 +28,7 @@ extern "C"{ #endif #include "hal_common.h" +#include "bl702_config.h" /*XTAL_TYPE*/ #define XTAL_NONE 0 diff --git a/drivers/bl702_driver/hal_drv/inc/hal_common.h b/drivers/bl702_driver/hal_drv/inc/hal_common.h index d54b79c5..8f088e71 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_common.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_common.h @@ -27,9 +27,7 @@ extern "C" { #endif -#include "drv_device.h" #include "bl702_common.h" -#include "bl702_config.h" void cpu_global_irq_enable(void); void cpu_global_irq_disable(void); diff --git a/drivers/bl702_driver/hal_drv/inc/hal_dac.h b/drivers/bl702_driver/hal_drv/inc/hal_dac.h index 85b3ae7c..ac6bd184 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_dac.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_dac.h @@ -28,6 +28,8 @@ extern "C"{ #endif #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" enum dac_index_type { #ifdef BSP_USING_DAC0 diff --git a/drivers/bl702_driver/hal_drv/inc/hal_dma.h b/drivers/bl702_driver/hal_drv/inc/hal_dma.h index 24ef7cc4..e49f9bea 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_dma.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_dma.h @@ -28,6 +28,8 @@ extern "C"{ #endif #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" #define DMA_CHANNEL_GET_STATUS 0x10 #define DMA_CHANNEL_START 0x11 diff --git a/drivers/bl702_driver/hal_drv/inc/hal_emac.h b/drivers/bl702_driver/hal_drv/inc/hal_emac.h index 49d621aa..0b6cbd50 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_emac.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_emac.h @@ -29,6 +29,8 @@ extern "C"{ #endif #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" #include "bl702_emac.h" typedef struct emac_device { diff --git a/drivers/bl702_driver/hal_drv/inc/hal_gpio.h b/drivers/bl702_driver/hal_drv/inc/hal_gpio.h index f28e7f4c..9fe07dac 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_gpio.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_gpio.h @@ -28,6 +28,8 @@ extern "C"{ #endif #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" enum gpio_pin_type { GPIO_PIN_0 = 0, diff --git a/drivers/bl702_driver/hal_drv/inc/hal_i2c.h b/drivers/bl702_driver/hal_drv/inc/hal_i2c.h index 87169b77..5892a721 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_i2c.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_i2c.h @@ -28,6 +28,8 @@ extern "C"{ #endif #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" enum i2c_index_type { #ifdef BSP_USING_I2C0 diff --git a/drivers/bl702_driver/hal_drv/inc/hal_i2s.h b/drivers/bl702_driver/hal_drv/inc/hal_i2s.h index 99e540fa..a34c3755 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_i2s.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_i2s.h @@ -28,10 +28,14 @@ extern "C"{ #endif #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" #define DEVICE_CTRL_I2S_GET_TX_FIFO 0x10 #define DEVICE_CTRL_I2S_GET_RX_FIFO 0x11 +#define DEVICE_CTRL_I2S_SET_SAMPL_FREQ 0x12 + enum i2s_index_type { #ifdef BSP_USING_I2S0 I2S0_INDEX, diff --git a/drivers/bl702_driver/hal_drv/inc/hal_keyscan.h b/drivers/bl702_driver/hal_drv/inc/hal_keyscan.h index a9eac01c..75786729 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_keyscan.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_keyscan.h @@ -22,11 +22,14 @@ */ #ifndef __HAL_KEYSCAN__H__ #define __HAL_KEYSCAN__H__ + #ifdef __cplusplus extern "C"{ #endif #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" #define DEVICE_CTRL_KEYSCAN_GET_KEYCODE 0x10 diff --git a/drivers/bl702_driver/hal_drv/inc/hal_mjpeg.h b/drivers/bl702_driver/hal_drv/inc/hal_mjpeg.h index 8de7ddd5..8bb8ccf3 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_mjpeg.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_mjpeg.h @@ -22,11 +22,14 @@ */ #ifndef __HAL_MJPEG__H__ #define __HAL_MJPEG__H__ + #ifdef __cplusplus extern "C"{ #endif #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" #define MJPEG_PACKET_ADD_NONE 0 #define MJPEG_PACKET_ADD_DEFAULT 1 << 0 diff --git a/drivers/bl702_driver/hal_drv/inc/hal_pwm.h b/drivers/bl702_driver/hal_drv/inc/hal_pwm.h index 90cc4463..f89ca00b 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_pwm.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_pwm.h @@ -22,10 +22,14 @@ */ #ifndef __HAL_PWM__H__ #define __HAL_PWM__H__ + #ifdef __cplusplus extern "C"{ #endif + #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" #define DEVICE_CTRL_PWM_FREQUENCE_CONFIG 0x10 #define DEVICE_CTRL_PWM_DUTYCYCLE_CONFIG 0x11 diff --git a/drivers/bl702_driver/hal_drv/inc/hal_qdec.h b/drivers/bl702_driver/hal_drv/inc/hal_qdec.h index 4cdc5c70..9ebe00ea 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_qdec.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_qdec.h @@ -23,10 +23,14 @@ #ifndef __HAL_QDEC__H__ #define __HAL_QDEC__H__ + #ifdef __cplusplus extern "C"{ #endif + #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" #define DEVICE_CTRL_GET_SAMPLE_VAL (0x10) #define DEVICE_CTRL_GET_SAMPLE_DIR (0x11) diff --git a/drivers/bl702_driver/hal_drv/inc/hal_rtc.h b/drivers/bl702_driver/hal_drv/inc/hal_rtc.h index 5498bf1d..feb33b9a 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_rtc.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_rtc.h @@ -22,6 +22,7 @@ */ #ifndef __HAL_RTC__H__ #define __HAL_RTC__H__ + #ifdef __cplusplus extern "C"{ #endif @@ -31,6 +32,7 @@ extern "C"{ void rtc_init(uint64_t sleep_time); void rtc_set_timestamp(uint64_t time_stamp); uint64_t rtc_get_timestamp(void); + #ifdef __cplusplus } #endif diff --git a/drivers/bl702_driver/hal_drv/inc/hal_sec_aes.h b/drivers/bl702_driver/hal_drv/inc/hal_sec_aes.h index cf3c22f0..16830276 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_sec_aes.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_sec_aes.h @@ -22,6 +22,7 @@ */ #ifndef __HAL_SEC_AES__H__ #define __HAL_SEC_AES__H__ + #ifdef __cplusplus extern "C"{ #endif diff --git a/drivers/bl702_driver/hal_drv/inc/hal_sec_dsa.h b/drivers/bl702_driver/hal_drv/inc/hal_sec_dsa.h index a1f07e8c..b08016a6 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_sec_dsa.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_sec_dsa.h @@ -22,6 +22,7 @@ */ #ifndef __HAL_SEC_DSA__H__ #define __HAL_SEC_DSA__H__ + #ifdef __cplusplus extern "C"{ #endif diff --git a/drivers/bl702_driver/hal_drv/inc/hal_sec_ecdsa.h b/drivers/bl702_driver/hal_drv/inc/hal_sec_ecdsa.h index 6aa492cb..10a4abc1 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_sec_ecdsa.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_sec_ecdsa.h @@ -22,6 +22,7 @@ */ #ifndef __HAL_SEC_ECDSA__H__ #define __HAL_SEC_ECDSA__H__ + #ifdef __cplusplus extern "C"{ #endif diff --git a/drivers/bl702_driver/hal_drv/inc/hal_sec_hash.h b/drivers/bl702_driver/hal_drv/inc/hal_sec_hash.h index b68e8c54..a14e00ba 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_sec_hash.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_sec_hash.h @@ -22,11 +22,14 @@ */ #ifndef __HAL_SEC_HASH__H__ #define __HAL_SEC_HASH__H__ + #ifdef __cplusplus extern "C"{ #endif #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" enum sec_hash_index_type { SEC_HASH0_INDEX, diff --git a/drivers/bl702_driver/hal_drv/inc/hal_spi.h b/drivers/bl702_driver/hal_drv/inc/hal_spi.h index da19bed2..3147418a 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_spi.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_spi.h @@ -22,11 +22,14 @@ */ #ifndef __HAL_SPI__H__ #define __HAL_SPI__H__ + #ifdef __cplusplus extern "C"{ #endif #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" #define DEVICE_CTRL_SPI_CONFIG_CLOCK 0x10 diff --git a/drivers/bl702_driver/hal_drv/inc/hal_timer.h b/drivers/bl702_driver/hal_drv/inc/hal_timer.h index 8e1b45ec..fb2f6437 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_timer.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_timer.h @@ -26,7 +26,10 @@ #ifdef __cplusplus extern "C"{ #endif + #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" enum timer_index_type { #ifdef BSP_USING_TIMER0 diff --git a/drivers/bl702_driver/hal_drv/inc/hal_uart.h b/drivers/bl702_driver/hal_drv/inc/hal_uart.h index d1e159b0..06f93f44 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_uart.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_uart.h @@ -22,11 +22,14 @@ */ #ifndef __HAL_UART__H__ #define __HAL_UART__H__ + #ifdef __cplusplus extern "C"{ #endif #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" #define UART_FIFO_LEN 128 diff --git a/drivers/bl702_driver/hal_drv/inc/hal_usb.h b/drivers/bl702_driver/hal_drv/inc/hal_usb.h index 669a3389..fdd1f60f 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_usb.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_usb.h @@ -22,12 +22,15 @@ */ #ifndef __HAL_USB__H__ #define __HAL_USB__H__ + #ifdef __cplusplus extern "C"{ #endif #include "hal_common.h" #include "ring_buffer.h" +#include "drv_device.h" +#include "bl702_config.h" #define DEVICE_CTRL_USB_DC_SET_ACK 0X10 #define DEVICE_CTRL_USB_DC_ENUM_ON 0X11 @@ -125,6 +128,16 @@ enum usb_dc_event_type { /** USB connection resumed by the HOST */ USB_DC_EVENT_RESUME, + /** USB interface selected */ + USB_DC_EVENT_SET_INTERFACE, + /** USB interface selected */ + USB_DC_EVENT_SET_REMOTE_WAKEUP, + /** USB interface selected */ + USB_DC_EVENT_CLEAR_REMOTE_WAKEUP, + /** Set Feature ENDPOINT_HALT received */ + USB_DC_EVENT_SET_HALT, + /** Clear Feature ENDPOINT_HALT received */ + USB_DC_EVENT_CLEAR_HALT, /** setup packet received */ USB_DC_EVENT_SETUP_NOTIFY, /** ep0 in packet received */ diff --git a/drivers/bl702_driver/hal_drv/inc/hal_wdt.h b/drivers/bl702_driver/hal_drv/inc/hal_wdt.h index f744d8b6..0a538e61 100644 --- a/drivers/bl702_driver/hal_drv/inc/hal_wdt.h +++ b/drivers/bl702_driver/hal_drv/inc/hal_wdt.h @@ -22,10 +22,14 @@ */ #ifndef __HAL_WDT__H__ #define __HAL_WDT__H__ + #ifdef __cplusplus extern "C"{ #endif + #include "hal_common.h" +#include "drv_device.h" +#include "bl702_config.h" #define DEVICE_CTRL_GET_WDT_COUNTER (0x10) #define DEVICE_CTRL_RST_WDT_COUNTER (0x11) diff --git a/drivers/bl702_driver/hal_drv/src/hal_common.c b/drivers/bl702_driver/hal_drv/src/hal_common.c index b3f15eda..1ee644d2 100644 --- a/drivers/bl702_driver/hal_drv/src/hal_common.c +++ b/drivers/bl702_driver/hal_drv/src/hal_common.c @@ -62,7 +62,7 @@ void hal_enter_usb_iap(void) { BL_WR_WORD(HBN_BASE + HBN_RSV0_OFFSET, 0x00425355); //"\0BSU" - bflb_platform_delay_ms(1000); + arch_delay_ms(1000); RomDriver_GLB_SW_System_Reset(); } @@ -75,7 +75,8 @@ void ATTR_TCM_SECTION hal_jump2app(uint32_t flash_offset) L1C_Cache_Flush_Ext(); app_main(); } else { - MSG("Illegal app flash offset:%d\r\n", flash_offset); + while(1) + {} } } diff --git a/drivers/bl702_driver/hal_drv/src/hal_emac.c b/drivers/bl702_driver/hal_drv/src/hal_emac.c index 6e7c5a22..be5cce14 100644 --- a/drivers/bl702_driver/hal_drv/src/hal_emac.c +++ b/drivers/bl702_driver/hal_drv/src/hal_emac.c @@ -25,6 +25,10 @@ #include "bl702_glb.h" #include "hal_emac.h" +#ifndef MSG +#define MSG(a,...) +#endif + #define EMAC_USE_INSIDE_CLOCK (0) #define TAG "EMAC_BD: " diff --git a/drivers/bl702_driver/hal_drv/src/hal_flash.c b/drivers/bl702_driver/hal_drv/src/hal_flash.c index fb70f427..ded744c5 100644 --- a/drivers/bl702_driver/hal_drv/src/hal_flash.c +++ b/drivers/bl702_driver/hal_drv/src/hal_flash.c @@ -132,11 +132,13 @@ BL_Err_Type ATTR_TCM_SECTION flash_init(void) g_flash_cfg.ioMode = g_flash_cfg.ioMode & 0x0f; ret = flash_config_init(&g_flash_cfg, (uint8_t *)&jedec_id); +#if 0 MSG("flash ID = %08x\r\n", jedec_id); bflb_platform_dump((uint8_t *)&g_flash_cfg, sizeof(g_flash_cfg)); if (ret != SUCCESS) { MSG("flash config init fail!\r\n"); } +#endif g_flash_cfg.clkDelay = clkDelay; g_flash_cfg.clkInvert = clkInvert; diff --git a/drivers/bl702_driver/hal_drv/src/hal_gpio.c b/drivers/bl702_driver/hal_drv/src/hal_gpio.c index 53cb4dd3..08fee02f 100644 --- a/drivers/bl702_driver/hal_drv/src/hal_gpio.c +++ b/drivers/bl702_driver/hal_drv/src/hal_gpio.c @@ -225,7 +225,7 @@ static void GPIO_IRQ(void) } while ((SET == GLB_Get_GPIO_IntStatus(int_cfg->pin)) && timeOut); if (!timeOut) { - MSG("WARNING: Clear GPIO interrupt status fail.\r\n"); + //MSG("WARNING: Clear GPIO interrupt status fail.\r\n"); } GLB_GPIO_IntClear(int_cfg->pin, RESET); diff --git a/drivers/bl702_driver/hal_drv/src/hal_i2s.c b/drivers/bl702_driver/hal_drv/src/hal_i2s.c index 3e2b17f0..759a22a4 100644 --- a/drivers/bl702_driver/hal_drv/src/hal_i2s.c +++ b/drivers/bl702_driver/hal_drv/src/hal_i2s.c @@ -21,6 +21,7 @@ * */ #include "hal_i2s.h" +#include "hal_clock.h" #include "hal_dma.h" #include "bl702_i2s.h" #include "bl702_glb.h" @@ -38,40 +39,7 @@ int i2s_open(struct device *dev, uint16_t oflag) I2S_CFG_Type i2sCfg = { 0 }; I2S_FifoCfg_Type fifoCfg = { 0 }; - GLB_Set_Chip_Out_0_CLK_Sel(GLB_CHIP_CLK_OUT_I2S_REF_CLK); - GLB_Set_I2S_CLK(ENABLE, GLB_I2S_OUT_REF_CLK_NONE); - - /*Finding the right frequency*/ - if (12288000 % (i2s_device->sampl_freq_hz) == 0) { - i2sCfg.audioFreqHz = 12288000; - PDS_Set_Audio_PLL_Freq(AUDIO_PLL_12288000_HZ); - } else if (11289600 % (i2s_device->sampl_freq_hz) == 0) { - i2sCfg.audioFreqHz = 11289600; - PDS_Set_Audio_PLL_Freq(AUDIO_PLL_11289600_HZ); - } else if (5644800 % (i2s_device->sampl_freq_hz) == 0) { - i2sCfg.audioFreqHz = 5644800; - PDS_Set_Audio_PLL_Freq(AUDIO_PLL_5644800_HZ); - } else { - switch (I2S_ADUIO_PLL_DEFAULT) { - case AUDIO_PLL_12288000_HZ: - i2sCfg.audioFreqHz = 12288000; - break; - - case AUDIO_PLL_11289600_HZ: - i2sCfg.audioFreqHz = 11289600; - break; - - case AUDIO_PLL_5644800_HZ: - i2sCfg.audioFreqHz = 5644800; - break; - - default: - return ERROR; - break; - } - - PDS_Set_Audio_PLL_Freq(I2S_ADUIO_PLL_DEFAULT); - } + i2sCfg.audioFreqHz = system_clock_get(SYSTEM_CLOCK_AUPLL); i2sCfg.sampleFreqHz = i2s_device->sampl_freq_hz; @@ -242,6 +210,8 @@ int i2s_control(struct device *dev, int cmd, void *args) { i2s_device_t *i2s_device = (i2s_device_t *)dev; + I2S_CFG_Type i2sCfg; + switch (cmd) { case DEVICE_CTRL_SET_INT: for (uint16_t i = 0, j = 1; i < 8; i++, j <<= 1) { @@ -291,6 +261,32 @@ int i2s_control(struct device *dev, int cmd, void *args) case DEVICE_CTRL_I2S_GET_RX_FIFO: return I2S_GetRxFIFO_AvlCnt(); + case DEVICE_CTRL_I2S_SET_SAMPL_FREQ: + switch (i2s_device->frame_size) { + case I2S_FRAME_LEN_8: + i2sCfg.frameSize = I2S_SIZE_FRAME_8; + break; + + case I2S_FRAME_LEN_16: + i2sCfg.frameSize = I2S_SIZE_FRAME_16; + break; + + case I2S_FRAME_LEN_24: + i2sCfg.frameSize = I2S_SIZE_FRAME_24; + break; + + case I2S_FRAME_LEN_32: + i2sCfg.frameSize = I2S_SIZE_FRAME_32; + break; + default: + return ERROR; + break; + } + i2sCfg.audioFreqHz = system_clock_get(SYSTEM_CLOCK_AUPLL); + i2sCfg.sampleFreqHz = (uint32_t)args; + I2S_SetBclkPeriod(&i2sCfg); + break; + default: return ERROR; break; diff --git a/drivers/bl702_driver/hal_drv/src/hal_sec_ecdsa.c b/drivers/bl702_driver/hal_drv/src/hal_sec_ecdsa.c index 196c1229..d80b8ec2 100644 --- a/drivers/bl702_driver/hal_drv/src/hal_sec_ecdsa.c +++ b/drivers/bl702_driver/hal_drv/src/hal_sec_ecdsa.c @@ -449,7 +449,7 @@ static int sec_ecdsa_verify_point_mul(uint8_t id, const uint32_t *m) #endif } else if (pka_p1_eq_inf == 0 && pka_p2_eq_inf == 1) { //sum = X1 - MSG("sum = X1\r\n"); + //MSG("sum = X1\r\n"); } else if (pka_p1_eq_inf == 0 && pka_p2_eq_inf == 0) { //sum = X1 + X2 sec_ecdsa_point_add(id); @@ -458,7 +458,7 @@ static int sec_ecdsa_verify_point_mul(uint8_t id, const uint32_t *m) sec_ecdsa_dump_temp_result(); #endif } else { - MSG("Error! infinite point + infinite point\r\n"); + //MSG("Error! infinite point + infinite point\r\n"); return -1; } } diff --git a/drivers/bl702_driver/hal_drv/src/hal_wdt.c b/drivers/bl702_driver/hal_drv/src/hal_wdt.c index 94e6899a..8b9ace43 100644 --- a/drivers/bl702_driver/hal_drv/src/hal_wdt.c +++ b/drivers/bl702_driver/hal_drv/src/hal_wdt.c @@ -124,7 +124,6 @@ int wdt_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t siz uint16_t wdt_timeout = (uint16_t)(uint32_t)buffer; WDT_Disable(); - MSG("wdt timeout %d \r\n", wdt_timeout); WDT_SetCompValue(wdt_timeout); WDT_Enable(); diff --git a/drivers/bl702_driver/startup/interrupt.c b/drivers/bl702_driver/startup/interrupt.c index 5b5acb41..668ab92c 100644 --- a/drivers/bl702_driver/startup/interrupt.c +++ b/drivers/bl702_driver/startup/interrupt.c @@ -21,7 +21,7 @@ * */ #include "bl702_common.h" -#include "bl702.h" +#include "bflb_platform.h" pFunc __Interrupt_Handlers[IRQn_LAST] = { 0 }; diff --git a/drivers/bl702_driver/startup/system_bl702.c b/drivers/bl702_driver/startup/system_bl702.c index 7f0547c5..d2d2568c 100644 --- a/drivers/bl702_driver/startup/system_bl702.c +++ b/drivers/bl702_driver/startup/system_bl702.c @@ -135,12 +135,9 @@ void SystemInit(void) } /*identify flash config automaticly*/ extern BL_Err_Type flash_init(void); -extern void bflb_platform_print_set(uint8_t disable); void System_Post_Init(void) { PDS_Trim_RC32M(); HBN_Trim_RC32K(); - bflb_platform_print_set(1); flash_init(); - bflb_platform_print_set(0); } \ No newline at end of file diff --git a/drivers/bl702_driver/std_drv/inc/bl702_aon.h b/drivers/bl702_driver/std_drv/inc/bl702_aon.h index 18b6b786..0c2ef2f2 100644 --- a/drivers/bl702_driver/std_drv/inc/bl702_aon.h +++ b/drivers/bl702_driver/std_drv/inc/bl702_aon.h @@ -1,107 +1,112 @@ -/** - ****************************************************************************** - * @file bl702_aon.h - * @version V1.0 - * @date - * @brief This file is the standard driver header file - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2020 Bouffalo Lab

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of Bouffalo Lab nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -#ifndef __BL702_AON_H__ -#define __BL702_AON_H__ - -#include "aon_reg.h" -#include "glb_reg.h" -#include "hbn_reg.h" -#include "pds_reg.h" -#include "bl702_ef_ctrl.h" -#include "bl702_common.h" - -/** @addtogroup BL702_Peripheral_Driver - * @{ - */ - -/** @addtogroup AON - * @{ - */ - -/** @defgroup AON_Public_Types - * @{ - */ - -/*@} end of group AON_Public_Types */ - -/** @defgroup AON_Public_Constants - * @{ - */ - -/*@} end of group AON_Public_Constants */ - -/** @defgroup AON_Public_Macros - * @{ - */ - -/*@} end of group AON_Public_Macros */ - -/** @defgroup AON_Public_Functions - * @{ - */ -/*----------*/ -BL_Err_Type AON_Power_On_MBG(void); -BL_Err_Type AON_Power_Off_MBG(void); -/*----------*/ -BL_Err_Type AON_Power_On_XTAL(void); -BL_Err_Type AON_Set_Xtal_CapCode(uint8_t capIn, uint8_t capOut); -uint8_t AON_Get_Xtal_CapCode(void); -BL_Err_Type AON_Power_Off_XTAL(void); -/*----------*/ -BL_Err_Type AON_Power_On_BG(void); -BL_Err_Type AON_Power_Off_BG(void); -/*----------*/ -BL_Err_Type AON_Power_On_LDO11_SOC(void); -BL_Err_Type AON_Power_Off_LDO11_SOC(void); -/*----------*/ -BL_Err_Type AON_Power_On_LDO15_RF(void); -BL_Err_Type AON_Power_Off_LDO15_RF(void); -/*----------*/ -BL_Err_Type AON_Power_On_SFReg(void); -BL_Err_Type AON_Power_Off_SFReg(void); -/*----------*/ -BL_Err_Type AON_LowPower_Enter_PDS0(void); -BL_Err_Type AON_LowPower_Exit_PDS0(void); -/*----------*/ -BL_Err_Type AON_Set_LDO11_SOC_Sstart_Delay(uint8_t delay); - -/*@} end of group AON_Public_Functions */ - -/*@} end of group AON */ - -/*@} end of group BL702_Peripheral_Driver */ - -#endif /* __BL702_AON_H__ */ +/** + ****************************************************************************** + * @file bl702_aon.h + * @version V1.0 + * @date + * @brief This file is the standard driver header file + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2020 Bouffalo Lab

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of Bouffalo Lab nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +#ifndef __BL702_AON_H__ +#define __BL702_AON_H__ + +#include "aon_reg.h" +#include "glb_reg.h" +#include "hbn_reg.h" +#include "pds_reg.h" +#include "bl702_ef_ctrl.h" +#include "bl702_common.h" + +/** @addtogroup BL702_Peripheral_Driver + * @{ + */ + +/** @addtogroup AON + * @{ + */ + +/** @defgroup AON_Public_Types + * @{ + */ + +/*@} end of group AON_Public_Types */ + +/** @defgroup AON_Public_Constants + * @{ + */ + +/*@} end of group AON_Public_Constants */ + +/** @defgroup AON_Public_Macros + * @{ + */ + +/*@} end of group AON_Public_Macros */ + +/** @defgroup AON_Public_Functions + * @{ + */ +/*----------*/ +BL_Err_Type AON_Power_On_MBG(void); +BL_Err_Type AON_Power_Off_MBG(void); +/*----------*/ +BL_Err_Type AON_Power_On_XTAL(void); +BL_Err_Type AON_Set_Xtal_CapCode(uint8_t capIn, uint8_t capOut); +uint8_t AON_Get_Xtal_CapCode(void); +BL_Err_Type AON_Set_Xtal_CapCode_Extra(uint8_t extra); +BL_Err_Type AON_Power_Off_XTAL(void); +/*----------*/ +BL_Err_Type AON_Power_On_BG(void); +BL_Err_Type AON_Power_Off_BG(void); +/*----------*/ +BL_Err_Type AON_Power_On_LDO11_SOC(void); +BL_Err_Type AON_Power_Off_LDO11_SOC(void); +/*----------*/ +BL_Err_Type AON_Power_On_LDO15_RF(void); +BL_Err_Type AON_Power_Off_LDO15_RF(void); +/*----------*/ +BL_Err_Type AON_Power_On_SFReg(void); +BL_Err_Type AON_Power_Off_SFReg(void); +/*----------*/ +BL_Err_Type AON_LowPower_Enter_PDS0(void); +BL_Err_Type AON_LowPower_Exit_PDS0(void); +/*----------*/ +BL_Err_Type AON_Set_LDO11_SOC_Sstart_Delay(uint8_t delay); +/*----------*/ +BL_Err_Type AON_Set_DCDC18_Top_0(uint8_t voutSel, uint8_t vpfm); +BL_Err_Type AON_Set_Xtal_Cfg(uint8_t gmBoost, uint8_t ampCtrl, uint8_t fastStartup); +/*----------*/ + +/*@} end of group AON_Public_Functions */ + +/*@} end of group AON */ + +/*@} end of group BL702_Peripheral_Driver */ + +#endif /* __BL702_AON_H__ */ diff --git a/drivers/bl702_driver/std_drv/inc/bl702_common.h b/drivers/bl702_driver/std_drv/inc/bl702_common.h index 80a17ec9..a0944ca0 100644 --- a/drivers/bl702_driver/std_drv/inc/bl702_common.h +++ b/drivers/bl702_driver/std_drv/inc/bl702_common.h @@ -2,7 +2,7 @@ #define __BL702_COMMON_H__ #include "bl702.h" -#include "bflb_platform.h" +#include "misc.h" #ifndef __NOP #define __NOP() __ASM volatile("nop") /* This implementation generates debug information */ @@ -57,6 +57,32 @@ __ALWAYS_STATIC_INLINE void __disable_irq(void) __ASM volatile("csrc mstatus, 8"); } +/** @defgroup COMMON_Public_Constants + * @{ + */ + +/** @defgroup DRIVER_INT_PERIPH + * @{ + */ +#define IS_INT_PERIPH(INT_PERIPH) ((INT_PERIPH) < IRQn_LAST) + +/*@} end of group DRIVER_INT_PERIPH */ + +/** @defgroup DRIVER_INT_MASK + * @{ + */ +#define IS_BL_MASK_TYPE(type) (((type) == MASK) || ((type) == UNMASK)) + +/*@} end of group COMMON_Public_Constants */ + +/*@} end of group DRIVER_Public_Macro */ +#define BL702_MemCpy arch_memcpy +#define BL702_MemSet arch_memset +#define BL702_MemCmp arch_memcmp +#define BL702_MemCpy4 arch_memcpy4 +#define BL702_MemCpy_Fast arch_memcpy_fast +#define BL702_MemSet4 arch_memset4 + #define arch_delay_us BL702_Delay_US #define arch_delay_ms BL702_Delay_MS diff --git a/drivers/bl702_driver/std_drv/inc/bl702_it.h b/drivers/bl702_driver/std_drv/inc/bl702_it.h deleted file mode 100644 index ab6f23c1..00000000 --- a/drivers/bl702_driver/std_drv/inc/bl702_it.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef __BL702_IT_H__ -#define __BL702_IT_H__ - -#include "bl702.h" -#include "bl_common.h" - -/** @addtogroup BL606_Peripheral_Driver - * @{ - */ - -/** @addtogroup COMMON - * @{ - */ - -/** @defgroup COMMON_Public_Types - * @{ - */ - -/*@} end of group COMMON_Public_Types */ - -/** @defgroup COMMON_Public_Constants - * @{ - */ - -/** @defgroup DRIVER_INT_PERIPH - * @{ - */ -#define IS_INT_PERIPH(INT_PERIPH) ((INT_PERIPH) < IRQn_LAST) - -/*@} end of group DRIVER_INT_PERIPH */ - -/** @defgroup DRIVER_INT_MASK - * @{ - */ -#define IS_BL_MASK_TYPE(type) (((type) == MASK) || ((type) == UNMASK)) - -/*@} end of group COMMON_Public_Constants */ - -/*@} end of group DRIVER_Public_Macro */ - -/** @defgroup DRIVER_Public_FunctionDeclaration - * @brief DRIVER functions declaration - * @{ - */ -void Interrupt_Handler_Register(IRQn_Type irq, pFunc interruptFun); - -/*@} end of group DRIVER_COMMON */ - -#endif /* __BL602_COMMON_H__ */ diff --git a/drivers/bl702_driver/std_drv/src/bl702_aon.c b/drivers/bl702_driver/std_drv/src/bl702_aon.c index 1af242c4..d1664558 100644 --- a/drivers/bl702_driver/std_drv/src/bl702_aon.c +++ b/drivers/bl702_driver/std_drv/src/bl702_aon.c @@ -1,518 +1,582 @@ -/** - ****************************************************************************** - * @file bl702_aon.c - * @version V1.0 - * @date - * @brief This file is the standard driver c file - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2020 Bouffalo Lab

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of Bouffalo Lab nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -#include "bl702_aon.h" - -/** @addtogroup BL702_Peripheral_Driver - * @{ - */ - -/** @addtogroup AON - * @{ - */ - -/** @defgroup AON_Private_Macros - * @{ - */ -#define AON_CLK_SET_DUMMY_WAIT \ - { \ - __NOP(); \ - __NOP(); \ - __NOP(); \ - __NOP(); \ - __NOP(); \ - __NOP(); \ - __NOP(); \ - __NOP(); \ - } - -/*@} end of group AON_Private_Macros */ - -/** @defgroup AON_Private_Types - * @{ - */ - -/*@} end of group AON_Private_Types */ - -/** @defgroup AON_Private_Variables - * @{ - */ - -/*@} end of group AON_Private_Variables */ - -/** @defgroup AON_Global_Variables - * @{ - */ - -/*@} end of group AON_Global_Variables */ - -/** @defgroup AON_Private_Fun_Declaration - * @{ - */ - -/*@} end of group AON_Private_Fun_Declaration */ - -/** @defgroup AON_Private_Functions - * @{ - */ - -/*@} end of group AON_Private_Functions */ - -/** @defgroup AON_Public_Functions - * @{ - */ - -/****************************************************************************/ /** - * @brief Power on MXX band gap - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -#ifndef BFLB_USE_ROM_DRIVER -__WEAK -BL_Err_Type ATTR_CLOCK_SECTION AON_Power_On_MBG(void) -{ - uint32_t tmpVal = 0; - - /* Power up RF for PLL to work */ - tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); - tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_MBG_AON); - BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); - - BL702_Delay_US(55); - - return SUCCESS; -} -#endif - -/****************************************************************************/ /** - * @brief Power off MXX band gap - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -#ifndef BFLB_USE_ROM_DRIVER -__WEAK -BL_Err_Type ATTR_CLOCK_SECTION AON_Power_Off_MBG(void) -{ - uint32_t tmpVal = 0; - - /* Power OFF */ - tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); - tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_MBG_AON); - BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); - - return SUCCESS; -} -#endif - -/****************************************************************************/ /** - * @brief Power on XTAL - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -#ifndef BFLB_USE_ROM_DRIVER -__WEAK -BL_Err_Type ATTR_CLOCK_SECTION AON_Power_On_XTAL(void) -{ - uint32_t tmpVal = 0; - uint32_t timeOut = 0; - - tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); - tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_XTAL_AON); - tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_XTAL_BUF_AON); - BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); - - /* Polling for ready */ - do { - BL702_Delay_US(10); - timeOut++; - tmpVal = BL_RD_REG(AON_BASE, AON_TSEN); - } while (!BL_IS_REG_BIT_SET(tmpVal, AON_XTAL_RDY) && timeOut < 120); - - if (timeOut >= 120) { - return TIMEOUT; - } - - return SUCCESS; -} -#endif - -/****************************************************************************/ /** - * @brief Set XTAL cap code - * - * @param capIn: Cap code in - * @param capOut: Cap code out - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -#ifndef BFLB_USE_ROM_DRIVER -__WEAK -BL_Err_Type ATTR_CLOCK_SECTION AON_Set_Xtal_CapCode(uint8_t capIn, uint8_t capOut) -{ - uint32_t tmpVal = 0; - - tmpVal = BL_RD_REG(AON_BASE, AON_XTAL_CFG); - tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_XTAL_CAPCODE_IN_AON, capIn); - tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_XTAL_CAPCODE_OUT_AON, capOut); - BL_WR_REG(AON_BASE, AON_XTAL_CFG, tmpVal); - - BL702_Delay_US(100); - - return SUCCESS; -} -#endif - -/****************************************************************************/ /** - * @brief Get XTAL cap code - * - * @param None - * - * @return Cap code - * -*******************************************************************************/ -uint8_t ATTR_CLOCK_SECTION AON_Get_Xtal_CapCode(void) -{ - uint32_t tmpVal = 0; - - tmpVal = BL_RD_REG(AON_BASE, AON_XTAL_CFG); - - return BL_GET_REG_BITS_VAL(tmpVal, AON_XTAL_CAPCODE_IN_AON); -} - -/****************************************************************************/ /** - * @brief Power off XTAL - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -#ifndef BFLB_USE_ROM_DRIVER -__WEAK -BL_Err_Type ATTR_CLOCK_SECTION AON_Power_Off_XTAL(void) -{ - uint32_t tmpVal = 0; - - tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); - tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_XTAL_AON); - tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_XTAL_BUF_AON); - BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); - - return SUCCESS; -} -#endif - -/****************************************************************************/ /** - * @brief Power on bandgap system - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -BL_Err_Type ATTR_TCM_SECTION AON_Power_On_BG(void) -{ - uint32_t tmpVal = 0; - - /* power up RF for PLL to work */ - tmpVal = BL_RD_REG(AON_BASE, AON_BG_SYS_TOP); - tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_BG_SYS_AON); - BL_WR_REG(AON_BASE, AON_BG_SYS_TOP, tmpVal); - - BL702_Delay_US(55); - - return SUCCESS; -} - -/****************************************************************************/ /** - * @brief Power off bandgap system - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -BL_Err_Type ATTR_TCM_SECTION AON_Power_Off_BG(void) -{ - uint32_t tmpVal = 0; - - /* power up RF for PLL to work */ - tmpVal = BL_RD_REG(AON_BASE, AON_BG_SYS_TOP); - tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_BG_SYS_AON); - BL_WR_REG(AON_BASE, AON_BG_SYS_TOP, tmpVal); - - BL702_Delay_US(55); - - return SUCCESS; -} - -/****************************************************************************/ /** - * @brief Power on LDO11 - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -BL_Err_Type ATTR_TCM_SECTION AON_Power_On_LDO11_SOC(void) -{ - uint32_t tmpVal = 0; - - tmpVal = BL_RD_REG(AON_BASE, AON_LDO11SOC_AND_DCTEST); - tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_LDO11SOC_AON); - BL_WR_REG(AON_BASE, AON_LDO11SOC_AND_DCTEST, tmpVal); - - BL702_Delay_US(55); - - return SUCCESS; -} - -/****************************************************************************/ /** - * @brief Power off LDO11 - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -BL_Err_Type ATTR_TCM_SECTION AON_Power_Off_LDO11_SOC(void) -{ - uint32_t tmpVal = 0; - - tmpVal = BL_RD_REG(AON_BASE, AON_LDO11SOC_AND_DCTEST); - tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_LDO11SOC_AON); - BL_WR_REG(AON_BASE, AON_LDO11SOC_AND_DCTEST, tmpVal); - - BL702_Delay_US(55); - - return SUCCESS; -} - -/****************************************************************************/ /** - * @brief Power on LDO15_RF - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -BL_Err_Type ATTR_TCM_SECTION AON_Power_On_LDO15_RF(void) -{ - uint32_t tmpVal = 0; - - /* ldo15rf power on */ - tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); - tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_LDO15RF_AON); - BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); - - BL702_Delay_US(90); - - return SUCCESS; -} - -/****************************************************************************/ /** - * @brief Power off LDO15_RF - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -BL_Err_Type ATTR_TCM_SECTION AON_Power_Off_LDO15_RF(void) -{ - uint32_t tmpVal = 0; - - /* ldo15rf power off */ - tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); - tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_LDO15RF_AON); - BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); - - return SUCCESS; -} - -/****************************************************************************/ /** - * @brief power on source follow regular - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -BL_Err_Type ATTR_TCM_SECTION AON_Power_On_SFReg(void) -{ - uint32_t tmpVal = 0; - - /* power on sfreg */ - tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); - tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_SFREG_AON); - BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); - - BL702_Delay_US(10); - - return SUCCESS; -} - -/****************************************************************************/ /** - * @brief power off source follow regular - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -BL_Err_Type ATTR_TCM_SECTION AON_Power_Off_SFReg(void) -{ - uint32_t tmpVal = 0; - - /* power off sfreg */ - tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); - tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_SFREG_AON); - BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); - - return SUCCESS; -} - -/****************************************************************************/ /** - * @brief Power off the power can be shut down in PDS0 - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -BL_Err_Type ATTR_TCM_SECTION AON_LowPower_Enter_PDS0(void) -{ - uint32_t tmpVal = 0; - - /* power off bz */ - tmpVal = BL_RD_REG(AON_BASE, AON_MISC); - tmpVal = BL_CLR_REG_BIT(tmpVal, AON_SW_BZ_EN_AON); - BL_WR_REG(AON_BASE, AON_MISC, tmpVal); - - tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); - tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_SFREG_AON); - tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_LDO15RF_AON); - tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_MBG_AON); - BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); - - /* gating Clock, no more use */ - //tmpVal=BL_RD_REG(GLB_BASE,GLB_CGEN_CFG0); - //tmpVal=tmpVal&(~(1<<6)); - //tmpVal=tmpVal&(~(1<<7)); - //BL_WR_REG(GLB_BASE,GLB_CGEN_CFG0,tmpVal); - - return SUCCESS; -} - -/****************************************************************************/ /** - * @brief Power on the power powered down in PDS0 - * - * @param None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -BL_Err_Type ATTR_TCM_SECTION AON_LowPower_Exit_PDS0(void) -{ - uint32_t tmpVal = 0; - - tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); - - tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_MBG_AON); - BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); - - BL702_Delay_US(20); - - tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_LDO15RF_AON); - BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); - - BL702_Delay_US(60); - - tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_SFREG_AON); - BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); - - BL702_Delay_US(20); - - /* power on bz */ - tmpVal = BL_RD_REG(AON_BASE, AON_MISC); - tmpVal = BL_SET_REG_BIT(tmpVal, AON_SW_BZ_EN_AON); - BL_WR_REG(AON_BASE, AON_MISC, tmpVal); - - /* ungating Clock, no more use */ - //tmpVal=BL_RD_REG(GLB_BASE,GLB_CGEN_CFG0); - //tmpVal=tmpVal|((1<<6)); - //tmpVal=tmpVal|((1<<7)); - //BL_WR_REG(GLB_BASE,GLB_CGEN_CFG0,tmpVal); - - return SUCCESS; -} - -/****************************************************************************/ /** - * @brief Power on the power powered down in PDS0 - * - * @param delay: None - * - * @return SUCCESS or ERROR - * -*******************************************************************************/ -BL_Err_Type ATTR_TCM_SECTION AON_Set_LDO11_SOC_Sstart_Delay(uint8_t delay) -{ - uint32_t tmpVal = 0; - - CHECK_PARAM((delay <= 0x3)); - - /* config ldo11soc_sstart_delay_aon */ - tmpVal = BL_RD_REG(AON_BASE, AON_LDO11SOC_AND_DCTEST); - tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_LDO11SOC_SSTART_DELAY_AON, delay); - BL_WR_REG(AON_BASE, AON_LDO11SOC_AND_DCTEST, tmpVal); - - return SUCCESS; -} - -/*@} end of group AON_Public_Functions */ - -/*@} end of group AON */ - -/*@} end of group BL702_Peripheral_Driver */ +/** + ****************************************************************************** + * @file bl702_aon.c + * @version V1.0 + * @date + * @brief This file is the standard driver c file + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2020 Bouffalo Lab

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of Bouffalo Lab nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +#include "bl702_aon.h" + +/** @addtogroup BL702_Peripheral_Driver + * @{ + */ + +/** @addtogroup AON + * @{ + */ + +/** @defgroup AON_Private_Macros + * @{ + */ +#define AON_CLK_SET_DUMMY_WAIT \ + { \ + __NOP(); \ + __NOP(); \ + __NOP(); \ + __NOP(); \ + __NOP(); \ + __NOP(); \ + __NOP(); \ + __NOP(); \ + } + +/*@} end of group AON_Private_Macros */ + +/** @defgroup AON_Private_Types + * @{ + */ + +/*@} end of group AON_Private_Types */ + +/** @defgroup AON_Private_Variables + * @{ + */ + +/*@} end of group AON_Private_Variables */ + +/** @defgroup AON_Global_Variables + * @{ + */ + +/*@} end of group AON_Global_Variables */ + +/** @defgroup AON_Private_Fun_Declaration + * @{ + */ + +/*@} end of group AON_Private_Fun_Declaration */ + +/** @defgroup AON_Private_Functions + * @{ + */ + +/*@} end of group AON_Private_Functions */ + +/** @defgroup AON_Public_Functions + * @{ + */ + +/****************************************************************************/ /** + * @brief Power on MXX band gap + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +#ifndef BFLB_USE_ROM_DRIVER +__WEAK BL_Err_Type ATTR_CLOCK_SECTION AON_Power_On_MBG(void) +{ + uint32_t tmpVal = 0; + + /* Power up RF for PLL to work */ + tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); + tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_MBG_AON); + BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); + + BL702_Delay_US(55); + + return SUCCESS; +} +#endif + +/****************************************************************************/ /** + * @brief Power off MXX band gap + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +#ifndef BFLB_USE_ROM_DRIVER +__WEAK BL_Err_Type ATTR_CLOCK_SECTION AON_Power_Off_MBG(void) +{ + uint32_t tmpVal = 0; + + /* Power OFF */ + tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); + tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_MBG_AON); + BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); + + return SUCCESS; +} +#endif + +/****************************************************************************/ /** + * @brief Power on XTAL + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +#ifndef BFLB_USE_ROM_DRIVER +__WEAK BL_Err_Type ATTR_CLOCK_SECTION AON_Power_On_XTAL(void) +{ + uint32_t tmpVal = 0; + uint32_t timeOut = 0; + + tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); + tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_XTAL_AON); + tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_XTAL_BUF_AON); + BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); + + /* Polling for ready */ + do { + BL702_Delay_US(10); + timeOut++; + tmpVal = BL_RD_REG(AON_BASE, AON_TSEN); + } while (!BL_IS_REG_BIT_SET(tmpVal, AON_XTAL_RDY) && timeOut < 120); + + if (timeOut >= 120) { + return TIMEOUT; + } + + return SUCCESS; +} +#endif + +/****************************************************************************/ /** + * @brief Set XTAL cap code + * + * @param capIn: Cap code in + * @param capOut: Cap code out + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +#ifndef BFLB_USE_ROM_DRIVER +__WEAK BL_Err_Type ATTR_CLOCK_SECTION AON_Set_Xtal_CapCode(uint8_t capIn, uint8_t capOut) +{ + uint32_t tmpVal = 0; + + tmpVal = BL_RD_REG(AON_BASE, AON_XTAL_CFG); + tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_XTAL_CAPCODE_IN_AON, capIn); + tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_XTAL_CAPCODE_OUT_AON, capOut); + BL_WR_REG(AON_BASE, AON_XTAL_CFG, tmpVal); + + BL702_Delay_US(100); + + return SUCCESS; +} +#endif + +/****************************************************************************/ /** + * @brief Get XTAL cap code + * + * @param None + * + * @return Cap code + * +*******************************************************************************/ +uint8_t ATTR_CLOCK_SECTION AON_Get_Xtal_CapCode(void) +{ + uint32_t tmpVal = 0; + + tmpVal = BL_RD_REG(AON_BASE, AON_XTAL_CFG); + + return BL_GET_REG_BITS_VAL(tmpVal, AON_XTAL_CAPCODE_IN_AON); +} + +/****************************************************************************/ /** + * @brief Set XTAL cap code + * + * @param extra: cap cpde extra aon + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +BL_Err_Type ATTR_CLOCK_SECTION AON_Set_Xtal_CapCode_Extra(uint8_t extra) +{ + uint32_t tmpVal = 0; + + tmpVal = BL_RD_REG(AON_BASE, AON_XTAL_CFG); + if (extra) { + tmpVal = BL_SET_REG_BIT(tmpVal, AON_XTAL_CAPCODE_EXTRA_AON); + } else { + tmpVal = BL_CLR_REG_BIT(tmpVal, AON_XTAL_CAPCODE_EXTRA_AON); + } + BL_WR_REG(AON_BASE, AON_XTAL_CFG, tmpVal); + + return SUCCESS; +} + +/****************************************************************************/ /** + * @brief Power off XTAL + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +#ifndef BFLB_USE_ROM_DRIVER +__WEAK BL_Err_Type ATTR_CLOCK_SECTION AON_Power_Off_XTAL(void) +{ + uint32_t tmpVal = 0; + + tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); + tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_XTAL_AON); + tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_XTAL_BUF_AON); + BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); + + return SUCCESS; +} +#endif + +/****************************************************************************/ /** + * @brief Power on bandgap system + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +BL_Err_Type ATTR_TCM_SECTION AON_Power_On_BG(void) +{ + uint32_t tmpVal = 0; + + /* power up RF for PLL to work */ + tmpVal = BL_RD_REG(AON_BASE, AON_BG_SYS_TOP); + tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_BG_SYS_AON); + BL_WR_REG(AON_BASE, AON_BG_SYS_TOP, tmpVal); + + BL702_Delay_US(55); + + return SUCCESS; +} + +/****************************************************************************/ /** + * @brief Power off bandgap system + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +BL_Err_Type ATTR_TCM_SECTION AON_Power_Off_BG(void) +{ + uint32_t tmpVal = 0; + + /* power up RF for PLL to work */ + tmpVal = BL_RD_REG(AON_BASE, AON_BG_SYS_TOP); + tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_BG_SYS_AON); + BL_WR_REG(AON_BASE, AON_BG_SYS_TOP, tmpVal); + + BL702_Delay_US(55); + + return SUCCESS; +} + +/****************************************************************************/ /** + * @brief Power on LDO11 + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +BL_Err_Type ATTR_TCM_SECTION AON_Power_On_LDO11_SOC(void) +{ + uint32_t tmpVal = 0; + + tmpVal = BL_RD_REG(AON_BASE, AON_LDO11SOC_AND_DCTEST); + tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_LDO11SOC_AON); + BL_WR_REG(AON_BASE, AON_LDO11SOC_AND_DCTEST, tmpVal); + + BL702_Delay_US(55); + + return SUCCESS; +} + +/****************************************************************************/ /** + * @brief Power off LDO11 + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +BL_Err_Type ATTR_TCM_SECTION AON_Power_Off_LDO11_SOC(void) +{ + uint32_t tmpVal = 0; + + tmpVal = BL_RD_REG(AON_BASE, AON_LDO11SOC_AND_DCTEST); + tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_LDO11SOC_AON); + BL_WR_REG(AON_BASE, AON_LDO11SOC_AND_DCTEST, tmpVal); + + BL702_Delay_US(55); + + return SUCCESS; +} + +/****************************************************************************/ /** + * @brief Power on LDO15_RF + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +BL_Err_Type ATTR_TCM_SECTION AON_Power_On_LDO15_RF(void) +{ + uint32_t tmpVal = 0; + + /* ldo15rf power on */ + tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); + tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_LDO15RF_AON); + BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); + + BL702_Delay_US(90); + + return SUCCESS; +} + +/****************************************************************************/ /** + * @brief Power off LDO15_RF + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +BL_Err_Type ATTR_TCM_SECTION AON_Power_Off_LDO15_RF(void) +{ + uint32_t tmpVal = 0; + + /* ldo15rf power off */ + tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); + tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_LDO15RF_AON); + BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); + + return SUCCESS; +} + +/****************************************************************************/ /** + * @brief power on source follow regular + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +BL_Err_Type ATTR_TCM_SECTION AON_Power_On_SFReg(void) +{ + uint32_t tmpVal = 0; + + /* power on sfreg */ + tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); + tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_SFREG_AON); + BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); + + BL702_Delay_US(10); + + return SUCCESS; +} + +/****************************************************************************/ /** + * @brief power off source follow regular + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +BL_Err_Type ATTR_TCM_SECTION AON_Power_Off_SFReg(void) +{ + uint32_t tmpVal = 0; + + /* power off sfreg */ + tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); + tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_SFREG_AON); + BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); + + return SUCCESS; +} + +/****************************************************************************/ /** + * @brief Power off the power can be shut down in PDS0 + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +BL_Err_Type ATTR_TCM_SECTION AON_LowPower_Enter_PDS0(void) +{ + uint32_t tmpVal = 0; + + /* power off bz */ + tmpVal = BL_RD_REG(AON_BASE, AON_MISC); + tmpVal = BL_CLR_REG_BIT(tmpVal, AON_SW_BZ_EN_AON); + BL_WR_REG(AON_BASE, AON_MISC, tmpVal); + + tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); + tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_SFREG_AON); + tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_LDO15RF_AON); + tmpVal = BL_CLR_REG_BIT(tmpVal, AON_PU_MBG_AON); + BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); + + /* gating Clock, no more use */ + //tmpVal=BL_RD_REG(GLB_BASE,GLB_CGEN_CFG0); + //tmpVal=tmpVal&(~(1<<6)); + //tmpVal=tmpVal&(~(1<<7)); + //BL_WR_REG(GLB_BASE,GLB_CGEN_CFG0,tmpVal); + + return SUCCESS; +} + +/****************************************************************************/ /** + * @brief Power on the power powered down in PDS0 + * + * @param None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +BL_Err_Type ATTR_TCM_SECTION AON_LowPower_Exit_PDS0(void) +{ + uint32_t tmpVal = 0; + + tmpVal = BL_RD_REG(AON_BASE, AON_RF_TOP_AON); + + tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_MBG_AON); + BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); + + BL702_Delay_US(20); + + tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_LDO15RF_AON); + BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); + + BL702_Delay_US(60); + + tmpVal = BL_SET_REG_BIT(tmpVal, AON_PU_SFREG_AON); + BL_WR_REG(AON_BASE, AON_RF_TOP_AON, tmpVal); + + BL702_Delay_US(20); + + /* power on bz */ + tmpVal = BL_RD_REG(AON_BASE, AON_MISC); + tmpVal = BL_SET_REG_BIT(tmpVal, AON_SW_BZ_EN_AON); + BL_WR_REG(AON_BASE, AON_MISC, tmpVal); + + /* ungating Clock, no more use */ + //tmpVal=BL_RD_REG(GLB_BASE,GLB_CGEN_CFG0); + //tmpVal=tmpVal|((1<<6)); + //tmpVal=tmpVal|((1<<7)); + //BL_WR_REG(GLB_BASE,GLB_CGEN_CFG0,tmpVal); + + return SUCCESS; +} + +/****************************************************************************/ /** + * @brief Power on the power powered down in PDS0 + * + * @param delay: None + * + * @return SUCCESS or ERROR + * +*******************************************************************************/ +BL_Err_Type ATTR_TCM_SECTION AON_Set_LDO11_SOC_Sstart_Delay(uint8_t delay) +{ + uint32_t tmpVal = 0; + + CHECK_PARAM((delay <= 0x3)); + + /* config ldo11soc_sstart_delay_aon */ + tmpVal = BL_RD_REG(AON_BASE, AON_LDO11SOC_AND_DCTEST); + tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_LDO11SOC_SSTART_DELAY_AON, delay); + BL_WR_REG(AON_BASE, AON_LDO11SOC_AND_DCTEST, tmpVal); + + return SUCCESS; +} + +/****************************************************************************/ /** + * @brief + * + * @param + * + * @return + * +*******************************************************************************/ +BL_Err_Type AON_Set_DCDC18_Top_0(uint8_t voutSel, uint8_t vpfm) +{ + uint32_t tmpVal = 0; + + tmpVal = BL_RD_REG(AON_BASE, AON_DCDC18_TOP_0); + //dcdc18_vout_sel_aon, 1.425V*1.05=1.5V + tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_DCDC18_VOUT_SEL_AON, voutSel); + //dcdc18_vpfm_aon + tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_DCDC18_VPFM_AON, vpfm); + BL_WR_REG(AON_BASE, AON_DCDC18_TOP_0, tmpVal); + + return SUCCESS; +} + +/****************************************************************************/ /** + * @brief + * + * @param + * + * @return + * +*******************************************************************************/ +BL_Err_Type AON_Set_Xtal_Cfg(uint8_t gmBoost, uint8_t ampCtrl, uint8_t fastStartup) +{ + uint32_t tmpVal = 0; + + tmpVal = BL_RD_REG(AON_BASE, AON_XTAL_CFG); + //xtal_gm_boost + tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_XTAL_GM_BOOST_AON, gmBoost); + //xtal_amp_ctrl + tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_XTAL_AMP_CTRL_AON, ampCtrl); + //xtal_fast_startup + tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_XTAL_FAST_STARTUP_AON, fastStartup); + BL_WR_REG(AON_BASE, AON_XTAL_CFG, tmpVal); + + return SUCCESS; +} + +/*@} end of group AON_Public_Functions */ + +/*@} end of group AON */ + +/*@} end of group BL702_Peripheral_Driver */ diff --git a/examples/acomp/main.c b/examples/acomp/main.c index 2f354a83..84996640 100644 --- a/examples/acomp/main.c +++ b/examples/acomp/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_pm.h" #include "hal_acomp.h" #include "hal_uart.h" diff --git a/examples/adc/adc_continuous_differential/main.c b/examples/adc/adc_continuous_differential/main.c index f32a1e04..c52c321d 100644 --- a/examples/adc/adc_continuous_differential/main.c +++ b/examples/adc/adc_continuous_differential/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_adc.h" #include "hal_gpio.h" diff --git a/examples/adc/adc_continuous_single_ended/main.c b/examples/adc/adc_continuous_single_ended/main.c index 09ad1ac9..1457c626 100644 --- a/examples/adc/adc_continuous_single_ended/main.c +++ b/examples/adc/adc_continuous_single_ended/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_adc.h" #include "hal_gpio.h" diff --git a/examples/adc/adc_int/main.c b/examples/adc/adc_int/main.c index 2bc45b8f..91f5ded9 100644 --- a/examples/adc/adc_int/main.c +++ b/examples/adc/adc_int/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_adc.h" #include "hal_gpio.h" diff --git a/examples/adc/adc_key/main.c b/examples/adc/adc_key/main.c index 0cfe2039..edb2d288 100644 --- a/examples/adc/adc_key/main.c +++ b/examples/adc/adc_key/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_adc.h" #include "hal_gpio.h" diff --git a/examples/adc/adc_one_shot_differential/main.c b/examples/adc/adc_one_shot_differential/main.c index bf5a3025..f8e16d6a 100644 --- a/examples/adc/adc_one_shot_differential/main.c +++ b/examples/adc/adc_one_shot_differential/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_adc.h" #include "hal_gpio.h" diff --git a/examples/adc/adc_one_shot_single_ended/main.c b/examples/adc/adc_one_shot_single_ended/main.c index b8c98906..379ae875 100644 --- a/examples/adc/adc_one_shot_single_ended/main.c +++ b/examples/adc/adc_one_shot_single_ended/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_adc.h" #include "hal_gpio.h" diff --git a/examples/adc/adc_scan_single_ended/main.c b/examples/adc/adc_scan_single_ended/main.c index c181304d..15103da7 100644 --- a/examples/adc/adc_scan_single_ended/main.c +++ b/examples/adc/adc_scan_single_ended/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_adc.h" #include "hal_gpio.h" diff --git a/examples/adc/adc_tsen/main.c b/examples/adc/adc_tsen/main.c index 11d552d8..0dfd8d6c 100644 --- a/examples/adc/adc_tsen/main.c +++ b/examples/adc/adc_tsen/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_adc.h" #include "hal_gpio.h" diff --git a/examples/adc/adc_vbat_poll/main.c b/examples/adc/adc_vbat_poll/main.c index acc69e2c..fb7b9645 100644 --- a/examples/adc/adc_vbat_poll/main.c +++ b/examples/adc/adc_vbat_poll/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_adc.h" #include "hal_gpio.h" diff --git a/examples/audio_cube/main.c b/examples/audio_cube/main.c index 099897e3..93f83dbf 100644 --- a/examples/audio_cube/main.c +++ b/examples/audio_cube/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_i2s.h" #include "hal_dma.h" diff --git a/examples/audiocube_sph0645/main.c b/examples/audiocube_sph0645/main.c index 55188dfa..de5cb082 100644 --- a/examples/audiocube_sph0645/main.c +++ b/examples/audiocube_sph0645/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_i2s.h" #include "hal_dma.h" diff --git a/examples/ble/ble_central/main.c b/examples/ble/ble_central/main.c index 6d3b6207..a7f42385 100644 --- a/examples/ble/ble_central/main.c +++ b/examples/ble/ble_central/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_uart.h" #include #include "semphr.h" diff --git a/examples/ble/ble_peripheral/main.c b/examples/ble/ble_peripheral/main.c index 28c9e6e6..d78b96b7 100644 --- a/examples/ble/ble_peripheral/main.c +++ b/examples/ble/ble_peripheral/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_uart.h" #include #include "semphr.h" diff --git a/examples/boot2_iap/bflb_eflash_loader_interface.c b/examples/boot2_iap/bflb_eflash_loader_interface.c index b5878418..724f2162 100644 --- a/examples/boot2_iap/bflb_eflash_loader_interface.c +++ b/examples/boot2_iap/bflb_eflash_loader_interface.c @@ -2,13 +2,13 @@ #include "partition.h" #include "blsp_common.h" #include "xz_config.h" -#include "blsp_port.h" -#include "hal_boot2.h" - +#include "blsp_port.h" +#include "hal_boot2.h" +#include "bflb_platform.h" uint8_t *g_eflash_loader_readbuf[2]; -volatile uint32_t g_rx_buf_index = 0; -volatile uint32_t g_rx_buf_len = 0; +volatile uint32_t g_rx_buf_index = 0; +volatile uint32_t g_rx_buf_len = 0; uint32_t g_eflash_loader_cmd_ack_buf[16]; @@ -33,7 +33,7 @@ eflash_loader_if_cfg_t * bflb_eflash_loader_if_set(eflash_loader_if_type_t type) //eflash_loader_if_cfg.boot_if_changerate=bflb_eflash_loader_uart_change_rate; return &eflash_loader_if_cfg; -#if BLSP_BOOT2_SUPPORT_USB_IAP +#if BLSP_BOOT2_SUPPORT_USB_IAP case BFLB_EFLASH_LOADER_IF_USB: eflash_loader_if_cfg.if_type=(uint8_t)BFLB_EFLASH_LOADER_IF_USB; eflash_loader_if_cfg.if_type_onfail=(uint8_t)BFLB_EFLASH_LOADER_IF_UART; @@ -49,7 +49,7 @@ eflash_loader_if_cfg_t * bflb_eflash_loader_if_set(eflash_loader_if_type_t type) //eflash_loader_if_cfg.boot_if_changerate=bflb_eflash_loader_uart_change_rate; return &eflash_loader_if_cfg; -#endif +#endif default: break; } @@ -87,82 +87,82 @@ int32_t bflb_eflash_loader_if_deinit() return eflash_loader_if_cfg.boot_if_deinit(); } - + int32_t bflb_eflash_loader_main() -{ - int32_t ret; - uint32_t total_len; - uint32_t i, tmp, cmd_len; - uint8_t *recv_buf = NULL; - uint8_t err_cnt = 0; - uint8_t to_cnt = 0; - - MSG("bflb_eflash_loader_main\r\n"); - pt_table_dump(); - ret = pt_table_get_iap_para(&p_iap_param); - if(0 != ret){ - MSG("no valid partition table\r\n"); - return -1; - } - - while (1) { - to_cnt = 0; - total_len = 0; - - do { - total_len = 0; - recv_buf = (uint8_t *)bflb_eflash_loader_if_read(&total_len); - - if (total_len <= 0) { - to_cnt++; - } - } while (to_cnt < 2 && total_len <= 0); - - if (to_cnt >= 2 || total_len <= 0) { - MSG("rcv err break\r\n"); - break; - } - - MSG("Recv\r\n"); - //eflash_loader_dump_data(recv_buf,total_len); - cmd_len = recv_buf[2] + (recv_buf[3] << 8); - MSG("cmd_len %d\r\n", cmd_len); - - /* Check checksum*/ - if (recv_buf[1] != 0) { - tmp = 0; - - for (i = 2; i < cmd_len + 4; i++) { - tmp += recv_buf[i]; - } - - if ((tmp & 0xff) != recv_buf[1]) { - /* FL+Error code(2bytes) */ - MSG("Checksum error %02x\r\n", tmp & 0xff); - g_eflash_loader_cmd_ack_buf[0] = BFLB_EFLASH_LOADER_CMD_NACK | ((BFLB_EFLASH_LOADER_CMD_CRC_ERROR << 16) & 0xffff0000); - bflb_eflash_loader_if_write(g_eflash_loader_cmd_ack_buf, 4);//ToDo - continue; - } - } - - ret = bflb_eflash_loader_cmd_process(recv_buf[0], recv_buf + 4, cmd_len); - - if (ret != BFLB_EFLASH_LOADER_SUCCESS) { - MSG(" CMD Pro Ret %d\r\n", ret); - - err_cnt++; - - if (err_cnt > 2) { - break; - } - } - } - - /* read data finished,deinit and go on*/ - bflb_eflash_loader_if_deinit();//ToDo +{ + int32_t ret; + uint32_t total_len; + uint32_t i, tmp, cmd_len; + uint8_t *recv_buf = NULL; + uint8_t err_cnt = 0; + uint8_t to_cnt = 0; + + MSG("bflb_eflash_loader_main\r\n"); + pt_table_dump(); + ret = pt_table_get_iap_para(&p_iap_param); + if(0 != ret){ + MSG("no valid partition table\r\n"); + return -1; + } + + while (1) { + to_cnt = 0; + total_len = 0; + + do { + total_len = 0; + recv_buf = (uint8_t *)bflb_eflash_loader_if_read(&total_len); + + if (total_len <= 0) { + to_cnt++; + } + } while (to_cnt < 2 && total_len <= 0); + + if (to_cnt >= 2 || total_len <= 0) { + MSG("rcv err break\r\n"); + break; + } + + MSG("Recv\r\n"); + //eflash_loader_dump_data(recv_buf,total_len); + cmd_len = recv_buf[2] + (recv_buf[3] << 8); + MSG("cmd_len %d\r\n", cmd_len); + + /* Check checksum*/ + if (recv_buf[1] != 0) { + tmp = 0; + + for (i = 2; i < cmd_len + 4; i++) { + tmp += recv_buf[i]; + } + + if ((tmp & 0xff) != recv_buf[1]) { + /* FL+Error code(2bytes) */ + MSG("Checksum error %02x\r\n", tmp & 0xff); + g_eflash_loader_cmd_ack_buf[0] = BFLB_EFLASH_LOADER_CMD_NACK | ((BFLB_EFLASH_LOADER_CMD_CRC_ERROR << 16) & 0xffff0000); + bflb_eflash_loader_if_write(g_eflash_loader_cmd_ack_buf, 4);//ToDo + continue; + } + } + + ret = bflb_eflash_loader_cmd_process(recv_buf[0], recv_buf + 4, cmd_len); + + if (ret != BFLB_EFLASH_LOADER_SUCCESS) { + MSG(" CMD Pro Ret %d\r\n", ret); + + err_cnt++; + + if (err_cnt > 2) { + break; + } + } + } + + /* read data finished,deinit and go on*/ + bflb_eflash_loader_if_deinit();//ToDo return 0; -} +} diff --git a/examples/boot2_iap/blsp_media_boot.c b/examples/boot2_iap/blsp_media_boot.c index d789ec03..672f2735 100644 --- a/examples/boot2_iap/blsp_media_boot.c +++ b/examples/boot2_iap/blsp_media_boot.c @@ -44,6 +44,7 @@ #include "blsp_media_boot.h" #include "softcrc.h" #include "bflb_eflash_loader_interface.h" +#include "hal_uart.h" extern int main(void); extern struct device *dev_check_hash; @@ -180,7 +181,7 @@ static int32_t blsp_mediaboot_parse_one_fw(boot2_image_config *boot_img_cfg, uin /* Due to OTA, the flash_offset is changed, so copy from partition info */ boot_img_cfg->img_start.flash_offset = img_addr; - + /* If sign enable,get pk key and signature*/ if(boot_img_cfg->sign_type){ /* Read public key */ @@ -229,7 +230,7 @@ static int32_t blsp_mediaboot_parse_one_fw(boot2_image_config *boot_img_cfg, uin if(ret!=BFLB_BOOT2_SUCCESS){ return ret; } - + #ifdef BOOT2_MC /* Read signature2*/ MSG_DBG("R SIG2\r\n"); @@ -257,7 +258,7 @@ static int32_t blsp_mediaboot_parse_one_fw(boot2_image_config *boot_img_cfg, uin ret=blsp_mediaboot_read(addr,g_boot2_read_buf,sizeof(boot_aes_config)); if(ret!=BFLB_BOOT2_SUCCESS){ return ret; - } + } if(blsp_boot2_dump_critical_flag()){ blsp_dump_data(g_boot2_read_buf,sizeof(boot_aes_config)); } diff --git a/examples/cxx/main.cc b/examples/cxx/main.cc index fad51031..e195a4b8 100644 --- a/examples/cxx/main.cc +++ b/examples/cxx/main.cc @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_uart.h" #include "hal_mtimer.h" #include diff --git a/examples/dac/dac_dma/main.c b/examples/dac/dac_dma/main.c index bcd8dadf..56fda992 100644 --- a/examples/dac/dac_dma/main.c +++ b/examples/dac/dac_dma/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_dac.h" #include "hal_dma.h" diff --git a/examples/dac/dac_mono_play_form_flash/main.c b/examples/dac/dac_mono_play_form_flash/main.c index 9af97bef..0f57036b 100644 --- a/examples/dac/dac_mono_play_form_flash/main.c +++ b/examples/dac/dac_mono_play_form_flash/main.c @@ -20,9 +20,11 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_dac.h" #include "hal_dma.h" #include "zfb_16.h" + int main(void) { bflb_platform_init(0); diff --git a/examples/dac/dac_poll/main.c b/examples/dac/dac_poll/main.c index 8f3a4068..a1125d2f 100644 --- a/examples/dac/dac_poll/main.c +++ b/examples/dac/dac_poll/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_dac.h" uint16_t sinList[] = { diff --git a/examples/dma/dma_m2m/main.c b/examples/dma/dma_m2m/main.c index 73d90a28..256af123 100644 --- a/examples/dma/dma_m2m/main.c +++ b/examples/dma/dma_m2m/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_dma.h" uint8_t dma_src_buffer[8000] __attribute__((section(".system_ram"))); diff --git a/examples/flash/flash_rw/main.c b/examples/flash/flash_rw/main.c index 8e130688..bf9660a9 100644 --- a/examples/flash/flash_rw/main.c +++ b/examples/flash/flash_rw/main.c @@ -20,7 +20,9 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_flash.h" + int main(void) { uint8_t writeTestData[256]; diff --git a/examples/gpio/gpio_blink/main.c b/examples/gpio/gpio_blink/main.c index 47b716a1..82456301 100644 --- a/examples/gpio/gpio_blink/main.c +++ b/examples/gpio/gpio_blink/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_gpio.h" uint32_t count = 0; diff --git a/examples/gpio/gpio_dht11/main.c b/examples/gpio/gpio_dht11/main.c index 0d44e746..0193e6dc 100644 --- a/examples/gpio/gpio_dht11/main.c +++ b/examples/gpio/gpio_dht11/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_gpio.h" uint32_t count = 0; diff --git a/examples/gpio/gpio_int/main.c b/examples/gpio/gpio_int/main.c index bf150a08..4efa038a 100644 --- a/examples/gpio/gpio_int/main.c +++ b/examples/gpio/gpio_int/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_gpio.h" static void gpio_int_callback(uint32_t pin) diff --git a/examples/hellowd/helloworld/main.c b/examples/hellowd/helloworld/main.c index 68e0e78b..21d6f6f4 100644 --- a/examples/hellowd/helloworld/main.c +++ b/examples/hellowd/helloworld/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_uart.h" int main(void) diff --git a/examples/i2c/i2c_at24cxx/main.c b/examples/i2c/i2c_at24cxx/main.c index a8ff5725..5e199a95 100644 --- a/examples/i2c/i2c_at24cxx/main.c +++ b/examples/i2c/i2c_at24cxx/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_i2c.h" #include "hal_uart.h" diff --git a/examples/i2c/i2c_bmp180/main.c b/examples/i2c/i2c_bmp180/main.c index 1a700afb..56c11a83 100644 --- a/examples/i2c/i2c_bmp180/main.c +++ b/examples/i2c/i2c_bmp180/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_i2c.h" #include "hal_uart.h" diff --git a/examples/i2c/i2c_ssd1306/cdk/i2c_ssd1306.cdkproj b/examples/i2c/i2c_ssd1306/cdk/i2c_ssd1306.cdkproj index 7a5617cf..fcc1938a 100644 --- a/examples/i2c/i2c_ssd1306/cdk/i2c_ssd1306.cdkproj +++ b/examples/i2c/i2c_ssd1306/cdk/i2c_ssd1306.cdkproj @@ -644,7 +644,7 @@ Board: bl70x_iot Optimize more (-O2) Default (-g) - $(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc + $(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc;$(ProjectPath)../../../../bsp/bsp_common/mcu_lcd -fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -Wignored-qualifiers -Wunused -Wundef -msmall-data-limit=4 -std=c99 no no diff --git a/examples/i2c/i2c_ssd1306/main.c b/examples/i2c/i2c_ssd1306/main.c index 9d712892..37c6f120 100644 --- a/examples/i2c/i2c_ssd1306/main.c +++ b/examples/i2c/i2c_ssd1306/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "ssd1306.h" #include "hal_uart.h" diff --git a/examples/i2s/i2s_play_from_flash/CMakeLists.txt b/examples/i2s/i2s_play_from_flash/CMakeLists.txt index 8a8d27bd..e3244b7f 100644 --- a/examples/i2s/i2s_play_from_flash/CMakeLists.txt +++ b/examples/i2s/i2s_play_from_flash/CMakeLists.txt @@ -1,7 +1,7 @@ set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common) set(TARGET_REQUIRED_LIBS fatfs) set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/es8388 ${BSP_COMMON_DIR}/wm8978 ${BSP_COMMON_DIR}/spi_sd) -set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/es8388/bsp_es8388.c ${BSP_COMMON_DIR}/wm8978/wm8978.c ${BSP_COMMON_DIR}/fatfs/fatfs_spi_sd.c ${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c) +set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/es8388/bsp_es8388.c ${BSP_COMMON_DIR}/wm8978/bsp_wm8978.c ${BSP_COMMON_DIR}/fatfs/fatfs_spi_sd.c ${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c) set(mains main.c) generate_bin() diff --git a/examples/i2s/i2s_play_from_flash/main.c b/examples/i2s/i2s_play_from_flash/main.c index c3c1552e..d7eceea6 100644 --- a/examples/i2s/i2s_play_from_flash/main.c +++ b/examples/i2s/i2s_play_from_flash/main.c @@ -38,6 +38,7 @@ * if you want to play different wav format source , pleases modify this case . * */ +#include "bflb_platform.h" #include "hal_i2s.h" #include "hal_gpio.h" #include "hal_dma.h" diff --git a/examples/i2s/i2s_play_from_record/main.c b/examples/i2s/i2s_play_from_record/main.c index 20a45341..ffe17fae 100644 --- a/examples/i2s/i2s_play_from_record/main.c +++ b/examples/i2s/i2s_play_from_record/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_i2s.h" #include "hal_dma.h" #include "bsp_es8388.h" diff --git a/examples/i2s/i2s_play_from_sd/main.c b/examples/i2s/i2s_play_from_sd/main.c index 3efe422a..bd77fcf5 100644 --- a/examples/i2s/i2s_play_from_sd/main.c +++ b/examples/i2s/i2s_play_from_sd/main.c @@ -33,7 +33,7 @@ * * This case use shell module to complete human-computer interaction. */ - +#include "bflb_platform.h" #include "ff.h" #include "fatfs_posix_api.h" #include "wav_play_from_sd_card.h" diff --git a/examples/keyscan/keyscan_it/main.c b/examples/keyscan/keyscan_it/main.c index f10e9313..f5642516 100644 --- a/examples/keyscan/keyscan_it/main.c +++ b/examples/keyscan/keyscan_it/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_uart.h" #include "hal_keyscan.h" @@ -42,7 +42,7 @@ int main(void) if (keyscan) { KEYSCAN_DEV(keyscan)->col_num = COL_NUM_4; KEYSCAN_DEV(keyscan)->row_num = ROW_NUM_4; - device_open(keyscan, 0); //current keyscan clock source:one is 32M/(31+1)/8 = 125Khz and another is 1MHZ + device_open(keyscan, 0); //current scan latency is 32K/1/8 = 4Khz device_set_callback(keyscan, keyscan_irq_callback); device_control(keyscan, DEVICE_CTRL_SET_INT, NULL); device_control(keyscan, DEVICE_CTRL_RESUME, NULL); diff --git a/examples/keyscan/keyscan_it/readme.md b/examples/keyscan/keyscan_it/readme.md index 2d77a827..d07ad704 100644 --- a/examples/keyscan/keyscan_it/readme.md +++ b/examples/keyscan/keyscan_it/readme.md @@ -1,7 +1,7 @@ **board/bl706_iot/clock_config.h** 中, -**BSP_QDEC_KEYSCAN_CLOCK_SOURCE** 设置成 **ROOT_CLOCK_SOURCE_XCLK** -**BSP_QDEC_KEYSCAN_CLOCK_DIV** 设置成 **31** +**BSP_QDEC_KEYSCAN_CLOCK_SOURCE** 设置成 **ROOT_CLOCK_SOURCE_32K_CLK** +**BSP_QDEC_KEYSCAN_CLOCK_DIV** 设置成 **0** **board/bl706_iot/pinmux_config.h** 中, 以下宏设置成 **GPIO_FUN_KEY_SCAN_ROW** diff --git a/examples/keyscan/keyscan_poll/main.c b/examples/keyscan/keyscan_poll/main.c index a24241c8..82d15a5f 100644 --- a/examples/keyscan/keyscan_poll/main.c +++ b/examples/keyscan/keyscan_poll/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_uart.h" #include "hal_keyscan.h" @@ -33,7 +33,7 @@ int main(void) if (keyscan) { KEYSCAN_DEV(keyscan)->col_num = COL_NUM_4; KEYSCAN_DEV(keyscan)->row_num = ROW_NUM_4; - device_open(keyscan, 0); //current keyscan clock source:one is 32M/(31+1)/8 = 125Khz and another is 1MHZ + device_open(keyscan, 0); //current scan latency is 32K/1/8 = 4Khz device_control(keyscan, DEVICE_CTRL_RESUME, NULL); MSG("keyscan found\n"); } diff --git a/examples/keyscan/keyscan_poll/readme.md b/examples/keyscan/keyscan_poll/readme.md index 918fd71c..fb3677b9 100644 --- a/examples/keyscan/keyscan_poll/readme.md +++ b/examples/keyscan/keyscan_poll/readme.md @@ -1,7 +1,7 @@ **board/bl706_iot/clock_config.h** 中, -**BSP_QDEC_KEYSCAN_CLOCK_SOURCE** 设置成 **ROOT_CLOCK_SOURCE_XCLK** -**BSP_QDEC_KEYSCAN_CLOCK_DIV** 设置成 **31** +**BSP_QDEC_KEYSCAN_CLOCK_SOURCE** 设置成 **ROOT_CLOCK_SOURCE_32K_CLK** +**BSP_QDEC_KEYSCAN_CLOCK_DIV** 设置成 **0** **board/bl706_iot/pinmux_config.h** 中, 以下宏设置成 **GPIO_FUN_KEY_SCAN_ROW** diff --git a/examples/lvgl/CMakeLists.txt b/examples/lvgl/CMakeLists.txt index 2057d8b4..2fc0d39c 100644 --- a/examples/lvgl/CMakeLists.txt +++ b/examples/lvgl/CMakeLists.txt @@ -1,10 +1,11 @@ set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common) -set(TARGET_REQUIRED_LIBS fatfs lvgl) -set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/mcu_lcd ${BSP_COMMON_DIR}/lvgl ${BSP_COMMON_DIR}/touch ${BSP_COMMON_DIR}/spi_sd) +set(TARGET_REQUIRED_LIBS lvgl) +set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/mcu_lcd ${BSP_COMMON_DIR}/lvgl ${BSP_COMMON_DIR}/touch) file(GLOB_RECURSE sources "${CMAKE_CURRENT_SOURCE_DIR}/demo/*.c") -set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/lvgl/lv_port_disp.c ${sources} ${BSP_COMMON_DIR}/mcu_lcd/mcu_lcd.c ${BSP_COMMON_DIR}/mcu_lcd/ili9341.c ${BSP_COMMON_DIR}/mcu_lcd/st7735s.c ${BSP_COMMON_DIR}/mcu_lcd/st7789v.c ${BSP_COMMON_DIR}/mcu_lcd/font.c - ${BSP_COMMON_DIR}/lvgl/lv_port_indev.c ${BSP_COMMON_DIR}/lvgl/lv_port_fs.c -${BSP_COMMON_DIR}/touch/xpt2046.c ${BSP_COMMON_DIR}/touch/touch.c ${BSP_COMMON_DIR}/fatfs/fatfs_spi_sd.c ${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c) +set(TARGET_REQUIRED_SRCS ${sources} ${BSP_COMMON_DIR}/mcu_lcd/mcu_lcd.c ${BSP_COMMON_DIR}/mcu_lcd/ili9341.c ${BSP_COMMON_DIR}/mcu_lcd/st7735s.c ${BSP_COMMON_DIR}/mcu_lcd/st7789v.c ${BSP_COMMON_DIR}/mcu_lcd/font.c +${BSP_COMMON_DIR}/lvgl/lv_port_disp.c ${BSP_COMMON_DIR}/lvgl/lv_port_indev.c +${BSP_COMMON_DIR}/touch/xpt2046.c ${BSP_COMMON_DIR}/touch/touch.c ) +list(APPEND GLOBAL_C_FLAGS -DLV_USING_FATFS=0 -DLV_USING_ROMFS=0) set(mains main.c) generate_bin() diff --git a/examples/lvgl/main.c b/examples/lvgl/main.c index b98834ec..2d0ac059 100644 --- a/examples/lvgl/main.c +++ b/examples/lvgl/main.c @@ -29,7 +29,7 @@ * * */ - +#include "bflb_platform.h" #include "hal_spi.h" #include "hal_gpio.h" #include "hal_dma.h" diff --git a/examples/memheap/main.c b/examples/memheap/main.c index 61853f80..8b3e3ddc 100644 --- a/examples/memheap/main.c +++ b/examples/memheap/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_uart.h" int memheap_test(void) diff --git a/examples/pka/sec_dsa/main.c b/examples/pka/sec_dsa/main.c index 344c1a09..7286dd47 100644 --- a/examples/pka/sec_dsa/main.c +++ b/examples/pka/sec_dsa/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_sec_dsa.h" /** @addtogroup BFLB_Peripheral_Case diff --git a/examples/pka/sec_ecdh/main.c b/examples/pka/sec_ecdh/main.c index 1a30d5ef..aa4ec9bb 100644 --- a/examples/pka/sec_ecdh/main.c +++ b/examples/pka/sec_ecdh/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_sec_ecdsa.h" /** @addtogroup BFLB_Peripheral_Case diff --git a/examples/pka/sec_ecdsa/main.c b/examples/pka/sec_ecdsa/main.c index 89be3d40..4b578f1f 100644 --- a/examples/pka/sec_ecdsa/main.c +++ b/examples/pka/sec_ecdsa/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_sec_ecdsa.h" /** @addtogroup BFLB_Peripheral_Case diff --git a/examples/pka/sec_trng/main.c b/examples/pka/sec_trng/main.c index 8f6c5b58..7bac83a3 100644 --- a/examples/pka/sec_trng/main.c +++ b/examples/pka/sec_trng/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_spi.h" #include "hal_sec_ecdsa.h" #include "bsp_il9341.h" diff --git a/examples/pka/sec_trng_random/main.c b/examples/pka/sec_trng_random/main.c index 118d19de..a3556e65 100644 --- a/examples/pka/sec_trng_random/main.c +++ b/examples/pka/sec_trng_random/main.c @@ -20,8 +20,8 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_sec_ecdsa.h" -#include extern void srandom(unsigned int __seed); extern long random(void); diff --git a/examples/pm/hbn_mode_wakeup/main.c b/examples/pm/hbn_mode_wakeup/main.c index 2f2df736..5e371241 100644 --- a/examples/pm/hbn_mode_wakeup/main.c +++ b/examples/pm/hbn_mode_wakeup/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_pm.h" #include "hal_acomp.h" #include "hal_uart.h" diff --git a/examples/pm/pds_mode_wakeup/main.c b/examples/pm/pds_mode_wakeup/main.c index 8cbd0c7f..fea641c2 100644 --- a/examples/pm/pds_mode_wakeup/main.c +++ b/examples/pm/pds_mode_wakeup/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_uart.h" #include "hal_pm.h" #include "hal_gpio.h" diff --git a/examples/pwm/pwm_breath_led/main.c b/examples/pwm/pwm_breath_led/main.c index ee0a09c7..b9f8e50c 100644 --- a/examples/pwm/pwm_breath_led/main.c +++ b/examples/pwm/pwm_breath_led/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_pwm.h" #include "hal_gpio.h" #include "hal_clock.h" diff --git a/examples/pwm/pwm_dc_motor/main.c b/examples/pwm/pwm_dc_motor/main.c index 7048b7b1..8e0b3caf 100644 --- a/examples/pwm/pwm_dc_motor/main.c +++ b/examples/pwm/pwm_dc_motor/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_pwm.h" #include "hal_gpio.h" #include "hal_clock.h" diff --git a/examples/pwm/pwm_it/main.c b/examples/pwm/pwm_it/main.c index 7853239e..e74a8546 100644 --- a/examples/pwm/pwm_it/main.c +++ b/examples/pwm/pwm_it/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_pwm.h" #include "hal_gpio.h" diff --git a/examples/pwm/pwm_step_motor/main.c b/examples/pwm/pwm_step_motor/main.c index cdd67edb..077a9652 100644 --- a/examples/pwm/pwm_step_motor/main.c +++ b/examples/pwm/pwm_step_motor/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_pwm.h" #include "hal_gpio.h" #include "hal_clock.h" diff --git a/examples/qdec/qdec_dc_motor/main.c b/examples/qdec/qdec_dc_motor/main.c index 6a369fa1..cdfcff64 100644 --- a/examples/qdec/qdec_dc_motor/main.c +++ b/examples/qdec/qdec_dc_motor/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_pwm.h" #include "hal_qdec.h" #include "hal_gpio.h" diff --git a/examples/qdec/qdec_it/main.c b/examples/qdec/qdec_it/main.c index ee8278da..65b959cc 100644 --- a/examples/qdec/qdec_it/main.c +++ b/examples/qdec/qdec_it/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_qdec.h" #include "hal_gpio.h" diff --git a/examples/rtc/rtc_calendar/main.c b/examples/rtc/rtc_calendar/main.c index d32051ed..a4ee296b 100644 --- a/examples/rtc/rtc_calendar/main.c +++ b/examples/rtc/rtc_calendar/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_rtc.h" #include "timestamp.h" diff --git a/examples/shell/main.c b/examples/shell/main.c index b39313c5..f942825b 100644 --- a/examples/shell/main.c +++ b/examples/shell/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_uart.h" #include "shell.h" diff --git a/examples/spi/spi_dma_sd/main.c b/examples/spi/spi_dma_sd/main.c index 0e7cf877..73748043 100644 --- a/examples/spi/spi_dma_sd/main.c +++ b/examples/spi/spi_dma_sd/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_spi.h" #include "hal_gpio.h" #include "hal_dma.h" diff --git a/examples/spi/spi_gsl61xx/main.c b/examples/spi/spi_gsl61xx/main.c index 9391e62f..1e01fa1e 100644 --- a/examples/spi/spi_gsl61xx/main.c +++ b/examples/spi/spi_gsl61xx/main.c @@ -20,8 +20,9 @@ * under the License. * */ - +#include "bflb_platform.h" #include "GSL61xx.h" + uint8_t image[120 * 104]; void main(void) diff --git a/examples/spi/spi_i2s_mono_play/CMakeLists.txt b/examples/spi/spi_i2s_mono_play/CMakeLists.txt index 8d249d46..1d194f67 100644 --- a/examples/spi/spi_i2s_mono_play/CMakeLists.txt +++ b/examples/spi/spi_i2s_mono_play/CMakeLists.txt @@ -1,6 +1,6 @@ set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common) set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/es8388 ${BSP_COMMON_DIR}/wm8978 ${BSP_COMMON_DIR}/spi_sd) -set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/es8388/bsp_es8388.c ${BSP_COMMON_DIR}/wm8978/wm8978.c ) +set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/es8388/bsp_es8388.c ${BSP_COMMON_DIR}/wm8978/bsp_wm8978.c ) set(mains main.c) generate_bin() diff --git a/examples/spi/spi_i2s_mono_play/main.c b/examples/spi/spi_i2s_mono_play/main.c index f8caa56b..7935f200 100644 --- a/examples/spi/spi_i2s_mono_play/main.c +++ b/examples/spi/spi_i2s_mono_play/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_spi.h" #include "hal_i2c.h" #include "hal_uart.h" @@ -39,7 +40,7 @@ #if (AUTIO_MODULE_TYPE == AUTIO_ES8388) #include "bsp_es8388.h" #elif (AUTIO_MODULE_TYPE == AUTIO_WM8978) -#include "wm8978.h" +#include "bsp_wm8978.h" #else #endif diff --git a/examples/spi/spi_i2s_mono_record/CMakeLists.txt b/examples/spi/spi_i2s_mono_record/CMakeLists.txt index cbef88aa..75a9808d 100644 --- a/examples/spi/spi_i2s_mono_record/CMakeLists.txt +++ b/examples/spi/spi_i2s_mono_record/CMakeLists.txt @@ -1,6 +1,6 @@ set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common) set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/es8388 ${BSP_COMMON_DIR}/wm8978 ${BSP_COMMON_DIR}/spi_sd) -set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/es8388/bsp_es8388.c ${BSP_COMMON_DIR}/wm8978/wm8978.c ) +set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/es8388/bsp_es8388.c ${BSP_COMMON_DIR}/wm8978/bsp_wm8978.c ) set(mains main.c) generate_bin() diff --git a/examples/spi/spi_i2s_mono_record/main.c b/examples/spi/spi_i2s_mono_record/main.c index 2f68dd29..31ae2c05 100644 --- a/examples/spi/spi_i2s_mono_record/main.c +++ b/examples/spi/spi_i2s_mono_record/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "bl702_glb.h" #include "bl702_spi.h" #include "hal_spi.h" diff --git a/examples/spi/spi_lcd/main.c b/examples/spi/spi_lcd/main.c index 19c91120..d37db823 100644 --- a/examples/spi/spi_lcd/main.c +++ b/examples/spi/spi_lcd/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_spi.h" #include "hal_gpio.h" #include "hal_dma.h" diff --git a/examples/spi/spi_lcd_display_jpeg/main.c b/examples/spi/spi_lcd_display_jpeg/main.c index b0f9c792..0f987904 100644 --- a/examples/spi/spi_lcd_display_jpeg/main.c +++ b/examples/spi/spi_lcd_display_jpeg/main.c @@ -32,7 +32,7 @@ * 关于 romfs 文件系统相关,请查看 components/romfs/genromfs/readme.md 文档 * 本例程是使用四分之一图片,通过镜像旋转到完整图片 */ - +#include "bflb_platform.h" #include "hal_spi.h" #include "hal_gpio.h" #include "hal_dma.h" diff --git a/examples/spi/spi_loopback/main.c b/examples/spi/spi_loopback/main.c index 7ef4355c..13f634c0 100644 --- a/examples/spi/spi_loopback/main.c +++ b/examples/spi/spi_loopback/main.c @@ -20,9 +20,11 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_spi.h" #include "hal_gpio.h" #include "hal_dma.h" + #define TRANSFER_LEN 256 static uint32_t txBuff[TRANSFER_LEN] = { 0 }; static uint32_t rxBuff[TRANSFER_LEN] = { 0 }; diff --git a/examples/spi/spi_ssd1306_badapple/main.c b/examples/spi/spi_ssd1306_badapple/main.c index 8a1e0467..f980fdd8 100644 --- a/examples/spi/spi_ssd1306_badapple/main.c +++ b/examples/spi/spi_ssd1306_badapple/main.c @@ -1,3 +1,26 @@ +/** + * @file main.c + * @brief + * + * Copyright (c) 2021 Bouffalolab team + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + */ +#include "bflb_platform.h" #include "hal_spi.h" #include "hal_gpio.h" #include "ssd1306.h" diff --git a/examples/spi/spi_ws2812b/main.c b/examples/spi/spi_ws2812b/main.c index 90b7a807..5cc10d24 100644 --- a/examples/spi/spi_ws2812b/main.c +++ b/examples/spi/spi_ws2812b/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_spi.h" #include "hal_gpio.h" #include "hal_dma.h" diff --git a/examples/systick/main.c b/examples/systick/main.c index 76523bd8..502dfdb8 100644 --- a/examples/systick/main.c +++ b/examples/systick/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_uart.h" void systick_isr() diff --git a/examples/tensorflow/main.c b/examples/tensorflow/main.c index 6f33e44a..80a61e33 100644 --- a/examples/tensorflow/main.c +++ b/examples/tensorflow/main.c @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include "main_functions.h" +#include "bflb_platform.h" #include "hal_uart.h" /// Global Destructor for C++, which we're not using. diff --git a/examples/uart/uart_dma/main.c b/examples/uart/uart_dma/main.c index f00142c8..a8329ba2 100644 --- a/examples/uart/uart_dma/main.c +++ b/examples/uart/uart_dma/main.c @@ -20,7 +20,7 @@ * under the License. * */ -#include "drv_mmheap.h" +#include "bflb_platform.h" #include "hal_uart.h" #include "hal_dma.h" diff --git a/examples/uart/uart_echo/main.c b/examples/uart/uart_echo/main.c index 0508f2b0..6a3db22d 100644 --- a/examples/uart/uart_echo/main.c +++ b/examples/uart/uart_echo/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_uart.h" void uart_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state) diff --git a/examples/uart/uart_poll/main.c b/examples/uart/uart_poll/main.c index 080bea2e..9979f283 100644 --- a/examples/uart/uart_poll/main.c +++ b/examples/uart/uart_poll/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_uart.h" static uint8_t buffer[100]; diff --git a/examples/uart/uart_rx_it/main.c b/examples/uart/uart_rx_it/main.c index 587951fd..0805a8bb 100644 --- a/examples/uart/uart_rx_it/main.c +++ b/examples/uart/uart_rx_it/main.c @@ -20,7 +20,7 @@ * under the License. * */ -#include "hal_mtimer.h" +#include "bflb_platform.h" #include "hal_uart.h" void uart_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state) diff --git a/examples/usb/usb2uart/main.c b/examples/usb/usb2uart/main.c index 62c8eaf1..732b9a3f 100644 --- a/examples/usb/usb2uart/main.c +++ b/examples/usb/usb2uart/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_cdc.h" diff --git a/examples/usb/usb_audio_mic_speaker/main.c b/examples/usb/usb_audio_mic_speaker/main.c index cbe27a79..fe3a62b1 100644 --- a/examples/usb/usb_audio_mic_speaker/main.c +++ b/examples/usb/usb_audio_mic_speaker/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_audio.h" diff --git a/examples/usb/usb_audio_mouse/main.c b/examples/usb/usb_audio_mouse/main.c index 8d3abd69..a569a667 100644 --- a/examples/usb/usb_audio_mouse/main.c +++ b/examples/usb/usb_audio_mouse/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_audio.h" diff --git a/examples/usb/usb_cdc_acm2/main.c b/examples/usb/usb_cdc_acm2/main.c index 764906df..c60f41ff 100644 --- a/examples/usb/usb_cdc_acm2/main.c +++ b/examples/usb/usb_cdc_acm2/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_cdc.h" diff --git a/examples/usb/usb_cdc_loopback/main.c b/examples/usb/usb_cdc_loopback/main.c index 808ae35c..2c68085b 100644 --- a/examples/usb/usb_cdc_loopback/main.c +++ b/examples/usb/usb_cdc_loopback/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_cdc.h" diff --git a/examples/usb/usb_cdc_msc/main.c b/examples/usb/usb_cdc_msc/main.c index 4644f66d..6148b91e 100644 --- a/examples/usb/usb_cdc_msc/main.c +++ b/examples/usb/usb_cdc_msc/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_cdc.h" diff --git a/examples/usb/usb_cdc_shell/main.c b/examples/usb/usb_cdc_shell/main.c index c46165e7..92114e65 100644 --- a/examples/usb/usb_cdc_shell/main.c +++ b/examples/usb/usb_cdc_shell/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_cdc.h" diff --git a/examples/usb/usb_cdc_video_psram/main.c b/examples/usb/usb_cdc_video_psram/main.c index 351f7166..d12d8839 100644 --- a/examples/usb/usb_cdc_video_psram/main.c +++ b/examples/usb/usb_cdc_video_psram/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_cdc.h" diff --git a/examples/usb/usb_hid_custom_keyboard/main.c b/examples/usb/usb_hid_custom_keyboard/main.c index 30d7e202..7aa9510f 100644 --- a/examples/usb/usb_hid_custom_keyboard/main.c +++ b/examples/usb/usb_hid_custom_keyboard/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_hid.h" diff --git a/examples/usb/usb_hid_keyboard/main.c b/examples/usb/usb_hid_keyboard/main.c index a9cfb879..902ca262 100644 --- a/examples/usb/usb_hid_keyboard/main.c +++ b/examples/usb/usb_hid_keyboard/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_hid.h" diff --git a/examples/usb/usb_hid_mouse/main.c b/examples/usb/usb_hid_mouse/main.c index bc027d93..720e1dc1 100644 --- a/examples/usb/usb_hid_mouse/main.c +++ b/examples/usb/usb_hid_mouse/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_hid.h" diff --git a/examples/usb/usb_msc_flash/main.c b/examples/usb/usb_msc_flash/main.c index 28b7e5f8..fbcdd498 100644 --- a/examples/usb/usb_msc_flash/main.c +++ b/examples/usb/usb_msc_flash/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_msc.h" diff --git a/examples/usb/usb_msc_flash_boot/main.c b/examples/usb/usb_msc_flash_boot/main.c index 7c326f66..d01e5af1 100644 --- a/examples/usb/usb_msc_flash_boot/main.c +++ b/examples/usb/usb_msc_flash_boot/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_msc.h" diff --git a/examples/usb/usb_msc_ram/main.c b/examples/usb/usb_msc_ram/main.c index a01a1632..4a8ae344 100644 --- a/examples/usb/usb_msc_ram/main.c +++ b/examples/usb/usb_msc_ram/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_msc.h" diff --git a/examples/usb/usb_msc_sd/main.c b/examples/usb/usb_msc_sd/main.c index 68c66e14..1ad5d17d 100644 --- a/examples/usb/usb_msc_sd/main.c +++ b/examples/usb/usb_msc_sd/main.c @@ -20,6 +20,7 @@ * under the License. * */ +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_msc.h" diff --git a/examples/usb/usb_video/main.c b/examples/usb/usb_video/main.c index 30b90125..3c0ce57a 100644 --- a/examples/usb/usb_video/main.c +++ b/examples/usb/usb_video/main.c @@ -20,7 +20,7 @@ * under the License. * */ - +#include "bflb_platform.h" #include "hal_usb.h" #include "usbd_core.h" #include "usbd_video.h"