mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-14 04:18:56 +00:00
rename hal_* to tusb_hal_*
This commit is contained in:
parent
c39b24001d
commit
0384e40320
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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. */
|
||||
|
@ -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. */
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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);\
|
||||
}\
|
||||
|
@ -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__)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user