modm API documentation
modm::AdcInterrupt Class Reference

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

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

Public Typedefs

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

Static Public Member Functions

static void attachInterruptHandler (Handler handler)
 
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
 
template<class... Signals>
static void connect ()
 
static void disable ()
 
static void disableFreeRunningMode ()
 
static void enableFreeRunningMode ()
 
static uint8_t getChannel ()
 
static bool getInterruptFlag ()
 Read an interrupt flag.
 
static void getParameter ()
 returns a parameter
 
static uint16_t getValue ()
 
template<class SystemClock , frequency_t frequency = 200_kHz, percent_t tolerance = 10_pct>
static void initialize ()
 
static bool isConversionFinished ()
 
static uint16_t readChannel (Channel channel)
 
static bool setChannel (Channel channel)
 
static void setLeftAdjustResult ()
 Change the presentation of the ADC conversion result to left adjusted.
 
static void setParameter ()
 sets a parameter
 
static void setRightAdjustResult ()
 Change the presentation of the ADC conversion result to right adjusted.
 
static void startConversion ()
 

Static Public Attributes

static constexpr uint8_t Resolution
 describes the maximum resolution in bits
 

Protected Typedefs

typedef void (* Handler) ()
 

Detailed Description

Basic interrupt-based interface of an ADC.

This class allows you to attach functions to the ADC Conversion Complete Interrupt via function pointers. Be aware however, that this implementation is slower and requires more resources than writing the function code directly into the interrupt service routines.

This interface allows for asynchronous operation:

void interruptComplete()
{
uint16_t value = Adc::getValue();
}
AdcInterrupt::attachConversionCompleteInterrupt(interruptComplete);
AdcInterrupt::enableInterrupt();
// start a new conversion on channel 3
See also
Adc for the synchronous 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 ( )
inheritedstatic

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 ( )
inheritedstatic

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 ( )
inheritedstatic

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 ( )
inheritedstatic
Returns
the currently selected analog channel
static uint16_t modm::Adc::getValue ( )
inheritedstatic
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 ( )
inheritedstatic

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 ( )
inheritedstatic
Returns
true if all conversion have finished, false otherwise
static uint16_t modm::Adc::readChannel ( Channel  channel)
inheritedstatic

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)
inheritedstatic

Analog channel selection.

Returns
true if the channel exists and was available, false otherwise
static void modm::Adc::startConversion ( )
inheritedstatic

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: