modm API documentation

#include <modm/architecture/interface/adc.hpp>

Inheritance diagram for modm::Adc:
modm::PeripheralDriver modm::AdcInterrupt

Public Typedefs

typedef uint8_t Channel
 this type may also be an enum or enum class
 

Static Public Member Functions

template<class... Signals>
static void connect ()
 
template<class SystemClock , frequency_t frequency = 200_kHz, percent_t tolerance = 10_pct>
static void initialize ()
 
static void disable ()
 
static void startConversion ()
 
static bool isConversionFinished ()
 
static uint16_t getValue ()
 
static uint16_t readChannel (Channel channel)
 
static bool setChannel (Channel channel)
 
static uint8_t getChannel ()
 
static void enableFreeRunningMode ()
 
static void disableFreeRunningMode ()
 
static void setLeftAdjustResult ()
 Change the presentation of the ADC conversion result to left adjusted.
 
static void setRightAdjustResult ()
 Change the presentation of the ADC conversion result to right adjusted.
 
static void acknowledgeInterruptFlag ()
 
template<uint64_t available, uint64_t requested, percent_t tolerance>
static void assertBaudrateInTolerance ()
 
template<double available, double requested, percent_t tolerance>
static void assertDurationInTolerance ()
 
static void configurePurpose ()
 configures a peripheral for a specific purpose
 
static bool getInterruptFlag ()
 Read an interrupt flag.
 
static void getParameter ()
 returns a parameter
 
static void setParameter ()
 sets a parameter
 

Static Public Attributes

static constexpr uint8_t Resolution
 describes the maximum resolution in bits
 

Detailed Description

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:

// read channel 2
uint16_t value = Adc::readChannel(2);

The above code is equivalent to this:

// start a new conversion on channel 3
;
// read the converted value
uint16_t value = Adc::getValue();
See also
AdcInterrupt for the asynchronous method.
Author
Niklas Hauser

Member Function Documentation

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
SignalsAt 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
SystemClockthe currently active system clock
frequencythe desired clock frequency in Hz
tolerancethe 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:

    >
  1. set the channel
  2. starts the conversion
  3. 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: