rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
adc_device.h
Go to the documentation of this file.
1/**
2 * @file adc_device.h
3 *
4 * @date May 3, 2014
5 * @author Andrey Belomutskiy, (c) 2012-2020
6 */
7
8#pragma once
9
10#if HAL_USE_ADC
11
12class AdcDevice {
13public:
14 explicit AdcDevice(ADCDriver *p_adcp, ADCConversionGroup* p_hwConfig, volatile adcsample_t *p_buf, size_t p_depth);
15 int enableChannel(adc_channel_e hwChannel);
16 /* Should be called from ISR context */
17 void startConversionI(void);
21 {
22 /* TODO: validate token? */
23
24 /* TODO: in case depth > 1 this will return random (not last) sample */
25 return samples[token];
26 };
28 int size() const;
29 void init(void);
30
31private:
32 ADCDriver *adcp;
33 ADCConversionGroup* hwConfig;
35 size_t depth;
36 uint8_t internalAdcIndexByHardwareIndex[EFI_ADC_TOTAL_CHANNELS];
37 /**
38 * Number of ADC channels in use
39 */
40 size_t channelCount = 0;
41};
42
43#endif /* HAL_USE_ADC */
44
uint32_t AdcToken
Definition adc_inputs.h:98
void init(void)
void startConversionI(void)
size_t depth
Definition adc_device.h:35
uint8_t internalAdcIndexByHardwareIndex[EFI_ADC_TOTAL_CHANNELS]
Definition adc_device.h:36
int size() const
adc_channel_e getAdcChannelByInternalIndex(int index) const
AdcToken getAdcChannelToken(adc_channel_e hwChannel)
int enableChannel(adc_channel_e hwChannel)
ADCConversionGroup * hwConfig
Definition adc_device.h:33
size_t channelCount
Definition adc_device.h:40
adcsample_t getAvgAdcValue(adc_channel_e hwChannel)
adcsample_t getAdcValueByToken(AdcToken token)
Definition adc_device.h:20
volatile adcsample_t * samples
Definition adc_device.h:34
ADCDriver * adcp
Definition adc_device.h:32
uint16_t adcsample_t
ADC sample data type.