26#define MAGNETO_METER_ADDR 0x1E
28#define MAGNETO_ACCEL_ADDR 0x19
30#define MAGNETO_I2C_SDA_PIN 0
32#define MAGNETO_I2C_SCL_PIN 1
34#define MAGNETO_I2C_BAUDRATE 1000000
37#define MAGNETO_CTRL_REG1_A 0x20
40#define MAGNETO_OUT_X_L_A 0x28
42#define MAGNETO_OUT_X_H_A 0x29
44#define MAGNETO_OUT_Y_L_A 0x2A
46#define MAGNETO_OUT_Y_H_A 0x2B
48#define MAGNETO_OUT_Z_L_A 0x2C
50#define MAGNETO_OUT_Z_H_A 0x2D
53#define MAGNETO_CRA_REG_M 0x00
55#define MAGNETO_MR_REG_M 0x02
57#define MAGNETO_OUT_X_H_M 0x03
59#define MAGNETO_OUT_X_L_M 0x04
61#define MAGNETO_OUT_Z_H_M 0x05
63#define MAGNETO_OUT_Z_L_M 0x06
65#define MAGNETO_OUT_Y_H_M 0x07
67#define MAGNETO_OUT_Y_L_M 0x08
70#define MAGNETO_BEARING_OFFSET 1.0f
72#define MAGNETO_GRAVITY_CONSTANT_F 9.80665 / 16384.0
void magneto_read_data(void)
Reads magnetometer data from the magnetometer sensor and outputs the values into the global variables...
Definition: magnetometer.c:69
float magneto_get_curr_bearing(void)
Gets the current bearing of the magnetometer sensor.
Definition: magnetometer.c:139
bool magneto_is_bearing_invalid(void)
Checks if the current bearing is invalid if it is out of bounds.
Definition: magnetometer.c:116
float magneto_get_true_bearing(void)
Gets the true bearing of the magnetometer sensor.
Definition: magnetometer.c:128
void magneto_init(void)
Initializes the magnetometer by initializing the USB, I2C, and setting the GPIO pins.
Definition: magnetometer.c:149