fix ci, remove use of CFG_TUSB_RHPORT0_MODE in bsp

This commit is contained in:
hathach 2022-06-06 12:51:10 +07:00
parent f626916a57
commit 7187cd9a85
11 changed files with 114 additions and 58 deletions

View File

@ -32,11 +32,11 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void USB_IRQHandler(void) void USB_IRQHandler(void)
{ {
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST #if CFG_TUD_ENABLED
tuh_int_handler(0); tuh_int_handler(0);
#endif #endif
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE #if CFG_TUH_ENABLED
tud_int_handler(0); tud_int_handler(0);
#endif #endif
} }
@ -115,7 +115,7 @@ void board_init(void)
SysTick_Config(SystemCoreClock / 1000); SysTick_Config(SystemCoreClock / 1000);
#elif CFG_TUSB_OS == OPT_OS_FREERTOS #elif CFG_TUSB_OS == OPT_OS_FREERTOS
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
#endif #endif
Chip_GPIO_Init(LPC_GPIO); Chip_GPIO_Init(LPC_GPIO);

View File

@ -53,6 +53,18 @@
// {0x02, 7, 0, 7 }, // SW6 // {0x02, 7, 0, 7 }, // SW6
//}; //};
#ifdef BOARD_TUD_RHPORT
#define PORT_SUPPORT_DEVICE(_n) (BOARD_TUD_RHPORT == _n)
#else
#define PORT_SUPPORT_DEVICE(_n) 0
#endif
#ifdef BOARD_TUH_RHPORT
#define PORT_SUPPORT_HOST(_n) (BOARD_TUH_RHPORT == _n)
#else
#define PORT_SUPPORT_HOST(_n) 0
#endif
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
/* BOARD API /* BOARD API
*------------------------------------------------------------------*/ *------------------------------------------------------------------*/
@ -116,7 +128,7 @@ void board_init(void)
SysTick_Config(SystemCoreClock / 1000); SysTick_Config(SystemCoreClock / 1000);
#elif CFG_TUSB_OS == OPT_OS_FREERTOS #elif CFG_TUSB_OS == OPT_OS_FREERTOS
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
//NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
#endif #endif
Chip_GPIO_Init(LPC_GPIO_PORT); Chip_GPIO_Init(LPC_GPIO_PORT);
@ -170,7 +182,7 @@ void board_init(void)
* - Insert jumpers in position 2-3 in JP17/JP18/JP19 * - Insert jumpers in position 2-3 in JP17/JP18/JP19
* - Insert jumpers in JP31 (OTG) * - Insert jumpers in JP31 (OTG)
*/ */
#if CFG_TUSB_RHPORT0_MODE #if PORT_SUPPORT_DEVICE(0) || PORT_SUPPORT_HOST(0)
Chip_USB0_Init(); Chip_USB0_Init();
#endif #endif
@ -195,14 +207,14 @@ void board_init(void)
* - LED34 lights green when +5V is available on J20. * - LED34 lights green when +5V is available on J20.
* - JP15 shall not be inserted. JP16 has no effect * - JP15 shall not be inserted. JP16 has no effect
*/ */
#if CFG_TUSB_RHPORT1_MODE #if PORT_SUPPORT_DEVICE(1) || PORT_SUPPORT_HOST(1)
Chip_USB1_Init(); Chip_USB1_Init();
#endif #endif
// USB0 Vbus Power: P2_3 on EA4357 channel B U20 GPIO26 active low (base board) // USB0 Vbus Power: P2_3 on EA4357 channel B U20 GPIO26 active low (base board)
Chip_SCU_PinMuxSet(2, 3, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC7); Chip_SCU_PinMuxSet(2, 3, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC7);
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE #if PORT_SUPPORT_DEVICE(0)
// P9_5 (GPIO5[18]) (GPIO28 on oem base) as USB connect, active low. // P9_5 (GPIO5[18]) (GPIO28 on oem base) as USB connect, active low.
Chip_SCU_PinMuxSet(9, 5, SCU_MODE_PULLDOWN | SCU_MODE_FUNC4); Chip_SCU_PinMuxSet(9, 5, SCU_MODE_PULLDOWN | SCU_MODE_FUNC4);
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 5, 18); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 5, 18);
@ -217,23 +229,23 @@ void board_init(void)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void USB0_IRQHandler(void) void USB0_IRQHandler(void)
{ {
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST #if PORT_SUPPORT_DEVICE(0)
tuh_int_handler(0); tud_int_handler(0);
#endif #endif
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE #if PORT_SUPPORT_HOST(0)
tud_int_handler(0); tuh_int_handler(0);
#endif #endif
} }
void USB1_IRQHandler(void) void USB1_IRQHandler(void)
{ {
#if CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST #if PORT_SUPPORT_DEVICE(1)
tuh_int_handler(1); tud_int_handler(1);
#endif #endif
#if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE #if PORT_SUPPORT_HOST(1)
tud_int_handler(1); tuh_int_handler(1);
#endif #endif
} }

