modm API documentation
modm::mcp3008< SpiMaster, Cs > Class Template Reference

#include <modm/driver/adc/mcp3008.hpp>

Inheritance diagram for modm::mcp3008< SpiMaster, Cs >:
modm::SpiDevice< SpiMaster > modm::NestedResumable< 1 >

Public Types

enum  Channel : uint8_t {
  Ch0 = 0b1000, Ch1 = 0b1001, Ch2 = 0b1010, Ch3 = 0b1011,
  Ch4 = 0b1100, Ch5 = 0b1101, Ch6 = 0b1110, Ch7 = 0b1111,
  Ch0Ch1Diff = 0b0000, Ch1Ch0Diff = 0b0001, Ch2Ch3Diff = 0b0010, Ch3Ch2Diff = 0b0011,
  Ch4Ch5Diff = 0b0100, Ch5Ch4Diff = 0b0101, Ch6Ch7Diff = 0b0110, Ch7Ch6Diff = 0b0111
}
 

Public Member Functions

 Mcp3008 () = default
 
void initialize ()
 Call initialize() before reading ADC.
 
modm::ResumableResult< uint16_t > read (Channel channel)
 Read ADC channel.
 
void attachConfigurationHandler (Spi::ConfigurationHandler handler)
 

Protected Member Functions

bool acquireMaster ()
 
bool releaseMaster ()
 
modm::ResumableResult< ReturnType > resumable function (...)
 
int8_t getResumableDepth () const
 
bool isResumableRunning () const
 
void stopResumable ()
 Force all resumable functions to stop running at the current nesting level.
 

Detailed Description

template<typename SpiMaster, typename Cs>
class modm::mcp3008< SpiMaster, Cs >

Simple driver for MCP3004/MCP3008 10-bit SAR SPI ADCs. Max SPI frequency 3.6 MHz at 5V, 1.36 MHz at 2.7V.

Author
Christopher Durand

Member Enumeration Documentation

template<typename SpiMaster , typename Cs >
enum modm::mcp3008::Channel : uint8_t
strong

ADC channels For MCP3004 only channels 0-3 are valid.

Member Function Documentation

modm::ResumableResult< ReturnType > resumable modm::NestedResumable< 1 >::function (   ...)
inherited

Run the resumable function.

You need to implement this method in you subclass yourself.

Returns
>NestingError if still running, <=NestingError if it has finished.
int8_t modm::NestedResumable< 1 >::getResumableDepth ( ) const
inheritedinline
Returns
the nesting depth in the current resumable function, or -1 if called outside any resumable function
bool modm::NestedResumable< 1 >::isResumableRunning ( ) const
inheritedinline
Returns
true if a resumable function is running at the current nesting level, else false

The documentation for this class was generated from the following file: