mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-15 20:42:23 +00:00
refactor hal
This commit is contained in:
parent
b5f17fd823
commit
4097d02254
@ -37,10 +37,11 @@
|
||||
/**************************************************************************/
|
||||
|
||||
#include "common/common.h"
|
||||
#include "hal.h"
|
||||
#include "hal/hal.h"
|
||||
|
||||
#if TUSB_CFG_MCU == MCU_LPC43XX
|
||||
|
||||
#include "LPC43xx.h"
|
||||
#include "lpc43xx_cgu.h"
|
||||
#include "lpc43xx_scu.h"
|
||||
|
||||
@ -70,6 +71,16 @@ static tusb_error_t hal_controller_reset(uint8_t coreid)
|
||||
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)
|
||||
{
|
||||
LPC_CREG->CREG0 &= ~(1<<5); /* Turn on the phy */
|
@ -46,15 +46,7 @@
|
||||
extern "C" {
|
||||
#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
|
||||
}
|
@ -50,7 +50,7 @@
|
||||
#include "common/compiler/compiler.h"
|
||||
|
||||
// callback from tusb.h
|
||||
extern void tusb_isr(uint8_t coreid);
|
||||
void tusb_isr(uint8_t coreid);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// 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
|
||||
* 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
|
||||
* \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
|
||||
* those MCUs.
|
||||
*/
|
||||
static inline void hal_interrupt_disable(uint8_t coreid) ATTR_ALWAYS_INLINE;
|
||||
void hal_interrupt_disable(uint8_t coreid);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INCLUDE DRIVEN
|
||||
@ -91,7 +91,7 @@ static inline void hal_interrupt_disable(uint8_t coreid) ATTR_ALWAYS_INLINE;
|
||||
#elif TUSB_CFG_MCU == MCU_LPC13UXX
|
||||
#include "hal_lpc13uxx.h"
|
||||
#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
|
||||
#include "hal_lpc175x_6x.h"
|
||||
#else
|
||||
@ -102,8 +102,6 @@ static inline void hal_interrupt_disable(uint8_t coreid) ATTR_ALWAYS_INLINE;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
static inline bool hal_debugger_is_attached(void) ATTR_PURE ATTR_ALWAYS_INLINE;
|
||||
static inline bool hal_debugger_is_attached(void)
|
||||
{
|
||||
// TODO check core M3/M4 defined instead
|
||||
|
@ -41,6 +41,18 @@
|
||||
|
||||
#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)
|
||||
{
|
||||
// TODO remove magic number
|
||||
|
@ -45,17 +45,6 @@
|
||||
extern "C" {
|
||||
#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
|
||||
}
|
||||
|
@ -41,6 +41,18 @@
|
||||
|
||||
#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)
|
||||
{
|
||||
// TODO remove magic number
|
||||
@ -65,4 +77,7 @@ void USB_IRQHandler(void)
|
||||
tusb_isr(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -45,17 +45,6 @@
|
||||
extern "C" {
|
||||
#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
|
||||
}
|
||||
|
@ -41,9 +41,17 @@
|
||||
|
||||
#if TUSB_CFG_MCU == MCU_LPC175X_6X
|
||||
|
||||
#ifdef __CC_ARM
|
||||
#pragma diag_suppress 66 // Suppress Keil warnings #66-D: enumeration value is out of "int" range
|
||||
#endif
|
||||
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);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// IMPLEMENTATION
|
||||
|
@ -46,20 +46,6 @@
|
||||
extern "C" {
|
||||
#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
|
||||
}
|
||||
|
@ -48,10 +48,6 @@
|
||||
|
||||
#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
|
||||
{
|
||||
OSAL_TIMEOUT_NOTIMEOUT = 0, // for use within ISR, return immediately
|
||||
@ -59,10 +55,6 @@ enum
|
||||
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)
|
||||
{
|
||||
|
@ -102,6 +102,8 @@
|
||||
*/
|
||||
tusb_error_t tusb_init(void);
|
||||
|
||||
void tusb_isr(uint8_t coreid);
|
||||
|
||||
#if TUSB_CFG_OS == TUSB_OS_NONE
|
||||
/** \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
|
||||
|
Loading…
x
Reference in New Issue
Block a user