modm API documentation
modm::ads7828< I2cMaster > Class Template Reference

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

Inheritance diagram for modm::ads7828< I2cMaster >:
modm::I2cDevice< I2cMaster, 1 > modm::NestedResumable< 10+1 >

Classes

struct  Data
 

Public Typedefs

typedef Configuration< CommandByte_t, InputChannel, Bit7|Bit6|Bit5|Bit4 > InputChannel_t
 
typedef Configuration< CommandByte_t, PowerDown, Bit3|Bit2 > PowerDown_t
 

Public Types

enum  InputChannel : uint8_t {
  Ch0Ch1 = 0u, Ch2Ch3 = int(CommandByte::C0), Ch4Ch5 = int(CommandByte::C1), Ch6Ch7 = int(CommandByte::C1) | int(CommandByte::C0),
  Ch1Ch0 = int(CommandByte::C2), Ch3Ch2 = int(CommandByte::C2) | int(CommandByte::C0), Ch5Ch4 = int(CommandByte::C2) | int(CommandByte::C1), Ch7Ch6 = int(CommandByte::C2) | int(CommandByte::C1) | int(CommandByte::C0),
  Ch0 = int(CommandByte::SD), Ch1 = int(CommandByte::SD) | int(CommandByte::C2), Ch2 = int(CommandByte::SD) | int(CommandByte::C0), Ch3 = int(CommandByte::SD) | int(CommandByte::C2) | int(CommandByte::C0),
  Ch4 = int(CommandByte::SD) | int(CommandByte::C1), Ch5 = int(CommandByte::SD) | int(CommandByte::C2) | int(CommandByte::C1), Ch6 = int(CommandByte::SD) | int(CommandByte::C1) | int(CommandByte::C0), Ch7 = int(CommandByte::SD) | int(CommandByte::C2) | int(CommandByte::C1) | int(CommandByte::C0)
}
 
enum  PowerDown : uint8_t { InternalReferenceOffAdcConverterOff = 0u, InternalReferenceOnAdcConverterOff = int(CommandByte::PD1), InternalReferenceOffAdcConverterOn = int(CommandByte::PD0), InternalReferenceOnAdcConverterOn = int(CommandByte::PD1) | int(CommandByte::PD0) }
 

Public Member Functions

 Ads7828 (Data &data, uint8_t address=0b1001000)
 Construct a new Ads7828 object. More...
 
modm::ResumableResult< bool > startMeasurement (InputChannel input)
 Measures the voltage in a single channel. More...
 
modm::ResumableResult< bool > setPowerDownSelection (PowerDown powerDownSelection)
 Sets the power down selection. More...
 
modm::ResumableResult< bool > readConversionResult ()
 Reads the latest measurement result.
 
DatagetData ()
 
void attachConfigurationHandler (I2c::ConfigurationHandler handler)
 
modm::ResumableResult< bool > ping ()
 
void setAddress (uint8_t address)
 

Protected Types

enum  CommandByte : uint8_t {
  SD = Bit7, C2 = Bit6, C1 = Bit5, C0 = Bit4,
  PD1 = Bit3, PD0 = Bit2
}
 

Protected Member Functions

 MODM_FLAGS8 (CommandByte)
 
modm::ResumableResult< ReturnType > resumable function (...)
 
int8_t getResumableDepth () const
 
bool isResumableRunning () const
 
bool isTransactionRunning ()
 
modm::ResumableResult< bool > runTransaction ()
 Starts our own transaction and waits until finished.
 
bool startRead (uint8_t *buffer, std::size_t size)
 Configures the transaction with a read operation and starts it.
 
bool startTransaction ()
 Starts the transaction with our own transaction object.
 
bool startTransaction (modm::I2cTransaction *transaction)
 Starts the transaction with a seperate transaction object.
 
bool startWrite (const uint8_t *buffer, std::size_t size)
 Configures the transaction with a write operation and starts it.
 
bool startWriteRead (const uint8_t *writeBuffer, std::size_t writeSize, uint8_t *readBuffer, std::size_t readSize)
 Configures the transaction with a write/read operation and starts it.
 
void stopResumable ()
 Force all resumable functions to stop running at the current nesting level.
 
bool wasTransactionSuccessful ()
 

Protected Attributes

I2cWriteReadTransaction transaction
 

Detailed Description

template<typename I2cMaster>
class modm::ads7828< I2cMaster >

Template Parameters
I2cMasterI2cMaster interface
Author
Jonas Holm Wentzlau
Jonas Kazem Andersen
Rasmus Kleist Hørlyck Sørensen

Member Function Documentation

template<typename I2cMaster >
modm::ads7828< I2cMaster >::Ads7828 ( Data data,
uint8_t  address = 0b1001000 
)

Construct a new Ads7828 object.

Parameters
data
addressThe adress is the i2c adress
void modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::attachConfigurationHandler ( I2c::ConfigurationHandler  handler)
inheritedinline

Attaches a configuration handler, which is called before a transaction, whenever the configuration has to be changed.

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
bool modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::isTransactionRunning ( )
inheritedinlineprotected
Returns
true when transaction is busy.
modm::ResumableResult<bool> modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::ping ( )
inheritedinline
Return Values
truedevice responds to address
falseno device with address found
void modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::setAddress ( uint8_t  address)
inheritedinline

Sets a new address of the slave device.

Parameters
addressthe slave address not yet shifted left (address < 128).
template<typename I2cMaster >
modm::ResumableResult<bool> modm::ads7828< I2cMaster >::setPowerDownSelection ( PowerDown  powerDownSelection)

Sets the power down selection.

Parameters
powerDownSelectionPD1 = 1 to have internal reference ON PD0 = 1 to have A/D converter ON
template<typename I2cMaster >
modm::ResumableResult<bool> modm::ads7828< I2cMaster >::startMeasurement ( InputChannel  input)

Measures the voltage in a single channel.

Parameters
channelChannelx where x is the channel to be read
settingsThe ads7828 has an internal reference which can be on or off, and the adc itself can be on or off. INTERNAL_REFERENCE_mode_ADC_mode, where mode is either ON or OFF. Does not have to be the same
bool modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::wasTransactionSuccessful ( )
inheritedinlineprotected
Returns
true when transaction did not return an error.

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