From 270ed237fd8956c347608e3c60d79e941f3ccdae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= Date: Mon, 25 Nov 2013 15:15:35 +0100 Subject: [PATCH] cc2538: usb: Make the GPIO driving the pull-up optional MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The data sheet recommends that the USB pull-up resistor be driven by a GPIO so that it can be controlled by software, but this is not mandatory. Hence, leave the choice so that CC253-based boards not using this option can build and work fine. Signed-off-by: Benoît Thébaudeau --- cpu/cc2538/usb/usb-arch.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cpu/cc2538/usb/usb-arch.c b/cpu/cc2538/usb/usb-arch.c index d9c58558b..c209d7778 100644 --- a/cpu/cc2538/usb/usb-arch.c +++ b/cpu/cc2538/usb/usb-arch.c @@ -54,8 +54,12 @@ #include #include /*---------------------------------------------------------------------------*/ +#ifdef USB_PULLUP_PORT #define USB_PULLUP_PORT_BASE GPIO_PORT_TO_BASE(USB_PULLUP_PORT) +#endif +#ifdef USB_PULLUP_PIN #define USB_PULLUP_PIN_MASK GPIO_PIN_MASK(USB_PULLUP_PIN) +#endif /*---------------------------------------------------------------------------*/ /* EP max FIFO sizes without double buffering */ #if CTRL_EP_SIZE > 32 @@ -332,9 +336,11 @@ usb_arch_setup(void) /* Wait until USB PLL is stable */ while(!(REG(USB_CTRL) & USB_CTRL_PLL_LOCKED)); - /* Enable pull-up on usb port */ + /* Enable pull-up on usb port if driven by GPIO */ +#if defined(USB_PULLUP_PORT_BASE) && defined(USB_PULLUP_PIN_MASK) GPIO_SET_OUTPUT(USB_PULLUP_PORT_BASE, USB_PULLUP_PIN_MASK); GPIO_SET_PIN(USB_PULLUP_PORT_BASE, USB_PULLUP_PIN_MASK); +#endif for(i = 0; i < USB_MAX_ENDPOINTS; i++) { usb_endpoints[i].flags = 0;