Loading...
Searching...
No Matches
a3g4250d.h
1
7
8// ALLOW FORMATTING
9#ifndef _A3G4250D_H
10#define _A3G4250D_H
11
12#include "spi.h"
13#include "gpiopin.h"
14
15#define A3G4250D_SENSITIVITY (0.00875f)
16#define A3G4250D_CTRL_REG1 0x20
17#define A3G4250D_CTRL_REG1_ODR_800Hz 0xC0
18#define A3G4250D_CTRL_REG1_PD_ENABLE 0x08
19#define A3G4250D_CTRL_REG1_AXIS_ENABLE 0x07
20#define A3G4250D_OUT_X_L 0x28
21#define A3G4250D_OUT_X_H 0x29
22#define A3G4250D_OUT_Y_L 0x2A
23#define A3G4250D_OUT_Y_H 0x2B
24#define A3G4250D_OUT_Z_L 0x2C
25#define A3G4250D_OUT_Z_H 0x2D
26
27#define A3G4250D_DATA_SIZE 2 // Two bytes per axis
28#define A3G4250D_DATA_COUNT 3 // Three axes - X Y Z
29#define A3G4250D_DATA_TOTAL (A3G4250D_DATA_COUNT * A3G4250D_DATA_SIZE)
30
36
38typedef struct A3G4250D {
42 void (*update)(struct A3G4250D *);
43 void (*readGyro)(struct A3G4250D *, float *);
44 void (*readRawBytes)(struct A3G4250D *, uint8_t *);
45 void (*processRawBytes)(struct A3G4250D *, uint8_t *, float *);
46 uint8_t axes[A3G4250D_DATA_COUNT];
47 int8_t sign[A3G4250D_DATA_COUNT];
48 uint8_t rawGyroData[A3G4250D_DATA_TOTAL];
49 float gyroData[A3G4250D_DATA_COUNT];
51
52A3G4250D_t A3G4250D_init(A3G4250D_t *, SPI_t *, GPIOpin_t, const float, const uint8_t *, const int8_t *);
54void A3G4250D_readGyro(A3G4250D_t *, float *);
55void A3G4250D_readRawBytes(A3G4250D_t *, uint8_t *);
56void A3G4250D_processRawBytes(A3G4250D_t *, uint8_t *, float *);
57
58uint8_t A3G4250D_readRegister(A3G4250D_t *, uint8_t);
59void A3G4250D_writeRegister(A3G4250D_t *, uint8_t, uint8_t);
60
62#endif
void A3G4250D_processRawBytes(A3G4250D_t *, uint8_t *, float *)
Process raw 3-axis data to floating point gyro rates.
Definition a3g4250d.c:94
void A3G4250D_update(A3G4250D_t *)
Updates internally stored gyro readings.
Definition a3g4250d.c:79
void A3G4250D_readRawBytes(A3G4250D_t *, uint8_t *)
Read raw 3-axis data.
Definition a3g4250d.c:109
void A3G4250D_readGyro(A3G4250D_t *, float *)
Read 3-axis floating point gyro rates.
Definition a3g4250d.c:65
A3G4250D_t A3G4250D_init(A3G4250D_t *, SPI_t *, GPIOpin_t, const float, const uint8_t *, const int8_t *)
Initialiser for a A3G4250D gyroscope.
Definition a3g4250d.c:28
Struct definition for a GPIO pin.
Definition gpiopin.h:151
Struct definition for SPI interface. Provides the interface for API consumers to interact with the SP...
Definition spi.h:134
uint8_t rawGyroData[A3G4250D_DATA_TOTAL]
Raw gyro rates array.
Definition a3g4250d.h:48
GPIOpin_t cs
Chip select GPIO.
Definition a3g4250d.h:40
void(* readRawBytes)(struct A3G4250D *, uint8_t *)
Raw gyro read method.
Definition a3g4250d.h:44
SPI_t * base
Parent SPI interface.
Definition a3g4250d.h:39
int8_t sign[A3G4250D_DATA_COUNT]
Array defining sign of axes.
Definition a3g4250d.h:47
uint8_t axes[A3G4250D_DATA_COUNT]
Array defining axes of mounting.
Definition a3g4250d.h:46
void(* readGyro)(struct A3G4250D *, float *)
Gyro read method.
Definition a3g4250d.h:43
float sensitivity
Gyroscope sensitivity.
Definition a3g4250d.h:41
void(* processRawBytes)(struct A3G4250D *, uint8_t *, float *)
Process raw gyro method.
Definition a3g4250d.h:45
void(* update)(struct A3G4250D *)
Gyro update method.
Definition a3g4250d.h:42
float gyroData[A3G4250D_DATA_COUNT]
Processed gyro rates array.
Definition a3g4250d.h:49