Skip to content

Commit

Permalink
init repo
Browse files Browse the repository at this point in the history
  • Loading branch information
South-River authored Apr 25, 2022
1 parent 4c8c757 commit 333e7a7
Show file tree
Hide file tree
Showing 8 changed files with 2,618 additions and 0 deletions.
74 changes: 74 additions & 0 deletions examples/BASIC_I2C/Basic_I2C.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Nanhe Chen
* [email protected]
*
* Copyright (c) 2022 High Performance IMU BMI085
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include "BMI085.h"

/* accel object */
BMI088Accel accel(Wire,0x18);
/* gyro object */
BMI088Gyro gyro(Wire,0x68);

void setup()
{
int status;
/* USB Serial to print data */
Serial.begin(115200);
while(!Serial) {}
/* start the sensors */
status = accel.begin();
if (status < 0) {
Serial.println("Accel Initialization Error");
Serial.println(status);
while (1) {}
}
status = gyro.begin();
if (status < 0) {
Serial.println("Gyro Initialization Error");
Serial.println(status);
while (1) {}
}
}

void loop()
{
/* read the accel */
accel.readSensor();
/* read the gyro */
gyro.readSensor();
/* print the data */
Serial.print(accel.getAccelX_mss());
Serial.print("\t");
Serial.print(accel.getAccelY_mss());
Serial.print("\t");
Serial.print(accel.getAccelZ_mss());
Serial.print("\t");
Serial.print(gyro.getGyroX_rads());
Serial.print("\t");
Serial.print(gyro.getGyroY_rads());
Serial.print("\t");
Serial.print(gyro.getGyroZ_rads());
Serial.print("\t");
Serial.print(accel.getTemperature_C());
Serial.print("\n");
/* delay to help with printing */
delay(20);
}
74 changes: 74 additions & 0 deletions examples/BASIC_SPI/Basic_SPI.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Nanhe Chen
* [email protected]
*
* Copyright (c) 2022 High Performance IMU BMI085
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include "BMI085.h"

/* accel object */
BMI085Accel accel(SPI,10);
/* gyro object */
BMI085Gyro gyro(SPI,9);

void setup()
{
int status;
/* USB Serial to print data */
Serial.begin(115200);
while(!Serial) {}
/* start the sensors */
status = accel.begin();
if (status < 0) {
Serial.println("Accel Initialization Error");
Serial.println(status);
while (1) {}
}
status = gyro.begin();
if (status < 0) {
Serial.println("Gyro Initialization Error");
Serial.println(status);
while (1) {}
}
}

void loop()
{
/* read the accel */
accel.readSensor();
/* read the gyro */
gyro.readSensor();
/* print the data */
Serial.print(accel.getAccelX_mss());
Serial.print("\t");
Serial.print(accel.getAccelY_mss());
Serial.print("\t");
Serial.print(accel.getAccelZ_mss());
Serial.print("\t");
Serial.print(gyro.getGyroX_rads());
Serial.print("\t");
Serial.print(gyro.getGyroY_rads());
Serial.print("\t");
Serial.print(gyro.getGyroZ_rads());
Serial.print("\t");
Serial.print(accel.getTemperature_C());
Serial.print("\n");
/* delay to help with printing */
delay(20);
}
101 changes: 101 additions & 0 deletions examples/Int_I2C/Int_I2C.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Nanhe Chen
* [email protected]
*
* Copyright (c) 2022 High Performance IMU BMI085
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include "BMI085.h"

/* accel object */
BMI085Accel accel(Wire,0x18);
/* gyro object */
BMI085Gyro gyro(Wire,0x68);

volatile bool accel_flag, gyro_flag;

void accel_drdy()
{
accel_flag = true;
}

void gyro_drdy()
{
gyro_flag = true;
}

void setup()
{
int status;
/* USB Serial to print data */
Serial.begin(115200);
while(!Serial) {}
/* start the sensors */
status = accel.begin();
if (status < 0) {
Serial.println("Accel Initialization Error");
Serial.println(status);
while (1) {}
}
status = accel.setOdr(BMI085Accel::ODR_100HZ_BW_19HZ);
status = accel.pinModeInt1(BMI085Accel::PUSH_PULL,BMI085Accel::ACTIVE_HIGH);
status = accel.mapDrdyInt1(true);


status = gyro.begin();
if (status < 0) {
Serial.println("Gyro Initialization Error");
Serial.println(status);
while (1) {}
}
status = gyro.setOdr(BMI085Gyro::ODR_100HZ_BW_12HZ);
status = gyro.pinModeInt3(BMI085Gyro::PUSH_PULL,BMI085Gyro::ACTIVE_HIGH);
status = gyro.mapDrdyInt3(true);

pinMode(3,INPUT);
attachInterrupt(3,accel_drdy,RISING);
pinMode(4,INPUT);
attachInterrupt(4,gyro_drdy,RISING);
}

