diff --git a/bsp/bsp_common/platform/bflb_platform.c b/bsp/bsp_common/platform/bflb_platform.c index d5f1a59f..4f9c45f0 100644 --- a/bsp/bsp_common/platform/bflb_platform.c +++ b/bsp/bsp_common/platform/bflb_platform.c @@ -49,6 +49,12 @@ void bflb_platform_init(uint32_t baudrate) board_init(); + uint8_t ret = 0; + + if (mmheap_init_with_pool(&__HeapBase, (size_t)&__HeapLimit - (size_t)&__HeapBase)) { + ret = 1; + } + if (!uart_dbg_disable) { uart_register(board_get_debug_uart_index(), "debug_log", DEVICE_OFLAG_RDWR); struct device *uart = device_find("debug_log"); @@ -62,11 +68,10 @@ void bflb_platform_init(uint32_t baudrate) bl_show_info(); } - if (!mmheap_init_with_pool(&__HeapBase, (size_t)&__HeapLimit - (size_t)&__HeapBase)) { + if (!ret) MSG("dynamic memory init success,heap size = %d Kbyte \r\n", ((size_t)&__HeapLimit - (size_t)&__HeapBase) / 1000); - } else { + else MSG("dynamic memory init error\r\n"); - } enable_irq(); } diff --git a/bsp/bsp_common/platform/bflb_platform.h b/bsp/bsp_common/platform/bflb_platform.h index 8fafdc97..dfd4c1f7 100644 --- a/bsp/bsp_common/platform/bflb_platform.h +++ b/bsp/bsp_common/platform/bflb_platform.h @@ -31,23 +31,16 @@ extern "C" { #include "misc.h" //#include "mcu_sdk_version.h" -#define printf(a, ...) bflb_platform_printf(a, ##__VA_ARGS__) #define MSG(a, ...) bflb_platform_printf(a, ##__VA_ARGS__) #define MSG_DBG(a, ...) bflb_platform_printf(a, ##__VA_ARGS__) #define MSG_ERR(a, ...) bflb_platform_printf(a, ##__VA_ARGS__) -#define BL_CASE_FAIL \ - { \ - MSG(" Case Fail\r\n"); \ - while (1) { \ - bflb_platform_delay_ms(1); \ - } \ +#define BL_CASE_FAIL \ + { \ + MSG("case fail\r\n"); \ } -#define BL_CASE_SUCCESS \ - { \ - MSG(" Case Success\r\n"); \ - while (1) { \ - bflb_platform_delay_ms(1); \ - } \ +#define BL_CASE_SUCCESS \ + { \ + MSG("case success\r\n"); \ } /* compatible with old version */ diff --git a/bsp/bsp_common/usb/usb_dc.c b/bsp/bsp_common/usb/usb_dc.c index 254f7ede..ddc5541b 100644 --- a/bsp/bsp_common/usb/usb_dc.c +++ b/bsp/bsp_common/usb/usb_dc.c @@ -77,7 +77,7 @@ struct device *usb_dc_init(void) int usbd_set_address(const uint8_t addr) { - return device_control(usb, DEVICE_CTRL_USB_DC_SET_ADDR, (void *)(uint32_t)addr); + return usb_dc_set_dev_address(addr); } int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg) @@ -86,16 +86,15 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg) } int usbd_ep_close(const uint8_t ep) { - device_control(usb, DEVICE_CTRL_USB_DC_SET_NACK, (void *)(uint32_t)ep); - return 0; + return usb_dc_ep_close(ep); } int usbd_ep_set_stall(const uint8_t ep) { - return device_control(usb, DEVICE_CTRL_USB_DC_SET_STALL, (void *)(uint32_t)ep); + return usb_dc_ep_set_stall(ep); } int usbd_ep_clear_stall(const uint8_t ep) { - return device_control(usb, DEVICE_CTRL_USB_DC_CLR_STALL, (void *)(uint32_t)ep); + return usb_dc_ep_clear_stall(ep); } int usbd_ep_is_stalled(const uint8_t ep, uint8_t *stalled) {