30#ifndef __ADCMANAGER_H__
31#define __ADCMANAGER_H__
97#ifndef HIDE_FROM_DOXYGEN
102 static constexpr float ADC_CHANNEL_MAX_FLOAT[ADC_CHANNEL_COUNT] = {
171 return m_AdcResolution;
188 return m_AdcResultsConvertedFiltered[adcChannel];
205 return m_AdcResultsConverted[adcChannel];
257 if (adcChannel >= ADC_CHANNEL_COUNT) {
260 m_analogFilter[adcChannel].Reset(newSetting);
261 m_AdcResultsConvertedFiltered[adcChannel] =
262 m_analogFilter[adcChannel].LastOutput();
281 m_AdcTimeoutLimit = timeout;
313 uint16_t maxReading = INT16_MAX & ~(INT16_MAX >> m_AdcResolution);
314 float voltage = ADC_CHANNEL_MAX_FLOAT[adcChannel] *
315 m_AdcResultsConvertedFiltered[adcChannel] / maxReading;
319#ifndef HIDE_FROM_DOXYGEN
331 volatile const uint32_t &ShiftRegSnapshot() {
332 return m_shiftRegSnapshot;
342 static constexpr float ADC_INITIAL_FILTER_VALUE_V[ADC_CHANNEL_COUNT] = {
354 volatile uint16_t m_AdcResultsConverted[ADC_CHANNEL_COUNT] = {0};
355 volatile uint16_t m_AdcResultsConvertedFiltered[ADC_CHANNEL_COUNT] = {0};
356 Iir16 m_analogFilter[ADC_CHANNEL_COUNT];
361 uint32_t m_shiftRegSnapshot;
362 uint32_t m_shiftRegPending;
365 uint8_t m_AdcResolution;
366 uint8_t m_AdcResPending;
370 uint8_t m_AdcTimeoutLimit;
373 uint32_t m_AdcBusyCount;
ADC Peripheral Manager for the ClearCore Board.
Definition AdcManager.h:48
static const uint32_t ADC_IIR_FILTER_TC_MS
Definition AdcManager.h:95
static const uint8_t ADC_TIMEOUT_DEFAULT
Definition AdcManager.h:91
AdcChannels
Definition AdcManager.h:57
@ ADC_5VOB_MON
5V off-board monitor
Definition AdcManager.h:60
@ ADC_AIN09
Analog input A-9.
Definition AdcManager.h:63
@ ADC_AIN11
Analog input A-11.
Definition AdcManager.h:61
@ ADC_SDRVR2_IMON
Screwdriver M-2 current monitor.
Definition AdcManager.h:65
@ ADC_AIN10
Analog input A-10.
Definition AdcManager.h:62
@ ADC_VSUPPLY_MON
Supply voltage monitor.
Definition AdcManager.h:58
@ ADC_SDRVR3_IMON
Screwdriver M-3 current monitor.
Definition AdcManager.h:64
@ ADC_AIN12
Analog input A-12.
Definition AdcManager.h:59
float AnalogVoltage(AdcChannels adcChannel)
Returns the filtered ADC result of a specific channel in volts.
Definition AdcManager.h:312
bool FilterReset(AdcChannels adcChannel, uint16_t newSetting)
Resets the filter for an ADC Channel.
Definition AdcManager.h:256
static const uint8_t ADC_RESOLUTION_DEFAULT
Definition AdcManager.h:87
uint16_t FilterTc(AdcChannels adcChannel, FilterUnits theUnits)
Gets the IIR filter time constant of an ADC channel.
bool FilterTc(AdcChannels adcChannel, uint16_t tc, FilterUnits theUnits)
Sets the IIR filter time constant for an ADC channel.
bool AdcResolution(uint8_t resolution)
Configure the ADC conversion resolution.
volatile const uint8_t & AdcResolution()
Returns the resolution of the ADC.
Definition AdcManager.h:170
volatile const uint16_t & FilteredResult(AdcChannels adcChannel)
Returns the filtered ADC result of a specific channel.
Definition AdcManager.h:187
FilterUnits
Units for the filter time constant.
Definition AdcManager.h:75
@ FILTER_UNIT_SAMPLES
Definition AdcManager.h:81
@ FILTER_UNIT_MS
Definition AdcManager.h:79
@ FILTER_UNIT_RAW
Definition AdcManager.h:77
volatile const bool & AdcTimeout()
Determine whether the ADC has timed out.
Definition AdcManager.h:295
void AdcTimeoutLimit(uint8_t timeout)
Configure the ADC conversion timeout.
Definition AdcManager.h:280
volatile const uint16_t & ConvertedResult(AdcChannels adcChannel)
Returns the converted ADC result of a specific channel.
Definition AdcManager.h:204
Namespace to encompass the ClearCore board API.
Definition AdcManager.h:36