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

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

Inheritance diagram for modm::ad7928< SpiMaster, Cs >:
modm::SpiDevice< SpiMaster > modm::NestedResumable< 3 >

Classes

struct  Data
 

Public Typedefs

typedef modm::Configuration< ControlRegister_t, SequenceMode, Bit14|Bit7 > SequenceMode_t
 
typedef modm::Configuration< ControlRegister_t, InputChannel, 0b111, 10 > InputChannel_t
 
typedef modm::Configuration< ControlRegister_t, PowerMode, 0b11, 8 > PowerMode_t
 
typedef modm::Configuration< ShadowRegister_t, SequenceChannels, 0xFF, 8 > Sequence1Channels_t
 
typedef modm::Configuration< ShadowRegister_t, SequenceChannels, 0xFF, 0 > Sequence2Channels_t
 
using Register_t = modm::FlagsGroup< ControlRegister_t, ShadowRegister_t >
 

Public Types

enum  ControlRegister : uint16_t { ControlRegister::WriteControlReg = Bit15, ControlRegister::VrefRange = Bit5, ControlRegister::UnsignedOutput = Bit4 }
 Control register. More...
 
enum  SequenceMode : uint16_t { SequenceMode::NoSequence = 0, SequenceMode::ProgramShadowRegister = Bit7, SequenceMode::ContinueSequence = Bit14, SequenceMode::ContinuousSequence = Bit14 | Bit7 }
 Sequence mode. More...
 
enum  InputChannel : uint8_t {
  Ch0 = 0, Ch1 = Bit0, Ch2 = Bit1, Ch3 = Bit1 | Bit0,
  Ch4 = Bit2, Ch5 = Bit2 | Bit0, Ch6 = Bit2 | Bit1, Ch7 = Bit2 | Bit1 | Bit0
}
 ADC input channels.
 
enum  PowerMode : uint8_t { Normal = Bit1 | Bit0, FullShutdown = Bit1, AutoShutdown = Bit0 }
 Power mode.
 
enum  ShadowRegister : uint16_t
 Shadow register, used for channel selection in sequence mode.
 
enum  SequenceChannels : uint8_t {
  Ch0 = Bit7, Ch1 = Bit6, Ch2 = Bit5, Ch3 = Bit4,
  Ch4 = Bit3, Ch5 = Bit2, Ch6 = Bit1, Ch7 = Bit0
}
 Configuration to select input channels for sequence conversion.
 

Public Member Functions

 MODM_FLAGS16 (ControlRegister)
 
 MODM_FLAGS16 (ShadowRegister)
 
 MODM_FLAGS8 (SequenceChannels)
 
 Ad7928 ()
 
modm::ResumableResult< void > initialize ()
 Call this function once before using the device.
 
modm::ResumableResult< DatasingleConversion (InputChannel channel)
 
modm::ResumableResult< void > startSequence (SequenceChannels_t channels1, SequenceChannels_t channels2=SequenceChannels_t (0))
 
modm::ResumableResult< DatanextSequenceConversion ()
 
void setExtendedRange (bool enabled)
 
bool isExtendedRange ()
 Test if extended range mode is enabled.
 
void setAutoShutdownEnabled (bool enabled)
 Shutdown device after each conversion, not supported in sequence mode.
 
bool isAutoShutdownEnabled ()
 Test if auto-shutdown is enabled.
 
modm::ResumableResult< void > fullShutdown ()
 
modm::ResumableResult< void > wakeup ()
 Wake up the device from full shutdown mode.
 
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::ad7928< SpiMaster, Cs >

Template Parameters
SpiMasterSpiMaster interface
CsChip-select pin
Author
Christopher Durand

Member Enumeration Documentation

template<typename SpiMaster , typename Cs >
enum modm::ad7928::ControlRegister : uint16_t
strong

Control register.

Enum ValuesDocumentation
WriteControlReg 

Enables writing to the control register.

VrefRange 

If this bit is set, the input range is 0..Vref, else 0..2*Vref (4.75V < AVdd < 5.25V required)

UnsignedOutput 

Unsigned output, else two's complement signed output for differential signals (output 0 for input Vref/2)

template<typename SpiMaster , typename Cs >
enum modm::ad7928::SequenceMode : uint16_t
strong

Sequence mode.

Enum ValuesDocumentation
NoSequence 

Sequence mode disabled.

ProgramShadowRegister 

If this bit is set, the next 2 bytes written to the device will be clocked into the shadow register and non-continuous sequence mode will be enabled

ContinueSequence 

Continue the current sequence, conversion settings can be changed.

ContinuousSequence 

Enable continuous sequence mode, not supported.

Member Function Documentation

template<typename SpiMaster , typename Cs >
modm::ResumableResult<void> modm::ad7928< SpiMaster, Cs >::fullShutdown ( )

Shutdown device Calling wakeup() or initiating a conversion will wake up the device

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
template<typename SpiMaster , typename Cs >
modm::ResumableResult<Data> modm::ad7928< SpiMaster, Cs >::nextSequenceConversion ( )

Perform the next sequence conversion The result is undefined if the device is not in sequence mode or not in normal power mode.

template<typename SpiMaster , typename Cs >
void modm::ad7928< SpiMaster, Cs >::setExtendedRange ( bool  enabled)

Enable extended range mode (0V < input < 2*Vref) The configuration will be applied after the next conversion Default mode: (0V < input < Vref)

template<typename SpiMaster , typename Cs >
modm::ResumableResult<Data> modm::ad7928< SpiMaster, Cs >::singleConversion ( InputChannel  channel)

Initiate a single conversion and return the result of the previous conversion A running sequence will be aborted. If the device is in full shutdown, it will be woken up.

template<typename SpiMaster , typename Cs >
modm::ResumableResult<void> modm::ad7928< SpiMaster, Cs >::startSequence ( SequenceChannels_t  channels1,
SequenceChannels_t  channels2 = SequenceChannels_t (0) 
)

Start a conversion sequence. The device will automatically cycle through the specified channels, starting with the lowest channel index in sequence1, when nextSequenceConversion() is called.


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