Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 #include "drv_spi_master.h"
71 #define GYRO9_REG_WHO_AM_I 0x0F
72 #define GYRO9_REG_CTRL_REG1 0x20
73 #define GYRO9_REG_CTRL_REG2 0x21
74 #define GYRO9_REG_CTRL_REG3 0x22
75 #define GYRO9_REG_CTRL_REG4 0x23
76 #define GYRO9_REG_CTRL_REG5 0x24
77 #define GYRO9_REG_REFERENCE 0x25
78 #define GYRO9_REG_OUT_TEMP 0x26
79 #define GYRO9_REG_STATUS_REG 0x27
80 #define GYRO9_REG_OUT_X_L 0x28
81 #define GYRO9_REG_OUT_X_H 0x29
82 #define GYRO9_REG_OUT_Y_L 0x2A
83 #define GYRO9_REG_OUT_Y_H 0x2B
84 #define GYRO9_REG_OUT_Z_L 0x2C
85 #define GYRO9_REG_OUT_Z_H 0x2D
86 #define GYRO9_REG_FIFO_CTRL_REG 0x2E
87 #define GYRO9_REG_FIFO_SRC_REG 0x2F
88 #define GYRO9_REG_INT1_CFG 0x30
89 #define GYRO9_REG_INT1_SRC 0x31
90 #define GYRO9_REG_INT1_TSH_XH 0x32
91 #define GYRO9_REG_INT1_TSH_XL 0x33
92 #define GYRO9_REG_INT1_TSH_YH 0x34
93 #define GYRO9_REG_INT1_TSH_YL 0x35
94 #define GYRO9_REG_INT1_TSH_ZH 0x36
95 #define GYRO9_REG_INT1_TSH_ZL 0x37
96 #define GYRO9_REG_INT1_DURATION 0x38
114 #define GYRO9_WHO_AM_I 0xD3
120 #define GYRO9_ODR_100_HZ 0x00
121 #define GYRO9_ODR_200_HZ 0x01
122 #define GYRO9_ODR_400_HZ 0x02
123 #define GYRO9_ODR_800_HZ 0x03
124 #define GYRO9_ODR_BIT_MASK 0xC0
130 #define GYRO9_BW_0 0x00
131 #define GYRO9_BW_1 0x01
132 #define GYRO9_BW_2 0x02
133 #define GYRO9_BW_3 0x03
134 #define GYRO9_BW_BIT_MASK 0x30
140 #define GYRO9_PD_POWER_DOWN 0x00
141 #define GYRO9_PD_SLEEP 0x08
142 #define GYRO9_PD_NORMAL 0x0F
143 #define GYRO9_PD_BIT_MASK 0x08
149 #define GYRO9_FIFO_CTRL_BYPASS_MODE 0x00
150 #define GYRO9_FIFO_CTRL_FIFO_MODE 0x01
151 #define GYRO9_FIFO_CTRL_STREAM_MODE 0x02
152 #define GYRO9_FIFO_CTRL_BIT_MASK 0xE0
158 #define GYRO9_CTRL_I1_INT1_EN 0x80
159 #define GYRO9_CTRL_I1_INT1_DIS 0x00
160 #define GYRO9_CTRL_I1_BOOT_EN 0x40
161 #define GYRO9_CTRL_I1_BOOT_DIS 0x00
162 #define GYRO9_CTRL_H_LACTIVE_EN 0x20
163 #define GYRO9_CTRL_H_LACTIVE_DIS 0x00
164 #define GYRO9_CTRL_PP_OD_EN 0x10
165 #define GYRO9_CTRL_PP_OD_DIS 0x00
166 #define GYRO9_CTRL_I2_DRDY_EN 0x08
167 #define GYRO9_CTRL_I2_DRDY_DIS 0x00
168 #define GYRO9_CTRL_I2_WTM_EN 0x04
169 #define GYRO9_CTRL_I2_WTM_DIS 0x00
170 #define GYRO9_CTRL_I2_ORUN_EN 0x02
171 #define GYRO9_CTRL_I2_ORUN_DIS 0x00
172 #define GYRO9_CTRL_I2_EMPTY_EN 0x01
173 #define GYRO9_CTRL_I2_EMPTY_DIS 0x00
179 #define GYRO9_SENSITIVITY_DPS 0.00875f
186 #define GYRO9_DEVICE_ADDRESS_GND 0x68
187 #define GYRO9_DEVICE_ADDRESS_VCC 0x69
197 #define GYRO9_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
198 #define GYRO9_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
216 #define GYRO9_MAP_MIKROBUS( cfg, mikrobus ) \
217 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
218 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
219 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
220 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
221 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
222 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
223 cfg.dr = MIKROBUS( mikrobus, MIKROBUS_AN ); \
224 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
pin_name_t cs
Definition: gyro9.h:278
gyro9_return_value_t
Gyro 9 Click return value data.
Definition: gyro9.h:323
void gyro9_cfg_setup(gyro9_cfg_t *cfg)
Gyro 9 configuration object setup function.
uint8_t i2c_address
Definition: gyro9.h:283
void gyro9_drv_interface_selection(gyro9_cfg_t *cfg, gyro9_drv_t drv_sel)
Gyro 9 driver interface setup function.
err_t gyro9_init(gyro9_t *ctx, gyro9_cfg_t *cfg)
Gyro 9 initialization function.
struct gyro9_s gyro9_t
Gyro 9 Click context object.
int16_t z
Definition: gyro9.h:301
int16_t x
Definition: gyro9.h:299
uint32_t spi_speed
Definition: gyro9.h:285
gyro9_drv_t
Gyro 9 Click driver selector.
Definition: gyro9.h:234
uint8_t gyro9_get_interrupt(gyro9_t *ctx)
Gyro 9 get interrupt function.
float z
Definition: gyro9.h:314
err_t gyro9_set_mode_normal(gyro9_t *ctx)
Gyro 9 set normal mode function.
pin_name_t mosi
Definition: gyro9.h:276
pin_name_t chip_select
Definition: gyro9.h:259
This file contains SPI specific macros, functions, etc.
err_t gyro9_set_fifo_mode(gyro9_t *ctx, uint8_t fifo_mode)
Gyro 9 set FIFO mode function.
err_t gyro9_set_output_data_rate(gyro9_t *ctx, uint8_t odr)
Gyro 9 set output data rate function.
uint8_t slave_address
Definition: gyro9.h:258
err_t gyro9_set_mode_sleep(gyro9_t *ctx)
Gyro 9 set sleep mode function.
gyro9_drv_t drv_sel
Definition: gyro9.h:289
uint8_t gyro9_get_data_ready(gyro9_t *ctx)
Gyro 9 get data ready function.
@ GYRO9_DRV_SEL_SPI
Definition: gyro9.h:235
err_t gyro9_get_status(gyro9_t *ctx, uint8_t *status)
Gyro 9 get status function.
err_t gyro9_default_cfg(gyro9_t *ctx)
Gyro 9 default configuration function.
Gyro 9 Click context object.
Definition: gyro9.h:251
float x
Definition: gyro9.h:312
Gyro 9 Click axis raw data structure object.
Definition: gyro9.h:298
err_t gyro9_get_gyro_axis(gyro9_t *ctx, gyro9_axis_t *gyro_axis)
Gyro 9 get gyro sensor axes function.
gyro9_master_io_t write_f
Definition: gyro9.h:262
int16_t y
Definition: gyro9.h:300
digital_in_t int_pin
Definition: gyro9.h:253
spi_master_t spi
Definition: gyro9.h:256
err_t gyro9_set_mode_pd(gyro9_t *ctx)
Gyro 9 set power-down mode function.
err_t gyro9_generic_write(gyro9_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Gyro 9 data writing function.
@ GYRO9_DRV_SEL_I2C
Definition: gyro9.h:236
pin_name_t int_pin
Definition: gyro9.h:280
pin_name_t dr
Definition: gyro9.h:279
i2c_master_t i2c
Definition: gyro9.h:255
pin_name_t sda
Definition: gyro9.h:274
gyro9_drv_t drv_sel
Definition: gyro9.h:260
pin_name_t sck
Definition: gyro9.h:277
spi_master_chip_select_polarity_t cs_polarity
Definition: gyro9.h:287
err_t gyro9_generic_read(gyro9_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Gyro 9 data reading function.
uint32_t i2c_speed
Definition: gyro9.h:282
digital_in_t dr
Definition: gyro9.h:252
err_t gyro9_enable_data_ready(gyro9_t *ctx)
Gyro 9 enable data ready function.
err_t gyro9_get_temperature_raw(gyro9_t *ctx, int8_t *temp_raw)
Gyro 9 get temperature data function.
err_t(* gyro9_master_io_t)(struct gyro9_s *, uint8_t, uint8_t *, uint8_t)
Gyro 9 Click driver interface.
Definition: gyro9.h:244
err_t gyro9_set_bandwidth_sel(gyro9_t *ctx, uint8_t bandwidth)
Gyro 9 set bandwidth function.
pin_name_t scl
Definition: gyro9.h:273
float y
Definition: gyro9.h:313
@ GYRO9_OK
Definition: gyro9.h:324
pin_name_t miso
Definition: gyro9.h:275
@ GYRO9_ERROR
Definition: gyro9.h:325
err_t gyro9_get_axis_data(gyro9_t *ctx, gyro9_axis_data_t *gyro_axis)
Gyro 9 get gyro data function.
Gyro 9 Click sensor axes structure object.
Definition: gyro9.h:311
err_t gyro9_get_device_id(gyro9_t *ctx, uint8_t *who_am_i)
Gyro 9 get device ID function.
gyro9_master_io_t read_f
Definition: gyro9.h:263
Gyro 9 Click configuration object.
Definition: gyro9.h:272
spi_master_mode_t spi_mode
Definition: gyro9.h:286