diff --git a/examples/device/device_virtual_com/src/main.c b/examples/device/device_virtual_com/src/main.c index 3e9005e64..294f3c2c0 100644 --- a/examples/device/device_virtual_com/src/main.c +++ b/examples/device/device_virtual_com/src/main.c @@ -118,7 +118,7 @@ void led_blinking_task(void) static uint32_t last_blink = 0; // not enough time - if ( last_blink + BLINK_INTEVAL > hal_tick_get() ) return; + if ( last_blink + BLINK_INTEVAL > tusb_hal_tick_get() ) return; last_blink += BLINK_INTEVAL; diff --git a/hw/bsp/board.c b/hw/bsp/board.c index 575e3859a..2e5597f27 100644 --- a/hw/bsp/board.c +++ b/hw/bsp/board.c @@ -48,7 +48,7 @@ void SysTick_Handler (void) system_ticks++; } -uint32_t hal_tick_get(void) +uint32_t tusb_hal_tick_get(void) { return system_ticks; } diff --git a/hw/mcu/nordic/nrf52/hal/hal_nrf52.c b/hw/mcu/nordic/nrf52/hal/hal_nrf52.c index 4e531bf27..c2fb42dc5 100644 --- a/hw/mcu/nordic/nrf52/hal/hal_nrf52.c +++ b/hw/mcu/nordic/nrf52/hal/hal_nrf52.c @@ -60,24 +60,24 @@ void SysTick_Handler (void) } -bool hal_usb_init(void) +bool tusb_hal_init(void) { } -void hal_usb_int_enable(uint8_t port) +void tusb_hal_init_enable(uint8_t port) { (void) port; NVIC_EnableIRQ(USBD_IRQn); } -void hal_usb_int_disable(uint8_t port) +void tusb_hal_init_disable(uint8_t port) { (void) port; NVIC_DisableIRQ(USBD_IRQn); } -uint32_t hal_tick_get(void) +uint32_t tusb_hal_tick_get(void) { //#define tick2ms(tck) ( ( ((uint64_t)(tck)) * 1000) / configTICK_RATE_HZ ) //return tick2ms( app_timer_cnt_get() ); @@ -85,7 +85,7 @@ uint32_t hal_tick_get(void) return system_ticks; } -void hal_debugger_breakpoint(void) +void tusb_hal_dbg_breakpoint(void) { // M0 cannot check if debugger is attached or not #if defined(__CORTEX_M) && (__CORTEX_M > 0) diff --git a/hw/mcu/nxp/lpc11uxx/hal_mcu/hal_lpc11uxx.c b/hw/mcu/nxp/lpc11uxx/hal_mcu/hal_lpc11uxx.c index c2efb219f..8bef1e9d2 100644 --- a/hw/mcu/nxp/lpc11uxx/hal_mcu/hal_lpc11uxx.c +++ b/hw/mcu/nxp/lpc11uxx/hal_mcu/hal_lpc11uxx.c @@ -41,19 +41,19 @@ #if TUSB_CFG_MCU == MCU_LPC11UXX -void hal_usb_int_enable(uint8_t port) +void tusb_hal_init_enable(uint8_t port) { (void) port; // discard compiler's warning NVIC_EnableIRQ(USB_IRQn); } -void hal_usb_int_disable(uint8_t port) +void tusb_hal_init_disable(uint8_t port) { (void) port; // discard compiler's warning NVIC_DisableIRQ(USB_IRQn); } -bool hal_usb_init(void) +bool tusb_hal_init(void) { // TODO remove magic number /* Enable AHB clock to the USB block and USB RAM. */ diff --git a/hw/mcu/nxp/lpc13uxx/hal_mcu/hal_lpc13uxx.c b/hw/mcu/nxp/lpc13uxx/hal_mcu/hal_lpc13uxx.c index d2ceb24b3..2d48ab88d 100644 --- a/hw/mcu/nxp/lpc13uxx/hal_mcu/hal_lpc13uxx.c +++ b/hw/mcu/nxp/lpc13uxx/hal_mcu/hal_lpc13uxx.c @@ -41,19 +41,19 @@ #if TUSB_CFG_MCU == MCU_LPC13UXX -void hal_usb_int_enable(uint8_t port) +void tusb_hal_init_enable(uint8_t port) { (void) port; // discard compiler's warning NVIC_EnableIRQ(USB_IRQ_IRQn); } -void hal_usb_int_disable(uint8_t port) +void tusb_hal_init_disable(uint8_t port) { (void) port; // discard compiler's warning NVIC_DisableIRQ(USB_IRQ_IRQn); } -bool hal_usb_init(void) +bool tusb_hal_init(void) { // TODO remove magic number LPC_SYSCON->SYSAHBCLKCTRL |= ((0x1<<14) | (0x1<<27)); /* Enable AHB clock to the USB block and USB RAM. */ diff --git a/hw/mcu/nxp/lpc175x_6x/hal_mcu/hal_lpc175x_6x.c b/hw/mcu/nxp/lpc175x_6x/hal_mcu/hal_lpc175x_6x.c index 44768a676..940376fd3 100644 --- a/hw/mcu/nxp/lpc175x_6x/hal_mcu/hal_lpc175x_6x.c +++ b/hw/mcu/nxp/lpc175x_6x/hal_mcu/hal_lpc175x_6x.c @@ -41,13 +41,13 @@ #if TUSB_CFG_MCU == MCU_LPC175X_6X -void hal_usb_int_enable(uint8_t port) +void tusb_hal_init_enable(uint8_t port) { (void) port; // discard compiler's warning NVIC_EnableIRQ(USB_IRQn); } -void hal_usb_int_disable(uint8_t port) +void tusb_hal_init_disable(uint8_t port) { (void) port; // discard compiler's warning NVIC_DisableIRQ(USB_IRQn); @@ -56,7 +56,7 @@ void hal_usb_int_disable(uint8_t port) //--------------------------------------------------------------------+ // IMPLEMENTATION //--------------------------------------------------------------------+ -bool hal_usb_init(void) +bool tusb_hal_init(void) { enum { USBCLK_DEVCIE = 0x12, // AHB + Device diff --git a/hw/mcu/nxp/lpc43xx/hal/hal_lpc43xx.c b/hw/mcu/nxp/lpc43xx/hal/hal_lpc43xx.c index 8758dc73c..b86f5024e 100644 --- a/hw/mcu/nxp/lpc43xx/hal/hal_lpc43xx.c +++ b/hw/mcu/nxp/lpc43xx/hal/hal_lpc43xx.c @@ -53,7 +53,7 @@ enum { LPC43XX_USBMODE_VBUS_HIGH = 1 }; -void hal_debugger_breakpoint(void) +void tusb_hal_dbg_breakpoint(void) { // M0 cannot check if debugger is attached or not #if defined(__CORTEX_M) && (__CORTEX_M > 0) @@ -65,12 +65,12 @@ void hal_debugger_breakpoint(void) #endif } -void hal_usb_int_enable(uint8_t port) +void tusb_hal_init_enable(uint8_t port) { NVIC_EnableIRQ(port ? USB1_IRQn : USB0_IRQn); } -void hal_usb_int_disable(uint8_t port) +void tusb_hal_init_disable(uint8_t port) { NVIC_DisableIRQ(port ? USB1_IRQn : USB0_IRQn); } @@ -91,7 +91,7 @@ static void hal_controller_reset(uint8_t port) // return timeout_expired(&timeout) ? TUSB_ERROR_OSAL_TIMEOUT : TUSB_ERROR_NONE; } -bool hal_usb_init(void) +bool tusb_hal_init(void) { LPC_CREG->CREG0 &= ~(1<<5); /* Turn on the phy */ diff --git a/tinyusb/common/assertion.h b/tinyusb/common/assertion.h index 16c9b07e4..f91f00301 100644 --- a/tinyusb/common/assertion.h +++ b/tinyusb/common/assertion.h @@ -84,7 +84,7 @@ extern "C" do{\ setup_statement;\ if (!(condition)) {\ - hal_debugger_breakpoint();\ + tusb_hal_dbg_breakpoint();\ _ASSERT_MESSAGE(format, __VA_ARGS__);\ error_handler(error, handler_para);\ }\ diff --git a/tinyusb/common/verify.h b/tinyusb/common/verify.h index f48e91662..3aec0a9f8 100644 --- a/tinyusb/common/verify.h +++ b/tinyusb/common/verify.h @@ -148,12 +148,12 @@ /*------------------------------------------------------------------*/ /* ASSERT - * basically VERIFY with hal_debugger_breakpoint as handler + * basically VERIFY with tusb_hal_dbg_breakpoint as handler * - 1 arg : return false if failed * - 2 arg : return error if failed *------------------------------------------------------------------*/ -#define ASSERT_1ARGS(cond) do { if (!(cond)) { hal_debugger_breakpoint(); _ASSERT_MESS() return false; } } while(0) -#define ASSERT_2ARGS(cond, _error) do { if (!(cond)) { hal_debugger_breakpoint(); _ASSERT_MESS() return _error;} } while(0) +#define ASSERT_1ARGS(cond) do { if (!(cond)) { tusb_hal_dbg_breakpoint(); _ASSERT_MESS() return false; } } while(0) +#define ASSERT_2ARGS(cond, _error) do { if (!(cond)) { tusb_hal_dbg_breakpoint(); _ASSERT_MESS() return _error;} } while(0) #define ASSERT_(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_2ARGS, ASSERT_1ARGS)(__VA_ARGS__) diff --git a/tinyusb/device/dcd.h b/tinyusb/device/dcd.h index b786a92a1..a7aec4ef9 100644 --- a/tinyusb/device/dcd.h +++ b/tinyusb/device/dcd.h @@ -58,7 +58,6 @@ typedef enum USBD_BUS_EVENT_RESUME }usbd_bus_event_type_t; -// TODO move Hal typedef struct { uint8_t port; uint8_t index; // must be zero to indicate control diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index f76b6c3f3..391dedb6d 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -647,7 +647,7 @@ static void qhd_xfer_error_isr(ehci_qhd_t * p_qhd) p_qhd->total_xferred_bytes += p_qhd->p_qtd_list_head->expected_bytes - p_qhd->p_qtd_list_head->total_bytes; -// if ( TUSB_EVENT_XFER_ERROR == error_event ) hal_debugger_breakpoint(); // TODO skip unplugged device +// if ( TUSB_EVENT_XFER_ERROR == error_event ) tusb_hal_dbg_breakpoint(); // TODO skip unplugged device p_qhd->p_qtd_list_head->used = 0; // free QTD qtd_remove_1st_from_qhd(p_qhd); diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h index 16e7021ac..229c51b99 100644 --- a/tinyusb/osal/osal_none.h +++ b/tinyusb/osal/osal_none.h @@ -53,7 +53,7 @@ //--------------------------------------------------------------------+ // TICK API //--------------------------------------------------------------------+ -#define osal_tick_get hal_tick_get +#define osal_tick_get tusb_hal_tick_get //--------------------------------------------------------------------+ // TASK API @@ -204,11 +204,11 @@ static inline void osal_queue_flush(osal_queue_t const queue_hdl) else\ return TUSB_ERROR_OSAL_WAITING;\ } else{\ - /*TODO mutex lock hal_usb_int_disable */\ + /*TODO mutex lock tusb_hal_init_disable */\ memcpy(p_data, queue_hdl->buffer + (queue_hdl->rd_idx * queue_hdl->item_size), queue_hdl->item_size);\ queue_hdl->rd_idx = (queue_hdl->rd_idx + 1) % queue_hdl->depth;\ queue_hdl->count--;\ - /*TODO mutex unlock hal_usb_int_enable */\ + /*TODO mutex unlock tusb_hal_init_enable */\ *(p_error) = TUSB_ERROR_NONE;\ }\ }while(0) @@ -258,7 +258,7 @@ static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) else\ return TUSB_ERROR_OSAL_WAITING;\ } else{\ - if (sem_hdl->count) sem_hdl->count--; /*TODO mutex hal_usb_int_disable consideration*/\ + if (sem_hdl->count) sem_hdl->count--; /*TODO mutex tusb_hal_init_disable consideration*/\ *(p_error) = TUSB_ERROR_NONE;\ }\ }while(0) diff --git a/tinyusb/tusb.c b/tinyusb/tusb.c index cf94c1b23..b9af2092f 100644 --- a/tinyusb/tusb.c +++ b/tinyusb/tusb.c @@ -42,7 +42,7 @@ tusb_error_t tusb_init(void) { - VERIFY( hal_usb_init(), TUSB_ERROR_FAILED ) ; // hardware init + VERIFY( tusb_hal_init(), TUSB_ERROR_FAILED ) ; // hardware init #if MODE_HOST_SUPPORTED ASSERT_STATUS( usbh_init() ); // host stack init @@ -53,11 +53,11 @@ tusb_error_t tusb_init(void) #endif #if (TUSB_CFG_CONTROLLER_0_MODE) - hal_usb_int_enable(0); + tusb_hal_init_enable(0); #endif #if (TUSB_CFG_CONTROLLER_1_MODE) - hal_usb_int_enable(1); + tusb_hal_init_enable(1); #endif return TUSB_ERROR_NONE; diff --git a/tinyusb/tusb_hal.h b/tinyusb/tusb_hal.h index 76a1e15c4..dd5d19e09 100644 --- a/tinyusb/tusb_hal.h +++ b/tinyusb/tusb_hal.h @@ -68,26 +68,26 @@ extern "C" { * \returns true if succeedded * \note This function is invoked by \ref tusb_init as part of the initialization. */ -bool hal_usb_init(void); +bool tusb_hal_init(void); /** \brief Enable USB Interrupt on a specific USB Controller * \param[in] port is a zero-based index to identify USB controller's ID * \note Some MCUs such as NXP LPC43xx has multiple USB controllers. It is necessary to know which USB controller for * those MCUs. */ -void hal_usb_int_enable(uint8_t port); +void tusb_hal_init_enable(uint8_t port); /** \brief Disable USB Interrupt on a specific USB Controller * \param[in] port is a zero-based index to identify USB controller's ID * \note Some MCUs such as NXP LPC43xx has multiple USB controllers. It is necessary to know which USB controller for * those MCUs. */ -void hal_usb_int_disable(uint8_t port); +void tusb_hal_init_disable(uint8_t port); -uint32_t hal_tick_get(void); +uint32_t tusb_hal_tick_get(void); // for debug only, halt mcu if assert/verify is failed if debugger is attached -void hal_debugger_breakpoint(void) ATTR_WEAK; +void tusb_hal_dbg_breakpoint(void) ATTR_WEAK; #ifdef __cplusplus }