diff --git a/boards/ark/fmu-v6x/extras/ark_fmu-v6x_bootloader.bin b/boards/ark/fmu-v6x/extras/ark_fmu-v6x_bootloader.bin index bbe99d9659..3b9fced00f 100755 Binary files a/boards/ark/fmu-v6x/extras/ark_fmu-v6x_bootloader.bin and b/boards/ark/fmu-v6x/extras/ark_fmu-v6x_bootloader.bin differ diff --git a/boards/ark/fmu-v6x/nuttx-config/include/board.h b/boards/ark/fmu-v6x/nuttx-config/include/board.h index e4146c3237..0561dffedc 100644 --- a/boards/ark/fmu-v6x/nuttx-config/include/board.h +++ b/boards/ark/fmu-v6x/nuttx-config/include/board.h @@ -302,7 +302,7 @@ #define STM32_SDMMC_CLKCR_EDGE STM32_SDMMC_CLKCR_NEGEDGE /* LED definitions ******************************************************************/ -/* The ARKV6X board has three, LED_GREEN a Green LED, LED_BLUE a Blue LED and +/* The board board has three, LED_GREEN a Green LED, LED_BLUE a Blue LED and * LED_RED a Red LED, that can be controlled by software. * * If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any way. @@ -366,10 +366,10 @@ #define GPIO_USART1_RX GPIO_USART1_RX_3 /* PB7 */ #define GPIO_USART1_TX GPIO_USART1_TX_3 /* PB6 */ -#define GPIO_USART2_RX GPIO_USART2_RX_1 /* PA3 */ -#define GPIO_USART2_TX GPIO_USART2_TX_2 /* PD5 */ -#define GPIO_USART2_RTS GPIO_USART2_RTS_2 /* PD4 */ -#define GPIO_USART2_CTS GPIO_USART2_CTS_NSS_2 /* PD3 */ +#define GPIO_USART2_RX GPIO_USART2_RX_1 /* PA3 */ +#define GPIO_USART2_TX GPIO_USART2_TX_2 /* PD5 */ +#define GPIO_USART2_RTS (GPIO_USART2_RTS_2 | GPIO_PULLDOWN) /* PD4 */ +#define GPIO_USART2_CTS (GPIO_USART2_CTS_NSS_2 | GPIO_PULLDOWN) /* PD3 */ #define GPIO_USART3_RX GPIO_USART3_RX_3 /* PD9 */ #define GPIO_USART3_TX GPIO_USART3_TX_3 /* PD8 */ @@ -385,10 +385,10 @@ #define GPIO_USART6_RX GPIO_USART6_RX_1 /* PC7 */ #define GPIO_USART6_TX GPIO_USART6_TX_1 /* PC6 */ -#define GPIO_UART7_RX GPIO_UART7_RX_4 /* PF6 */ -#define GPIO_UART7_TX GPIO_UART7_TX_3 /* PE8 */ -#define GPIO_UART7_RTS GPIO_UART7_RTS_2 /* PF8 */ -#define GPIO_UART7_CTS GPIO_UART7_CTS_1 /* PE10 */ +#define GPIO_UART7_RX GPIO_UART7_RX_4 /* PF6 */ +#define GPIO_UART7_TX GPIO_UART7_TX_3 /* PE8 */ +#define GPIO_UART7_RTS (GPIO_UART7_RTS_2 | GPIO_PULLDOWN) /* PF8 */ +#define GPIO_UART7_CTS (GPIO_UART7_CTS_1 | GPIO_PULLDOWN) /* PE10 */ #define GPIO_UART8_RX GPIO_UART8_RX_1 /* PE0 */ #define GPIO_UART8_TX GPIO_UART8_TX_1 /* PE1 */ @@ -447,27 +447,15 @@ #define GPIO_I2C1_SCL GPIO_I2C1_SCL_2 /* PB8 */ #define GPIO_I2C1_SDA GPIO_I2C1_SDA_2 /* PB9 */ -#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_2 /* PF1 */ #define GPIO_I2C2_SDA GPIO_I2C2_SDA_2 /* PF0 */ -#define GPIO_I2C2_SCL_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN |GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTF | GPIO_PIN1) -#define GPIO_I2C2_SDA_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN |GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTF | GPIO_PIN0) - #define GPIO_I2C3_SCL GPIO_I2C3_SCL_1 /* PA8 */ #define GPIO_I2C3_SDA GPIO_I2C3_SDA_2 /* PH8 */ -#define GPIO_I2C3_SCL_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN |GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTA | GPIO_PIN8) -#define GPIO_I2C3_SDA_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN |GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTH | GPIO_PIN8) - #define GPIO_I2C4_SCL GPIO_I2C4_SCL_2 /* PF14 */ #define GPIO_I2C4_SDA GPIO_I2C4_SDA_2 /* PF15 */ -#define GPIO_I2C4_SCL_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN | GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTF | GPIO_PIN14) -#define GPIO_I2C4_SDA_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN | GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTF | GPIO_PIN15) - /* SDMMC2 * * VDD 3.3 diff --git a/boards/ark/fmu-v6x/nuttx-config/scripts/bootloader_script.ld b/boards/ark/fmu-v6x/nuttx-config/scripts/bootloader_script.ld index 5b1bb4cb05..2929c89fe5 100644 --- a/boards/ark/fmu-v6x/nuttx-config/scripts/bootloader_script.ld +++ b/boards/ark/fmu-v6x/nuttx-config/scripts/bootloader_script.ld @@ -34,7 +34,7 @@ * ****************************************************************************/ -/* The ARKV6X uses an STM32H753II has 2048Kb of main FLASH memory. +/* The board uses an STM32H753II has 2048Kb of main FLASH memory. * The flash memory is partitioned into a User Flash memory and a System * Flash memory. Each of these memories has two banks: * @@ -59,7 +59,7 @@ * 2) BOOT=1: Boot address defined by user option byte BOOT_ADD1[15:0]. * ST programmed value: System bootloader at 0x1FF0:0000 * - * The ARKV6X has a test point on board, the BOOT0 pin is at ground so by + * The board has a test point on board, the BOOT0 pin is at ground so by * default, the STM32 will boot to address 0x0800:0000 in FLASH unless the test * point is pulled to 3.3V.then the boot will be from 0x1FF0:0000 * diff --git a/boards/ark/fmu-v6x/nuttx-config/scripts/script.ld b/boards/ark/fmu-v6x/nuttx-config/scripts/script.ld index d06a7d7aa7..79dad57a4d 100644 --- a/boards/ark/fmu-v6x/nuttx-config/scripts/script.ld +++ b/boards/ark/fmu-v6x/nuttx-config/scripts/script.ld @@ -34,7 +34,7 @@ * ****************************************************************************/ -/* The ARKV6X uses an STM32H753II has 2048Kb of main FLASH memory. +/* The board uses an STM32H753II has 2048Kb of main FLASH memory. * The flash memory is partitioned into a User Flash memory and a System * Flash memory. Each of these memories has two banks: * @@ -59,7 +59,7 @@ * 2) BOOT=1: Boot address defined by user option byte BOOT_ADD1[15:0]. * ST programmed value: System bootloader at 0x1FF0:0000 * - * The ARKV6X has a test point on board, the BOOT0 pin is at ground so by + * The board has a test point on board, the BOOT0 pin is at ground so by * default, the STM32 will boot to address 0x0800:0000 in FLASH unless the test * point is pulled to 3.3V.then the boot will be from 0x1FF0:0000 * diff --git a/boards/ark/fmu-v6x/src/CMakeLists.txt b/boards/ark/fmu-v6x/src/CMakeLists.txt index 3135751c66..76e4e4f47a 100644 --- a/boards/ark/fmu-v6x/src/CMakeLists.txt +++ b/boards/ark/fmu-v6x/src/CMakeLists.txt @@ -40,6 +40,7 @@ if("${PX4_BOARD_LABEL}" STREQUAL "bootloader") ) target_link_libraries(drivers_board PRIVATE + arch_board_init nuttx_arch # sdio nuttx_drivers # sdio px4_layer #gpio @@ -67,6 +68,7 @@ else() target_link_libraries(drivers_board PRIVATE + arch_board_init arch_io_pins arch_spi arch_board_hw_info diff --git a/boards/ark/fmu-v6x/src/board_config.h b/boards/ark/fmu-v6x/src/board_config.h index 752caf497e..8f492d240d 100644 --- a/boards/ark/fmu-v6x/src/board_config.h +++ b/boards/ark/fmu-v6x/src/board_config.h @@ -34,7 +34,7 @@ /** * @file board_config.h * - * ARKFMU-v6x internal definitions + * board internal definitions */ #pragma once @@ -253,15 +253,6 @@ #define DIRECT_PWM_OUTPUT_CHANNELS 8 #define BOARD_PWM_FREQ 1024000 -#define GPIO_FMU_CH1 /* PI0 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTI|GPIO_PIN0) -#define GPIO_FMU_CH2 /* PH12 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTH|GPIO_PIN12) -#define GPIO_FMU_CH3 /* PH11 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTH|GPIO_PIN11) -#define GPIO_FMU_CH4 /* PH10 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTH|GPIO_PIN10) -#define GPIO_FMU_CH5 /* PD13 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTD|GPIO_PIN13) -#define GPIO_FMU_CH6 /* PD14 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTD|GPIO_PIN14) -#define GPIO_FMU_CH7 /* PH6 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTH|GPIO_PIN6) -#define GPIO_FMU_CH8 /* PH9 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTH|GPIO_PIN9) - #define GPIO_FMU_CAP /* PE11 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTE|GPIO_PIN11) #define GPIO_SPIX_SYNC /* PE9 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTE|GPIO_PIN9) @@ -367,7 +358,7 @@ #define SPEKTRUM_POWER(_on_true) VDD_3V3_SPEKTRUM_POWER_EN(_on_true) /* - * ARKV6X has a separate RC_IN + * board has a separate RC_IN * * GPIO PPM_IN on PI5 T8CH1 * SPEKTRUM_RX (it's TX or RX in Bind) on UART6 PC7 @@ -401,7 +392,7 @@ #define BOARD_ADC_USB_CONNECTED (px4_arch_gpioread(GPIO_OTGFS_VBUS)) #define BOARD_ADC_USB_VALID (!px4_arch_gpioread(GPIO_nVDD_USB_VALID)) -/* ARKV6X never powers off the Servo rail */ +/* board never powers off the Servo rail */ #define BOARD_ADC_SERVO_VALID (1) @@ -453,14 +444,11 @@ GPIO_TRACE, \ PX4_ADC_GPIO, \ GPIO_HW_VER_REV_DRIVE, \ - GPIO_CAN1_TX, \ - GPIO_CAN1_RX, \ - GPIO_CAN2_TX, \ - GPIO_CAN2_RX, \ GPIO_HEATER_OUTPUT, \ GPIO_nPOWER_IN_A, \ GPIO_nPOWER_IN_B, \ GPIO_nPOWER_IN_C, \ + GPIO_OTGFS_VBUS, \ GPIO_VDD_5V_PERIPH_nEN, \ GPIO_VDD_5V_PERIPH_nOC, \ GPIO_VDD_5V_HIPOWER_nEN, \ @@ -477,15 +465,7 @@ GPIO_SAFETY_SWITCH_IN, \ GPIO_PG6, \ GPIO_nARMED_INIT, \ - GPIO_FMU_CH1, \ - GPIO_FMU_CH2, \ - GPIO_FMU_CH3, \ - GPIO_FMU_CH4, \ - GPIO_FMU_CH5, \ - GPIO_FMU_CH6, \ - GPIO_FMU_CH7, \ - GPIO_FMU_CH8, \ - GPIO_FMU_CAP, \ + GPIO_FMU_CAP, \ GPIO_SPIX_SYNC \ } @@ -533,8 +513,6 @@ int stm32_sdio_initialize(void); extern void stm32_spiinitialize(void); -extern void stm32_usbinitialize(void); - extern void board_peripheral_reset(int ms); #include diff --git a/boards/ark/fmu-v6x/src/bootloader_main.c b/boards/ark/fmu-v6x/src/bootloader_main.c index 7a3ef5e019..a42de95c75 100644 --- a/boards/ark/fmu-v6x/src/bootloader_main.c +++ b/boards/ark/fmu-v6x/src/bootloader_main.c @@ -46,33 +46,10 @@ #include #include #include "arm_internal.h" -#include #include extern int sercon_main(int c, char **argv); -__EXPORT void board_on_reset(int status) {} - -__EXPORT void stm32_boardinitialize(void) -{ - /* configure pins */ - const uint32_t list[] = PX4_GPIO_INIT_LIST; - - for (size_t gpio = 0; gpio < arraySize(list); gpio++) { - if (list[gpio] != 0) { - px4_arch_configgpio(list[gpio]); - } - } - - /* configure USB interfaces */ - stm32_usbinitialize(); -} - -__EXPORT int board_app_initialize(uintptr_t arg) -{ - return 0; -} - void board_late_initialize(void) { sercon_main(0, NULL); diff --git a/boards/ark/fmu-v6x/src/init.c b/boards/ark/fmu-v6x/src/init.c index fddc066d1e..3d7e8309cc 100644 --- a/boards/ark/fmu-v6x/src/init.c +++ b/boards/ark/fmu-v6x/src/init.c @@ -34,7 +34,7 @@ /** * @file init.c * - * ARKFMU-specific early startup code. This file implements the + * board-specific early startup code. This file implements the * board_app_initialize() function that is called early by nsh during startup. * * Code here is run before the rcS script is invoked; it should start required @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -165,23 +166,12 @@ __EXPORT void board_on_reset(int status) __EXPORT void stm32_boardinitialize(void) { - board_on_reset(-1); /* Reset PWM first thing */ + px4_arch_pin_initialize(); /* configure LEDs */ - board_autoled_initialize(); - /* configure pins */ - - const uint32_t gpio[] = PX4_GPIO_INIT_LIST; - px4_gpio_init(gpio, arraySize(gpio)); - - /* configure USB interfaces */ - - stm32_usbinitialize(); - VDD_3V3_ETH_POWER_EN(true); - } /**************************************************************************** @@ -211,7 +201,10 @@ stm32_boardinitialize(void) __EXPORT int board_app_initialize(uintptr_t arg) { +#if !defined(BOOTLOADER) + /* Power on Interfaces */ + VDD_3V3_SD_CARD_EN(true); VDD_5V_PERIPH_EN(true); VDD_5V_HIPOWER_EN(true); VDD_3V3_SENSORS4_EN(true); @@ -249,11 +242,11 @@ __EXPORT int board_app_initialize(uintptr_t arg) syslog(LOG_ERR, "[boot] DMA alloc FAILED\n"); } -#if defined(SERIAL_HAVE_RXDMA) +# if defined(SERIAL_HAVE_RXDMA) // set up the serial DMA polling at 1ms intervals for received bytes that have not triggered a DMA event. static struct hrt_call serial_dma_call; hrt_call_every(&serial_dma_call, 1000, 1000, (hrt_callout)stm32_serial_dma_poll, NULL); -#endif +# endif /* initial LED state */ drv_led_start(); @@ -270,7 +263,7 @@ __EXPORT int board_app_initialize(uintptr_t arg) VDD_3V3_SD_CARD_EN(true); usleep(500 * 1000); -#ifdef CONFIG_MMCSD +# ifdef CONFIG_MMCSD int ret = stm32_sdio_initialize(); if (ret != OK) { @@ -278,11 +271,13 @@ __EXPORT int board_app_initialize(uintptr_t arg) return ret; } -#endif /* CONFIG_MMCSD */ +# endif /* CONFIG_MMCSD */ /* Configure the SPIX_SYNC output */ spix_sync_servo_init(BOARD_SPIX_SYNC_FREQ); spix_sync_servo_set(0, 150); +#endif /* !defined(BOOTLOADER) */ + return OK; } diff --git a/boards/ark/fmu-v6x/src/led.c b/boards/ark/fmu-v6x/src/led.c index 7730150731..ca0e079577 100644 --- a/boards/ark/fmu-v6x/src/led.c +++ b/boards/ark/fmu-v6x/src/led.c @@ -34,7 +34,7 @@ /** * @file led.c * - * ARKFMU LED backend. + * board LED backend. */ #include diff --git a/boards/ark/fmu-v6x/src/usb.c b/boards/ark/fmu-v6x/src/usb.c index 1c64e94ba1..3b61b2f8e8 100644 --- a/boards/ark/fmu-v6x/src/usb.c +++ b/boards/ark/fmu-v6x/src/usb.c @@ -51,43 +51,12 @@ #include #include -#include "arm_internal.h" +#include #include #include #include #include "board_config.h" -/************************************************************************************ - * Definitions - ************************************************************************************/ - -/************************************************************************************ - * Private Functions - ************************************************************************************/ - -/************************************************************************************ - * Public Functions - ************************************************************************************/ - -/************************************************************************************ - * Name: stm32_usbinitialize - * - * Description: - * Called to setup USB-related GPIO pins for the ARKFMU board. - * - ************************************************************************************/ - -__EXPORT void stm32_usbinitialize(void) -{ - /* The OTG FS has an internal soft pull-up */ - - /* Configure the OTG FS VBUS sensing GPIO, Power On, and Overcurrent GPIOs */ - -#ifdef CONFIG_STM32H7_OTGFS - stm32_configgpio(GPIO_OTGFS_VBUS); -#endif -} - /************************************************************************************ * Name: stm32_usbsuspend * diff --git a/boards/px4/fmu-v5/src/CMakeLists.txt b/boards/px4/fmu-v5/src/CMakeLists.txt index 5323380e37..502ae036a5 100644 --- a/boards/px4/fmu-v5/src/CMakeLists.txt +++ b/boards/px4/fmu-v5/src/CMakeLists.txt @@ -51,6 +51,7 @@ add_dependencies(drivers_board nuttx_context) target_link_libraries(drivers_board PRIVATE + arch_board_init arch_board_hw_info arch_io_pins arch_spi diff --git a/boards/px4/fmu-v5/src/board_config.h b/boards/px4/fmu-v5/src/board_config.h index 8246664dec..d6b50f5a38 100644 --- a/boards/px4/fmu-v5/src/board_config.h +++ b/boards/px4/fmu-v5/src/board_config.h @@ -34,7 +34,7 @@ /** * @file board_config.h * - * PX4FMU-v5 internal definitions + * board internal definitions */ #pragma once @@ -336,7 +336,7 @@ #define SPEKTRUM_POWER_CONFIG() px4_arch_configgpio(GPIO_VDD_3V3_SPEKTRUM_POWER_EN) /* - * FMUv5 has a separate RC_IN + * board has a separate RC_IN * * GPIO PPM_IN on PI5 T8CH1 * SPEKTRUM_RX (it's TX or RX in Bind) on UART6 PG9 (NOT FMUv5 test HW ONLY) @@ -417,15 +417,6 @@ PX4_ADC_GPIO, \ GPIO_HW_REV_DRIVE, \ GPIO_HW_VER_DRIVE, \ - GPIO_CAN1_TX, \ - GPIO_CAN1_RX, \ - GPIO_CAN2_TX, \ - GPIO_CAN2_RX, \ - GPIO_CAN3_TX, \ - GPIO_CAN3_RX, \ - GPIO_CAN1_SILENT_S0, \ - GPIO_CAN2_SILENT_S1, \ - GPIO_CAN3_SILENT_S2, \ GPIO_HEATER_OUTPUT, \ GPIO_nPOWER_IN_A, \ GPIO_nPOWER_IN_B, \ @@ -442,15 +433,7 @@ GPIO_RSSI_IN_INIT, \ GPIO_nSAFETY_SWITCH_LED_OUT_INIT, \ GPIO_SAFETY_SWITCH_IN, \ - GPIO_nARMED_INIT, \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C1_SCL), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C1_SDA), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C2_SCL), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C2_SDA), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C3_SCL), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C3_SDA), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C4_SCL), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C4_SDA), \ + GPIO_nARMED_INIT \ } #define BOARD_ENABLE_CONSOLE_BUFFER @@ -494,8 +477,6 @@ int stm32_sdio_initialize(void); extern void stm32_spiinitialize(void); -extern void stm32_usbinitialize(void); - extern void board_peripheral_reset(int ms); #include diff --git a/boards/px4/fmu-v5/src/can.c b/boards/px4/fmu-v5/src/can.c index fb3ecceb2d..31d366bb9c 100644 --- a/boards/px4/fmu-v5/src/can.c +++ b/boards/px4/fmu-v5/src/can.c @@ -75,19 +75,17 @@ uint16_t board_get_can_interfaces(void) #include "stm32_can.h" #include "board_config.h" -#ifdef CONFIG_CAN - /************************************************************************************ * Pre-processor Definitions ************************************************************************************/ /* Configuration ********************************************************************/ -#if defined(CONFIG_STM32_CAN1) && defined(CONFIG_STM32_CAN2) +#if defined(CONFIG_STM32F7_CAN1) && defined(CONFIG_STM32F7_CAN2) # warning "Both CAN1 and CAN2 are enabled. Assuming only CAN1." -# undef CONFIG_STM32_CAN2 +# undef CONFIG_STM32F7_CAN2 #endif -#ifdef CONFIG_STM32_CAN1 +#ifdef CONFIG_STM32F7_CAN1 # define CAN_PORT 1 #else # define CAN_PORT 2 @@ -145,7 +143,4 @@ int can_devinit(void) return OK; } - -#endif - #endif /* CONFIG_CAN */ diff --git a/boards/px4/fmu-v5/src/init.c b/boards/px4/fmu-v5/src/init.c index cfec81bae6..c6257cef40 100644 --- a/boards/px4/fmu-v5/src/init.c +++ b/boards/px4/fmu-v5/src/init.c @@ -35,10 +35,10 @@ * @file init.c * * PX4FMU-specific early startup code. This file implements the - * board_app_initializ() function that is called early by nsh during startup. + * board_app_initialize() function that is called early by nsh during startup. * * Code here is run before the rcS script is invoked; it should start required - * subsystems and perform board-specific initialisation. + * subsystems and perform board-specific initialization. */ /**************************************************************************** @@ -66,10 +66,11 @@ #include #include "arm_internal.h" -#include #include #include #include +#include +#include #include #include #include @@ -161,22 +162,10 @@ __EXPORT void board_on_reset(int status) __EXPORT void stm32_boardinitialize(void) { - board_on_reset(-1); /* Reset PWM first thing */ + px4_arch_pin_initialize(); /* configure LEDs */ - board_autoled_initialize(); - - /* configure pins */ - - const uint32_t gpio[] = PX4_GPIO_INIT_LIST; - px4_gpio_init(gpio, arraySize(gpio)); - board_control_spi_sensors_power_configgpio(); - - /* configure USB interfaces */ - - stm32_usbinitialize(); - } /**************************************************************************** @@ -204,7 +193,6 @@ stm32_boardinitialize(void) * ****************************************************************************/ - __EXPORT int board_app_initialize(uintptr_t arg) { /* Power on Interfaces */ diff --git a/boards/px4/fmu-v5/src/usb.c b/boards/px4/fmu-v5/src/usb.c index 0e28676586..3b61b2f8e8 100644 --- a/boards/px4/fmu-v5/src/usb.c +++ b/boards/px4/fmu-v5/src/usb.c @@ -57,37 +57,6 @@ #include #include "board_config.h" -/************************************************************************************ - * Definitions - ************************************************************************************/ - -/************************************************************************************ - * Private Functions - ************************************************************************************/ - -/************************************************************************************ - * Public Functions - ************************************************************************************/ - -/************************************************************************************ - * Name: stm32_usbinitialize - * - * Description: - * Called to setup USB-related GPIO pins for the PX4FMU board. - * - ************************************************************************************/ - -__EXPORT void stm32_usbinitialize(void) -{ - /* The OTG FS has an internal soft pull-up */ - - /* Configure the OTG FS VBUS sensing GPIO, Power On, and Overcurrent GPIOs */ - -#ifdef CONFIG_STM32F7_OTGFS - stm32_configgpio(GPIO_OTGFS_VBUS); -#endif -} - /************************************************************************************ * Name: stm32_usbsuspend * diff --git a/boards/px4/fmu-v5x/src/CMakeLists.txt b/boards/px4/fmu-v5x/src/CMakeLists.txt index 684b11736e..346552cb93 100644 --- a/boards/px4/fmu-v5x/src/CMakeLists.txt +++ b/boards/px4/fmu-v5x/src/CMakeLists.txt @@ -48,6 +48,7 @@ add_dependencies(drivers_board platform_gpio_mcp23009) target_link_libraries(drivers_board PRIVATE + arch_board_init arch_io_pins arch_spi arch_board_hw_info diff --git a/boards/px4/fmu-v5x/src/board_config.h b/boards/px4/fmu-v5x/src/board_config.h index 281c769f26..10bf1d62e5 100644 --- a/boards/px4/fmu-v5x/src/board_config.h +++ b/boards/px4/fmu-v5x/src/board_config.h @@ -34,7 +34,7 @@ /** * @file board_config.h * - * PX4FMU-v5 internal definitions + * board internal definitions */ #pragma once @@ -334,7 +334,7 @@ #define SPEKTRUM_POWER(_on_true) VDD_3V3_SPEKTRUM_POWER_EN(_on_true) /* - * FMUv5X has a separate RC_IN + * board has a separate RC_IN * * GPIO PPM_IN on PI5 T8CH1 * SPEKTRUM_RX (it's TX or RX in Bind) on UART6 PC7 @@ -368,7 +368,7 @@ #define BOARD_ADC_USB_CONNECTED (px4_arch_gpioread(GPIO_OTGFS_VBUS)) #define BOARD_ADC_USB_VALID (!px4_arch_gpioread(GPIO_nVDD_USB_VALID)) -/* FMUv5X never powers off the Servo rail */ +/* board never powers off the Servo rail */ #define BOARD_ADC_SERVO_VALID (1) @@ -408,10 +408,6 @@ #define PX4_GPIO_INIT_LIST { \ PX4_ADC_GPIO, \ GPIO_HW_VER_REV_DRIVE, \ - GPIO_CAN1_TX, \ - GPIO_CAN1_RX, \ - GPIO_CAN2_TX, \ - GPIO_CAN2_RX, \ GPIO_HEATER_OUTPUT, \ GPIO_nPOWER_IN_A, \ GPIO_nPOWER_IN_B, \ @@ -432,15 +428,7 @@ GPIO_nSAFETY_SWITCH_LED_OUT_INIT, \ GPIO_SAFETY_SWITCH_IN, \ GPIO_PG6, \ - GPIO_nARMED_INIT, \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C1_SCL), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C1_SDA), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C2_SCL), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C2_SDA), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C3_SCL), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C3_SDA), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C4_SCL), \ - PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C4_SDA), \ + GPIO_nARMED_INIT \ } #define BOARD_ENABLE_CONSOLE_BUFFER @@ -486,8 +474,6 @@ int stm32_sdio_initialize(void); extern void stm32_spiinitialize(void); -extern void stm32_usbinitialize(void); - extern void board_peripheral_reset(int ms); #include diff --git a/boards/px4/fmu-v5x/src/can.c b/boards/px4/fmu-v5x/src/can.c index bb777d8f04..9250993a2b 100644 --- a/boards/px4/fmu-v5x/src/can.c +++ b/boards/px4/fmu-v5x/src/can.c @@ -32,7 +32,7 @@ ****************************************************************************/ /** - * @file px4fmu_can.c + * @file can.c * * Board-specific CAN functions. */ diff --git a/boards/px4/fmu-v5x/src/init.cpp b/boards/px4/fmu-v5x/src/init.cpp index a6606761db..beaf4f0c3c 100644 --- a/boards/px4/fmu-v5x/src/init.cpp +++ b/boards/px4/fmu-v5x/src/init.cpp @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -163,23 +164,12 @@ __EXPORT void board_on_reset(int status) extern "C" __EXPORT void stm32_boardinitialize(void) { - board_on_reset(-1); /* Reset PWM first thing */ + px4_arch_pin_initialize(); /* configure LEDs */ - board_autoled_initialize(); - /* configure pins */ - - const uint32_t gpio[] = PX4_GPIO_INIT_LIST; - px4_gpio_init(gpio, arraySize(gpio)); - - /* configure USB interfaces */ - - stm32_usbinitialize(); - VDD_3V3_ETH_POWER_EN(true); - } /**************************************************************************** diff --git a/boards/px4/fmu-v5x/src/usb.c b/boards/px4/fmu-v5x/src/usb.c index 28965c442d..3b61b2f8e8 100644 --- a/boards/px4/fmu-v5x/src/usb.c +++ b/boards/px4/fmu-v5x/src/usb.c @@ -32,7 +32,7 @@ ****************************************************************************/ /** - * @file px4fmu_usb.c + * @file usb.c * * Board-specific USB functions. */ @@ -57,37 +57,6 @@ #include #include "board_config.h" -/************************************************************************************ - * Definitions - ************************************************************************************/ - -/************************************************************************************ - * Private Functions - ************************************************************************************/ - -/************************************************************************************ - * Public Functions - ************************************************************************************/ - -/************************************************************************************ - * Name: stm32_usbinitialize - * - * Description: - * Called to setup USB-related GPIO pins for the PX4FMU board. - * - ************************************************************************************/ - -__EXPORT void stm32_usbinitialize(void) -{ - /* The OTG FS has an internal soft pull-up */ - - /* Configure the OTG FS VBUS sensing GPIO, Power On, and Overcurrent GPIOs */ - -#ifdef CONFIG_STM32F7_OTGFS - stm32_configgpio(GPIO_OTGFS_VBUS); -#endif -} - /************************************************************************************ * Name: stm32_usbsuspend * diff --git a/boards/px4/fmu-v6x/extras/px4_fmu-v6x_bootloader.bin b/boards/px4/fmu-v6x/extras/px4_fmu-v6x_bootloader.bin index 9668fdb20b..bd7a4e4082 100755 Binary files a/boards/px4/fmu-v6x/extras/px4_fmu-v6x_bootloader.bin and b/boards/px4/fmu-v6x/extras/px4_fmu-v6x_bootloader.bin differ diff --git a/boards/px4/fmu-v6x/nuttx-config/include/board.h b/boards/px4/fmu-v6x/nuttx-config/include/board.h index 99d79a9f3e..12f18cf108 100644 --- a/boards/px4/fmu-v6x/nuttx-config/include/board.h +++ b/boards/px4/fmu-v6x/nuttx-config/include/board.h @@ -302,7 +302,7 @@ #define STM32_SDMMC_CLKCR_EDGE STM32_SDMMC_CLKCR_NEGEDGE /* LED definitions ******************************************************************/ -/* The PX4 FMUV6X board has three, LED_GREEN a Green LED, LED_BLUE a Blue LED and +/* The board board has three, LED_GREEN a Green LED, LED_BLUE a Blue LED and * LED_RED a Red LED, that can be controlled by software. * * If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any way. @@ -366,10 +366,10 @@ #define GPIO_USART1_RX GPIO_USART1_RX_3 /* PB7 */ #define GPIO_USART1_TX GPIO_USART1_TX_3 /* PB6 */ -#define GPIO_USART2_RX GPIO_USART2_RX_1 /* PA3 */ -#define GPIO_USART2_TX GPIO_USART2_TX_2 /* PD5 */ -#define GPIO_USART2_RTS GPIO_USART2_RTS_2 /* PD4 */ -#define GPIO_USART2_CTS GPIO_USART2_CTS_NSS_2 /* PD3 */ +#define GPIO_USART2_RX GPIO_USART2_RX_1 /* PA3 */ +#define GPIO_USART2_TX GPIO_USART2_TX_2 /* PD5 */ +#define GPIO_USART2_RTS (GPIO_USART2_RTS_2 | GPIO_PULLDOWN) /* PD4 */ +#define GPIO_USART2_CTS (GPIO_USART2_CTS_NSS_2 | GPIO_PULLDOWN) /* PD3 */ #define GPIO_USART3_RX GPIO_USART3_RX_3 /* PD9 */ #define GPIO_USART3_TX GPIO_USART3_TX_3 /* PD8 */ @@ -385,10 +385,10 @@ #define GPIO_USART6_RX GPIO_USART6_RX_1 /* PC7 */ #define GPIO_USART6_TX GPIO_USART6_TX_1 /* PC6 */ -#define GPIO_UART7_RX GPIO_UART7_RX_4 /* PF6 */ -#define GPIO_UART7_TX GPIO_UART7_TX_3 /* PE8 */ -#define GPIO_UART7_RTS (GPIO_UART7_RTS_2 | GPIO_PULLDOWN) /* PF8 */ -#define GPIO_UART7_CTS (GPIO_UART7_CTS_1 | GPIO_PULLDOWN) /* PE10 */ +#define GPIO_UART7_RX GPIO_UART7_RX_4 /* PF6 */ +#define GPIO_UART7_TX GPIO_UART7_TX_3 /* PE8 */ +#define GPIO_UART7_RTS (GPIO_UART7_RTS_2 | GPIO_PULLDOWN) /* PF8 */ +#define GPIO_UART7_CTS (GPIO_UART7_CTS_1 | GPIO_PULLDOWN) /* PE10 */ #define GPIO_UART8_RX GPIO_UART8_RX_1 /* PE0 */ #define GPIO_UART8_TX GPIO_UART8_TX_1 /* PE1 */ @@ -447,27 +447,15 @@ #define GPIO_I2C1_SCL GPIO_I2C1_SCL_2 /* PB8 */ #define GPIO_I2C1_SDA GPIO_I2C1_SDA_2 /* PB9 */ -#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_2 /* PF1 */ #define GPIO_I2C2_SDA GPIO_I2C2_SDA_2 /* PF0 */ -#define GPIO_I2C2_SCL_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN |GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTF | GPIO_PIN1) -#define GPIO_I2C2_SDA_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN |GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTF | GPIO_PIN0) - #define GPIO_I2C3_SCL GPIO_I2C3_SCL_1 /* PA8 */ #define GPIO_I2C3_SDA GPIO_I2C3_SDA_2 /* PH8 */ -#define GPIO_I2C3_SCL_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN |GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTA | GPIO_PIN8) -#define GPIO_I2C3_SDA_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN |GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTH | GPIO_PIN8) - #define GPIO_I2C4_SCL GPIO_I2C4_SCL_2 /* PF14 */ #define GPIO_I2C4_SDA GPIO_I2C4_SDA_2 /* PF15 */ -#define GPIO_I2C4_SCL_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN | GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTF | GPIO_PIN14) -#define GPIO_I2C4_SDA_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN | GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTF | GPIO_PIN15) - /* SDMMC2 * * VDD 3.3 diff --git a/boards/px4/fmu-v6x/nuttx-config/scripts/bootloader_script.ld b/boards/px4/fmu-v6x/nuttx-config/scripts/bootloader_script.ld index 2e6eba3607..5cb342d0a2 100644 --- a/boards/px4/fmu-v6x/nuttx-config/scripts/bootloader_script.ld +++ b/boards/px4/fmu-v6x/nuttx-config/scripts/bootloader_script.ld @@ -34,7 +34,7 @@ * ****************************************************************************/ -/* The PX4 FMUV6X uses an STM32H753II has 2048Kb of main FLASH memory. +/* The board uses an STM32H753II has 2048Kb of main FLASH memory. * The flash memory is partitioned into a User Flash memory and a System * Flash memory. Each of these memories has two banks: * @@ -59,7 +59,7 @@ * 2) BOOT=1: Boot address defined by user option byte BOOT_ADD1[15:0]. * ST programmed value: System bootloader at 0x1FF0:0000 * - * The PX4 FMUV6X has a test point on board, the BOOT0 pin is at ground so by + * The board has a test point on board, the BOOT0 pin is at ground so by * default, the STM32 will boot to address 0x0800:0000 in FLASH unless the test * point is pulled to 3.3V.then the boot will be from 0x1FF0:0000 * diff --git a/boards/px4/fmu-v6x/nuttx-config/scripts/script.ld b/boards/px4/fmu-v6x/nuttx-config/scripts/script.ld index b6b341d4e8..2694e43560 100644 --- a/boards/px4/fmu-v6x/nuttx-config/scripts/script.ld +++ b/boards/px4/fmu-v6x/nuttx-config/scripts/script.ld @@ -34,7 +34,7 @@ * ****************************************************************************/ -/* The PX4 FMUV6X uses an STM32H753II has 2048Kb of main FLASH memory. +/* The board uses an STM32H753II has 2048Kb of main FLASH memory. * The flash memory is partitioned into a User Flash memory and a System * Flash memory. Each of these memories has two banks: * @@ -59,7 +59,7 @@ * 2) BOOT=1: Boot address defined by user option byte BOOT_ADD1[15:0]. * ST programmed value: System bootloader at 0x1FF0:0000 * - * The PX4 FMUV6X has a test point on board, the BOOT0 pin is at ground so by + * The board has a test point on board, the BOOT0 pin is at ground so by * default, the STM32 will boot to address 0x0800:0000 in FLASH unless the test * point is pulled to 3.3V.then the boot will be from 0x1FF0:0000 * diff --git a/boards/px4/fmu-v6x/src/CMakeLists.txt b/boards/px4/fmu-v6x/src/CMakeLists.txt index d4a16ff4f3..2efc7ebb48 100644 --- a/boards/px4/fmu-v6x/src/CMakeLists.txt +++ b/boards/px4/fmu-v6x/src/CMakeLists.txt @@ -40,6 +40,7 @@ if("${PX4_BOARD_LABEL}" STREQUAL "bootloader") ) target_link_libraries(drivers_board PRIVATE + arch_board_init nuttx_arch # sdio nuttx_drivers # sdio px4_layer #gpio @@ -65,6 +66,7 @@ else() target_link_libraries(drivers_board PRIVATE + arch_board_init arch_io_pins arch_spi arch_board_hw_info diff --git a/boards/px4/fmu-v6x/src/board_config.h b/boards/px4/fmu-v6x/src/board_config.h index fecd7efc9c..4e44a9069e 100644 --- a/boards/px4/fmu-v6x/src/board_config.h +++ b/boards/px4/fmu-v6x/src/board_config.h @@ -34,7 +34,7 @@ /** * @file board_config.h * - * PX4FMU-v6x internal definitions + * board internal definitions */ #pragma once @@ -367,7 +367,7 @@ #define SPEKTRUM_POWER(_on_true) VDD_3V3_SPEKTRUM_POWER_EN(_on_true) /* - * FMUv6X has a separate RC_IN + * board has a separate RC_IN * * GPIO PPM_IN on PI5 T8CH1 * SPEKTRUM_RX (it's TX or RX in Bind) on UART6 PC7 @@ -401,7 +401,7 @@ #define BOARD_ADC_USB_CONNECTED (px4_arch_gpioread(GPIO_OTGFS_VBUS)) #define BOARD_ADC_USB_VALID (!px4_arch_gpioread(GPIO_nVDD_USB_VALID)) -/* FMUv6X never powers off the Servo rail */ +/* board never powers off the Servo rail */ #define BOARD_ADC_SERVO_VALID (1) @@ -453,14 +453,11 @@ GPIO_TRACE, \ PX4_ADC_GPIO, \ GPIO_HW_VER_REV_DRIVE, \ - GPIO_CAN1_TX, \ - GPIO_CAN1_RX, \ - GPIO_CAN2_TX, \ - GPIO_CAN2_RX, \ GPIO_HEATER_OUTPUT, \ GPIO_nPOWER_IN_A, \ GPIO_nPOWER_IN_B, \ GPIO_nPOWER_IN_C, \ + GPIO_OTGFS_VBUS, \ GPIO_VDD_5V_PERIPH_nEN, \ GPIO_VDD_5V_PERIPH_nOC, \ GPIO_VDD_5V_HIPOWER_nEN, \ @@ -523,8 +520,6 @@ int stm32_sdio_initialize(void); extern void stm32_spiinitialize(void); -extern void stm32_usbinitialize(void); - extern void board_peripheral_reset(int ms); #include diff --git a/boards/px4/fmu-v6x/src/can.c b/boards/px4/fmu-v6x/src/can.c index 1f4e1f28a3..cdebe7a3ad 100644 --- a/boards/px4/fmu-v6x/src/can.c +++ b/boards/px4/fmu-v6x/src/can.c @@ -32,7 +32,7 @@ ****************************************************************************/ /** - * @file px4fmu_can.c + * @file can.c * * Board-specific CAN functions. */ diff --git a/boards/px4/fmu-v6x/src/init.c b/boards/px4/fmu-v6x/src/init.c index cd6714af16..ec98efb197 100644 --- a/boards/px4/fmu-v6x/src/init.c +++ b/boards/px4/fmu-v6x/src/init.c @@ -34,7 +34,7 @@ /** * @file init.c * - * PX4FMU-specific early startup code. This file implements the + * board-specific early startup code. This file implements the * board_app_initialize() function that is called early by nsh during startup. * * Code here is run before the rcS script is invoked; it should start required @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -162,23 +163,12 @@ __EXPORT void board_on_reset(int status) __EXPORT void stm32_boardinitialize(void) { - board_on_reset(-1); /* Reset PWM first thing */ + px4_arch_pin_initialize(); /* configure LEDs */ - board_autoled_initialize(); - /* configure pins */ - - const uint32_t gpio[] = PX4_GPIO_INIT_LIST; - px4_gpio_init(gpio, arraySize(gpio)); - - /* configure USB interfaces */ - - stm32_usbinitialize(); - VDD_3V3_ETH_POWER_EN(true); - } /**************************************************************************** diff --git a/boards/px4/fmu-v6x/src/led.c b/boards/px4/fmu-v6x/src/led.c index bff4b09864..ca0e079577 100644 --- a/boards/px4/fmu-v6x/src/led.c +++ b/boards/px4/fmu-v6x/src/led.c @@ -32,9 +32,9 @@ ****************************************************************************/ /** - * @file px4fmu2_led.c + * @file led.c * - * PX4FMU LED backend. + * board LED backend. */ #include diff --git a/boards/px4/fmu-v6x/src/spi.cpp b/boards/px4/fmu-v6x/src/spi.cpp index d3bbdb9315..84f6379595 100644 --- a/boards/px4/fmu-v6x/src/spi.cpp +++ b/boards/px4/fmu-v6x/src/spi.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (C) 2020, 2022 PX4 Development Team. All rights reserved. + * Copyright (C) 2020-2022 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/boards/px4/fmu-v6x/src/usb.c b/boards/px4/fmu-v6x/src/usb.c index 6d42476b71..3b61b2f8e8 100644 --- a/boards/px4/fmu-v6x/src/usb.c +++ b/boards/px4/fmu-v6x/src/usb.c @@ -32,7 +32,7 @@ ****************************************************************************/ /** - * @file px4fmu_usb.c + * @file usb.c * * Board-specific USB functions. */ @@ -57,37 +57,6 @@ #include #include "board_config.h" -/************************************************************************************ - * Definitions - ************************************************************************************/ - -/************************************************************************************ - * Private Functions - ************************************************************************************/ - -/************************************************************************************ - * Public Functions - ************************************************************************************/ - -/************************************************************************************ - * Name: stm32_usbinitialize - * - * Description: - * Called to setup USB-related GPIO pins for the PX4FMU board. - * - ************************************************************************************/ - -__EXPORT void stm32_usbinitialize(void) -{ - /* The OTG FS has an internal soft pull-up */ - - /* Configure the OTG FS VBUS sensing GPIO, Power On, and Overcurrent GPIOs */ - -#ifdef CONFIG_STM32H7_OTGFS - stm32_configgpio(GPIO_OTGFS_VBUS); -#endif -} - /************************************************************************************ * Name: stm32_usbsuspend * diff --git a/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt index b55e895db7..fa73718f88 100644 --- a/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt +++ b/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt @@ -31,6 +31,7 @@ # ############################################################################ +add_subdirectory(board_init) add_subdirectory(../stm32_common/adc adc) add_subdirectory(../stm32_common/board_critmon board_critmon) diff --git a/platforms/nuttx/src/px4/stm/stm32f7/board_init/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32f7/board_init/CMakeLists.txt new file mode 100644 index 0000000000..004241394d --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f7/board_init/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2023 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +px4_add_library(arch_board_init + board_init.cpp +) diff --git a/platforms/nuttx/src/px4/stm/stm32f7/board_init/board_init.cpp b/platforms/nuttx/src/px4/stm/stm32f7/board_init/board_init.cpp new file mode 100644 index 0000000000..9060de724c --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f7/board_init/board_init.cpp @@ -0,0 +1,188 @@ +/**************************************************************************** + * + * Copyright (c) 2023 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#include + +#include "chip.h" +#include "stm32_gpio.h" +#include "board_config.h" + +#include +#include + +#define SPI_PIN_OFF(def) (((def) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz)) +#define SDMMC_PIN_OFF(def) (((def) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | (GPIO_INPUT|GPIO_FLOAT |GPIO_SPEED_2MHz)) + +void px4_arch_pin_initialize() +{ + // Reset PWM first thing + board_on_reset(-1); + + // configure pins +#if defined(PX4_GPIO_INIT_LIST) + const uint32_t list[] = PX4_GPIO_INIT_LIST; + + for (auto &gpio : list) { + if (gpio != 0) { + px4_arch_configgpio(gpio); + } + } + +#endif // PX4_GPIO_INIT_LIST + + + + +// CAN + +#if defined(GPIO_CAN1_RX) + px4_arch_configgpio(GPIO_CAN1_RX); +#endif // GPIO_CAN1_RX +#if defined(GPIO_CAN1_TX) + px4_arch_configgpio(GPIO_CAN1_TX); +#endif // GPIO_CAN1_TX +#if defined(GPIO_CAN1_SILENT_S0) + px4_arch_configgpio(GPIO_CAN1_SILENT_S0); +#endif // GPIO_CAN1_SILENT_S0 + +#if defined(GPIO_CAN2_RX) + px4_arch_configgpio(GPIO_CAN2_RX); +#endif // GPIO_CAN2_RX +#if defined(GPIO_CAN2_TX) + px4_arch_configgpio(GPIO_CAN2_TX); +#endif // GPIO_CAN2_TX +#if defined(GPIO_CAN2_SILENT_S0) + px4_arch_configgpio(GPIO_CAN2_SILENT_S0); +#endif // GPIO_CAN2_SILENT_S0 + +#if defined(GPIO_CAN3_RX) + px4_arch_configgpio(GPIO_CAN3_RX); +#endif // GPIO_CAN3_RX +#if defined(GPIO_CAN3_TX) + px4_arch_configgpio(GPIO_CAN3_TX); +#endif // GPIO_CAN3_TX +#if defined(GPIO_CAN3_SILENT_S0) + px4_arch_configgpio(GPIO_CAN3_SILENT_S0); +#endif // GPIO_CAN3_SILENT_S0 + + + + +// I2C + +#if defined(CONFIG_STM32F7_I2C1) + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C1_SCL)); + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C1_SDA)); +#endif // CONFIG_STM32F7_I2C1 + +#if defined(CONFIG_STM32F7_I2C2) + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C2_SCL)); + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C2_SDA)); +#endif // CONFIG_STM32F7_I2C2 + +#if defined(CONFIG_STM32F7_I2C3) + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C3_SCL)); + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C3_SDA)); +#endif // CONFIG_STM32F7_I2C3 + +#if defined(CONFIG_STM32F7_I2C4) + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C4_SCL)); + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C4_SDA)); +#endif // CONFIG_STM32F7_I2C4 + + + + +// SPI + +#if defined(CONFIG_STM32F7_SPI1) + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI1_SCK)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI1_MISO)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI1_MOSI)); +#endif // CONFIG_STM32_SPI1 +#if defined(CONFIG_STM32F7_SPI2) + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI2_SCK)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI2_MISO)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI2_MOSI)); +#endif // CONFIG_STM32_SPI2 +#if defined(CONFIG_STM32F7_SPI3) + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI3_SCK)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI3_MISO)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI3_MOSI)); +#endif // CONFIG_STM32_SPI3 +#if defined(CONFIG_STM32F7_SPI4) + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI4_SCK)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI4_MISO)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI4_MOSI)); +#endif // CONFIG_STM32_SPI4 +#if defined(CONFIG_STM32F7_SPI5) + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI5_SCK)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI5_MISO)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI5_MOSI)); +#endif // CONFIG_STM32_SPI5 +#if defined(CONFIG_STM32F7_SPI6) + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI6_SCK)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI6_MISO)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI6_MOSI)); +#endif // CONFIG_STM32_SPI6 + + + + +// SDMMC + +#if defined(CONFIG_STM32F7_SDMMC1) + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC1_D0)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC1_D1)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC1_D2)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC1_D3)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC1_CMD)); +#endif // CONFIG_STM32F7_SDMMC1 +#if defined(CONFIG_STM32F7_SDMMC2) + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC2_D0)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC2_D1)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC2_D2)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC2_D3)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC2_CMD)); +#endif // CONFIG_STM32F7_SDMMC2 + + + + +// USB +#if defined(CONFIG_STM32F7_OTGFS) + px4_arch_configgpio(GPIO_OTGFS_VBUS); +#endif + +} + diff --git a/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/board_init.h b/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/board_init.h new file mode 100644 index 0000000000..87bc998907 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/board_init.h @@ -0,0 +1,39 @@ +/**************************************************************************** + * + * Copyright (c) 2023 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ +#pragma once + +__BEGIN_DECLS + +void px4_arch_pin_initialize(void); + +__END_DECLS diff --git a/platforms/nuttx/src/px4/stm/stm32h7/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32h7/CMakeLists.txt index 1205a6eda2..2ff02fb59a 100644 --- a/platforms/nuttx/src/px4/stm/stm32h7/CMakeLists.txt +++ b/platforms/nuttx/src/px4/stm/stm32h7/CMakeLists.txt @@ -31,6 +31,7 @@ # ############################################################################ +add_subdirectory(board_init) add_subdirectory(adc) add_subdirectory(../stm32_common/board_critmon board_critmon) diff --git a/platforms/nuttx/src/px4/stm/stm32h7/board_init/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32h7/board_init/CMakeLists.txt new file mode 100644 index 0000000000..004241394d --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32h7/board_init/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2023 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +px4_add_library(arch_board_init + board_init.cpp +) diff --git a/platforms/nuttx/src/px4/stm/stm32h7/board_init/board_init.cpp b/platforms/nuttx/src/px4/stm/stm32h7/board_init/board_init.cpp new file mode 100644 index 0000000000..095e7f1d54 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32h7/board_init/board_init.cpp @@ -0,0 +1,188 @@ +/**************************************************************************** + * + * Copyright (c) 2023 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#include + +#include "chip.h" +#include "stm32_gpio.h" +#include "board_config.h" + +#include +#include + +#define SPI_PIN_OFF(def) (((def) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz)) +#define SDMMC_PIN_OFF(def) (((def) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | (GPIO_INPUT|GPIO_FLOAT |GPIO_SPEED_2MHz)) + +void px4_arch_pin_initialize() +{ + // Reset PWM first thing + board_on_reset(-1); + + // configure pins +#if defined(PX4_GPIO_INIT_LIST) + const uint32_t list[] = PX4_GPIO_INIT_LIST; + + for (auto &gpio : list) { + if (gpio != 0) { + px4_arch_configgpio(gpio); + } + } + +#endif // PX4_GPIO_INIT_LIST + + + + +// CAN + +#if defined(GPIO_CAN1_RX) + px4_arch_configgpio(GPIO_CAN1_RX); +#endif // GPIO_CAN1_RX +#if defined(GPIO_CAN1_TX) + px4_arch_configgpio(GPIO_CAN1_TX); +#endif // GPIO_CAN1_TX +#if defined(GPIO_CAN1_SILENT_S0) + px4_arch_configgpio(GPIO_CAN1_SILENT_S0); +#endif // GPIO_CAN1_SILENT_S0 + +#if defined(GPIO_CAN2_RX) + px4_arch_configgpio(GPIO_CAN2_RX); +#endif // GPIO_CAN2_RX +#if defined(GPIO_CAN2_TX) + px4_arch_configgpio(GPIO_CAN2_TX); +#endif // GPIO_CAN2_TX +#if defined(GPIO_CAN2_SILENT_S0) + px4_arch_configgpio(GPIO_CAN2_SILENT_S0); +#endif // GPIO_CAN2_SILENT_S0 + +#if defined(GPIO_CAN3_RX) + px4_arch_configgpio(GPIO_CAN3_RX); +#endif // GPIO_CAN3_RX +#if defined(GPIO_CAN3_TX) + px4_arch_configgpio(GPIO_CAN3_TX); +#endif // GPIO_CAN3_TX +#if defined(GPIO_CAN3_SILENT_S0) + px4_arch_configgpio(GPIO_CAN3_SILENT_S0); +#endif // GPIO_CAN3_SILENT_S0 + + + + +// I2C + +#if defined(CONFIG_STM32H7_I2C1) + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C1_SCL)); + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C1_SDA)); +#endif // CONFIG_STM32H7_I2C1 + +#if defined(CONFIG_STM32H7_I2C2) + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C2_SCL)); + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C2_SDA)); +#endif // CONFIG_STM32H7_I2C2 + +#if defined(CONFIG_STM32H7_I2C3) + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C3_SCL)); + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C3_SDA)); +#endif // CONFIG_STM32H7_I2C3 + +#if defined(CONFIG_STM32H7_I2C4) + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C4_SCL)); + px4_arch_configgpio(PX4_MAKE_GPIO_OUTPUT_CLEAR(GPIO_I2C4_SDA)); +#endif // CONFIG_STM32H7_I2C4 + + + + +// SPI + +#if defined(CONFIG_STM32H7_SPI1) + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI1_SCK)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI1_MISO)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI1_MOSI)); +#endif // CONFIG_STM32_SPI1 +#if defined(CONFIG_STM32H7_SPI2) + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI2_SCK)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI2_MISO)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI2_MOSI)); +#endif // CONFIG_STM32_SPI2 +#if defined(CONFIG_STM32H7_SPI3) + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI3_SCK)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI3_MISO)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI3_MOSI)); +#endif // CONFIG_STM32_SPI3 +#if defined(CONFIG_STM32H7_SPI4) + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI4_SCK)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI4_MISO)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI4_MOSI)); +#endif // CONFIG_STM32_SPI4 +#if defined(CONFIG_STM32H7_SPI5) + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI5_SCK)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI5_MISO)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI5_MOSI)); +#endif // CONFIG_STM32_SPI5 +#if defined(CONFIG_STM32H7_SPI6) + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI6_SCK)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI6_MISO)); + px4_arch_configgpio(SPI_PIN_OFF(GPIO_SPI6_MOSI)); +#endif // CONFIG_STM32_SPI6 + + + + +// SDMMC + +#if defined(CONFIG_STM32H7_SDMMC1) + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC1_D0)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC1_D1)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC1_D2)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC1_D3)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC1_CMD)); +#endif // CONFIG_STM32H7_SDMMC1 +#if defined(CONFIG_STM32H7_SDMMC2) + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC2_D0)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC2_D1)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC2_D2)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC2_D3)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SDMMC2_CMD)); +#endif // CONFIG_STM32H7_SDMMC2 + + + + +// USB +#if defined(CONFIG_STM32H7_OTGFS) + px4_arch_configgpio(GPIO_OTGFS_VBUS); +#endif + +} + diff --git a/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/board_init.h b/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/board_init.h new file mode 100644 index 0000000000..87bc998907 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/board_init.h @@ -0,0 +1,39 @@ +/**************************************************************************** + * + * Copyright (c) 2023 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ +#pragma once + +__BEGIN_DECLS + +void px4_arch_pin_initialize(void); + +__END_DECLS