-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbma4.h
2209 lines (2086 loc) · 73.2 KB
/
bma4.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
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* 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 bma4.h
* @date 2023-07-05
* @version V2.29.0
*
*/
/*
* @file bma4.h
* @brief Source file for the BMA4 Sensor API
*/
/*!
* @defgroup bma4xy BMA4XY
*/
/**
* \ingroup bma4xy
* \defgroup bma4 BMA4
* @brief Sensor driver for BMA4 sensor
*/
#ifndef BMA4_H__
#define BMA4_H__
/*********************************************************************/
/* header files */
#include "bma4_defs.h"
#ifdef AKM9916
#include "aux_akm9916.h"
#endif
#ifdef BMM150
#include "aux_bmm150.h"
#endif
/*********************************************************************/
/* (extern) variable declarations */
/*********************************************************************/
/* function prototype declarations */
/**
* \ingroup bma4
* \defgroup bma4ApiInit Initialization
* @brief Initialize the sensor and device structure
*/
/*!
* \ingroup bma4ApiInit
* \page bma4_api_bma4_init bma4_init
* \code
* int8_t bma4_init(struct bma4_dev *dev);
* \endcode
* @details This API is the entry point.
* Call this API before using all other APIs.
* This API reads the chip-id of the sensor which is the first step to
* verify the sensor and also it configures the read mechanism of SPI and
* I2C interface.
*
* @param[in,out] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*
* @note
* While changing the parameter of the bma4
* consider the following point:
* Changing the reference value of the parameter
* will changes the local copy or local reference
* make sure your changes will not
* affect the reference value of the parameter
* (Better case don't change the reference value of the parameter)
*/
int8_t bma4_init(struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiConfig ConfigFile
* @brief Write binary configuration in the sensor
*/
/*!
* \ingroup bma4ApiConfig
* \page bma4_api_bma4_write_config_file bma4_write_config_file
* \code
* int8_t bma4_write_config_file(struct bma4_dev *dev);
* \endcode
* @details This API is used to write the binary configuration in the sensor
*
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_write_config_file(struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiRegisters Registers
* @brief Perform read / write operation to registers of the sensor
*/
/*!
* \ingroup bma4ApiRegisters
* \page bma4_api_bma4_write_regs bma4_write_regs
* \code
* int8_t bma4_write_regs(uint8_t addr, uint8_t *data, uint8_t len, struct bma4_dev *dev);
* \endcode
* @details This API checks whether the write operation requested is for
* feature config or register write and accordingly writes the data in the
* sensor.
*
* @note user has to disable the advance power save mode in the sensor when
* using this API in burst write mode.
* bma4_set_advance_power_save(BMA4_DISABLE, dev);
*
* @param[in] addr : Register address.
* @param[in] data : Write data buffer
* @param[in] len : No of bytes to write
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_write_regs(uint8_t addr, const uint8_t *data, uint32_t len, struct bma4_dev *dev);
/*!
* \ingroup bma4ApiRegisters
* \page bma4_api_bma4_read_regs bma4_read_regs
* \code
* int8_t bma4_write_regs(uint8_t addr, uint8_t *data, uint8_t len, struct bma4_dev *dev);
* \endcode
* @details This API checks whether the read operation requested is for
* feature or register read and accordingly reads the data from the sensor.
*
* @param[in] addr : Register address.
* @param[in] data : Read data buffer.
* @param[in] len : No of bytes to read.
* @param[in] dev : Structure instance of bma4_dev
*
* @note For most of the registers auto address increment applies, with the
* exception of a few special registers, which trap the address. For e.g.,
* Register address - 0x26, 0x5E.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_read_regs(uint8_t addr, uint8_t *data, uint32_t len, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiErrorStatus Error Status
* @brief Read error status of the sensor
*/
/*!
* \ingroup bma4ApiErrorStatus
* \page bma4_api_bma4_get_error_status bma4_get_error_status
* \code
* int8_t bma4_get_error_status(struct bma4_err_reg *err_reg, struct bma4_dev *dev);;
* \endcode
* @details This API reads the error status from the sensor.
*
* Below table mention the types of error which can occur in the sensor
*
*@verbatim
*************************************************************************
* Error | Description
*************************|***********************************************
* | Fatal Error, chip is not in operational
* fatal | state (Boot-, power-system).
* | This flag will be reset only by
* | power-on-reset or soft reset.
*************************|***********************************************
* cmd | Command execution failed.
*************************|***********************************************
* | Value Name Description
* error_code | 000 no_error no error
* | 001 acc_err error in
* | ACC_CONF
*************************|***********************************************
* | Error in FIFO detected: Input data was
* fifo | discarded in stream mode. This flag
* | will be reset when read.
*************************|***********************************************
* mag | Error in I2C-Master detected.
* | This flag will be reset when read.
*************************************************************************
*@endverbatim
*
* @param[in,out] err_reg : Pointer to structure variable which stores the
* error status read from the sensor.
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_get_error_status(struct bma4_err_reg *err_reg, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiAccelxyz Accel XYZ Data
* @brief Read accel xyz data from the sensor
*/
/*!
* \ingroup bma4ApiAccelxyz
* \page bma4_api_bma4_read_accel_xyz bma4_read_accel_xyz
* \code
* int8_t bma4_read_accel_xyz(struct bma4_accel *accel, struct bma4_dev *dev);
* \endcode
* @details This API reads the Accel data for x,y and z axis from the sensor.
* The data units is in LSB format.
*
* @param[in] accel : Variable used to store the Accel data which is read
* from the sensor.
* @param[in] dev : Structure instance of bma4_dev.
*
* @note For setting the Accel configuration use the below function
* bma4_set_accel_config
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_read_accel_xyz(struct bma4_accel *accel, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiSensorTime Sensor Time
* @brief Read sensor time of the sensor
*/
/*!
* \ingroup bma4ApiSensorTime
* \page bma4_api_bma4_get_sensor_time bma4_get_sensor_time
* \code
* int8_t bma4_get_sensor_time(uint32_t *sensor_time, struct bma4_dev *dev);
* \endcode
* @details This API reads the sensor time of Sensor time gets updated
* with every update of data register or FIFO.
*
* @param[in] sensor_time : Pointer variable which stores sensor time
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_get_sensor_time(uint32_t *sensor_time, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiTemperature Temperature
* @brief Read chip temperature of the sensor
*/
/*!
* \ingroup bma4ApiTemperature
* \page bma4_api_bma4_get_temperature bma4_get_temperature
* \code
* int8_t bma4_get_temperature(int32_t *temp, uint8_t temp_unit, struct bma4_dev *dev);
* \endcode
* @details This API reads the chip temperature of sensor.
* @note If Accel and Mag are disabled, the temperature value will be set
* to invalid.
*
* @param[out] temp : Pointer variable which stores the temperature value.
* @param[in] temp_unit : indicates the unit of temperature
*
* @verbatim
* temp_unit | description
* ------------|-------------------
* BMA4_DEG | degrees Celsius
* BMA4_FAHREN | degrees fahrenheit
* BMA4_KELVIN | degrees kelvin
*@endverbatim
*
* @param[in] dev : Structure instance of bma4_dev.
*
* @note Using a scaling factor of 1000, to obtain integer values, which
* at the user end, are used to get accurate temperature value.
* BMA4_SCALE_FARHAN = 1.8 * 1000, BMA4_SCALE_KELVIN = 273.15 * 1000
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_get_temperature(int32_t *temp, uint8_t temp_unit, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiAccel Accel Configuration
* @brief Read / Write configurations of accel sensor
*/
/*!
* \ingroup bma4ApiAccel
* \page bma4_api_bma4_get_accel_config bma4_get_accel_config
* \code
* int8_t bma4_get_accel_config(struct bma4_accel_config *accel, struct bma4_dev *dev);
* \endcode
* @details This API reads the Output data rate, Bandwidth, perf_mode
* and Range of accel.
*
* @param[in,out] accel : Address of user passed structure which is used
* to store the Accel configurations read from the sensor.
*
* @note Enums and corresponding values for structure parameters like
* Odr, Bandwidth and Range are mentioned in the below tables.
*
*@verbatim
* Value | Odr
* -----------|------------------------------------
* 1 | BMA4_OUTPUT_DATA_RATE_0_78HZ
* 2 | BMA4_OUTPUT_DATA_RATE_1_56HZ
* 3 | BMA4_OUTPUT_DATA_RATE_3_12HZ
* 4 | BMA4_OUTPUT_DATA_RATE_6_25HZ
* 5 | BMA4_OUTPUT_DATA_RATE_12_5HZ
* 6 | BMA4_OUTPUT_DATA_RATE_25HZ
* 7 | BMA4_OUTPUT_DATA_RATE_50HZ
* 8 | BMA4_OUTPUT_DATA_RATE_100HZ
* 9 | BMA4_OUTPUT_DATA_RATE_200HZ
* 10 | BMA4_OUTPUT_DATA_RATE_400HZ
* 11 | BMA4_OUTPUT_DATA_RATE_800HZ
* 12 | BMA4_OUTPUT_DATA_RATE_1600HZ
*@endverbatim
*
*@verbatim
* Value | accel_bw
* ------|--------------------------
* 0 | BMA4_ACCEL_OSR4_AVG1
* 1 | BMA4_ACCEL_OSR2_AVG2
* 2 | BMA4_ACCEL_NORMAL_AVG4
* 3 | BMA4_ACCEL_CIC_AVG8
* 4 | BMA4_ACCEL_RES_AVG16
* 5 | BMA4_ACCEL_RES_AVG32
* 6 | BMA4_ACCEL_RES_AVG64
* 7 | BMA4_ACCEL_RES_AVG128
*@endverbatim
*
*@verbatim
* Value | g_range
* --------|---------------------
* 0x00 | BMA4_ACCEL_RANGE_2G
* 0x01 | BMA4_ACCEL_RANGE_4G
* 0x02 | BMA4_ACCEL_RANGE_8G
* 0x03 | BMA4_ACCEL_RANGE_16G
*@endverbatim
*
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_get_accel_config(struct bma4_accel_config *accel, struct bma4_dev *dev);
/*!
* \ingroup bma4ApiAccel
* \page bma4_api_bma4_set_accel_config bma4_set_accel_config
* \code
* int8_t bma4_set_accel_config(struct bma4_accel_config *accel, struct bma4_dev *dev);
* \endcode
* @details This API sets the output_data_rate, bandwidth, perf_mode
* and range of Accel.
*
* @param[in] accel : Pointer to structure variable which specifies the
* Accel configurations.
*
* @note Enums and corresponding values for structure parameters like
* Odr, Bandwidth and Range are mentioned in the below tables.
*
* @verbatim
* Value | ODR
* --------|-----------------------------------------
* 1 | BMA4_OUTPUT_DATA_RATE_0_78HZ
* 2 | BMA4_OUTPUT_DATA_RATE_1_56HZ
* 3 | BMA4_OUTPUT_DATA_RATE_3_12HZ
* 4 | BMA4_OUTPUT_DATA_RATE_6_25HZ
* 5 | BMA4_OUTPUT_DATA_RATE_12_5HZ
* 6 | BMA4_OUTPUT_DATA_RATE_25HZ
* 7 | BMA4_OUTPUT_DATA_RATE_50HZ
* 8 | BMA4_OUTPUT_DATA_RATE_100HZ
* 9 | BMA4_OUTPUT_DATA_RATE_200HZ
* 10 | BMA4_OUTPUT_DATA_RATE_400HZ
* 11 | BMA4_OUTPUT_DATA_RATE_800HZ
* 12 | BMA4_OUTPUT_DATA_RATE_1600HZ
*
*@endverbatim
*
*@verbatim
* Value | accel_bw
* ------|--------------------------
* 0 | BMA4_ACCEL_OSR4_AVG1
* 1 | BMA4_ACCEL_OSR2_AVG2
* 2 | BMA4_ACCEL_NORMAL_AVG4
* 3 | BMA4_ACCEL_CIC_AVG8
* 4 | BMA4_ACCEL_RES_AVG16
* 5 | BMA4_ACCEL_RES_AVG32
* 6 | BMA4_ACCEL_RES_AVG64
* 7 | BMA4_ACCEL_RES_AVG128
*@endverbatim
*
*@verbatim
* Value | g_range
* --------|---------------------
* 0x00 | BMA4_ACCEL_RANGE_2G
* 0x01 | BMA4_ACCEL_RANGE_4G
* 0x02 | BMA4_ACCEL_RANGE_8G
* 0x03 | BMA4_ACCEL_RANGE_16G
*@endverbatim
*
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*
*/
int8_t bma4_set_accel_config(const struct bma4_accel_config *accel, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiAdvancedPowerMode Advanced Power Mode
* @brief Read / Write advance power mode of accel sensor
*/
/*!
* \ingroup bma4ApiAdvancedPowerMode
* \page bma4_api_bma4_set_advance_power_save bma4_set_advance_power_save
* \code
* int8_t bma4_set_advance_power_save(uint8_t adv_pwr_save, struct bma4_dev *dev);
* \endcode
* @details This API sets the advance power save mode in the sensor.
*
* @note If advanced power save is enabled and the Accel and/or
* magnetometer operate in duty cycling mode, the length of the unlatched
* DRDY interrupt pulse is longer than 1/3.2 kHz (312.5 us).
*
* @param[in] adv_pwr_save : The value of advance power save mode
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_set_advance_power_save(uint8_t adv_pwr_save, struct bma4_dev *dev);
/*!
* \ingroup bma4ApiAdvancedPowerMode
* \page bma4_api_bma4_get_advance_power_save bma4_get_advance_power_save
* \code
* int8_t bma4_get_advance_power_save(uint8_t adv_pwr_save, struct bma4_dev *dev);
* \endcode
* @details This API reads the status of advance power save mode
* from the sensor.
*
* @note If the advanced power save is enabled and the Accel and/or
* magnetometer operate in duty cycling mode, the length of the unlatched
* DRDY interrupt pulse is longer than 1/3.2 kHz (312.5 us).
*
* @param[out] adv_pwr_save : The value of advance power save mode
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_get_advance_power_save(uint8_t *adv_pwr_save, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiFIFOSelfWakeUp FIFO Self Wake up
* @brief Read / Write FIFO self wake up functionality in the sensor
*/
/*!
* \ingroup bma4ApiFIFOSelfWakeUp
* \page bma4_api_bma4_set_fifo_self_wakeup bma4_set_fifo_self_wakeup
* \code
* int8_t bma4_set_fifo_self_wakeup(uint8_t fifo_self_wakeup, struct bma4_dev *dev);
* \endcode
* @details This API sets the FIFO self wake up functionality in the sensor.
*
* @note Functionality related to FIFO self wake up depends upon the
* advance power save mode. for more info. refer data sheet.
*
* @param[in] fifo_self_wakeup : Variable used to enable or disable
* FIFO self wake up functionality.
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_set_fifo_self_wakeup(uint8_t fifo_self_wakeup, struct bma4_dev *dev);
/*!
* \ingroup bma4ApiFIFOSelfWakeUp
* \page bma4_api_bma4_get_fifo_self_wakeup bma4_get_fifo_self_wakeup
* \code
* int8_t bma4_get_fifo_self_wakeup(uint8_t *fifo_self_wakeup, struct bma4_dev *dev);
* \endcode
* @details This API gets the status of FIFO self wake up functionality from
* the sensor.
*
* @note Functionality related to FIFO self wake up depends upon the
* advance power save mode. for more info. refer data sheet.
*
* @param[out] fifo_self_wake_up : Pointer variable used to store the
* fifo self wake up status.
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_get_fifo_self_wakeup(uint8_t *fifo_self_wake_up, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiAccelEnable Accel Enable
* @brief Enables / Disables accelerometer in the sensor
*/
/*!
* \ingroup bma4ApiAccelEnable
* \page bma4_api_bma4_set_accel_enable bma4_set_accel_enable
* \code
* int8_t bma4_set_accel_enable(uint8_t accel_en, struct bma4_dev *dev);
* \endcode
* @details This API enables or disables the Accel in the sensor.
*
* @note Before reading Accel data, user should call this API.
*
* @param[in] accel_en : Variable used to enable or disable the Accel.
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_set_accel_enable(uint8_t accel_en, struct bma4_dev *dev);
/*!
* \ingroup bma4ApiAccelEnable
* \page bma4_api_bma4_get_accel_enable bma4_get_accel_enable
* \code
* int8_t bma4_get_accel_enable(uint8_t *accel_en, struct bma4_dev *dev);
* \endcode
* @details This API checks whether Accel is enabled or not in the sensor.
*
* @param[out] accel_en : Pointer variable used to store the Accel enable
* status
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_get_accel_enable(uint8_t *accel_en, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiMagEnable Magnetometer Enable
* @brief Enables / Disables Auxiliary Magnetometer in the sensor
*/
/*!
* \ingroup bma4ApiMagEnable
* \page bma4_api_bma4_set_mag_enable bma4_set_mag_enable
* \code
* int8_t bma4_set_mag_enable(uint8_t mag_en, struct bma4_dev *dev);
* \endcode
* @details This API is used to enable or disable auxiliary Mag
* in the sensor.
*
* @note Before reading Mag data, user should call this API.
*
* @param[in] mag_en : Variable used to enable or disable the Mag.
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_set_mag_enable(uint8_t mag_en, struct bma4_dev *dev);
/*!
* \ingroup bma4ApiMagEnable
* \page bma4_api_bma4_get_mag_enable bma4_get_mag_enable
* \code
* int8_t bma4_get_mag_enable(uint8_t *mag_en, struct bma4_dev *dev);
* \endcode
* @details This API is used to check whether the auxiliary Mag is enabled
* or not in the sensor.
*
* @param[out] mag_en : Pointer variable used to store the enable status of
* Mag in the sensor.
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_get_mag_enable(uint8_t *mag_en, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiSpiInterface SPI interface
* @brief Read / Write SPI interface mode set for primary interface
*/
/*!
* \ingroup bma4AiSpiInterface
* \page bma4_api_bma4_set_spi_interface bma4_set_spi_interface
* \code
* int8_t bma4_set_spi_interface(uint8_t *spi, struct bma4_dev *dev);
* \endcode
* @details This API reads the SPI interface mode which is set for primary
* interface.
*
* @param[out] spi : Pointer variable which stores the SPI mode selection
*
* @verbatim
* Value | Description
* --------|------------------
* 0 | SPI 4-wire mode
* 1 | SPI 3-wire mode
*
*@endverbatim
*
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_get_spi_interface(uint8_t *spi, struct bma4_dev *dev);
/*!
* \ingroup bma4ApiSpiInterface
* \page bma4_api_bma4_get_spi_interface bma4_get_spi_interface
* \code
* int8_t bma4_get_spi_interface(uint8_t spi, struct bma4_dev *dev);
* \endcode
* @details This API configures the SPI interface Mode for primary interface
*
* @param[in] spi : The value of SPI mode selection
*
*@verbatim
* Value | Description
* --------|------------------
* 0 | SPI 4-wire mode
* 1 | SPI 3-wire mode
*
*@endverbatim
*
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_set_spi_interface(uint8_t spi, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiCommandReg Command Register
* @brief Write available sensor specific commands to the sensor
*/
/*!
* \ingroup bma4ApiCommandReg
* \page bma4_api_bma4_set_command_register bma4_set_command_register
* \code
* int8_t bma4_set_command_register(uint8_t command_reg, struct bma4_dev *dev);
* \endcode
* @details This API writes the available sensor specific commands
* to the sensor.
*
* @param[in] command_reg : The command to write to the command register
*
*@verbatim
* value | Description
* --------|------------------------------------------------------
* 0xB6 | Triggers a soft reset
* 0xB0 | Clears all data in the FIFO, does not change
* | FIFO_CONFIG and FIFO_DOWNS registers
* 0xF0 | Reset acceleration data path
*@endverbatim
*
*
* @param[in] dev : Structure instance of bma4_dev.
*
* @note Register will always read as 0x00
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_set_command_register(uint8_t command_reg, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiI2CAddr i2C Device Address
* @brief Write I2C device address of auxiliary sensor
*/
/*!
* \ingroup bma4ApiI2CAddr
* \page bma4_api_bma4_set_i2c_device_addr bma4_set_i2c_device_addr
* \code
* int8_t bma4_set_i2c_device_addr(struct bma4_dev *dev);
* \endcode
* @details This API sets the I2C device address of auxiliary sensor
*
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_set_i2c_device_addr(struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiMagManualEnable Mag Manual Enable
* @brief Read / Write register access on magnetometer manually
*/
/*!
* \ingroup bma4ApiMagManualEnable
* \page bma4_api_bma4_set_mag_manual_enable bma4_set_mag_manual_enable
* \code
* int8_t bma4_set_mag_manual_enable(uint8_t mag_manual, struct bma4_dev *dev);
* \endcode
* @details This API sets the register access on MAG_IF[2], MAG_IF[3],
* MAG_IF[4] in the sensor. This implies that the DATA registers are
* not updated with Mag values automatically.
*
* @param[in] mag_manual : Variable used to specify the Mag manual
* enable status.
*
*@verbatim
* value | mag manual
* ---------|--------------------
* 0x01 | BMA4_ENABLE
* 0x00 | BMA4_DISABLE
*@endverbatim
*
* @param[out] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_set_mag_manual_enable(uint8_t mag_manual, struct bma4_dev *dev);
/*!
* \ingroup bma4ApiMagManualEnable
* \page bma4_api_bma4_get_mag_manual_enable bma4_get_mag_manual_enable
* \code
* int8_t bma4_get_mag_manual_enable(uint8_t *mag_manual, struct bma4_dev *dev);
* \endcode
* @details This API checks whether the Mag access is done manually or
* automatically in the sensor.
* If the Mag access is done through manual mode then Mag data registers
* in sensor are not updated automatically.
*
* @param[out] mag_manual : Mag manual enable value
*
*@verbatim
* value | mag_manual
* --------|-------------------
* 0x01 | BMA4_ENABLE
* 0x00 | BMA4_DISABLE
*@endverbatim
*
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_get_mag_manual_enable(uint8_t *mag_manual, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiMagIFMode Mag Interface Mode
* @brief Set I2C interface configuration mode for auxiliary magnetometer
*/
/*!
* \ingroup bma4ApiMagIFMode
* \page bma4_api_bma4_set_aux_if_mode bma4_set_aux_if_mode
* \code
* int8_t bma4_set_aux_if_mode(uint8_t if_mode, struct bma4_dev *dev);
* \endcode
* @details This API sets the I2C interface configuration(if) mode
* for auxiliary Mag.
*
* @param[in] if_mode : The value of interface configuration mode
*
*@verbatim
* Value | Description
* ------------|-------------------------------------------
* 0 | p_auto_s_off Auxiliary interface:off
* 1 | p_auto_s_mag Auxiliary interface:on
*@endverbatim
*
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_set_aux_if_mode(uint8_t if_mode, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiMagRead Mag Read
* @brief Set / Get address of register of Aux Mag sensor to read data
*/
/*!
* \ingroup bma4ApiMagRead
* \page bma4_api_bma4_get_mag_read_addr bma4_get_mag_read_addr
* \code
* int8_t bma4_get_mag_read_addr(uint8_t *mag_read_addr, struct bma4_dev *dev);
* \endcode
* @details This API gets the address of the register of Aux Mag sensor
* where the data to be read.
*
* @param[out] mag_read_addr : Pointer variable used to store the
* mag read address.
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_get_mag_read_addr(uint8_t *mag_read_addr, struct bma4_dev *dev);
/*!
* \ingroup bma4ApiMagRead
* \page bma4_api_bma4_set_mag_read_addr bma4_set_mag_read_addr
* \code
* int8_t bma4_set_mag_read_addr(uint8_t mag_read_addr, struct bma4_dev *dev);
* \endcode
* @details This API sets the address of the register of Aux Mag sensor
* where the data to be read.
*
* @param[in] mag_read_addr: Value of Mag. read address in order to read
* the data from the auxiliary Mag.
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_set_mag_read_addr(uint8_t mag_read_addr, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiMagWrite Mag Write
* @brief Set / Get address of register of Aux Mag sensor to write data
*/
/*!
* \ingroup bma4ApiMagWrite
* \page bma4_api_bma4_get_mag_write_addr bma4_get_mag_write_addr
* \code
* int8_t bma4_get_mag_write_addr(uint8_t *mag_write_addr, struct bma4_dev *dev);
* \endcode
* @details This API gets the Aux Mag write address from the sensor.
* Mag write address is where the Mag data will be written.
*
* @param[out] mag_write_addr: Pointer used to store the Mag write address
* which is read from the sensor.
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_get_mag_write_addr(uint8_t *mag_write_addr, struct bma4_dev *dev);
/*!
* \ingroup bma4ApiMagWrite
* \page bma4_api_bma4_set_mag_write_addr bma4_set_mag_write_addr
* \code
* int8_t bma4_set_mag_write_addr(uint8_t mag_write_addr, struct bma4_dev *dev);
* \endcode
* @details This API sets the Aux Mag write address in the sensor.
* Mag write address is where the Mag data will be written.
*
* @param[in] mag_write_addr: Write address of Mag where the data will
* be written.
* @param[out] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_set_mag_write_addr(uint8_t mag_write_addr, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiMagData Mag Data
* @brief Read / Write data from the Mag sensor
*/
/*!
* \ingroup bma4ApiMagData
* \page bma4_api_bma4_get_mag_write_data bma4_get_mag_write_data
* \code
* int8_t bma4_get_mag_write_data(uint8_t *mag_write_data, struct bma4_dev *dev);
* \endcode
* @details This API reads the data from the sensor which is written to the
* Mag.
*
* @param[out] mag_write_data: Pointer variable which stores the
* data which is written in Mag through sensor.
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_get_mag_write_data(uint8_t *mag_write_data, struct bma4_dev *dev);
/*!
* \ingroup bma4ApiMagData
* \page bma4_api_bma4_set_mag_write_data bma4_set_mag_write_data
* \code
* int8_t bma4_set_mag_write_data(uint8_t mag_write_data, struct bma4_dev *dev);
* \endcode
* @details This API sets the data in the sensor which in turn will
* be written to Mag.
*
* @param[in] mag_write_data: variable which specify the data which is to
* be written in Mag.
* @param[out] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bma4_set_mag_write_data(uint8_t mag_write_data, struct bma4_dev *dev);
/**
* \ingroup bma4
* \defgroup bma4ApiReadMagXYZR Mag xyzr Data
* @brief Read xyzr axes data from auxiliary Mag sensor
*/
/*!
* \ingroup bma4ApiReadMagXYZR
* \page bma4_api_bma4_read_mag_xyzr bma4_read_mag_xyzr
* \code
* int8_t bma4_read_mag_xyzr(struct bma4_mag_xyzr *mag, struct bma4_dev *dev);