View File

@ -61,7 +61,7 @@ void isr(void)
irqs = irq_pending() & irq_getmask(); irqs = irq_pending() & irq_getmask();
#if CFG_TUSB_RHPORT0_MODE == OPT_MODE_DEVICE #if CFG_TUD_ENABLED
if (irqs & (1 << USB_INTERRUPT)) { if (irqs & (1 << USB_INTERRUPT)) {
tud_int_handler(0); tud_int_handler(0);
} }

View File

@ -34,9 +34,25 @@
#include "clock_config.h" #include "clock_config.h"
#ifdef BOARD_TUD_RHPORT
#define PORT_SUPPORT_DEVICE(_n) (BOARD_TUD_RHPORT == _n)
#else
#define PORT_SUPPORT_DEVICE(_n) 0
#endif
#ifdef BOARD_TUH_RHPORT
#define PORT_SUPPORT_HOST(_n) (BOARD_TUH_RHPORT == _n)
#else
#define PORT_SUPPORT_HOST(_n) 0
#endif
// needed by fsl_flexspi_nor_boot // needed by fsl_flexspi_nor_boot
const uint8_t dcd_data[] = { 0x00 }; const uint8_t dcd_data[] = { 0x00 };
//--------------------------------------------------------------------+
//
//--------------------------------------------------------------------+
void board_init(void) void board_init(void)
{ {
// Init clock // Init clock
@ -51,9 +67,9 @@ void board_init(void)
SysTick_Config(SystemCoreClock / 1000); SysTick_Config(SystemCoreClock / 1000);
#elif CFG_TUSB_OS == OPT_OS_FREERTOS #elif CFG_TUSB_OS == OPT_OS_FREERTOS
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
NVIC_SetPriority(USB_OTG1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); NVIC_SetPriority(USB_OTG1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
#ifdef USB_OTG2_IRQn #ifdef USBPHY2
NVIC_SetPriority(USB_OTG2_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); NVIC_SetPriority(USB_OTG2_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
#endif #endif
#endif #endif
@ -149,23 +165,23 @@ void board_init(void)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void USB_OTG1_IRQHandler(void) void USB_OTG1_IRQHandler(void)
{ {
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST #if PORT_SUPPORT_DEVICE(0)
tuh_int_handler(0); tud_int_handler(0);
#endif #endif
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE #if PORT_SUPPORT_HOST(0)
tud_int_handler(0); tuh_int_handler(0);
#endif #endif
} }
void USB_OTG2_IRQHandler(void) void USB_OTG2_IRQHandler(void)
{ {
#if CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST #if PORT_SUPPORT_DEVICE(1)
tuh_int_handler(1); tud_int_handler(1);
#endif #endif
#if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE #if PORT_SUPPORT_HOST(1)
tud_int_handler(1); tuh_int_handler(1);
#endif #endif
} }

View File

@ -33,6 +33,18 @@
#include "bsp/board.h" #include "bsp/board.h"
#include "board.h" #include "board.h"
#ifdef BOARD_TUD_RHPORT
#define PORT_SUPPORT_DEVICE(_n) (BOARD_TUD_RHPORT == _n)
#else
#define PORT_SUPPORT_DEVICE(_n) 0
#endif
#ifdef BOARD_TUH_RHPORT
#define PORT_SUPPORT_HOST(_n) (BOARD_TUH_RHPORT == _n)
#else
#define PORT_SUPPORT_HOST(_n) 0
#endif
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM // MACRO TYPEDEF CONSTANT ENUM
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@ -152,8 +164,7 @@ void board_init(void)
#if defined(FSL_FEATURE_SOC_USBHSD_COUNT) && FSL_FEATURE_SOC_USBHSD_COUNT #if defined(FSL_FEATURE_SOC_USBHSD_COUNT) && FSL_FEATURE_SOC_USBHSD_COUNT
// LPC546xx and LPC540xx has OTG 1 FS + 1 HS rhports // LPC546xx and LPC540xx has OTG 1 FS + 1 HS rhports
#if PORT_SUPPORT_DEVICE(0)
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
// Port0 is Full Speed // Port0 is Full Speed
POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*< Turn on USB Phy */ POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*< Turn on USB Phy */
CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1, false); CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1, false);
@ -167,7 +178,7 @@ void board_init(void)
CLOCK_EnableUsbfs0DeviceClock(kCLOCK_UsbSrcFro, CLOCK_GetFroHfFreq()); CLOCK_EnableUsbfs0DeviceClock(kCLOCK_UsbSrcFro, CLOCK_GetFroHfFreq());
#endif #endif
#if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE #if PORT_SUPPORT_DEVICE(1)
// Port1 is High Speed // Port1 is High Speed
POWER_DisablePD(kPDRUNCFG_PD_USB1_PHY); POWER_DisablePD(kPDRUNCFG_PD_USB1_PHY);
@ -178,10 +189,8 @@ void board_init(void)
CLOCK_EnableUsbhs0DeviceClock(kCLOCK_UsbSrcUsbPll, 0U); CLOCK_EnableUsbhs0DeviceClock(kCLOCK_UsbSrcUsbPll, 0U);
#endif #endif
#else #else
// LPC5411x series only has full speed device // LPC5411x series only has full speed device
POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); // Turn on USB Phy POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); // Turn on USB Phy
CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB IP clock */ CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB IP clock */
#endif #endif

View File

@ -34,6 +34,18 @@
#include "fsl_sctimer.h" #include "fsl_sctimer.h"
#include "sct_neopixel.h" #include "sct_neopixel.h"
#ifdef BOARD_TUD_RHPORT
#define PORT_SUPPORT_DEVICE(_n) (BOARD_TUD_RHPORT == _n)
#else
#define PORT_SUPPORT_DEVICE(_n) 0
#endif
#ifdef BOARD_TUH_RHPORT
#define PORT_SUPPORT_HOST(_n) (BOARD_TUH_RHPORT == _n)
#else
#define PORT_SUPPORT_HOST(_n) 0
#endif
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM // MACRO TYPEDEF CONSTANT ENUM
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@ -164,7 +176,7 @@ void board_init(void)
/* PORT0 PIN22 configured as USB0_VBUS */ /* PORT0 PIN22 configured as USB0_VBUS */
IOCON_PinMuxSet(IOCON, 0U, 22U, IOCON_PIO_DIG_FUNC7_EN); IOCON_PinMuxSet(IOCON, 0U, 22U, IOCON_PIO_DIG_FUNC7_EN);
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE #if PORT_SUPPORT_DEVICE(0)
// Port0 is Full Speed // Port0 is Full Speed
/* Turn on USB0 Phy */ /* Turn on USB0 Phy */
@ -189,7 +201,7 @@ void board_init(void)
CLOCK_EnableUsbfs0DeviceClock(kCLOCK_UsbfsSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); CLOCK_EnableUsbfs0DeviceClock(kCLOCK_UsbfsSrcFro, CLOCK_GetFreq(kCLOCK_FroHf));
#endif #endif
#if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE #if PORT_SUPPORT_DEVICE(1)
// Port1 is High Speed // Port1 is High Speed
/* Turn on USB1 Phy */ /* Turn on USB1 Phy */

View File

@ -32,12 +32,12 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void USB_IRQHandler(void) void USB_IRQHandler(void)
{ {
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST #if CFG_TUD_ENABLED
tuh_int_handler(0); tud_int_handler(0);
#endif #endif
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE #if CFG_TUH_ENABLED
tud_int_handler(0); tuh_int_handler(0);
#endif #endif
} }

View File

@ -146,12 +146,12 @@ void board_init(void)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void USB_IRQHandler(void) void USB_IRQHandler(void)
{ {
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST #if CFG_TUD_ENABLED
tuh_int_handler(0); tud_int_handler(0);
#endif #endif
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE #if CFG_TUH_ENABLED
tud_int_handler(0); tuh_int_handler(0);
#endif #endif
} }

View File

@ -40,6 +40,18 @@
#define BOARD_UART_PIN_TX 10 // PF.10 : UART0_TXD #define BOARD_UART_PIN_TX 10 // PF.10 : UART0_TXD
#define BOARD_UART_PIN_RX 11 // PF.11 : UART0_RXD #define BOARD_UART_PIN_RX 11 // PF.11 : UART0_RXD
#ifdef BOARD_TUD_RHPORT
#define PORT_SUPPORT_DEVICE(_n) (BOARD_TUD_RHPORT == _n)
#else
#define PORT_SUPPORT_DEVICE(_n) 0
#endif
#ifdef BOARD_TUH_RHPORT
#define PORT_SUPPORT_HOST(_n) (BOARD_TUH_RHPORT == _n)
#else
#define PORT_SUPPORT_HOST(_n) 0
#endif
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
/* BOARD API /* BOARD API
*------------------------------------------------------------------*/ *------------------------------------------------------------------*/
@ -120,7 +132,7 @@ void board_init(void)
SysTick_Config(SystemCoreClock / 1000); SysTick_Config(SystemCoreClock / 1000);
#elif CFG_TUSB_OS == OPT_OS_FREERTOS #elif CFG_TUSB_OS == OPT_OS_FREERTOS
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
//NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
#endif #endif
Chip_GPIO_Init(LPC_GPIO_PORT); Chip_GPIO_Init(LPC_GPIO_PORT);
@ -167,9 +179,7 @@ void board_init(void)
* status feedback from the distribution switch. GPIO54 is used for VBUS sensing. 15Kohm pull-down * status feedback from the distribution switch. GPIO54 is used for VBUS sensing. 15Kohm pull-down
* resistors are always active * resistors are always active
*/ */
#if CFG_TUSB_RHPORT0_MODE
Chip_USB0_Init(); Chip_USB0_Init();
#endif
/* USB1 /* USB1
* When USB channel #1 is used as USB Host, 15Kohm pull-down resistors are needed on the USB data * When USB channel #1 is used as USB Host, 15Kohm pull-down resistors are needed on the USB data
@ -189,12 +199,9 @@ void board_init(void)
* of VBUS can be read via U31. * of VBUS can be read via U31.
* JP16 shall not be inserted. * JP16 shall not be inserted.
*/ */
#if CFG_TUSB_RHPORT1_MODE
Chip_USB1_Init(); Chip_USB1_Init();
// Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 5, 6); /* GPIO5[6] = USB1_PWR_EN */ // Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 5, 6); /* GPIO5[6] = USB1_PWR_EN */
// Chip_GPIO_SetPinState(LPC_GPIO_PORT, 5, 6, true); /* GPIO5[6] output high */ // Chip_GPIO_SetPinState(LPC_GPIO_PORT, 5, 6, true); /* GPIO5[6] output high */
#endif
} }
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@ -202,23 +209,23 @@ void board_init(void)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void USB0_IRQHandler(void) void USB0_IRQHandler(void)
{ {
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST #if PORT_SUPPORT_DEVICE(0)
tuh_int_handler(0); tud_int_handler(0);
#endif #endif
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE #if PORT_SUPPORT_HOST(0)
tud_int_handler(0); tuh_int_handler(0);
#endif #endif
} }
void USB1_IRQHandler(void) void USB1_IRQHandler(void)
{ {
#if CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST #if PORT_SUPPORT_DEVICE(1)
tuh_int_handler(1); tud_int_handler(1);
#endif #endif
#if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE #if PORT_SUPPORT_HOST(1)
tud_int_handler(1); tuh_int_handler(1);
#endif #endif
} }

View File

@ -99,7 +99,7 @@ void board_init(void)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void UDP_Handler(void) void UDP_Handler(void)
{ {
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE #if CFG_TUD_ENABLED
tud_int_handler(0); tud_int_handler(0);
#endif #endif
} }

View File

@ -312,7 +312,7 @@ static void _dcd_ft90x_detach(void)
// Determine the speed of the USB to which we are connected. // Determine the speed of the USB to which we are connected.
// Set the speed of the PHY accordingly. // Set the speed of the PHY accordingly.
// High speed can be disabled through CFG_TUSB_RHPORT0_MODE settings. // High speed can be disabled through CFG_TUSB_RHPORT0_MODE or CFG_TUD_MAX_SPEED settings.
static void _ft90x_usb_speed(void) static void _ft90x_usb_speed(void)
{ {
uint8_t fctrl_val; uint8_t fctrl_val;