mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
55s69 device work with usb0
This commit is contained in:
parent
dd07e743d8
commit
a90e2aa2ce
@ -74,10 +74,10 @@
|
|||||||
//------------- CLASS -------------//
|
//------------- CLASS -------------//
|
||||||
#define CFG_TUD_CDC 1
|
#define CFG_TUD_CDC 1
|
||||||
#define CFG_TUD_MSC 1
|
#define CFG_TUD_MSC 1
|
||||||
|
|
||||||
#if CFG_TUSB_MCU == OPT_MCU_STM32F4
|
#if CFG_TUSB_MCU == OPT_MCU_STM32F4
|
||||||
// STM32F4 does not have enough endpoints (4, including hardcoded control
|
// STM32F4 does not have enough endpoints (4, including hardcoded control
|
||||||
// endpoint) to enable CDC, MSC, and HID simultaneously, so disable HID as a
|
// endpoint) to enable CDC, MSC, and HID simultaneously, so disable HID as a compromise.
|
||||||
// compromise.
|
|
||||||
#define CFG_TUD_HID 0
|
#define CFG_TUD_HID 0
|
||||||
#else
|
#else
|
||||||
#define CFG_TUD_HID 1
|
#define CFG_TUD_HID 1
|
||||||
|
@ -23,7 +23,7 @@ SRC_C += \
|
|||||||
$(MCU_DIR)/drivers/fsl_reset.c
|
$(MCU_DIR)/drivers/fsl_reset.c
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
$(TOP)/$(MCU_DIR)/../CMSIS/Include \
|
$(TOP)/$(MCU_DIR)/../../CMSIS/Include \
|
||||||
$(TOP)/$(MCU_DIR) \
|
$(TOP)/$(MCU_DIR) \
|
||||||
$(TOP)/$(MCU_DIR)/drivers
|
$(TOP)/$(MCU_DIR)/drivers
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ SRC_C += \
|
|||||||
$(MCU_DIR)/drivers/fsl_reset.c
|
$(MCU_DIR)/drivers/fsl_reset.c
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
$(TOP)/$(MCU_DIR)/../CMSIS/Include \
|
$(TOP)/$(MCU_DIR)/../../CMSIS/Include \
|
||||||
$(TOP)/$(MCU_DIR) \
|
$(TOP)/$(MCU_DIR) \
|
||||||
$(TOP)/$(MCU_DIR)/drivers
|
$(TOP)/$(MCU_DIR)/drivers
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ SRC_C += \
|
|||||||
$(MCU_DIR)/drivers/fsl_reset.c
|
$(MCU_DIR)/drivers/fsl_reset.c
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
$(TOP)/$(MCU_DIR)/../CMSIS/Include \
|
$(TOP)/$(MCU_DIR)/../../CMSIS/Include \
|
||||||
$(TOP)/$(MCU_DIR) \
|
$(TOP)/$(MCU_DIR) \
|
||||||
$(TOP)/$(MCU_DIR)/drivers
|
$(TOP)/$(MCU_DIR)/drivers
|
||||||
|
|
||||||
|
@ -108,38 +108,65 @@ void board_init(void)
|
|||||||
board_led_write(true);
|
board_led_write(true);
|
||||||
|
|
||||||
// Button
|
// Button
|
||||||
const uint32_t port1_pin18_config = (/* Pin is configured as PIO1_18 */
|
const uint32_t port1_pin18_config = (
|
||||||
IOCON_PIO_FUNC0 |
|
IOCON_PIO_FUNC0 | /* Pin is configured as PIO1_18 */
|
||||||
/* No addition pin function */
|
IOCON_PIO_MODE_INACT | /* No addition pin function */
|
||||||
IOCON_PIO_MODE_INACT |
|
IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
|
||||||
/* Standard mode, output slew rate control is enabled */
|
IOCON_PIO_INV_DI | /* Input function is not inverted */
|
||||||
IOCON_PIO_SLEW_STANDARD |
|
IOCON_PIO_DIGITAL_EN | /* Enables digital function */
|
||||||
/* Input function is not inverted */
|
IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
|
||||||
IOCON_PIO_INV_DI |
|
);
|
||||||
/* Enables digital function */
|
|
||||||
IOCON_PIO_DIGITAL_EN |
|
|
||||||
/* Open drain is disabled */
|
|
||||||
IOCON_PIO_OPENDRAIN_DI);
|
|
||||||
/* PORT1 PIN18 (coords: 64) is configured as PIO1_18 */
|
/* PORT1 PIN18 (coords: 64) is configured as PIO1_18 */
|
||||||
IOCON_PinMuxSet(IOCON, 1U, 18U, port1_pin18_config);
|
IOCON_PinMuxSet(IOCON, 1U, 18U, port1_pin18_config);
|
||||||
|
|
||||||
gpio_pin_config_t const button_config = { kGPIO_DigitalInput, 0};
|
gpio_pin_config_t const button_config = { kGPIO_DigitalInput, 0};
|
||||||
GPIO_PinInit(GPIO, BUTTON_PORT, BUTTON_PIN, &button_config);
|
GPIO_PinInit(GPIO, BUTTON_PORT, BUTTON_PIN, &button_config);
|
||||||
|
|
||||||
#if 0
|
// USB VBUS
|
||||||
// USB
|
const uint32_t port0_pin22_config = (
|
||||||
const uint32_t port1_pin6_config = (
|
IOCON_PIO_FUNC7 | /* Pin is configured as USB0_VBUS */
|
||||||
IOCON_PIO_FUNC7 | /* Pin is configured as USB0_VBUS */
|
IOCON_PIO_MODE_INACT | /* No addition pin function */
|
||||||
IOCON_PIO_MODE_INACT | /* No addition pin function */
|
IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
|
||||||
IOCON_PIO_INV_DI | /* Input function is not inverted */
|
IOCON_PIO_INV_DI | /* Input function is not inverted */
|
||||||
IOCON_PIO_DIGITAL_EN | /* Enables digital function */
|
IOCON_PIO_DIGITAL_EN | /* Enables digital function */
|
||||||
IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
|
IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
|
||||||
IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
|
|
||||||
);
|
);
|
||||||
IOCON_PinMuxSet(IOCON, 1, 6, port1_pin6_config); /* PORT1 PIN6 (coords: 26) is configured as USB0_VBUS */
|
/* PORT0 PIN22 (coords: 78) is configured as USB0_VBUS */
|
||||||
|
IOCON_PinMuxSet(IOCON, 0U, 22U, port0_pin22_config);
|
||||||
|
|
||||||
POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*Turn on USB Phy */
|
// USB Controller
|
||||||
CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB IP clock */
|
POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*Turn on USB0 Phy */
|
||||||
|
POWER_DisablePD(kPDRUNCFG_PD_USB1_PHY); /*< Turn on USB1 Phy */
|
||||||
|
|
||||||
|
/* reset the IP to make sure it's in reset state. */
|
||||||
|
RESET_PeripheralReset(kUSB0D_RST_SHIFT_RSTn);
|
||||||
|
RESET_PeripheralReset(kUSB0HSL_RST_SHIFT_RSTn);
|
||||||
|
RESET_PeripheralReset(kUSB0HMR_RST_SHIFT_RSTn);
|
||||||
|
RESET_PeripheralReset(kUSB1H_RST_SHIFT_RSTn);
|
||||||
|
RESET_PeripheralReset(kUSB1D_RST_SHIFT_RSTn);
|
||||||
|
RESET_PeripheralReset(kUSB1_RST_SHIFT_RSTn);
|
||||||
|
RESET_PeripheralReset(kUSB1RAM_RST_SHIFT_RSTn);
|
||||||
|
|
||||||
|
#if (defined USB_DEVICE_CONFIG_LPCIP3511HS) && (USB_DEVICE_CONFIG_LPCIP3511HS)
|
||||||
|
CLOCK_EnableClock(kCLOCK_Usbh1);
|
||||||
|
/* Put PHY powerdown under software control */
|
||||||
|
*((uint32_t *)(USBHSH_BASE + 0x50)) = USBHSH_PORTMODE_SW_PDCOM_MASK;
|
||||||
|
/* According to reference mannual, device mode setting has to be set by access usb host register */
|
||||||
|
*((uint32_t *)(USBHSH_BASE + 0x50)) |= USBHSH_PORTMODE_DEV_ENABLE_MASK;
|
||||||
|
/* enable usb1 host clock */
|
||||||
|
CLOCK_DisableClock(kCLOCK_Usbh1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 || (defined USB_DEVICE_CONFIG_LPCIP3511FS) && (USB_DEVICE_CONFIG_LPCIP3511FS)
|
||||||
|
CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1, false);
|
||||||
|
CLOCK_AttachClk(kFRO_HF_to_USB0_CLK);
|
||||||
|
/* enable usb0 host clock */
|
||||||
|
CLOCK_EnableClock(kCLOCK_Usbhsl0);
|
||||||
|
/*According to reference mannual, device mode setting has to be set by access usb host register */
|
||||||
|
*((uint32_t *)(USBFSH_BASE + 0x5C)) |= USBFSH_PORTMODE_DEV_ENABLE_MASK;
|
||||||
|
/* disable usb0 host clock */
|
||||||
|
CLOCK_DisableClock(kCLOCK_Usbhsl0);
|
||||||
|
CLOCK_EnableUsbfs0DeviceClock(kCLOCK_UsbfsSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB Device clock */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,14 +39,16 @@
|
|||||||
#if TUSB_OPT_DEVICE_ENABLED && ( CFG_TUSB_MCU == OPT_MCU_LPC11UXX || \
|
#if TUSB_OPT_DEVICE_ENABLED && ( CFG_TUSB_MCU == OPT_MCU_LPC11UXX || \
|
||||||
CFG_TUSB_MCU == OPT_MCU_LPC13XX || \
|
CFG_TUSB_MCU == OPT_MCU_LPC13XX || \
|
||||||
CFG_TUSB_MCU == OPT_MCU_LPC51UXX || \
|
CFG_TUSB_MCU == OPT_MCU_LPC51UXX || \
|
||||||
CFG_TUSB_MCU == OPT_MCU_LPC54XXX )
|
CFG_TUSB_MCU == OPT_MCU_LPC54XXX || \
|
||||||
|
CFG_TUSB_MCU == OPT_MCU_LPC55XX)
|
||||||
|
|
||||||
#if CFG_TUSB_MCU == OPT_MCU_LPC11UXX || CFG_TUSB_MCU == OPT_MCU_LPC13XX
|
#if CFG_TUSB_MCU == OPT_MCU_LPC11UXX || CFG_TUSB_MCU == OPT_MCU_LPC13XX
|
||||||
// LPC11Uxx and LPC13xx use lpcopen
|
// LPC11Uxx and LPC13xx use lpcopen
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
#define DCD_REGS LPC_USB
|
#define DCD_REGS LPC_USB
|
||||||
#define DCD_IRQHandler USB_IRQHandler
|
#define DCD_IRQHandler USB_IRQHandler
|
||||||
#elif CFG_TUSB_MCU == OPT_MCU_LPC51UXX || CFG_TUSB_MCU == OPT_MCU_LPC54XXX
|
#elif CFG_TUSB_MCU == OPT_MCU_LPC51UXX || CFG_TUSB_MCU == OPT_MCU_LPC54XXX || \
|
||||||
|
CFG_TUSB_MCU == OPT_MCU_LPC55XX // TODO 55xx has dual usb controllers
|
||||||
#include "fsl_device_registers.h"
|
#include "fsl_device_registers.h"
|
||||||
#define DCD_REGS USB0
|
#define DCD_REGS USB0
|
||||||
#define DCD_IRQHandler USB0_IRQHandler
|
#define DCD_IRQHandler USB0_IRQHandler
|
||||||
|
Loading…
x
Reference in New Issue
Block a user