1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-25 17:25:18 +03:00

Converted ADC to new IO (#356)

* Converted ADC to new IO
* Updated rcc.c for new IO
This commit is contained in:
Martin Budden 2016-07-19 09:36:50 +01:00 committed by Konstantin Sharlaimov
parent 45fc7a68a3
commit 1cab71963f
30 changed files with 407 additions and 452 deletions

View file

@ -17,5 +17,52 @@
#pragma once
#include "io.h"
#include "rcc.h"
#if defined(STM32F4)
#define ADC_TAG_MAP_COUNT 16
#elif defined(STM32F3)
#define ADC_TAG_MAP_COUNT 39
#else
#define ADC_TAG_MAP_COUNT 10
#endif
typedef enum ADCDevice {
ADCINVALID = -1,
ADCDEV_1 = 0,
#if defined(STM32F3)
ADCDEV_2,
ADCDEV_MAX = ADCDEV_2,
#elif defined(STM32F4)
ADCDEV_2,
ADCDEV_3,
ADCDEV_MAX = ADCDEV_3,
#else
ADCDEV_MAX = ADCDEV_1,
#endif
} ADCDevice;
typedef struct adcTagMap_s {
ioTag_t tag;
uint8_t channel;
} adcTagMap_t;
typedef struct adcDevice_s {
ADC_TypeDef* ADCx;
rccPeriphTag_t rccADC;
rccPeriphTag_t rccDMA;
#if defined(STM32F4)
DMA_Stream_TypeDef* DMAy_Streamx;
uint32_t channel;
#else
DMA_Channel_TypeDef* DMAy_Channelx;
#endif
} adcDevice_t;
extern const adcDevice_t adcHardware[];
extern const adcTagMap_t adcTagMap[ADC_TAG_MAP_COUNT];
extern adc_config_t adcConfig[ADC_CHANNEL_COUNT];
extern volatile uint16_t adcValues[ADC_CHANNEL_COUNT];
uint8_t adcChannelByTag(ioTag_t ioTag);