px4fmu-v5:Using arch agnostic gpio init

Define the GPIO pin list use the board_gpio_init
This commit is contained in:
David Sidrane 2017-06-23 13:04:05 -10:00
parent 044b845c40
commit 54bd0a9f2a
3 changed files with 46 additions and 89 deletions

View File

@ -515,6 +515,39 @@ __BEGIN_DECLS
#define BOARD_DMA_ALLOC_POOL_SIZE 5120 #define BOARD_DMA_ALLOC_POOL_SIZE 5120
/* The list of GPIO that will be initialized */
#define PX4_GPIO_PWM_INIT_LIST { \
GPIO_GPIO7_INPUT, \
GPIO_GPIO6_INPUT, \
GPIO_GPIO5_INPUT, \
GPIO_GPIO4_INPUT, \
GPIO_GPIO3_INPUT, \
GPIO_GPIO2_INPUT, \
GPIO_GPIO1_INPUT, \
GPIO_GPIO0_INPUT, \
}
#define PX4_GPIO_INIT_LIST { \
PX4_ADC_GPIO, \
GPIO_HEATER, \
GPIO_CAN1_SILENT_S0, \
GPIO_CAN2_SILENT_S1, \
GPIO_CAN3_SILENT_S2, \
GPIO_POWER_IN_A, \
GPIO_POWER_IN_B, \
GPIO_POWER_IN_C, \
GPIO_VDD_BRICK_VALID, \
GPIO_nVDD_5V_PERIPH_EN, \
GPIO_VDD_3V3_SENSORS_EN, \
GPIO_VDD_3V3V_SD_CARD_EN, \
GPIO_VDD_5V_RC_EN, \
GPIO_VDD_5V_WIFI_EN, \
GPIO_VDD_3V3_SPEKTRUM_POWER_EN, \
GPIO_nSAFETY_SWITCH_LED_OUT, \
GPIO_SAFETY_SWITCH_IN, \
}
/**************************************************************************************************** /****************************************************************************************************
* Public Types * Public Types
****************************************************************************************************/ ****************************************************************************************************/

View File

@ -205,59 +205,19 @@ __EXPORT void board_peripheral_reset(int ms)
__EXPORT void __EXPORT void
stm32_boardinitialize(void) stm32_boardinitialize(void)
{ {
board_on_reset(-1); /* Reset PWM first thing */
/* configure LEDs */ /* configure LEDs */
board_autoled_initialize(); board_autoled_initialize();
/* configure the GPIO pins to outputs and keep them low */ /* configure pins */
stm32_configgpio(GPIO_GPIO0_OUTPUT);
stm32_configgpio(GPIO_GPIO1_OUTPUT);
stm32_configgpio(GPIO_GPIO2_OUTPUT);
stm32_configgpio(GPIO_GPIO3_OUTPUT);
stm32_configgpio(GPIO_GPIO4_OUTPUT);
stm32_configgpio(GPIO_GPIO5_OUTPUT);
/* configure ADC pins */ const uint32_t gpio[] = PX4_GPIO_INIT_LIST;
stm32_configgpio(GPIO_ADC1_IN0); /* ADC_BATTERY_VOLTAGE_CHANNEL */ board_gpio_init(gpio, arraySize(gpio));
stm32_configgpio(GPIO_ADC1_IN1); /* ADC_BATTERY_CURRENT_CHANNEL */
stm32_configgpio(GPIO_ADC1_IN2); /* ADC_BATTERY1_VOLTAGE_CHANNEL */
stm32_configgpio(GPIO_ADC1_IN3); /* ADC_BATTERY1_CURRENT_CHANNEL */
stm32_configgpio(GPIO_ADC1_IN4); /* ADC_5V_RAIL_SENSE */
stm32_configgpio(GPIO_ADC1_IN8); /* ADC_RC_RSSI_CHANNEL */
stm32_configgpio(GPIO_ADC1_IN10); /* ADC_INT_1 */
stm32_configgpio(GPIO_ADC1_IN11); /* ADC_INT_2 */
stm32_configgpio(GPIO_ADC1_IN12); /* ADC_INT_3 */
stm32_configgpio(GPIO_ADC1_IN13); /* ADC_INT_4 */
stm32_configgpio(GPIO_ADC1_IN14); /* ADC_INT_5 */
/* Configure the HEATER off */
stm32_configgpio(GPIO_HEATER);
/* Configure the CAN Silent Control pins and keep them low */
stm32_configgpio(GPIO_CAN1_SILENCE);
stm32_configgpio(GPIO_CAN2_SILENCE);
stm32_configgpio(GPIO_CAN3_SILENCE);
/* configure power supply control/sense pins */
stm32_configgpio(GPIO_POWER_IN_A);
stm32_configgpio(GPIO_POWER_IN_B);
stm32_configgpio(GPIO_POWER_IN_C);
stm32_configgpio(GPIO_VDD_BRICK_VALID);
stm32_configgpio(GPIO_nVDD_5V_PERIPH_EN);
stm32_configgpio(GPIO_VDD_3V3_SENSORS_EN);
stm32_configgpio(GPIO_VDD_3V3V_SD_CARD_EN);
stm32_configgpio(GPIO_VDD_5V_RC_EN);
stm32_configgpio(GPIO_VDD_5V_WIFI_EN);
stm32_configgpio(GPIO_VDD_3V3_SPEKTRUM_POWER_EN);
stm32_configgpio(GPIO_nSAFETY_SWITCH_LED_OUT);
stm32_configgpio(GPIO_SAFETY_SWITCH_IN);
/* configure SPI interfaces */ /* configure SPI interfaces */
stm32_spiinitialize(); stm32_spiinitialize();
} }

