-
Notifications
You must be signed in to change notification settings - Fork 12
/
bhy2.h
664 lines (593 loc) · 25.9 KB
/
bhy2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
/**
* Copyright (c) 2023 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bhy2.h
* @date 2023-03-24
* @version v1.6.0
*
*/
#ifndef __BHY2_H__
#define __BHY2_H__
/* Start of CPP Guard */
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus */
#include "bhy2_defs.h"
/**
* @brief Function to link the callback interfaces
* @param[in] intf : Physical communication interface
* @param[in] read : Read function pointer
* @param[in] write : Write function pointer
* @param[in] delay_us : Microsecond delay function pointer
* @param[in] read_write_len : Maximum read/write lengths supported
* @param[in] intf_ptr : Reference to the interface. Can be NULL
* @param[out] dev : Device reference
* @return API error codes
*/
int8_t bhy2_init(enum bhy2_intf intf,
bhy2_read_fptr_t read,
bhy2_write_fptr_t write,
bhy2_delay_us_fptr_t delay_us,
uint32_t read_write_len,
void *intf_ptr,
struct bhy2_dev *dev);
/**
* @brief Function to get data from registers
* @param[in] reg_addr : Register address to be read from
* @param[out] reg_data : Reference to the data buffer
* @param[in] length : Length of the data buffer
* @param[in] dev : Device reference
* @return API Error codes
*/
int8_t bhy2_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint16_t length, struct bhy2_dev *dev);
/**
* @brief Function to set data to registers
* @param[in] reg_addr : Register address to write to
* @param[in] reg_data : Reference to the data buffer
* @param[in] length : Length of the data buffer
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_regs(uint8_t reg_addr, const uint8_t *reg_data, uint16_t length, struct bhy2_dev *dev);
/**
* @brief Function to get the product ID
* @param[out] product_id : Reference to data buffer to store the product ID
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_product_id(uint8_t *product_id, struct bhy2_dev *dev);
/**
* @brief Function to get the chip ID
* @param[out] chip_id : Reference to data buffer to store the chip ID
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_chip_id(uint8_t *chip_id, struct bhy2_dev *dev);
/**
* @brief Function to get the revision ID
* @param[out] revision_id : Reference to data buffer to store the revision ID
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_revision_id(uint8_t *revision_id, struct bhy2_dev *dev);
/**
* @brief Function to get the ROM version
* @param[out] rom_version : Reference to the data buffer to store the ROM version
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_rom_version(uint16_t *rom_version, struct bhy2_dev *dev);
/**
* @brief Function to get the kernel version
* @param[out] kernel_version : Reference to the data buffer to store the kernel version
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_kernel_version(uint16_t *kernel_version, struct bhy2_dev *dev);
/**
* @brief Function to get the user version
* @param[out] user_version : Reference to the data buffer to store the user version
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_user_version(uint16_t *user_version, struct bhy2_dev *dev);
/**
* @brief Function to get the boot status
* @param[out] boot_status : Reference to the data buffer to store the boot status
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_boot_status(uint8_t *boot_status, struct bhy2_dev *dev);
/**
* @brief Function to get the host status
* @param[out] host_status : Reference to the data buffer to store the host status
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_host_status(uint8_t *host_status, struct bhy2_dev *dev);
/**
* @brief Function to get the feature status
* @param[out] feat_status : Reference to the data buffer to store the feature status
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_feature_status(uint8_t *feat_status, struct bhy2_dev *dev);
/**
* @brief Function to get the virtual sensor list and store in the device structure
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_virt_sensor_list(struct bhy2_dev *dev);
/**
* @brief Function to get the virtual sensor configuration
* @param[in] sensor_id : Sensor ID of the virtual sensor
* @param[out] virt_sensor_conf : Reference to the data buffer to store the virtual sensor configuration
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_virt_sensor_cfg(uint8_t sensor_id, struct bhy2_virt_sensor_conf *virt_sensor_conf,
struct bhy2_dev *dev);
/**
* @brief Function to set the sample rate and latency of the virtual sensor
* @param[in] sensor_id : Sensor ID of the virtual sensor
* @param[in] sample_rate : Sample rate in Hz
* @param[in] latency : Report latency in milliseconds
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_virt_sensor_cfg(uint8_t sensor_id, bhy2_float sample_rate, uint32_t latency, struct bhy2_dev *dev);
/**
* @brief Function set the range of the virtual sensor
* @param[in] sensor_id : Sensor ID of the virtual sensor
* @param[in] range : Range of the virtual sensor
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_virt_sensor_range(uint8_t sensor_id, uint16_t range, struct bhy2_dev *dev);
/**
* @brief Function to get and process the FIFOs
* @param[in] work_buffer : Reference to the data buffer where the FIFO data is copied to before parsing
* @param[in] buffer_size : Size of the data buffer
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_and_process_fifo(uint8_t *work_buffer, uint32_t buffer_size, struct bhy2_dev *dev);
/**
* @brief Function get the FIFO control register
* @param[out] fifo_ctrl : Reference to the data buffer to store the FIFO control
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_fifo_ctrl(uint32_t *fifo_ctrl, struct bhy2_dev *dev);
/**
* @brief Function to set the Wake up FIFO watermark
* @param[in] watermark : Size of the watermark
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_fifo_wmark_wkup(uint32_t watermark, struct bhy2_dev *dev);
/**
* @brief Function to get the Wake up FIFO watermark
* @param[out] watermark : Reference to the data buffer to store the FIFO watermark size
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_fifo_wmark_wkup(uint32_t *watermark, struct bhy2_dev *dev);
/**
* @brief Function to set the Non wake up FIFO watermark
* @param[in] watermark : Size of the watermark
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_fifo_wmark_nonwkup(uint32_t watermark, struct bhy2_dev *dev);
/**
* @brief Function to get the Non wake up FIFO watermark
* @param[out] watermark : Reference to the data buffer to store the FIFO watermark size
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_fifo_wmark_nonwkup(uint32_t *watermark, struct bhy2_dev *dev);
/**
* @brief Function to flush data of a virtual sensor from the FIFOs
* @param[in] sensor_id : Sensor ID of the virtual sensor
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_flush_fifo(uint8_t sensor_id, struct bhy2_dev *dev);
/**
* @brief Function to set the FIFO format
* @param[in] param : FIFO format settings
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_fifo_format_ctrl(uint8_t param, struct bhy2_dev *dev);
/**
* @brief Function to upload firmware to RAM
* @param[in] firmware : Reference to the data buffer containing the firmware
* @param[in] length : Size of the firmware
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_upload_firmware_to_ram(const uint8_t *firmware, uint32_t length, struct bhy2_dev *dev);
/**
* @brief Function to upload part of the firmware to RAM
* @param[in] firmware : Reference to the data buffer containing the current firmware section
* @param[in] total_size : Total size of the firmware
* @param[in] cur_pos : Current position of the part being loaded
* @param[in] packet_len : Size of the part being loaded
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_upload_firmware_to_ram_partly(const uint8_t *firmware,
uint32_t total_size,
uint32_t cur_pos,
uint32_t packet_len,
struct bhy2_dev *dev);
/**
* @brief Function to boot firmware from RAM
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_boot_from_ram(struct bhy2_dev *dev);
/**
* @brief Function to erase the flash
* @param[in] start_addr : Start address
* @param[in] end_addr : End address
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_erase_flash(uint32_t start_address, uint32_t end_addr, struct bhy2_dev *dev);
/**
* @brief Function to upload firmware to Flash
* @param[in] firmware : Reference to the data buffer containing the firmware
* @param[in] length : Size of the firwmare
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_upload_firmware_to_flash(const uint8_t *firmware, uint32_t length, struct bhy2_dev *dev);
/**
* @brief Function to upload part of the firmware to Flash
* @param[in] firmware : Reference to the data buffer containing the current firmware section
* @param[in] cur_pos : Current position of the part being loaded
* @param[in] packet_len : Size of the part being loaded
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_upload_firmware_to_flash_partly(const uint8_t *firmware,
uint32_t cur_pos,
uint32_t packet_len,
struct bhy2_dev *dev);
/**
* @brief Function to boot from Flash
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_boot_from_flash(struct bhy2_dev *dev);
/**
* @brief Function to set the host interrupt control register
* @param[in] hintr_ctrl : Host interrupt control configuration
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_host_interrupt_ctrl(uint8_t hintr_ctrl, struct bhy2_dev *dev);
/**
* @brief Function to get the host interrupt control register
* @param[out] hintr_ctrl : Reference to the data buffer to store the configuration
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_host_interrupt_ctrl(uint8_t *hintr_ctrl, struct bhy2_dev *dev);
/**
* @brief Function to get the interrupt status register
* @param[out] int_status : Reference to the data buffer to store the interrupt status
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_interrupt_status(uint8_t *int_status, struct bhy2_dev *dev);
/**
* @brief Function to set the host interface control register
* @param[in] hintf_ctrl : Host interface control configuration
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_host_intf_ctrl(uint8_t hintf_ctrl, struct bhy2_dev *dev);
/**
* @brief Function to get the host interface control register
* @param[out] hintf_ctrl : Reference to the data buffer to store the configuration
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_host_intf_ctrl(uint8_t *hintf_ctrl, struct bhy2_dev *dev);
/**
* @brief Function to trigger a timestamp event
* @param[in] ts_ev_req : Pass a non-zero value to trigger a timestamp event
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_timestamp_event_req(uint8_t ts_ev_req, struct bhy2_dev *dev);
/**
* @brief Function to get the timestamp of the sensor in nanoseconds
* @param[out] timestamp_ns : Reference to the data buffer to store the timestamp in nanoseconds
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_hw_timestamp_ns(uint64_t *timestamp_ns, struct bhy2_dev *dev);
/**
* @brief Function to get the host control register
* @param[in] host_ctrl : Host control configuration
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_host_ctrl(uint8_t host_ctrl, struct bhy2_dev *dev);
/**
* @brief Function to get the host control register
* @param[out] host_ctrl : Reference to the data buffer to store the host control configuration
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_host_ctrl(uint8_t *host_ctrl, struct bhy2_dev *dev);
/**
* @brief Function to trigger a soft reset
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_soft_reset(struct bhy2_dev *dev);
/**
* @brief Function to perform a self test of a virtual sensor
* @param[in] phys_sensor_id : Physical sensor ID of the virtual sensor
* @param[out] self_test_resp : Reference to the data buffer to store the self test response from the virtual sensor
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_perform_self_test(uint8_t phys_sensor_id, struct bhy2_self_test_resp *self_test_resp, struct bhy2_dev *dev);
/**
* @brief Function to perform a fast offset compensation of a virtual sensor
* @param[in] phys_sensor_id : Physical Sensor ID of the virtual sensor
* @param[out] self_test_resp : Reference to the data buffer to store the FOC response from the virtual sensor
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_perform_foc(uint8_t phys_sensor_id, struct bhy2_foc_resp *foc_resp, struct bhy2_dev *dev);
/**
* @brief Function to set the orientation matrix of a physical sensor
* @param[in] phys_sensor_id : Sensor ID of the virtual sensor
* @param[in] orient_matrix : Orientation matrix
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_orientation_matrix(uint8_t phys_sensor_id, struct bhy2_orient_matrix orient_matrix,
struct bhy2_dev *dev);
/**
* @brief Function to get the physical sensor information
* @param[in] phys_sensor_id : Sensor ID of the physical sensor
* @param[out] phy_sen_info : Reference to the data buffer to the store the physical sensor information
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_phys_sensor_info(uint8_t phys_sensor_id,
struct bhy2_phys_sensor_info *phy_sen_info,
struct bhy2_dev *dev);
/**
* @brief Function to get the orientation matrix of a physical sensor
* @param[in] phys_sensor_id : Sensor ID of the virtual sensor
* @param[out] orient_matrix : Reference to the data buffer to the store the orientation matrix
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_orientation_matrix(uint8_t phys_sensor_id,
struct bhy2_orient_matrix *orient_matrix,
struct bhy2_dev *dev);
/**
* @brief Function to set the Soft Iron Correction matrix
* @param[in] sic_matrix : Reference to the data buffer storing the Soft Iron Correction matrix
* @param[in] matrix_len : Length of the matrix
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_sic_matrix(const uint8_t *sic_matrix, uint16_t matrix_len, struct bhy2_dev *dev);
/**
* @brief Function to get the Soft Iron Correction matrix
* @param[out] sic_matrix : Reference to the data buffer to store the Soft Iron Correction matrix
* @param[in] matrix_len : Length of data buffer
* @param[out] actual_len : Actual length of the Soft Iron Correction matrix
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_sic_matrix(uint8_t *sic_matrix, uint16_t matrix_len, uint32_t *actual_len, struct bhy2_dev *dev);
/**
* @brief Function to get the calibration profile of a BSX virtual sensor
* @param[in] phys_sensor_id: Physical Sensor ID of the virtual sensor
* @param[out] calib_prof : Reference to the data buffer to store the calibration profile
* @param[in] prof_len : Length of the data buffer
* @param[out] actual_len : Actual length of the calibration profile
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_calibration_profile(uint8_t phys_sensor_id,
uint8_t *calib_prof,
uint16_t prof_len,
uint32_t *actual_len,
struct bhy2_dev *dev);
/**
* @brief Function to set the calibration profile of a BSX virtual sensor
* @param[in] phys_sensor_id: Physical Sensor ID of the virtual sensor
* @param[in] calib_prof : Reference to the data buffer storing the calibration profile
* @param[in] prof_len : Length of the profil
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_calibration_profile(uint8_t phys_sensor_idv,
const uint8_t *calib_prof,
uint16_t prof_len,
struct bhy2_dev *dev);
/**
* @brief Function to get the post mortem data
* @param[out] post_mortem : Reference to the data buffer to store the post mortem data
* @param[in] buffer_len : Length of the data buffer
* @param[out] actual_len : Actual length of the post mortem data
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_post_mortem_data(uint8_t *post_mortem, uint32_t buffer_len, uint32_t *actual_len, struct bhy2_dev *dev);
/**
* @brief Function to link a callback and relevant reference when the sensor event is available in the FIFO
* @param[in] sensor_id : Sensor ID of the virtual sensor
* @param[in] callback : Reference of the callback function
* @param[in] callback_ref : Reference needed inside the callback function. Can be NULL
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_register_fifo_parse_callback(uint8_t sensor_id,
bhy2_fifo_parse_callback_t callback,
void *callback_ref,
struct bhy2_dev *dev);
/**
* @brief Function to unlink a callback and relevant reference
* @param[in] sensor_id : Sensor ID of the virtual sensor
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_deregister_fifo_parse_callback(uint8_t sensor_id, struct bhy2_dev *dev);
/**
* @brief Function to update the callback table's information
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_update_virtual_sensor_list(struct bhy2_dev *dev);
/**
* @brief Function to get information of a virtual sensor
* @param[in] sensor_id : Sensor ID of the virtual sensor
* @param[out] info : Reference to the data buffer to store the virtual sensor information
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_sensor_info(uint8_t sensor_id, struct bhy2_sensor_info *info, struct bhy2_dev *dev);
/**
* @brief Function to set a parameter
* @param[in] param : Parameter ID
* @param[in] payload : Reference to the data buffer storing the parameter's payload
* @param[in] length : Length of the payload
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_parameter(uint16_t param, const uint8_t *payload, uint32_t length, struct bhy2_dev *dev);
/**
* @brief Function to get a parameter
* @param[in] param : Parameter ID
* @param[out] payload : Reference to the data buffer to store the parameter's payload
* @param[in] payload_len : Length of the data buffer
* @param[out] actual_len : Actual length of the payload
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_parameter(uint16_t param,
uint8_t *payload,
uint32_t payload_len,
uint32_t *actual_len,
struct bhy2_dev *dev);
/**
* @brief Function to get the error value register
* @param[out] error_value : Reference to the data buffer to store the error value
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_error_value(uint8_t *error_value, struct bhy2_dev *dev);
/**
* @brief Function to directly communicate with the sensor
* @param[in] conf : The configuration of the transfer
* @param[in] reg_addr : Register address to write to
* @param[in] length : Length of the data buffer to be transferred
* @param[in/out] reg_data : Reference to the data buffer
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_soft_passthrough_transfer(union bhy2_soft_passthrough_conf *conf,
uint8_t reg_addr,
uint8_t length,
uint8_t *reg_data,
struct bhy2_dev *dev);
/**
* @brief Function to check if a virtual sensor is available
* @param[in] sensor_id : Sensor ID of the virtual sensor
* @param[in] dev : Device reference
* @return 1 if the sensor is available. 0 otherwise
*/
uint8_t bhy2_is_sensor_available(uint8_t sensor_id, const struct bhy2_dev *dev);
/**
* @brief Function to get the BHy260 variant ID
*
* @param[in] variant_id : Reference to store the variant ID
* @param[in] dev : Device reference
* @return int8_t API error codes
*/
int8_t bhy2_get_variant_id(uint32_t *variant_id, struct bhy2_dev *dev);
/**
* @brief Function to inject data
* @param[in] payload : Reference to the data buffer
* @param[in] payload_len : Length of the data buffer
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_inject_data(const uint8_t *payload, uint32_t payload_len, struct bhy2_dev *dev);
/**
* @brief Function to set inject mode
* @param[in] mode : Type of data inject mode
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_set_data_injection_mode(enum bhy2_data_inj_mode mode, struct bhy2_dev *dev);
/**
* @brief Function to clear the FIFO
* @param[in] flush_cfg : Type of FIFO Flush
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_clear_fifo(uint8_t flush_cfg, struct bhy2_dev *dev);
/**
* @brief Function to read the status FIFO
* @param[out] status_code : Status Code
* @param[in] status_buff : Buffer for reading Status Response
* @param[in] status_len : Length of the Response
* @param[out] actual_len : Length of Data read
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_read_status(uint16_t *status_code,
uint8_t *status_buff,
uint32_t status_len,
uint32_t *actual_len,
struct bhy2_dev *dev);
/* End of CPP Guard */
#ifdef __cplusplus
}
#endif /*__cplusplus */
#endif /* __BHY2_H__ */