summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-03-02 15:20:55 +0700
committerhathach <[email protected]>2018-03-02 15:20:55 +0700
commit4097d022542708ee2bc441552679834477a58cf6 (patch)
tree7079fc373aec266dd418c31a465fabed01af4574
parentb5f17fd8235b66b0137c79bf7abd26de4e77d3f7 (diff)
refactor hal
-rw-r--r--hw/mcu/nxp/lpc43xx/usb/hal_lpc43xx.c (renamed from tinyusb/hal/hal_lpc43xx.c)13
-rw-r--r--hw/mcu/nxp/lpc43xx/usb/hal_lpc43xx.h (renamed from tinyusb/hal/hal_lpc43xx.h)8
-rw-r--r--tinyusb/hal/hal.h10
-rw-r--r--tinyusb/hal/hal_lpc11uxx.c12
-rw-r--r--tinyusb/hal/hal_lpc11uxx.h11
-rw-r--r--tinyusb/hal/hal_lpc13uxx.c15
-rw-r--r--tinyusb/hal/hal_lpc13uxx.h11
-rw-r--r--tinyusb/hal/hal_lpc175x_6x.c14
-rw-r--r--tinyusb/hal/hal_lpc175x_6x.h14
-rw-r--r--tinyusb/osal/osal_common.h8
-rw-r--r--tinyusb/tusb.h2
11 files changed, 56 insertions, 62 deletions
diff --git a/tinyusb/hal/hal_lpc43xx.c b/hw/mcu/nxp/lpc43xx/usb/hal_lpc43xx.c
index af6fba126..96ddea5f4 100644
--- a/tinyusb/hal/hal_lpc43xx.c
+++ b/hw/mcu/nxp/lpc43xx/usb/hal_lpc43xx.c
@@ -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 */
diff --git a/tinyusb/hal/hal_lpc43xx.h b/hw/mcu/nxp/lpc43xx/usb/hal_lpc43xx.h
index 899f14445..ecc892d4a 100644
--- a/tinyusb/hal/hal_lpc43xx.h
+++ b/hw/mcu/nxp/lpc43xx/usb/hal_lpc43xx.h
@@ -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
}
diff --git a/tinyusb/hal/hal.h b/tinyusb/hal/hal.h
index 24e39289d..cdaa3c773 100644
--- a/tinyusb/hal/hal.h
+++ b/tinyusb/hal/hal.h
@@ -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
diff --git a/tinyusb/hal/hal_lpc11uxx.c b/tinyusb/hal/hal_lpc11uxx.c
index 8a8232904..36755bdd5 100644
--- a/tinyusb/hal/hal_lpc11uxx.c
+++ b/tinyusb/hal/hal_lpc11uxx.c
@@ -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
diff --git a/tinyusb/hal/hal_lpc11uxx.h b/tinyusb/hal/hal_lpc11uxx.h
index d94aa3dd3..1fd20aff6 100644
--- a/tinyusb/hal/hal_lpc11uxx.h
+++ b/tinyusb/hal/hal_lpc11uxx.h
@@ -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
}
diff --git a/tinyusb/hal/hal_lpc13uxx.c b/tinyusb/hal/hal_lpc13uxx.c
index 9f3361d35..afa67ff21 100644
--- a/tinyusb/hal/hal_lpc13uxx.c
+++ b/tinyusb/hal/hal_lpc13uxx.c
@@ -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
diff --git a/tinyusb/hal/hal_lpc13uxx.h b/tinyusb/hal/hal_lpc13uxx.h
index c5dc8afd4..07bf7f2bd 100644
--- a/tinyusb/hal/hal_lpc13uxx.h
+++ b/tinyusb/hal/hal_lpc13uxx.h
@@ -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
}
diff --git a/tinyusb/hal/hal_lpc175x_6x.c b/tinyusb/hal/hal_lpc175x_6x.c
index c611656a6..f7f1d6a7d 100644
--- a/tinyusb/hal/hal_lpc175x_6x.c
+++ b/tinyusb/hal/hal_lpc175x_6x.c
@@ -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
diff --git a/tinyusb/hal/hal_lpc175x_6x.h b/tinyusb/hal/hal_lpc175x_6x.h
index 744454110..053c34442 100644
--- a/tinyusb/hal/hal_lpc175x_6x.h
+++ b/tinyusb/hal/hal_lpc175x_6x.h
@@ -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
}
diff --git a/tinyusb/osal/osal_common.h b/tinyusb/osal/osal_common.h
index 0a2608933..977b7d59d 100644
--- a/tinyusb/osal/osal_common.h
+++ b/tinyusb/osal/osal_common.h
@@ -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)
{
diff --git a/tinyusb/tusb.h b/tinyusb/tusb.h
index f34749133..5eabf0666 100644
--- a/tinyusb/tusb.h
+++ b/tinyusb/tusb.h
@@ -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