modm API documentation
modm::as5600< I2cMaster > Class Template Reference
Inheritance diagram for modm::as5600< I2cMaster >:
modm::I2cDevice< I2cMaster, 2 > modm::NestedResumable< 10+1 >

Public Typedefs

using PowerMode_t = Configuration< Config_t, PowerMode, 0b11, 0 >
 
using Hysteresis_t = Configuration< Config_t, Hysteresis, 0b11, 2 >
 
using OutputStage_t = Configuration< Config_t, OutputStage, 0b11, 4 >
 
using PWMFrequency_t = Configuration< Config_t, PWMFrequency, 0b11, 6 >
 
using SlowFilter_t = Configuration< Config_t, SlowFilter, 0b11, 8 >
 
using FastFilterThreshold_t = Configuration< Config_t, FastFilterThreshold, 0b11, 10 >
 
using Data = modm::IntegerAngle< 12 >
 

Public Types

enum  Register : uint8_t {
  ZMCO = 0x00, ZPOS = 0x01, MPOS = 0x03, MANG = 0x05,
  CONF = 0x07, ANGLE_RAW = 0x0C, ANGLE = 0x0E, STATUS = 0x0B,
  AGC = 0x1A, MAGNITUDE = 0x1B, BURN = 0xFF, I2C_ADDR = 0x20,
  I2C_UPDT = 0x21
}
 
enum  Config : uint16_t {
  PM0 = Bit0, PM1 = Bit1, HYST0 = Bit2, HYST1 = Bit3,
  OUTS0 = Bit4, OUTS1 = Bit5, PWM0 = Bit6, PWM1 = Bit7,
  SF0 = Bit8, SF1 = Bit9, FTH0 = Bit10, FTH1 = Bit11,
  FTH2 = Bit12, WD = Bit13
}
 
enum  PowerMode : uint16_t { NOM = 0, LPM1 = 1, LPM2 = 2, LPM3 = 3 }
 
enum  Hysteresis : uint16_t { OFF = 0, LSB = 1, LSB2 = 2, LSB3 = 3 }
 
enum  OutputStage : uint16_t { ANALOG = 0, ANALOG_REDUCED = 1, PWM = 2 }
 
enum  PWMFrequency : uint16_t { Hz115 = 0, Hz230 = 1, Hz460 = 2, Hz920 = 3 }
 
enum  SlowFilter : uint16_t { x16 = 0, x8 = 1, x4 = 2, x2 = 3 }
 
enum  FastFilterThreshold : uint16_t {
  LSB6 = 0, LSB7 = 1, LSB9 = 2, LSB18 = 3,
  LSB21 = 4, LSB24 = 5, LSB10 = 6
}
 
enum  Burn : uint8_t { ANGLE = Bit3, CONFIG = Bit2 }
 
enum  Status : uint8_t { MagnetTooStrong = Bit3, MagnetTooWeak = Bit4, MagnetDetected = Bit5 }
 

Public Member Functions

 MODM_FLAGS16 (Config)
 
 MODM_FLAGS8 (Status)
 
 As5600 (Data &data, uint8_t address=0x36)
 
modm::ResumableResult< bool > reset ()
 
modm::ResumableResult< bool > configure (Config_t config)
 
modm::ResumableResult< bool > setI2cAddress (uint8_t address)
 
modm::ResumableResult< bool > setLowerLimit (Data data)
 Wait 1ms after setting the lower limit.
 
modm::ResumableResult< bool > setUpperLimit (Data data)
 Wait 1ms after setting the upper limit.
 
modm::ResumableResult< bool > setMaxAngle (Data data)
 
modm::ResumableResult< bool > burn (Burn flags)
 
modm::ResumableResult< DatagetRawValue ()
 
modm::ResumableResult< Status > getStatus ()
 
modm::ResumableResult< uint16_t > getMagnitude ()
 
modm::ResumableResult< uint8_t > getAgcValue ()
 
modm::ResumableResult< bool > read ()
 
DatagetData ()
 
void attachConfigurationHandler (I2c::ConfigurationHandler handler)
 
modm::ResumableResult< bool > ping ()
 
modm::ResumableResult< bool > read (uint8_t *buffer, std::size_t size)
 Starts a write transaction and waits until finished.
 
void setAddress (uint8_t address)
 
modm::ResumableResult< bool > write (const uint8_t *buffer, std::size_t size)
 Starts a write transaction and waits until finished.
 
modm::ResumableResult< bool > writeRead (const uint8_t *writeBuffer, std::size_t writeSize, uint8_t *readBuffer, std::size_t readSize)
 Starts a write-read transaction and waits until finished.
 

Protected Member Functions

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 separate 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
 

Member Function Documentation

template<class I2cMaster >
modm::as5600< I2cMaster >::As5600 ( Data data,
uint8_t  address = 0x36 
)
inline

AS5600 has hardwired address 0x36 AS4500L has default address 0x40 but supports programming a different one

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.

template<class I2cMaster >
modm::ResumableResult<bool> modm::as5600< I2cMaster >::burn ( Burn  flags)
inline

Permanently burn configurations

Warning
As5600 can be burned only 3 times!
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.
template<class I2cMaster >
modm::ResumableResult<uint8_t> modm::as5600< I2cMaster >::getAgcValue ( )
inline

Automated Gain Control

The AS5600 uses Automatic Gain Control in a closed loop to compensate for variations of the magnetic field strength due to changes of temperature, airgap between IC and magnet, and magnet degradation.

For the most robust performance, the gain value should be in the center of its range. The airgap of the physical system can be adjusted to achieve this value.

In 5V operation, range is 0-255 In 3.3V operation, range is reduced to 0-128

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
template<class I2cMaster >
modm::ResumableResult<bool> modm::as5600< I2cMaster >::reset ( )
inline

Reset to Power up state. Useful for developement, not required in production.

The config registers span from 0x00 to 0x08

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).
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: