- house keeping

- add controller id for hal_interrupt_enable/disable
This commit is contained in:
hathach 2013-03-23 10:56:41 +07:00
parent ae9b9ead7a
commit 0c6d406ddf
6 changed files with 26 additions and 34 deletions

View File

@ -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 */

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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

View File

@ -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,