diff --git a/boards/atl/mantis-edu/src/CMakeLists.txt b/boards/atl/mantis-edu/src/CMakeLists.txt index 398389f97d..fc7781f8d7 100644 --- a/boards/atl/mantis-edu/src/CMakeLists.txt +++ b/boards/atl/mantis-edu/src/CMakeLists.txt @@ -46,6 +46,7 @@ add_dependencies(drivers_board arch_board_hw_info) target_link_libraries(drivers_board PRIVATE arch_board_hw_info + arch_init arch_spi drivers__led # drv_led_start nuttx_arch # sdio diff --git a/boards/atl/mantis-edu/src/board_config.h b/boards/atl/mantis-edu/src/board_config.h index 2342446c13..0ce43e3510 100644 --- a/boards/atl/mantis-edu/src/board_config.h +++ b/boards/atl/mantis-edu/src/board_config.h @@ -190,7 +190,6 @@ GPIO_HW_VER_DRIVE, \ GPIO_HEATER_OUTPUT, \ GPIO_VDD_3V3_SD_CARD_EN, \ - GPIO_OTGFS_VBUS \ } #define BOARD_ENABLE_CONSOLE_BUFFER diff --git a/boards/atl/mantis-edu/src/init.c b/boards/atl/mantis-edu/src/init.c index 461c16377e..5293e30387 100644 --- a/boards/atl/mantis-edu/src/init.c +++ b/boards/atl/mantis-edu/src/init.c @@ -149,27 +149,6 @@ __EXPORT void board_on_reset(int status) { } -/************************************************************************************ - * 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. - * - ************************************************************************************/ - -__EXPORT void stm32_boardinitialize(void) -{ - /* Hold power state */ - board_pwr_init(0); - - /* configure pins */ - const uint32_t gpio[] = PX4_GPIO_INIT_LIST; - px4_gpio_init(gpio, arraySize(gpio)); - board_control_spi_sensors_power_configgpio(); -} - /**************************************************************************** * Name: board_app_initialize * diff --git a/boards/cubepilot/cubeyellow/src/CMakeLists.txt b/boards/cubepilot/cubeyellow/src/CMakeLists.txt index db075c83d3..d233a948a1 100644 --- a/boards/cubepilot/cubeyellow/src/CMakeLists.txt +++ b/boards/cubepilot/cubeyellow/src/CMakeLists.txt @@ -42,6 +42,7 @@ add_library(drivers_board target_link_libraries(drivers_board PRIVATE + arch_init arch_spi drivers__led # drv_led_start nuttx_arch # sdio diff --git a/boards/cubepilot/cubeyellow/src/board_config.h b/boards/cubepilot/cubeyellow/src/board_config.h index 53fff3ac6e..4b82dfeb0a 100644 --- a/boards/cubepilot/cubeyellow/src/board_config.h +++ b/boards/cubepilot/cubeyellow/src/board_config.h @@ -149,10 +149,6 @@ #define PX4_GPIO_INIT_LIST { \ PX4_ADC_GPIO, \ - GPIO_CAN1_TX, \ - GPIO_CAN1_RX, \ - GPIO_CAN2_TX, \ - GPIO_CAN2_RX, \ GPIO_PWM_VOLT_SEL, \ GPIO_nVDD_BRICK1_VALID, \ GPIO_nVDD_BRICK1_VALID, \ diff --git a/boards/cubepilot/cubeyellow/src/init.c b/boards/cubepilot/cubeyellow/src/init.c index 8ba8972402..5ea043f1ef 100644 --- a/boards/cubepilot/cubeyellow/src/init.c +++ b/boards/cubepilot/cubeyellow/src/init.c @@ -107,29 +107,6 @@ __EXPORT void board_on_reset(int status) } } -/************************************************************************************ - * 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. - * - ************************************************************************************/ -__EXPORT void stm32_boardinitialize(void) -{ - /* Reset PWM first thing */ - board_on_reset(-1); - - /* configure pins */ - const uint32_t gpio[] = PX4_GPIO_INIT_LIST; - px4_gpio_init(gpio, arraySize(gpio)); - board_control_spi_sensors_power_configgpio(); - - /* configure LEDs */ - board_autoled_initialize(); -} - /**************************************************************************** * Name: board_app_initialize * diff --git a/boards/cubepilot/cubeyellow/src/usb.c b/boards/cubepilot/cubeyellow/src/usb.c index 343f3cbcad..d75b63e9e7 100644 --- a/boards/cubepilot/cubeyellow/src/usb.c +++ b/boards/cubepilot/cubeyellow/src/usb.c @@ -37,13 +37,21 @@ * Board-specific USB functions. */ -#include "board_config.h" +#include + +#include +#include +#include +#include + #include #include -#include -#include -#include +#include +#include +#include +#include +#include "board_config.h" /************************************************************************************ * Name: stm32_usbsuspend @@ -55,6 +63,7 @@ * while the USB is suspended. * ************************************************************************************/ + __EXPORT void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume) { uinfo("resume: %d\n", resume); diff --git a/boards/holybro/kakutef7/src/CMakeLists.txt b/boards/holybro/kakutef7/src/CMakeLists.txt index d4a02322dc..9b6731a1c9 100644 --- a/boards/holybro/kakutef7/src/CMakeLists.txt +++ b/boards/holybro/kakutef7/src/CMakeLists.txt @@ -42,6 +42,7 @@ add_library(drivers_board target_link_libraries(drivers_board PRIVATE + arch_init arch_spi drivers__led # drv_led_start nuttx_arch # sdio diff --git a/boards/holybro/kakutef7/src/board_config.h b/boards/holybro/kakutef7/src/board_config.h index 9254c57c52..0ea3def725 100644 --- a/boards/holybro/kakutef7/src/board_config.h +++ b/boards/holybro/kakutef7/src/board_config.h @@ -132,37 +132,11 @@ #define BOARD_NUM_IO_TIMERS 4 __BEGIN_DECLS - -/**************************************************************************************************** - * Public Types - ****************************************************************************************************/ - -/**************************************************************************************************** - * Public data - ****************************************************************************************************/ - #ifndef __ASSEMBLY__ -/**************************************************************************************************** - * Public Functions - ****************************************************************************************************/ - -/**************************************************************************************************** - * Name: stm32_spiinitialize - * - * Description: - * Called to configure SPI chip select GPIO pins for the board. - * - ****************************************************************************************************/ - extern void stm32_spiinitialize(void); - -extern void stm32_usbinitialize(void); - extern void board_peripheral_reset(int ms); #include - #endif /* __ASSEMBLY__ */ - __END_DECLS diff --git a/boards/holybro/kakutef7/src/usb.c b/boards/holybro/kakutef7/src/usb.c index 0ea22da849..d079395b6f 100644 --- a/boards/holybro/kakutef7/src/usb.c +++ b/boards/holybro/kakutef7/src/usb.c @@ -37,10 +37,6 @@ * Board-specific USB functions. */ -/************************************************************************************ - * Included Files - ************************************************************************************/ - #include #include @@ -57,37 +53,6 @@ #include #include "board_config.h" -/************************************************************************************ - * Definitions - ************************************************************************************/ - -/************************************************************************************ - * Private Functions - ************************************************************************************/ - -/************************************************************************************ - * Public Functions - ************************************************************************************/ - -/************************************************************************************ - * Name: stm32_usbinitialize - * - * Description: - * Called to setup USB-related GPIO pins for the 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/modalai/fc-v1/src/CMakeLists.txt b/boards/modalai/fc-v1/src/CMakeLists.txt index 3ccb6124bf..24de464bcb 100644 --- a/boards/modalai/fc-v1/src/CMakeLists.txt +++ b/boards/modalai/fc-v1/src/CMakeLists.txt @@ -46,6 +46,7 @@ add_dependencies(drivers_board arch_board_hw_info) target_link_libraries(drivers_board PRIVATE + arch_init arch_spi arch_board_hw_info drivers__led # drv_led_start diff --git a/boards/modalai/fc-v1/src/board_config.h b/boards/modalai/fc-v1/src/board_config.h index 11e46d6586..9d552fc2c5 100644 --- a/boards/modalai/fc-v1/src/board_config.h +++ b/boards/modalai/fc-v1/src/board_config.h @@ -246,8 +246,6 @@ #define PX4_GPIO_INIT_LIST { \ PX4_ADC_GPIO, \ GPIO_HW_VER_REV_DRIVE, \ - GPIO_CAN1_TX, \ - GPIO_CAN1_RX, \ GPIO_VDD_3V3_SPEKTRUM_POWER_EN, \ GPIO_VDD_3V3_SD_CARD_EN, \ GPIO_A71CH_nRST, \ @@ -299,8 +297,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/modalai/fc-v1/src/init.c b/boards/modalai/fc-v1/src/init.c index beee10b875..c58812af4e 100644 --- a/boards/modalai/fc-v1/src/init.c +++ b/boards/modalai/fc-v1/src/init.c @@ -146,64 +146,6 @@ __EXPORT void board_on_reset(int status) } } -/**************************************************************************** - * Name: board_app_finalinitialize - * - * 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_FINALINIT. - * - * Input Parameters: - * arg - The argument has no meaning. - * - * Returned Value: - * Zero (OK) is returned on success; a negated errno value is returned on - * any failure to indicate the nature of the failure. - * - ****************************************************************************/ - -#ifdef CONFIG_BOARDCTL_FINALINIT -int board_app_finalinitialize(uintptr_t arg) -{ - return 0; -} -#endif - -/************************************************************************************ - * 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. - * - ************************************************************************************/ - -__EXPORT void -stm32_boardinitialize(void) -{ - board_on_reset(-1); /* Reset PWM first thing */ - - /* configure LEDs */ - - board_autoled_initialize(); - - /* configure pins */ - - const uint32_t gpio[] = PX4_GPIO_INIT_LIST; - px4_gpio_init(gpio, arraySize(gpio)); - - /* configure SPI interfaces */ - - stm32_spiinitialize(); - - /* configure USB interfaces */ - - stm32_usbinitialize(); - -} /**************************************************************************** * Name: board_app_initialize @@ -234,12 +176,10 @@ stm32_boardinitialize(void) __EXPORT int board_app_initialize(uintptr_t arg) { /* Power on Interfaces */ - VDD_3V3_SD_CARD_EN(true); VDD_3V3_SPEKTRUM_POWER_EN(true); /* Need hrt running before using the ADC */ - px4_platform_init(); if (OK == board_determine_hw_info()) { @@ -250,8 +190,9 @@ __EXPORT int board_app_initialize(uintptr_t arg) syslog(LOG_ERR, "[boot] Failed to read HW revision and version\n"); } - /* configure the DMA allocator */ + stm32_spiinitialize(); + /* configure the DMA allocator */ if (board_dma_alloc_init() < 0) { syslog(LOG_ERR, "[boot] DMA alloc FAILED\n"); } diff --git a/boards/modalai/fc-v1/src/usb.c b/boards/modalai/fc-v1/src/usb.c index 8fbe73df91..a101b60943 100644 --- a/boards/modalai/fc-v1/src/usb.c +++ b/boards/modalai/fc-v1/src/usb.c @@ -37,10 +37,6 @@ * Board-specific USB functions. */ -/************************************************************************************ - * Included Files - ************************************************************************************/ - #include #include @@ -57,37 +53,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-v5/nuttx-config/include/board.h b/boards/px4/fmu-v5/nuttx-config/include/board.h index de1fb2099d..6d9c96a44b 100644 --- a/boards/px4/fmu-v5/nuttx-config/include/board.h +++ b/boards/px4/fmu-v5/nuttx-config/include/board.h @@ -381,12 +381,6 @@ #define GPIO_SPI6_SCK GPIO_SPI6_SCK_1 /* PG13 */ /* I2C - * - * Each I2C is associated with a U[S]ART - * hence the naming I2C2_SDA_UART4 in FMU USAGE spreadsheet - * - * - * I2C3 is not pined out on FMUv5 on 144 pin packages * * The optional _GPIO configurations allow the I2C driver to manually * reset the bus to clear stuck slaves. They match the pin configuration, diff --git a/boards/px4/fmu-v5/src/CMakeLists.txt b/boards/px4/fmu-v5/src/CMakeLists.txt index f900cbf8be..84dc75b3dd 100644 --- a/boards/px4/fmu-v5/src/CMakeLists.txt +++ b/boards/px4/fmu-v5/src/CMakeLists.txt @@ -52,6 +52,7 @@ add_dependencies(drivers_board nuttx_context) target_link_libraries(drivers_board PRIVATE arch_board_hw_info + arch_init arch_spi drivers__led # drv_led_start nuttx_arch # sdio diff --git a/boards/px4/fmu-v5/src/board_config.h b/boards/px4/fmu-v5/src/board_config.h index 0d9bb9041b..cfe81adbb0 100644 --- a/boards/px4/fmu-v5/src/board_config.h +++ b/boards/px4/fmu-v5/src/board_config.h @@ -434,15 +434,6 @@ static inline bool board_get_external_lockout_state(void) 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, \ @@ -460,14 +451,6 @@ static inline bool board_get_external_lockout_state(void) 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), \ } #define BOARD_ENABLE_CONSOLE_BUFFER @@ -511,8 +494,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/init.c b/boards/px4/fmu-v5/src/init.c index cfec81bae6..c74a0ac744 100644 --- a/boards/px4/fmu-v5/src/init.c +++ b/boards/px4/fmu-v5/src/init.c @@ -148,37 +148,6 @@ __EXPORT void board_on_reset(int status) } } -/************************************************************************************ - * 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. - * - ************************************************************************************/ - -__EXPORT void -stm32_boardinitialize(void) -{ - board_on_reset(-1); /* Reset PWM first thing */ - - /* 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(); - -} - /**************************************************************************** * Name: board_app_initialize * diff --git a/boards/px4/fmu-v5/src/usb.c b/boards/px4/fmu-v5/src/usb.c index ef279653d9..575a0451c7 100644 --- a/boards/px4/fmu-v5/src/usb.c +++ b/boards/px4/fmu-v5/src/usb.c @@ -37,10 +37,6 @@ * Board-specific USB functions. */ -/************************************************************************************ - * Included Files - ************************************************************************************/ - #include #include @@ -57,37 +53,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..33b4bb5fed 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_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 bdb8b2b5fe..acca63124b 100644 --- a/boards/px4/fmu-v5x/src/board_config.h +++ b/boards/px4/fmu-v5x/src/board_config.h @@ -250,7 +250,7 @@ /* ETHERNET GPIO */ -#define GPIO_ETH_POWER_EN /* PG15 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTG|GPIO_PIN15) +#define GPIO_ETH_POWER_EN /* PG15 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN15) /* NFC GPIO */ @@ -399,10 +399,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, \ @@ -424,14 +420,6 @@ 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), \ } #define BOARD_ENABLE_CONSOLE_BUFFER @@ -442,47 +430,13 @@ #define PX4_I2C_BUS_MTD 4,5 __BEGIN_DECLS - -/**************************************************************************************************** - * Public Types - ****************************************************************************************************/ - -/**************************************************************************************************** - * Public data - ****************************************************************************************************/ - #ifndef __ASSEMBLY__ -/**************************************************************************************************** - * Public Functions - ****************************************************************************************************/ - -/**************************************************************************** - * Name: stm32_sdio_initialize - * - * Description: - * Initialize SDIO-based MMC/SD card support - * - ****************************************************************************/ - int stm32_sdio_initialize(void); -/**************************************************************************************************** - * Name: stm32_spiinitialize - * - * Description: - * Called to configure SPI chip select GPIO pins for the PX4FMU board. - * - ****************************************************************************************************/ - extern void stm32_spiinitialize(void); - -extern void stm32_usbinitialize(void); - extern void board_peripheral_reset(int ms); #include - #endif /* __ASSEMBLY__ */ - __END_DECLS diff --git a/boards/px4/fmu-v5x/src/init.cpp b/boards/px4/fmu-v5x/src/init.cpp index 1632e5891e..f3f61399a0 100644 --- a/boards/px4/fmu-v5x/src/init.cpp +++ b/boards/px4/fmu-v5x/src/init.cpp @@ -151,37 +151,6 @@ __EXPORT void board_on_reset(int status) } } -/************************************************************************************ - * 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. - * - ************************************************************************************/ - -extern "C" __EXPORT void -stm32_boardinitialize(void) -{ - board_on_reset(-1); /* Reset PWM first thing */ - - /* 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); - -} /**************************************************************************** * Name: board_app_initialize diff --git a/boards/px4/fmu-v5x/src/usb.c b/boards/px4/fmu-v5x/src/usb.c index 8fbe73df91..575a0451c7 100644 --- a/boards/px4/fmu-v5x/src/usb.c +++ b/boards/px4/fmu-v5x/src/usb.c @@ -32,15 +32,11 @@ ****************************************************************************/ /** - * @file px4fmu_usb.c + * @file usb.c * * Board-specific USB functions. */ -/************************************************************************************ - * Included Files - ************************************************************************************/ - #include #include @@ -57,37 +53,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/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt index b55e895db7..ef14dd5517 100644 --- a/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt +++ b/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt @@ -46,3 +46,9 @@ add_subdirectory(../stm32_common/version version) add_subdirectory(px4io_serial) add_subdirectory(watchdog) + +px4_add_library(arch_init + init.cpp +) + +target_link_libraries(arch_init PRIVATE px4_layer) diff --git a/platforms/nuttx/src/px4/stm/stm32f7/init.cpp b/platforms/nuttx/src/px4/stm/stm32f7/init.cpp new file mode 100644 index 0000000000..e37e2ebe79 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f7/init.cpp @@ -0,0 +1,147 @@ + +/**************************************************************************** + * + * Copyright (c) 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 + * 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 "board_config.h" + +#include +#include +#include + +extern "C" __EXPORT void stm32_boardinitialize(void) +{ +#if defined(BOARD_HAS_ON_RESET) + // Reset PWM first thing + board_on_reset(-1); +#endif // BOARD_HAS_ON_RESET + + +#if defined(PX4_GPIO_INIT_LIST) + // configure pins + static constexpr uint32_t gpio_init_list[] = PX4_GPIO_INIT_LIST; + + for (const auto &gpio : gpio_init_list) { + px4_arch_configgpio(gpio); + } + +#endif // PX4_GPIO_INIT_LIST + + board_control_spi_sensors_power_configgpio(); + + // 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(PX4_GPIO_PIN_OFF(GPIO_SPI1_SCK)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI1_MISO)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI1_MOSI)); +#endif // CONFIG_STM32F7_SPI1 +#if defined(CONFIG_STM32F7_SPI2) + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI2_SCK)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI2_MISO)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI2_MOSI)); +#endif // CONFIG_STM32F7_SPI2 +#if defined(CONFIG_STM32F7_SPI3) + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI3_SCK)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI3_MISO)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI3_MOSI)); +#endif // CONFIG_STM32F7_SPI3 +#if defined(CONFIG_STM32F7_SPI4) + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI4_SCK)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI4_MISO)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI4_MOSI)); +#endif // CONFIG_STM32F7_SPI4 +#if defined(CONFIG_STM32F7_SPI5) + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI5_SCK)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI5_MISO)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI5_MOSI)); +#endif // CONFIG_STM32F7_SPI5 +#if defined(CONFIG_STM32F7_SPI6) + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI6_SCK)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI6_MISO)); + px4_arch_configgpio(PX4_GPIO_PIN_OFF(GPIO_SPI6_MOSI)); +#endif // CONFIG_STM32F7_SPI6 + + + // CAN +#if defined(GPIO_CAN1_TX) && defined(GPIO_CAN1_RX) + px4_arch_configgpio(GPIO_CAN1_TX); + px4_arch_configgpio(GPIO_CAN1_RX); +# if defined(GPIO_CAN1_SILENT_S0) + px4_arch_configgpio(GPIO_CAN1_SILENT_S0); +# endif // GPIO_CAN1_SILENT_S0 +#endif // GPIO_CAN1_TX && GPIO_CAN1_RX +#if defined(GPIO_CAN2_TX) && defined(GPIO_CAN2_RX) + px4_arch_configgpio(GPIO_CAN2_TX); + px4_arch_configgpio(GPIO_CAN2_RX); +# if defined(GPIO_CAN2_SILENT_S0) + px4_arch_configgpio(GPIO_CAN2_SILENT_S0); +# endif // GPIO_CAN2_SILENT_S0 +#endif // GPIO_CAN2_TX && GPIO_CAN2_RX +#if defined(GPIO_CAN3_TX) && defined(GPIO_CAN3_RX) + px4_arch_configgpio(GPIO_CAN3_TX); + px4_arch_configgpio(GPIO_CAN3_RX); +# if defined(GPIO_CAN3_SILENT_S0) + px4_arch_configgpio(GPIO_CAN3_SILENT_S0); +# endif // GPIO_CAN3_SILENT_S0 +#endif // GPIO_CAN3_TX && GPIO_CAN3_RX + + +#if defined(CONFIG_STM32F7_OTGFS) + // configure USB interfaces + stm32_configgpio(GPIO_OTGFS_VBUS); +#endif // CONFIG_STM32F7_OTGFS + + +#if defined(CONFIG_ARCH_LEDS) + // configure LEDs + board_autoled_initialize(); +#endif // CONFIG_ARCH_LEDS +}