Skip to content

Commit eacc6e9

Browse files
committed
fixes arduino-libraries#4 by parameterising interrupt and reset pins, and setting the defaults to the pins mapped to modern shields
1 parent 2f096fe commit eacc6e9

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=9 Axes Motion
2-
version=1.1.0
2+
version=1.2.0
33
author=Bosch Sensortec GmbH
44
maintainer=Arduino <[email protected]>
55
sentence=Arduino 9 Axes Motion Shield Library

src/NineAxesMotion.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,17 @@ NineAxesMotion::NineAxesMotion()
6565

6666
/*******************************************************************************************
6767
*Description: Function with the bare minimum initialization
68-
*Input Parameters: None
68+
*Input Parameters:
69+
unsigned int address: I2C address of the BNO055. Default 0x28
70+
int int_pin: GPIO to receive the Interrupt from the BNO055 for the Arduino Uno (Interrupt is visible on the INT LED on the Shield)
71+
int reset_pin: GPIO to reset the BNO055 (RESET pin has to be HIGH for the BNO055 to operate)
6972
*Return Parameter: None
7073
*******************************************************************************************/
71-
void NineAxesMotion::initSensor(unsigned int address)
74+
void NineAxesMotion::initSensor(unsigned int address, int int_pin, int reset_pin)
7275
{
76+
INT_PIN = int_pin;
77+
RESET_PIN = reset_pin;
78+
7379
//Initialize the GPIO peripheral
7480
pinMode(INT_PIN, INPUT_PULLUP); //Configure Interrupt pin
7581
pinMode(RESET_PIN, OUTPUT); //Configure Reset pin

src/NineAxesMotion.h

+14-12
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,16 @@ struct bno055_accel_stat_t {
9292
uint8_t powerMode; //Power mode: Normal - Deep suspend
9393
};
9494

95-
//GPIO pins used for controlling the Sensor
96-
#define RESET_PIN 4 //GPIO to reset the BNO055 (RESET pin has to be HIGH for the BNO055 to operate)
97-
98-
#if defined(__AVR_ATmega32U4__) //Arduino Yun and Leonardo
99-
#define INT_PIN 4 //GPIO to receive the Interrupt from the BNO055 for the Arduino Uno(Interrupt is visible on the INT LED on the Shield)
100-
#elif defined(ARDUINO_ARCH_SAM) //INT_PIN is the interrupt number not the interrupt pin
101-
#define INT_PIN 2
102-
#elif defined(ARDUINO_ARCH_SAMD)
103-
#define INT_PIN 7
95+
//GPIO to reset the BNO055 (RESET pin has to be HIGH for the BNO055 to operate)
96+
int RESET_PIN = 7; // 7 or 4 are most likely candidate pins
97+
98+
//GPIO to receive the Interrupt from the BNO055 (Interrupt is visible on the INT LED on the Shield)
99+
#if defined(__AVR_ATmega32U4__) //Arduino Yun and Leonardo have I2C shared with pins 2 and 3
100+
int INT_PIN = 7;
101+
#elif defined(ARDUINO_SAMD)
102+
int INT_PIN = 7; // Older SAMD boards have NMI mapped on pin 2
104103
#else
105-
#define INT_PIN 0
104+
int INT_PIN = 2;
106105
#endif
107106

108107
#define ENABLE 1 //For use in function parameters
@@ -147,10 +146,13 @@ class NineAxesMotion {
147146

148147
/*******************************************************************************************
149148
*Description: Function with the bare minimum initialization
150-
*Input Parameters: None
149+
*Input Parameters:
150+
unsigned int address: I2C address of the BNO055. Default 0x28
151+
int int_pin: GPIO to receive the Interrupt from the BNO055 for the Arduino Uno (Interrupt is visible on the INT LED on the Shield)
152+
int reset_pin: GPIO to reset the BNO055 (RESET pin has to be HIGH for the BNO055 to operate)
151153
*Return Parameter: None
152154
*******************************************************************************************/
153-
void initSensor(unsigned int address = 0x28);
155+
void initSensor(unsigned int address = 0x28, int int_pin = 2, int reset_pin = 7);
154156

155157
/*******************************************************************************************
156158
*Description: This function is used to reset the BNO055

0 commit comments

Comments
 (0)