|
PebbleOS
|
#include <pbl/util/bits.h>Macros | |
STATUS1 bits | |
| #define | MMC5603NJ_STATUS1_OTP_READ_DONE_MASK PBL_BIT(4) |
| OTP memory has been read. | |
| #define | MMC5603NJ_STATUS1_SAT_SENSOR_MASK PBL_BIT(5) |
| Sensor is saturated. | |
| #define | MMC5603NJ_STATUS1_MEAS_M_DONE_MASK PBL_BIT(6) |
| Magnetic measurement done. | |
| #define | MMC5603NJ_STATUS1_MEAS_T_DONE_MASK PBL_BIT(7) |
| Temperature measurement done. | |
CTRL0 bits | |
| #define | MMC5603NJ_CTRL0_TAKE_MEAS_M PBL_BIT(0) |
| Take a single magnetic field measurement. | |
| #define | MMC5603NJ_CTRL0_TAKE_MEAS_T PBL_BIT(1) |
| Take a single temperature measurement. | |
| #define | MMC5603NJ_CTRL0_DO_SET PBL_BIT(3) |
| Perform a single set operation. | |
| #define | MMC5603NJ_CTRL0_DO_RESET PBL_BIT(4) |
| Perform a single reset operation. | |
| #define | MMC5603NJ_CTRL0_AUTO_SR_EN PBL_BIT(5) |
| Enable automatic set/reset. | |
| #define | MMC5603NJ_CTRL0_AUTO_ST_EN PBL_BIT(6) |
| Perform a single self-test. | |
| #define | MMC5603NJ_CTRL0_CMM_FREQ_EN PBL_BIT(7) |
| Compute the measurement period for the ODR. | |
CTRL1 bits | |
The bandwidth sets the measurement length; longer measurements have lower noise. | |
| #define | MMC5603NJ_CTRL1_BANDWIDTH_MASK PBL_GENMASK(1, 0) |
| Bandwidth field. | |
| #define | MMC5603NJ_CTRL1_BANDWIDTH_6ms6 0U |
| Bandwidth 0: 6.6 ms measurement. | |
| #define | MMC5603NJ_CTRL1_BANDWIDTH_3ms5 1U |
| Bandwidth 1: 3.5 ms measurement. | |
| #define | MMC5603NJ_CTRL1_BANDWIDTH_2ms 2U |
| Bandwidth 2: 2.0 ms measurement. | |
| #define | MMC5603NJ_CTRL1_BANDWIDTH_1ms2 3U |
| Bandwidth 3: 1.2 ms measurement. | |
| #define | MMC5603NJ_CTRL1_X_INHIBIT PBL_BIT(2) |
| Disable the X channel, shortening the measurement. | |
| #define | MMC5603NJ_CTRL1_Y_INHIBIT PBL_BIT(3) |
| Disable the Y channel, shortening the measurement. | |
| #define | MMC5603NJ_CTRL1_Z_INHIBIT PBL_BIT(4) |
| Disable the Z channel, shortening the measurement. | |
| #define | MMC5603NJ_CTRL1_ST_ENP PBL_BIT(5) |
| Drive a DC current through the self-test coil, offsetting the measured field. | |
| #define | MMC5603NJ_CTRL1_ST_ENM PBL_BIT(6) |
| As MMC5603NJ_CTRL1_ST_ENP, in the opposite direction. | |
| #define | MMC5603NJ_CTRL1_SW_RESET PBL_BIT(7) |
| Software reset: clear all registers and reread OTP. | |
CTRL2 bits | |
AUTOSET_PRD_n performs an automatic set/reset every n measurements. | |
| #define | MMC5603NJ_CTRL2_AUTOSET_PRD_MASK PBL_GENMASK(2, 0) |
| Automatic set/reset period field. | |
| #define | MMC5603NJ_CTRL2_AUTOSET_PRD_1 0U |
| Automatic set/reset every measurement. | |
| #define | MMC5603NJ_CTRL2_AUTOSET_PRD_25 1U |
| Automatic set/reset every 25 measurements. | |
| #define | MMC5603NJ_CTRL2_AUTOSET_PRD_75 2U |
| Automatic set/reset every 75 measurements. | |
| #define | MMC5603NJ_CTRL2_AUTOSET_PRD_100 3U |
| Automatic set/reset every 100 measurements. | |
| #define | MMC5603NJ_CTRL2_AUTOSET_PRD_250 4U |
| Automatic set/reset every 250 measurements. | |
| #define | MMC5603NJ_CTRL2_AUTOSET_PRD_500 5U |
| Automatic set/reset every 500 measurements. | |
| #define | MMC5603NJ_CTRL2_AUTOSET_PRD_1000 6U |
| Automatic set/reset every 1000 measurements. | |
| #define | MMC5603NJ_CTRL2_AUTOSET_PRD_2000 7U |
| Automatic set/reset every 2000 measurements. | |
| #define | MMC5603NJ_CTRL2_PRD_SET_EN PBL_BIT(3) |
| Enable periodic automatic set (recommended). | |
| #define | MMC5603NJ_CTRL2_CMM_EN PBL_BIT(4) |
| Enable continuous measurement mode. | |
| #define | MMC5603NJ_CTRL2_HPOWER PBL_BIT(7) |
| High power mode, allowing an ODR up to 1000 Hz. | |
Variables | |
Register addresses | |
| static const uint8_t | MMC5603NJ_REG_XOUT0 = 0x00 |
| X output, bits 19:12. | |
| static const uint8_t | MMC5603NJ_REG_XOUT1 = 0x01 |
| X output, bits 11:4. | |
| static const uint8_t | MMC5603NJ_REG_YOUT0 = 0x02 |
| Y output, bits 19:12. | |
| static const uint8_t | MMC5603NJ_REG_YOUT1 = 0x03 |
| Y output, bits 11:4. | |
| static const uint8_t | MMC5603NJ_REG_ZOUT0 = 0x04 |
| Z output, bits 19:12. | |
| static const uint8_t | MMC5603NJ_REG_ZOUT1 = 0x05 |
| Z output, bits 11:4. | |
| static const uint8_t | MMC5603NJ_REG_XOUT2 = 0x06 |
| X output, bits 3:0. | |
| static const uint8_t | MMC5603NJ_REG_YOUT2 = 0x07 |
| Y output, bits 3:0. | |
| static const uint8_t | MMC5603NJ_REG_ZOUT2 = 0x08 |
| Z output, bits 3:0. | |
| static const uint8_t | MMC5603NJ_REG_TOUT = 0x09 |
| Temperature output. | |
| static const uint8_t | MMC5603NJ_REG_STATUS1 = 0x18 |
| Device status. | |
| static const uint8_t | MMC5603NJ_REG_ODR = 0x1A |
| Output data rate. | |
| static const uint8_t | MMC5603NJ_REG_CTRL0 = 0x1B |
| Control register 0. | |
| static const uint8_t | MMC5603NJ_REG_CTRL1 = 0x1C |
| Control register 1. | |
| static const uint8_t | MMC5603NJ_REG_CTRL2 = 0x1D |
| Control register 2. | |
| static const uint8_t | MMC5603NJ_REG_ST_X_TH = 0x1E |
| X-axis self-test threshold. | |
| static const uint8_t | MMC5603NJ_REG_ST_Y_TH = 0x1F |
| Y-axis self-test threshold. | |
| static const uint8_t | MMC5603NJ_REG_ST_Z_TH = 0x20 |
| Z-axis self-test threshold. | |
| static const uint8_t | MMC5603NJ_REG_ST_X = 0x27 |
| X-axis self-test set value. | |
| static const uint8_t | MMC5603NJ_REG_ST_Y = 0x28 |
| Y-axis self-test set value. | |
| static const uint8_t | MMC5603NJ_REG_ST_Z = 0x29 |
| Z-axis self-test set value. | |
| static const uint8_t | MMC5603NJ_REG_WHO_AM_I = 0x39 |
| Product ID. | |
Device constants | |
| static const uint8_t | MMC5603NJ_WHO_AM_I_VALUE = 0x10 |
| Expected MMC5603NJ_REG_WHO_AM_I value. | |
| static const uint8_t | MMC5603NJ_SW_RESET_DELAY_MS = 20 |
| Delay in milliseconds required after a software reset. | |
| static const uint8_t | MMC5603NJ_SET_DELAY_MS = 1 |
| Delay in milliseconds required after a set or reset operation. | |