JM9 XRCU Board 0.1.2
Libraries API Reference
Loading...
Searching...
No Matches
Hmc5883l Class Reference

HMC5883L Compass Driver for XRCU. More...

#include <Hmc5883l.h>

Inheritance diagram for Hmc5883l:
General_compass Heading_sensor Supported_sensor Supported_module

Public Member Functions

 Hmc5883l (const uint32_t init_port)
 Creates a new Hmc5883l object.
 
bool begin (const uint8_t init_i2c_address=DEFAULT_I2C_ADDRESS)
 Configures the settings of the I2C bus and the HMC5883L magnetometer.
 
bool begin (const Compass_cal_vals_t compass_cal_values, const uint8_t init_i2c_address=DEFAULT_I2C_ADDRESS)
 Configures the settings of the I2C bus and the HMC5883L magnetometer.
 
bool update ()
 Fetches and updates new data from the compass.
 
uint32_t id ()
 Reads the identification register.
 
bool is_mag_present ()
 Checks for the presence of the HMC5883L magnetometer on the I2C bus.
 
- Public Member Functions inherited from General_compass
int16_t get_raw_x ()
 Gets the magnetic field strength in X-axis in raw value.
 
int16_t get_raw_y ()
 Gets the magnetic field strength in Y-axis in raw value.
 
int16_t get_raw_z ()
 Gets the magnetic field strength in Z-axis in raw value.
 
Mag_field_raw_t get_raw_mag ()
 Gets a package of magnetic field strengths in 3 axes in raw value.
 
double get_uT_x ()
 Gets the magnetic field strength in X-axis in µT (microTesla).
 
double get_uT_y ()
 Gets the magnetic field strength in Y-axis in µT (microTesla).
 
double get_uT_z ()
 Gets the magnetic field strength in Z-axis in µT (microTesla).
 
Mag_field_uT_t get_uT_mag ()
 Gets a package of magnetic field strengths in 3 axes in µT (microTesla).
 
bool compass_cal ()
 Calibrates the compass, and find the ranges of each axis respectively for compass usage.
 
Compass_cal_vals_t get_prev_caled_vals ()
 Gets the previously calibrated values of the compass.
 
void save_caled_vals ()
 Saves the calibrated values into local EEPROM.
 
bool reset_heading ()
 Takes the current heading of compass as zero.
 
int16_t get_re_zero_heading ()
 Gets the real-world heading referenced as zero-degrees.
 
void save_re_zero_heading ()
 Saves the real-world heading referenced as zero-degrees into local EEPROM.
 
virtual uint16_t get_heading ()
 Gets the heading of compass in degrees.
 

Additional Inherited Members

- Protected Member Functions inherited from General_compass
void set_raw_data (Mag_field_raw_t data)
 Sets the latest raw values of magnetic field strength in 3 axes.
 
void set_cal_vals (Compass_cal_vals_t vals)
 Sets the calibration values.
 
Compass_cal_vals_t get_eeprom_caled_vals ()
 Loads calibration values from EEPROM.
 
void use_eeprom_re_zero_heading ()
 Uses the re-zero heading from EEPROM.
 
 General_compass ()
 Creates a General_compass object.
 
- Protected Member Functions inherited from Heading_sensor
 Heading_sensor ()
 Creates a Heading_sensor object.
 
- Protected Member Functions inherited from Supported_sensor
 Supported_sensor ()
 Creates an object of a supported sensor.
 
- Protected Member Functions inherited from Supported_module
 Supported_module ()
 Creates an object of a supported module.
 

Detailed Description

HMC5883L Compass Driver for XRCU.

Author
YH Choi @ JM9

Constructor & Destructor Documentation

◆ Hmc5883l()

Hmc5883l::Hmc5883l ( const uint32_t init_port)

Creates a new Hmc5883l object.

Parameters
init_portthe I2C port connected to this HMC5883L magnetometer.

Member Function Documentation

◆ begin() [1/2]

bool Hmc5883l::begin ( const Compass_cal_vals_t compass_cal_values,
const uint8_t init_i2c_address = DEFAULT_I2C_ADDRESS )

Configures the settings of the I2C bus and the HMC5883L magnetometer.

YOU MUST CALL THIS FUNCTION IN void setup () FUNCTION TO USE THIS OBJECT PROPERLY.

Parameters
compass_cal_valuesthe calibrated values of the HMC5883L magnetometer
init_i2c_addressthe 7-bit I2C address of the HMC5883L magnetometer
Returns
true if activation succeed, false if activation failed

◆ begin() [2/2]

bool Hmc5883l::begin ( const uint8_t init_i2c_address = DEFAULT_I2C_ADDRESS)

Configures the settings of the I2C bus and the HMC5883L magnetometer.

YOU MUST CALL THIS FUNCTION IN void setup () FUNCTION TO USE THIS OBJECT PROPERLY.

Parameters
init_i2c_addressthe 7-bit I2C address of the HMC5883L magnetometer
Returns
true if activation succeed, false if activation failed

◆ id()

uint32_t Hmc5883l::id ( )

Reads the identification register.

Returns
the identification register, which should have a value of ASCII-encoded "H4C"

◆ is_mag_present()

bool Hmc5883l::is_mag_present ( )

Checks for the presence of the HMC5883L magnetometer on the I2C bus.

Returns
true if the HMC5883L magnetometer is found on the I2C bus, false otherwise

◆ update()

bool Hmc5883l::update ( )
virtual

Fetches and updates new data from the compass.

Returns
true if new data is fetched and updated, false if new data is not ready

Implements General_compass.


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