diff options
| author | hathach <[email protected]> | 2013-11-22 15:16:24 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-11-22 15:16:24 +0700 |
| commit | 83f1d660ce1a1520b7a7e781d05c47221067f3f7 (patch) | |
| tree | c86ce99d5ce7feb84669c9d390eb80cf29590076 /tinyusb/hal | |
| parent | d1ef89a1543581d1703ea43b0056b5112fd64019 (diff) | |
clean up
add some doxygen work
finalize device disconnection & suspend
- suspend & resume & remote wake up is not supported yet
Diffstat (limited to 'tinyusb/hal')
| -rw-r--r-- | tinyusb/hal/hal_lpc13uxx.c | 4 | ||||
| -rw-r--r-- | tinyusb/hal/hal_lpc175x_6x.c | 26 | ||||
| -rw-r--r-- | tinyusb/hal/hal_lpc175x_6x.h | 1 |
3 files changed, 19 insertions, 12 deletions
diff --git a/tinyusb/hal/hal_lpc13uxx.c b/tinyusb/hal/hal_lpc13uxx.c index a5697afc3..4e986faac 100644 --- a/tinyusb/hal/hal_lpc13uxx.c +++ b/tinyusb/hal/hal_lpc13uxx.c @@ -44,8 +44,8 @@ tusb_error_t hal_init(void) { // TODO remove magic number - /* Enable AHB clock to the USB block and USB RAM. */ - LPC_SYSCON->SYSAHBCLKCTRL |= ((0x1<<14) | (0x1<<27)); + LPC_SYSCON->SYSAHBCLKCTRL |= ((0x1<<14) | (0x1<<27)); /* Enable AHB clock to the USB block and USB RAM. */ + LPC_SYSCON->PDRUNCFG &= ~( BIT_(8) | BIT_(10) ); // enable USB PLL & USB transceiver /* Pull-down is needed, or internally, VBUS will be floating. This is to address the wrong status in VBUSDebouncing bit in CmdStatus register. */ diff --git a/tinyusb/hal/hal_lpc175x_6x.c b/tinyusb/hal/hal_lpc175x_6x.c index aca4bd42b..ae63b7b7a 100644 --- a/tinyusb/hal/hal_lpc175x_6x.c +++ b/tinyusb/hal/hal_lpc175x_6x.c @@ -51,27 +51,33 @@ //--------------------------------------------------------------------+ tusb_error_t hal_init(void) { - //------------- user manual 11.13 usb device controller initialization -------------// - // TODO remove magic number - /* Enable AHB clock to the USB block and USB RAM. */ -// LPC_SYSCON->SYSAHBCLKCTRL |= ((0x1<<14) | (0x1<<27)); + LPC_SC->PCONP |= CLKPWR_PCONP_PCUSB; /* USB PCLK -> enable USB Per.*/ + //------------- user manual 11.13 usb device controller initialization -------------// LPC_PINCON->PINSEL1 &= ~((3<<26)|(3<<28)); /* P0.29 D+, P0.30 D- */ LPC_PINCON->PINSEL1 |= ((1<<26)|(1<<28)); /* PINSEL1 26.27, 28.29 = 01 */ // LPC_PINCON->PINSEL3 &= ~(3<<6); TODO HOST // LPC_PINCON->PINSEL3 |= (2<<6); - LPC_SC->PCONP |= CLKPWR_PCONP_PCUSB; /* USB PCLK -> enable USB Per.*/ + //------------- Device -------------// + LPC_PINCON->PINSEL4 &= ~(3 << 18); + LPC_PINCON->PINSEL4 |= (1 << 18); // P2_9 as USB Connect + + // P1_30 as VBUS, ignore if it is already in VBUS mode + if ( !(!BIT_TEST_(LPC_PINCON->PINSEL3, 28) && BIT_TEST_(LPC_PINCON->PINSEL3, 29)) ) + { + // some board like lpcxpresso1769 does not connect VBUS signal to pin P1_30, this allow those board to overwrite + // by always pulling P1_30 to high + PINSEL_ConfigPin( &(PINSEL_CFG_Type) { + .Portnum = 1, .Pinnum = 30, + .Funcnum = 2, .Pinmode = PINSEL_PINMODE_PULLDOWN} ); + } - // DEVICE mode LPC_USB->USBClkCtrl = 0x12; /* Dev, PortSel, AHB clock enable */ while ((LPC_USB->USBClkSt & 0x12) != 0x12); - /* Pull-down is needed, or internally, VBUS will be floating. This is to - address the wrong status in VBUSDebouncing bit in CmdStatus register. */ - -return TUSB_ERROR_NONE; + return TUSB_ERROR_NONE; } void USB_IRQHandler(void) diff --git a/tinyusb/hal/hal_lpc175x_6x.h b/tinyusb/hal/hal_lpc175x_6x.h index 013bdcb37..47b38747b 100644 --- a/tinyusb/hal/hal_lpc175x_6x.h +++ b/tinyusb/hal/hal_lpc175x_6x.h @@ -48,6 +48,7 @@ #include "LPC17xx.h" #include "lpc17xx_clkpwr.h" +#include "lpc17xx_pinsel.h" #ifdef __cplusplus extern "C" { |
