From 6641bb0e21260224b02db8ac7944e6ac2c9e9024 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Wed, 8 Apr 2015 15:01:37 +0200 Subject: [PATCH] OP-1828 - Add boards support --- .../boards/discoveryf4bare/firmware/pios_board.c | 11 +++++++++++ flight/targets/boards/discoveryf4bare/pios_board.h | 8 ++++---- flight/targets/boards/osd/firmware/pios_board.c | 11 +++++++++++ flight/targets/boards/osd/pios_board.h | 14 +++++++------- .../boards/revolution/firmware/pios_board.c | 12 +++++++++++- flight/targets/boards/revolution/pios_board.h | 8 ++++---- .../targets/boards/revoproto/firmware/pios_board.c | 11 +++++++++++ flight/targets/boards/revoproto/pios_board.h | 10 +++++----- 8 files changed, 64 insertions(+), 21 deletions(-) diff --git a/flight/targets/boards/discoveryf4bare/firmware/pios_board.c b/flight/targets/boards/discoveryf4bare/firmware/pios_board.c index 3876a28cd..5770db566 100644 --- a/flight/targets/boards/discoveryf4bare/firmware/pios_board.c +++ b/flight/targets/boards/discoveryf4bare/firmware/pios_board.c @@ -908,6 +908,17 @@ void PIOS_Board_Init(void) #include PIOS_WS2811_Init(&pios_ws2811_cfg, &pios_ws2811_pin_cfg); #endif // PIOS_INCLUDE_WS2811 +#ifdef PIOS_INCLUDE_ADC + { + uint8_t adc_config[HWSETTINGS_ADCROUTING_NUMELEM]; + HwSettingsADCRoutingArrayGet(adc_config); + for (uint32_t i = 0; i < HWSETTINGS_ADCROUTING_NUMELEM; i++) { + if (adc_config[i] != HWSETTINGS_ADCROUTING_DISABLED) { + PIOS_ADC_PinSetup(i); + } + } + } +#endif // PIOS_INCLUDE_ADC } /** diff --git a/flight/targets/boards/discoveryf4bare/pios_board.h b/flight/targets/boards/discoveryf4bare/pios_board.h index 82e8df8f9..d25c71d53 100644 --- a/flight/targets/boards/discoveryf4bare/pios_board.h +++ b/flight/targets/boards/discoveryf4bare/pios_board.h @@ -264,10 +264,10 @@ extern uint32_t pios_packet_handler; // ------------------------- #define PIOS_DMA_PIN_CONFIG \ { \ - { GPIOC, GPIO_Pin_1, ADC_Channel_11 }, \ - { GPIOC, GPIO_Pin_2, ADC_Channel_12 }, \ - { NULL, 0, ADC_Channel_Vrefint }, /* Voltage reference */ \ - { NULL, 0, ADC_Channel_TempSensor }, /* Temperature sensor */ \ + { GPIOC, GPIO_Pin_1, ADC_Channel_11, false }, \ + { GPIOC, GPIO_Pin_2, ADC_Channel_12, false }, \ + { NULL, 0, ADC_Channel_Vrefint, false }, /* Voltage reference */ \ + { NULL, 0, ADC_Channel_TempSensor, false }, /* Temperature sensor */ \ } /* we have to do all this to satisfy the PIOS_ADC_MAX_SAMPLES define in pios_adc.h */ diff --git a/flight/targets/boards/osd/firmware/pios_board.c b/flight/targets/boards/osd/firmware/pios_board.c index e125eb151..680c93c2e 100644 --- a/flight/targets/boards/osd/firmware/pios_board.c +++ b/flight/targets/boards/osd/firmware/pios_board.c @@ -449,6 +449,17 @@ void PIOS_Board_Init(void) // PIOS_TIM_InitClock(&pios_tim4_cfg); PIOS_Video_Init(&pios_video_cfg); #endif +#ifdef PIOS_INCLUDE_ADC + { + uint8_t adc_config[HWSETTINGS_ADCROUTING_NUMELEM]; + HwSettingsADCRoutingArrayGet(adc_config); + for (uint32_t i = 0; i < HWSETTINGS_ADCROUTING_NUMELEM; i++) { + if (adc_config[i] != HWSETTINGS_ADCROUTING_DISABLED) { + PIOS_ADC_PinSetup(i); + } + } + } +#endif // PIOS_INCLUDE_ADC } uint16_t supv_timer = 0; diff --git a/flight/targets/boards/osd/pios_board.h b/flight/targets/boards/osd/pios_board.h index f0068f978..ab5fb7688 100644 --- a/flight/targets/boards/osd/pios_board.h +++ b/flight/targets/boards/osd/pios_board.h @@ -208,13 +208,13 @@ extern uint32_t pios_com_telem_usb_id; #define PIOS_DMA_PIN_CONFIG \ { \ - { GPIOC, GPIO_Pin_0, ADC_Channel_10 }, \ - { GPIOC, GPIO_Pin_1, ADC_Channel_11 }, \ - { GPIOC, GPIO_Pin_2, ADC_Channel_12 }, \ - { NULL, 0, ADC_Channel_TempSensor }, /* Temperature sensor */ \ - { GPIOC, GPIO_Pin_3, ADC_Channel_13 }, \ - { GPIOA, GPIO_Pin_7, ADC_Channel_7 }, \ - { NULL, 0, ADC_Channel_Vrefint } /* Voltage reference */ \ + { GPIOC, GPIO_Pin_0, ADC_Channel_10, true }, \ + { GPIOC, GPIO_Pin_1, ADC_Channel_11, true }, \ + { GPIOC, GPIO_Pin_2, ADC_Channel_12, true }, \ + { NULL, 0, ADC_Channel_TempSensor, true }, /* Temperature sensor */ \ + { GPIOC, GPIO_Pin_3, ADC_Channel_13, true }, \ + { GPIOA, GPIO_Pin_7, ADC_Channel_7, true }, \ + { NULL, 0, ADC_Channel_Vrefint, true } /* Voltage reference */ \ } /* we have to do all this to satisfy the PIOS_ADC_MAX_SAMPLES define in pios_adc.h */ diff --git a/flight/targets/boards/revolution/firmware/pios_board.c b/flight/targets/boards/revolution/firmware/pios_board.c index da954a045..16286b8f5 100644 --- a/flight/targets/boards/revolution/firmware/pios_board.c +++ b/flight/targets/boards/revolution/firmware/pios_board.c @@ -946,8 +946,18 @@ void PIOS_Board_Init(void) if (ws2811_pin_settings != HWSETTINGS_WS2811LED_OUT_DISABLED && ws2811_pin_settings < NELEMENTS(pios_ws2811_pin_cfg)) { PIOS_WS2811_Init(&pios_ws2811_cfg, &pios_ws2811_pin_cfg[ws2811_pin_settings]); } - #endif // PIOS_INCLUDE_WS2811 +#ifdef PIOS_INCLUDE_ADC + { + uint8_t adc_config[HWSETTINGS_ADCROUTING_NUMELEM]; + HwSettingsADCRoutingArrayGet(adc_config); + for (uint32_t i = 0; i < HWSETTINGS_ADCROUTING_NUMELEM; i++) { + if (adc_config[i] != HWSETTINGS_ADCROUTING_DISABLED) { + PIOS_ADC_PinSetup(i); + } + } + } +#endif // PIOS_INCLUDE_ADC } /** diff --git a/flight/targets/boards/revolution/pios_board.h b/flight/targets/boards/revolution/pios_board.h index 7f9ab9d77..d782696ef 100644 --- a/flight/targets/boards/revolution/pios_board.h +++ b/flight/targets/boards/revolution/pios_board.h @@ -283,10 +283,10 @@ extern uint32_t pios_packet_handler; // ------------------------- #define PIOS_DMA_PIN_CONFIG \ { \ - { GPIOC, GPIO_Pin_1, ADC_Channel_11 }, \ - { GPIOC, GPIO_Pin_2, ADC_Channel_12 }, \ - { NULL, 0, ADC_Channel_Vrefint }, /* Voltage reference */ \ - { NULL, 0, ADC_Channel_TempSensor }, /* Temperature sensor */ \ + { GPIOC, GPIO_Pin_1, ADC_Channel_11, false }, \ + { GPIOC, GPIO_Pin_2, ADC_Channel_12, false }, \ + { NULL, 0, ADC_Channel_Vrefint, false }, /* Voltage reference */ \ + { NULL, 0, ADC_Channel_TempSensor, false }, /* Temperature sensor */ \ } /* we have to do all this to satisfy the PIOS_ADC_MAX_SAMPLES define in pios_adc.h */ diff --git a/flight/targets/boards/revoproto/firmware/pios_board.c b/flight/targets/boards/revoproto/firmware/pios_board.c index 99cdef338..1649325d3 100644 --- a/flight/targets/boards/revoproto/firmware/pios_board.c +++ b/flight/targets/boards/revoproto/firmware/pios_board.c @@ -925,6 +925,17 @@ void PIOS_Board_Init(void) default: PIOS_DEBUG_Assert(0); } +#ifdef PIOS_INCLUDE_ADC + { + uint8_t adc_config[HWSETTINGS_ADCROUTING_NUMELEM]; + HwSettingsADCRoutingArrayGet(adc_config); + for (uint32_t i = 0; i < HWSETTINGS_ADCROUTING_NUMELEM; i++) { + if (adc_config[i] != HWSETTINGS_ADCROUTING_DISABLED) { + PIOS_ADC_PinSetup(i); + } + } + } +#endif // PIOS_INCLUDE_ADC } /** diff --git a/flight/targets/boards/revoproto/pios_board.h b/flight/targets/boards/revoproto/pios_board.h index d3a421114..30cab6600 100644 --- a/flight/targets/boards/revoproto/pios_board.h +++ b/flight/targets/boards/revoproto/pios_board.h @@ -242,11 +242,11 @@ extern uint32_t pios_com_hkosd_id; // ------------------------- #define PIOS_DMA_PIN_CONFIG \ { \ - { GPIOC, GPIO_Pin_0, ADC_Channel_10 }, \ - { GPIOC, GPIO_Pin_1, ADC_Channel_11 }, \ - { NULL, 0, ADC_Channel_Vrefint }, /* Voltage reference */ \ - { NULL, 0, ADC_Channel_TempSensor }, /* Temperature sensor */ \ - { GPIOC, GPIO_Pin_2, ADC_Channel_12 } \ + { GPIOC, GPIO_Pin_0, ADC_Channel_10, true }, \ + { GPIOC, GPIO_Pin_1, ADC_Channel_11, true }, \ + { NULL, 0, ADC_Channel_Vrefint, true }, /* Voltage reference */ \ + { NULL, 0, ADC_Channel_TempSensor, true }, /* Temperature sensor */ \ + { GPIOC, GPIO_Pin_2, ADC_Channel_12, true } \ } /* we have to do all this to satisfy the PIOS_ADC_MAX_SAMPLES define in pios_adc.h */