Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HMC5843 by
HMC5843 Class Reference
Honeywell HMC5843 digital compass. More...
#include <HMC5843.h>
Public Member Functions | |
| HMC5843 (PinName sda, PinName scl) | |
| Constructor. | |
| HMC5843 (I2C &i2c) | |
| Constructor that accepts external i2c interface object. | |
| ~HMC5843 () | |
| Destructor that frees self-allocated I2C object. | |
| void | setSleepMode () |
| Enter into sleep mode. | |
| void | setDefault () |
| Set Device in Default Mode. | |
| void | getAddress (char *address) |
| Read the memory location on the device which contains the address. | |
| void | setOpMode (int mode, int ConfigA, int ConfigB) |
| Set the operation mode. | |
| void | write (int address, int data) |
| Write to on the device. | |
| void | readData (int *readings) |
| Get the output of all three axes. | |
| int | getMx () |
| Get the output of X axis. | |
| int | getMy () |
| Get the output of Y axis. | |
| int | getMz () |
| Get the output of Z axis. | |
| int | getStatus (void) |
| Get the current operation mode. | |
Static Public Attributes | |
| static const int | I2C_ADDRESS = HMC5843_I2C_WRITE |
| The I2C address that can be passed directly to i2c object (it's already shifted 1 bit left). | |
Protected Member Functions | |
| int | getWord (int regi) |
| Reads a word (2 bytes) from the sensor via I2C bus. | |
Detailed Description
Honeywell HMC5843 digital compass.
Definition at line 112 of file HMC5843.h.
Constructor & Destructor Documentation
| HMC5843 | ( | PinName | sda, |
| PinName | scl | ||
| ) |
Constructor.
- Parameters:
-
sda mbed pin to use for SDA line of I2C interface. scl mbed pin to use for SCL line of I2C interface.
Definition at line 39 of file HMC5843.cpp.
| HMC5843 | ( | I2C & | i2c ) |
| ~HMC5843 | ( | ) |
Member Function Documentation
| void getAddress | ( | char * | address ) |
Read the memory location on the device which contains the address.
- Parameters:
-
Pointer to a buffer to hold the address value Expected H, 4 and 3.
Definition at line 76 of file HMC5843.cpp.
| int getMx | ( | ) |
| int getMy | ( | ) |
| int getMz | ( | ) |
| int getStatus | ( | void | ) |
Get the current operation mode.
- Returns:
- Status register values
| int getWord | ( | int | regi ) | [protected] |
Reads a word (2 bytes) from the sensor via I2C bus.
The queried value is assumed big-endian, 2's complement value.
This protected function is added because we shouldn't write getMx(), getMy() and getMz() independently, but collect common codes.
- Parameters:
-
regi Register address to be read.
Definition at line 123 of file HMC5843.cpp.
| void readData | ( | int * | readings ) |
Get the output of all three axes.
- Parameters:
-
Pointer to a buffer to hold the magnetics value for the x-axis, y-axis and z-axis [in that order].
Definition at line 109 of file HMC5843.cpp.
| void setDefault | ( | void | ) |
Set Device in Default Mode.
HMC5843_CONTINUOUS, HMC5843_10HZ_NORMAL HMC5843_1_0GA
Definition at line 67 of file HMC5843.cpp.
| void setOpMode | ( | int | mode, |
| int | ConfigA, | ||
| int | ConfigB | ||
| ) |
Set the operation mode.
- Parameters:
-
mode 0x00 -> Continuous 0x01 -> Single 0x02 -> Idle ConfigA values ConfigB values
Definition at line 96 of file HMC5843.cpp.
| void setSleepMode | ( | ) |
Enter into sleep mode.
Definition at line 62 of file HMC5843.cpp.
| void write | ( | int | address, |
| int | data | ||
| ) |
Write to on the device.
- Parameters:
-
address Address to write to. data Data to write.
Definition at line 48 of file HMC5843.cpp.
Field Documentation
const int I2C_ADDRESS = HMC5843_I2C_WRITE [static] |
Generated on Sat Jul 23 2022 09:37:36 by
1.7.2