View File

@ -109,59 +109,23 @@ static const uint32_t spi6selects_gpio[] = PX4_EXTERNAL2_BUS_CS_GPIO;
__EXPORT void stm32_spiinitialize(void) __EXPORT void stm32_spiinitialize(void)
{ {
#ifdef CONFIG_STM32F7_SPI1 #ifdef CONFIG_STM32F7_SPI1
board_gpio_init(spi1selects_gpio, arraySize(spi1selects_gpio));
for (int cs = 0; cs < arraySize(spi1selects_gpio); cs++) {
if (spi1selects_gpio[cs] != 0) {
stm32_configgpio(spi1selects_gpio[cs]);
}
}
#endif #endif
#ifdef CONFIG_STM32F7_SPI2 #ifdef CONFIG_STM32F7_SPI2
board_gpio_init(spi2selects_gpio, arraySize(spi2selects_gpio));
for (int cs = 0; cs < arraySize(spi2selects_gpio); cs++) {
if (spi2selects_gpio[cs] != 0) {
stm32_configgpio(spi2selects_gpio[cs]);
}
}
#endif #endif
#ifdef CONFIG_STM32F7_SPI3 #ifdef CONFIG_STM32F7_SPI3
board_gpio_init(spi3selects_gpio, arraySize(spi3selects_gpio));
for (int cs = 0; cs < arraySize(spi3selects_gpio); cs++) {
if (spi3selects_gpio[cs] != 0) {
stm32_configgpio(spi3selects_gpio[cs]);
}
}
#endif #endif
#ifdef CONFIG_STM32F7_SPI4 #ifdef CONFIG_STM32F7_SPI4
board_gpio_init(spi4selects_gpio, arraySize(spi4selects_gpio));
for (int cs = 0; cs < arraySize(spi4selects_gpio); cs++) {
if (spi4selects_gpio[cs] != 0) {
stm32_configgpio(spi4selects_gpio[cs]);
}
}
#endif #endif
#ifdef CONFIG_STM32F7_SPI5 #ifdef CONFIG_STM32F7_SPI5
board_gpio_init(spi5selects_gpio, arraySize(spi5selects_gpio));
for (int cs = 0; cs < arraySize(spi5selects_gpio); cs++) {
if (spi5selects_gpio[cs] != 0) {
stm32_configgpio(spi5selects_gpio[cs]);
}
}
#endif #endif
#ifdef CONFIG_STM32F7_SPI6 #ifdef CONFIG_STM32F7_SPI6
board_gpio_init(spi6selects_gpio, arraySize(spi6selects_gpio));
for (int cs = 0; cs < arraySize(spi6selects_gpio); cs++) {
if (spi6selects_gpio[cs] != 0) {
stm32_configgpio(spi6selects_gpio[cs]);
}
}
#endif #endif
} }