refactor hal
This commit is contained in:
parent
b5f17fd823
commit
4097d02254
|
@ -37,10 +37,11 @@
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "hal.h"
|
#include "hal/hal.h"
|
||||||
|
|
||||||
#if TUSB_CFG_MCU == MCU_LPC43XX
|
#if TUSB_CFG_MCU == MCU_LPC43XX
|
||||||
|
|
||||||
|
#include "LPC43xx.h"
|
||||||
#include "lpc43xx_cgu.h"
|
#include "lpc43xx_cgu.h"
|
||||||
#include "lpc43xx_scu.h"
|
#include "lpc43xx_scu.h"
|
||||||
|
|
||||||
|
@ -70,6 +71,16 @@ static tusb_error_t hal_controller_reset(uint8_t coreid)
|
||||||
return TUSB_ERROR_NONE;
|
return TUSB_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hal_interrupt_enable(uint8_t coreid)
|
||||||
|
{
|
||||||
|
NVIC_EnableIRQ(coreid ? USB1_IRQn : USB0_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hal_interrupt_disable(uint8_t coreid)
|
||||||
|
{
|
||||||
|
NVIC_DisableIRQ(coreid ? USB1_IRQn : USB0_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
tusb_error_t hal_init(void)
|
tusb_error_t hal_init(void)
|
||||||
{
|
{
|
||||||
LPC_CREG->CREG0 &= ~(1<<5); /* Turn on the phy */
|
LPC_CREG->CREG0 &= ~(1<<5); /* Turn on the phy */
|
|
@ -46,15 +46,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void hal_interrupt_enable(uint8_t coreid)
|
|
||||||
{
|
|
||||||
NVIC_EnableIRQ(coreid ? USB1_IRQn : USB0_IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void hal_interrupt_disable(uint8_t coreid)
|
|
||||||
{
|
|
||||||
NVIC_DisableIRQ(coreid ? USB1_IRQn : USB0_IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -50,7 +50,7 @@
|
||||||
#include "common/compiler/compiler.h"
|
#include "common/compiler/compiler.h"
|
||||||
|
|
||||||
// callback from tusb.h
|
// callback from tusb.h
|
||||||
extern void tusb_isr(uint8_t coreid);
|
void tusb_isr(uint8_t coreid);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// HAL API
|
// HAL API
|
||||||
|
@ -74,14 +74,14 @@ tusb_error_t hal_init(void);
|
||||||
* \note Some MCUs such as NXP LPC43xx has multiple USB controllers. It is necessary to know which USB controller for
|
* \note Some MCUs such as NXP LPC43xx has multiple USB controllers. It is necessary to know which USB controller for
|
||||||
* those MCUs.
|
* those MCUs.
|
||||||
*/
|
*/
|
||||||
static inline void hal_interrupt_enable(uint8_t coreid) ATTR_ALWAYS_INLINE;
|
void hal_interrupt_enable(uint8_t coreid);
|
||||||
|
|
||||||
/** \brief Disable USB Interrupt on a specific USB Controller
|
/** \brief Disable USB Interrupt on a specific USB Controller
|
||||||
* \param[in] coreid is a zero-based index to identify USB controller's ID
|
* \param[in] coreid 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
|
* \note Some MCUs such as NXP LPC43xx has multiple USB controllers. It is necessary to know which USB controller for
|
||||||
* those MCUs.
|
* those MCUs.
|
||||||
*/
|
*/
|
||||||
static inline void hal_interrupt_disable(uint8_t coreid) ATTR_ALWAYS_INLINE;
|
void hal_interrupt_disable(uint8_t coreid);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INCLUDE DRIVEN
|
// INCLUDE DRIVEN
|
||||||
|
@ -91,7 +91,7 @@ static inline void hal_interrupt_disable(uint8_t coreid) ATTR_ALWAYS_INLINE;
|
||||||
#elif TUSB_CFG_MCU == MCU_LPC13UXX
|
#elif TUSB_CFG_MCU == MCU_LPC13UXX
|
||||||
#include "hal_lpc13uxx.h"
|
#include "hal_lpc13uxx.h"
|
||||||
#elif TUSB_CFG_MCU == MCU_LPC43XX
|
#elif TUSB_CFG_MCU == MCU_LPC43XX
|
||||||
#include "hal_lpc43xx.h"
|
#include "mcu/nxp/lpc43xx/usb/hal_lpc43xx.h"
|
||||||
#elif TUSB_CFG_MCU == MCU_LPC175X_6X
|
#elif TUSB_CFG_MCU == MCU_LPC175X_6X
|
||||||
#include "hal_lpc175x_6x.h"
|
#include "hal_lpc175x_6x.h"
|
||||||
#else
|
#else
|
||||||
|
@ -102,8 +102,6 @@ static inline void hal_interrupt_disable(uint8_t coreid) ATTR_ALWAYS_INLINE;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static inline bool hal_debugger_is_attached(void) ATTR_PURE ATTR_ALWAYS_INLINE;
|
|
||||||
static inline bool hal_debugger_is_attached(void)
|
static inline bool hal_debugger_is_attached(void)
|
||||||
{
|
{
|
||||||
// TODO check core M3/M4 defined instead
|
// TODO check core M3/M4 defined instead
|
||||||
|
|
|
@ -41,6 +41,18 @@
|
||||||
|
|
||||||
#if TUSB_CFG_MCU == MCU_LPC11UXX
|
#if TUSB_CFG_MCU == MCU_LPC11UXX
|
||||||
|
|
||||||
|
void hal_interrupt_enable(uint8_t coreid)
|
||||||
|
{
|
||||||
|
(void) coreid; // discard compiler's warning
|
||||||
|
NVIC_EnableIRQ(USB_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hal_interrupt_disable(uint8_t coreid)
|
||||||
|
{
|
||||||
|
(void) coreid; // discard compiler's warning
|
||||||
|
NVIC_DisableIRQ(USB_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
tusb_error_t hal_init(void)
|
tusb_error_t hal_init(void)
|
||||||
{
|
{
|
||||||
// TODO remove magic number
|
// TODO remove magic number
|
||||||
|
|
|
@ -45,17 +45,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void hal_interrupt_enable(uint8_t coreid)
|
|
||||||
{
|
|
||||||
(void) coreid; // discard compiler's warning
|
|
||||||
NVIC_EnableIRQ(USB_IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void hal_interrupt_disable(uint8_t coreid)
|
|
||||||
{
|
|
||||||
(void) coreid; // discard compiler's warning
|
|
||||||
NVIC_DisableIRQ(USB_IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,18 @@
|
||||||
|
|
||||||
#if TUSB_CFG_MCU == MCU_LPC13UXX
|
#if TUSB_CFG_MCU == MCU_LPC13UXX
|
||||||
|
|
||||||
|
void hal_interrupt_enable(uint8_t coreid)
|
||||||
|
{
|
||||||
|
(void) coreid; // discard compiler's warning
|
||||||
|
NVIC_EnableIRQ(USB_IRQ_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hal_interrupt_disable(uint8_t coreid)
|
||||||
|
{
|
||||||
|
(void) coreid; // discard compiler's warning
|
||||||
|
NVIC_DisableIRQ(USB_IRQ_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
tusb_error_t hal_init(void)
|
tusb_error_t hal_init(void)
|
||||||
{
|
{
|
||||||
// TODO remove magic number
|
// TODO remove magic number
|
||||||
|
@ -65,4 +77,7 @@ void USB_IRQHandler(void)
|
||||||
tusb_isr(0);
|
tusb_isr(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,17 +45,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void hal_interrupt_enable(uint8_t coreid)
|
|
||||||
{
|
|
||||||
(void) coreid; // discard compiler's warning
|
|
||||||
NVIC_EnableIRQ(USB_IRQ_IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void hal_interrupt_disable(uint8_t coreid)
|
|
||||||
{
|
|
||||||
(void) coreid; // discard compiler's warning
|
|
||||||
NVIC_DisableIRQ(USB_IRQ_IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,9 +41,17 @@
|
||||||
|
|
||||||
#if TUSB_CFG_MCU == MCU_LPC175X_6X
|
#if TUSB_CFG_MCU == MCU_LPC175X_6X
|
||||||
|
|
||||||
#ifdef __CC_ARM
|
void hal_interrupt_enable(uint8_t coreid)
|
||||||
#pragma diag_suppress 66 // Suppress Keil warnings #66-D: enumeration value is out of "int" range
|
{
|
||||||
#endif
|
(void) coreid; // discard compiler's warning
|
||||||
|
NVIC_EnableIRQ(USB_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hal_interrupt_disable(uint8_t coreid)
|
||||||
|
{
|
||||||
|
(void) coreid; // discard compiler's warning
|
||||||
|
NVIC_DisableIRQ(USB_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// IMPLEMENTATION
|
// IMPLEMENTATION
|
||||||
|
|
|
@ -46,20 +46,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
//
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
static inline void hal_interrupt_enable(uint8_t coreid)
|
|
||||||
{
|
|
||||||
(void) coreid; // discard compiler's warning
|
|
||||||
NVIC_EnableIRQ(USB_IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void hal_interrupt_disable(uint8_t coreid)
|
|
||||||
{
|
|
||||||
(void) coreid; // discard compiler's warning
|
|
||||||
NVIC_DisableIRQ(USB_IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,10 +48,6 @@
|
||||||
|
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
|
|
||||||
#ifdef __CC_ARM
|
|
||||||
#pragma diag_suppress 66 // Suppress Keil warnings #66-D: enumeration value is out of "int" range
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
OSAL_TIMEOUT_NOTIMEOUT = 0, // for use within ISR, return immediately
|
OSAL_TIMEOUT_NOTIMEOUT = 0, // for use within ISR, return immediately
|
||||||
|
@ -59,10 +55,6 @@ enum
|
||||||
OSAL_TIMEOUT_WAIT_FOREVER = 0xFFFFFFFF
|
OSAL_TIMEOUT_WAIT_FOREVER = 0xFFFFFFFF
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __CC_ARM
|
|
||||||
#pragma diag_default 66 // return Keil 66 to normal severity
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline uint32_t osal_tick_from_msec(uint32_t msec) ATTR_CONST ATTR_ALWAYS_INLINE;
|
static inline uint32_t osal_tick_from_msec(uint32_t msec) ATTR_CONST ATTR_ALWAYS_INLINE;
|
||||||
static inline uint32_t osal_tick_from_msec(uint32_t msec)
|
static inline uint32_t osal_tick_from_msec(uint32_t msec)
|
||||||
{
|
{
|
||||||
|
|
|
@ -102,6 +102,8 @@
|
||||||
*/
|
*/
|
||||||
tusb_error_t tusb_init(void);
|
tusb_error_t tusb_init(void);
|
||||||
|
|
||||||
|
void tusb_isr(uint8_t coreid);
|
||||||
|
|
||||||
#if TUSB_CFG_OS == TUSB_OS_NONE
|
#if TUSB_CFG_OS == TUSB_OS_NONE
|
||||||
/** \brief Run all tinyusb's internal tasks (e.g host task, device task).
|
/** \brief Run all tinyusb's internal tasks (e.g host task, device task).
|
||||||
* \note This function is only required when using no RTOS (\ref TUSB_CFG_OS == TUSB_OS_NONE). All the stack functions
|
* \note This function is only required when using no RTOS (\ref TUSB_CFG_OS == TUSB_OS_NONE). All the stack functions
|
||||||
|
|
Loading…
Reference in New Issue