#include <modm/architecture/interface/adc.hpp>
|
typedef uint8_t | Channel |
| this type may also be an enum or enum class
|
|
|
static constexpr uint8_t | Resolution |
| describes the maximum resolution in bits
|
|
Basic interface of an ADC.
This interface only provides the very basic common functionality between modules. Therefore for any special operating mode, such as interlaced operation, external trigger options or DMA data management, you must refer to the platform specific documentation.
This interface only allows for synchronous operation:
The above code is equivalent to this:
- See also
- AdcInterrupt for the asynchronous method.
- Author
- Niklas Hauser
static void modm::PeripheralDriver::acknowledgeInterruptFlag |
( |
| ) |
|
|
inheritedstatic |
Acknowledge an interrupt flag.
We use acknowledge here, since it describes the intention rather than the actual implementation.
template<uint64_t available, uint64_t requested, percent_t tolerance>
static void modm::PeripheralDriver::assertBaudrateInTolerance |
( |
| ) |
|
|
inheritedinlinestatic |
Since baudrates are usually generated by prescaling a system clock, only several distinct values can be generated. This method checks if the user requested baudrate is within error tolerance of the system achievable baudrate.
template<class... Signals>
static void modm::Adc::connect |
( |
| ) |
|
|
static |
Configures the input signals and connects them.
- Template Parameters
-
Signals | At least one input signal is required and can be passed out-of-order. |
static void modm::Adc::disableFreeRunningMode |
( |
| ) |
|
|
static |
Disables free running mode
The ADC will do only one sample and stop. The result will be in the ADC register.
static void modm::Adc::enableFreeRunningMode |
( |
| ) |
|
|
static |
Enables free running mode
The ADC will continously start conversions and provide the most recent result in the ADC register.
static uint8_t modm::Adc::getChannel |
( |
| ) |
|
|
static |
- Returns
- the currently selected analog channel
static uint16_t modm::Adc::getValue |
( |
| ) |
|
|
static |
- Returns
- the most recent result of any conversion
template<class SystemClock , frequency_t frequency = 200_kHz, percent_t tolerance = 10_pct>
static void modm::Adc::initialize |
( |
| ) |
|
|
static |
Initializes the hardware and sets the datarate.
- Template Parameters
-
SystemClock | the currently active system clock |
frequency | the desired clock frequency in Hz |
tolerance | the allowed relative tolerance for the resulting clock frequency |
static bool modm::Adc::isConversionFinished |
( |
| ) |
|
|
static |
- Returns
true
if all conversion have finished, false
otherwise
static uint16_t modm::Adc::readChannel |
( |
Channel |
channel | ) |
|
|
static |
Convenience function:
>
- set the channel
- starts the conversion
- waits until conversion is complete
- Returns
- result of the conversion
static bool modm::Adc::setChannel |
( |
Channel |
channel | ) |
|
|
static |
Analog channel selection.
- Returns
true
if the channel exists and was available, false
otherwise
static void modm::Adc::startConversion |
( |
| ) |
|
|
static |
starts a conversion on the selected analog channel
- Precondition
- A channel must be selected with setChannel().
The documentation for this class was generated from the following file: