INF2004-Project v0.1
 
Loading...
Searching...
No Matches
magnetometer.h
Go to the documentation of this file.
1
12#ifndef MAGNETOMETER_H // Include guard.
13#define MAGNETOMETER_H
14
15// Definitions.
16// -----------------------------------------------------------------------------
17//
18
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
35
37#define MAGNETO_CTRL_REG1_A 0x20
38
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
51
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
68
70#define MAGNETO_BEARING_OFFSET 1.0f
72#define MAGNETO_GRAVITY_CONSTANT_F 9.80665 / 16384.0
73 // End of magnetometer_constants group.
76
77// Public Function prototypes.
78//
79void magneto_init(void);
80void magneto_read_data(void);
82float magneto_get_true_bearing(void);
83float magneto_get_curr_bearing(void);
84
85#endif // MAGNETOMETER_H
86
87// End of file driver/magnetometer/magnetometer.h.
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