lpc40xx device work, moving Chip_USB_Init out of tinyusb

This commit is contained in:
hathach
2018-12-05 08:47:23 +07:00
parent fe8346e642
commit dd9c7b4249
7 changed files with 70 additions and 44 deletions
+32 -1
View File
@@ -39,6 +39,7 @@
#ifdef BOARD_EA4088QS
#include "../board.h"
#include "tusb.h"
#define LED_PORT 2
#define LED_PIN 19
@@ -55,9 +56,25 @@ const uint32_t RTCOscRateIn = 32768;
static const PINMUX_GRP_T pinmuxing[] =
{
/* LEDs */
{0x2, 19, (IOCON_FUNC0 | IOCON_MODE_INACT)},
{2, 19, (IOCON_FUNC0 | IOCON_MODE_INACT)},
};
static const PINMUX_GRP_T pin_usb_mux[] =
{
// USB1 as Host
{0, 29, (IOCON_FUNC1 | IOCON_MODE_INACT)}, // D+1
{0, 30, (IOCON_FUNC1 | IOCON_MODE_INACT)}, // D-1
{1, 18, (IOCON_FUNC1 | IOCON_MODE_INACT)}, // UP LED1
{1, 19, (IOCON_FUNC2 | IOCON_MODE_INACT)}, // PPWR1
// USB2 as Device
{0, 31, (IOCON_FUNC1 | IOCON_MODE_INACT)}, // D+2
{0, 13, (IOCON_FUNC1 | IOCON_MODE_INACT)}, // UP LED
{0, 14, (IOCON_FUNC3 | IOCON_MODE_INACT)}, // CONNECT2
/* VBUS is not connected on this board, so leave the pin at default setting. */
/*Chip_IOCON_PinMux(LPC_IOCON, 1, 30, IOCON_MODE_INACT, IOCON_FUNC2);*/ /* USB VBUS */
};
// Invoked by startup code
void SystemInit(void)
@@ -90,6 +107,20 @@ void board_init(void)
//------------- UART -------------//
//------------- USB -------------//
// Port1 as Host, Port2: Device
Chip_USB_Init();
enum {
USBCLK = 0x1B // Host + Device + OTG + AHB
};
LPC_USB->OTGClkCtrl = USBCLK;
while ( (LPC_USB->OTGClkSt & USBCLK) != USBCLK );
// USB1 = host, USB2 = device
LPC_USB->StCtrl = 0x3;
Chip_IOCON_SetPinMuxing(LPC_IOCON, pin_usb_mux, sizeof(pin_usb_mux) / sizeof(PINMUX_GRP_T));
}