diff --git a/Documentation/platforms/arm/stm32f4/boards/nucleo-f401re/index.rst b/Documentation/platforms/arm/stm32f4/boards/nucleo-f401re/index.rst index 9bfbbdc589df1..b1d7a8f1591d9 100644 --- a/Documentation/platforms/arm/stm32f4/boards/nucleo-f401re/index.rst +++ b/Documentation/platforms/arm/stm32f4/boards/nucleo-f401re/index.rst @@ -3,15 +3,9 @@ ST Nucleo F401RE ================ This page discusses issues unique to NuttX configurations for the ST -NucleoF401RE and NucleoF411RE boards from ST Micro. See +NucleoF401RE boards from ST Micro. See http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1577/LN1810/PF258797 - http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1577/LN1877/PF260049 - -These two boards are very similar, both supporting STM32 "Dynamic Efficiency -Line" parts but differing in the specific STM32 chip mounted on board. The -chips themselves are also very similar with the STM32F411RE having some -additional capability: NucleoF401RE: @@ -30,8 +24,6 @@ NucleoF401RE: - CRC calculation unit - RTC -The NucleoF411RE also has additional DMA and SPI peripheral capabilities. - Board features, however, are identical: - Peripherals: 1 led, 1 push button @@ -41,8 +33,7 @@ Board features, however, are identical: Uses a STM32F103 to provide a ST-Link for programming, debug similar to the OpenOcd FTDI function - USB to JTAG front-end. -See http://mbed.org/platforms/ST-Nucleo-F401RE and -http://developer.mbed.org/platforms/ST-Nucleo-F411RE for more +See http://mbed.org/platforms/ST-Nucleo-F401RE for more information about these boards. mbed @@ -55,12 +46,12 @@ The Nucleo-F401RE includes boot loader from mbed: Using the mbed loader: -1. Connect the Nucleo-F4x1RE to the host PC using the USB connector. +1. Connect the Nucleo-F401RE to the host PC using the USB connector. 2. A new file system will appear called NUCLEO; open it with Windows Explorer (assuming that you are using Windows). 3. Drag and drop nuttx.bin into the MBED window. This will load the - nuttx.bin binary into the Nucleo-F4x1RE. The NUCLEO window will - close then re-open and the Nucleo-F4x1RE will be running the new code. + nuttx.bin binary into the Nucleo-F401RE. The NUCLEO window will + close then re-open and the Nucleo-F401RE will be running the new code. Hardware ======== @@ -93,7 +84,7 @@ microcontroller. LEDs ---- -The Nucleo F401RE and Nucleo F411RE provide a single user LED, LD2. LD2 +The Nucleo F401RE provides a single user LED, LD2. LD2 is the green LED connected to Arduino signal D13 corresponding to MCU I/O PA5 (pin 21) or PB13 (pin 34) depending on the STM32target. @@ -141,7 +132,7 @@ pin selections. TTL to RS-232 converter connection:: - Nucleo CN10 STM32F4x1RE + Nucleo CN10 STM32F401RE ----------- ------------ Pin 21 PA9 USART1_RX *Warning you make need to reverse RX/TX on Pin 33 PA10 USART1_TX some RS-232 converters @@ -174,7 +165,7 @@ Pins and Connectors:: TTL to RS-232 converter connection:: - Nucleo CN9 STM32F4x1RE + Nucleo CN9 STM32F401RE ----------- ------------ Pin 1 PA3 USART2_RX *Warning you make need to reverse RX/TX on Pin 2 PA2 USART2_TX some RS-232 converters @@ -258,7 +249,7 @@ RS-232 from Cutedigi.com Supports a single RS-232 connected via:: - Nucleo CN9 STM32F4x1RE Cutedigi + Nucleo CN9 STM32F401RE Cutedigi ----------- ------------ -------- Pin 1 PA3 USART2_RX RXD Pin 2 PA2 USART2_TX TXD @@ -275,7 +266,7 @@ about this joystick. Itead Joystick Connection:: --------- ----------------- --------------------------------- - ARDUINO ITEAD NUCLEO-F4x1 + ARDUINO ITEAD NUCLEO-F401 PIN NAME SIGNAL SIGNAL --------- ----------------- --------------------------------- D3 Button E Output PB3 @@ -349,8 +340,8 @@ STATUS: Configurations ============== -f401-nsh: ---------- +nsh: +---- Configures the NuttShell (nsh) located at apps/examples/nsh for the Nucleo-F401RE board. The Configuration enables the serial interfaces @@ -380,15 +371,10 @@ NOTES: Consoles). I have been using a TTL-to-RS-232 converter connected as shown below:: - Nucleo CN10 STM32F4x1RE + Nucleo CN10 STM32F401RE ----------- ------------ Pin 21 PA9 USART1_RX *Warning you make need to reverse RX/TX on Pin 33 PA10 USART1_TX some RS-232 converters Pin 20 GND Pin 8 U5V -f411-nsh --------- - -This configuration is the same as the f401-nsh configuration, except -that it is configured to support the Nucleo-F411RE. diff --git a/Documentation/platforms/arm/stm32f4/boards/nucleo-f411re/index.rst b/Documentation/platforms/arm/stm32f4/boards/nucleo-f411re/index.rst index 0d6bb7228b6ec..57b76c0bc1cc3 100644 --- a/Documentation/platforms/arm/stm32f4/boards/nucleo-f411re/index.rst +++ b/Documentation/platforms/arm/stm32f4/boards/nucleo-f411re/index.rst @@ -3,16 +3,10 @@ ST Nucleo F411RE ================ This page discusses issues unique to NuttX configurations for the ST -NucleoF401RE and NucleoF411RE boards from ST Micro. See +NucleoF411RE board from ST Micro. See - http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1577/LN1810/PF258797 http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1577/LN1877/PF260049 -These two boards are very similar, both supporting STM32 "Dynamic Efficiency -Line" parts but differing in the specific STM32 chip mounted on board. The -chips themselves are also very similar with the STM32F411RE having some -additional capability: - NucleoF411RE: - Microprocessor: 32-bit ARM Cortex M4 at 100MHz STM32F411RE @@ -30,8 +24,6 @@ NucleoF411RE: - CRC calculation unit - RTC -The NucleoF411RE also has additional DMA and SPI peripheral capabilities. - Board features, however, are identical: - Peripherals: 1 led, 1 push button @@ -41,8 +33,7 @@ Board features, however, are identical: Uses a STM32F103 to provide a ST-Link for programming, debug similar to the OpenOcd FTDI function - USB to JTAG front-end. -See http://mbed.org/platforms/ST-Nucleo-F401RE and -http://developer.mbed.org/platforms/ST-Nucleo-F411RE for more +See http://developer.mbed.org/platforms/ST-Nucleo-F411RE for more information about these boards. mbed @@ -50,17 +41,17 @@ mbed The Nucleo-F411RE includes boot loader from mbed: - https://mbed.org/platforms/ST-Nucleo-F401RE/ + https://mbed.org/platforms/ST-Nucleo-F411RE/ https://mbed.org/handbook/Homepage Using the mbed loader: -1. Connect the Nucleo-F4x1RE to the host PC using the USB connector. +1. Connect the Nucleo-F411RE to the host PC using the USB connector. 2. A new file system will appear called NUCLEO; open it with Windows Explorer (assuming that you are using Windows). 3. Drag and drop nuttx.bin into the MBED window. This will load the - nuttx.bin binary into the Nucleo-F4x1RE. The NUCLEO window will - close then re-open and the Nucleo-F4x1RE will be running the new code. + nuttx.bin binary into the Nucleo-F411RE. The NUCLEO window will + close then re-open and the Nucleo-F411RE will be running the new code. Hardware ======== @@ -82,7 +73,7 @@ GPIO LED2=D6=PB_10 I2C1_SDA=D14=PB_9 Probe D7=PA_8 I2C1_SCL=D15=PB_8 Probe - From: https://mbed.org/platforms/ST-Nucleo-F401RE/ + From: https://mbed.org/platforms/ST-Nucleo-F411RE/ Buttons ------- @@ -93,7 +84,7 @@ microcontroller. LEDs ---- -The Nucleo F401RE and Nucleo F411RE provide a single user LED, LD2. LD2 +The Nucleo F411RE provide a single user LED, LD2. LD2 is the green LED connected to Arduino signal D13 corresponding to MCU I/O PA5 (pin 21) or PB13 (pin 34) depending on the STM32target. @@ -141,7 +132,7 @@ pin selections. TTL to RS-232 converter connection:: - Nucleo CN10 STM32F4x1RE + Nucleo CN10 STM32F411RE ----------- ------------ Pin 21 PA9 USART1_RX *Warning you make need to reverse RX/TX on Pin 33 PA10 USART1_TX some RS-232 converters @@ -174,7 +165,7 @@ Pins and Connectors:: TTL to RS-232 converter connection:: - Nucleo CN9 STM32F4x1RE + Nucleo CN9 STM32F411RE ----------- ------------ Pin 1 PA3 USART2_RX *Warning you make need to reverse RX/TX on Pin 2 PA2 USART2_TX some RS-232 converters @@ -258,7 +249,7 @@ RS-232 from Cutedigi.com Supports a single RS-232 connected via:: - Nucleo CN9 STM32F4x1RE Cutedigi + Nucleo CN9 STM32F411RE Cutedigi ----------- ------------ -------- Pin 1 PA3 USART2_RX RXD Pin 2 PA2 USART2_TX TXD @@ -275,7 +266,7 @@ about this joystick. Itead Joystick Connection:: --------- ----------------- --------------------------------- - ARDUINO ITEAD NUCLEO-F4x1 + ARDUINO ITEAD NUCLEO-F411 PIN NAME SIGNAL SIGNAL --------- ----------------- --------------------------------- D3 Button E Output PB3 @@ -349,8 +340,8 @@ STATUS: Configurations ============== -f401-nsh: ---------- +nsh +--- Configures the NuttShell (nsh) located at apps/examples/nsh for the Nucleo-F401RE board. The Configuration enables the serial interfaces @@ -380,15 +371,9 @@ NOTES: Consoles). I have been using a TTL-to-RS-232 converter connected as shown below:: - Nucleo CN10 STM32F4x1RE + Nucleo CN10 STM32F411RE ----------- ------------ Pin 21 PA9 USART1_RX *Warning you make need to reverse RX/TX on Pin 33 PA10 USART1_TX some RS-232 converters Pin 20 GND Pin 8 U5V - -f411-nsh --------- - -This configuration is the same as the f401-nsh configuration, except -that it is configured to support the Nucleo-F411RE. diff --git a/boards/Kconfig b/boards/Kconfig index b870cd591955b..ac166752cc4c3 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -3391,7 +3391,8 @@ config ARCH_BOARD default "nucleo-f303re" if ARCH_BOARD_NUCLEO_F303RE default "nucleo-f303ze" if ARCH_BOARD_NUCLEO_F303ZE default "nucleo-f334r8" if ARCH_BOARD_NUCLEO_F334R8 - default "nucleo-f4x1re" if ARCH_BOARD_NUCLEO_F401RE || ARCH_BOARD_NUCLEO_F411RE + default "nucleo-f401re" if ARCH_BOARD_NUCLEO_F401RE + default "nucleo-f411re" if ARCH_BOARD_NUCLEO_F411RE default "stm32f401rc-rs485" if ARCH_BOARD_STM32F401RC_RS485 default "nucleo-f429zi" if ARCH_BOARD_NUCLEO_F429ZI default "nucleo-f446re" if ARCH_BOARD_NUCLEO_F446RE @@ -4190,8 +4191,11 @@ endif if ARCH_BOARD_NUCLEO_F446RE source "boards/arm/stm32/nucleo-f446re/Kconfig" endif -if ARCH_BOARD_NUCLEO_F401RE || ARCH_BOARD_NUCLEO_F411RE -source "boards/arm/stm32/nucleo-f4x1re/Kconfig" +if ARCH_BOARD_NUCLEO_F401RE +source "boards/arm/stm32/nucleo-f401re/Kconfig" +endif +if ARCH_BOARD_NUCLEO_F411RE +source "boards/arm/stm32/nucleo-f411re/Kconfig" endif if ARCH_BOARD_STM32F401RC_RS485 source "boards/arm/stm32/stm32f401rc-rs485/Kconfig" diff --git a/boards/arm/stm32/nucleo-f4x1re/CMakeLists.txt b/boards/arm/stm32/nucleo-f401re/CMakeLists.txt similarity index 95% rename from boards/arm/stm32/nucleo-f4x1re/CMakeLists.txt rename to boards/arm/stm32/nucleo-f401re/CMakeLists.txt index 7c6db43bc54e2..fc3725e660d65 100644 --- a/boards/arm/stm32/nucleo-f4x1re/CMakeLists.txt +++ b/boards/arm/stm32/nucleo-f401re/CMakeLists.txt @@ -1,5 +1,5 @@ # ############################################################################## -# boards/arm/stm32/nucleo-f4x1re/CMakeLists.txt +# boards/arm/stm32/nucleo-f401re/CMakeLists.txt # # SPDX-License-Identifier: Apache-2.0 # diff --git a/boards/arm/stm32/nucleo-f4x1re/Kconfig b/boards/arm/stm32/nucleo-f401re/Kconfig similarity index 100% rename from boards/arm/stm32/nucleo-f4x1re/Kconfig rename to boards/arm/stm32/nucleo-f401re/Kconfig diff --git a/boards/arm/stm32/nucleo-f4x1re/configs/f401-fb/defconfig b/boards/arm/stm32/nucleo-f401re/configs/fb/defconfig similarity index 97% rename from boards/arm/stm32/nucleo-f4x1re/configs/f401-fb/defconfig rename to boards/arm/stm32/nucleo-f401re/configs/fb/defconfig index 99a3d22d1092c..d0e8f3ccafc17 100644 --- a/boards/arm/stm32/nucleo-f4x1re/configs/f401-fb/defconfig +++ b/boards/arm/stm32/nucleo-f401re/configs/fb/defconfig @@ -12,7 +12,7 @@ # CONFIG_NSH_DISABLE_IFCONFIG is not set # CONFIG_NSH_DISABLE_PS is not set CONFIG_ARCH="arm" -CONFIG_ARCH_BOARD="nucleo-f4x1re" +CONFIG_ARCH_BOARD="nucleo-f401re" CONFIG_ARCH_BOARD_COMMON=y CONFIG_ARCH_BOARD_NUCLEO_F401RE=y CONFIG_ARCH_BUTTONS=y diff --git a/boards/arm/stm32/nucleo-f4x1re/configs/f401-nsh/defconfig b/boards/arm/stm32/nucleo-f401re/configs/nsh/defconfig similarity index 97% rename from boards/arm/stm32/nucleo-f4x1re/configs/f401-nsh/defconfig rename to boards/arm/stm32/nucleo-f401re/configs/nsh/defconfig index 62a6fab8775aa..e29dd5ce3bfbb 100644 --- a/boards/arm/stm32/nucleo-f4x1re/configs/f401-nsh/defconfig +++ b/boards/arm/stm32/nucleo-f401re/configs/nsh/defconfig @@ -11,7 +11,7 @@ # CONFIG_NSH_DISABLE_IFCONFIG is not set # CONFIG_NSH_DISABLE_PS is not set CONFIG_ARCH="arm" -CONFIG_ARCH_BOARD="nucleo-f4x1re" +CONFIG_ARCH_BOARD="nucleo-f401re" CONFIG_ARCH_BOARD_NUCLEO_F401RE=y CONFIG_ARCH_BUTTONS=y CONFIG_ARCH_CHIP="stm32" diff --git a/boards/arm/stm32/nucleo-f4x1re/include/nucleo-f401re.h b/boards/arm/stm32/nucleo-f401re/include/board.h similarity index 59% rename from boards/arm/stm32/nucleo-f4x1re/include/nucleo-f401re.h rename to boards/arm/stm32/nucleo-f401re/include/board.h index 0bac3bc2b8dd9..2db6874d6516a 100644 --- a/boards/arm/stm32/nucleo-f4x1re/include/nucleo-f401re.h +++ b/boards/arm/stm32/nucleo-f401re/include/board.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/include/nucleo-f401re.h + * boards/arm/stm32/nucleo-f401re/include/board.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_ARM_STM32_NUCLEO_F401RE_INCLUDE_NUCLEO_F401RE_H -#define __BOARDS_ARM_STM32_NUCLEO_F401RE_INCLUDE_NUCLEO_F401RE_H +#ifndef __BOARDS_ARM_STM32_NUCLEO_F401RE_INCLUDE_BOARD_H +#define __BOARDS_ARM_STM32_NUCLEO_F401RE_INCLUDE_BOARD_H /**************************************************************************** * Included Files @@ -208,29 +208,166 @@ # define SDIO_SDXFR_CLKDIV (3 << SDIO_CLKCR_CLKDIV_SHIFT) #endif -/**************************************************************************** - * Public Data - ****************************************************************************/ +/* DMA Channel/Stream Selections ********************************************/ -#ifndef __ASSEMBLY__ +/* Stream selections are arbitrary for now but might become important in + * the future is we set aside more DMA channels/streams. + * + * SDIO DMA + *   DMAMAP_SDIO_1 = Channel 4, Stream 3 <- may later be used by SPI DMA + *   DMAMAP_SDIO_2 = Channel 4, Stream 6 + */ + +#define DMAMAP_SDIO DMAMAP_SDIO_1 -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" -{ +/* Need to VERIFY fwb */ + +#define DMACHAN_SPI1_RX DMAMAP_SPI1_RX_1 +#define DMACHAN_SPI1_TX DMAMAP_SPI1_TX_1 +#define DMACHAN_SPI2_RX DMAMAP_SPI2_RX +#define DMACHAN_SPI2_TX DMAMAP_SPI2_TX + +/* Alternate function pin selections ****************************************/ + +/* USART1: + * RXD: PA10 CN9 pin 3, CN10 pin 33 + * PB7 CN7 pin 21 + * TXD: PA9 CN5 pin 1, CN10 pin 21 + * PB6 CN5 pin 3, CN10 pin 17 + */ + +#if 1 +# define GPIO_USART1_RX GPIO_USART1_RX_1 /* PA10 */ +# define GPIO_USART1_TX GPIO_USART1_TX_1 /* PA9 */ #else -#define EXTERN extern +# define GPIO_USART1_RX GPIO_USART1_RX_2 /* PB7 */ +# define GPIO_USART1_TX GPIO_USART1_TX_2 /* PB6 */ #endif -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ +/* USART2: + * RXD: PA3 CN9 pin 1 (See SB13, 14, 62, 63). CN10 pin 37 + * PD6 + * TXD: PA2 CN9 pin 2(See SB13, 14, 62, 63). CN10 pin 35 + * PD5 + */ -#undef EXTERN -#if defined(__cplusplus) -} -#endif +#define GPIO_USART2_RX GPIO_USART2_RX_1 /* PA3 */ +#define GPIO_USART2_TX GPIO_USART2_TX_1 /* PA2 */ +#define GPIO_USART2_RTS GPIO_USART2_RTS_2 +#define GPIO_USART2_CTS GPIO_USART2_CTS_2 + +/* USART6: + * RXD: PC7 CN5 pin2, CN10 pin 19 + * PA12 CN10, pin 12 + * TXD: PC6 CN10, pin 4 + * PA11 CN10, pin 14 + */ + +#define GPIO_USART6_RX GPIO_USART6_RX_1 /* PC7 */ +#define GPIO_USART6_TX GPIO_USART6_TX_1 /* PC6 */ + +/* UART RX DMA configurations */ + +#define DMAMAP_USART1_RX DMAMAP_USART1_RX_2 +#define DMAMAP_USART6_RX DMAMAP_USART6_RX_2 + +/* I2C + * + * The optional _GPIO configurations allow the I2C driver to manually + * reset the bus to clear stuck slaves. They match the pin configuration, + * but are normally-high GPIOs. + */ + +#define GPIO_I2C1_SCL GPIO_I2C1_SCL_2 +#define GPIO_I2C1_SDA GPIO_I2C1_SDA_2 +#define GPIO_I2C1_SCL_GPIO \ + (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN8) +#define GPIO_I2C1_SDA_GPIO \ + (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN9) + +#define GPIO_I2C2_SCL GPIO_I2C2_SCL_1 +#define GPIO_I2C2_SDA GPIO_I2C2_SDA_1 +#define GPIO_I2C2_SCL_GPIO \ + (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN10) +#define GPIO_I2C2_SDA_GPIO \ + (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN11) + +/* SPI + * + * There are sensors on SPI1, and SPI2 is connected to the FRAM. + */ + +#define GPIO_SPI1_MISO GPIO_SPI1_MISO_1 +#define GPIO_SPI1_MOSI GPIO_SPI1_MOSI_1 +#define GPIO_SPI1_SCK GPIO_SPI1_SCK_1 + +#define GPIO_SPI2_MISO GPIO_SPI2_MISO_1 +#define GPIO_SPI2_MOSI GPIO_SPI2_MOSI_1 +#define GPIO_SPI2_SCK GPIO_SPI2_SCK_2 + +/* LEDs + * + * The Nucleo F401RE board provide a single user LED, LD2. LD2 + * is the green LED connected to Arduino signal D13 corresponding to MCU I/O + * PA5 (pin 21) or PB13 (pin 34) depending on the STM32 target. + * + * - When the I/O is HIGH value, the LED is on. + * - When the I/O is LOW, the LED is off. + */ + +/* LED index values for use with board_userled() */ + +#define BOARD_LD2 0 +#define BOARD_NLEDS 1 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LD2_BIT (1 << BOARD_LD2) + +/* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is + * defined. In that case, the usage by the board port is defined in + * include/board.h and src/sam_leds.c. The LEDs are used to encode OS-related + * events as follows when the red LED (PE24) is available: + * + * SYMBOL Meaning LD2 + * ------------------- ----------------------- ----------- + * LED_STARTED NuttX has been started OFF + * LED_HEAPALLOCATE Heap has been allocated OFF + * LED_IRQSENABLED Interrupts enabled OFF + * LED_STACKCREATED Idle stack created ON + * LED_INIRQ In an interrupt No change + * LED_SIGNAL In a signal handler No change + * LED_ASSERTION An assertion failed No change + * LED_PANIC The system has crashed Blinking + * LED_IDLE MCU is is sleep mode Not used + * + * Thus if LD2, NuttX has successfully booted and is, apparently, running + * normally. If LD2 is flashing at approximately 2Hz, then a fatal error + * has been detected and the system has halted. + */ + +#define LED_STARTED 0 +#define LED_HEAPALLOCATE 0 +#define LED_IRQSENABLED 0 +#define LED_STACKCREATED 1 +#define LED_INIRQ 2 +#define LED_SIGNAL 2 +#define LED_ASSERTION 2 +#define LED_PANIC 1 + +/* Buttons + * + * B1 USER: + * the user button is connected to the I/O PC13 (pin 2) of the STM32 + * microcontroller. + */ + +#define BUTTON_USER 0 +#define NUM_BUTTONS 1 + +#define BUTTON_USER_BIT (1 << BUTTON_USER) + +#define GPIO_TIM2_CH1IN (GPIO_TIM2_CH1IN_1 | GPIO_PULLUP) +#define GPIO_TIM2_CH2IN (GPIO_TIM2_CH2IN_1 | GPIO_PULLUP) -#endif /* __ASSEMBLY__ */ -#endif /* __BOARDS_ARM_STM32_NUCLEO_F401RE_INCLUDE_NUCLEO_F401RE_H */ +#endif /* __BOARDS_ARM_STM32_NUCLEO_F401RE_INCLUDE_BOARD_H */ diff --git a/boards/arm/stm32/nucleo-f4x1re/scripts/Make.defs b/boards/arm/stm32/nucleo-f401re/scripts/Make.defs similarity index 90% rename from boards/arm/stm32/nucleo-f4x1re/scripts/Make.defs rename to boards/arm/stm32/nucleo-f401re/scripts/Make.defs index 780bd120a13e9..a106e21e6af79 100644 --- a/boards/arm/stm32/nucleo-f4x1re/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-f401re/scripts/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/stm32/nucleo-f4x1re/scripts/Make.defs +# boards/arm/stm32/nucleo-f401re/scripts/Make.defs # # SPDX-License-Identifier: Apache-2.0 # @@ -24,11 +24,7 @@ include $(TOPDIR)/.config include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs -ifeq ($(CONFIG_ARCH_CHIP_STM32F401RE),y) -LDSCRIPT = f401re.ld -else ifeq ($(CONFIG_ARCH_CHIP_STM32F411RE),y) -LDSCRIPT = f411re.ld -endif +LDSCRIPT = flash.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) diff --git a/boards/arm/stm32/nucleo-f4x1re/scripts/f401re.ld b/boards/arm/stm32/nucleo-f401re/scripts/flash.ld similarity index 98% rename from boards/arm/stm32/nucleo-f4x1re/scripts/f401re.ld rename to boards/arm/stm32/nucleo-f401re/scripts/flash.ld index 8992ad490aa67..baa6ff5ad1523 100644 --- a/boards/arm/stm32/nucleo-f4x1re/scripts/f401re.ld +++ b/boards/arm/stm32/nucleo-f401re/scripts/flash.ld @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/scripts/f401re.ld + * boards/arm/stm32/nucleo-f401re/scripts/flash.ld * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/arm/stm32/nucleo-f4x1re/src/CMakeLists.txt b/boards/arm/stm32/nucleo-f401re/src/CMakeLists.txt similarity index 84% rename from boards/arm/stm32/nucleo-f4x1re/src/CMakeLists.txt rename to boards/arm/stm32/nucleo-f401re/src/CMakeLists.txt index d7db323a0677d..804ea88612de0 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/CMakeLists.txt +++ b/boards/arm/stm32/nucleo-f401re/src/CMakeLists.txt @@ -1,5 +1,5 @@ # ############################################################################## -# boards/arm/stm32/nucleo-f4x1re/src/CMakeLists.txt +# boards/arm/stm32/nucleo-f401re/src/CMakeLists.txt # # SPDX-License-Identifier: Apache-2.0 # @@ -55,8 +55,4 @@ endif() target_sources(board PRIVATE ${SRCS}) -if(CONFIG_ARCH_CHIP_STM32F401RE) - set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/f401re.ld") -elseif(CONFIG_ARCH_CHIP_STM32F411RE) - set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/f411re.ld") -endif() +set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld") diff --git a/boards/arm/stm32/nucleo-f4x1re/src/Make.defs b/boards/arm/stm32/nucleo-f401re/src/Make.defs similarity index 97% rename from boards/arm/stm32/nucleo-f4x1re/src/Make.defs rename to boards/arm/stm32/nucleo-f401re/src/Make.defs index cefced9d60823..372f00f24830c 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/Make.defs +++ b/boards/arm/stm32/nucleo-f401re/src/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/stm32/nucleo-f4x1re/src/Make.defs +# boards/arm/stm32/nucleo-f401re/src/Make.defs # # SPDX-License-Identifier: Apache-2.0 # diff --git a/boards/arm/stm32/nucleo-f4x1re/src/nucleo-f4x1re.h b/boards/arm/stm32/nucleo-f401re/src/nucleo-f401re.h similarity index 99% rename from boards/arm/stm32/nucleo-f4x1re/src/nucleo-f4x1re.h rename to boards/arm/stm32/nucleo-f401re/src/nucleo-f401re.h index 8683f29c1a19a..976fca4a406b0 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/nucleo-f4x1re.h +++ b/boards/arm/stm32/nucleo-f401re/src/nucleo-f401re.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/src/nucleo-f4x1re.h + * boards/arm/stm32/nucleo-f401re/src/nucleo-f401re.h * * SPDX-License-Identifier: Apache-2.0 * @@ -143,7 +143,7 @@ * about this joystick. * * --------- ----------------- --------------------------------- - * ARDUINO ITEAD NUCLEO-F4x1 + * ARDUINO ITEAD NUCLEO-F401 * PIN NAME SIGNAL SIGNAL * --------- ----------------- --------------------------------- * D3 Button E Output PB3 diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_adc.c b/boards/arm/stm32/nucleo-f401re/src/stm32_adc.c similarity index 97% rename from boards/arm/stm32/nucleo-f4x1re/src/stm32_adc.c rename to boards/arm/stm32/nucleo-f401re/src/stm32_adc.c index e693f7621c6a6..426061b6eb525 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_adc.c +++ b/boards/arm/stm32/nucleo-f401re/src/stm32_adc.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/src/stm32_adc.c + * boards/arm/stm32/nucleo-f401re/src/stm32_adc.c * * SPDX-License-Identifier: Apache-2.0 * @@ -35,7 +35,7 @@ #include "chip.h" #include "arm_internal.h" #include "stm32_adc.h" -#include "nucleo-f4x1re.h" +#include "nucleo-f401re.h" #include diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_ajoystick.c b/boards/arm/stm32/nucleo-f401re/src/stm32_ajoystick.c similarity index 99% rename from boards/arm/stm32/nucleo-f4x1re/src/stm32_ajoystick.c rename to boards/arm/stm32/nucleo-f401re/src/stm32_ajoystick.c index 13993a5c64ae9..cbad8b5e1ce9e 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_ajoystick.c +++ b/boards/arm/stm32/nucleo-f401re/src/stm32_ajoystick.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/src/stm32_ajoystick.c + * boards/arm/stm32/nucleo-f401re/src/stm32_ajoystick.c * * SPDX-License-Identifier: Apache-2.0 * @@ -40,7 +40,7 @@ #include "stm32_gpio.h" #include "stm32_adc.h" #include "hardware/stm32_adc.h" -#include "nucleo-f4x1re.h" +#include "nucleo-f401re.h" /**************************************************************************** * Pre-processor Definitions diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_appinit.c b/boards/arm/stm32/nucleo-f401re/src/stm32_appinit.c similarity index 97% rename from boards/arm/stm32/nucleo-f4x1re/src/stm32_appinit.c rename to boards/arm/stm32/nucleo-f401re/src/stm32_appinit.c index 0f56e20c2ec8a..b1562d2d4af63 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_appinit.c +++ b/boards/arm/stm32/nucleo-f401re/src/stm32_appinit.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/src/stm32_appinit.c + * boards/arm/stm32/nucleo-f401re/src/stm32_appinit.c * * SPDX-License-Identifier: Apache-2.0 * @@ -29,7 +29,7 @@ #include #include -#include "nucleo-f4x1re.h" +#include "nucleo-f401re.h" #include diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_autoleds.c b/boards/arm/stm32/nucleo-f401re/src/stm32_autoleds.c similarity index 96% rename from boards/arm/stm32/nucleo-f4x1re/src/stm32_autoleds.c rename to boards/arm/stm32/nucleo-f401re/src/stm32_autoleds.c index 02c875f866cc6..dd8cc76628be7 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_autoleds.c +++ b/boards/arm/stm32/nucleo-f401re/src/stm32_autoleds.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/src/stm32_autoleds.c + * boards/arm/stm32/nucleo-f401re/src/stm32_autoleds.c * * SPDX-License-Identifier: Apache-2.0 * @@ -35,7 +35,7 @@ #include "chip.h" #include "arm_internal.h" #include "stm32.h" -#include "nucleo-f4x1re.h" +#include "nucleo-f401re.h" #include diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_boot.c b/boards/arm/stm32/nucleo-f401re/src/stm32_boot.c similarity index 97% rename from boards/arm/stm32/nucleo-f4x1re/src/stm32_boot.c rename to boards/arm/stm32/nucleo-f401re/src/stm32_boot.c index 52eb2163de0bf..f46b1ed78137a 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_boot.c +++ b/boards/arm/stm32/nucleo-f401re/src/stm32_boot.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/src/stm32_boot.c + * boards/arm/stm32/nucleo-f401re/src/stm32_boot.c * * SPDX-License-Identifier: Apache-2.0 * @@ -34,7 +34,7 @@ #include #include "arm_internal.h" -#include "nucleo-f4x1re.h" +#include "nucleo-f401re.h" #include diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_bringup.c b/boards/arm/stm32/nucleo-f401re/src/stm32_bringup.c similarity index 98% rename from boards/arm/stm32/nucleo-f4x1re/src/stm32_bringup.c rename to boards/arm/stm32/nucleo-f401re/src/stm32_bringup.c index 3193bd4b45473..b1daccc915b78 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_bringup.c +++ b/boards/arm/stm32/nucleo-f401re/src/stm32_bringup.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/src/stm32_bringup.c + * boards/arm/stm32/nucleo-f401re/src/stm32_bringup.c * * SPDX-License-Identifier: Apache-2.0 * @@ -47,7 +47,7 @@ # include #endif -#include "nucleo-f4x1re.h" +#include "nucleo-f401re.h" #include diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_buttons.c b/boards/arm/stm32/nucleo-f401re/src/stm32_buttons.c similarity index 98% rename from boards/arm/stm32/nucleo-f4x1re/src/stm32_buttons.c rename to boards/arm/stm32/nucleo-f401re/src/stm32_buttons.c index d745997f2441e..b0a02f7a879d7 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_buttons.c +++ b/boards/arm/stm32/nucleo-f401re/src/stm32_buttons.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/src/stm32_buttons.c + * boards/arm/stm32/nucleo-f401re/src/stm32_buttons.c * * SPDX-License-Identifier: Apache-2.0 * @@ -33,7 +33,7 @@ #include #include "stm32_gpio.h" -#include "nucleo-f4x1re.h" +#include "nucleo-f401re.h" #include diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_lcd_ssd1306.c b/boards/arm/stm32/nucleo-f401re/src/stm32_lcd_ssd1306.c similarity index 97% rename from boards/arm/stm32/nucleo-f4x1re/src/stm32_lcd_ssd1306.c rename to boards/arm/stm32/nucleo-f401re/src/stm32_lcd_ssd1306.c index 2bf821953021e..9bee0a0317563 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_lcd_ssd1306.c +++ b/boards/arm/stm32/nucleo-f401re/src/stm32_lcd_ssd1306.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/src/stm32_lcd_ssd1306.c + * boards/arm/stm32/nucleo-f401re/src/stm32_lcd_ssd1306.c * * SPDX-License-Identifier: Apache-2.0 * @@ -33,7 +33,7 @@ #include #include "stm32.h" -#include "nucleo-f4x1re.h" +#include "nucleo-f401re.h" #include "stm32_ssd1306.h" diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_mcp2515.c b/boards/arm/stm32/nucleo-f401re/src/stm32_mcp2515.c similarity index 98% rename from boards/arm/stm32/nucleo-f4x1re/src/stm32_mcp2515.c rename to boards/arm/stm32/nucleo-f401re/src/stm32_mcp2515.c index 4806158cdc1fb..e8c490e4d94f9 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_mcp2515.c +++ b/boards/arm/stm32/nucleo-f401re/src/stm32_mcp2515.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/src/stm32_mcp2515.c + * boards/arm/stm32/nucleo-f401re/src/stm32_mcp2515.c * * SPDX-License-Identifier: Apache-2.0 * @@ -35,7 +35,7 @@ #include "stm32.h" #include "stm32_spi.h" -#include "nucleo-f4x1re.h" +#include "nucleo-f401re.h" #if defined(CONFIG_SPI) && defined(CONFIG_STM32_SPI1) && \ defined(CONFIG_CAN_MCP2515) diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_spi.c b/boards/arm/stm32/nucleo-f401re/src/stm32_spi.c similarity index 98% rename from boards/arm/stm32/nucleo-f4x1re/src/stm32_spi.c rename to boards/arm/stm32/nucleo-f401re/src/stm32_spi.c index 1e2aadac222b9..fd839614221af 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_spi.c +++ b/boards/arm/stm32/nucleo-f401re/src/stm32_spi.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/src/stm32_spi.c + * boards/arm/stm32/nucleo-f401re/src/stm32_spi.c * * SPDX-License-Identifier: Apache-2.0 * @@ -37,7 +37,7 @@ #include "chip.h" #include "stm32.h" -#include "nucleo-f4x1re.h" +#include "nucleo-f401re.h" #include @@ -65,8 +65,7 @@ struct spi_dev_s *g_spi2; * Name: stm32_spidev_initialize * * Description: - * Called to configure SPI chip select GPIO pins for the Nucleo-F401RE and - * Nucleo-F411RE boards. + * Called to configure SPI chip select GPIO pins for the Nucleo-F401RE * ****************************************************************************/ diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_userleds.c b/boards/arm/stm32/nucleo-f401re/src/stm32_userleds.c similarity index 98% rename from boards/arm/stm32/nucleo-f4x1re/src/stm32_userleds.c rename to boards/arm/stm32/nucleo-f401re/src/stm32_userleds.c index dd25e5f692965..e85b48cbbb8d7 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_userleds.c +++ b/boards/arm/stm32/nucleo-f401re/src/stm32_userleds.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/src/stm32_userleds.c + * boards/arm/stm32/nucleo-f401re/src/stm32_userleds.c * * SPDX-License-Identifier: Apache-2.0 * @@ -36,7 +36,7 @@ #include "chip.h" #include "arm_internal.h" #include "stm32.h" -#include "nucleo-f4x1re.h" +#include "nucleo-f401re.h" #include diff --git a/boards/arm/stm32/nucleo-f411re/CMakeLists.txt b/boards/arm/stm32/nucleo-f411re/CMakeLists.txt new file mode 100644 index 0000000000000..53fe0025e449b --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/CMakeLists.txt @@ -0,0 +1,23 @@ +# ############################################################################## +# boards/arm/stm32/nucleo-f411re/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +add_subdirectory(src) diff --git a/boards/arm/stm32/nucleo-f411re/Kconfig b/boards/arm/stm32/nucleo-f411re/Kconfig new file mode 100644 index 0000000000000..d8f9cca70a587 --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/Kconfig @@ -0,0 +1,25 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_NUCLEO_F411RE + +config NUCLEO_F411RE_QETIMER + int "Timer to use with QE encoder" + default 3 + depends on SENSORS_QENCODER + +config NUCLEO_F411RE_AJOY_MINBUTTONS + bool "Minimal Joystick Buttons" + default STM32_USART1 + depends on INPUT_AJOYSTICK + ---help--- + The Itead Joystick shield supports analog X/Y position and up to 5 + buttons. Some of these buttons may conflict with other resources + (Button F, for example, conflicts with the default USART1 pin usage). + Selecting this option will return the number of buttons to the + minimal set: SELECT (joystick down), FIRE (BUTTON B), and JUMP + (BUTTON A). + +endif # ARCH_BOARD_NUCLEO_F411RE diff --git a/boards/arm/stm32/nucleo-f4x1re/configs/f411-mcp2515-extid/defconfig b/boards/arm/stm32/nucleo-f411re/configs/mcp2515-extid/defconfig similarity index 97% rename from boards/arm/stm32/nucleo-f4x1re/configs/f411-mcp2515-extid/defconfig rename to boards/arm/stm32/nucleo-f411re/configs/mcp2515-extid/defconfig index 9a48f82f22f1d..e7853127320e5 100644 --- a/boards/arm/stm32/nucleo-f4x1re/configs/f411-mcp2515-extid/defconfig +++ b/boards/arm/stm32/nucleo-f411re/configs/mcp2515-extid/defconfig @@ -11,7 +11,7 @@ # CONFIG_NSH_DISABLE_IFCONFIG is not set # CONFIG_NSH_DISABLE_PS is not set CONFIG_ARCH="arm" -CONFIG_ARCH_BOARD="nucleo-f4x1re" +CONFIG_ARCH_BOARD="nucleo-f411re" CONFIG_ARCH_BOARD_NUCLEO_F411RE=y CONFIG_ARCH_BUTTONS=y CONFIG_ARCH_CHIP="stm32" diff --git a/boards/arm/stm32/nucleo-f4x1re/configs/f411-nsh/defconfig b/boards/arm/stm32/nucleo-f411re/configs/nsh/defconfig similarity index 97% rename from boards/arm/stm32/nucleo-f4x1re/configs/f411-nsh/defconfig rename to boards/arm/stm32/nucleo-f411re/configs/nsh/defconfig index 886bb96aa804d..ea0120452e4a6 100644 --- a/boards/arm/stm32/nucleo-f4x1re/configs/f411-nsh/defconfig +++ b/boards/arm/stm32/nucleo-f411re/configs/nsh/defconfig @@ -11,7 +11,7 @@ # CONFIG_NSH_DISABLE_IFCONFIG is not set # CONFIG_NSH_DISABLE_PS is not set CONFIG_ARCH="arm" -CONFIG_ARCH_BOARD="nucleo-f4x1re" +CONFIG_ARCH_BOARD="nucleo-f411re" CONFIG_ARCH_BOARD_NUCLEO_F411RE=y CONFIG_ARCH_BUTTONS=y CONFIG_ARCH_CHIP="stm32" diff --git a/boards/arm/stm32/nucleo-f4x1re/include/nucleo-f411re.h b/boards/arm/stm32/nucleo-f411re/include/board.h similarity index 58% rename from boards/arm/stm32/nucleo-f4x1re/include/nucleo-f411re.h rename to boards/arm/stm32/nucleo-f411re/include/board.h index 506d45835c1ff..c036fece691b9 100644 --- a/boards/arm/stm32/nucleo-f4x1re/include/nucleo-f411re.h +++ b/boards/arm/stm32/nucleo-f411re/include/board.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/include/nucleo-f411re.h + * boards/arm/stm32/nucleo-f411re/include/board.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_ARM_STM32_NUCLEO_F401RE_INCLUDE_NUCLEO_F411RE_H -#define __BOARDS_ARM_STM32_NUCLEO_F401RE_INCLUDE_NUCLEO_F411RE_H +#ifndef __BOARDS_ARM_STM32_NUCLEO_F411RE_INCLUDE_BOARD_H +#define __BOARDS_ARM_STM32_NUCLEO_F411RE_INCLUDE_BOARD_H /**************************************************************************** * Included Files @@ -205,29 +205,166 @@ # define SDIO_SDXFR_CLKDIV (3 << SDIO_CLKCR_CLKDIV_SHIFT) #endif -/**************************************************************************** - * Public Data - ****************************************************************************/ +/* DMA Channel/Stream Selections ********************************************/ -#ifndef __ASSEMBLY__ +/* Stream selections are arbitrary for now but might become important in + * the future is we set aside more DMA channels/streams. + * + * SDIO DMA + *   DMAMAP_SDIO_1 = Channel 4, Stream 3 <- may later be used by SPI DMA + *   DMAMAP_SDIO_2 = Channel 4, Stream 6 + */ + +#define DMAMAP_SDIO DMAMAP_SDIO_1 -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" -{ +/* Need to VERIFY fwb */ + +#define DMACHAN_SPI1_RX DMAMAP_SPI1_RX_1 +#define DMACHAN_SPI1_TX DMAMAP_SPI1_TX_1 +#define DMACHAN_SPI2_RX DMAMAP_SPI2_RX +#define DMACHAN_SPI2_TX DMAMAP_SPI2_TX + +/* Alternate function pin selections ****************************************/ + +/* USART1: + * RXD: PA10 CN9 pin 3, CN10 pin 33 + * PB7 CN7 pin 21 + * TXD: PA9 CN5 pin 1, CN10 pin 21 + * PB6 CN5 pin 3, CN10 pin 17 + */ + +#if 1 +# define GPIO_USART1_RX GPIO_USART1_RX_1 /* PA10 */ +# define GPIO_USART1_TX GPIO_USART1_TX_1 /* PA9 */ #else -#define EXTERN extern +# define GPIO_USART1_RX GPIO_USART1_RX_2 /* PB7 */ +# define GPIO_USART1_TX GPIO_USART1_TX_2 /* PB6 */ #endif -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ +/* USART2: + * RXD: PA3 CN9 pin 1 (See SB13, 14, 62, 63). CN10 pin 37 + * PD6 + * TXD: PA2 CN9 pin 2(See SB13, 14, 62, 63). CN10 pin 35 + * PD5 + */ -#undef EXTERN -#if defined(__cplusplus) -} -#endif +#define GPIO_USART2_RX GPIO_USART2_RX_1 /* PA3 */ +#define GPIO_USART2_TX GPIO_USART2_TX_1 /* PA2 */ +#define GPIO_USART2_RTS GPIO_USART2_RTS_2 +#define GPIO_USART2_CTS GPIO_USART2_CTS_2 + +/* USART6: + * RXD: PC7 CN5 pin2, CN10 pin 19 + * PA12 CN10, pin 12 + * TXD: PC6 CN10, pin 4 + * PA11 CN10, pin 14 + */ + +#define GPIO_USART6_RX GPIO_USART6_RX_1 /* PC7 */ +#define GPIO_USART6_TX GPIO_USART6_TX_1 /* PC6 */ + +/* UART RX DMA configurations */ + +#define DMAMAP_USART1_RX DMAMAP_USART1_RX_2 +#define DMAMAP_USART6_RX DMAMAP_USART6_RX_2 + +/* I2C + * + * The optional _GPIO configurations allow the I2C driver to manually + * reset the bus to clear stuck slaves. They match the pin configuration, + * but are normally-high GPIOs. + */ + +#define GPIO_I2C1_SCL GPIO_I2C1_SCL_2 +#define GPIO_I2C1_SDA GPIO_I2C1_SDA_2 +#define GPIO_I2C1_SCL_GPIO \ + (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN8) +#define GPIO_I2C1_SDA_GPIO \ + (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN9) + +#define GPIO_I2C2_SCL GPIO_I2C2_SCL_1 +#define GPIO_I2C2_SDA GPIO_I2C2_SDA_1 +#define GPIO_I2C2_SCL_GPIO \ + (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN10) +#define GPIO_I2C2_SDA_GPIO \ + (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN11) + +/* SPI + * + * There are sensors on SPI1, and SPI2 is connected to the FRAM. + */ + +#define GPIO_SPI1_MISO GPIO_SPI1_MISO_1 +#define GPIO_SPI1_MOSI GPIO_SPI1_MOSI_1 +#define GPIO_SPI1_SCK GPIO_SPI1_SCK_1 + +#define GPIO_SPI2_MISO GPIO_SPI2_MISO_1 +#define GPIO_SPI2_MOSI GPIO_SPI2_MOSI_1 +#define GPIO_SPI2_SCK GPIO_SPI2_SCK_2 + +/* LEDs + * + * The Nucleo F411RE board provide a single user LED, LD2. LD2 + * is the green LED connected to Arduino signal D13 corresponding to MCU I/O + * PA5 (pin 21) or PB13 (pin 34) depending on the STM32 target. + * + * - When the I/O is HIGH value, the LED is on. + * - When the I/O is LOW, the LED is off. + */ + +/* LED index values for use with board_userled() */ + +#define BOARD_LD2 0 +#define BOARD_NLEDS 1 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LD2_BIT (1 << BOARD_LD2) + +/* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is + * defined. In that case, the usage by the board port is defined in + * include/board.h and src/sam_leds.c. The LEDs are used to encode OS-related + * events as follows when the red LED (PE24) is available: + * + * SYMBOL Meaning LD2 + * ------------------- ----------------------- ----------- + * LED_STARTED NuttX has been started OFF + * LED_HEAPALLOCATE Heap has been allocated OFF + * LED_IRQSENABLED Interrupts enabled OFF + * LED_STACKCREATED Idle stack created ON + * LED_INIRQ In an interrupt No change + * LED_SIGNAL In a signal handler No change + * LED_ASSERTION An assertion failed No change + * LED_PANIC The system has crashed Blinking + * LED_IDLE MCU is is sleep mode Not used + * + * Thus if LD2, NuttX has successfully booted and is, apparently, running + * normally. If LD2 is flashing at approximately 2Hz, then a fatal error + * has been detected and the system has halted. + */ + +#define LED_STARTED 0 +#define LED_HEAPALLOCATE 0 +#define LED_IRQSENABLED 0 +#define LED_STACKCREATED 1 +#define LED_INIRQ 2 +#define LED_SIGNAL 2 +#define LED_ASSERTION 2 +#define LED_PANIC 1 + +/* Buttons + * + * B1 USER: + * the user button is connected to the I/O PC13 (pin 2) of the STM32 + * microcontroller. + */ + +#define BUTTON_USER 0 +#define NUM_BUTTONS 1 + +#define BUTTON_USER_BIT (1 << BUTTON_USER) + +#define GPIO_TIM2_CH1IN (GPIO_TIM2_CH1IN_1 | GPIO_PULLUP) +#define GPIO_TIM2_CH2IN (GPIO_TIM2_CH2IN_1 | GPIO_PULLUP) -#endif /* __ASSEMBLY__ */ -#endif /* __BOARDS_ARM_STM32_NUCLEO_F401RE_INCLUDE_NUCLEO_F411RE_H */ +#endif /* __BOARDS_ARM_STM32_NUCLEO_F411RE_INCLUDE_BOARD_H */ diff --git a/boards/arm/stm32/nucleo-f411re/scripts/Make.defs b/boards/arm/stm32/nucleo-f411re/scripts/Make.defs new file mode 100644 index 0000000000000..88f77e2be62d9 --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/scripts/Make.defs @@ -0,0 +1,43 @@ +############################################################################ +# boards/arm/stm32/nucleo-f411re/scripts/Make.defs +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs + +LDSCRIPT = flash.ld + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + diff --git a/boards/arm/stm32/nucleo-f4x1re/scripts/f411re.ld b/boards/arm/stm32/nucleo-f411re/scripts/flash.ld similarity index 98% rename from boards/arm/stm32/nucleo-f4x1re/scripts/f411re.ld rename to boards/arm/stm32/nucleo-f411re/scripts/flash.ld index 9b4c82898a151..03d21e681802d 100644 --- a/boards/arm/stm32/nucleo-f4x1re/scripts/f411re.ld +++ b/boards/arm/stm32/nucleo-f411re/scripts/flash.ld @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/scripts/f411re.ld + * boards/arm/stm32/nucleo-f411re/scripts/flash.ld * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/arm/stm32/nucleo-f411re/src/CMakeLists.txt b/boards/arm/stm32/nucleo-f411re/src/CMakeLists.txt new file mode 100644 index 0000000000000..112eee3d55e3e --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/CMakeLists.txt @@ -0,0 +1,58 @@ +# ############################################################################## +# boards/arm/stm32/nucleo-f411re/src/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +set(SRCS stm32_boot.c stm32_spi.c stm32_bringup.c) + +if(CONFIG_VIDEO_FB) + if(CONFIG_LCD_SSD1306) + list(APPEND SRCS stm32_lcd_ssd1306.c) + endif() +endif() + +if(CONFIG_ARCH_LEDS) + list(APPEND SRCS stm32_autoleds.c) +else() + list(APPEND SRCS stm32_userleds.c) +endif() + +if(CONFIG_ARCH_BUTTONS) + list(APPEND SRCS stm32_buttons.c) +endif() + +if(CONFIG_ADC) + list(APPEND SRCS stm32_adc.c) + if(CONFIG_INPUT_AJOYSTICK) + list(APPEND SRCS stm32_ajoystick.c) + endif() +endif() + +if(CONFIG_CAN_MCP2515) + list(APPEND SRCS stm32_mcp2515.c) +endif() + +if(CONFIG_BOARDCTL) + list(APPEND SRCS stm32_appinit.c) +endif() + +target_sources(board PRIVATE ${SRCS}) + +set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld") diff --git a/boards/arm/stm32/nucleo-f411re/src/Make.defs b/boards/arm/stm32/nucleo-f411re/src/Make.defs new file mode 100644 index 0000000000000..20c1fcb2be2ad --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/Make.defs @@ -0,0 +1,60 @@ +############################################################################ +# boards/arm/stm32/nucleo-f411re/src/Make.defs +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/Make.defs + +CSRCS = stm32_boot.c stm32_spi.c stm32_bringup.c + +ifeq ($(CONFIG_VIDEO_FB),y) +ifeq ($(CONFIG_LCD_SSD1306),y) + CSRCS += stm32_lcd_ssd1306.c +endif +endif + +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += stm32_autoleds.c +else +CSRCS += stm32_userleds.c +endif + +ifeq ($(CONFIG_ARCH_BUTTONS),y) +CSRCS += stm32_buttons.c +endif + +ifeq ($(CONFIG_ADC),y) +CSRCS += stm32_adc.c +ifeq ($(CONFIG_INPUT_AJOYSTICK),y) +CSRCS += stm32_ajoystick.c +endif +endif + +ifeq ($(CONFIG_CAN_MCP2515),y) + CSRCS += stm32_mcp2515.c +endif + +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += stm32_appinit.c +endif + +DEPPATH += --dep-path board +VPATH += :board +CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board diff --git a/boards/arm/stm32/nucleo-f411re/src/nucleo-f411re.h b/boards/arm/stm32/nucleo-f411re/src/nucleo-f411re.h new file mode 100644 index 0000000000000..88f6fdce853b6 --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/nucleo-f411re.h @@ -0,0 +1,311 @@ +/**************************************************************************** + * boards/arm/stm32/nucleo-f411re/src/nucleo-f411re.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_STM32_NUCLEO_F411RE_SRC_NUCLEO_F411RE_H +#define __BOARDS_ARM_STM32_NUCLEO_F411RE_SRC_NUCLEO_F411RE_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +#define HAVE_MMCSD 1 +#if !defined(CONFIG_STM32_SDIO) || !defined(CONFIG_MMCSD) || \ + !defined(CONFIG_MMCSD_SDIO) +# undef HAVE_MMCSD +#endif + +/* LED. User LD2: the green LED is a user LED connected to Arduino signal + * D13 corresponding to MCU I/O PA5 (pin 21) or PB13 (pin 34) depending on + * the STM32 target. + * + * - When the I/O is HIGH value, the LED is on. + * - When the I/O is LOW, the LED is off. + */ + +#define GPIO_LD2 \ + (GPIO_PORTA | GPIO_PIN5 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | \ + GPIO_SPEED_50MHz) + +/* Buttons + * + * B1 USER: the user button is connected to the I/O PC13 (pin 2) of the STM32 + * microcontroller. + */ + +#define MIN_IRQBUTTON BUTTON_USER +#define MAX_IRQBUTTON BUTTON_USER +#define NUM_IRQBUTTONS 1 + +#define GPIO_BTN_USER \ + (GPIO_INPUT |GPIO_FLOAT |GPIO_EXTI | GPIO_PORTC | GPIO_PIN13) + +/* The shield uses the following pins: + * + * +5V + * GND + * SERIAL_TX=PA_2 USER_BUTTON=PC_13 + * SERIAL_RX=PA_3 LD2=PA_5 + * + * Analog Digital + * A0=PA_0 USART2RX D0=PA_3 D8 =PA_9 + * A1=PA_1 USART2TX D1=PA_2 D9 =PC_7 + * A2=PA_4 D2=PA_10 WIFI_CS=D10=PB_6 SPI_CS + * A3=PB_0 WIFI_INT=D3=PB_3 D11=PA_7 SPI_MOSI + * A4=PC_1 SD_CS=D4=PB_5 D12=PA_6 SPI_MISO + * A5=PC_0 WIFI_EN=D5=PB_4 LD2=D13=PA_5 SPI_SCK + * LED2=D6=PB_10 I2C1_SDA=D14=PB_9 WIFI Probe + * D7=PA_8 I2C1_SCL=D15=PB_8 WIFI Probe + * + * mostly from: https://mbed.org/platforms/ST-Nucleo-F411RE/ + * + */ + +/* SPI1 off */ + +#define GPIO_SPI1_MOSI_OFF (GPIO_INPUT | GPIO_PULLDOWN | \ + GPIO_PORTA | GPIO_PIN7) +#define GPIO_SPI1_MISO_OFF (GPIO_INPUT | GPIO_PULLDOWN | \ + GPIO_PORTA | GPIO_PIN6) +#define GPIO_SPI1_SCK_OFF (GPIO_INPUT | GPIO_PULLDOWN | \ + GPIO_PORTA | GPIO_PIN5) + +/* SSD1306 */ + +#define GPIO_SSD1306_CS (GPIO_OUTPUT|GPIO_OTYPER_PP(0)|GPIO_SPEED_2MHz|\ + GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN6) + +#define GPIO_SSD1306_CMD (GPIO_OUTPUT|GPIO_OTYPER_PP(0)|GPIO_OSPEED_2MHz|\ + GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN7) + +#define GPIO_SSD1306_RST (GPIO_OUTPUT|GPIO_OTYPER_PP(0)|GPIO_SPEED_2MHz|\ + GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN9) + +/* MCP2551 */ + +#define GPIO_MCP2515_CS (GPIO_OUTPUT|GPIO_OTYPER_PP(0)|GPIO_SPEED_2MHz|\ + GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4) + +#define GPIO_MCP2515_IRQ (GPIO_INPUT|GPIO_FLOAT|GPIO_PORTA|GPIO_PIN1) + +#ifdef HAVE_MMCSD +# define GPIO_SPI_CS_SD_CARD_OFF \ + (GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \ + GPIO_PORTB | GPIO_PIN5) +#endif + +#ifdef HAVE_MMCSD +# define GPIO_SPI_CS_SD_CARD \ + (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \ + GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN5) +#endif + +/* Devices on the onboard bus. + * + * Note that these are unshifted addresses. + */ + +#define NUCLEO_I2C_OBDEV_LED 0x55 +#define NUCLEO_I2C_OBDEV_HMC5883 0x1e + +/* Itead Joystick Shield + * + * See http://imall.iteadstudio.com/im120417014.html for more information + * about this joystick. + * + * --------- ----------------- --------------------------------- + * ARDUINO ITEAD NUCLEO-F411 + * PIN NAME SIGNAL SIGNAL + * --------- ----------------- --------------------------------- + * D3 Button E Output PB3 + * D4 Button D Output PB5 + * D5 Button C Output PB4 + * D6 Button B Output PB10 + * D7 Button A Output PA8 + * D8 Button F Output PA9 + * D9 Button G Output PC7 + * A0 Joystick Y Output PA0 ADC1_0 + * A1 Joystick X Output PA1 ADC1_1 + * --------- ----------------- --------------------------------- + * + * All buttons are pulled on the shield. A sensed low value indicates + * when the button is pressed. + * + * NOTE: Button F cannot be used with the default USART1 configuration + * because PA9 is configured for USART1_RX by default. Use select + * different USART1 pins in the board.h file or select a different + * USART or select CONFIG_NUCLEO_F411RE_AJOY_MINBUTTONS which will + * eliminate all but buttons A, B, and C. + */ + +#define ADC_XOUPUT 1 /* X output is on ADC channel 1 */ +#define ADC_YOUPUT 0 /* Y output is on ADC channel 0 */ + +#define GPIO_BUTTON_A \ + (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTA | GPIO_PIN8) +#define GPIO_BUTTON_B \ + (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTB | GPIO_PIN10) +#define GPIO_BUTTON_C \ + (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTB | GPIO_PIN4) +#define GPIO_BUTTON_D \ + (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTB | GPIO_PIN5) +#define GPIO_BUTTON_E \ + (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTB | GPIO_PIN3) +#define GPIO_BUTTON_F \ + (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTA | GPIO_PIN9) +#define GPIO_BUTTON_G \ + (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTC | GPIO_PIN7) + +/* Itead Joystick Signal interpretation: + * + * --------- ----------------------- --------------------------- + * BUTTON TYPE NUTTX ALIAS + * --------- ----------------------- --------------------------- + * Button A Large button A JUMP/BUTTON 3 + * Button B Large button B FIRE/BUTTON 2 + * Button C Joystick select button SELECT/BUTTON 1 + * Button D Tiny Button D BUTTON 6 + * Button E Tiny Button E BUTTON 7 + * Button F Large Button F BUTTON 4 + * Button G Large Button G BUTTON 5 + * --------- ----------------------- --------------------------- + */ + +#define GPIO_BUTTON_1 GPIO_BUTTON_C +#define GPIO_BUTTON_2 GPIO_BUTTON_B +#define GPIO_BUTTON_3 GPIO_BUTTON_A +#define GPIO_BUTTON_4 GPIO_BUTTON_F +#define GPIO_BUTTON_5 GPIO_BUTTON_G +#define GPIO_BUTTON_6 GPIO_BUTTON_D +#define GPIO_BUTTON_7 GPIO_BUTTON_E + +#define GPIO_SELECT GPIO_BUTTON_1 +#define GPIO_FIRE GPIO_BUTTON_2 +#define GPIO_JUMP GPIO_BUTTON_3 + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* Global driver instances */ + +#ifdef CONFIG_STM32_SPI1 +extern struct spi_dev_s *g_spi1; +#endif +#ifdef CONFIG_STM32_SPI2 +extern struct spi_dev_s *g_spi2; +#endif +#ifdef HAVE_MMCSD +extern struct sdio_dev_s *g_sdio; +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_bringup + * + * Description: + * Perform architecture specific initialization + * + * CONFIG_BOARDCTL=y: + * If CONFIG_NSH_ARCHINITIALIZE=y: + * Called from the NSH library (or other application) + * Otherwise, assumed to be called from some other application. + * + * Otherwise CONFIG_BOARD_LATE_INITIALIZE=y: + * Called from board_late_initialize(). + * + * Otherwise, bad news: Never called + * + ****************************************************************************/ + +int stm32_bringup(void); + +/**************************************************************************** + * Name: stm32_spidev_initialize + * + * Description: + * Called to configure SPI chip select GPIO pins. + * + ****************************************************************************/ + +void stm32_spidev_initialize(void); + +/**************************************************************************** + * Name: stm32_usbinitialize + * + * Description: + * Called to setup USB-related GPIO pins. + * + ****************************************************************************/ + +void stm32_usbinitialize(void); + +/**************************************************************************** + * Name: stm32_adc_setup + * + * Description: + * Initialize ADC and register the ADC driver. + * + ****************************************************************************/ + +#ifdef CONFIG_ADC +int stm32_adc_setup(void); +#endif + +/**************************************************************************** + * Name: board_ajoy_initialize + * + * Description: + * Initialize and register the button joystick driver + * + ****************************************************************************/ + +#ifdef CONFIG_INPUT_AJOYSTICK +int board_ajoy_initialize(void); +#endif + +/**************************************************************************** + * Name: stm32_mcp2515initialize + * + * Description: + * Initialize and register the MCP2515 CAN driver. + * + ****************************************************************************/ + +#ifdef CONFIG_CAN_MCP2515 +int stm32_mcp2515initialize(const char *devpath); +#endif + +#endif /* __BOARDS_ARM_STM32_NUCLEO_F411RE_SRC_NUCLEO_F411RE_H */ diff --git a/boards/arm/stm32/nucleo-f411re/src/stm32_adc.c b/boards/arm/stm32/nucleo-f411re/src/stm32_adc.c new file mode 100644 index 0000000000000..4abf451586f99 --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/stm32_adc.c @@ -0,0 +1,142 @@ +/**************************************************************************** + * boards/arm/stm32/nucleo-f411re/src/stm32_adc.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include + +#include "chip.h" +#include "arm_internal.h" +#include "stm32_adc.h" +#include "nucleo-f411re.h" + +#include + +#ifdef CONFIG_STM32_ADC1 + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* The number of ADC channels in the conversion list */ + +#ifdef CONFIG_ADC_DMA +# define ADC1_NCHANNELS 2 +#else +# define ADC1_NCHANNELS 1 +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* Identifying number of each ADC channel. */ + +#ifdef CONFIG_ADC_DMA +/* Configure ADC inputs on ADC_IN0 and ADC_IN1 */ + +static const uint8_t g_adc1_chanlist[ADC1_NCHANNELS] = +{ + 0, 1 +}; + +/* Configurations of pins used byte each ADC channels */ + +static const uint32_t g_adc1_pinlist[ADC1_NCHANNELS] = +{ + GPIO_ADC1_IN0, GPIO_ADC1_IN0 +}; + +#else +/* Without DMA, only a single channel can be supported */ + +/* Configura ADC input on ADC_IN0 */ + +static const uint8_t g_adc1_chanlist[ADC1_NCHANNELS] = +{ + 0 +}; + +/* Configurations of pins used byte each ADC channels */ + +static const uint32_t g_adc1_pinlist[ADC1_NCHANNELS] = +{ + GPIO_ADC1_IN0 +}; + +#endif /* CONFIG_ADC_DMA */ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_adc_setup + * + * Description: + * Initialize ADC and register the ADC driver. + * + ****************************************************************************/ + +int stm32_adc_setup(void) +{ + struct adc_dev_s *adc; + int ret; + int i; + + /* Configure the pins as analog inputs for the selected channels */ + + for (i = 0; i < ADC1_NCHANNELS; i++) + { + stm32_configgpio(g_adc1_pinlist[i]); + } + + /* Call stm32_adcinitialize() to get an instance of the ADC interface */ + + adc = stm32_adcinitialize(1, g_adc1_chanlist, ADC1_NCHANNELS); + if (adc == NULL) + { + aerr("ERROR: Failed to get ADC interface\n"); + return -ENODEV; + } + + /* Register the ADC driver at "/dev/adc0" */ + + ret = adc_register("/dev/adc0", adc); + if (ret < 0) + { + aerr("ERROR: adc_register failed: %d\n", ret); + return ret; + } + + return OK; +} + +#endif /* CONFIG_STM32_ADC1 */ diff --git a/boards/arm/stm32/nucleo-f411re/src/stm32_ajoystick.c b/boards/arm/stm32/nucleo-f411re/src/stm32_ajoystick.c new file mode 100644 index 0000000000000..a2f055fd61208 --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/stm32_ajoystick.c @@ -0,0 +1,490 @@ +/**************************************************************************** + * boards/arm/stm32/nucleo-f411re/src/stm32_ajoystick.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "stm32_gpio.h" +#include "stm32_adc.h" +#include "hardware/stm32_adc.h" +#include "nucleo-f411re.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Check for pre-requisites and pin conflicts */ + +#ifdef CONFIG_INPUT_AJOYSTICK +# if !defined(CONFIG_ADC) +# error CONFIG_ADC is required for the Itead joystick +# undef CONFIG_INPUT_AJOYSTICK +# elif !defined(CONFIG_STM32_ADC1) +# error CONFIG_STM32_ADC1 is required for Itead joystick +# undef CONFIG_INPUT_AJOYSTICK +# endif +#endif /* CONFIG_INPUT_AJOYSTICK */ + +#ifdef CONFIG_INPUT_AJOYSTICK + +/* A no-ADC, buttons only version can be built for testing */ + +#undef NO_JOYSTICK_ADC + +/* Maximum number of ADC channels */ + +#define MAX_ADC_CHANNELS 8 + +/* Dual channel ADC support requires DMA */ + +#ifdef CONFIG_ADC_DMA +# define NJOYSTICK_CHANNELS 2 +#else +# define NJOYSTICK_CHANNELS 1 +#endif + +#ifdef CONFIG_NUCLEO_F411RE_AJOY_MINBUTTONS +/* Number of Joystick buttons */ + +# define AJOY_NGPIOS 3 + +/* Bitset of supported Joystick buttons */ + +# define AJOY_SUPPORTED (AJOY_BUTTON_1_BIT | AJOY_BUTTON_2_BIT | \ + AJOY_BUTTON_3_BIT) +#else +/* Number of Joystick buttons */ + +# define AJOY_NGPIOS 7 + +/* Bitset of supported Joystick buttons */ + +# define AJOY_SUPPORTED (AJOY_BUTTON_1_BIT | AJOY_BUTTON_2_BIT | \ + AJOY_BUTTON_3_BIT | AJOY_BUTTON_4_BIT | \ + AJOY_BUTTON_5_BIT | AJOY_BUTTON_6_BIT | \ + AJOY_BUTTON_7_BIT ) +#endif + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static ajoy_buttonset_t +ajoy_supported(const struct ajoy_lowerhalf_s *lower); +static int ajoy_sample(const struct ajoy_lowerhalf_s *lower, + struct ajoy_sample_s *sample); +static ajoy_buttonset_t +ajoy_buttons(const struct ajoy_lowerhalf_s *lower); +static void ajoy_enable(const struct ajoy_lowerhalf_s *lower, + ajoy_buttonset_t press, ajoy_buttonset_t release, + ajoy_handler_t handler, void *arg); + +static void ajoy_disable(void); +static int ajoy_interrupt(int irq, void *context, void *arg); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* Pin configuration for each Itead joystick button. Index using AJOY_* + * button definitions in include/nuttx/input/ajoystick.h. + */ + +#ifdef CONFIG_NUCLEO_F411RE_AJOY_MINBUTTONS +static const uint32_t g_joygpio[AJOY_NGPIOS] = +{ + GPIO_BUTTON_1, GPIO_BUTTON_2, GPIO_BUTTON_3 +}; +#else +static const uint32_t g_joygpio[AJOY_NGPIOS] = +{ + GPIO_BUTTON_1, GPIO_BUTTON_2, GPIO_BUTTON_3, GPIO_BUTTON_4, + GPIO_BUTTON_5, GPIO_BUTTON_6, GPIO_BUTTON_7 +}; +#endif + +/* This is the button joystick lower half driver interface */ + +static const struct ajoy_lowerhalf_s g_ajoylower = +{ + .al_supported = ajoy_supported, + .al_sample = ajoy_sample, + .al_buttons = ajoy_buttons, + .al_enable = ajoy_enable, +}; + +#ifndef NO_JOYSTICK_ADC +/* Thread-independent file structure for the open ADC driver */ + +static struct file g_adcfile; +#endif + +/* Current interrupt handler and argument */ + +static ajoy_handler_t g_ajoyhandler; +static void *g_ajoyarg; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ajoy_supported + * + * Description: + * Return the set of buttons supported on the button joystick device + * + ****************************************************************************/ + +static ajoy_buttonset_t +ajoy_supported(const struct ajoy_lowerhalf_s *lower) +{ + iinfo("Supported: %02x\n", AJOY_SUPPORTED); + return (ajoy_buttonset_t)AJOY_SUPPORTED; +} + +/**************************************************************************** + * Name: ajoy_sample + * + * Description: + * Return the current state of all button joystick buttons + * + ****************************************************************************/ + +static int ajoy_sample(const struct ajoy_lowerhalf_s *lower, + struct ajoy_sample_s *sample) +{ +#ifndef NO_JOYSTICK_ADC + struct adc_msg_s adcmsg[MAX_ADC_CHANNELS]; + struct adc_msg_s *ptr; + ssize_t nread; + ssize_t offset; + int have; + int i; + + /* Read all of the available samples (handling the case where additional + * channels are enabled). + */ + + nread = file_read(&g_adcfile, adcmsg, + MAX_ADC_CHANNELS * sizeof(struct adc_msg_s)); + if (nread < 0) + { + if (nread != -EINTR) + { + ierr("ERROR: read failed: %d\n", (int)nread); + } + + return nread; + } + else if (nread < NJOYSTICK_CHANNELS * sizeof(struct adc_msg_s)) + { + ierr("ERROR: read too small: %ld\n", (long)nread); + return -EIO; + } + + /* Sample and the raw analog inputs */ + +#ifdef CONFIG_ADC_DMA + have = 0; + +#else + /* If DMA is not supported, then we will have only a single ADC channel */ + + have = 2; + sample->as_y = 0; +#endif + + for (i = 0, offset = 0; + i < MAX_ADC_CHANNELS && offset < nread && have != 3; + i++, offset += sizeof(struct adc_msg_s)) + { + ptr = &adcmsg[i]; + + /* Is this one of the channels that we need? */ + + if ((have & 1) == 0 && ptr->am_channel == 0) + { + int32_t tmp = ptr->am_data; + sample->as_x = (int16_t)tmp; + have |= 1; + + iinfo("X sample: %ld -> %d\n", (long)tmp, (int)sample->as_x); + } + +#ifdef CONFIG_ADC_DMA + if ((have & 2) == 0 && ptr->am_channel == 1) + { + int32_t tmp = ptr->am_data; + sample->as_y = (int16_t)tmp; + have |= 2; + + iinfo("Y sample: %ld -> %d\n", (long)tmp, (int)sample->as_y); + } +#endif + } + + if (have != 3) + { + ierr("ERROR: Could not find joystick channels\n"); + return -EIO; + } + +#else + /* ADC support is disabled */ + + sample->as_x = 0; + sample->as_y = 0; +#endif + + /* Sample the discrete button inputs */ + + sample->as_buttons = ajoy_buttons(lower); + iinfo("Returning: %02x\n", sample->as_buttons); + return OK; +} + +/**************************************************************************** + * Name: ajoy_buttons + * + * Description: + * Return the current state of button data (only) + * + ****************************************************************************/ + +static ajoy_buttonset_t +ajoy_buttons(const struct ajoy_lowerhalf_s *lower) +{ + ajoy_buttonset_t ret = 0; + int i; + + /* Read each joystick GPIO value */ + + for (i = 0; i < AJOY_NGPIOS; i++) + { + /* Button outputs are pulled high. So a sensed low level means that the + * button is pressed. + */ + + if (!stm32_gpioread(g_joygpio[i])) + { + ret |= (1 << i); + } + } + + iinfo("Returning: %02x\n", ret); + return ret; +} + +/**************************************************************************** + * Name: ajoy_enable + * + * Description: + * Enable interrupts on the selected set of joystick buttons. And empty + * set will disable all interrupts. + * + ****************************************************************************/ + +static void ajoy_enable(const struct ajoy_lowerhalf_s *lower, + ajoy_buttonset_t press, ajoy_buttonset_t release, + ajoy_handler_t handler, void *arg) +{ + irqstate_t flags; + ajoy_buttonset_t either = press | release; + ajoy_buttonset_t bit; + bool rising; + bool falling; + int i; + + /* Start with all interrupts disabled */ + + flags = enter_critical_section(); + ajoy_disable(); + + iinfo("press: %02x release: %02x handler: %p arg: %p\n", + press, release, handler, arg); + + /* If no events are indicated or if no handler is provided, then this + * must really be a request to disable interrupts. + */ + + if (either && handler) + { + /* Save the new the handler and argument */ + + g_ajoyhandler = handler; + g_ajoyarg = arg; + + /* Check each GPIO. */ + + for (i = 0; i < AJOY_NGPIOS; i++) + { + /* Enable interrupts on each pin that has either a press or + * release event associated with it. + */ + + bit = (1 << i); + if ((either & bit) != 0) + { + /* Active low so a press corresponds to a falling edge and + * a release corresponds to a rising edge. + */ + + falling = ((press & bit) != 0); + rising = ((release & bit) != 0); + + iinfo("GPIO %d: rising: %d falling: %d\n", + i, rising, falling); + + stm32_gpiosetevent(g_joygpio[i], rising, falling, + true, ajoy_interrupt, NULL); + } + } + } + + leave_critical_section(flags); +} + +/**************************************************************************** + * Name: ajoy_disable + * + * Description: + * Disable all joystick interrupts + * + ****************************************************************************/ + +static void ajoy_disable(void) +{ + irqstate_t flags; + int i; + + /* Disable each joystick interrupt */ + + flags = enter_critical_section(); + for (i = 0; i < AJOY_NGPIOS; i++) + { + stm32_gpiosetevent(g_joygpio[i], false, false, false, NULL, NULL); + } + + leave_critical_section(flags); + + /* Nullify the handler and argument */ + + g_ajoyhandler = NULL; + g_ajoyarg = NULL; +} + +/**************************************************************************** + * Name: ajoy_interrupt + * + * Description: + * Discrete joystick interrupt handler + * + ****************************************************************************/ + +static int ajoy_interrupt(int irq, void *context, void *arg) +{ + DEBUGASSERT(g_ajoyhandler); + + if (g_ajoyhandler) + { + g_ajoyhandler(&g_ajoylower, g_ajoyarg); + } + + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_ajoy_initialize + * + * Description: + * Initialize and register the button joystick driver + * + ****************************************************************************/ + +int board_ajoy_initialize(void) +{ + int ret; + int i; + +#ifndef NO_JOYSTICK_ADC + iinfo("Initialize ADC driver: /dev/adc0\n"); + + /* NOTE: The ADC driver was initialized earlier in the bring-up sequence. */ + + /* Open the ADC driver for reading. */ + + ret = file_open(&g_adcfile, "/dev/adc0", O_RDONLY); + if (ret < 0) + { + ierr("ERROR: Failed to open /dev/adc0: %d\n", ret); + return ret; + } +#endif + + /* Configure the GPIO pins as interrupting inputs. NOTE: This is + * unnecessary for interrupting pins since it will also be done by + * stm32_gpiosetevent(). + */ + + for (i = 0; i < AJOY_NGPIOS; i++) + { + /* Configure the PIO as an input */ + + stm32_configgpio(g_joygpio[i]); + } + + /* Register the joystick device as /dev/ajoy0 */ + + iinfo("Initialize joystick driver: /dev/ajoy0\n"); + + ret = ajoy_register("/dev/ajoy0", &g_ajoylower); + if (ret < 0) + { + ierr("ERROR: ajoy_register failed: %d\n", ret); +#ifndef NO_JOYSTICK_ADC + file_close(&g_adcfile); +#endif + } + + return ret; +} + +#endif /* CONFIG_INPUT_AJOYSTICK */ diff --git a/boards/arm/stm32/nucleo-f411re/src/stm32_appinit.c b/boards/arm/stm32/nucleo-f411re/src/stm32_appinit.c new file mode 100644 index 0000000000000..c2b6d362bed92 --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/stm32_appinit.c @@ -0,0 +1,78 @@ +/**************************************************************************** + * boards/arm/stm32/nucleo-f411re/src/stm32_appinit.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "nucleo-f411re.h" + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ +#ifdef CONFIG_BOARD_LATE_INITIALIZE + return OK; +#else + /* Perform board initialization here */ + + return stm32_bringup(); +#endif +} diff --git a/boards/arm/stm32/nucleo-f411re/src/stm32_autoleds.c b/boards/arm/stm32/nucleo-f411re/src/stm32_autoleds.c new file mode 100644 index 0000000000000..c9a53c8197814 --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/stm32_autoleds.c @@ -0,0 +1,83 @@ +/**************************************************************************** + * boards/arm/stm32/nucleo-f411re/src/stm32_autoleds.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include "chip.h" +#include "arm_internal.h" +#include "stm32.h" +#include "nucleo-f411re.h" + +#include + +#ifdef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_autoled_initialize + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + /* Configure LD2 GPIO for output */ + + stm32_configgpio(GPIO_LD2); +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ + if (led == 1) + { + stm32_gpiowrite(GPIO_LD2, true); + } +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ + if (led == 1) + { + stm32_gpiowrite(GPIO_LD2, false); + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/boards/arm/stm32/nucleo-f411re/src/stm32_boot.c b/boards/arm/stm32/nucleo-f411re/src/stm32_boot.c new file mode 100644 index 0000000000000..d279630946970 --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/stm32_boot.c @@ -0,0 +1,105 @@ +/**************************************************************************** + * boards/arm/stm32/nucleo-f411re/src/stm32_boot.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include + +#include + +#include "arm_internal.h" +#include "nucleo-f411re.h" + +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_boardinitialize + * + * Description: + * All STM32 architectures must provide the following entry point. + * This entry point is called early in the initialization -- after all + * memory has been configured and mapped but before any devices have been + * initialized. + * + ****************************************************************************/ + +void stm32_boardinitialize(void) +{ + /* Configure on-board LEDs if LED support has been selected. */ + +#ifdef CONFIG_ARCH_LEDS + board_autoled_initialize(); +#endif + + /* Configure SPI chip selects if 1) SP2 is not disabled, and 2) the weak + * function stm32_spidev_initialize() has been brought into the link. + */ + +#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3) + stm32_spidev_initialize(); +#endif + + /* Initialize USB is 1) USBDEV is selected, 2) the USB controller is not + * disabled, and 3) the weak function stm32_usbinitialize() has been + * brought into the build. + */ + +#if defined(CONFIG_USBDEV) && defined(CONFIG_STM32_USB) + stm32_usbinitialize(); +#endif +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() will + * be called immediately after up_initialize() is called and just before + * the initial application is started. This additional initialization + * phase may be used, for example, to initialize board-specific device + * drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board initialization here instead of from the + * board_app_initialize(). + */ + + stm32_bringup(); +} +#endif diff --git a/boards/arm/stm32/nucleo-f411re/src/stm32_bringup.c b/boards/arm/stm32/nucleo-f411re/src/stm32_bringup.c new file mode 100644 index 0000000000000..22e899f055106 --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/stm32_bringup.c @@ -0,0 +1,221 @@ +/**************************************************************************** + * boards/arm/stm32/nucleo-f411re/src/stm32_bringup.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#ifdef CONFIG_USERLED +# include +#endif + +#ifdef CONFIG_INPUT_BUTTONS +# include +#endif + +#include "nucleo-f411re.h" + +#include + +#ifdef CONFIG_SENSORS_QENCODER +#include "board_qencoder.h" +#endif + +#undef HAVE_LEDS +#if !defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER) +# define HAVE_LEDS 1 +#endif + +#ifdef CONFIG_EXAMPLES_LEDS_DEVPATH +# define LED_DRIVER_PATH CONFIG_EXAMPLES_LEDS_DEVPATH +#else +# define LED_DRIVER_PATH "/dev/userleds" +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y : + * Called from the NSH library + * + ****************************************************************************/ + +int stm32_bringup(void) +{ + int ret = OK; + +#ifdef HAVE_LEDS + /* Register the LED driver */ + + ret = userled_lower_initialize(LED_DRIVER_PATH); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret); + return ret; + } +#endif + +#ifdef CONFIG_INPUT_BUTTONS + /* Register the BUTTON driver */ + + ret = btn_lower_initialize("/dev/buttons"); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret); + } +#endif + + /* Configure SPI-based devices */ + +#ifdef CONFIG_STM32_SPI1 + /* Get the SPI port */ + + struct spi_dev_s *spi; + + spi = stm32_spibus_initialize(1); + if (!spi) + { + syslog(LOG_ERR, "ERROR: Failed to initialize SPI port 1\n"); + return -ENODEV; + } + +#if defined(CONFIG_LCD_SSD1306_SPI) && !defined(CONFIG_VIDEO_FB) + board_lcd_initialize(); +#endif + +#ifdef CONFIG_VIDEO_FB + ret = fb_register(0, 0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: fb_register() failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_CAN_MCP2515 +#ifdef CONFIG_STM32_SPI1 + stm32_configgpio(GPIO_MCP2515_CS); /* MEMS chip select */ +#endif + + /* Configure and initialize the MCP2515 CAN device */ + + ret = stm32_mcp2515initialize("/dev/can0"); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_mcp2515initialize() failed: %d\n", ret); + } +#endif +#endif + +#ifdef HAVE_MMCSD + /* First, get an instance of the SDIO interface */ + + g_sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO); + if (!g_sdio) + { + syslog(LOG_ERR, "ERROR: Failed to initialize SDIO slot %d\n", + CONFIG_NSH_MMCSDSLOTNO); + return -ENODEV; + } + + /* Now bind the SDIO interface to the MMC/SD driver */ + + ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, g_sdio); + if (ret != OK) + { + syslog(LOG_ERR, + "ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", + ret); + return ret; + } + + /* Then let's guess and say that there is a card in the slot. There is no + * card detect GPIO. + */ + + sdio_mediachange(g_sdio, true); + + syslog(LOG_INFO, "[boot] Initialized SDIO\n"); +#endif + +#ifdef CONFIG_ADC + /* Initialize ADC and register the ADC driver. */ + + ret = stm32_adc_setup(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_adc_setup failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_SENSORS_QENCODER + /* Initialize and register the qencoder driver */ + + ret = board_qencoder_initialize(0, CONFIG_NUCLEO_F411RE_QETIMER); + if (ret != OK) + { + syslog(LOG_ERR, + "ERROR: Failed to register the qencoder: %d\n", + ret); + return ret; + } +#endif + +#ifdef CONFIG_INPUT_AJOYSTICK + /* Initialize and register the joystick driver */ + + ret = board_ajoy_initialize(); + if (ret != OK) + { + syslog(LOG_ERR, + "ERROR: Failed to register the joystick driver: %d\n", + ret); + return ret; + } +#endif + + return ret; +} diff --git a/boards/arm/stm32/nucleo-f411re/src/stm32_buttons.c b/boards/arm/stm32/nucleo-f411re/src/stm32_buttons.c new file mode 100644 index 0000000000000..7d064a6b2d5e9 --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/stm32_buttons.c @@ -0,0 +1,117 @@ +/**************************************************************************** + * boards/arm/stm32/nucleo-f411re/src/stm32_buttons.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include + +#include "stm32_gpio.h" +#include "nucleo-f411re.h" + +#include + +#ifdef CONFIG_ARCH_BUTTONS + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_button_initialize + * + * Description: + * board_button_initialize() must be called to initialize button resources. + * After that, board_buttons() may be called to collect the current state + * of all buttons or board_button_irq() may be called to register button + * interrupt handlers. + * + ****************************************************************************/ + +uint32_t board_button_initialize(void) +{ + /* Configure the single button as an input. NOTE that EXTI interrupts are + * also configured for the pin. + */ + + stm32_configgpio(GPIO_BTN_USER); + return NUM_BUTTONS; +} + +/**************************************************************************** + * Name: board_buttons + ****************************************************************************/ + +uint32_t board_buttons(void) +{ + /* Check that state of each USER button. A LOW value means that the key is + * pressed. + */ + + bool released = stm32_gpioread(GPIO_BTN_USER); + return !released; +} + +/**************************************************************************** + * Button support. + * + * Description: + * board_button_initialize() must be called to initialize button resources. + * After that, board_buttons() may be called to collect the current state + * of all buttons or board_button_irq() may be called to register button + * interrupt handlers. + * + * After board_button_initialize() has been called, board_buttons() may be + * called to collect the state of all buttons. board_buttons() returns an + * 32-bit bit set with each bit associated with a button. See the + * BUTTON_*_BIT definitions in board.h for the meaning of each bit. + * + * board_button_irq() may be called to register an interrupt handler that + * will be called when a button is depressed or released. The ID value is a + * button enumeration value that uniquely identifies a button resource. See + * the BUTTON_* definitions in board.h for the meaning of enumeration + * value. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_IRQBUTTONS +int board_button_irq(int id, xcpt_t irqhandler, void *arg) +{ + int ret = -EINVAL; + + if (id == BUTTON_USER) + { + ret = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true, + irqhandler, arg); + } + + return ret; +} +#endif +#endif /* CONFIG_ARCH_BUTTONS */ diff --git a/boards/arm/stm32/nucleo-f411re/src/stm32_lcd_ssd1306.c b/boards/arm/stm32/nucleo-f411re/src/stm32_lcd_ssd1306.c new file mode 100644 index 0000000000000..ac67c71350401 --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/stm32_lcd_ssd1306.c @@ -0,0 +1,88 @@ +/**************************************************************************** + * boards/arm/stm32/nucleo-f411re/src/stm32_lcd_ssd1306.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include +#include + +#include "stm32.h" +#include "nucleo-f411re.h" + +#include "stm32_ssd1306.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define OLED_SPI_PORT 1 /* OLED display connected to SPI1 */ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_lcd_initialize + ****************************************************************************/ + +int board_lcd_initialize(void) +{ + int ret; + + ret = board_ssd1306_initialize(OLED_SPI_PORT); + if (ret < 0) + { + lcderr("ERROR: Failed to initialize SSD1306\n"); + return ret; + } + + return OK; +} + +/**************************************************************************** + * Name: board_lcd_getdev + ****************************************************************************/ + +struct lcd_dev_s *board_lcd_getdev(int devno) +{ + return board_ssd1306_getdev(); +} + +/**************************************************************************** + * Name: board_lcd_uninitialize + ****************************************************************************/ + +void board_lcd_uninitialize(void) +{ + /* TO-FIX */ +} diff --git a/boards/arm/stm32/nucleo-f411re/src/stm32_mcp2515.c b/boards/arm/stm32/nucleo-f411re/src/stm32_mcp2515.c new file mode 100644 index 0000000000000..a5138a38d7651 --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/stm32_mcp2515.c @@ -0,0 +1,241 @@ +/**************************************************************************** + * boards/arm/stm32/nucleo-f411re/src/stm32_mcp2515.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "stm32.h" +#include "stm32_spi.h" +#include "nucleo-f411re.h" + +#if defined(CONFIG_SPI) && defined(CONFIG_STM32_SPI1) && \ + defined(CONFIG_CAN_MCP2515) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define MCP2515_SPI_PORTNO 1 /* On SPI1 */ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct stm32_mcp2515config_s +{ + /* Configuration structure as seen by the MCP2515 driver */ + + struct mcp2515_config_s config; + + /* Additional private definitions only known to this driver */ + + struct mcp2515_can_s *handle; /* The MCP2515 driver handle */ + mcp2515_handler_t handler; /* The MCP2515 interrupt handler */ + void *arg; /* Argument to pass to the interrupt handler */ +}; + +/**************************************************************************** + * Static Function Prototypes + ****************************************************************************/ + +/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks + * to isolate the MCP2515 driver from differences in GPIO interrupt handling + * by varying boards and MCUs. + * + * attach - Attach the MCP2515 interrupt handler to the GPIO interrupt + */ + +static int mcp2515_attach(struct mcp2515_config_s *state, + mcp2515_handler_t handler, void *arg); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* A reference to a structure of this type must be passed to the MCP2515 + * driver. This structure provides information about the configuration + * of the MCP2515 and provides some board-specific hooks. + * + * Memory for this structure is provided by the caller. It is not copied + * by the driver and is presumed to persist while the driver is active. The + * memory must be writable because, under certain circumstances, the driver + * may modify frequency or X plate resistance values. + */ + +static struct stm32_mcp2515config_s g_mcp2515config = +{ + .config = + { + .spi = NULL, + .baud = 0, /* REVISIT. Probably broken by commit eb7373cedfa */ + .btp = 0, /* REVISIT. Probably broken by commit eb7373cedfa */ + .devid = 0, + .mode = 0, /* REVISIT. Probably broken by commit eb7373cedfa */ + .nfilters = 6, +#ifdef MCP2515_LOOPBACK + .loopback = false; +#endif + .attach = mcp2515_attach, + }, +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/* This is the MCP2515 Interrupt handler */ + +int mcp2515_interrupt(int irq, void *context, void *arg) +{ + struct stm32_mcp2515config_s *priv = + (struct stm32_mcp2515config_s *)arg; + + DEBUGASSERT(priv != NULL); + + /* Verify that we have a handler attached */ + + if (priv->handler) + { + /* Yes.. forward with interrupt along with its argument */ + + priv->handler(&priv->config, priv->arg); + } + + return OK; +} + +static int mcp2515_attach(struct mcp2515_config_s *state, + mcp2515_handler_t handler, void *arg) +{ + struct stm32_mcp2515config_s *priv = + (struct stm32_mcp2515config_s *)state; + irqstate_t flags; + + caninfo("Saving handler %p\n", handler); + + flags = enter_critical_section(); + + priv->handler = handler; + priv->arg = arg; + + /* Configure the interrupt for falling edge */ + + stm32_gpiosetevent(GPIO_MCP2515_IRQ, false, true, false, + mcp2515_interrupt, priv); + + leave_critical_section(flags); + + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_mcp2515initialize + * + * Description: + * Initialize and register the MCP2515 RFID driver. + * + * Input Parameters: + * devpath - The full path to the driver to register. E.g., "/dev/rfid0" + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int stm32_mcp2515initialize(const char *devpath) +{ + struct spi_dev_s *spi; + struct can_dev_s *can; + struct mcp2515_can_s *mcp2515; + int ret; + + /* Check if we are already initialized */ + + if (!g_mcp2515config.handle) + { + sninfo("Initializing\n"); + + /* Configure the MCP2515 interrupt pin as an input */ + + stm32_configgpio(GPIO_MCP2515_IRQ); + + spi = stm32_spibus_initialize(MCP2515_SPI_PORTNO); + + if (!spi) + { + return -ENODEV; + } + + /* Save the SPI instance in the mcp2515_config_s structure */ + + g_mcp2515config.config.spi = spi; + + /* Instantiate the MCP2515 CAN Driver */ + + mcp2515 = mcp2515_instantiate(&g_mcp2515config.config); + if (mcp2515 == NULL) + { + canerr("ERROR: Failed to get MCP2515 Driver Loaded\n"); + return -ENODEV; + } + + /* Save the opaque structure */ + + g_mcp2515config.handle = mcp2515; + + /* Initialize the CAN Device with the MCP2515 operations */ + + can = mcp2515_initialize(mcp2515); + if (can == NULL) + { + canerr("ERROR: Failed to get CAN interface\n"); + return -ENODEV; + } + + /* Register the CAN driver at "/dev/can0" */ + + ret = can_register(devpath, can); + if (ret < 0) + { + canerr("ERROR: can_register failed: %d\n", ret); + return ret; + } + } + + return OK; +} + +#endif /* CONFIG_SPI && CONFIG_CAN_MCP2515 */ diff --git a/boards/arm/stm32/nucleo-f411re/src/stm32_spi.c b/boards/arm/stm32/nucleo-f411re/src/stm32_spi.c new file mode 100644 index 0000000000000..9462a72809aaf --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/stm32_spi.c @@ -0,0 +1,246 @@ +/**************************************************************************** + * boards/arm/stm32/nucleo-f411re/src/stm32_spi.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include + +#include "arm_internal.h" +#include "chip.h" +#include "stm32.h" + +#include "nucleo-f411re.h" + +#include + +#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || \ + defined(CONFIG_STM32_SPI3) + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* Global driver instances */ + +#ifdef CONFIG_STM32_SPI1 +struct spi_dev_s *g_spi1; +#endif +#ifdef CONFIG_STM32_SPI2 +struct spi_dev_s *g_spi2; +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_spidev_initialize + * + * Description: + * Called to configure SPI chip select GPIO pins for the Nucleo-F411RE + * + ****************************************************************************/ + +void weak_function stm32_spidev_initialize(void) +{ +#ifdef CONFIG_STM32_SPI1 + /* Configure SPI-based devices */ + + g_spi1 = stm32_spibus_initialize(1); + if (!g_spi1) + { + spierr("ERROR: FAILED to initialize SPI port 1\n"); + } + +#ifdef CONFIG_LCD_SSD1306_SPI + stm32_configgpio(GPIO_SSD1306_CS); /* SSD1306 chip select */ + stm32_configgpio(GPIO_SSD1306_CMD); /* SSD1306 data/!command */ +#endif + +#ifdef CONFIG_CAN_MCP2515 + stm32_configgpio(GPIO_MCP2515_CS); /* MCP2515 chip select */ +#endif + +#ifdef HAVE_MMCSD + stm32_configgpio(GPIO_SPI_CS_SD_CARD); +#endif +#endif + +#ifdef CONFIG_STM32_SPI2 + /* Configure SPI-based devices */ + + g_spi2 = stm32_spibus_initialize(2); +#endif +} + +/**************************************************************************** + * Name: stm32_spi1/2/3select and stm32_spi1/2/3status + * + * Description: + * The external functions, stm32_spi1/2/3select and stm32_spi1/2/3status + * must be provided by board-specific logic. They are implementations of + * the select and status methods of the SPI interface defined by struct + * spi_ops_s (see include/nuttx/spi/spi.h). All other methods (including + * stm32_spibus_initialize()) are provided by common STM32 logic. To use + * this common SPI logic on your board: + * + * 1. Provide logic in stm32_boardinitialize() to configure SPI chip select + * pins. + * 2. Provide stm32_spi1/2/3select() and stm32_spi1/2/3status() functions + * in your board-specific logic. These functions will perform chip + * selection and status operations using GPIOs in the way your board is + * configured. + * 3. Add a calls to stm32_spibus_initialize() in your low level + * application initialization logic + * 4. The handle returned by stm32_spibus_initialize() may then be used to + * bind the SPI driver to higher level logic (e.g., calling + * mmcsd_spislotinitialize(), for example, will bind the SPI driver to + * the SPI MMC/SD driver). + * + ****************************************************************************/ + +#ifdef CONFIG_STM32_SPI1 +void stm32_spi1select(struct spi_dev_s *dev, uint32_t devid, + bool selected) +{ + spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : + "de-assert"); + +#if defined(CONFIG_LCD_SSD1306_SPI) + if (devid == SPIDEV_DISPLAY(0)) + { + stm32_gpiowrite(GPIO_SSD1306_CS, !selected); + } +#endif + +#if defined(CONFIG_CAN_MCP2515) + if (devid == SPIDEV_CANBUS(0)) + { + stm32_gpiowrite(GPIO_MCP2515_CS, !selected); + } +#endif + +#ifdef HAVE_MMCSD + if (devid == SPIDEV_MMCSD(0)) + { + stm32_gpiowrite(GPIO_SPI_CS_SD_CARD, !selected); + } +#endif +} + +uint8_t stm32_spi1status(struct spi_dev_s *dev, uint32_t devid) +{ + return 0; +} +#endif + +#ifdef CONFIG_STM32_SPI2 +void stm32_spi2select(struct spi_dev_s *dev, uint32_t devid, + bool selected) +{ + spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : + "de-assert"); +} + +uint8_t stm32_spi2status(struct spi_dev_s *dev, uint32_t devid) +{ + return 0; +} +#endif + +#ifdef CONFIG_STM32_SPI3 +void stm32_spi3select(struct spi_dev_s *dev, uint32_t devid, + bool selected) +{ + spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : + "de-assert"); +} + +uint8_t stm32_spi3status(struct spi_dev_s *dev, uint32_t devid) +{ + return 0; +} +#endif + +/**************************************************************************** + * Name: stm32_spi1cmddata + * + * Description: + * Set or clear the SH1101A A0 or SD1306 D/C n bit to select data (true) + * or command (false). This function must be provided by platform-specific + * logic. This is an implementation of the cmddata method of the SPI + * interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h). + * + * Input Parameters: + * + * spi - SPI device that controls the bus the device that requires the CMD/ + * DATA selection. + * devid - If there are multiple devices on the bus, this selects which one + * to select cmd or data. NOTE: This design restricts, for example, + * one one SPI display per SPI bus. + * cmd - true: select command; false: select data + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_SPI_CMDDATA +#ifdef CONFIG_STM32_SPI1 +int stm32_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) +{ +#if defined(CONFIG_LCD_SSD1306_SPI) + if (devid == SPIDEV_DISPLAY(0)) + { + stm32_gpiowrite(GPIO_SSD1306_CMD, !cmd); + } +#endif + + return OK; +} +#endif + +#ifdef CONFIG_STM32_SPI2 +int stm32_spi2cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) +{ + return OK; +} +#endif + +#ifdef CONFIG_STM32_SPI3 +int stm32_spi3cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) +{ + return OK; +} +#endif +#endif /* CONFIG_SPI_CMDDATA */ + +#endif /* CONFIG_STM32_SPI1 || CONFIG_STM32_SPI2 || CONFIG_STM32_SPI3 */ diff --git a/boards/arm/stm32/nucleo-f411re/src/stm32_userleds.c b/boards/arm/stm32/nucleo-f411re/src/stm32_userleds.c new file mode 100644 index 0000000000000..0e9370c49edea --- /dev/null +++ b/boards/arm/stm32/nucleo-f411re/src/stm32_userleds.c @@ -0,0 +1,218 @@ +/**************************************************************************** + * boards/arm/stm32/nucleo-f411re/src/stm32_userleds.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include + +#include "chip.h" +#include "arm_internal.h" +#include "stm32.h" +#include "nucleo-f411re.h" + +#include + +#ifndef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/* LED Power Management */ + +#ifdef CONFIG_PM +static void led_pm_notify(struct pm_callback_s *cb, int domain, + enum pm_state_e pmstate); +static int led_pm_prepare(struct pm_callback_s *cb, int domain, + enum pm_state_e pmstate); +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#ifdef CONFIG_PM +static struct pm_callback_s g_ledscb = +{ + .notify = led_pm_notify, + .prepare = led_pm_prepare, +}; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: led_pm_notify + * + * Description: + * Notify the driver of new power state. This callback is called after + * all drivers have had the opportunity to prepare for the new power state. + * + ****************************************************************************/ + +#ifdef CONFIG_PM +static void led_pm_notify(struct pm_callback_s *cb, int domain, + enum pm_state_e pmstate) +{ + switch (pmstate) + { + case(PM_NORMAL): + { + /* Restore normal LEDs operation */ + } + break; + + case(PM_IDLE): + { + /* Entering IDLE mode - Turn leds off */ + } + break; + + case(PM_STANDBY): + { + /* Entering STANDBY mode - Logic for PM_STANDBY goes here */ + } + break; + + case(PM_SLEEP): + { + /* Entering SLEEP mode - Logic for PM_SLEEP goes here */ + } + break; + + default: + { + /* Should not get here */ + } + break; + } +} +#endif + +/**************************************************************************** + * Name: led_pm_prepare + * + * Description: + * Request the driver to prepare for a new power state. This is a warning + * that the system is about to enter into a new power state. The driver + * should begin whatever operations that may be required to enter power + * state. The driver may abort the state change mode by returning a + * non-zero value from the callback function. + * + ****************************************************************************/ + +#ifdef CONFIG_PM +static int led_pm_prepare(struct pm_callback_s *cb, int domain, + enum pm_state_e pmstate) +{ + /* No preparation to change power modes is required by the LEDs driver. + * We always accept the state change by returning OK. + */ + + return OK; +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +uint32_t board_userled_initialize(void) +{ + /* Configure LD2 GPIO for output */ + + stm32_configgpio(GPIO_LD2); + return BOARD_NLEDS; +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + if (BOARD_LD2_BIT == (1 << led)) + { + stm32_gpiowrite(GPIO_LD2, ledon); + } +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint32_t ledset) +{ + /* An output of '1' illuminates the LED */ + + stm32_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0); +} + +#ifdef CONFIG_USERLED_LOWER_READSTATE +/**************************************************************************** + * Name: board_userled_getall + ****************************************************************************/ + +void board_userled_getall(uint32_t *ledset) +{ + /* Clear the LED bits */ + + *ledset = 0; + + /* Get LED state. An output of '1' illuminates the LED. */ + + *ledset |= ((stm32_gpioread(GPIO_LD2) & 1) << BOARD_LD2); +} + +#endif /* CONFIG_USERLED_LOWER_READSTATE */ + +/**************************************************************************** + * Name: stm32_led_pminitialize + ****************************************************************************/ + +#ifdef CONFIG_PM +void stm32_led_pminitialize(void) +{ + /* Register to receive power management callbacks */ + + int ret = pm_register(&g_ledscb); + DEBUGASSERT(ret == OK); + UNUSED(ret); +} +#endif /* CONFIG_PM */ + +#endif /* !CONFIG_ARCH_LEDS */ diff --git a/boards/arm/stm32/nucleo-f4x1re/include/board.h b/boards/arm/stm32/nucleo-f4x1re/include/board.h deleted file mode 100644 index 408cad5d7a9d7..0000000000000 --- a/boards/arm/stm32/nucleo-f4x1re/include/board.h +++ /dev/null @@ -1,209 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/include/board.h - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __BOARDS_ARM_STM32_NUCLEO_F401RE_INCLUDE_BOARD_H -#define __BOARDS_ARM_STM32_NUCLEO_F401RE_INCLUDE_BOARD_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#ifndef __ASSEMBLY__ -# include -#endif - -/* Clocking *****************************************************************/ - -#if defined(CONFIG_ARCH_CHIP_STM32F401RE) -# include -#elif defined(CONFIG_ARCH_CHIP_STM32F411RE) -# include -#endif - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* DMA Channel/Stream Selections ********************************************/ - -/* Stream selections are arbitrary for now but might become important in - * the future is we set aside more DMA channels/streams. - * - * SDIO DMA - *   DMAMAP_SDIO_1 = Channel 4, Stream 3 <- may later be used by SPI DMA - *   DMAMAP_SDIO_2 = Channel 4, Stream 6 - */ - -#define DMAMAP_SDIO DMAMAP_SDIO_1 - -/* Need to VERIFY fwb */ - -#define DMACHAN_SPI1_RX DMAMAP_SPI1_RX_1 -#define DMACHAN_SPI1_TX DMAMAP_SPI1_TX_1 -#define DMACHAN_SPI2_RX DMAMAP_SPI2_RX -#define DMACHAN_SPI2_TX DMAMAP_SPI2_TX - -/* Alternate function pin selections ****************************************/ - -/* USART1: - * RXD: PA10 CN9 pin 3, CN10 pin 33 - * PB7 CN7 pin 21 - * TXD: PA9 CN5 pin 1, CN10 pin 21 - * PB6 CN5 pin 3, CN10 pin 17 - */ - -#if 1 -# define GPIO_USART1_RX GPIO_USART1_RX_1 /* PA10 */ -# define GPIO_USART1_TX GPIO_USART1_TX_1 /* PA9 */ -#else -# define GPIO_USART1_RX GPIO_USART1_RX_2 /* PB7 */ -# define GPIO_USART1_TX GPIO_USART1_TX_2 /* PB6 */ -#endif - -/* USART2: - * RXD: PA3 CN9 pin 1 (See SB13, 14, 62, 63). CN10 pin 37 - * PD6 - * TXD: PA2 CN9 pin 2(See SB13, 14, 62, 63). CN10 pin 35 - * PD5 - */ - -#define GPIO_USART2_RX GPIO_USART2_RX_1 /* PA3 */ -#define GPIO_USART2_TX GPIO_USART2_TX_1 /* PA2 */ -#define GPIO_USART2_RTS GPIO_USART2_RTS_2 -#define GPIO_USART2_CTS GPIO_USART2_CTS_2 - -/* USART6: - * RXD: PC7 CN5 pin2, CN10 pin 19 - * PA12 CN10, pin 12 - * TXD: PC6 CN10, pin 4 - * PA11 CN10, pin 14 - */ - -#define GPIO_USART6_RX GPIO_USART6_RX_1 /* PC7 */ -#define GPIO_USART6_TX GPIO_USART6_TX_1 /* PC6 */ - -/* UART RX DMA configurations */ - -#define DMAMAP_USART1_RX DMAMAP_USART1_RX_2 -#define DMAMAP_USART6_RX DMAMAP_USART6_RX_2 - -/* I2C - * - * The optional _GPIO configurations allow the I2C driver to manually - * reset the bus to clear stuck slaves. They match the pin configuration, - * but are normally-high GPIOs. - */ - -#define GPIO_I2C1_SCL GPIO_I2C1_SCL_2 -#define GPIO_I2C1_SDA GPIO_I2C1_SDA_2 -#define GPIO_I2C1_SCL_GPIO \ - (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN8) -#define GPIO_I2C1_SDA_GPIO \ - (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN9) - -#define GPIO_I2C2_SCL GPIO_I2C2_SCL_1 -#define GPIO_I2C2_SDA GPIO_I2C2_SDA_1 -#define GPIO_I2C2_SCL_GPIO \ - (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN10) -#define GPIO_I2C2_SDA_GPIO \ - (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN11) - -/* SPI - * - * There are sensors on SPI1, and SPI2 is connected to the FRAM. - */ - -#define GPIO_SPI1_MISO GPIO_SPI1_MISO_1 -#define GPIO_SPI1_MOSI GPIO_SPI1_MOSI_1 -#define GPIO_SPI1_SCK GPIO_SPI1_SCK_1 - -#define GPIO_SPI2_MISO GPIO_SPI2_MISO_1 -#define GPIO_SPI2_MOSI GPIO_SPI2_MOSI_1 -#define GPIO_SPI2_SCK GPIO_SPI2_SCK_2 - -/* LEDs - * - * The Nucleo F401RE and F411RE boards provide a single user LED, LD2. LD2 - * is the green LED connected to Arduino signal D13 corresponding to MCU I/O - * PA5 (pin 21) or PB13 (pin 34) depending on the STM32 target. - * - * - When the I/O is HIGH value, the LED is on. - * - When the I/O is LOW, the LED is off. - */ - -/* LED index values for use with board_userled() */ - -#define BOARD_LD2 0 -#define BOARD_NLEDS 1 - -/* LED bits for use with board_userled_all() */ - -#define BOARD_LD2_BIT (1 << BOARD_LD2) - -/* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is - * defined. In that case, the usage by the board port is defined in - * include/board.h and src/sam_leds.c. The LEDs are used to encode OS-related - * events as follows when the red LED (PE24) is available: - * - * SYMBOL Meaning LD2 - * ------------------- ----------------------- ----------- - * LED_STARTED NuttX has been started OFF - * LED_HEAPALLOCATE Heap has been allocated OFF - * LED_IRQSENABLED Interrupts enabled OFF - * LED_STACKCREATED Idle stack created ON - * LED_INIRQ In an interrupt No change - * LED_SIGNAL In a signal handler No change - * LED_ASSERTION An assertion failed No change - * LED_PANIC The system has crashed Blinking - * LED_IDLE MCU is is sleep mode Not used - * - * Thus if LD2, NuttX has successfully booted and is, apparently, running - * normally. If LD2 is flashing at approximately 2Hz, then a fatal error - * has been detected and the system has halted. - */ - -#define LED_STARTED 0 -#define LED_HEAPALLOCATE 0 -#define LED_IRQSENABLED 0 -#define LED_STACKCREATED 1 -#define LED_INIRQ 2 -#define LED_SIGNAL 2 -#define LED_ASSERTION 2 -#define LED_PANIC 1 - -/* Buttons - * - * B1 USER: - * the user button is connected to the I/O PC13 (pin 2) of the STM32 - * microcontroller. - */ - -#define BUTTON_USER 0 -#define NUM_BUTTONS 1 - -#define BUTTON_USER_BIT (1 << BUTTON_USER) - -#define GPIO_TIM2_CH1IN (GPIO_TIM2_CH1IN_1 | GPIO_PULLUP) -#define GPIO_TIM2_CH2IN (GPIO_TIM2_CH2IN_1 | GPIO_PULLUP) - -#endif /* __BOARDS_ARM_STM32_NUCLEO_F401RE_INCLUDE_BOARD_H */ diff --git a/tools/ci/testlist/arm-09.dat b/tools/ci/testlist/arm-09.dat index effe67e4d39c4..f3af9f5162ce7 100644 --- a/tools/ci/testlist/arm-09.dat +++ b/tools/ci/testlist/arm-09.dat @@ -36,10 +36,11 @@ CMake,nucleo-f446re:pwm CMake,nucleo-f446re:qenco CMake,nucleo-f446re:systemview -CMake,nucleo-f4x1re:f401-fb -CMake,nucleo-f4x1re:f401-nsh -CMake,nucleo-f4x1re:f411-mcp2515-extid -CMake,nucleo-f4x1re:f411-nsh +CMake,nucleo-f401re:fb +CMake,nucleo-f401re:nsh + +CMake,nucleo-f411re:mcp2515-extid +CMake,nucleo-f411re:nsh CMake,nucleo-g431kb:comp CMake,nucleo-g431kb:nsh diff --git a/tools/ci/testlist/msys2.dat b/tools/ci/testlist/msys2.dat index 66e4c6adbbfe1..542b59af41900 100644 --- a/tools/ci/testlist/msys2.dat +++ b/tools/ci/testlist/msys2.dat @@ -5,7 +5,7 @@ /arm/stm32/nucleo-l152re/configs/nsh,CONFIG_ARM_TOOLCHAIN_GNU_EABI -/arm/stm32/nucleo-f4x1re/configs/f411-nsh,CONFIG_ARM_TOOLCHAIN_GNU_EABI +/arm/stm32/nucleo-f411re/configs/nsh,CONFIG_ARM_TOOLCHAIN_GNU_EABI # ARM64