mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
add alignof to compilier specific
add static_assert support for IAR (built-in support)
This commit is contained in:
parent
5207875add
commit
656da2992d
@ -83,7 +83,7 @@ void test_hcd_init_usbint(void)
|
||||
|
||||
for(uint32_t i=0; i<TUSB_CFG_HOST_CONTROLLER_NUM; i++)
|
||||
{
|
||||
ehci_registers_t* regs = get_operational_register(i+TUSB_CFG_HOST_CONTROLLER_START_INDEX);
|
||||
ehci_registers_t* const regs = get_operational_register(i+TUSB_CFG_HOST_CONTROLLER_START_INDEX);
|
||||
|
||||
//------------- USB INT Enable-------------//
|
||||
TEST_ASSERT(regs->usb_int_enable_bit.usb_error);
|
||||
@ -188,5 +188,9 @@ void test_hcd_init_usbcmd(void)
|
||||
TEST_ASSERT_BITS(BIN8(11), EHCI_CFG_FRAMELIST_SIZE_BITS, regs->usb_cmd_bit.framelist_size);
|
||||
TEST_ASSERT_EQUAL(EHCI_CFG_FRAMELIST_SIZE_BITS >> 2, regs->usb_cmd_bit.nxp_framelist_size_msb);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void test_hcd_init_portsc(void)
|
||||
{
|
||||
TEST_IGNORE_MESSAGE("more advance stuff need manipulate this register");
|
||||
}
|
||||
|
@ -61,13 +61,17 @@ extern "C"
|
||||
//--------------------------------------------------------------------+
|
||||
// Compile-time Assert
|
||||
//--------------------------------------------------------------------+
|
||||
#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
|
||||
#define _ASSERT_COUNTER __COUNTER__
|
||||
#ifdef __ICCARM__
|
||||
#define STATIC_ASSERT static_assert
|
||||
#else
|
||||
#define _ASSERT_COUNTER __LINE__
|
||||
#endif
|
||||
#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
|
||||
#define _ASSERT_COUNTER __COUNTER__
|
||||
#else
|
||||
#define _ASSERT_COUNTER __LINE__
|
||||
#endif
|
||||
|
||||
#define STATIC_ASSSERT(const_expr) enum { XSTRING_CONCAT(static_assert_, _ASSERT_COUNTER) = 1/(!!(const_expr)) }
|
||||
#define STATIC_ASSERT(const_expr, message) enum { XSTRING_CONCAT_(static_assert_, _ASSERT_COUNTER) = 1/(!!(const_expr)) }
|
||||
#endif
|
||||
|
||||
//#if ( defined CFG_PRINTF_UART || defined CFG_PRINTF_USBCDC || defined CFG_PRINTF_DEBUG )
|
||||
#if TUSB_CFG_DEBUG == 3
|
||||
|
@ -51,6 +51,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ALIGN_OF(x) __alignof__(x)
|
||||
|
||||
/// Normally, the compiler places the objects it generates in sections like data or bss & function in text. Sometimes, however, you need additional sections, or you need certain particular variables to appear in special sections, for example to map to special hardware. The section attribute specifies that a variable (or function) lives in a particular section
|
||||
#define ATTR_SECTION(section) __attribute__ ((#section))
|
||||
|
||||
|
@ -51,6 +51,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ALIGN_OF(x) __ALIGNOF__(x)
|
||||
|
||||
#define ATTR_PREPACKED __packed
|
||||
#define ATTR_PACKED
|
||||
|
||||
|
@ -61,6 +61,9 @@
|
||||
#define DEVICE_ROM_REG_BASE LPC_USB0_BASE // TODO USB1
|
||||
#define DEVICE_ROM_DRIVER_ADDR 0x1040011C
|
||||
|
||||
#define tusb_1st_isr USB0_IRQHandler
|
||||
#define tusb_2nd_isr
|
||||
|
||||
static inline void hal_interrupt_enable()
|
||||
{
|
||||
NVIC_EnableIRQ(USB0_IRQn); // TODO USB1
|
||||
|
@ -59,6 +59,12 @@ STATIC_ ehci_link_t period_frame_list0[EHCI_FRAMELIST_SIZE] ATTR_ALIGNED(4096) T
|
||||
STATIC_ ehci_link_t period_frame_list1[EHCI_FRAMELIST_SIZE] ATTR_ALIGNED(4096) TUSB_CFG_ATTR_USBRAM;
|
||||
#endif
|
||||
|
||||
//------------- Validation -------------//
|
||||
STATIC_ASSERT( ALIGN_OF(period_frame_list0) == 4096, "Period Framelist must be 4k alginment");
|
||||
#if TUSB_CFG_HOST_CONTROLLER_NUM > 1
|
||||
STATIC_ASSERT( ALIGN_OF(period_frame_list1) == 4096, "Period Framelist must be 4k alginment");
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// IMPLEMENTATION
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -91,6 +91,11 @@
|
||||
#error EHCI_CFG_FRAMELIST_SIZE_BITS must be from 0-7
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USBH-HCD API
|
||||
//--------------------------------------------------------------------+
|
||||
void hcd_isr(uint8_t hostid);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// EHCI Data Structure
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -41,15 +41,16 @@
|
||||
|
||||
tusb_error_t tusb_init(void)
|
||||
{
|
||||
ASSERT_STATUS( hal_init() ) ; /* HARDWARE INIT */
|
||||
ASSERT_STATUS( hal_init() ) ; // hardware init
|
||||
|
||||
#ifdef TUSB_CFG_HOST
|
||||
ASSERT_STATUS( usbh_init() );
|
||||
ASSERT_STATUS( usbh_init() ); // host stack init
|
||||
#endif
|
||||
|
||||
#ifdef TUSB_CFG_DEVICE
|
||||
ASSERT_STATUS( dcd_init(0) );
|
||||
ASSERT_STATUS( dcd_init(0) ); // device stack init
|
||||
#endif
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user