10 #define I2C_DEV_ADDR 0x6A
12 #define GYR_WHO_AM_I 0x0F // who am i, answer 0xD4
13 #define GYR_CTRL_REG1 0x20 // axis enable, power down, bandwidth
14 #define GYR_CTRL_REG2 0x21 // highpass filters
15 #define GYR_CTRL_REG3 0x22 // interrupts control
16 #define GYR_CTRL_REG4 0x23 // scale and data selection
17 #define GYR_CTRL_REG5 0x24 // miscanellous
18 #define GYR_REFERENCE 0x25 // reference register
19 #define GYR_OUT_TEMP 0x26 // temperature measure
20 #define GYR_STATUS_REG 0x27 // data status
21 #define GYR_OUT_X_L 0x28 // X value axis LSB
22 #define GYR_OUT_X_H 0x29 // X value axis MSB
23 #define GYR_OUT_Y_L 0x2A // Y value axis LSB
24 #define GYR_OUT_Y_H 0x2B // Y value axis MSB
25 #define GYR_OUT_Z_L 0x2C // Z value axis LSB
26 #define GYR_OUT_Z_H 0x2D // Z value axis MSB
27 #define GYR_FIFO_CTRL_REG 0x2E // fifo control register
28 #define GYR_FIFO_SRC_REG 0x2F // fifo status register
29 #define GYR_INT1_CFG 0x30 // interrupt control register
30 #define GYR_INT1_SRC 0x31 // interrupt status register
31 #define GYR_INT_TSH_XH 0x32 // X value treshold interrupt MSB
32 #define GYR_INT_TSH_XL 0x33 // X value treshold interrupt LSB
33 #define GYR_INT_TSH_YH 0x34 // Y value treshold interrupt MSB
34 #define GYR_INT_TSH_YL 0x35 // Y value treshold interrupt LSB
35 #define GYR_INT_TSH_ZH 0x36 // Z value treshold interrupt MSB
36 #define GYR_INT_TSH_ZL 0x37 // Z value treshold interrupt LSB
37 #define GYR_INT1_DURATION 0x38 // duration before interrupt
39 #define GYR_WHO_AM_I_DATA 0xD4 // signature of gyroscope
56 if(status !=
NO_ERROR)
return status;
57 status =
bus_writeread(bus,I2C_DEV_ADDR,®Address,1,data,1,NULL);
58 if(status !=
NO_ERROR)
return status;
60 if(status !=
NO_ERROR)
return status;
74 status =
Gyro_RD(GYR_WHO_AM_I,&data);
77 if(data != GYR_WHO_AM_I_DATA)
94 regAddress = GYR_OUT_X_L | (1 << 7);
96 if(status !=
NO_ERROR)
return status;
97 status =
bus_writeread(bus,I2C_DEV_ADDR,®Address,1,data,6,NULL);
98 if(status !=
NO_ERROR)
return status;
100 if(status !=
NO_ERROR)
return status;
106 measure->
y = -(data[0] | (data[1] << 8));
107 measure->
x = +(data[2] | (data[3] << 8));
108 measure->
z = +(data[4] | (data[5] << 8));
122 if(status !=
NO_ERROR)
return status;
123 status =
bus_write(bus,I2C_DEV_ADDR,&dta,2);
124 if(status !=
NO_ERROR)
return status;
126 if(status !=
NO_ERROR)
return status;
status_e bus_release(const struct heivs_bus_t *bus)
Release exclusive access to the bus.
int16_t z
z axis gyroscope value (32767 to -32768)
static status_e Gyro_RD(uint8_t address, uint8_t *data)
Read a data byte from gyroscope.
status_e Gyro_Write(uint8_t reg, uint8_t data)
Write special config to accelrometer.
int16_t y
y axis gyroscope value (32767 to -32768)
status_e bus_write(const struct heivs_bus_t *bus, uint32_t address, const void *data, size_t len)
Write data to the bus.
status_e bus_init(const struct heivs_bus_t *bus)
initialize the bus
const struct heivs_bus_t bus_i2c[BSP_I2C_BUS_COUNT]
All i2c busses.
You should check your solder/cables.
status_e Gyro_Init(void)
Initialise the gyroscope Accelerometer in initialised for fast acquisition.
status_e bus_get(const struct heivs_bus_t *bus)
Get exclusive access to the bus.
ARMEBS4 eeprom access functions.
status_e Gyro_Read(struct gyroscope_data_t *measure)
Read the X, Y and Z values from gyroscope.
status_e bus_writeread(const struct heivs_bus_t *bus, uint32_t address, const void *src, size_t src_len, void *dst, size_t dst_len, size_t *rlen)
Combined write and read data.
int16_t x
x axis gyroscope value (32767 to -32768)