mirror of
https://github.com/apache/nuttx.git
synced 2026-08-22 14:08:30 +00:00
boards/nucleo-l073rz: Add USB device support and a CDC/ACM configuration.
The STM32L073RZ provides a full speed USB device controller, but the Nucleo-L073RZ board support did not enable it and no configuration exercised it. Add the pieces required to run USB device mode on this board: - Add the USB device pin definitions to the STM32L0 pin map. - Provide board level pull-up control using the embedded DP pull-up in USB_BCDR, and register the CDC/ACM class at boot when it is selected. - Add a usb-cdc configuration that presents an NSH console on USART2 and a CDC/ACM serial device on USB. The 48MHz clock for the controller is supplied by HSI48 trimmed from the USB start of frame packet, which is the crystal-less USB configuration already described by this board's board.h. Assisted-by: GitHub Copilot:claude-opus-5 Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
This commit is contained in:
parent
4c0a8af494
commit
421bd04a95
5 changed files with 131 additions and 1 deletions
|
|
@ -320,7 +320,10 @@
|
|||
#define GPIO_USART5_TX_2 (GPIO_ALT | GPIO_PULLUP | GPIO_AF6 | GPIO_PUSHPULL | GPIO_PORTE | GPIO_PIN10)
|
||||
#define GPIO_USART5_TX_3 (GPIO_ALT | GPIO_PULLUP | GPIO_AF6 | GPIO_PUSHPULL | GPIO_PORTB | GPIO_PIN4)
|
||||
|
||||
/* TODO: USB */
|
||||
/* USB */
|
||||
|
||||
#define GPIO_USB_DM (GPIO_ALT | GPIO_AF0 | GPIO_PORTA | GPIO_PIN11)
|
||||
#define GPIO_USB_DP (GPIO_ALT | GPIO_AF0 | GPIO_PORTA | GPIO_PIN12)
|
||||
|
||||
/* TODO: LPTIM */
|
||||
|
||||
|
|
|
|||
62
boards/arm/stm32l0/nucleo-l073rz/configs/usb-cdc/defconfig
Normal file
62
boards/arm/stm32l0/nucleo-l073rz/configs/usb-cdc/defconfig
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="nucleo-l073rz"
|
||||
CONFIG_ARCH_BOARD_NUCLEO_L073RZ=y
|
||||
CONFIG_ARCH_CHIP="stm32l0"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32L073RZ=y
|
||||
CONFIG_ARCH_CHIP_STM32L073XX=y
|
||||
CONFIG_ARCH_CHIP_STM32L0=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARDCTL_USBDEVCTRL=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=2796
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CDCACM=y
|
||||
CONFIG_CDCACM_RXBUFSIZE=256
|
||||
CONFIG_CDCACM_TXBUFSIZE=256
|
||||
CONFIG_DEBUG_FEATURES=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DEBUG_USB=y
|
||||
CONFIG_DISABLE_ENVIRON=y
|
||||
CONFIG_DISABLE_MQUEUE=y
|
||||
CONFIG_DISABLE_POSIX_TIMERS=y
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=1536
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LINE_MAX=64
|
||||
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NUNGET_CHARS=0
|
||||
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=1536
|
||||
CONFIG_PTHREAD_MUTEX_UNSAFE=y
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=1536
|
||||
CONFIG_RAM_SIZE=20480
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=19
|
||||
CONFIG_START_MONTH=5
|
||||
CONFIG_START_YEAR=2013
|
||||
CONFIG_STDIO_DISABLE_BUFFERING=y
|
||||
CONFIG_STM32_HSI48=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_STM32_USB=y
|
||||
CONFIG_STM32_VREFINT=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USBDEV_TRACE=y
|
||||
CONFIG_USBDEV_TRACE_STRINGS=y
|
||||
|
|
@ -94,6 +94,11 @@
|
|||
# define STM32_HSI48_SYNCSRC SYNCSRC_USB
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_STM32_USB) && defined(CONFIG_USBDEV)
|
||||
int stm32_usb_setpullup(bool enable);
|
||||
bool stm32_usb_pullup_enabled(void);
|
||||
#endif
|
||||
|
||||
/* TODO: timers */
|
||||
|
||||
/* LED definitions **********************************************************/
|
||||
|
|
|
|||
|
|
@ -26,9 +26,17 @@
|
|||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "arm_internal.h"
|
||||
#include "hardware/stm32_usbdev.h"
|
||||
#include "stm32_usbdev.h"
|
||||
#include "nucleo-l073rz.h"
|
||||
|
||||
/****************************************************************************
|
||||
|
|
@ -77,6 +85,45 @@ void stm32_boardinitialize(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(CONFIG_STM32_USB) && defined(CONFIG_USBDEV)
|
||||
int stm32_usb_setpullup(bool enable)
|
||||
{
|
||||
irqstate_t flags;
|
||||
uint16_t regval;
|
||||
|
||||
flags = enter_critical_section();
|
||||
regval = getreg16(STM32_USB_BCDR);
|
||||
|
||||
if (enable)
|
||||
{
|
||||
regval |= USB_BCDR_DPPU;
|
||||
}
|
||||
else
|
||||
{
|
||||
regval &= ~USB_BCDR_DPPU;
|
||||
}
|
||||
|
||||
putreg16(regval, STM32_USB_BCDR);
|
||||
leave_critical_section(flags);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
bool stm32_usb_pullup_enabled(void)
|
||||
{
|
||||
return (getreg16(STM32_USB_BCDR) & USB_BCDR_DPPU) != 0;
|
||||
}
|
||||
|
||||
int stm32_usbpullup(FAR struct usbdev_s *dev, bool enable)
|
||||
{
|
||||
return stm32_usb_setpullup(enable);
|
||||
}
|
||||
|
||||
void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_late_initialize
|
||||
*
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/leds/userled.h>
|
||||
#include <nuttx/usb/cdcacm.h>
|
||||
|
||||
#include "nucleo-l073rz.h"
|
||||
|
||||
|
|
@ -50,6 +51,10 @@
|
|||
# define HAVE_DAC2 1
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_CDCACM) && !defined(CONFIG_CDCACM_COMPOSITE)
|
||||
# define HAVE_CDCACM 1
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -80,6 +85,14 @@ int stm32_bringup(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CDCACM
|
||||
ret = cdcacm_initialize(0, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to register CDC ACM: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ADC
|
||||
/* Initialize ADC and register the ADC driver. */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue