Skip to content

Commit 4ecde9a

Browse files
committed
BNO055 with Arduino
1 parent 86cd75c commit 4ecde9a

File tree

13 files changed

+19369
-0
lines changed

13 files changed

+19369
-0
lines changed

BNO055.c

Lines changed: 16137 additions & 0 deletions
Large diffs are not rendered by default.

BNO055.h

Lines changed: 2296 additions & 0 deletions
Large diffs are not rendered by default.

BNO055_support.cpp

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
/*
2+
***************************************************************************
3+
*
4+
* bno055.c - part of sample SW for using BNO055 with Arduino
5+
*
6+
* Usage: BNO055 Sensor Driver Support Source File
7+
*
8+
* (C) All rights reserved by ROBERT BOSCH GMBH
9+
*
10+
* Copyright (C) 2014 Bosch Sensortec GmbH
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU General Public License as published by
14+
* the Free Software Foundation, either version 3 of the License, or
15+
* (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
**************************************************************************/
26+
/* Date: 2014/01/07
27+
* Revision: 1.2
28+
*
29+
*/
30+
31+
#include "BNO055_support.h"
32+
33+
/*****************************************************************************
34+
* Description: *//**\brief
35+
* This function initialises the structure pointer, receives
36+
* and assigns the I2C address.
37+
*
38+
*
39+
*
40+
*
41+
*
42+
* \param bno055_t *bno055 structure pointer.
43+
*
44+
*
45+
*
46+
* \return communication results.
47+
*
48+
*
49+
****************************************************************************/
50+
/* Scheduling:
51+
*
52+
*
53+
*
54+
* Usage guide:
55+
*
56+
*
57+
* Remarks:
58+
*
59+
****************************************************************************/
60+
BNO055_RETURN_FUNCTION_TYPE BNO_Init(struct bno055_t *bno055)
61+
{
62+
63+
BNO055_RETURN_FUNCTION_TYPE comres = BNO055_Zero_U8X;
64+
//Link the function pointers for communication (late-binding)
65+
bno055->bus_read = BNO055_I2C_bus_read;
66+
bno055->bus_write = BNO055_I2C_bus_write;
67+
bno055->delay_msec = _delay;
68+
//Initialization from the BNO055 API
69+
comres = bno055_init(bno055);
70+
return comres;
71+
72+
}
73+
74+
75+
76+
77+
/*****************************************************************************
78+
* Description: *//**\brief
79+
* This function is called when data has to be read over the I2C bus
80+
*
81+
*
82+
*
83+
*
84+
*
85+
* \param unsigned char dev_addr holds the device address
86+
* unsigned char reg_addr holds the register address
87+
* unsigned char *reg_data holds the pointer for the start of the
88+
* data structure
89+
* unsigned char cnt holds the count of the number of bytes to be
90+
* read
91+
*
92+
*
93+
* \return communication results.
94+
*
95+
*
96+
****************************************************************************/
97+
/* Scheduling:
98+
*
99+
*
100+
*
101+
* Usage guide:
102+
*
103+
*
104+
* Remarks:
105+
*
106+
****************************************************************************/
107+
BNO055_RETURN_FUNCTION_TYPE BNO055_I2C_bus_read(unsigned char dev_addr,unsigned char reg_addr, unsigned char *reg_data, unsigned char cnt)
108+
{
109+
BNO055_RETURN_FUNCTION_TYPE comres = BNO055_Zero_U8X;
110+
Wire.beginTransmission(dev_addr); //Start of transmission
111+
Wire.write(reg_addr); //Desired start register
112+
Wire.endTransmission(); //Stop of transmission
113+
delayMicroseconds(150);
114+
Wire.requestFrom(dev_addr, cnt); //Request data
115+
while(Wire.available()) //The slave device may send less than requested
116+
{
117+
*reg_data = Wire.read(); //Receive a byte
118+
reg_data++; //Increment pointer
119+
}
120+
return comres;
121+
}
122+
123+
124+
125+
126+
127+
/*****************************************************************************
128+
* Description: *//**\brief
129+
* This function is called when data has to be written over
130+
* I2C bus
131+
*
132+
*
133+
*
134+
*
135+
*
136+
* \param unsigned char dev_addr holds the device address
137+
* unsigned char reg_addr holds the register address
138+
* unsigned char *reg_data holds the pointer for the start of the
139+
* data structure
140+
* unsigned char cnt holds the count of the number of bytes to be
141+
* written
142+
*
143+
*
144+
* \return communication results.
145+
*
146+
*
147+
****************************************************************************/
148+
/* Scheduling:
149+
*
150+
*
151+
*
152+
* Usage guide:
153+
*
154+
*
155+
* Remarks:
156+
*
157+
****************************************************************************/
158+
BNO055_RETURN_FUNCTION_TYPE BNO055_I2C_bus_write(unsigned char dev_addr,unsigned char reg_addr, unsigned char *reg_data, unsigned char cnt)
159+
{
160+
BNO055_RETURN_FUNCTION_TYPE comres = BNO055_Zero_U8X;
161+
Wire.beginTransmission(dev_addr); //Start of transmission
162+
Wire.write(reg_addr); //Desired start register
163+
for(unsigned char index = 0; index < cnt; index++)
164+
{
165+
Wire.write(*reg_data); //Write the data
166+
reg_data++; //Increment pointer
167+
}
168+
Wire.endTransmission(); //Stop of transmission
169+
delayMicroseconds(150);
170+
return comres;
171+
}
172+
173+
/*****************************************************************************
174+
* Description: *//**\brief
175+
* This function is a mirror for the delay function for type casting
176+
*
177+
*
178+
*
179+
*
180+
*
181+
* \param unsigned int
182+
*
183+
*
184+
* \return none
185+
*
186+
*
187+
****************************************************************************/
188+
/* Scheduling:
189+
*
190+
*
191+
*
192+
* Usage guide:
193+
*
194+
*
195+
* Remarks:
196+
*
197+
****************************************************************************/
198+
void _delay(unsigned int period)
199+
{
200+
delay(long(period));
201+
}
202+
203+
204+
205+

