M5Unit-ANADIG 0.2.0 git rev:e984a40
Loading...
Searching...
No Matches
m5::unit::UnitGP8413 Class Reference

Digital-to-analog signal conversion unit. More...

#include <unit_GP8413.hpp>

Inheritance diagram for m5::unit::UnitGP8413:

Classes

struct  config_t
 Settings for begin. More...
 

Public Member Functions

 UnitGP8413 (const uint8_t addr=DEFAULT_ADDRESS)
 
virtual bool begin () override
 
Settings for begin
config_t config ()
 Gets the configration.
 
void config (const config_t &cfg)
 Set the configration.
 
Settings
gp8413::Output range (const gp8413::Channel channel) const
 Gets the inner range.
 
float maximumVoltage (const gp8413::Channel channel) const
 Get the maximum voltage of the channel.
 
bool writeOutputRange (const gp8413::Output range0, const gp8413::Output range1)
 Write the output range.
 
Output the voltage
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, std::nullptr_t >::type = nullptr>
bool writeVoltage (const gp8413::Channel channel, const T mv)
 Output the voltage.
 
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, std::nullptr_t >::type = nullptr>
bool writeChannel0Voltage (const T mv)
 Output the voltage(mV) to channel 0.
 
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, std::nullptr_t >::type = nullptr>
bool writeChannel1Voltage (const T mv)
 Output the voltage(mV) to channel 1.
 
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, std::nullptr_t >::type = nullptr>
bool writeBothVoltage (const T mv0, const T mv1)
 Output the voltage to both channel.
 
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, std::nullptr_t >::type = nullptr>
bool writeBothVoltage (const T mv)
 Output the voltage to both channel.
 
Output the raw value
bool writeVoltage (const gp8413::Channel channel, const uint16_t raw)
 Output the raw value.
 
bool writeChannel0Voltage (const uint16_t raw)
 Output the raw value to channel 0.
 
bool writeChannel1Voltage (const uint16_t raw)
 Output the raw value to channel 1.
 
bool writeBothVoltage (const uint16_t raw0, const uint16_t raw1)
 Output the raw value to both channel.
 
bool writeBothVoltage (const uint16_t raw)
 Output the raw value to both channel.
 
Store output voltage
Note
The GP8413 supports storing voltage data in the chip to ensure that the voltage output state remains
in the corresponding state after power-down or start-up.
bool storeBothVoltage ()
 Store the current output voltage to the chip.
 

Static Public Attributes

static constexpr uint16_t RESOLUTION {0x7FFF}
 

Protected Member Functions

uint16_t voltage_to_raw (const gp8413::Channel channel, const float mv)
 
bool write_voltage (const uint8_t reg, const uint8_t *buf, const uint32_t len)
 

Detailed Description

Digital-to-analog signal conversion unit.

Member Function Documentation

◆ storeBothVoltage()

bool m5::unit::UnitGP8413::storeBothVoltage ( )

Store the current output voltage to the chip.

Returns
True if successful
Warning
It is necessary to wait at least 7 ms for the store process to complete. Blocked until wait is complete
Note that the output range is not stored

◆ writeBothVoltage() [1/4]

template<typename T , typename std::enable_if< std::is_floating_point< T >::value, std::nullptr_t >::type = nullptr>
bool m5::unit::UnitGP8413::writeBothVoltage ( const T mv)
inline

Output the voltage to both channel.

Parameters
mvOutput voltage(mV) to both channel
Returns
True if successful

◆ writeBothVoltage() [2/4]

template<typename T , typename std::enable_if< std::is_floating_point< T >::value, std::nullptr_t >::type = nullptr>
bool m5::unit::UnitGP8413::writeBothVoltage ( const T mv0,
const T mv1 )
inline

Output the voltage to both channel.

Parameters
mv0Output voltage(mV) to channel 0
mv1Output voltage(mV) to channel 1
Returns
True if successful

◆ writeBothVoltage() [3/4]

bool m5::unit::UnitGP8413::writeBothVoltage ( const uint16_t raw)
inline

Output the raw value to both channel.

Parameters
rawOutput raw value to both channel
Returns
True if successful

◆ writeBothVoltage() [4/4]

bool m5::unit::UnitGP8413::writeBothVoltage ( const uint16_t raw0,
const uint16_t raw1 )

Output the raw value to both channel.

Parameters
raw0Output raw value to channel 0
raw1Output raw value to channel 1
Returns
True if successful

◆ writeOutputRange()

bool m5::unit::UnitGP8413::writeOutputRange ( const gp8413::Output range0,
const gp8413::Output range1 )

Write the output range.

Parameters
range0Output range to channel 0
range1Output range to channel 1
Returns
True if successful

◆ writeVoltage() [1/2]

template<typename T , typename std::enable_if< std::is_floating_point< T >::value, std::nullptr_t >::type = nullptr>
bool m5::unit::UnitGP8413::writeVoltage ( const gp8413::Channel channel,
const T mv )
inline

Output the voltage.

Parameters
channelChannel to output
mvOutput voltage(mV)
Returns
True if successful @Note If exceeding the range, it will be kept within the range

◆ writeVoltage() [2/2]

bool m5::unit::UnitGP8413::writeVoltage ( const gp8413::Channel channel,
const uint16_t raw )

Output the raw value.

Parameters
channelChannel to output
rawOutput raw value
Returns
True if successful