Compare commits

...

1 Commits

Author SHA1 Message Date
Daniel Agar 6b0cf1652e WIP: nuttx common early pin init per architecture 2023-01-22 11:55:20 -05:00
39 changed files with 610 additions and 349 deletions
Binary file not shown.
@@ -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
@@ -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
*
@@ -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
*
+2
View File
@@ -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
+5 -27
View File
@@ -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 <px4_platform_common/board_common.h>
-23
View File
@@ -46,33 +46,10 @@
#include <stm32_uart.h>
#include <arch/board/board.h>
#include "arm_internal.h"
#include <px4_platform/gpio.h>
#include <px4_platform_common/init.h>
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);
+12 -17
View File
@@ -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 <drivers/drv_hrt.h>
#include <drivers/drv_board_led.h>
#include <systemlib/px4_macros.h>
#include <px4_arch/board_init.h>
#include <px4_arch/io_timer.h>
#include <px4_platform_common/init.h>
#include <px4_platform_common/px4_manifest.h>
@@ -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;
}
+1 -1
View File
@@ -34,7 +34,7 @@
/**
* @file led.c
*
* ARKFMU LED backend.
* board LED backend.
*/
#include <px4_platform_common/px4_config.h>
+1 -32
View File
@@ -51,43 +51,12 @@
#include <nuttx/usb/usbdev.h>
#include <nuttx/usb/usbdev_trace.h>
#include "arm_internal.h"
#include <arm_internal.h>
#include <chip.h>
#include <stm32_gpio.h>
#include <stm32_otg.h>
#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
*
+1
View File
@@ -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
+3 -22
View File
@@ -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 <px4_platform_common/board_common.h>
+3 -8
View File
@@ -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 */
+5 -17
View File
@@ -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 <arch/board/board.h>
#include "arm_internal.h"
#include <px4_arch/io_timer.h>
#include <drivers/drv_hrt.h>
#include <drivers/drv_board_led.h>
#include <systemlib/px4_macros.h>
#include <px4_arch/board_init.h>
#include <px4_arch/io_timer.h>
#include <px4_platform_common/init.h>
#include <px4_platform/gpio.h>
#include <px4_platform/board_determine_hw_info.h>
@@ -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 */
-31
View File
@@ -57,37 +57,6 @@
#include <stm32_otg.h>
#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
*
+1
View File
@@ -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
+4 -18
View File
@@ -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 <px4_platform_common/board_common.h>
+1 -1
View File
@@ -32,7 +32,7 @@
****************************************************************************/
/**
* @file px4fmu_can.c
* @file can.c
*
* Board-specific CAN functions.
*/
+2 -12
View File
@@ -68,6 +68,7 @@
#include <drivers/drv_hrt.h>
#include <drivers/drv_board_led.h>
#include <systemlib/px4_macros.h>
#include <px4_arch/board_init.h>
#include <px4_arch/io_timer.h>
#include <px4_platform_common/init.h>
#include <px4_platform_common/px4_manifest.h>
@@ -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);
}
/****************************************************************************
+1 -32
View File
@@ -32,7 +32,7 @@
****************************************************************************/
/**
* @file px4fmu_usb.c
* @file usb.c
*
* Board-specific USB functions.
*/
@@ -57,37 +57,6 @@
#include <stm32_otg.h>
#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
*
Binary file not shown.
@@ -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
@@ -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
*
@@ -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
*
+2
View File
@@ -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
+4 -9
View File
@@ -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 <px4_platform_common/board_common.h>
+1 -1
View File
@@ -32,7 +32,7 @@
****************************************************************************/
/**
* @file px4fmu_can.c
* @file can.c
*
* Board-specific CAN functions.
*/
+3 -13
View File
@@ -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 <drivers/drv_hrt.h>
#include <drivers/drv_board_led.h>
#include <systemlib/px4_macros.h>
#include <px4_arch/board_init.h>
#include <px4_arch/io_timer.h>
#include <px4_platform_common/init.h>
#include <px4_platform_common/px4_manifest.h>
@@ -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);
}
/****************************************************************************
+2 -2
View File
@@ -32,9 +32,9 @@
****************************************************************************/
/**
* @file px4fmu2_led.c
* @file led.c
*
* PX4FMU LED backend.
* board LED backend.
*/
#include <px4_platform_common/px4_config.h>
+1 -1
View File
@@ -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
+1 -32
View File
@@ -32,7 +32,7 @@
****************************************************************************/
/**
* @file px4fmu_usb.c
* @file usb.c
*
* Board-specific USB functions.
*/
@@ -57,37 +57,6 @@
#include <stm32_otg.h>
#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
*
@@ -31,6 +31,7 @@
#
############################################################################
add_subdirectory(board_init)
add_subdirectory(../stm32_common/adc adc)
add_subdirectory(../stm32_common/board_critmon board_critmon)
@@ -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
)
@@ -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 <px4_arch/board_init.h>
#include "chip.h"
#include "stm32_gpio.h"
#include "board_config.h"
#include <nuttx/board.h>
#include <arch/board/board.h>
#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
}
@@ -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
@@ -31,6 +31,7 @@
#
############################################################################
add_subdirectory(board_init)
add_subdirectory(adc)
add_subdirectory(../stm32_common/board_critmon board_critmon)
@@ -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
)
@@ -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 <px4_arch/board_init.h>
#include "chip.h"
#include "stm32_gpio.h"
#include "board_config.h"
#include <nuttx/board.h>
#include <arch/board/board.h>
#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
}
@@ -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