no-OS
adxrs290.h
Go to the documentation of this file.
1 /***************************************************************************/
40 #ifndef ADXRS290_H_
41 #define ADXRS290_H_
42 
43 /******************************************************************************/
44 /***************************** Include Files **********************************/
45 /******************************************************************************/
46 
47 #include <stdlib.h>
48 #include <stdbool.h>
49 #include "no_os_gpio.h"
50 #include "no_os_spi.h"
51 #include "no_os_util.h"
52 
53 /******************************************************************************/
54 /********************** Macros and Constants Definitions **********************/
55 /******************************************************************************/
56 
57 /* ADXRS290 ID */
58 #define ADXRS290_ADI_ID 0xAD
59 #define ADXRS290_MEMS_ID 0x1D
60 #define ADXRS290_DEV_ID 0x92
61 
62 /* ADXRS290 Registers */
63 #define ADXRS290_REG_ADI_ID 0x00
64 #define ADXRS290_REG_MEMS_ID 0x01
65 #define ADXRS290_REG_DEV_ID 0x02
66 #define ADXRS290_REG_REV_ID 0x03
67 #define ADXRS290_REG_SN0 0x04
68 #define ADXRS290_REG_SN1 0x05
69 #define ADXRS290_REG_SN2 0x06
70 #define ADXRS290_REG_SN3 0x07
71 #define ADXRS290_REG_DATAX0 0x08
72 #define ADXRS290_REG_DATAX1 0x09
73 #define ADXRS290_REG_DATAY0 0x0A
74 #define ADXRS290_REG_DATAY1 0x0B
75 #define ADXRS290_REG_TEMP0 0x0C
76 #define ADXRS290_REG_TEMP1 0x0D
77 
78 #define ADXRS290_REG_POWER_CTL 0x10
79 #define ADXRS290_REG_FILTER 0x11
80 #define ADXRS290_REG_DATA_READY 0x12
81 
82 #define ADXRS290_READ NO_OS_BIT(7)
83 #define ADXRS290_TSM NO_OS_BIT(0)
84 #define ADXRS290_MEASUREMENT NO_OS_BIT(1)
85 #define ADXRS290_DATA_RDY_OUT NO_OS_BIT(0)
86 #define ADXRS290_SYNC_MASK 0x03
87 #define ADXRS290_SYNC(x) (x) & ADXRS290_SYNC_MASK
88 #define ADXRS290_LPF_MASK 0x07
89 #define ADXRS290_LPF(x) (x) & ADXRS290_LPF_MASK
90 #define ADXRS290_HPF_MASK 0xF0
91 #define ADXRS290_HPF(x) ((x) & ADXRS290_HPF_MASK ) >> 4
92 
93 #define ADXRS290_READ_REG(reg) (ADXRS290_READ | (reg))
94 
95 #define ADXRS290_MAX_TRANSITION_TIME_MS 100
96 #define ADXRS290_CHANNEL_COUNT 3
97 #define ADXRS290_CHANNEL_MASK 0x07
98 /******************************************************************************/
99 /*************************** Types Declarations *******************************/
100 /******************************************************************************/
101 
111 };
112 
124 };
125 
139 };
140 
157 };
158 
174 };
175 
180 struct adxrs290_dev {
186  uint8_t ch_mask;
187 };
188 
189 /******************************************************************************/
190 /************************ Functions Declarations ******************************/
191 /******************************************************************************/
192 
193 /* Read device register. */
194 int32_t adxrs290_reg_read(struct adxrs290_dev *dev, uint8_t address,
195  uint8_t *data);
196 
197 /* Write device register. */
198 int32_t adxrs290_reg_write(struct adxrs290_dev *dev, uint8_t address,
199  uint8_t data);
200 
201 /* Set mode */
202 int32_t adxrs290_set_op_mode(struct adxrs290_dev *dev, enum adxrs290_mode mode);
203 
204 /* Get the low-pass filter pole location. */
205 int32_t adxrs290_get_lpf(struct adxrs290_dev *dev, enum adxrs290_lpf *lpf);
206 
207 /* Set the low-pass filter pole location. */
208 int32_t adxrs290_set_lpf(struct adxrs290_dev *dev, enum adxrs290_lpf lpf);
209 
210 /* Get the high-pass filter pole location. */
211 int32_t adxrs290_get_hpf(struct adxrs290_dev *dev, enum adxrs290_hpf *hpf);
212 
213 /* Set the high-pass filter pole location. */
214 int32_t adxrs290_set_hpf(struct adxrs290_dev *dev, enum adxrs290_hpf hpf);
215 
216 /* Read X or Y angular velocity data */
217 int32_t adxrs290_get_rate_data(struct adxrs290_dev *dev,
218  enum adxrs290_channel ch, int16_t *rate);
219 
220 /* Read Temperature data */
221 int32_t adxrs290_get_temp_data(struct adxrs290_dev *dev, int16_t *temp);
222 
223 /* Get the burst data */
224 int32_t adxrs290_get_burst_data(struct adxrs290_dev *dev, int16_t *burst_data,
225  uint8_t *ch_cnt);
226 
227 /* Set the ADXRS290 active channels */
228 int32_t adxrs290_set_active_channels(struct adxrs290_dev *dev, uint32_t mask);
229 
230 /* Get the data ready state */
231 int32_t adxrs290_get_data_ready(struct adxrs290_dev *dev, bool *rdy);
232 
233 /* Init. the comm. peripheral and checks if the ADXRS290 part is present. */
234 int32_t adxrs290_init(struct adxrs290_dev **device,
235  const struct adxrs290_init_param *init_param);
236 
237 /* Free the resources allocated by adxrs290_init(). */
238 int32_t adxrs290_remove(struct adxrs290_dev *dev);
239 
240 
241 #endif /* ADXRS290_H_ */
adxrs290_get_lpf
int32_t adxrs290_get_lpf(struct adxrs290_dev *dev, enum adxrs290_lpf *lpf)
Get the low-pass filter pole location.
Definition: adxrs290.c:125
adxrs290_init
int32_t adxrs290_init(struct adxrs290_dev **device, const struct adxrs290_init_param *init_param)
Definition: adxrs290.c:338
ADXRS290_REG_FILTER
#define ADXRS290_REG_FILTER
Definition: adxrs290.h:79
ADXRS290_REG_DATAX1
#define ADXRS290_REG_DATAX1
Definition: adxrs290.h:72
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:85
adxrs290_set_active_channels
int32_t adxrs290_set_active_channels(struct adxrs290_dev *dev, uint32_t mask)
Set the ADXRS290 active channels.
Definition: adxrs290.c:298
ADXRS290_LPF_160HZ
@ ADXRS290_LPF_160HZ
Definition: adxrs290.h:133
ADXRS290_TSM
#define ADXRS290_TSM
Definition: adxrs290.h:83
adxrs290_init_param::mode
enum adxrs290_mode mode
Definition: adxrs290.h:169
adxrs290_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: adxrs290.h:182
adxrs290_get_rate_data
int32_t adxrs290_get_rate_data(struct adxrs290_dev *dev, enum adxrs290_channel ch, int16_t *rate)
Get the Gyro data channels.
Definition: adxrs290.c:208
adxrs290_set_hpf
int32_t adxrs290_set_hpf(struct adxrs290_dev *dev, enum adxrs290_hpf hpf)
Set the low-pass filter pole location.
Definition: adxrs290.c:186
no_os_spi_write_and_read
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:82
ADXRS290_LPF_320HZ
@ ADXRS290_LPF_320HZ
Definition: adxrs290.h:132
no_os_spi.h
Header file of SPI Interface.
ADXRS290_HPF_0HZ087
@ ADXRS290_HPF_0HZ087
Definition: adxrs290.h:150
ADXRS290_HPF_0HZ022
@ ADXRS290_HPF_0HZ022
Definition: adxrs290.h:148
ADXRS290_HPF_0HZ700
@ ADXRS290_HPF_0HZ700
Definition: adxrs290.h:153
ADXRS290_HPF_2HZ800
@ ADXRS290_HPF_2HZ800
Definition: adxrs290.h:155
no_os_gpio_get_value
int32_t no_os_gpio_get_value(struct no_os_gpio_desc *desc, uint8_t *value)
Get the value of the specified GPIO.
Definition: no_os_gpio.c:177
ADXRS290_LPF_40HZ
@ ADXRS290_LPF_40HZ
Definition: adxrs290.h:136
NO_OS_IS_ERR_VALUE
#define NO_OS_IS_ERR_VALUE(x)
Definition: no_os_error.h:56
adxrs290_get_burst_data
int32_t adxrs290_get_burst_data(struct adxrs290_dev *dev, int16_t *burst_data, uint8_t *ch_cnt)
Get the burst data.
Definition: adxrs290.c:258
adxrs290_reg_read
int32_t adxrs290_reg_read(struct adxrs290_dev *dev, uint8_t address, uint8_t *data)
Read device register.
Definition: adxrs290.c:60
ADXRS290_LPF_480HZ
@ ADXRS290_LPF_480HZ
Definition: adxrs290.h:131
device
Definition: ad9361_util.h:75
ADXRS290_MODE_MEASUREMENT
@ ADXRS290_MODE_MEASUREMENT
Definition: adxrs290.h:110
NO_OS_GPIO_HIGH
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:123
adxrs290_dev::gpio_sync
struct no_os_gpio_desc * gpio_sync
Definition: adxrs290.h:184
no_os_gpio_direction_input
int32_t no_os_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition: no_os_gpio.c:108
ad7616_init_param::mode
enum ad7616_mode mode
Definition: ad7616.h:180
adxrs290_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: adxrs290.h:165
ADXRS290_HPF_ALL_PASS
@ ADXRS290_HPF_ALL_PASS
Definition: adxrs290.h:146
adxrs290_set_hpf
int32_t adxrs290_set_hpf(struct adxrs290_dev *dev, enum adxrs290_hpf hpf)
Set the low-pass filter pole location.
Definition: adxrs290.c:186
ADXRS290_HPF
#define ADXRS290_HPF(x)
Definition: adxrs290.h:91
ADXRS290_CHANNEL_Y
@ ADXRS290_CHANNEL_Y
Definition: adxrs290.h:121
adxrs290_set_lpf
int32_t adxrs290_set_lpf(struct adxrs290_dev *dev, enum adxrs290_lpf lpf)
Set the low-pass filter pole location.
Definition: adxrs290.c:145
ADXRS290_HPF_1HZ400
@ ADXRS290_HPF_1HZ400
Definition: adxrs290.h:154
adxrs290_get_temp_data
int32_t adxrs290_get_temp_data(struct adxrs290_dev *dev, int16_t *temp)
Get the temperature data.
Definition: adxrs290.c:232
ADXRS290_LPF_80HZ
@ ADXRS290_LPF_80HZ
Definition: adxrs290.h:134
ADXRS290_HPF_0HZ175
@ ADXRS290_HPF_0HZ175
Definition: adxrs290.h:151
ADXRS290_HPF_11HZ30
@ ADXRS290_HPF_11HZ30
Definition: adxrs290.h:156
ADXRS290_CHANNEL_COUNT
#define ADXRS290_CHANNEL_COUNT
Definition: adxrs290.h:96
no_os_error.h
Error codes definition.
ADXRS290_LPF_20HZ
@ ADXRS290_LPF_20HZ
Definition: adxrs290.h:138
ADXRS290_LPF_56HZ6
@ ADXRS290_LPF_56HZ6
Definition: adxrs290.h:135
ADXRS290_CHANNEL_X
@ ADXRS290_CHANNEL_X
Definition: adxrs290.h:119
ADXRS290_HPF_0HZ011
@ ADXRS290_HPF_0HZ011
Definition: adxrs290.h:147
adxrs290_get_burst_data
int32_t adxrs290_get_burst_data(struct adxrs290_dev *dev, int16_t *burst_data, uint8_t *ch_cnt)
Get the burst data.
Definition: adxrs290.c:258
adxrs290_set_active_channels
int32_t adxrs290_set_active_channels(struct adxrs290_dev *dev, uint32_t mask)
Set the ADXRS290 active channels.
Definition: adxrs290.c:298
adxrs290_get_data_ready
int32_t adxrs290_get_data_ready(struct adxrs290_dev *dev, bool *rdy)
Get the state of data ready.
Definition: adxrs290.c:311
adxrs290.h
Implementation of ADXRS290 Driver.
ADXRS290_DEV_ID
#define ADXRS290_DEV_ID
Definition: adxrs290.h:60
adxrs290_remove
int32_t adxrs290_remove(struct adxrs290_dev *dev)
Free memory allocated by adxrs290_setup().
Definition: adxrs290.c:417
adxrs290_get_temp_data
int32_t adxrs290_get_temp_data(struct adxrs290_dev *dev, int16_t *temp)
Get the temperature data.
Definition: adxrs290.c:232
adxrs290_get_rate_data
int32_t adxrs290_get_rate_data(struct adxrs290_dev *dev, enum adxrs290_channel ch, int16_t *rate)
Get the Gyro data channels.
Definition: adxrs290.c:208
ADXRS290_REG_DATA_READY
#define ADXRS290_REG_DATA_READY
Definition: adxrs290.h:80
ADXRS290_REG_POWER_CTL
#define ADXRS290_REG_POWER_CTL
Definition: adxrs290.h:78
adxrs290_init_param
Device driver initialization structure.
Definition: adxrs290.h:163
adxrs290_remove
int32_t adxrs290_remove(struct adxrs290_dev *dev)
Free memory allocated by adxrs290_setup().
Definition: adxrs290.c:417
no_os_gpio_remove
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:95
ADXRS290_HPF_0HZ350
@ ADXRS290_HPF_0HZ350
Definition: adxrs290.h:152
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:132
adxrs290_set_lpf
int32_t adxrs290_set_lpf(struct adxrs290_dev *dev, enum adxrs290_lpf lpf)
Set the low-pass filter pole location.
Definition: adxrs290.c:145
adxrs290_dev
Device driver handler.
Definition: adxrs290.h:180
ADXRS290_LPF
#define ADXRS290_LPF(x)
Definition: adxrs290.h:89
ADXRS290_CHANNEL_TEMP
@ ADXRS290_CHANNEL_TEMP
Definition: adxrs290.h:123
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:102
ADXRS290_CHANNEL_MASK
#define ADXRS290_CHANNEL_MASK
Definition: adxrs290.h:97
adxrs290_get_data_ready
int32_t adxrs290_get_data_ready(struct adxrs290_dev *dev, bool *rdy)
Get the state of data ready.
Definition: adxrs290.c:311
adxrs290_reg_read
int32_t adxrs290_reg_read(struct adxrs290_dev *dev, uint8_t address, uint8_t *data)
Read device register.
Definition: adxrs290.c:60
adxrs290_init
int32_t adxrs290_init(struct adxrs290_dev **device, const struct adxrs290_init_param *init_param)
Definition: adxrs290.c:338
ADXRS290_LPF_28HZ3
@ ADXRS290_LPF_28HZ3
Definition: adxrs290.h:137
ADXRS290_REG_DEV_ID
#define ADXRS290_REG_DEV_ID
Definition: adxrs290.h:65
ADXRS290_MODE_STANDBY
@ ADXRS290_MODE_STANDBY
Definition: adxrs290.h:108
adxrs290_dev::ch_mask
uint8_t ch_mask
Definition: adxrs290.h:186
adxrs290_reg_write
int32_t adxrs290_reg_write(struct adxrs290_dev *dev, uint8_t address, uint8_t data)
Write device register.
Definition: adxrs290.c:82
adxrs290_set_op_mode
int32_t adxrs290_set_op_mode(struct adxrs290_dev *dev, enum adxrs290_mode mode)
Set device operation mode.
Definition: adxrs290.c:96
adxrs290_reg_write
int32_t adxrs290_reg_write(struct adxrs290_dev *dev, uint8_t address, uint8_t data)
Write device register.
Definition: adxrs290.c:82
ADXRS290_REG_DATAX0
#define ADXRS290_REG_DATAX0
Definition: adxrs290.h:71
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:96
adxrs290_set_op_mode
int32_t adxrs290_set_op_mode(struct adxrs290_dev *dev, enum adxrs290_mode mode)
Set device operation mode.
Definition: adxrs290.c:96
adxrs290_get_hpf
int32_t adxrs290_get_hpf(struct adxrs290_dev *dev, enum adxrs290_hpf *hpf)
Get the high-pass filter pole location.
Definition: adxrs290.c:166
no_os_spi_remove
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:70
ADXRS290_DATA_RDY_OUT
#define ADXRS290_DATA_RDY_OUT
Definition: adxrs290.h:85
no_os_gpio.h
Header file of GPIO Interface.
ADXRS290_REG_TEMP1
#define ADXRS290_REG_TEMP1
Definition: adxrs290.h:76
ADXRS290_LPF_MASK
#define ADXRS290_LPF_MASK
Definition: adxrs290.h:88
adxrs290_get_lpf
int32_t adxrs290_get_lpf(struct adxrs290_dev *dev, enum adxrs290_lpf *lpf)
Get the low-pass filter pole location.
Definition: adxrs290.c:125
adxrs290_lpf
adxrs290_lpf
Low-Pass filter pole location.
Definition: adxrs290.h:130
no_os_spi_init
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:51
adxrs290_hpf
adxrs290_hpf
High-Pass filter pole location.
Definition: adxrs290.h:145
no_os_util.h
Implementation of utility functions.
adxrs290_init_param::hpf
enum adxrs290_hpf hpf
Definition: adxrs290.h:173
adxrs290_channel
adxrs290_channel
Channel of teh adxrs290 data rate.
Definition: adxrs290.h:117
adxrs290_get_hpf
int32_t adxrs290_get_hpf(struct adxrs290_dev *dev, enum adxrs290_hpf *hpf)
Get the high-pass filter pole location.
Definition: adxrs290.c:166
ADXRS290_HPF_MASK
#define ADXRS290_HPF_MASK
Definition: adxrs290.h:90
ADXRS290_REG_TEMP0
#define ADXRS290_REG_TEMP0
Definition: adxrs290.h:75
adxrs290_init_param::gpio_sync
struct no_os_gpio_init_param * gpio_sync
Definition: adxrs290.h:167
adxrs290_init_param::lpf
enum adxrs290_lpf lpf
Definition: adxrs290.h:171
ADXRS290_MEASUREMENT
#define ADXRS290_MEASUREMENT
Definition: adxrs290.h:84
adxrs290_mode
adxrs290_mode
Mode of the adxrs290.
Definition: adxrs290.h:106
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:112
ADXRS290_HPF_0HZ044
@ ADXRS290_HPF_0HZ044
Definition: adxrs290.h:149
no_os_gpio_get_optional
int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Get the value of an optional GPIO.
Definition: no_os_gpio.c:75