mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-09 18:44:31 +00:00
- house keeping
- add controller id for hal_interrupt_enable/disable
This commit is contained in:
parent
ae9b9ead7a
commit
0c6d406ddf
@ -72,28 +72,16 @@ extern "C" {
|
|||||||
// callback from tusb.h
|
// callback from tusb.h
|
||||||
extern void tusb_isr(uint8_t controller_id);
|
extern void tusb_isr(uint8_t controller_id);
|
||||||
|
|
||||||
|
/// USB hardware init
|
||||||
|
tusb_error_t hal_init(void);
|
||||||
|
|
||||||
/** \brief USB hardware init
|
/// Enable USB Interrupt
|
||||||
*
|
static inline void hal_interrupt_enable(uint8_t controller_id) ATTR_ALWAYS_INLINE;
|
||||||
* \param[in] para1
|
/// Disable USB Interrupt
|
||||||
* \param[out] para2
|
static inline void hal_interrupt_disable(uint8_t controller_id) ATTR_ALWAYS_INLINE;
|
||||||
* \return Error Code of the \ref TUSB_ERROR enum
|
|
||||||
* \note
|
|
||||||
*/
|
|
||||||
tusb_error_t hal_init();
|
|
||||||
|
|
||||||
/**
|
static inline bool hal_debugger_is_attached(void) ATTR_PURE ATTR_ALWAYS_INLINE;
|
||||||
* Enable USB Interrupt
|
static inline bool hal_debugger_is_attached(void)
|
||||||
*/
|
|
||||||
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()
|
|
||||||
{
|
{
|
||||||
#ifndef _TEST_
|
#ifndef _TEST_
|
||||||
return (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == CoreDebug_DHCSR_C_DEBUGEN_Msk;
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void hal_debugger_breakpoint() ATTR_ALWAYS_INLINE;
|
static inline void hal_debugger_breakpoint(void) ATTR_ALWAYS_INLINE;
|
||||||
static inline void hal_debugger_breakpoint()
|
static inline void hal_debugger_breakpoint(void)
|
||||||
{
|
{
|
||||||
#ifndef _TEST_
|
#ifndef _TEST_
|
||||||
if (hal_debugger_is_attached()) /* if there is debugger connected */
|
if (hal_debugger_is_attached()) /* if there is debugger connected */
|
||||||
|
@ -64,13 +64,15 @@
|
|||||||
#endif
|
#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);
|
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);
|
NVIC_DisableIRQ(USB_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,13 +61,15 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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);
|
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);
|
NVIC_DisableIRQ(USB_IRQ_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ enum {
|
|||||||
LPC43XX_USBMODE_VBUS_HIGH = 1
|
LPC43XX_USBMODE_VBUS_HIGH = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
tusb_error_t hal_init()
|
tusb_error_t hal_init(void)
|
||||||
{
|
{
|
||||||
/* Set up USB0 clock */
|
/* Set up USB0 clock */
|
||||||
CGU_EnableEntity(CGU_CLKSRC_PLL0, DISABLE); /* Disable PLL first */
|
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 */
|
LPC_CREG->CREG0 &= ~(1<<5); /* Turn on the phy */
|
||||||
|
|
||||||
//------------- reset controller & set role -------------//
|
//------------- 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);
|
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;
|
return TUSB_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
@ -61,14 +61,14 @@
|
|||||||
#define DEVICE_ROM_REG_BASE LPC_USB0_BASE // TODO USB1
|
#define DEVICE_ROM_REG_BASE LPC_USB0_BASE // TODO USB1
|
||||||
#define DEVICE_ROM_DRIVER_ADDR 0x1040011C
|
#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
|
#ifdef __cplusplus
|
||||||
|
@ -61,7 +61,7 @@ void tusb_tick_tock(void)
|
|||||||
#define ENUM_QUEUE_DEPTH 5
|
#define ENUM_QUEUE_DEPTH 5
|
||||||
|
|
||||||
// TODO fix number of class driver
|
// 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] = {
|
[TUSB_CLASS_HID] = {
|
||||||
.init = hidh_init,
|
.init = hidh_init,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user