Skip to content

Commit

Permalink
fixes arduino-libraries#4 by parameterising interrupt and reset pins,…
Browse files Browse the repository at this point in the history
… and setting the defaults to the pins mapped to modern shields
  • Loading branch information
trullock committed Nov 18, 2019
1 parent 2f096fe commit eacc6e9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=9 Axes Motion
version=1.1.0
version=1.2.0
author=Bosch Sensortec GmbH
maintainer=Arduino <[email protected]>
sentence=Arduino 9 Axes Motion Shield Library
Expand Down
10 changes: 8 additions & 2 deletions src/NineAxesMotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ NineAxesMotion::NineAxesMotion()

/*******************************************************************************************
*Description: Function with the bare minimum initialization
*Input Parameters: None
*Input Parameters:
unsigned int address: I2C address of the BNO055. Default 0x28
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)
int reset_pin: GPIO to reset the BNO055 (RESET pin has to be HIGH for the BNO055 to operate)
*Return Parameter: None
*******************************************************************************************/
void NineAxesMotion::initSensor(unsigned int address)
void NineAxesMotion::initSensor(unsigned int address, int int_pin, int reset_pin)
{
INT_PIN = int_pin;
RESET_PIN = reset_pin;

//Initialize the GPIO peripheral
pinMode(INT_PIN, INPUT_PULLUP); //Configure Interrupt pin
pinMode(RESET_PIN, OUTPUT); //Configure Reset pin
Expand Down
26 changes: 14 additions & 12 deletions src/NineAxesMotion.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,16 @@ struct bno055_accel_stat_t {
uint8_t powerMode; //Power mode: Normal - Deep suspend
};

//GPIO pins used for controlling the Sensor
#define RESET_PIN 4 //GPIO to reset the BNO055 (RESET pin has to be HIGH for the BNO055 to operate)

#if defined(__AVR_ATmega32U4__) //Arduino Yun and Leonardo
#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)
#elif defined(ARDUINO_ARCH_SAM) //INT_PIN is the interrupt number not the interrupt pin
#define INT_PIN 2
#elif defined(ARDUINO_ARCH_SAMD)
#define INT_PIN 7
//GPIO to reset the BNO055 (RESET pin has to be HIGH for the BNO055 to operate)
int RESET_PIN = 7; // 7 or 4 are most likely candidate pins

//GPIO to receive the Interrupt from the BNO055 (Interrupt is visible on the INT LED on the Shield)
#if defined(__AVR_ATmega32U4__) //Arduino Yun and Leonardo have I2C shared with pins 2 and 3
int INT_PIN = 7;
#elif defined(ARDUINO_SAMD)
int INT_PIN = 7; // Older SAMD boards have NMI mapped on pin 2
#else
#define INT_PIN 0
int INT_PIN = 2;
#endif

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

/*******************************************************************************************
*Description: Function with the bare minimum initialization
*Input Parameters: None
*Input Parameters:
unsigned int address: I2C address of the BNO055. Default 0x28
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)
int reset_pin: GPIO to reset the BNO055 (RESET pin has to be HIGH for the BNO055 to operate)
*Return Parameter: None
*******************************************************************************************/
void initSensor(unsigned int address = 0x28);
void initSensor(unsigned int address = 0x28, int int_pin = 2, int reset_pin = 7);

/*******************************************************************************************
*Description: This function is used to reset the BNO055
Expand Down

0 comments on commit eacc6e9

Please sign in to comment.