diff --git a/tinyusb/hal/hal.h b/tinyusb/hal/hal.h index 941063665..f95d62ae9 100644 --- a/tinyusb/hal/hal.h +++ b/tinyusb/hal/hal.h @@ -72,28 +72,16 @@ extern "C" { // callback from tusb.h extern void tusb_isr(uint8_t controller_id); +/// USB hardware init +tusb_error_t hal_init(void); -/** \brief USB hardware init - * - * \param[in] para1 - * \param[out] para2 - * \return Error Code of the \ref TUSB_ERROR enum - * \note - */ -tusb_error_t hal_init(); +/// Enable USB Interrupt +static inline void hal_interrupt_enable(uint8_t controller_id) ATTR_ALWAYS_INLINE; +/// Disable USB Interrupt +static inline void hal_interrupt_disable(uint8_t controller_id) ATTR_ALWAYS_INLINE; -/** - * Enable USB Interrupt - */ -static inline void hal_interrupt_enable() ATTR_ALWAYS_INLINE; - -/** - * Disable USB Interrupt - */ -static inline void hal_interrupt_disable() ATTR_ALWAYS_INLINE; - -static inline bool hal_debugger_is_attached() ATTR_PURE ATTR_ALWAYS_INLINE; -static inline bool hal_debugger_is_attached() +static inline bool hal_debugger_is_attached(void) ATTR_PURE ATTR_ALWAYS_INLINE; +static inline bool hal_debugger_is_attached(void) { #ifndef _TEST_ return (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == CoreDebug_DHCSR_C_DEBUGEN_Msk; @@ -102,8 +90,8 @@ static inline bool hal_debugger_is_attached() #endif } -static inline void hal_debugger_breakpoint() ATTR_ALWAYS_INLINE; -static inline void hal_debugger_breakpoint() +static inline void hal_debugger_breakpoint(void) ATTR_ALWAYS_INLINE; +static inline void hal_debugger_breakpoint(void) { #ifndef _TEST_ if (hal_debugger_is_attached()) /* if there is debugger connected */ diff --git a/tinyusb/hal/hal_lpc11uxx.h b/tinyusb/hal/hal_lpc11uxx.h index 19fd79c23..b8acdec2a 100644 --- a/tinyusb/hal/hal_lpc11uxx.h +++ b/tinyusb/hal/hal_lpc11uxx.h @@ -64,13 +64,15 @@ #endif -static inline void hal_interrupt_enable() +static inline void hal_interrupt_enable(uint8_t controller_id) { + (void) controller_id; // discard compiler's warning NVIC_EnableIRQ(USB_IRQn); } -static inline void hal_interrupt_disable() +static inline void hal_interrupt_disable(uint8_t controller_id) { + (void) controller_id; // discard compiler's warning NVIC_DisableIRQ(USB_IRQn); } diff --git a/tinyusb/hal/hal_lpc13uxx.h b/tinyusb/hal/hal_lpc13uxx.h index 83d2f9ecd..aa319b228 100644 --- a/tinyusb/hal/hal_lpc13uxx.h +++ b/tinyusb/hal/hal_lpc13uxx.h @@ -61,13 +61,15 @@ extern "C" { #endif -static inline void hal_interrupt_enable() +static inline void hal_interrupt_enable(uint8_t controller_id) { + (void) controller_id; // discard compiler's warning NVIC_EnableIRQ(USB_IRQ_IRQn); } -static inline void hal_interrupt_disable() +static inline void hal_interrupt_disable(uint8_t controller_id) { + (void) controller_id; // discard compiler's warning NVIC_DisableIRQ(USB_IRQ_IRQn); } diff --git a/tinyusb/hal/hal_lpc43xx.c b/tinyusb/hal/hal_lpc43xx.c index 388552ec1..5d6a7f5ca 100644 --- a/tinyusb/hal/hal_lpc43xx.c +++ b/tinyusb/hal/hal_lpc43xx.c @@ -52,7 +52,7 @@ enum { LPC43XX_USBMODE_VBUS_HIGH = 1 }; -tusb_error_t hal_init() +tusb_error_t hal_init(void) { /* Set up USB0 clock */ CGU_EnableEntity(CGU_CLKSRC_PLL0, DISABLE); /* Disable PLL first */ @@ -62,10 +62,10 @@ tusb_error_t hal_init() LPC_CREG->CREG0 &= ~(1<<5); /* Turn on the phy */ //------------- reset controller & set role -------------// - hcd_controller_reset(0); // TODO where to place prototype + hcd_controller_reset(0); // TODO where to place prototype, USB1 LPC_USB0->USBMODE_H = LPC43XX_USBMODE_HOST | (LPC43XX_USBMODE_VBUS_HIGH << 5); - hal_interrupt_enable(); + hal_interrupt_enable(0); // TODO USB1 return TUSB_ERROR_NONE; } diff --git a/tinyusb/hal/hal_lpc43xx.h b/tinyusb/hal/hal_lpc43xx.h index 63da8a37c..9afbf8bbd 100644 --- a/tinyusb/hal/hal_lpc43xx.h +++ b/tinyusb/hal/hal_lpc43xx.h @@ -61,14 +61,14 @@ #define DEVICE_ROM_REG_BASE LPC_USB0_BASE // TODO USB1 #define DEVICE_ROM_DRIVER_ADDR 0x1040011C -static inline void hal_interrupt_enable() +static inline void hal_interrupt_enable(uint8_t controller_id) { - NVIC_EnableIRQ(USB0_IRQn); // TODO USB1 + NVIC_EnableIRQ(controller_id ? USB1_IRQn : USB0_IRQn); } -static inline void hal_interrupt_disable() +static inline void hal_interrupt_disable(uint8_t controller_id) { - NVIC_DisableIRQ(USB0_IRQn); // TODO USB1 + NVIC_DisableIRQ(controller_id ? USB1_IRQn : USB0_IRQn); } #ifdef __cplusplus diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index f871d8979..dbc0c2765 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -61,7 +61,7 @@ void tusb_tick_tock(void) #define ENUM_QUEUE_DEPTH 5 // TODO fix number of class driver -class_driver_t const usbh_class_drivers[TUSB_CLASS_MAX_CONSEC_NUMBER] = +static class_driver_t const usbh_class_drivers[TUSB_CLASS_MAX_CONSEC_NUMBER] = { [TUSB_CLASS_HID] = { .init = hidh_init,