Statistics
| Branch: | Tag: | Revision:

amiro-lld / include / BNO055 / v1 / alld_BNO055_v1.h @ 5d67f4db

History | View | Annotate | Download (5.025 KB)

1
/*
2
AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2019  Thomas Schöpping et al.
4

5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU Lesser General Public License as pub
7
hed by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10

11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU Lesser General Public License for more details.
15

16
You should have received a copy of the GNU Lesser General Public License
17
along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
*/
19

    
20
/**
21
 * @file    alld_BNO055_v1.h
22
 * @brief   Accelerometer macros and structures.
23
 *
24
 * @addtogroup lld_accel
25
 * @{
26
 */
27

    
28
#ifndef AMIROLLD_BNO055_V1_H
29
#define AMIROLLD_BNO055_V1_H
30

    
31
#include <amiro-lld.h>
32

    
33
#if (defined(AMIROLLD_CFG_BNO055) && (AMIROLLD_CFG_BNO055 == 1)) || defined(__DOXYGEN__)
34

    
35
/******************************************************************************/
36
/* CONSTANTS                                                                  */
37
/******************************************************************************/
38

    
39
/******************************************************************************/
40
/* SETTINGS                                                                   */
41
/******************************************************************************/
42

    
43
/******************************************************************************/
44
/* CHECKS                                                                     */
45
/******************************************************************************/
46

    
47
/******************************************************************************/
48
/* DATA STRUCTURES AND TYPES                                                  */
49
/******************************************************************************/
50

    
51
/**
52
 * @brief The BNO055 mode (sensor, fusion)
53
 */
54
typedef enum {
55
    MOTN_MODE_NONE = 0,
56
    MOTN_MODE_ACC,
57
    MOTN_MODE_GYR,
58
    MOTN_MODE_MAG,
59
    MOTN_MODE_ACC_GYR,
60
    MOTN_MODE_ACC_MAG,
61
    MOTN_MODE_GYRO_MAG,
62
    MOTN_MODE_ACC_GYR_MAG,
63
    MOTN_MODE_IMU,
64
    MOTN_MODE_COMPASS,
65
    MOTN_MODE_M4G,
66
    MOTN_MODE_NDOF
67
} BNO055_Mode;
68

    
69
/**
70
 * @brief The BNO055 unified sample rate settings
71
 */
72
typedef enum {
73
    MOTN_SR_LOW = 0, MOTN_SR_NORMAL, MOTN_SR_HIGHSPEED
74
} BNO055_SampleRate;
75

    
76
/**
77
 * @brief The BNO055 driver struct
78
 */
79
typedef struct {
80
  apalSPIDriver_t* spid;        /**< @brief The SPI Driver */
81
  BNO055_Mode mode;
82
  BNO055_SampleRate sr;
83
} BNO055_Driver;
84

    
85
typedef struct {
86
    int16_t ax;
87
    int16_t ay;
88
    int16_t az;
89
} BNO055_DataAcc;
90

    
91
typedef struct {
92
    int16_t gx;
93
    int16_t gy;
94
    int16_t gz;
95
} BNO055_DataGyr;
96

    
97
typedef struct {
98
    int16_t mx;
99
    int16_t my;
100
    int16_t mz;
101
} BNO055_DataMag;
102

    
103
typedef struct {
104
    int16_t eh;
105
    int16_t er;
106
    int16_t ep;
107
} BNO055_DataEuler;
108

    
109
typedef struct {
110
    int16_t qw;
111
    int16_t qx;
112
    int16_t qy;
113
    int16_t qz;
114
} BNO055_DataQuaternion;
115

    
116
typedef union {
117

    
118
    BNO055_DataEuler euler;
119
    BNO055_DataQuaternion quaternion;
120

    
121
} BNO055_DataFusion;
122

    
123
#define MOTN_DATA_ACC_OFFSET    0
124
#define MOTN_DATA_GYR_OFFSET    6
125
#define MOTN_DATA_MGN_OFFSET    12
126

    
127
typedef struct {
128
    BNO055_DataAcc acc;
129
    BNO055_DataGyr gyr;
130
    BNO055_DataMag mag;
131

    
132
} BNO055_Data;
133

    
134
typedef union {
135
    // 8 Bytes is max from BNO055_DataQuaternion
136
    uint8_t byte[18];
137
    BNO055_Data raw;           // max 18 Byte
138
    BNO055_DataFusion fsn;     // max 8 Byte
139

    
140
} BNO055_DataUnion;
141

    
142

    
143
/******************************************************************************/
144
/* MACROS                                                                     */
145
/******************************************************************************/
146

    
147
/******************************************************************************/
148
/* EXTERN DECLARATIONS                                                        */
149
/******************************************************************************/
150

    
151
#ifdef __cplusplus
152
extern "C" {
153
#endif
154

    
155
 
156
  apalExitStatus_t BNO055_lld_init(const BNO055_Driver* const bno);
157

    
158
  apalExitStatus_t BNO055_lld_set_mode(const BNO055_Mode mode, const BNO055_SampleRate sr);
159
  apalExitStatus_t BNO055_lld_get_data(const BNO055_DataUnion* const dto);
160
  
161
 
162

    
163
  //TODO add more fancy functions to do more fancy things e.g.
164
  //apalExitStatus_t BNO055_lld_start_calibration(...)
165

    
166
  //apalExitStatus_t BNO055_lld_set_interrupts(...)
167
  //apalExitStatus_t BNO055_lld_enable_interrupts(...)
168
  //apalExitStatus_t BNO055_lld_clear_interrupts()
169

    
170
  
171

    
172
#ifdef __cplusplus
173
}
174
#endif
175

    
176
/******************************************************************************/
177
/* INLINE FUNCTIONS                                                           */
178
/******************************************************************************/
179

    
180
#endif /* defined(AMIROLLD_CFG_BNO055) && (AMIROLLD_CFG_BNO055 == 1) */
181

    
182
#endif /* AMIROLLD_BNO055_V1_H */
183

    
184
/** @} */