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

#include <modm/driver/inertial/hmc5883l.hpp>

Inheritance diagram for modm::hmc5883< I2cMaster >:
modm::Hmc58x3< I2cMaster > modm::I2cDevice< I2cMaster, 2 > modm::NestedResumable< 10+1 >

Public Types

enum  MeasurementAverage : uint8_t { Average8 = int(ConfigA::MA1) | int(ConfigA::MA0), Average4 = int(ConfigA::MA1), Average2 = int(ConfigA::MA0), Average1 = 0 }
 
enum  Gain : uint8_t {
  Ga0_88 = 0, Ga1_3 = int(ConfigB::GN0), Ga1_9 = int(ConfigB::GN1), Ga2_5 = int(ConfigB::GN1) | int(ConfigB::GN2),
  Ga4_0 = int(ConfigB::GN2), Ga4_7 = int(ConfigB::GN2) | int(ConfigB::GN0), Ga5_6 = int(ConfigB::GN2) | int(ConfigB::GN1), Ga8_1 = int(ConfigB::GN2) | int(ConfigB::GN1) | int(ConfigB::GN0)
}
 
enum  MeasurementRate : uint8_t {
  Hz0_75 = 0, Hz1_5 = int(ConfigA::DO0), Hz3 = int(ConfigA::DO1), Hz7_5 = int(ConfigA::DO1) | int(ConfigA::DO0),
  Hz15 = int(ConfigA::DO2), Hz30 = int(ConfigA::DO2) | int(ConfigA::DO0), Hz75 = int(ConfigA::DO2) | int(ConfigA::DO1)
}
 
enum  ConfigA : uint8_t
 Configuration Register A.
 
enum  ConfigB : uint8_t
 Configuration Register B.
 
enum  Mode : uint8_t
 Mode Register.
 
enum  OperationMode : uint8_t
 Operation modes.
 
enum  Status : uint8_t
 Status Register.
 

Public Member Functions

 Hmc5883 (Data &data, uint8_t address=0x1e)
 Constructor, requires a hmc58x3::Data object, sets address to default of 0x1e.
 
modm::ResumableResult< bool > configure (MeasurementRate rate=MeasurementRate::Hz15, Gain gain=Gain::Ga1_3, MeasurementAverage average=MeasurementAverage::Average1)
 
modm::ResumableResult< bool > setMeasurementAverage (MeasurementAverage average)
 
modm::ResumableResult< bool > setMeasurementRate (MeasurementRate rate)
 
modm::ResumableResult< bool > setGain (Gain gain)
 
 MODM_FLAGS8 (ConfigA)
 
 MODM_FLAGS8 (ConfigB)
 
 MODM_FLAGS8 (Mode)
 
 MODM_FLAGS8 (Status)
 
void attachConfigurationHandler (I2c::ConfigurationHandler handler)
 
DatagetData ()
 Get the data object for this sensor.
 
Status_t getStatus ()
 
modm::ResumableResult< bool > ping ()
 
modm::ResumableResult< bool > readMagneticField ()
 
modm::ResumableResult< bool > readStatus ()
 
void setAddress (uint8_t address)
 
modm::ResumableResult< bool > setOperationMode (OperationMode mode)
 

Protected Member Functions

modm::ResumableResult< ReturnType > resumable function (...)
 
ConfigA_t getConfigA ()
 
ConfigB_t getConfigB ()
 
Mode_t getMode ()
 
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.
 
modm::ResumableResult< bool > updateConfigA (ConfigA_t setMask, ConfigA_t clearMask=ConfigA_t (0x7f))
 
modm::ResumableResult< bool > updateConfigB (ConfigB_t setMask, ConfigB_t clearMask=ConfigB_t (0xe0))
 
modm::ResumableResult< bool > updateMode (Mode_t setMask, Mode_t clearMask=Mode::MD_Mask)
 
bool wasTransactionSuccessful ()
 

Protected Attributes

I2cWriteReadTransaction transaction
 

Detailed Description

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

HMC5843 digital compass driver.

This class extends the Hmc58x3 family driver only by the addition of device specific Register bit masks.

For further information on this device consult the datasheet.

See also
Hmc58x3
Author
Niklas Hauser

Member Function Documentation

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