ClearCore Library
|
ADC Peripheral Manager for the ClearCore Board.
This class manages the ADC peripheral on the Teknic ClearCore.
Utilizes DMA sequence to configure channels, trigger conversion, and read results.
Uses DMAC Channels: 0,1
ADC Peripheral Manager for the ClearCore Board. More...
#include <AdcManager.h>
Public Types | |
enum | AdcChannels { ADC_VSUPPLY_MON = 0 , ADC_AIN12 , ADC_5VOB_MON , ADC_AIN11 , ADC_AIN10 , ADC_AIN09 , ADC_SDRVR3_IMON , ADC_SDRVR2_IMON , ADC_CHANNEL_COUNT } |
enum | FilterUnits { FILTER_UNIT_RAW , FILTER_UNIT_MS , FILTER_UNIT_SAMPLES } |
Units for the filter time constant. More... | |
Public Member Functions | |
bool | AdcResolution (uint8_t resolution) |
Configure the ADC conversion resolution. | |
volatile const uint8_t & | AdcResolution () |
Returns the resolution of the ADC. | |
volatile const uint16_t & | FilteredResult (AdcChannels adcChannel) |
Returns the filtered ADC result of a specific channel. | |
volatile const uint16_t & | ConvertedResult (AdcChannels adcChannel) |
Returns the converted ADC result of a specific channel. | |
bool | FilterTc (AdcChannels adcChannel, uint16_t tc, FilterUnits theUnits) |
Sets the IIR filter time constant for an ADC channel. | |
uint16_t | FilterTc (AdcChannels adcChannel, FilterUnits theUnits) |
Gets the IIR filter time constant of an ADC channel. | |
bool | FilterReset (AdcChannels adcChannel, uint16_t newSetting) |
Resets the filter for an ADC Channel. | |
void | AdcTimeoutLimit (uint8_t timeout) |
Configure the ADC conversion timeout. | |
volatile const bool & | AdcTimeout () |
Determine whether the ADC has timed out. | |
float | AnalogVoltage (AdcChannels adcChannel) |
Returns the filtered ADC result of a specific channel in volts. | |
Static Public Attributes | |
static const uint8_t | ADC_RESOLUTION_DEFAULT = 12 |
static const uint8_t | ADC_TIMEOUT_DEFAULT = 3 |
static const uint32_t | ADC_IIR_FILTER_TC_MS = 2 |
ADC conversion channels.
|
inline |
Returns the resolution of the ADC.
Possible values are: 8, 10, and 12.
bool ClearCore::AdcManager::AdcResolution | ( | uint8_t | resolution | ) |
Configure the ADC conversion resolution.
ADC naturally supports 12-bit operation. Lower resolution is used to decrease sample time.
Passing an unsupported resolution yields no change and returns false.
Acceptable Inputs:
resolution | Bit resolution. Acceptable values: 8, 10, and 12. |
|
inline |
Determine whether the ADC has timed out.
|
inline |
Configure the ADC conversion timeout.
The ADC will post an error to the StatusReg if it is unable to complete a conversion within the number of samples specified by the input of this function.
[in] | timeout | The length of the timeout in samples. |
|
inline |
Returns the filtered ADC result of a specific channel in volts.
[in] | adcChannel | ADC channel to get the voltage reading of. |
|
inline |
Returns the converted ADC result of a specific channel.
[in] | adcChannel | ADC channel to get the results of. |
|
inline |
Returns the filtered ADC result of a specific channel.
[in] | adcChannel | ADC channel to get the filtered results of. |
|
inline |
Resets the filter for an ADC Channel.
[in] | adcChannel | ADC Channel filter to reset. |
[in] | newSetting | The initial filter value. |
uint16_t ClearCore::AdcManager::FilterTc | ( | AdcChannels | adcChannel, |
FilterUnits | theUnits | ||
) |
Gets the IIR filter time constant of an ADC channel.
[in] | adcChannel | ADC channel to get filter constant for. |
[in] | theUnits | The units of the returned time constant. See FilterUnits. |
bool ClearCore::AdcManager::FilterTc | ( | AdcChannels | adcChannel, |
uint16_t | tc, | ||
FilterUnits | theUnits | ||
) |
Sets the IIR filter time constant for an ADC channel.
[in] | adcChannel | ADC channel to set filter constant for |
[in] | tc | The new filter time constant (99% step change time) |
[in] | theUnits | The units of the time constant tc. See FilterUnits. |
|
static |
The default ADC filter time constant, in milliseconds.
|
static |
The default resolution of the ADC, in bits.
|
static |
The default timeout for waiting on an ADC conversion, in samples.