BNO055_support.h

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
/*
2+
***************************************************************************
3+
*
4+
* bno055_support.h - part of sample SW for using BNO055 with Arduino
5+
*
6+
* Usage: BNO055 Sensor Driver Support header File
7+
*
8+
* (C) All rights reserved by ROBERT BOSCH GMBH
9+
*
10+
* Copyright (C) 2014 Bosch Sensortec GmbH
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU General Public License as published by
14+
* the Free Software Foundation, either version 3 of the License, or
15+
* (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
**************************************************************************/
26+
/* Date: 2014/01/07
27+
* Revision: 1.2
28+
*
29+
*/
30+
31+
#ifndef __BNO055_SUPPORT_H__
32+
#define __BNO055_SUPPORT_H__
33+
34+
extern "C" {
35+
#include "BNO055.h"
36+
}
37+
#include <Wire.h>
38+
#include "Arduino.h"
39+
40+
/*****************************************************************************
41+
* Description: *//**\brief
42+
* This function initialises the structure pointer, receives
43+
* and assigns the I2C address.
44+
*
45+
*
46+
*
47+
*
48+
*
49+
* \param bno055_t *bno055 structure pointer.
50+
*
51+
*
52+
*
53+
* \return communication results.
54+
*
55+
*
56+
****************************************************************************/
57+
/* Scheduling:
58+
*
59+
*
60+
*
61+
* Usage guide:
62+
*
63+
*
64+
* Remarks:
65+
*
66+
****************************************************************************/
67+
BNO055_RETURN_FUNCTION_TYPE BNO_Init(struct bno055_t *);
68+
69+
70+
71+
72+
73+
/*****************************************************************************
74+
* Description: *//**\brief
75+
* This function is called when data has to be read over the I2C bus
76+
*
77+
*
78+
*
79+
*
80+
*
81+
* \param unsigned char dev_addr holds the device address
82+
* unsigned char reg_addr holds the register address
83+
* unsigned char *reg_data holds the pointer for the start of the
84+
* data structure
85+
* unsigned char cnt holds the count of the number of bytes to be
86+
* read
87+
*
88+
*
89+
* \return communication results.
90+
*
91+
*
92+
****************************************************************************/
93+
/* Scheduling:
94+
*
95+
*
96+
*
97+
* Usage guide:
98+
*
99+
*
100+
* Remarks:
101+
*
102+
****************************************************************************/
103+
BNO055_RETURN_FUNCTION_TYPE BNO055_I2C_bus_read(unsigned char,unsigned char, unsigned char*, unsigned char);
104+
105+
106+
107+
108+
109+
110+
/*****************************************************************************
111+
* Description: *//**\brief
112+
* This function is called when data has to be written over
113+
* I2C bus
114+
*
115+
*
116+
*
117+
*
118+
*
119+
* \param unsigned char dev_addr holds the device address
120+
* unsigned char reg_addr holds the register address
121+
* unsigned char *reg_data holds the pointer for the start of the
122+
* data structure
123+
* unsigned char cnt holds the count of the number of bytes to be
124+
* written
125+
*
126+
*
127+
* \return communication results.
128+
*
129+
*
130+
****************************************************************************/
131+
/* Scheduling:
132+
*
133+
*
134+
*
135+
* Usage guide:
136+
*
137+
*
138+
* Remarks:
139+
*
140+
****************************************************************************/
141+
BNO055_RETURN_FUNCTION_TYPE BNO055_I2C_bus_write(unsigned char ,unsigned char , unsigned char* , unsigned char );
142+
143+
/*****************************************************************************
144+
* Description: *//**\brief
145+
* This function is a mirror for the delay function for type casting
146+
*
147+
*
148+
*
149+
*
150+
*
151+
* \param unsigned int
152+
*
153+
*
154+
* \return none
155+
*
156+
*
157+
****************************************************************************/
158+
/* Scheduling:
159+
*
160+
*
161+
*
162+
* Usage guide:
163+
*
164+
*
165+
* Remarks:
166+
*
167+
****************************************************************************/
168+
void _delay(unsigned int);
169+
#endif
170+
171+
172+
173+
174+

README.md

1.44 KB

BNO055

BNO055

Sample SW for using BNO055 with Arduino

(C) All rights reserved by ROBERT BOSCH GMBH

Copyright (C) 2014 Bosch Sensortec GmbH

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

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

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

0 commit comments

Comments
 (0)