void loop()
{
if (accel_flag && gyro_flag) {
accel_flag = false;
gyro_flag = false;
/* read the accel */
accel.readSensor();
/* read the gyro */
gyro.readSensor();
/* print the data */
Serial.print(accel.getAccelX_mss());
Serial.print("\t");
Serial.print(accel.getAccelY_mss());
Serial.print("\t");
Serial.print(accel.getAccelZ_mss());
Serial.print("\t");
Serial.print(gyro.getGyroX_rads());
Serial.print("\t");
Serial.print(gyro.getGyroY_rads());
Serial.print("\t");
Serial.print(gyro.getGyroZ_rads());
Serial.print("\t");
Serial.print(accel.getTemperature_C());
Serial.print("\n");
}
}
107 changes: 107 additions & 0 deletions examples/Sync_SPI/Sync_SPI.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* Nanhe Chen
* [email protected]
*
* Copyright (c) 2022 High Performance IMU BMI085
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include "BMI085.h"

/* BMI085 object */
BMI085 bmi(SPI,10,9);

void drdy()
{
/* read the imu */
bmi.readSensor();
/* print the data */
Serial.print(bmi.getAccelX_mss());
Serial.print("\t");
Serial.print(bmi.getAccelY_mss());
Serial.print("\t");
Serial.print(bmi.getAccelZ_mss());
Serial.print("\t");
Serial.print(bmi.getGyroX_rads());
Serial.print("\t");
Serial.print(bmi.getGyroY_rads());
Serial.print("\t");
Serial.print(bmi.getGyroZ_rads());
Serial.print("\t");
Serial.print(bmi.getTemperature_C());
Serial.print("\n");
}

void setup()
{
int status;
/* USB Serial to print data */
Serial.begin(115200);
while(!Serial) {}
/* start the sensors */
status = bmi.begin();
if (status < 0) {
Serial.println("IMU Initialization Error");
Serial.println(status);
while (1) {}
}
/* set the ranges */
status = bmi.setRange(BMI085::ACCEL_RANGE_6G,BMI085::GYRO_RANGE_500DPS);
if (status < 0) {
Serial.println("Failed to set ranges");
Serial.println(status);
while (1) {}
}
/* set the output data rate */
status = bmi.setOdr(BMI085::ODR_400HZ);
if (status < 0) {
Serial.println("Failed to set ODR");
Serial.println(status);
while (1) {}
}
/* specify whether to use pin 3 or pin 4 to loop back the gyro interrupt */
status = bmi.mapSync(BMI085::PIN_3);
if (status < 0) {
Serial.println("Failed to map sync pin");
Serial.println(status);
while (1) {}
}
/*
* specify whether to use pin 1 or pin 2 to indicate data ready, the other pin will be used
* for gyro interrupt input
*/
status = bmi.mapDrdy(BMI085::PIN_2);
if (status < 0) {
Serial.println("Failed to map data ready pin");
Serial.println(status);
while (1) {}
}
/* set the data ready pin to push-pull and active high */
status = bmi.pinModeDrdy(BMI085::PUSH_PULL,BMI085::ACTIVE_HIGH);
if (status < 0) {
Serial.println("Failed to setup data ready pin");
Serial.println(status);
while (1) {}
}
/* attach the corresponding uC pin to an interrupt */
pinMode(1,INPUT);
attachInterrupt(1,drdy,RISING);
}

void loop()
{
}
28 changes: 28 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Bmi085Accel KEYWORD1
Bmi085Gyro KEYWORD1
Bmi085 KEYWORD1
begin KEYWORD2
setOdr KEYWORD2
setRange KEYWORD2
pinModeInt1 KEYWORD2
pinModeInt2 KEYWORD2
pinModeInt3 KEYWORD2
pinModeInt4 KEYWORD2
mapDrdyInt1 KEYWORD2
mapDrdyInt2 KEYWORD2
mapDrdyInt3 KEYWORD2
mapDrdyInt4 KEYWORD2
mapDrdy KEYWORD2
mapSync KEYWORD2
pinModeDrdy KEYWORD2
getDrdyStatus KEYWORD2
readSensor KEYWORD2
getAccelX_mss KEYWORD2
getAccelY_mss KEYWORD2
getAccelZ_mss KEYWORD2
getGyroX_rads KEYWORD2
getGyroY_rads KEYWORD2
getGyroZ_rads KEYWORD2
getTemperature_C KEYWORD2
getTime_ps KEYWORD2
Loading

0 comments on commit 333e7a7

Please sign in to comment.