MBot Software Library  v1.0
An API documentation to mbot_firmware repository
bhy_uc_driver_types.h
Go to the documentation of this file.
1 
51 #ifndef BHY_UC_DRIVER_TYPES_H_
52 #define BHY_UC_DRIVER_TYPES_H_
53 
55 
56 /****************************************************************************/
57 /* MACRO */
58 /****************************************************************************/
59 /* system page */
60 #define BHY_PAGE_SYSTEM 1
61 #define BHY_PARAM_SYSTEM_META_EVENT_CTRL 1
62 #define BHY_PARAM_SYSTEM_FIFO_CTRL 2
63 #define BHY_PARAM_SYSTEM_STAUS_BANK_0 3
64 #define BHY_PARAM_SYSTEM_STAUS_BANK_1 4
65 #define BHY_PARAM_SYSTEM_STAUS_BANK_2 5
66 #define BHY_PARAM_SYSTEM_STAUS_BANK_3 6
67 #define BHY_PARAM_SYSTEM_CUSTOM_VERSION 24
68 #define BHY_PARAM_SYSTEM_WAKE_UP_META_EVENT_CTRL 29
69 #define BHY_PARAM_SYSTEM_HOST_IRQ_TIMESTAMP 30
70 #define BHY_PARAM_SYSTEM_PHYSICAL_SENSOR_STATUS 31
71 #define BHY_PARAM_SYSTEM_PHYSICAL_SENSOR_PRESENT 32
72 #define BHY_PARAM_SYSTEM_PHYSICAL_SENSOR_DETAIL_0 32
73 #define BHY_PARAM_SYSTEM_PHYSICAL_SENSOR_DETAIL_ACC 33
74 
75 #define VS_NON_WAKEUP 0
76 #define VS_WAKEUP 32
77 #define VS_FLUSH_NONE 0x00
78 #define VS_FLUSH_ALL 0xFF
79 #define VS_FLUSH_SINGLE 0x01
80 
81 #define META_EVENT_1_INT_ENABLE_BIT (1<<0)
82 #define META_EVENT_1_ENABLE_BIT (1<<1)
83 
84 /****************************************************************************/
85 /* ENUM */
86 /****************************************************************************/
87 /* follows section 9.4 table 14 of the BHI160 datasheet */
88 typedef enum {
89  VS_TYPE_ACCELEROMETER = VS_ID_ACCELEROMETER,
90  VS_TYPE_GEOMAGNETIC_FIELD = VS_ID_MAGNETOMETER,
91  VS_TYPE_ORIENTATION = VS_ID_ORIENTATION,
92  VS_TYPE_GYROSCOPE = VS_ID_GYROSCOPE,
93  VS_TYPE_LIGHT = VS_ID_LIGHT,
94  VS_TYPE_PRESSURE = VS_ID_BAROMETER,
95  VS_TYPE_TEMPERATURE = VS_ID_TEMPERATURE,
96  VS_TYPE_PROXIMITY = VS_ID_PROXIMITY,
97  VS_TYPE_GRAVITY = VS_ID_GRAVITY,
98  VS_TYPE_LINEAR_ACCELERATION = VS_ID_LINEAR_ACCELERATION,
99  VS_TYPE_ROTATION_VECTOR = VS_ID_ROTATION_VECTOR,
100  VS_TYPE_RELATIVE_HUMIDITY = VS_ID_HUMIDITY,
101  VS_TYPE_AMBIENT_TEMPERATURE = VS_ID_AMBIENT_TEMPERATURE,
102  VS_TYPE_MAGNETIC_FIELD_UNCALIBRATED = VS_ID_UNCALIBRATED_MAGNETOMETER,
103  VS_TYPE_GAME_ROTATION_VECTOR = VS_ID_GAME_ROTATION_VECTOR,
104  VS_TYPE_GYROSCOPE_UNCALIBRATED = VS_ID_UNCALIBRATED_GYROSCOPE,
105  VS_TYPE_SIGNIFICANT_MOTION = VS_ID_SIGNIFICANT_MOTION,
106  VS_TYPE_STEP_DETECTOR = VS_ID_STEP_DETECTOR,
107  VS_TYPE_STEP_COUNTER = VS_ID_STEP_COUNTER,
108  VS_TYPE_GEOMAGNETIC_ROTATION_VECTOR = VS_ID_GEOMAGNETIC_ROTATION_VECTOR,
109  VS_TYPE_HEART_RATE = VS_ID_HEART_RATE,
110  VS_TYPE_TILT = VS_ID_TILT_DETECTOR,
111  VS_TYPE_WAKEUP = VS_ID_WAKE_GESTURE,
112  VS_TYPE_GLANCE = VS_ID_GLANCE_GESTURE,
113  VS_TYPE_PICKUP = VS_ID_PICKUP_GESTURE,
114  VS_TYPE_CUS1 = VS_ID_CUS1,
115  VS_TYPE_CUS2 = VS_ID_CUS2,
116  VS_TYPE_CUS3 = VS_ID_CUS3,
117  VS_TYPE_CUS4 = VS_ID_CUS4,
118  VS_TYPE_CUS5 = VS_ID_CUS5,
119  VS_TYPE_ACTIVITY_RECOGNITION = VS_ID_ACTIVITY
120 } bhy_virtual_sensor_t;
121 
122 typedef enum {
123  BHY_META_EVENT_TYPE_NOT_USED = 0,
124  BHY_META_EVENT_TYPE_FLUSH_COMPLETE = 1,
125  BHY_META_EVENT_TYPE_SAMPLE_RATE_CHANGED = 2,
126  BHY_META_EVENT_TYPE_POWER_MODE_CHANGED = 3,
127  BHY_META_EVENT_TYPE_ERROR = 4,
128  BHY_META_EVENT_TYPE_ALGORITHM = 5,
129  /* IDs 6-10 are reserved */
130  BHY_META_EVENT_TYPE_SENSOR_ERROR = 11,
131  BHY_META_EVENT_TYPE_FIFO_OVERFLOW = 12,
132  BHY_META_EVENT_TYPE_DYNAMIC_RANGE_CHANGED = 13,
133  BHY_META_EVENT_TYPE_FIFO_WATERMARK = 14,
134  BHY_META_EVENT_TYPE_SELF_TEST_RESULTS = 15,
135  BHY_META_EVENT_TYPE_INITIALIZED = 16,
136 
137 } bhy_meta_event_type_t;
138 
139 typedef enum {
140  /* group 1 only read for host -s */
141  BHY_GP_REG_20 = 0x4B,
142  BHY_GP_REG_21 = 0x4C,
143  BHY_GP_REG_22 = 0x4D,
144  BHY_GP_REG_23 = 0x4E,
145  BHY_GP_REG_24 = 0x4F,
146  /* group 1 only read for host -e */
147  /* group 2 read & write for host -s */
148  BHY_GP_REG_31 = 0x56,
149  BHY_GP_REG_32 = 0x57,
150  BHY_GP_REG_33 = 0x58,
151  BHY_GP_REG_34 = 0x59,
152  BHY_GP_REG_35 = 0x5A,
153  BHY_GP_REG_36 = 0x5B,
154  /* group 2 read & write for host -e */
155  /* group 3 read & write for host -s */
156  BHY_GP_REG_46 = 0x65,
157  BHY_GP_REG_47 = 0x66,
158  BHY_GP_REG_48 = 0x67,
159  BHY_GP_REG_49 = 0x68,
160  BHY_GP_REG_50 = 0x69,
161  BHY_GP_REG_51 = 0x6A,
162  BHY_GP_REG_52 = 0x6B,
163  /* group 3 read & write for host -e */
164 } bhy_gp_register_type_t;
165 
166 /* follows section 15 of the BHI160 datasheet the order of this enumeration */
167 /* is important, do not change it */
168 typedef enum {
169  BHY_DATA_TYPE_PADDING = 0,
170  BHY_DATA_TYPE_QUATERNION = 1,
171  BHY_DATA_TYPE_VECTOR = 2,
172  BHY_DATA_TYPE_SCALAR_U8 = 3,
173  BHY_DATA_TYPE_SCALAR_U16 = 4,
174  BHY_DATA_TYPE_SCALAR_S16 = 5,
175  BHY_DATA_TYPE_SCALAR_U24 = 6,
176  BHY_DATA_TYPE_SENSOR_EVENT = 7,
177  BHY_DATA_TYPE_UNCALIB_VECTOR = 8,
178  BHY_DATA_TYPE_META_EVENT = 9,
179  BHY_DATA_TYPE_BSX = 10,
180  BHY_DATA_TYPE_DEBUG = 11,
181  BHY_DATA_TYPE_CUS1 = 12,
182  BHY_DATA_TYPE_CUS2 = 13,
183  BHY_DATA_TYPE_CUS3 = 14,
184  BHY_DATA_TYPE_CUS4 = 15,
185  BHY_DATA_TYPE_CUS5 = 16,
186 } bhy_data_type_t;
187 
188 typedef enum {
189  META_EVENT_IN_NON_WAKEUP_FIFO = 1,
190  META_EVENT_IN_WAKEUP_FIFO = 29,
191 } bhy_meta_event_fifo_type_t;
192 
193 typedef enum
194 {
195  PHYSICAL_SENSOR_INDEX_ACC = 0,
196  PHYSICAL_SENSOR_INDEX_MAG,
197  PHYSICAL_SENSOR_INDEX_GYRO,
198  PHYSICAL_SENSOR_COUNT
199 } bhy_physical_sensor_index_type_t;
200 
201 /****************************************************************************/
202 /* STRUCTRE DEFINITION */
203 /****************************************************************************/
204 
205 /* definition of structures of all the data types */
206 typedef struct {
207  uint8_t sensor_id;
209 
210 typedef struct {
211  uint8_t sensor_id;
212  int16_t x;
213  int16_t y;
214  int16_t z;
215  int16_t w;
216  int16_t estimated_accuracy;
218 
219 typedef struct {
220  uint8_t sensor_id;
221  int16_t x;
222  int16_t y;
223  int16_t z;
224  uint8_t status;
226 
227 typedef struct {
228  uint8_t sensor_id;
229  uint8_t data;
231 
232 typedef struct {
233  uint8_t sensor_id;
234  uint16_t data;
236 
237 typedef struct {
238  uint8_t sensor_id;
239  int16_t data;
241 
242 typedef struct {
243  uint8_t sensor_id;
244  uint32_t data;
246 
247 typedef struct {
248  uint8_t sensor_id;
250 
251 typedef struct {
252  uint8_t sensor_id;
253  int16_t x;
254  int16_t y;
255  int16_t z;
256  int16_t x_bias;
257  int16_t y_bias;
258  int16_t z_bias;
259  uint8_t status;
261 
262 typedef struct {
263  uint8_t meta_event_id;
264  bhy_meta_event_type_t event_number;
265  uint8_t sensor_type;
266  uint8_t event_specific;
268 
269 typedef struct {
270  uint8_t sensor_id;
271  int32_t x;
272  int32_t y;
273  int32_t z;
274  uint32_t timestamp;
276 
277 typedef struct {
278  uint8_t sensor_id;
279  uint8_t data[13];
281 
282 typedef struct {
283  uint8_t sensor_id;
284  int16_t deltaX;
285  int16_t deltaY;
286  int16_t deltaZ;
287  int16_t confidencelevel;
288  uint16_t direction;
289  uint16_t stepCount;
291 
292 typedef struct {
293  uint8_t sensor_id;
294  uint8_t data[16];
296 
297 
298 /* definition of a generic structure that can contain any data type it */
299 /* occupies in RAM the size of the largest data structure, which is 18 bytes*/
300 /* as of 08/04/2015 */
301 typedef union {
302  bhy_data_padding_t data_padding;
303  bhy_data_quaternion_t data_quaternion;
304  bhy_data_vector_t data_vector;
305  bhy_data_scalar_u8_t data_scalar_u8;
306  bhy_data_scalar_u16_t data_scalar_u16;
307  bhy_data_scalar_s16_t data_scalar_s16;
308  bhy_data_scalar_u24_t data_scalar_u24;
309  bhy_data_sensor_event_t data_sensor_event;
310  bhy_data_uncalib_vector_t data_uncalib_vector;
311  bhy_data_meta_event_t data_meta_event;
312  bhy_data_bsx_t data_bsx;
313  bhy_data_debug_t data_debug;
314  bhy_data_custom_t data_custom;
315  bhy_data_pdr_t data_pdr;
317 
318 #endif /* BHY_UC_DRIVER_TYPES_H_ */
header file of bhy_uc_driver.c
Definition: bhy_uc_driver_types.h:269
Definition: bhy_uc_driver_types.h:292
Definition: bhy_uc_driver_types.h:277
Definition: bhy_uc_driver_types.h:262
Definition: bhy_uc_driver_types.h:206
Definition: bhy_uc_driver_types.h:282
Definition: bhy_uc_driver_types.h:210
Definition: bhy_uc_driver_types.h:237
Definition: bhy_uc_driver_types.h:232
Definition: bhy_uc_driver_types.h:242
Definition: bhy_uc_driver_types.h:227
Definition: bhy_uc_driver_types.h:247
Definition: bhy_uc_driver_types.h:251
Definition: bhy_uc_driver_types.h:219
Definition: bhy_uc_driver_types.h:301