Loading...
Searching...
No Matches
iam_20380.h
1
7
8// ALLOW FORMATTING
9#ifndef _IAM_20380_H
10#define _IAM_20380_H
11
12#include "gyroscope.h"
13
14#include "spi.h"
15#include "gpiopin.h"
16
17#define IAM_20380_SENSITIVITY_FS_SEL250 (1.0f / 131.0f)
18#define IAM_20380_SENSITIVITY_FS_SEL500 (1.0f / 65.5f)
19#define IAM_20380_SENSITIVITY_FS_SEL1000 (1.0f / 32.8f)
20#define IAM_20380_SENSITIVITY_FS_SEL2000 (1.0f / 16.4f)
21#define IAM_20380_SAMPLE_RATE_DIV(rate) (1000.0f / rate) - 1
22
23#define IAM_20380_WHO_AM_I 0x75
24
25#define IAM_20380_XG_OFFS_USRH 0x13
26#define IAM_20380_XG_OFFS_USRL 0x14
27#define IAM_20380_YG_OFFS_USRH 0x15
28#define IAM_20380_YG_OFFS_USRL 0x16
29#define IAM_20380_ZG_OFFS_USRH 0x17
30#define IAM_20380_ZG_OFFS_USRL 0x18
31
32#define IAM_20380_SMPLRT_DIV 0x19
33#define IAM_20380_CONFIG 0x1A
34#define IAM_20380_GYRO_CONFIG 0x1B
35
36#define IAM_20380_XOUT_H 0x43
37#define IAM_20380_XOUT_L 0x44
38#define IAM_20380_YOUT_H 0x45
39#define IAM_20380_YOUT_L 0x46
40#define IAM_20380_ZOUT_H 0x47
41#define IAM_20380_ZOUT_L 0x48
42
43#define IAM_20380_CONFIG_FS_SEL250 0x00
44#define IAM_20380_CONFIG_FS_SEL500 0x08
45#define IAM_20380_CONFIG_FS_SEL1000 0x10
46#define IAM_20380_CONFIG_FS_SEL2000 0x18
47
48#define IAM_20380_USER_CTRL 0x6A
49#define IAM_20380_PWR_MGMT_1 0x6B
50#define IAM_20380_PWR_MGMT_2 0x6C
51
52#define IAM_20380_PWR_MGMT_1_RESET 0x80
53#define IAM_20380_PWR_MGMT_1_CLKSEL 0x01
54
55#define IAM_20380_PWR_MGMT_2_STBY_XG 0x4
56#define IAM_20380_PWR_MGMT_2_STBY_YG 0x2
57#define IAM_20380_PWR_MGMT_2_STBY_ZG 0x1
58
59#define IAM_20380_DATA_SIZE 2 // Two bytes per axis
60#define IAM_20380_DATA_COUNT 3 // Three axes - X Y Z
61#define IAM_20380_DATA_TOTAL (IAM_20380_DATA_COUNT * IAM_20380_DATA_SIZE)
62
68
70typedef struct IAM_20380 {
74 uint8_t dataSize;
76 uint8_t axes[IAM_20380_DATA_COUNT];
77 int8_t sign[IAM_20380_DATA_COUNT];
78 uint8_t rawGyroData[IAM_20380_DATA_TOTAL];
79 float gyroData[IAM_20380_DATA_COUNT];
80 float bias[IAM_20380_DATA_COUNT];
82
83IAM_20380_t IAM_20380_init(IAM_20380_t *, SPI_t *, GPIOpin_t, const float, const uint8_t *, const int8_t *);
85void IAM_20380_readGyro(Gyro_t *, float *);
86void IAM_20380_readRawBytes(Gyro_t *, uint8_t *);
87void IAM_20380_processRawBytes(Gyro_t *, uint8_t *, float *);
88
90#endif
Struct definition for a GPIO pin.
Definition gpiopin.h:151
void IAM_20380_processRawBytes(Gyro_t *, uint8_t *, float *)
Process raw 3-axis data to floating point gyro rates.
Definition iam_20380.c:119
IAM_20380_t IAM_20380_init(IAM_20380_t *, SPI_t *, GPIOpin_t, const float, const uint8_t *, const int8_t *)
Initialiser for a IAM_20380 gyroscope.
Definition iam_20380.c:27
void IAM_20380_readRawBytes(Gyro_t *, uint8_t *)
Read raw 3-axis data.
Definition iam_20380.c:135
void IAM_20380_readGyro(Gyro_t *, float *)
Read 3-axis floating point gyro rates.
Definition iam_20380.c:90
void IAM_20380_update(Gyro_t *)
Updates internally stored gyro readings.
Definition iam_20380.c:104
Struct definition for SPI interface. Provides the interface for API consumers to interact with the SP...
Definition spi.h:134
Defines the API for the Gyroscope sensor.
uint8_t rawGyroData[IAM_20380_DATA_TOTAL]
Raw gyro rates array.
Definition iam_20380.h:78
float gyroData[IAM_20380_DATA_COUNT]
Processed gyro rates array.
Definition iam_20380.h:79
float bias[IAM_20380_DATA_COUNT]
Bias offset array.
Definition iam_20380.h:80
GPIOpin_t cs
Chip select GPIO.
Definition iam_20380.h:73
Gyro_t base
Base gyroscope API.
Definition iam_20380.h:71
uint8_t axes[IAM_20380_DATA_COUNT]
Array defining axes of mounting.
Definition iam_20380.h:76
float sensitivity
Gyroscope sensitivity.
Definition iam_20380.h:75
int8_t sign[IAM_20380_DATA_COUNT]
Array defining sign of axes.
Definition iam_20380.h:77
SPI_t * spi
Parent SPI interface.
Definition iam_20380.h:72
uint8_t dataSize
Total data size.
Definition iam_20380.h:74