forked from sedoski20/BNO055_driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bno055.h
8138 lines (7432 loc) · 269 KB
/
bno055.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) 2020 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 bno055.h
* @date 10/01/2020
* @version 2.0.6
*
*/
/*! \file bno055.h
* \brief BNO055 Sensor Driver Support Header File */
#ifndef __BNO055_H__
#define __BNO055_H__
/****************************************************************/
/**\name DATA TYPES INCLUDES */
/************************************************************/
/*!
* @brief The following definition uses for define the data types
*
* @note While porting the API please consider the following
* @note Please check the version of C standard
* @note Are you using Linux platform
*/
/*!
* @brief For the Linux platform support
* Please use the types.h for your data types definitions
*/
#ifdef __KERNEL__
#include <linux/types.h>
/* singed integer type*/
typedef int8_t s8; /**< used for signed 8bit */
typedef int16_t s16; /**< used for signed 16bit */
typedef int32_t s32; /**< used for signed 32bit */
typedef int64_t s64; /**< used for signed 64bit */
typedef u_int8_t u8; /**< used for unsigned 8bit */
typedef u_int16_t u16; /**< used for unsigned 16bit */
typedef u_int32_t u32; /**< used for unsigned 32bit */
typedef u_int64_t u64; /**< used for unsigned 64bit */
#else /* ! __KERNEL__ */
/**********************************************************
* These definition uses for define the C
* standard version data types
***********************************************************/
# if !defined(__STDC_VERSION__)
/************************************************
* compiler is C11 C standard
************************************************/
#if (__STDC_VERSION__ == 201112L)
/************************************************/
#include <stdint.h>
/************************************************/
/*unsigned integer types*/
typedef uint8_t u8; /**< used for unsigned 8bit */
typedef uint16_t u16; /**< used for unsigned 16bit */
typedef uint32_t u32; /**< used for unsigned 32bit */
typedef uint64_t u64; /**< used for unsigned 64bit */
/*signed integer types*/
typedef int8_t s8; /**< used for signed 8bit */
typedef int16_t s16; /**< used for signed 16bit */
typedef int32_t s32; /**< used for signed 32bit */
typedef int64_t s64; /**< used for signed 64bit */
/************************************************
* compiler is C99 C standard
************************************************/
#elif (__STDC_VERSION__ == 199901L)
/* stdint.h is a C99 supported c library.
* which is used to fixed the integer size*/
/************************************************/
#include <stdint.h>
/************************************************/
/*unsigned integer types*/
typedef uint8_t u8; /**< used for unsigned 8bit */
typedef uint16_t u16; /**< used for unsigned 16bit */
typedef uint32_t u32; /**< used for unsigned 32bit */
typedef uint64_t u64; /**< used for unsigned 64bit */
/*signed integer types*/
typedef int8_t s8; /**< used for signed 8bit */
typedef int16_t s16; /**< used for signed 16bit */
typedef int32_t s32; /**< used for signed 32bit */
typedef int64_t s64; /**< used for signed 64bit */
/************************************************
* compiler is C89 or other C standard
************************************************/
#else /* !defined(__STDC_VERSION__) */
/*!
* @brief By default it is defined as 32 bit machine configuration
* define your data types based on your
* machine/compiler/controller configuration
*/
#define MACHINE_32_BIT
/*! @brief
* If your machine support 16 bit
* define the MACHINE_16_BIT
*/
#ifdef MACHINE_16_BIT
#include <limits.h>
/*signed integer types*/
typedef signed char s8; /**< used for signed 8bit */
typedef signed short int s16; /**< used for signed 16bit */
typedef signed long int s32; /**< used for signed 32bit */
#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
typedef long int s64; /**< used for signed 64bit */
typedef unsigned long int u64; /**< used for unsigned 64bit */
#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
typedef long long int s64; /**< used for signed 64bit */
typedef unsigned long long int u64; /**< used for unsigned 64bit */
#else
#warning Either the correct data type for signed 64 bit integer \
could not be found, or 64 bit integers are not supported in your environment.
#warning If 64 bit integers are supported on your platform, \
please set s64 manually.
#endif
/*unsigned integer types*/
typedef unsigned char u8; /**< used for unsigned 8bit */
typedef unsigned short int u16; /**< used for unsigned 16bit */
typedef unsigned long int u32; /**< used for unsigned 32bit */
/* If your machine support 32 bit
* define the MACHINE_32_BIT*/
#elif defined MACHINE_32_BIT
/*signed integer types*/
typedef signed char s8; /**< used for signed 8bit */
typedef signed short int s16; /**< used for signed 16bit */
typedef signed int s32; /**< used for signed 32bit */
typedef signed long long int s64; /**< used for signed 64bit */
/*unsigned integer types*/
typedef unsigned char u8; /**< used for unsigned 8bit */
typedef unsigned short int u16; /**< used for unsigned 16bit */
typedef unsigned int u32; /**< used for unsigned 32bit */
typedef unsigned long long int u64; /**< used for unsigned 64bit */
/* If your machine support 64 bit
* define the MACHINE_64_BIT*/
#elif defined MACHINE_64_BIT
/*signed integer types*/
typedef signed char s8; /**< used for signed 8bit */
typedef signed short int s16; /**< used for signed 16bit */
typedef signed int s32; /**< used for signed 32bit */
typedef signed long int s64; /**< used for signed 64bit */
/*unsigned integer types*/
typedef unsigned char u8; /**< used for unsigned 8bit */
typedef unsigned short int u16; /**< used for unsigned 16bit */
typedef unsigned int u32; /**< used for unsigned 32bit */
typedef unsigned long int u64; /**< used for unsigned 64bit */
#else
#warning The data types defined above which not supported \
define the data types manually
#endif
#endif
/*** This else will execute for the compilers
* which are not supported the C standards
* Like C89/C99/C11***/
#else
/*!
* @brief By default it is defined as 32 bit machine configuration
* define your data types based on your
* machine/compiler/controller configuration
*/
#define MACHINE_32_BIT
/* If your machine support 16 bit
* define the MACHINE_16_BIT*/
#ifdef MACHINE_16_BIT
#include <limits.h>
/*signed integer types*/
typedef signed char s8; /**< used for signed 8bit */
typedef signed short int s16; /**< used for signed 16bit */
typedef signed long int s32; /**< used for signed 32bit */
#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
typedef long int s64; /**< used for signed 64bit */
typedef unsigned long int u64; /**< used for unsigned 64bit */
#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
typedef long long int s64; /**< used for signed 64bit */
typedef unsigned long long int u64; /**< used for unsigned 64bit */
#else
#warning Either the correct data type for signed 64 bit integer \
could not be found, or 64 bit integers are not supported in your environment.
#warning If 64 bit integers are supported on your platform, \
please set s64 manually.
#endif
/*unsigned integer types*/
typedef unsigned char u8; /**< used for unsigned 8bit */
typedef unsigned short int u16; /**< used for unsigned 16bit */
typedef unsigned long int u32; /**< used for unsigned 32bit */
/*! @brief If your machine support 32 bit
* define the MACHINE_32_BIT*/
#elif defined MACHINE_32_BIT
/*signed integer types*/
typedef signed char s8; /**< used for signed 8bit */
typedef signed short int s16; /**< used for signed 16bit */
typedef signed int s32; /**< used for signed 32bit */
typedef signed long long int s64; /**< used for signed 64bit */
/*unsigned integer types*/
typedef unsigned char u8; /**< used for unsigned 8bit */
typedef unsigned short int u16; /**< used for unsigned 16bit */
typedef unsigned int u32; /**< used for unsigned 32bit */
typedef unsigned long long int u64; /**< used for unsigned 64bit */
/* If your machine support 64 bit
* define the MACHINE_64_BIT*/
#elif defined MACHINE_64_BIT
/*signed integer types*/
typedef signed char s8; /**< used for signed 8bit */
typedef signed short int s16; /**< used for signed 16bit */
typedef signed int s32; /**< used for signed 32bit */
typedef signed long int s64; /**< used for signed 64bit */
/*unsigned integer types*/
typedef unsigned char u8; /**< used for unsigned 8bit */
typedef unsigned short int u16; /**< used for unsigned 16bit */
typedef unsigned int u32; /**< used for unsigned 32bit */
typedef unsigned long int u64; /**< used for unsigned 64bit */
#else
#warning The data types defined above which not supported \
define the data types manually
#endif
#endif
#endif
/***************************************************************/
/**\name BUS READ AND WRITE FUNCTIONS */
/***************************************************************/
#define BNO055_WR_FUNC_PTR s8 (*bus_write) \
(u8, u8, u8 *, u8)
#define BNO055_BUS_WRITE_FUNC(dev_addr, reg_addr, reg_data, wr_len) \
bus_write(dev_addr, reg_addr, reg_data, wr_len)
#define BNO055_RD_FUNC_PTR s8 \
(*bus_read)(u8, u8, u8 *, u8)
#define BNO055_BUS_READ_FUNC(dev_addr, reg_addr, reg_data, r_len) \
bus_read(dev_addr, reg_addr, reg_data, r_len)
#define BNO055_DELAY_RETURN_TYPE void
#define BNO055_DELAY_PARAM_TYPES u32
#define BNO055_DELAY_FUNC(delay_in_msec) \
delay_func(delay_in_msec)
/********************************************************/
/**\name I2C ADDRESS DEFINITION FOR BNO055 */
/********************************************************/
/* bno055 I2C Address */
#define BNO055_I2C_ADDR1 (0x28)
#define BNO055_I2C_ADDR2 (0x29)
/***************************************************/
/**\name REGISTER ADDRESS DEFINITION */
/***************************************************/
/* Page id register definition*/
#define BNO055_PAGE_ID_ADDR (0X07)
/* PAGE0 REGISTER DEFINITION START*/
#define BNO055_CHIP_ID_ADDR (0x00)
#define BNO055_ACCEL_REV_ID_ADDR (0x01)
#define BNO055_MAG_REV_ID_ADDR (0x02)
#define BNO055_GYRO_REV_ID_ADDR (0x03)
#define BNO055_SW_REV_ID_LSB_ADDR (0x04)
#define BNO055_SW_REV_ID_MSB_ADDR (0x05)
#define BNO055_BL_REV_ID_ADDR (0X06)
/* Accel data register*/
#define BNO055_ACCEL_DATA_X_LSB_ADDR (0X08)
#define BNO055_ACCEL_DATA_X_MSB_ADDR (0X09)
#define BNO055_ACCEL_DATA_Y_LSB_ADDR (0X0A)
#define BNO055_ACCEL_DATA_Y_MSB_ADDR (0X0B)
#define BNO055_ACCEL_DATA_Z_LSB_ADDR (0X0C)
#define BNO055_ACCEL_DATA_Z_MSB_ADDR (0X0D)
/*Mag data register*/
#define BNO055_MAG_DATA_X_LSB_ADDR (0X0E)
#define BNO055_MAG_DATA_X_MSB_ADDR (0X0F)
#define BNO055_MAG_DATA_Y_LSB_ADDR (0X10)
#define BNO055_MAG_DATA_Y_MSB_ADDR (0X11)
#define BNO055_MAG_DATA_Z_LSB_ADDR (0X12)
#define BNO055_MAG_DATA_Z_MSB_ADDR (0X13)
/*Gyro data registers*/
#define BNO055_GYRO_DATA_X_LSB_ADDR (0X14)
#define BNO055_GYRO_DATA_X_MSB_ADDR (0X15)
#define BNO055_GYRO_DATA_Y_LSB_ADDR (0X16)
#define BNO055_GYRO_DATA_Y_MSB_ADDR (0X17)
#define BNO055_GYRO_DATA_Z_LSB_ADDR (0X18)
#define BNO055_GYRO_DATA_Z_MSB_ADDR (0X19)
/*Euler data registers*/
#define BNO055_EULER_H_LSB_ADDR (0X1A)
#define BNO055_EULER_H_MSB_ADDR (0X1B)
#define BNO055_EULER_R_LSB_ADDR (0X1C)
#define BNO055_EULER_R_MSB_ADDR (0X1D)
#define BNO055_EULER_P_LSB_ADDR (0X1E)
#define BNO055_EULER_P_MSB_ADDR (0X1F)
/*Quaternion data registers*/
#define BNO055_QUATERNION_DATA_W_LSB_ADDR (0X20)
#define BNO055_QUATERNION_DATA_W_MSB_ADDR (0X21)
#define BNO055_QUATERNION_DATA_X_LSB_ADDR (0X22)
#define BNO055_QUATERNION_DATA_X_MSB_ADDR (0X23)
#define BNO055_QUATERNION_DATA_Y_LSB_ADDR (0X24)
#define BNO055_QUATERNION_DATA_Y_MSB_ADDR (0X25)
#define BNO055_QUATERNION_DATA_Z_LSB_ADDR (0X26)
#define BNO055_QUATERNION_DATA_Z_MSB_ADDR (0X27)
/* Linear acceleration data registers*/
#define BNO055_LINEAR_ACCEL_DATA_X_LSB_ADDR (0X28)
#define BNO055_LINEAR_ACCEL_DATA_X_MSB_ADDR (0X29)
#define BNO055_LINEAR_ACCEL_DATA_Y_LSB_ADDR (0X2A)
#define BNO055_LINEAR_ACCEL_DATA_Y_MSB_ADDR (0X2B)
#define BNO055_LINEAR_ACCEL_DATA_Z_LSB_ADDR (0X2C)
#define BNO055_LINEAR_ACCEL_DATA_Z_MSB_ADDR (0X2D)
/*Gravity data registers*/
#define BNO055_GRAVITY_DATA_X_LSB_ADDR (0X2E)
#define BNO055_GRAVITY_DATA_X_MSB_ADDR (0X2F)
#define BNO055_GRAVITY_DATA_Y_LSB_ADDR (0X30)
#define BNO055_GRAVITY_DATA_Y_MSB_ADDR (0X31)
#define BNO055_GRAVITY_DATA_Z_LSB_ADDR (0X32)
#define BNO055_GRAVITY_DATA_Z_MSB_ADDR (0X33)
/* Temperature data register*/
#define BNO055_TEMP_ADDR (0X34)
/* Status registers*/
#define BNO055_CALIB_STAT_ADDR (0X35)
#define BNO055_SELFTEST_RESULT_ADDR (0X36)
#define BNO055_INTR_STAT_ADDR (0X37)
#define BNO055_SYS_CLK_STAT_ADDR (0X38)
#define BNO055_SYS_STAT_ADDR (0X39)
#define BNO055_SYS_ERR_ADDR (0X3A)
/* Unit selection register*/
#define BNO055_UNIT_SEL_ADDR (0X3B)
#define BNO055_DATA_SELECT_ADDR (0X3C)
/* Mode registers*/
#define BNO055_OPR_MODE_ADDR (0X3D)
#define BNO055_PWR_MODE_ADDR (0X3E)
#define BNO055_SYS_TRIGGER_ADDR (0X3F)
#define BNO055_TEMP_SOURCE_ADDR (0X40)
/* Axis remap registers*/
#define BNO055_AXIS_MAP_CONFIG_ADDR (0X41)
#define BNO055_AXIS_MAP_SIGN_ADDR (0X42)
/* SIC registers*/
#define BNO055_SIC_MATRIX_0_LSB_ADDR (0X43)
#define BNO055_SIC_MATRIX_0_MSB_ADDR (0X44)
#define BNO055_SIC_MATRIX_1_LSB_ADDR (0X45)
#define BNO055_SIC_MATRIX_1_MSB_ADDR (0X46)
#define BNO055_SIC_MATRIX_2_LSB_ADDR (0X47)
#define BNO055_SIC_MATRIX_2_MSB_ADDR (0X48)
#define BNO055_SIC_MATRIX_3_LSB_ADDR (0X49)
#define BNO055_SIC_MATRIX_3_MSB_ADDR (0X4A)
#define BNO055_SIC_MATRIX_4_LSB_ADDR (0X4B)
#define BNO055_SIC_MATRIX_4_MSB_ADDR (0X4C)
#define BNO055_SIC_MATRIX_5_LSB_ADDR (0X4D)
#define BNO055_SIC_MATRIX_5_MSB_ADDR (0X4E)
#define BNO055_SIC_MATRIX_6_LSB_ADDR (0X4F)
#define BNO055_SIC_MATRIX_6_MSB_ADDR (0X50)
#define BNO055_SIC_MATRIX_7_LSB_ADDR (0X51)
#define BNO055_SIC_MATRIX_7_MSB_ADDR (0X52)
#define BNO055_SIC_MATRIX_8_LSB_ADDR (0X53)
#define BNO055_SIC_MATRIX_8_MSB_ADDR (0X54)
/* Accelerometer Offset registers*/
#define BNO055_ACCEL_OFFSET_X_LSB_ADDR (0X55)
#define BNO055_ACCEL_OFFSET_X_MSB_ADDR (0X56)
#define BNO055_ACCEL_OFFSET_Y_LSB_ADDR (0X57)
#define BNO055_ACCEL_OFFSET_Y_MSB_ADDR (0X58)
#define BNO055_ACCEL_OFFSET_Z_LSB_ADDR (0X59)
#define BNO055_ACCEL_OFFSET_Z_MSB_ADDR (0X5A)
/* Magnetometer Offset registers*/
#define BNO055_MAG_OFFSET_X_LSB_ADDR (0X5B)
#define BNO055_MAG_OFFSET_X_MSB_ADDR (0X5C)
#define BNO055_MAG_OFFSET_Y_LSB_ADDR (0X5D)
#define BNO055_MAG_OFFSET_Y_MSB_ADDR (0X5E)
#define BNO055_MAG_OFFSET_Z_LSB_ADDR (0X5F)
#define BNO055_MAG_OFFSET_Z_MSB_ADDR (0X60)
/* Gyroscope Offset registers*/
#define BNO055_GYRO_OFFSET_X_LSB_ADDR (0X61)
#define BNO055_GYRO_OFFSET_X_MSB_ADDR (0X62)
#define BNO055_GYRO_OFFSET_Y_LSB_ADDR (0X63)
#define BNO055_GYRO_OFFSET_Y_MSB_ADDR (0X64)
#define BNO055_GYRO_OFFSET_Z_LSB_ADDR (0X65)
#define BNO055_GYRO_OFFSET_Z_MSB_ADDR (0X66)
/* Radius registers*/
#define BNO055_ACCEL_RADIUS_LSB_ADDR (0X67)
#define BNO055_ACCEL_RADIUS_MSB_ADDR (0X68)
#define BNO055_MAG_RADIUS_LSB_ADDR (0X69)
#define BNO055_MAG_RADIUS_MSB_ADDR (0X6A)
/* PAGE0 REGISTERS DEFINITION END*/
/* PAGE1 REGISTERS DEFINITION START*/
/* Configuration registers*/
#define BNO055_ACCEL_CONFIG_ADDR (0X08)
#define BNO055_MAG_CONFIG_ADDR (0X09)
#define BNO055_GYRO_CONFIG_ADDR (0X0A)
#define BNO055_GYRO_MODE_CONFIG_ADDR (0X0B)
#define BNO055_ACCEL_SLEEP_CONFIG_ADDR (0X0C)
#define BNO055_GYRO_SLEEP_CONFIG_ADDR (0X0D)
#define BNO055_MAG_SLEEP_CONFIG_ADDR (0x0E)
/* Interrupt registers*/
#define BNO055_INT_MASK_ADDR (0X0F)
#define BNO055_INT_ADDR (0X10)
#define BNO055_ACCEL_ANY_MOTION_THRES_ADDR (0X11)
#define BNO055_ACCEL_INTR_SETTINGS_ADDR (0X12)
#define BNO055_ACCEL_HIGH_G_DURN_ADDR (0X13)
#define BNO055_ACCEL_HIGH_G_THRES_ADDR (0X14)
#define BNO055_ACCEL_NO_MOTION_THRES_ADDR (0X15)
#define BNO055_ACCEL_NO_MOTION_SET_ADDR (0X16)
#define BNO055_GYRO_INTR_SETING_ADDR (0X17)
#define BNO055_GYRO_HIGHRATE_X_SET_ADDR (0X18)
#define BNO055_GYRO_DURN_X_ADDR (0X19)
#define BNO055_GYRO_HIGHRATE_Y_SET_ADDR (0X1A)
#define BNO055_GYRO_DURN_Y_ADDR (0X1B)
#define BNO055_GYRO_HIGHRATE_Z_SET_ADDR (0X1C)
#define BNO055_GYRO_DURN_Z_ADDR (0X1D)
#define BNO055_GYRO_ANY_MOTION_THRES_ADDR (0X1E)
#define BNO055_GYRO_ANY_MOTION_SET_ADDR (0X1F)
/* PAGE1 REGISTERS DEFINITION END*/
#define BNO055_MDELAY_DATA_TYPE u32
/*< This refers BNO055 return type as s8 */
#define BNO055_RETURN_FUNCTION_TYPE s8
/* Compile switch definition for Float and double*/
#define BNO055_FLOAT_ENABLE
#define BNO055_DOUBLE_ENABLE
/**************************************************************/
/**\name STRUCTURE DEFINITIONS */
/**************************************************************/
/*!
* @brief bno055 struct
*/
struct bno055_t
{
u8 chip_id; /**< chip_id of bno055 */
u16 sw_rev_id; /**< software revision id of bno055 */
u8 page_id; /**< page_id of bno055 */
u8 accel_rev_id; /**< accel revision id of bno055 */
u8 mag_rev_id; /**< mag revision id of bno055 */
u8 gyro_rev_id; /**< gyro revision id of bno055 */
u8 bl_rev_id; /**< boot loader revision id of bno055 */
u8 dev_addr; /**< i2c device address of bno055 */
BNO055_WR_FUNC_PTR; /**< bus write function pointer */
BNO055_RD_FUNC_PTR; /**<bus read function pointer */
void (*delay_msec)(BNO055_MDELAY_DATA_TYPE); /**< delay function pointer */
};
/*!
* @brief struct for accel data read from registers
*/
struct bno055_accel_t
{
s16 x; /**< accel x data */
s16 y; /**< accel y data */
s16 z; /**< accel z data */
};
/*!
* @brief struct for Mag data read from registers
*/
struct bno055_mag_t
{
s16 x; /**< mag x data */
s16 y; /**< mag y data */
s16 z; /**< mag z data */
};
/*!
* @brief struct for Gyro data read from registers
*/
struct bno055_gyro_t
{
s16 x; /**< gyro x data */
s16 y; /**< gyro y data */
s16 z; /**< gyro z data */
};
/*!
* @brief struct for Euler data read from registers
*/
struct bno055_euler_t
{
s16 h; /**< Euler h data */
s16 r; /**< Euler r data */
s16 p; /**< Euler p data */
};
/*!
* @brief struct for Quaternion data read from registers
*/
struct bno055_quaternion_t
{
s16 w; /**< Quaternion w data */
s16 x; /**< Quaternion x data */
s16 y; /**< Quaternion y data */
s16 z; /**< Quaternion z data */
};
/*!
* @brief struct for Linear Accel data read from registers
*/
struct bno055_linear_accel_t
{
s16 x; /**< Linear Accel x data */
s16 y; /**< Linear Accel y data */
s16 z; /**< Linear Accel z data */
};
/*!
* @brief struct for Gravity data read from registers
*/
struct bno055_gravity_t
{
s16 x; /**< Gravity x data */
s16 y; /**< Gravity y data */
s16 z; /**< Gravity z data */
};
#ifdef BNO055_DOUBLE_ENABLE
/*!
* @brief struct for Accel-output data of precision double
*/
struct bno055_accel_double_t
{
double x; /**< Accel x double data */
double y; /**< Accel y double data */
double z; /**< Accel z double data */
};
/*!
* @brief struct for Mag-output data of precision double
*/
struct bno055_mag_double_t
{
double x; /**< Mag x double data */
double y; /**< Mag y double data */
double z; /**< Mag z double data */
};
/*!
* @brief struct for Gyro-output data of precision double
*/
struct bno055_gyro_double_t
{
double x; /**< Gyro x double data */
double y; /**< Gyro y double data */
double z; /**< Gyro z double data */
};
/*!
* @brief struct for Euler-output data of precision double
*/
struct bno055_euler_double_t
{
double h; /**< Euler h double data */
double r; /**< Euler r double data */
double p; /**< Euler p double data */
};
/*!
* @brief struct for Linear Accel-output data of precision double
*/
struct bno055_linear_accel_double_t
{
double x; /**< linear accel x double data */
double y; /**< linear accel y double data */
double z; /**< linear accel z double data */
};
/*!
* @brief struct for Gravity-output data of precision double
*/
struct bno055_gravity_double_t
{
double x; /**< Gravity x double data */
double y; /**< Gravity y double data */
double z; /**< Gravity z double data */
};
#endif
#ifdef BNO055_FLOAT_ENABLE
/*!
* @brief struct for Accel-output data of precision float
*/
struct bno055_accel_float_t
{
float x; /**< accel x float data */
float y; /**< accel y float data */
float z; /**< accel z float data */
};
/*!
* @brief struct for Mag-output data of precision float
*/
struct bno055_mag_float_t
{
float x; /**< Mag x float data */
float y; /**< Mag y float data */
float z; /**< Mag z float data */
};
/*!
* @brief struct for Gyro-output data of precision float
*/
struct bno055_gyro_float_t
{
float x; /**< Gyro x float data */
float y; /**< Gyro y float data */
float z; /**< Gyro z float data */
};
/*!
* @brief struct for Euler-output data of precision float
*/
struct bno055_euler_float_t
{
float h; /**< Euler h float data */
float r; /**< Euler r float data */
float p; /**< Euler p float data */
};
/*!
* @brief struct for Linear accel-output data of precision float
*/
struct bno055_linear_accel_float_t
{
float x; /**< Linear accel x float data */
float y; /**< Linear accel y float data */
float z; /**< Linear accel z float data */
};
/*!
* @brief struct for Gravity-output data of precision float
*/
struct bno055_gravity_float_t
{
float x; /**< Gravity x float data */
float y; /**< Gravity y float data */
float z; /**< Gravity z float data */
};
#endif
/*!
* @brief struct for Accel offset
*/
struct bno055_accel_offset_t
{
s16 x; /**< Accel offset x data */
s16 y; /**< Accel offset y data */
s16 z; /**< Accel offset z data */
s16 r; /**< Accel radius r data */
};
/*!
* @brief struct for Gyro offset
*/
struct bno055_gyro_offset_t
{
s16 x; /**< Gyro offset x data */
s16 y; /**< Gyro offset y data */
s16 z; /**< Gyro offset z data */
};
/*!
* @brief struct for Mag offset
*/
struct bno055_mag_offset_t
{
s16 x; /**< Mag offset x data */
s16 y; /**< Mag offset y data */
s16 z; /**< Mag offset z data */
s16 r; /**< Mag radius x data */
};
/*!
* @brief struct for soft iron calibration matrix
*/
struct bno055_sic_matrix_t
{
s16 sic_0; /**< soft iron calibration matrix 0 data */
s16 sic_1; /**< soft iron calibration matrix 1 data */
s16 sic_2; /**< soft iron calibration matrix 2 data */
s16 sic_3; /**< soft iron calibration matrix 3 data */
s16 sic_4; /**< soft iron calibration matrix 4 data */
s16 sic_5; /**< soft iron calibration matrix 5 data */
s16 sic_6; /**< soft iron calibration matrix 6 data */
s16 sic_7; /**< soft iron calibration matrix 7 data */
s16 sic_8; /**< soft iron calibration matrix 8 data */
};
/***************************************************/
/**\name CONSTANT DEFINITIONS */
/***************************************************/
#define BNO055_INIT_VALUE ((u8)0)
#define BNO055_GEN_READ_WRITE_LENGTH ((u8)1)
#define BNO055_LSB_MSB_READ_LENGTH ((u8)2)
#define BNO055_MAG_POWER_MODE_RANGE ((u8)4)
#define BNO055_MAG_OPR_MODE_RANGE ((u8)5)
#define BNO055_ACCEL_POWER_MODE_RANGE ((u8)6)
#define BNO055_ACCEL_SLEEP_DURATION_RANGE ((u8)16)
#define BNO055_GYRO_AUTO_SLEEP_DURATION_RANGE ((u8)8)
#define BNO055_ACCEL_GYRO_BW_RANGE ((u8)8)
#define BNO055_MAG_OUTPUT_RANGE ((u8)8)
#define BNO055_ACCEL_RANGE ((u8)5)
#define BNO055_SHIFT_EIGHT_BITS ((u8)8)
#define BNO055_GYRO_RANGE ((u8)5)
#define BNO055_ACCEL_SLEEP_MODE_RANGE ((u8)2)
/* BNO055 API BNO055_ERROR codes */
#define BNO055_E_NULL_PTR ((s8) - 127)
#define BNO055_OUT_OF_RANGE ((s8) - 2)
#define BNO055_SUCCESS ((u8)0)
#define BNO055_ERROR ((s8) - 1)
/* Selection for bit enable and disable */
#define BNO055_BIT_ENABLE (0x01)
#define BNO055_BIT_DISABLE (0x00)
/* Page ID */
#define BNO055_PAGE_ZERO (0X00)
#define BNO055_PAGE_ONE (0X01)
/* Enable the temperature source */
#define BNO055_ACCEL_TEMP_EN (0x00)
#define BNO055_GYRO_TEMP_EN (0x01)
#define BNO055_MCU_TEMP_EN (0x03)
/*Accel unit*/
#define BNO055_ACCEL_UNIT_MSQ (0x00)
#define BNO055_ACCEL_UNIT_MG (0x01)
/*Gyro unit*/
#define BNO055_GYRO_UNIT_DPS (0x00)
#define BNO055_GYRO_UNIT_RPS (0x01)
/* Euler unit*/
#define BNO055_EULER_UNIT_DEG (0x00)
#define BNO055_EULER_UNIT_RAD (0x01)
/*Temperature unit*/
#define BNO055_TEMP_UNIT_CELSIUS (0x00)
#define BNO055_TEMP_UNIT_FAHRENHEIT (0x01)
/*Accel division factor*/
#define BNO055_ACCEL_DIV_MSQ (100.0)
#define BNO055_ACCEL_DIV_MG (1.0)
/*Mag division factor*/
#define BNO055_MAG_DIV_UT (16.0)
/*Gyro division factor*/
#define BNO055_GYRO_DIV_DPS (16.0)
#define BNO055_GYRO_DIV_RPS (900.0)
/*Euler division factor*/
#define BNO055_EULER_DIV_DEG (16.0)
#define BNO055_EULER_DIV_RAD (900.0)
/*Linear accel division factor*/
#define BNO055_LINEAR_ACCEL_DIV_MSQ (100.0)
/*Gravity accel division factor*/
#define BNO055_GRAVITY_DIV_MSQ (100.0)
/* Temperature division factor*/
#define BNO055_TEMP_DIV_FAHRENHEIT (0.5)
#define BNO055_TEMP_DIV_CELSIUS (1.0)
#define BNO055_MODE_SWITCHING_DELAY (600)
#define BNO055_CONFIG_MODE_SWITCHING_DELAY ((u8)20)
/* Operation mode settings*/
#define BNO055_OPERATION_MODE_CONFIG (0X00)
#define BNO055_OPERATION_MODE_ACCONLY (0X01)
#define BNO055_OPERATION_MODE_MAGONLY (0X02)
#define BNO055_OPERATION_MODE_GYRONLY (0X03)
#define BNO055_OPERATION_MODE_ACCMAG (0X04)
#define BNO055_OPERATION_MODE_ACCGYRO (0X05)
#define BNO055_OPERATION_MODE_MAGGYRO (0X06)
#define BNO055_OPERATION_MODE_AMG (0X07)
#define BNO055_OPERATION_MODE_IMUPLUS (0X08)
#define BNO055_OPERATION_MODE_COMPASS (0X09)
#define BNO055_OPERATION_MODE_M4G (0X0A)
#define BNO055_OPERATION_MODE_NDOF_FMC_OFF (0X0B)
#define BNO055_OPERATION_MODE_NDOF (0X0C)
/* Power mode*/
#define BNO055_POWER_MODE_NORMAL (0X00)
#define BNO055_POWER_MODE_LOWPOWER (0X01)
#define BNO055_POWER_MODE_SUSPEND (0X02)
/* PAGE-1 definitions*/
/* Accel Range */
#define BNO055_ACCEL_RANGE_2G (0X00)
#define BNO055_ACCEL_RANGE_4G (0X01)
#define BNO055_ACCEL_RANGE_8G (0X02)
#define BNO055_ACCEL_RANGE_16G (0X03)
/* Accel Bandwidth*/
#define BNO055_ACCEL_BW_7_81HZ (0x00)
#define BNO055_ACCEL_BW_15_63HZ (0x01)
#define BNO055_ACCEL_BW_31_25HZ (0x02)
#define BNO055_ACCEL_BW_62_5HZ (0X03)
#define BNO055_ACCEL_BW_125HZ (0X04)
#define BNO055_ACCEL_BW_250HZ (0X05)
#define BNO055_ACCEL_BW_500HZ (0X06)
#define BNO055_ACCEL_BW_1000HZ (0X07)
/* Accel Power mode*/
#define BNO055_ACCEL_NORMAL (0X00)
#define BNO055_ACCEL_SUSPEND (0X01)
#define BNO055_ACCEL_LOWPOWER_1 (0X02)
#define BNO055_ACCEL_STANDBY (0X03)
#define BNO055_ACCEL_LOWPOWER_2 (0X04)
#define BNO055_ACCEL_DEEPSUSPEND (0X05)
/* Mag data output rate*/
#define BNO055_MAG_DATA_OUTRATE_2HZ (0X00)
#define BNO055_MAG_DATA_OUTRATE_6HZ (0X01)
#define BNO055_MAG_DATA_OUTRATE_8HZ (0X02)
#define BNO055_MAG_DATA_OUTRATE_10HZ (0X03)
#define BNO055_MAG_DATA_OUTRATE_15HZ (0X04)
#define BNO055_MAG_DATA_OUTRATE_20HZ (0X05)
#define BNO055_MAG_DATA_OUTRATE_25HZ (0X06)
#define BNO055_MAG_DATA_OUTRATE_30HZ (0X07)
/* Mag Operation mode*/
#define BNO055_MAG_OPERATION_MODE_LOWPOWER (0X00)
#define BNO055_MAG_OPERATION_MODE_REGULAR (0X01)
#define BNO055_MAG_OPERATION_MODE_ENHANCED_REGULAR (0X02)
#define BNO055_MAG_OPERATION_MODE_HIGH_ACCURACY (0X03)
/* Mag power mode*/
#define BNO055_MAG_POWER_MODE_NORMAL (0X00)
#define BNO055_MAG_POWER_MODE_SLEEP (0X01)
#define BNO055_MAG_POWER_MODE_SUSPEND (0X02)
#define BNO055_MAG_POWER_MODE_FORCE_MODE (0X03)
/* Gyro range*/
#define BNO055_GYRO_RANGE_2000DPS (0x00)
#define BNO055_GYRO_RANGE_1000DPS (0x01)
#define BNO055_GYRO_RANGE_500DPS (0x02)
#define BNO055_GYRO_RANGE_250DPS (0x03)
#define BNO055_GYRO_RANGE_125DPS (0x04)
/* Gyro Bandwidth*/
#define BNO055_GYRO_BW_523HZ (0x00)
#define BNO055_GYRO_BW_230HZ (0x01)
#define BNO055_GYRO_BW_116HZ (0x02)
#define BNO055_GYRO_BW_47HZ (0x03)
#define BNO055_GYRO_BW_23HZ (0x04)
#define BNO055_GYRO_BW_12HZ (0x05)
#define BNO055_GYRO_BW_64HZ (0x06)
#define BNO055_GYRO_BW_32HZ (0x07)
/* Gyro power mode*/
#define BNO055_GYRO_POWER_MODE_NORMAL (0X00)
#define BNO055_GYRO_POWER_MODE_FASTPOWERUP (0X01)
#define BNO055_GYRO_POWER_MODE_DEEPSUSPEND (0X02)
#define BNO055_GYRO_POWER_MODE_SUSPEND (0X03)
#define BNO055_GYRO_POWER_MODE_ADVANCE_POWERSAVE (0X04)
/* Accel Sleep Duration */
#define BNO055_ACCEL_SLEEP_DURN_0_5MS (0x05)
/* sets sleep duration to 0.5 ms */
#define BNO055_ACCEL_SLEEP_DURN_1MS (0x06)
/* sets sleep duration to 1 ms */
#define BNO055_ACCEL_SLEEP_DURN_2MS (0x07)
/* sets sleep duration to 2 ms */
#define BNO055_ACCEL_SLEEP_DURN_4MS (0x08)
/* sets sleep duration to 4 ms */
#define BNO055_ACCEL_SLEEP_DURN_6MS (0x09)
/* sets sleep duration to 6 ms*/
#define BNO055_ACCEL_SLEEP_DURN_10MS (0x0A)
/* sets sleep duration to 10 ms */
#define BNO055_ACCEL_SLEEP_DURN_25MS (0x0B)
/* sets sleep duration to 25 ms */
#define BNO055_ACCEL_SLEEP_DURN_50MS (0x0C)
/* sets sleep duration to 50 ms */
#define BNO055_ACCEL_SLEEP_DURN_100MS (0x0D)
/* sets sleep duration to 100 ms */
#define BNO055_ACCEL_SLEEP_DURN_500MS (0x0E)
/* sets sleep duration to 500 ms */
#define BNO055_ACCEL_SLEEP_DURN_1S (0x0F)
/* sets sleep duration to 1 s */
/* Gyro Auto sleep duration*/
#define BNO055_GYRO_No_AUTOSLPDUR (0x00)
#define BNO055_GYRO_4MS_AUTOSLPDUR (0x01)
#define BNO055_GYRO_5MS_AUTOSLPDUR (0x02)
#define BNO055_GYRO_8MS_AUTOSLPDUR (0x03)
#define BNO055_GYRO_10MS_AUTOSLPDUR (0x04)
#define BNO055_GYRO_15MS_AUTOSLPDUR (0x05)
#define BNO055_GYRO_20MS_AUTOSLPDUR (0x06)
#define BNO055_GYRO_40MS_AUTOSLPDUR (0x07)
/* Accel Any/No motion axis selection*/
#define BNO055_ACCEL_ANY_MOTION_NO_MOTION_X_AXIS (0)
#define BNO055_ACCEL_ANY_MOTION_NO_MOTION_Y_AXIS (1)
#define BNO055_ACCEL_ANY_MOTION_NO_MOTION_Z_AXIS (2)
/* Accel High g axis selection*/
#define BNO055_ACCEL_HIGH_G_X_AXIS (0)
#define BNO055_ACCEL_HIGH_G_Y_AXIS (1)
#define BNO055_ACCEL_HIGH_G_Z_AXIS (2)
/* Gyro Any motion axis selection*/
#define BNO055_GYRO_ANY_MOTION_X_AXIS (0)
#define BNO055_GYRO_ANY_MOTION_Y_AXIS (1)
#define BNO055_GYRO_ANY_MOTION_Z_AXIS (2)