├── .gitignore ├── Arduino ├── AD7746 │ ├── AD7746.cpp │ ├── AD7746.h │ └── library.json ├── ADS1115 │ ├── ADS1115.cpp │ ├── ADS1115.h │ ├── examples │ │ ├── ADS1115_differential │ │ │ └── ADS1115_differential.ino │ │ └── ADS1115_single │ │ │ └── ADS1115_single.ino │ └── library.json ├── ADXL345 │ ├── ADXL345.cpp │ ├── ADXL345.h │ ├── examples │ │ └── ADXL345_raw │ │ │ └── ADXL345_raw.ino │ └── library.json ├── AK8963 │ ├── AK8963.cpp │ ├── AK8963.h │ └── library.json ├── AK8975 │ ├── AK8975.cpp │ ├── AK8975.h │ ├── examples │ │ ├── AK8975_MPUEVB_heading │ │ │ └── AK8975_MPUEVB_heading.ino │ │ ├── AK8975_MPUEVB_raw │ │ │ └── AK8975_MPUEVB_raw.ino │ │ └── AK8975_raw │ │ │ └── AK8975_raw.ino │ └── library.json ├── AT30TSE75x │ ├── AT30TSE75x.cpp │ ├── AT30TSE75x.h │ └── Examples │ │ └── AT30TSE75x_basic │ │ └── AT30TSE75x_basic.ino ├── BMA150 │ ├── BMA150.cpp │ ├── BMA150.h │ ├── examples │ │ └── BMA150_raw │ │ │ └── BMA150_raw.ino │ └── library.json ├── BMP085 │ ├── BMP085.cpp │ ├── BMP085.h │ ├── examples │ │ └── BMP085_basic │ │ │ └── BMP085_basic.ino │ └── library.json ├── DS1307 │ ├── DS1307.cpp │ ├── DS1307.h │ ├── examples │ │ ├── DS1307_settime │ │ │ └── DS1307_settime.ino │ │ └── DS1307_tick │ │ │ └── DS1307_tick.ino │ └── library.json ├── HMC5843 │ ├── HMC5843.cpp │ ├── HMC5843.h │ ├── examples │ │ └── HMC5843_raw │ │ │ └── HMC5843_raw.ino │ └── library.json ├── HMC5883L │ ├── HMC5883L.cpp │ ├── HMC5883L.h │ ├── examples │ │ └── HMC5883L_raw │ │ │ └── HMC5883L_raw.ino │ └── library.json ├── HTU21D │ ├── HTU21D.cpp │ ├── HTU21D.h │ ├── examples │ │ └── HTU21D_simple │ │ │ └── HTU21D_simple.ino │ └── library.json ├── I2Cdev │ ├── I2Cdev.cpp │ ├── I2Cdev.h │ ├── keywords.txt │ └── library.json ├── IAQ2000 │ ├── IAQ2000.cpp │ ├── IAQ2000.h │ ├── examples │ │ └── IAQ2000 │ │ │ └── IAQ2000.ino │ ├── keywords.txt │ └── library.json ├── ITG3200 │ ├── ITG3200.cpp │ ├── ITG3200.h │ ├── examples │ │ └── ITG3200_raw │ │ │ └── ITG3200_raw.ino │ └── library.json ├── L3G4200D │ ├── L3G4200D.cpp │ ├── L3G4200D.h │ ├── examples │ │ └── L3G4200D_raw │ │ │ └── L3G4200D_raw.ino │ └── library.json ├── L3GD20H │ ├── L3GD20H.cpp │ ├── L3GD20H.h │ └── examples │ │ └── L3GD20H_basic │ │ └── L3GD20H_basic.ino ├── LM73 │ ├── LM73.cpp │ ├── LM73.h │ └── library.json ├── LSM303DLHC │ ├── LSM303DLHC.cpp │ ├── LSM303DLHC.h │ └── examples │ │ └── LSM303DLHC_test │ │ └── LSM303DLHC_test.ino ├── MPR121 │ ├── MPR121.cpp │ ├── MPR121.h │ └── library.json ├── MPU6050 │ ├── MPU6050.cpp │ ├── MPU6050.h │ ├── MPU6050_6Axis_MotionApps20.cpp │ ├── MPU6050_6Axis_MotionApps20.h │ ├── MPU6050_6Axis_MotionApps612.cpp │ ├── MPU6050_6Axis_MotionApps612.h │ ├── MPU6050_9Axis_MotionApps41.cpp │ ├── MPU6050_9Axis_MotionApps41.h │ ├── examples │ │ ├── IMU_Zero │ │ │ └── IMU_Zero.ino │ │ ├── MPU6050_DMP6 │ │ │ ├── MPU6050_DMP6.ino │ │ │ └── Processing │ │ │ │ └── MPUTeapot │ │ │ │ └── MPUTeapot.pde │ │ ├── MPU6050_DMP6_ESPWiFi │ │ │ ├── MPU6050_DMP6_ESPWiFi.ino │ │ │ └── Processing │ │ │ │ └── MPUOSCTeapot │ │ │ │ └── MPUOSCTeapot.pde │ │ ├── MPU6050_DMP6_Ethernet │ │ │ └── MPU6050_DMP6_Ethernet.ino │ │ ├── MPU6050_DMP6_using_DMP_V6.12 │ │ │ ├── MPU6050_DMP6_using_DMP_V6.12.ino │ │ │ └── MPUplane │ │ │ │ ├── MPUplane.pde │ │ │ │ └── data │ │ │ │ ├── biplane.obj │ │ │ │ └── diffuse_512.png │ │ └── MPU6050_raw │ │ │ └── MPU6050_raw.ino │ ├── helper_3dmath.h │ └── library.json ├── MPU9150 │ ├── Examples │ │ └── MPU9150_DMP9 │ │ │ └── MPU9150_DMP9.ino │ ├── MPU9150.cpp │ ├── MPU9150.h │ ├── MPU9150_9Axis_MotionApps41.h │ ├── examples │ │ └── MPU9150_raw │ │ │ └── MPU9150_raw.ino │ ├── helper_3dmath.h │ └── library.json ├── MPU9250 │ ├── BMP180.cpp │ ├── BMP180.h │ ├── MPU9250.cpp │ ├── MPU9250.h │ ├── README.md │ └── examples │ │ └── IMU_10DOF_Test │ │ └── IMU_10DOF_Test.ino ├── MS5803 │ ├── MS5803.cpp │ ├── MS5803.h │ ├── examples │ │ └── test_MS5803 │ │ │ └── test_MS5803.ino │ └── keywords.txt ├── SSD1308 │ ├── SSD1308.cpp │ ├── SSD1308.h │ ├── example.pde │ ├── fixedWidthFont.h │ └── library.json ├── TCA6424A │ ├── TCA6424A.cpp │ ├── TCA6424A.h │ └── library.json └── _Stub │ ├── _Stub.cpp │ └── _Stub.h ├── BeagleBoneBlack └── I2Cdev │ ├── I2Cdev.cpp │ └── I2Cdev.h ├── EFM32 └── I2Cdev │ ├── I2Cdev.cpp │ └── I2Cdev.h ├── ESP32_ESP-IDF ├── .idea │ ├── ESP32_ESP-IDF.iml │ ├── encodings.xml │ ├── misc.xml │ ├── modules.xml │ ├── vcs.xml │ └── workspace.xml ├── CMakeLists.txt ├── Makefile ├── README.md ├── components │ ├── I2Cdev │ │ ├── CMakeLists.txt │ │ ├── I2Cdev.cpp │ │ ├── I2Cdev.h │ │ └── component.mk │ └── MPU6050 │ │ ├── CMakeLists.txt │ │ ├── MPU6050.cpp │ │ ├── MPU6050.h │ │ ├── MPU6050_6Axis_MotionApps20.h │ │ ├── MPU6050_9Axis_MotionApps41.h │ │ ├── component.mk │ │ └── helper_3dmath.h ├── main │ ├── CMakeLists.txt │ ├── component.mk │ ├── example.cpp │ └── main.cpp ├── sdkconfig └── sdkconfig.old ├── Jennic ├── I2Cdev │ ├── I2Cdev.c │ └── I2Cdev.h ├── MPU6050 │ ├── MPU6050.c │ └── MPU6050.h └── README.md ├── LinuxI2CDev ├── I2Cdev │ ├── I2Cdev.cpp │ └── I2Cdev.h └── MPU6050 │ ├── MPU6050.cpp │ ├── MPU6050.h │ ├── MPU6050_6Axis_MotionApps20.cpp │ ├── MPU6050_6Axis_MotionApps20.h │ └── helper_3dmath.h ├── MSP430 ├── AK8975 │ ├── AK8975.cpp │ ├── AK8975.h │ └── library.json ├── I2Cdev │ ├── ArduinoWrapper.h │ ├── I2Cdev.cpp │ ├── I2Cdev.h │ ├── keywords.txt │ ├── library.json │ ├── msp430_i2c.c │ └── msp430_i2c.h └── MPU6050 │ ├── MPU6050.cpp │ ├── MPU6050.h │ ├── MPU6050_6Axis_MotionApps20.h │ ├── MPU6050_9Axis_MotionApps41.h │ ├── helper_3dmath.h │ └── library.json ├── PIC18 ├── I2Cdev │ ├── I2Cdev.c │ └── I2Cdev.h ├── MPU6050 │ ├── Examples │ │ └── MPU6050_raw.X │ │ │ ├── Makefile │ │ │ ├── funclist │ │ │ ├── l.obj │ │ │ ├── main.c │ │ │ └── nbproject │ │ │ ├── Makefile-default.mk │ │ │ ├── Makefile-genesis.properties │ │ │ ├── Makefile-impl.mk │ │ │ ├── Makefile-local-default.mk │ │ │ ├── Makefile-variables.mk │ │ │ ├── Package-default.bash │ │ │ ├── configurations.xml │ │ │ ├── project.properties │ │ │ └── project.xml │ ├── MPU6050.c │ └── MPU6050.h └── README.md ├── README.md ├── RP2040 ├── I2Cdev │ ├── I2Cdev.cpp │ └── I2Cdev.h └── MPU6050 │ ├── MPU6050.cpp │ ├── MPU6050.h │ ├── MPU6050_6Axis_MotionApps_V6_12.h │ ├── examples │ ├── README.md │ ├── mpu6050_DMP_V6.12 │ │ ├── CMakeLists.txt │ │ ├── mpu6050_DMP_port.cpp │ │ └── pico_sdk_import.cmake │ └── mpu6050_calibration │ │ ├── CMakeLists.txt │ │ ├── mpu6050_calibration.cpp │ │ └── pico_sdk_import.cmake │ └── helper_3dmath.h ├── RaspberryPi_bcm2835 ├── ADXL345 │ └── examples │ │ └── ADXL345_example_1.cpp ├── BMP085 │ └── examples │ │ └── BMP085_basic.cpp ├── HMC5883L │ └── examples │ │ └── HMC5883L_example_1.cpp ├── I2Cdev │ ├── I2Cdev.cpp │ └── I2Cdev.h └── MPU6050 │ ├── MPU6050.cpp │ ├── MPU6050.h │ └── examples │ ├── IMU_zero.cpp │ └── MPU6050_example_1.cpp ├── STM32 ├── HMC5883 │ ├── HMC5883L.c │ └── HMC5883L.h ├── I2Cdev.c ├── I2Cdev.h ├── MPU6050 │ ├── MPU6050.c │ └── MPU6050.h ├── QMC5883L │ ├── QMC5883L.c │ └── QMC5883L.h └── README.md ├── STM32HAL ├── APDS9960 │ ├── APDS9960.c │ ├── APDS9960.h │ └── README.md ├── BMP085 │ ├── BMP085.c │ └── BMP085.h ├── HMC5883L │ ├── HMC5883L.c │ └── HMC5883L.h ├── I2Cdev │ ├── I2Cdev.c │ └── I2Cdev.h ├── MPU6050 │ ├── MPU6050.c │ └── MPU6050.h └── README.md ├── dsPIC30F ├── I2Cdev │ ├── I2Cdev.c │ ├── I2Cdev.h │ └── I2CdevdsPic30F.X │ │ └── nbproject │ │ └── project.xml ├── MPU6050 │ ├── Examples │ │ └── MPU6050_example.X │ │ │ ├── I2Cdev.c │ │ │ ├── I2Cdev.h │ │ │ ├── MPU6050.c │ │ │ ├── MPU6050.h │ │ │ ├── MPU6050_example_main.c │ │ │ ├── Makefile │ │ │ └── nbproject │ │ │ ├── Makefile-default.mk │ │ │ ├── Makefile-genesis.properties │ │ │ ├── Makefile-impl.mk │ │ │ ├── Makefile-local-default.mk │ │ │ ├── Makefile-variables.mk │ │ │ ├── Package-default.bash │ │ │ ├── configurations.xml │ │ │ └── project.xml │ ├── MPU6050.c │ └── MPU6050.h └── README.md └── nRF51 └── I2CDev ├── I2Cdev.cpp └── I2Cdev.h /.gitignore: -------------------------------------------------------------------------------- 1 | PIC18/MPU6050/Examples/MPU6050_raw.X/dist/ 2 | PIC18/MPU6050/Examples/MPU6050_raw.X/nbproject/private/ 3 | PIC18/MPU6050/Examples/MPU6050_raw.X/build/ 4 | *~ 5 | /dsPIC30F/I2Cdev/I2CdevdsPic30F.X/nbproject/private/ 6 | /dsPIC30F/I2Cdev/I2CdevdsPic30F.X/dist/default/ 7 | /dsPIC30F/I2Cdev/testMCC.X/nbproject/private/ 8 | /dsPIC30F/MPU6050/Examples/MPU6050_example.X/nbproject/private/ 9 | /dsPIC30F/MPU6050/Examples/MPU6050_example.X/build/default/ 10 | /dsPIC30F/MPU6050/Examples/MPU6050_example.X/dist/default/ 11 | ESP32_ESP-IDF/build/ 12 | ESP32_ESP-IDF/sdkconfig -------------------------------------------------------------------------------- /Arduino/AD7746/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-AD7746", 3 | "version": "1.0.0", 4 | "keywords": "capacitance, converter, sensor, i2cdevlib, i2c", 5 | "description": "The AD7745/AD7746 are 24-Bit Capacitance-to-Digital Converter with Temperature Sensor", 6 | "include": "Arduino/AD7746", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/ADS1115/examples/ADS1115_differential/ADS1115_differential.ino: -------------------------------------------------------------------------------- 1 | // I2C device class (I2Cdev) demonstration Arduino sketch for ADS1115 class 2 | // Example of reading two differential inputs of the ADS1115 and showing the value in mV 3 | // 06 May 2013 by Frederick Farzanegan (frederick1@farzanegan.org) 4 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 5 | // 6 | // Changelog: 7 | // 2013-05-13 - initial release 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2011 Jeff Rowberg 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | =============================================== 31 | */ 32 | #include "ADS1115.h" 33 | 34 | ADS1115 adc0(ADS1115_DEFAULT_ADDRESS); 35 | 36 | void setup() { 37 | Wire.begin(); // join I2C bus 38 | Serial.begin(19200); // initialize serial communication 39 | Serial.println("Initializing I2C devices..."); 40 | adc0.initialize(); // initialize ADS1115 16 bit A/D chip 41 | 42 | Serial.println("Testing device connections..."); 43 | Serial.println(adc0.testConnection() ? "ADS1115 connection successful" : "ADS1115 connection failed"); 44 | 45 | // To get output from this method, you'll need to turn on the 46 | //#define ADS1115_SERIAL_DEBUG // in the ADS1115.h file 47 | adc0.showConfigRegister(); 48 | 49 | // We're going to do continuous sampling 50 | adc0.setMode(ADS1115_MODE_CONTINUOUS); 51 | } 52 | 53 | void loop() { 54 | 55 | // Sensor is on P0/N1 (pins 4/5) 56 | Serial.println("Sensor 1 ************************"); 57 | // Set the gain (PGA) +/- 1.024v 58 | adc0.setGain(ADS1115_PGA_1P024); 59 | 60 | // Get the number of counts of the accumulator 61 | Serial.print("Counts for sensor 1 is:"); 62 | 63 | // The below method sets the mux and gets a reading. 64 | int sensorOneCounts=adc0.getConversionP0N1(); // counts up to 16-bits 65 | Serial.println(sensorOneCounts); 66 | 67 | // To turn the counts into a voltage, we can use 68 | Serial.print("Voltage for sensor 1 is:"); 69 | Serial.println(sensorOneCounts*adc0.getMvPerCount()); 70 | 71 | Serial.println(); 72 | 73 | 74 | // 2nd sensor is on P2/N3 (pins 6/7) 75 | Serial.println("Sensor 2 ************************"); 76 | // Set the gain (PGA) +/- 0.256v 77 | adc0.setGain(ADS1115_PGA_0P256); 78 | 79 | // Manually set the MUX // could have used the getConversionP* above 80 | adc0.setMultiplexer(ADS1115_MUX_P2_N3); 81 | Serial.print("Counts for sensor 2 is:"); 82 | Serial.println(adc0.getConversion()); 83 | 84 | Serial.print("mVoltage sensor 2 is:"); 85 | Serial.println(adc0.getMilliVolts()); // Convenience method to calculate voltage 86 | 87 | Serial.println(); 88 | 89 | delay(500); 90 | } 91 | 92 | -------------------------------------------------------------------------------- /Arduino/ADS1115/examples/ADS1115_single/ADS1115_single.ino: -------------------------------------------------------------------------------- 1 | // I2C device class (I2Cdev) demonstration Arduino sketch for ADS1115 class 2 | // Example of reading two differential inputs of the ADS1115 and showing the value in mV 3 | // 2016-03-22 by Eadf (https://github.com/eadf) 4 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 5 | // 6 | // Changelog: 7 | // 2016-03-22 - initial release 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2011 Jeff Rowberg 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | =============================================== 31 | */ 32 | 33 | #include "ADS1115.h" 34 | 35 | ADS1115 adc0(ADS1115_DEFAULT_ADDRESS); 36 | 37 | // Wire ADS1115 ALERT/RDY pin to Arduino pin 2 38 | const int alertReadyPin = 2; 39 | 40 | void setup() { 41 | //I2Cdev::begin(); // join I2C bus 42 | Wire.begin(); 43 | Serial.begin(115200); // initialize serial communication 44 | 45 | Serial.println("Testing device connections..."); 46 | Serial.println(adc0.testConnection() ? "ADS1115 connection successful" : "ADS1115 connection failed"); 47 | 48 | adc0.initialize(); // initialize ADS1115 16 bit A/D chip 49 | 50 | // We're going to do single shot sampling 51 | adc0.setMode(ADS1115_MODE_SINGLESHOT); 52 | 53 | // Slow things down so that we can see that the "poll for conversion" code works 54 | adc0.setRate(ADS1115_RATE_8); 55 | 56 | // Set the gain (PGA) +/- 6.144V 57 | // Note that any analog input must be higher than –0.3V and less than VDD +0.3 58 | adc0.setGain(ADS1115_PGA_6P144); 59 | // ALERT/RDY pin will indicate when conversion is ready 60 | 61 | pinMode(alertReadyPin,INPUT_PULLUP); 62 | adc0.setConversionReadyPinMode(); 63 | 64 | // To get output from this method, you'll need to turn on the 65 | //#define ADS1115_SERIAL_DEBUG // in the ADS1115.h file 66 | #ifdef ADS1115_SERIAL_DEBUG 67 | adc0.showConfigRegister(); 68 | Serial.print("HighThreshold="); Serial.println(adc0.getHighThreshold(),BIN); 69 | Serial.print("LowThreshold="); Serial.println(adc0.getLowThreshold(),BIN); 70 | #endif 71 | } 72 | 73 | /** Poll the assigned pin for conversion status 74 | */ 75 | void pollAlertReadyPin() { 76 | for (uint32_t i = 0; i<100000; i++) 77 | if (!digitalRead(alertReadyPin)) return; 78 | Serial.println("Failed to wait for AlertReadyPin, it's stuck high!"); 79 | } 80 | 81 | void loop() { 82 | 83 | // The below method sets the mux and gets a reading. 84 | adc0.setMultiplexer(ADS1115_MUX_P0_NG); 85 | adc0.triggerConversion(); 86 | pollAlertReadyPin(); 87 | Serial.print("A0: "); Serial.print(adc0.getMilliVolts(false)); Serial.print("mV\t"); 88 | 89 | adc0.setMultiplexer(ADS1115_MUX_P1_NG); 90 | adc0.triggerConversion(); 91 | pollAlertReadyPin(); 92 | Serial.print("A1: "); Serial.print(adc0.getMilliVolts(false)); Serial.print("mV\t"); 93 | 94 | adc0.setMultiplexer(ADS1115_MUX_P2_NG); 95 | adc0.triggerConversion(); 96 | pollAlertReadyPin(); 97 | Serial.print("A2: "); Serial.print(adc0.getMilliVolts(false)); Serial.print("mV\t"); 98 | 99 | adc0.setMultiplexer(ADS1115_MUX_P3_NG); 100 | // Do conversion polling via I2C on this last reading: 101 | Serial.print("A3: "); Serial.print(adc0.getMilliVolts(true)); Serial.print("mV"); 102 | 103 | Serial.println(digitalRead(alertReadyPin)); 104 | delay(500); 105 | } 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /Arduino/ADS1115/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-ADS1115", 3 | "version": "1.0.0", 4 | "keywords": "MUX, PGA, comparator, oscillator, reference, i2cdevlib, i2c", 5 | "description": "ADS1115 is 16-Bit ADC with Integrated MUX, PGA, Comparator, Oscillator, and Reference", 6 | "include": "Arduino/ADS1115", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/ADXL345/examples/ADXL345_raw/ADXL345_raw.ino: -------------------------------------------------------------------------------- 1 | // I2C device class (I2Cdev) demonstration Arduino sketch for ADXL345 class 2 | // 10/7/2011 by Jeff Rowberg 3 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 4 | // 5 | // Changelog: 6 | // 2011-10-07 - initial release 7 | 8 | /* ============================================ 9 | I2Cdev device library code is placed under the MIT license 10 | Copyright (c) 2011 Jeff Rowberg 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of this software and associated documentation files (the "Software"), to deal 14 | in the Software without restriction, including without limitation the rights 15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | copies of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in 20 | all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | THE SOFTWARE. 29 | =============================================== 30 | */ 31 | 32 | // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation 33 | // is used in I2Cdev.h 34 | #include "Wire.h" 35 | 36 | // I2Cdev and ADXL345 must be installed as libraries, or else the .cpp/.h files 37 | // for both classes must be in the include path of your project 38 | #include "I2Cdev.h" 39 | #include "ADXL345.h" 40 | 41 | // class default I2C address is 0x53 42 | // specific I2C addresses may be passed as a parameter here 43 | // ALT low = 0x53 (default for SparkFun 6DOF board) 44 | // ALT high = 0x1D 45 | ADXL345 accel; 46 | 47 | int16_t ax, ay, az; 48 | 49 | #define LED_PIN 13 // (Arduino is 13, Teensy is 6) 50 | bool blinkState = false; 51 | 52 | void setup() { 53 | // join I2C bus (I2Cdev library doesn't do this automatically) 54 | Wire.begin(); 55 | 56 | // initialize serial communication 57 | // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but 58 | // it's really up to you depending on your project) 59 | Serial.begin(38400); 60 | 61 | // initialize device 62 | Serial.println("Initializing I2C devices..."); 63 | accel.initialize(); 64 | 65 | // verify connection 66 | Serial.println("Testing device connections..."); 67 | Serial.println(accel.testConnection() ? "ADXL345 connection successful" : "ADXL345 connection failed"); 68 | 69 | // configure LED for output 70 | pinMode(LED_PIN, OUTPUT); 71 | } 72 | 73 | void loop() { 74 | // read raw accel measurements from device 75 | accel.getAcceleration(&ax, &ay, &az); 76 | 77 | // display tab-separated accel x/y/z values 78 | Serial.print("accel:\t"); 79 | Serial.print(ax); Serial.print("\t"); 80 | Serial.print(ay); Serial.print("\t"); 81 | Serial.println(az); 82 | 83 | // blink LED to indicate activity 84 | blinkState = !blinkState; 85 | digitalWrite(LED_PIN, blinkState); 86 | } 87 | -------------------------------------------------------------------------------- /Arduino/ADXL345/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-ADXL345", 3 | "version": "1.0.0", 4 | "keywords": "accelerometer, sensor, i2cdevlib, i2c", 5 | "description": "The ADXL345 is a small, thin, ultralow power, 3-axis accelerometer with high resolution (13-bit) measurement", 6 | "include": "Arduino/ADXL345", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/AK8963/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-AK8963", 3 | "version": "1.0.0", 4 | "keywords": "compass, sensor, i2cdevlib, i2c", 5 | "description": "AK8963 is 3-axis electronic compass IC with high sensitive Hall sensor technology", 6 | "include": "Arduino/AK8963", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/AK8975/examples/AK8975_MPUEVB_raw/AK8975_MPUEVB_raw.ino: -------------------------------------------------------------------------------- 1 | // I2C device class (I2Cdev) demonstration Arduino sketch for AK8975 class 2 | // 10/7/2011 by Jeff Rowberg 3 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 4 | // 5 | // This example uses the AK8975 as mounted on the InvenSense MPU-6050 Evaluation 6 | // Board, and as such also depends (minimally) on the MPU6050 library from the 7 | // I2Cdevlib collection. It initializes the MPU6050 and immediately enables its 8 | // "I2C Bypass" mode, which allows the sketch to communicate with the AK8975 9 | // that is attached to the MPU's AUX SDA/SCL lines. The AK8975 is configured on 10 | // this board to use the 0x0E address. 11 | // 12 | // Note that this small demo does not make use of any of the MPU's amazing 13 | // motion processing capabilities (the DMP); it only provides raw sensor access 14 | // to the compass as mounted on that particular evaluation board. 15 | // 16 | // For more info on the MPU-6050 and some more impressive demos, check out the 17 | // device page on the I2Cdevlib website: 18 | // http://www.i2cdevlib.com/devices/mpu6050 19 | // 20 | // Changelog: 21 | // 2011-10-07 - initial release 22 | 23 | /* ============================================ 24 | I2Cdev device library code is placed under the MIT license 25 | Copyright (c) 2011 Jeff Rowberg 26 | 27 | Permission is hereby granted, free of charge, to any person obtaining a copy 28 | of this software and associated documentation files (the "Software"), to deal 29 | in the Software without restriction, including without limitation the rights 30 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 31 | copies of the Software, and to permit persons to whom the Software is 32 | furnished to do so, subject to the following conditions: 33 | 34 | The above copyright notice and this permission notice shall be included in 35 | all copies or substantial portions of the Software. 36 | 37 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 38 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 39 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 40 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 41 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 42 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 43 | THE SOFTWARE. 44 | =============================================== 45 | */ 46 | 47 | // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation 48 | // is used in I2Cdev.h 49 | #include "Wire.h" 50 | 51 | // I2Cdev, AK8975, and MPU6050 must be installed as libraries, or else the 52 | // .cpp/.h files for all classes must be in the include path of your project 53 | #include "I2Cdev.h" 54 | #include "AK8975.h" 55 | #include "MPU6050.h" 56 | 57 | // class default I2C address is 0x0C 58 | // specific I2C addresses may be passed as a parameter here 59 | // Addr pins low/low = 0x0C 60 | // Addr pins low/high = 0x0D 61 | // Addr pins high/low = 0x0E (default for InvenSense MPU6050 evaluation board) 62 | // Addr pins high/high = 0x0F 63 | AK8975 mag(0x0E); 64 | MPU6050 accelgyro; // address = 0x68, the default, on MPU6050 EVB 65 | 66 | int16_t mx, my, mz; 67 | 68 | #define LED_PIN 13 69 | bool blinkState = false; 70 | 71 | void setup() { 72 | // join I2C bus (I2Cdev library doesn't do this automatically) 73 | Wire.begin(); 74 | 75 | // initialize serial communication 76 | // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but 77 | // it's really up to you depending on your project) 78 | Serial.begin(38400); 79 | 80 | // initialize devices 81 | Serial.println("Initializing I2C devices..."); 82 | 83 | // initialize MPU first so we can switch to the AUX lines 84 | accelgyro.initialize(); 85 | accelgyro.setI2CBypassEnabled(true); 86 | mag.initialize(); 87 | 88 | // verify connection 89 | Serial.println("Testing device connections..."); 90 | Serial.println(mag.testConnection() ? "AK8975 connection successful" : "AK8975 connection failed"); 91 | 92 | // configure Arduino LED pin for output 93 | pinMode(LED_PIN, OUTPUT); 94 | } 95 | 96 | void loop() { 97 | // read raw heading measurements from device 98 | mag.getHeading(&mx, &my, &mz); 99 | 100 | // display tab-separated gyro x/y/z values 101 | Serial.print("mag:\t"); 102 | Serial.print(mx); Serial.print("\t"); 103 | Serial.print(my); Serial.print("\t"); 104 | Serial.println(mz); 105 | 106 | // blink LED to indicate activity 107 | blinkState = !blinkState; 108 | digitalWrite(LED_PIN, blinkState); 109 | } 110 | -------------------------------------------------------------------------------- /Arduino/AK8975/examples/AK8975_raw/AK8975_raw.ino: -------------------------------------------------------------------------------- 1 | // I2C device class (I2Cdev) demonstration Arduino sketch for AK8975 class 2 | // 10/7/2011 by Jeff Rowberg 3 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 4 | // 5 | // Changelog: 6 | // 2011-10-07 - initial release 7 | 8 | /* ============================================ 9 | I2Cdev device library code is placed under the MIT license 10 | Copyright (c) 2011 Jeff Rowberg 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of this software and associated documentation files (the "Software"), to deal 14 | in the Software without restriction, including without limitation the rights 15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | copies of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in 20 | all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | THE SOFTWARE. 29 | =============================================== 30 | */ 31 | 32 | // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation 33 | // is used in I2Cdev.h 34 | #include "Wire.h" 35 | 36 | // I2Cdev and AK8975 must be installed as libraries, or else the .cpp/.h files 37 | // for both classes must be in the include path of your project 38 | #include "I2Cdev.h" 39 | #include "AK8975.h" 40 | 41 | // class default I2C address is 0x0C 42 | // specific I2C addresses may be passed as a parameter here 43 | // Addr pins low/low = 0x0C 44 | // Addr pins low/high = 0x0D 45 | // Addr pins high/low = 0x0E (default for InvenSense MPU6050 evaluation board) 46 | // Addr pins high/high = 0x0F 47 | AK8975 mag; 48 | 49 | int16_t mx, my, mz; 50 | 51 | #define LED_PIN 13 52 | bool blinkState = false; 53 | 54 | void setup() { 55 | // join I2C bus (I2Cdev library doesn't do this automatically) 56 | Wire.begin(); 57 | 58 | // initialize serial communication 59 | // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but 60 | // it's really up to you depending on your project) 61 | Serial.begin(38400); 62 | 63 | // initialize device 64 | Serial.println("Initializing I2C devices..."); 65 | mag.initialize(); 66 | 67 | // verify connection 68 | Serial.println("Testing device connections..."); 69 | Serial.println(mag.testConnection() ? "AK8975 connection successful" : "AK8975 connection failed"); 70 | 71 | // configure Arduino LED pin for output 72 | pinMode(LED_PIN, OUTPUT); 73 | } 74 | 75 | void loop() { 76 | // read raw heading measurements from device 77 | mag.getHeading(&mx, &my, &mz); 78 | 79 | // display tab-separated gyro x/y/z values 80 | Serial.print("mag:\t"); 81 | Serial.print(mx); Serial.print("\t"); 82 | Serial.print(my); Serial.print("\t"); 83 | Serial.println(mz); 84 | 85 | // blink LED to indicate activity 86 | blinkState = !blinkState; 87 | digitalWrite(LED_PIN, blinkState); 88 | } 89 | -------------------------------------------------------------------------------- /Arduino/AK8975/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-AK8975", 3 | "version": "1.0.0", 4 | "keywords": "compass, sensor, i2cdevlib, i2c", 5 | "description": "AK8975 is 3-axis electronic compass IC with high sensitive Hall sensor technology", 6 | "include": "Arduino/AK8975", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*", 15 | "jrowberg/I2Cdevlib-MPU6050": "*" 16 | }, 17 | "frameworks": "arduino", 18 | "platforms": "*" 19 | } 20 | -------------------------------------------------------------------------------- /Arduino/AT30TSE75x/Examples/AT30TSE75x_basic/AT30TSE75x_basic.ino: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - AT30TSE752/754/758 I2C device class header file 2 | // Based on ATMEL AT30TSE75 datasheet, 2013 Rev. Atmel-8751F-DTS-AT30TSE752-754-758-Datasheet_092013 3 | // 2014-02-16 by Bartosz Kryza 4 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 5 | // 6 | // Changelog: 7 | // 2014-02-16 - initial release 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2014 Bartosz Kryza, Jeff Rowberg 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | =============================================== 31 | */ 32 | 33 | #include 34 | #include "AT30TSE75x.h" 35 | 36 | // 37 | // Initialize the sensor with A2-A0 pins grounded 38 | // and variant with 8Kb of EEPROM memory. 39 | // 40 | AT30TSE75x tempSensor(0x00, AT30TSE75x_758); 41 | 42 | void setup() { 43 | 44 | // 45 | // Initialize Wire and Serial 46 | // 47 | Wire.begin(); 48 | Serial.begin(9600); 49 | Serial.println("Initializing temp sensor"); 50 | 51 | // 52 | // Initialize the sensor with 12 bit conversion resolution 53 | // 54 | tempSensor.initialize(); 55 | tempSensor.setConversionResolution(AT30TSE75x_RES_12BIT); 56 | 57 | } 58 | 59 | 60 | 61 | void loop() { 62 | 63 | // 64 | // Read Celcius temperature 65 | // 66 | float tempValue = tempSensor.getTemperatureCelcius(); 67 | Serial.print("Current temperature: "); 68 | Serial.print(tempValue); 69 | Serial.println("C"); 70 | 71 | // 72 | // Read Fahrenheit temperature 73 | // 74 | tempValue = tempSensor.getTemperatureFahrenheit(); 75 | Serial.print("Current temperature: "); 76 | Serial.print(tempValue); 77 | Serial.println("F"); 78 | 79 | // 80 | // Write/read EEPROM byte 81 | // 82 | uint8_t page = 16; 83 | uint8_t byteInPage = 5; 84 | tempSensor.writeEEPROMByte(16*page+byteInPage, 13); 85 | uint8_t eepromValue = tempSensor.readEEPROMByte(16*page+byteInPage); 86 | Serial.print("Read EEPROM byte: "); 87 | Serial.println(eepromValue); 88 | 89 | // 90 | // Write/read EEPROM page 91 | // 92 | uint8_t pageBytes[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; 93 | page = 3; 94 | tempSensor.writeEEPROMPage(16*page, pageBytes); 95 | 96 | // AT30TSE buffers pages before writing them to the EEPROM thus 97 | // delay is necessary between writing and reading a page from EEPROM 98 | // to ensure we get new values 99 | delay(10); 100 | 101 | uint8_t pageBytesRead[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 102 | 103 | tempSensor.readEEPROMPage(16*page, pageBytesRead); 104 | 105 | Serial.print("Read EEPROM page: "); 106 | for(int i=0; i<16; i++) { 107 | Serial.print(pageBytesRead[i]); Serial.print(" "); 108 | } 109 | Serial.println(""); 110 | 111 | delay(2000); 112 | 113 | } 114 | -------------------------------------------------------------------------------- /Arduino/BMA150/examples/BMA150_raw/BMA150_raw.ino: -------------------------------------------------------------------------------- 1 | // I2C device class (I2Cdev) demonstration Arduino sketch for BMA150 class 2 | // 18/01/2012 by Brian McCain 3 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 4 | // 5 | // Changelog: 6 | // 2012-01-18 - initial release 7 | 8 | /* ============================================ 9 | I2Cdev device library code is placed under the MIT license 10 | Copyright (c) 2011 Jeff Rowberg 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of this software and associated documentation files (the "Software"), to deal 14 | in the Software without restriction, including without limitation the rights 15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | copies of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in 20 | all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | THE SOFTWARE. 29 | =============================================== 30 | */ 31 | 32 | // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation 33 | // is used in I2Cdev.h 34 | #include "Wire.h" 35 | 36 | // I2Cdev and BMA150 must be installed as libraries, or else the .cpp/.h files 37 | // for both classes must be in the include path of your project 38 | #include "I2Cdev.h" 39 | #include "BMA150.h" 40 | 41 | // class default I2C address is 0x38 42 | 43 | BMA150 accel; 44 | 45 | int16_t ax, ay, az; 46 | 47 | #define LED_PIN 13 48 | bool blinkState = false; 49 | 50 | void setup() { 51 | // join I2C bus (I2Cdev library doesn't do this automatically) 52 | Wire.begin(); 53 | 54 | // initialize serial communication 55 | // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but 56 | // it's really up to you depending on your project) 57 | Serial.begin(38400); 58 | 59 | // initialize device 60 | Serial.println("Initializing I2C devices..."); 61 | accel.initialize(); 62 | 63 | // verify connection 64 | Serial.println("Testing device connections..."); 65 | Serial.println(accel.testConnection() ? "BMA150 connection successful" : "BMA150 connection failed"); 66 | 67 | // configure Arduino LED pin for output 68 | pinMode(LED_PIN, OUTPUT); 69 | } 70 | 71 | void loop() { 72 | // read raw gyro measurements from device 73 | accel.getAcceleration(&ax, &ay, &az); 74 | 75 | // display tab-separated accel x/y/z values 76 | Serial.print("accel:\t"); 77 | Serial.print(ax); Serial.print("\t"); 78 | Serial.print(ay); Serial.print("\t"); 79 | Serial.println(az); 80 | 81 | // blink LED to indicate activity 82 | blinkState = !blinkState; 83 | digitalWrite(LED_PIN, blinkState); 84 | } 85 | -------------------------------------------------------------------------------- /Arduino/BMA150/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-BMA150", 3 | "version": "1.0.0", 4 | "keywords": "accelerometer, sensor, i2cdevlib, i2c", 5 | "description": "The BMA150 is a triaxial, low-g acceleration sensor IC with digital output for consumer market applications", 6 | "include": "Arduino/BMA150", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/BMP085/examples/BMP085_basic/BMP085_basic.ino: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - BMP085 basic Arduino example sketch 2 | // Based on register information stored in the I2Cdevlib internal database 3 | // 2012-06-28 by Jeff Rowberg 4 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 5 | // 6 | // Changelog: 7 | // 2012-06-28 - initial release, dynamically built 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2012 Jeff Rowberg 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | =============================================== 31 | */ 32 | 33 | // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation 34 | // is used in I2Cdev.h 35 | #include "Wire.h" 36 | 37 | // I2Cdev and BMP085 must be installed as libraries, or else the .cpp/.h files 38 | // for both classes must be in the include path of your project 39 | #include "I2Cdev.h" 40 | #include "BMP085.h" 41 | 42 | // class default I2C address is 0x77 43 | // specific I2C addresses may be passed as a parameter here 44 | // (though the BMP085 supports only one address) 45 | BMP085 barometer; 46 | 47 | float temperature; 48 | float pressure; 49 | int32_t altitude; 50 | 51 | #define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6) 52 | bool blinkState = false; 53 | 54 | void setup() { 55 | // join I2C bus (I2Cdev library doesn't do this automatically) 56 | Wire.begin(); 57 | 58 | // initialize serial communication 59 | // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but 60 | // it's really up to you depending on your project) 61 | Serial.begin(38400); 62 | 63 | // initialize device 64 | Serial.println("Initializing I2C devices..."); 65 | barometer.initialize(); 66 | 67 | // verify connection 68 | Serial.println("Testing device connections..."); 69 | Serial.println(barometer.testConnection() ? "BMP085 connection successful" : "BMP085 connection failed"); 70 | 71 | // configure LED pin for activity indication 72 | pinMode(LED_PIN, OUTPUT); 73 | } 74 | 75 | void loop() { 76 | // request temperature 77 | barometer.setControl(BMP085_MODE_TEMPERATURE); 78 | 79 | // read calibrated temperature value in degrees Celsius 80 | temperature = barometer.getTemperatureC(); 81 | 82 | // request pressure (3x oversampling mode, high detail, 23.5ms delay) 83 | barometer.setControl(BMP085_MODE_PRESSURE_3); 84 | 85 | // read calibrated pressure value in Pascals (Pa) 86 | pressure = barometer.getPressure(); 87 | 88 | // calculate absolute altitude in meters based on known pressure 89 | // (may pass a second "sea level pressure" parameter here, 90 | // otherwise uses the standard value of 101325 Pa) 91 | altitude = barometer.getAltitude(pressure); 92 | 93 | // display measured values if appropriate 94 | Serial.print("T/P/A\t"); 95 | Serial.print(temperature); Serial.print("\t"); 96 | Serial.print(pressure); Serial.print("\t"); 97 | Serial.print(altitude); 98 | Serial.println(""); 99 | 100 | // blink LED to indicate activity 101 | blinkState = !blinkState; 102 | digitalWrite(LED_PIN, blinkState); 103 | 104 | // delay 100 msec to allow visually parsing blink and any serial output 105 | delay(100); 106 | } -------------------------------------------------------------------------------- /Arduino/BMP085/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-BMP085", 3 | "version": "1.0.0", 4 | "keywords": "altimeter, altitude, barometer, pressure, temperature, sensor, i2cdevlib, i2c", 5 | "description": "The BMP085 is barometric pressure, temperature and altitude sensor", 6 | "include": "Arduino/BMP085", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/DS1307/examples/DS1307_settime/DS1307_settime.ino: -------------------------------------------------------------------------------- 1 | // I2C device class (I2Cdev) demonstration Arduino sketch for DS1307 class 2 | // 3 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 4 | // I2C Device Library hosted at http://www.i2cdevlib.com 5 | // 6 | // Changelog: 7 | // 2016-04-15 - initial release 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2016 Jeff Rowberg 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | =============================================== 31 | */ 32 | 33 | // I2Cdev and DS1307 must be installed as libraries, or else the .cpp/.h files 34 | // for both classes must be in the include path of your project 35 | #include "DS1307.h" 36 | 37 | 38 | DS1307 rtc; 39 | 40 | void setup() { 41 | // join I2C bus (I2Cdev library doesn't do this automatically) 42 | // Note that the DS1307 doesn't support 400Khz i2c 43 | Wire.begin(); 44 | 45 | // initialize serial communication 46 | // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but 47 | // it's really up to you depending on your project) 48 | Serial.begin(38400); 49 | 50 | // initialize device 51 | Serial.println("Initializing I2C devices..."); 52 | rtc.initialize(); 53 | 54 | // verify connection 55 | Serial.println("Testing device connections..."); 56 | Serial.println(rtc.testConnection() ? "DS1307 connection successful" : "DS1307 connection failed"); 57 | 58 | 59 | // Use "the compiler's time" to set time. Make sure the sketch is recompiled before uploading. 60 | DateTime compilerNow (__DATE__, __TIME__); 61 | rtc.setDateTime(compilerNow); 62 | rtc.setClockRunning(true); 63 | Serial.print(" Clock is set "); 64 | Serial.println(rtc.getClockRunning()?"and running":"but it is NOT running"); 65 | } 66 | 67 | void printDigits(int digits, const char* prefix="") { 68 | // utility function: prints prefix and leading 0 before the number 69 | Serial.print(prefix); 70 | if (digits < 10) 71 | Serial.print('0'); 72 | Serial.print(digits); 73 | } 74 | 75 | void loop() { 76 | // ISO 8601 FTW! 77 | 78 | uint16_t year = 0; 79 | uint8_t month, day, dow, hours, minutes, seconds = 0; 80 | static uint32_t tick = 0; 81 | 82 | rtc.getDateTime24(&year, &month, &day, &hours, &minutes, &seconds); 83 | Serial.print(tick++); 84 | printDigits(year, ": "); 85 | printDigits(month,"-"); 86 | printDigits(day,"-"); 87 | printDigits(hours," "); 88 | printDigits(minutes,":"); 89 | printDigits(seconds, ":"); 90 | 91 | Serial.println(); 92 | delay(1000); 93 | } 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /Arduino/DS1307/examples/DS1307_tick/DS1307_tick.ino: -------------------------------------------------------------------------------- 1 | // I2C device class (I2Cdev) demonstration Arduino sketch for DS1307 class 2 | // 11/12/2011 by Jeff Rowberg 3 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 4 | // I2C Device Library hosted at http://www.i2cdevlib.com 5 | // 6 | // Changelog: 7 | // 2011-11-12 - initial release 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2011 Jeff Rowberg 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | =============================================== 31 | */ 32 | 33 | // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation 34 | // is used in I2Cdev.h 35 | #include "Wire.h" 36 | 37 | // I2Cdev and DS1307 must be installed as libraries, or else the .cpp/.h files 38 | // for both classes must be in the include path of your project 39 | #include "I2Cdev.h" 40 | #include "DS1307.h" 41 | 42 | // class default I2C address is 0x68 43 | // specific I2C addresses may be passed as a parameter here 44 | // but this device only supports one I2C address (0x68) 45 | DS1307 rtc; 46 | 47 | uint16_t year; 48 | uint8_t month, day, dow, hours, minutes, seconds; 49 | 50 | #define LED_PIN 13 51 | bool blinkState = false; 52 | 53 | void setup() { 54 | // join I2C bus (I2Cdev library doesn't do this automatically) 55 | Wire.begin(); 56 | 57 | // initialize serial communication 58 | // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but 59 | // it's really up to you depending on your project) 60 | Serial.begin(38400); 61 | 62 | // initialize device 63 | Serial.println("Initializing I2C devices..."); 64 | rtc.initialize(); 65 | 66 | // verify connection 67 | Serial.println("Testing device connections..."); 68 | Serial.println(rtc.testConnection() ? "DS1307 connection successful" : "DS1307 connection failed"); 69 | 70 | // configure LED pin for output 71 | pinMode(LED_PIN, OUTPUT); 72 | 73 | // set sample time 74 | rtc.setDateTime24(2011, 11, 12, 13, 45, 0); 75 | } 76 | 77 | void loop() { 78 | // read all clock info from device 79 | rtc.getDateTime24(&year, &month, &day, &hours, &minutes, &seconds); 80 | 81 | // display YYYY-MM-DD hh:mm:ss time 82 | Serial.print("rtc:\t"); 83 | Serial.print(year); Serial.print("-"); 84 | if (month < 10) Serial.print("0"); 85 | Serial.print(month); Serial.print("-"); 86 | if (day < 10) Serial.print("0"); 87 | Serial.print(day); Serial.print(" "); 88 | if (hours < 10) Serial.print("0"); 89 | Serial.print(hours); Serial.print(":"); 90 | if (minutes < 10) Serial.print("0"); 91 | Serial.print(minutes); Serial.print(":"); 92 | if (seconds < 10) Serial.print("0"); 93 | Serial.println(seconds); 94 | 95 | // blink LED to indicate activity 96 | blinkState = !blinkState; 97 | digitalWrite(LED_PIN, blinkState); 98 | 99 | // wait one second so the next reading will be different 100 | delay(1000); 101 | } 102 | -------------------------------------------------------------------------------- /Arduino/DS1307/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-DS1307", 3 | "version": "1.0.0", 4 | "keywords": "rtc, time, clock, i2cdevlib, i2c", 5 | "description": "The DS1307 serial real-time clock (RTC) is a low-power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM", 6 | "include": "Arduino/DS1307", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/HMC5843/examples/HMC5843_raw/HMC5843_raw.ino: -------------------------------------------------------------------------------- 1 | // I2C device class (I2Cdev) demonstration Arduino sketch for HMC5843 class 2 | // 10/7/2011 by Jeff Rowberg 3 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 4 | // 5 | // Changelog: 6 | // 2011-10-07 - initial release 7 | 8 | /* ============================================ 9 | I2Cdev device library code is placed under the MIT license 10 | Copyright (c) 2011 Jeff Rowberg 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of this software and associated documentation files (the "Software"), to deal 14 | in the Software without restriction, including without limitation the rights 15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | copies of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in 20 | all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | THE SOFTWARE. 29 | =============================================== 30 | */ 31 | 32 | // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation 33 | // is used in I2Cdev.h 34 | #include "Wire.h" 35 | 36 | // I2Cdev and HMC5843 must be installed as libraries, or else the .cpp/.h files 37 | // for both classes must be in the include path of your project 38 | #include "I2Cdev.h" 39 | #include "HMC5843.h" 40 | 41 | // class default I2C address is 0x1E 42 | // specific I2C addresses may be passed as a parameter here 43 | // this device only supports one I2C address (0x1E) 44 | HMC5843 mag; 45 | 46 | int16_t mx, my, mz; 47 | 48 | #define LED_PIN 13 49 | bool blinkState = false; 50 | 51 | void setup() { 52 | // join I2C bus (I2Cdev library doesn't do this automatically) 53 | Wire.begin(); 54 | 55 | // initialize serial communication 56 | // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but 57 | // it's really up to you depending on your project) 58 | Serial.begin(38400); 59 | 60 | // initialize device 61 | Serial.println("Initializing I2C devices..."); 62 | mag.initialize(); 63 | 64 | // verify connection 65 | Serial.println("Testing device connections..."); 66 | Serial.println(mag.testConnection() ? "HMC5843 connection successful" : "HMC5843 connection failed"); 67 | 68 | // configure Arduino LED pin for output 69 | pinMode(LED_PIN, OUTPUT); 70 | } 71 | 72 | void loop() { 73 | // read raw heading measurements from device 74 | mag.getHeading(&mx, &my, &mz); 75 | 76 | // display tab-separated gyro x/y/z values 77 | Serial.print("mag:\t"); 78 | Serial.print(mx); Serial.print("\t"); 79 | Serial.print(my); Serial.print("\t"); 80 | Serial.println(mz); 81 | 82 | // blink LED to indicate activity 83 | blinkState = !blinkState; 84 | digitalWrite(LED_PIN, blinkState); 85 | } 86 | -------------------------------------------------------------------------------- /Arduino/HMC5843/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-HMC5843", 3 | "version": "1.0.0", 4 | "keywords": "magnetometer, compass, sensor, i2cdevlib, i2c", 5 | "description": "The HMC5843 is 3-Axis digital compass/magnetometer", 6 | "include": "Arduino/HMC5843", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/HMC5883L/examples/HMC5883L_raw/HMC5883L_raw.ino: -------------------------------------------------------------------------------- 1 | // I2C device class (I2Cdev) demonstration Arduino sketch for HMC5883L class 2 | // 10/7/2011 by Jeff Rowberg 3 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 4 | // 5 | // Changelog: 6 | // 2013-05-04 - Added Heading Calculation in degrees 7 | // 2011-10-07 - initial release 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2011 Jeff Rowberg 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | =============================================== 31 | */ 32 | 33 | // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation 34 | // is used in I2Cdev.h 35 | #include "Wire.h" 36 | 37 | // I2Cdev and HMC5883L must be installed as libraries, or else the .cpp/.h files 38 | // for both classes must be in the include path of your project 39 | #include "I2Cdev.h" 40 | #include "HMC5883L.h" 41 | 42 | // class default I2C address is 0x1E 43 | // specific I2C addresses may be passed as a parameter here 44 | // this device only supports one I2C address (0x1E) 45 | HMC5883L mag; 46 | 47 | int16_t mx, my, mz; 48 | 49 | #define LED_PIN 13 50 | bool blinkState = false; 51 | 52 | void setup() { 53 | // join I2C bus (I2Cdev library doesn't do this automatically) 54 | Wire.begin(); 55 | 56 | // initialize serial communication 57 | // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but 58 | // it's really up to you depending on your project) 59 | Serial.begin(38400); 60 | 61 | // initialize device 62 | Serial.println("Initializing I2C devices..."); 63 | mag.initialize(); 64 | 65 | // verify connection 66 | Serial.println("Testing device connections..."); 67 | Serial.println(mag.testConnection() ? "HMC5883L connection successful" : "HMC5883L connection failed"); 68 | 69 | // configure Arduino LED pin for output 70 | pinMode(LED_PIN, OUTPUT); 71 | } 72 | 73 | void loop() { 74 | // read raw heading measurements from device 75 | mag.getHeading(&mx, &my, &mz); 76 | 77 | // display tab-separated gyro x/y/z values 78 | Serial.print("mag:\t"); 79 | Serial.print(mx); Serial.print("\t"); 80 | Serial.print(my); Serial.print("\t"); 81 | Serial.print(mz); Serial.print("\t"); 82 | 83 | // To calculate heading in degrees. 0 degree indicates North 84 | float heading = atan2(my, mx); 85 | if(heading < 0) 86 | heading += 2 * M_PI; 87 | Serial.print("heading:\t"); 88 | Serial.println(heading * 180/M_PI); 89 | 90 | // blink LED to indicate activity 91 | blinkState = !blinkState; 92 | digitalWrite(LED_PIN, blinkState); 93 | } 94 | -------------------------------------------------------------------------------- /Arduino/HMC5883L/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-HMC5883L", 3 | "version": "1.0.0", 4 | "keywords": "magnetometer, compass, sensor, i2cdevlib, i2c", 5 | "description": "The HMC5883L is 3-Axis digital compass/magnetometer", 6 | "include": "Arduino/HMC5883L", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/HTU21D/HTU21D.cpp: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - HTU21D I2C device class header file 2 | // Based on MEAS HTU21D HPC199_2 HTU321(F) datasheet, October 2013 3 | // 2016-03-24 by https://github.com/eadf 4 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 5 | // 6 | // Changelog: 7 | // 2016-03-24 - initial release 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2016 Eadf, Jeff Rowberg 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | =============================================== 31 | */ 32 | 33 | #include "HTU21D.h" 34 | 35 | 36 | /** Default constructor, uses default I2C address. 37 | * @see HTU21D_DEFAULT_ADDRESS 38 | */ 39 | HTU21D::HTU21D() { 40 | devAddr = HTU21D_DEFAULT_ADDRESS; 41 | } 42 | 43 | /** Power on and prepare for general usage. 44 | * This operation calls reset() on the HTU21D device and it takes at least 15milliseconds. 45 | */ 46 | void HTU21D::initialize() { 47 | reset(); 48 | } 49 | 50 | /** Verify the I2C connection. 51 | * Make sure the device is connected and responds as expected. 52 | * This operation calls reset() on the HTU21D device and it takes at least 15milliseconds. 53 | * @return True if connection is valid, false otherwise 54 | */ 55 | bool HTU21D::testConnection() { 56 | reset(); 57 | buffer[0] = 0; 58 | I2Cdev::readByte(devAddr, HTU21D_READ_USER_REGISTER, buffer); 59 | return buffer[0] == 0x2; 60 | } 61 | 62 | /** Reads and returns the temperature, ignores the CRC field. 63 | * @return The measured temperature, or NaN if the operation failed. 64 | */ 65 | float HTU21D::getTemperature() { 66 | // Ignore the CRC byte 67 | uint16_t t = 0; 68 | if (1!=I2Cdev::readWord(devAddr, HTU21D_RA_TEMPERATURE, &t)){ 69 | return NAN; 70 | } 71 | // clear the status bits (bit0 & bit1) and calculate the temperature 72 | // as per the formula in the datasheet 73 | return ((float)(t&0xFFFC))*175.72/65536.0-46.85; 74 | } 75 | 76 | /** Reads and returns the humidity, ignores the CRC field 77 | * @return The measured humidity, or NaN if the operation failed. 78 | */ 79 | float HTU21D::getHumidity() { 80 | // Ignore the CRC byte 81 | uint16_t t = 0; 82 | if (1!=I2Cdev::readWord(devAddr, HTU21D_RA_HUMIDITY, &t)){ 83 | return NAN; 84 | } 85 | // clear the status bits (bit0 & bit1) and calculate the humidity 86 | // as per the formula in the datasheet 87 | return ((float)(t&0xFFFC))*125.0/65536.0-6.0; 88 | } 89 | 90 | /** Does a soft reset of the HTU21D 91 | * This operation takes at least 15milliseconds. 92 | */ 93 | void HTU21D::reset() { 94 | I2Cdev::writeByte(devAddr, HTU21D_RESET, 0); 95 | delay(15); 96 | } 97 | 98 | -------------------------------------------------------------------------------- /Arduino/HTU21D/HTU21D.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - HTU21D I2C device class header file 2 | // Based on MEAS HTU21D HPC199_2 HTU321(F) datasheet, October 2013 3 | // 2016-03-24 by https://github.com/eadf 4 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 5 | // 6 | // Changelog: 7 | // 2016-03-24 - initial release 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2016 Eadf, Jeff Rowberg 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | =============================================== 31 | */ 32 | 33 | #ifndef _HTU21D_H_ 34 | #define _HTU21D_H_ 35 | 36 | #include "I2Cdev.h" 37 | 38 | #define HTU21D_DEFAULT_ADDRESS 0x40 39 | 40 | #define HTU21D_RA_TEMPERATURE 0xE3 41 | #define HTU21D_RA_HUMIDITY 0xE5 42 | #define HTU21D_RESET 0xFE 43 | #define HTU21D_WRITE_USER_REGISTER 0xE6 44 | #define HTU21D_READ_USER_REGISTER 0xE7 45 | 46 | class HTU21D { 47 | public: 48 | HTU21D(); 49 | 50 | void initialize(); 51 | bool testConnection(); 52 | 53 | float getTemperature(); 54 | float getHumidity(); 55 | 56 | void reset(); 57 | 58 | private: 59 | uint8_t devAddr; 60 | uint8_t buffer[2]; 61 | }; 62 | 63 | #endif /* _HTU21D_H_ */ 64 | -------------------------------------------------------------------------------- /Arduino/HTU21D/examples/HTU21D_simple/HTU21D_simple.ino: -------------------------------------------------------------------------------- 1 | // I2C device class (I2Cdev) demonstration Arduino sketch for HTU21D class 2 | // Example of reading temperature and humidity from the HTU21D sensor 3 | // 2016-03-24 by Eadf (https://github.com/eadf) 4 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 5 | // 6 | // Changelog: 7 | // 2016-03-24 - initial release 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2016 Eadf, Jeff Rowberg 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | =============================================== 31 | */ 32 | 33 | #include "HTU21D.h" 34 | 35 | HTU21D htu21d; 36 | 37 | void setup() { 38 | //I2Cdev::begin(); // join I2C bus 39 | Wire.begin(); 40 | Serial.begin(38400); 41 | htu21d.initialize(); 42 | Serial.println("Testing device connections..."); 43 | Serial.println(htu21d.testConnection() ? "HTU21D connection successful" : "HTU21D connection failed"); 44 | } 45 | 46 | void loop() { 47 | Serial.print("Temperature: "); Serial.print(htu21d.getTemperature()); 48 | Serial.print("\t\tHumidity: "); Serial.println(htu21d.getHumidity()); 49 | delay(400); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /Arduino/HTU21D/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-HTU21D", 3 | "version": "1.0.0", 4 | "keywords": "temperature, humidity, i2cdevlib, i2c", 5 | "description": "HTU21D is 12-Bit humidity and 14-bit temperature sensor", 6 | "include": "Arduino/HTU21D", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/I2Cdev/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For I2Cdev 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | I2Cdev KEYWORD1 9 | 10 | ####################################### 11 | # Methods and Functions (KEYWORD2) 12 | ####################################### 13 | 14 | readBit KEYWORD2 15 | readBitW KEYWORD2 16 | readBits KEYWORD2 17 | readBitsW KEYWORD2 18 | readByte KEYWORD2 19 | readBytes KEYWORD2 20 | readWord KEYWORD2 21 | readWords KEYWORD2 22 | writeBit KEYWORD2 23 | writeBitW KEYWORD2 24 | writeBits KEYWORD2 25 | writeBitsW KEYWORD2 26 | writeByte KEYWORD2 27 | writeBytes KEYWORD2 28 | writeWord KEYWORD2 29 | writeWords KEYWORD2 30 | 31 | ####################################### 32 | # Instances (KEYWORD2) 33 | ####################################### 34 | 35 | ####################################### 36 | # Constants (LITERAL1) 37 | ####################################### 38 | 39 | -------------------------------------------------------------------------------- /Arduino/I2Cdev/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-Core", 3 | "version": "1.0.1", 4 | "keywords": "i2cdevlib, i2c", 5 | "description": "The I2C Device Library (I2Cdevlib) is a collection of uniform and well-documented classes to provide simple and intuitive interfaces to I2C devices.", 6 | "include": "Arduino/I2Cdev", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "frameworks": "arduino", 13 | "platforms": "*", 14 | "dependencies": { 15 | "Wire": "*" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Arduino/IAQ2000/IAQ2000.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - iAQ-2000 I2C device class header file 2 | // Based on AppliedSensor iAQ-2000 Interface Description, Version PA1, 2009 3 | // 2012-04-01 by Peteris Skorovs 4 | // 5 | // This I2C device library is using (and submitted as a part of) Jeff Rowberg's I2Cdevlib library, 6 | // which should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 7 | // 8 | // Changelog: 9 | // 2012-04-01 - initial release 10 | // 2015-11-08 - added TVoc and Status 11 | 12 | /* ============================================ 13 | I2Cdev device library code is placed under the MIT license 14 | Copyright (c) 2012 Peteris Skorovs, Jeff Rowberg 15 | 16 | Permission is hereby granted, free of charge, to any person obtaining a copy 17 | of this software and associated documentation files (the "Software"), to deal 18 | in the Software without restriction, including without limitation the rights 19 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20 | copies of the Software, and to permit persons to whom the Software is 21 | furnished to do so, subject to the following conditions: 22 | 23 | The above copyright notice and this permission notice shall be included in 24 | all copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 32 | THE SOFTWARE. 33 | =============================================== 34 | */ 35 | 36 | #ifndef _IAQ2000_H_ 37 | #define _IAQ2000_H_ 38 | 39 | #include "I2Cdev.h" 40 | 41 | #define IAQ2000_ADDRESS 0x5A 42 | #define IAQ2000_DEFAULT_ADDRESS IAQ2000_ADDRESS 43 | 44 | #define IAQ2000_RA_DATA1 0x00 45 | #define IAQ2000_RA_DATA2 0x01 46 | 47 | class IAQ2000 { 48 | public: 49 | IAQ2000(); 50 | IAQ2000(uint8_t address); 51 | void initialize(); 52 | bool testConnection(); 53 | uint16_t getIaqtvoc(); 54 | uint16_t getIaqpred(); 55 | uint8_t getIaqstatus(); 56 | 57 | private: 58 | uint8_t devAddr; 59 | uint8_t buffer[8]; 60 | 61 | int8_t readAllBytes(uint8_t devAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); 62 | }; 63 | 64 | #endif /* _IAQ200_H_ */ 65 | -------------------------------------------------------------------------------- /Arduino/IAQ2000/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For IAQ2000 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | IAQ2000 KEYWORD1 9 | 10 | ####################################### 11 | # Methods and Functions (KEYWORD2) 12 | ####################################### 13 | 14 | initialize KEYWORD2 15 | testConnection KEYWORD2 16 | getIaq KEYWORD2 17 | 18 | ####################################### 19 | # Instances (KEYWORD2) 20 | ####################################### 21 | 22 | ####################################### 23 | # Constants (LITERAL1) 24 | ####################################### 25 | 26 | -------------------------------------------------------------------------------- /Arduino/IAQ2000/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-IAQ2000", 3 | "version": "1.0.0", 4 | "keywords": "co2, carbon, dioxide, sensor, i2cdevlib, i2c", 5 | "description": "The iAQ-2000 Indoor Air Quality Module is a sensitive, low-cost solution for detecting poor air quality", 6 | "include": "Arduino/IAQ2000", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/ITG3200/examples/ITG3200_raw/ITG3200_raw.ino: -------------------------------------------------------------------------------- 1 | // I2C device class (I2Cdev) demonstration Arduino sketch for ITG3200 class 2 | // 10/7/2011 by Jeff Rowberg 3 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 4 | // 5 | // Changelog: 6 | // 2011-10-07 - initial release 7 | 8 | /* ============================================ 9 | I2Cdev device library code is placed under the MIT license 10 | Copyright (c) 2011 Jeff Rowberg 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of this software and associated documentation files (the "Software"), to deal 14 | in the Software without restriction, including without limitation the rights 15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | copies of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in 20 | all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | THE SOFTWARE. 29 | =============================================== 30 | */ 31 | 32 | // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation 33 | // is used in I2Cdev.h 34 | #include "Wire.h" 35 | 36 | // I2Cdev and ITG3200 must be installed as libraries, or else the .cpp/.h files 37 | // for both classes must be in the include path of your project 38 | #include "I2Cdev.h" 39 | #include "ITG3200.h" 40 | 41 | // class default I2C address is 0x68 42 | // specific I2C addresses may be passed as a parameter here 43 | // AD0 low = 0x68 (default for SparkFun 6DOF board) 44 | // AD0 high = 0x69 (default for SparkFun ITG-3200 standalone board) 45 | ITG3200 gyro; 46 | 47 | int16_t gx, gy, gz; 48 | 49 | #define LED_PIN 13 50 | bool blinkState = false; 51 | 52 | void setup() { 53 | // join I2C bus (I2Cdev library doesn't do this automatically) 54 | Wire.begin(); 55 | 56 | // initialize serial communication 57 | // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but 58 | // it's really up to you depending on your project) 59 | Serial.begin(38400); 60 | 61 | // initialize device 62 | Serial.println("Initializing I2C devices..."); 63 | gyro.initialize(); 64 | 65 | // verify connection 66 | Serial.println("Testing device connections..."); 67 | Serial.println(gyro.testConnection() ? "ITG3200 connection successful" : "ITG3200 connection failed"); 68 | 69 | // configure Arduino LED pin for output 70 | pinMode(LED_PIN, OUTPUT); 71 | } 72 | 73 | void loop() { 74 | // read raw gyro measurements from device 75 | gyro.getRotation(&gx, &gy, &gz); 76 | 77 | // display tab-separated gyro x/y/z values 78 | Serial.print("gyro:\t"); 79 | Serial.print(gx); Serial.print("\t"); 80 | Serial.print(gy); Serial.print("\t"); 81 | Serial.println(gz); 82 | 83 | // blink LED to indicate activity 84 | blinkState = !blinkState; 85 | digitalWrite(LED_PIN, blinkState); 86 | } 87 | -------------------------------------------------------------------------------- /Arduino/ITG3200/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-ITG3200", 3 | "version": "1.0.0", 4 | "keywords": "gyroscope, sensor, i2cdevlib, i2c", 5 | "description": "The ITG-3200 is groundbreaking 3-axis, digital output MEMS gyroscope", 6 | "include": "Arduino/ITG3200", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/L3G4200D/examples/L3G4200D_raw/L3G4200D_raw.ino: -------------------------------------------------------------------------------- 1 | // I2C device class (I2Cdev) demonstration Arduino sketch for L3G4200D class 2 | // 7/31/2013 by Jonathan Arnett 3 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 4 | // 5 | // Changelog: 6 | // 2011-07-31 - initial release 7 | 8 | /* ============================================ 9 | I2Cdev device library code is placed under the MIT license 10 | Copyright (c) 2011 Jonathan Arnett, Jeff Rowberg 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of this software and associated documentation files (the "Software"), to deal 14 | in the Software without restriction, including without limitation the rights 15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | copies of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in 20 | all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | THE SOFTWARE. 29 | =============================================== 30 | */ 31 | 32 | // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation 33 | // is used in I2Cdev.h 34 | #include 35 | 36 | // I2Cdev and L3G4200D must be installed as libraries, or else the .cpp/.h files 37 | // for both classes must be in the include path of your project 38 | #include 39 | #include 40 | 41 | // default address is 105 42 | // specific I2C address may be passed here 43 | L3G4200D gyro; 44 | 45 | int16_t avx, avy, avz; 46 | 47 | #define LED_PIN 13 // (Arduino is 13, Teensy is 6) 48 | bool blinkState = false; 49 | 50 | void setup() { 51 | // join I2C bus (I2Cdev library doesn't do this automatically) 52 | Wire.begin(); 53 | 54 | // initialize serial communication 55 | // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but 56 | // it's really up to you depending on your project) 57 | Serial.begin(9600); 58 | 59 | // initialize device 60 | Serial.println("Initializing I2C devices..."); 61 | gyro.initialize(); 62 | 63 | // verify connection 64 | Serial.println("Testing device connections..."); 65 | Serial.println(gyro.testConnection() ? "L3G4200D connection successful" : "L3G4200D connection failed"); 66 | 67 | // configure LED for output 68 | pinMode(LED_PIN, OUTPUT); 69 | 70 | // data seems to be best when full scale is 2000 71 | gyro.setFullScale(2000); 72 | } 73 | 74 | void loop() { 75 | // read raw angular velocity measurements from device 76 | gyro.getAngularVelocity(&avx, &avy, &avz); 77 | 78 | Serial.print("angular velocity:\t"); 79 | Serial.print(avx); Serial.print("\t"); 80 | Serial.print(avy); Serial.print("\t"); 81 | Serial.println(avz); 82 | 83 | // blink LED to indicate activity 84 | blinkState = !blinkState; 85 | digitalWrite(LED_PIN, blinkState); 86 | } 87 | 88 | 89 | -------------------------------------------------------------------------------- /Arduino/L3G4200D/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-L3G4200D", 3 | "version": "1.0.0", 4 | "keywords": "accelerometer, sensor, i2cdevlib, i2c", 5 | "description": "The L3G4200D is a low-power three-axis angular rate sensor able to provide unprecedented stablility of zero rate level and sensitivity over temperature and time", 6 | "include": "Arduino/L3G4200D", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/LM73/LM73.cpp: -------------------------------------------------------------------------------- 1 | // LM73 I2C class 2 | // Based on Texas Instruments datasheet http://www.ti.com/lit/ds/symlink/lm73.pdf 3 | // Note that this is a bare-bones driver and does not support all of the features 4 | // of the LM73. I only added what I needed. 5 | // 12/03/2012 Abe Erdos (abe@erdosmiller.com) 6 | 7 | #include "LM73.h" 8 | 9 | LM73::LM73() { 10 | devAddr = LM73_DEFAULT_ADDRESS; 11 | devConfig.all = 0x40; // reset state 12 | devCtrlStat.all = 0x08; // reset state 13 | } 14 | 15 | LM73::LM73(uint8_t address) { 16 | devAddr = address; 17 | devConfig.all = 0x40; // reset state 18 | devCtrlStat.all = 0x08; // reset state 19 | } 20 | 21 | void LM73::initialize() { 22 | // there's nothing to do, really 23 | } 24 | 25 | bool LM73::testConnection() { 26 | uint16_t buf; 27 | I2Cdev::readWord(devAddr, LM73_RA_ID, &buf); 28 | return buf == 0x0190; 29 | } 30 | 31 | LM73ConfigReg LM73::getConfig() { 32 | I2Cdev::readByte(devAddr, LM73_RA_CONFIG, buffer); 33 | devConfig.all = buffer[0]; 34 | return devConfig; 35 | } 36 | 37 | LM73CtrlStatReg LM73::getCtrlStat() { 38 | I2Cdev::readByte(devAddr, LM73_RA_CTRL_STAT, buffer); 39 | devCtrlStat.all = buffer[0]; 40 | return devCtrlStat; 41 | } 42 | 43 | void LM73::setCtrlStat(LM73CtrlStatReg value) { 44 | I2Cdev::writeByte(devAddr, LM73_RA_CTRL_STAT, value.all); 45 | } 46 | 47 | uint8_t LM73::getResolution() { 48 | LM73::getCtrlStat(); 49 | return devCtrlStat.bit.RES + 11; 50 | } 51 | 52 | float LM73::getTemp() { 53 | uint16_t buf; 54 | int16_t temp; 55 | I2Cdev::readWord(devAddr, LM73_RA_TEMP, &buf); 56 | temp = buf; 57 | temp = (temp>>2); 58 | return 0.03125f * (float)temp; 59 | } 60 | 61 | void LM73::setResolution(uint8_t resolution) { 62 | if(10 < resolution && resolution < 15) { 63 | LM73::getCtrlStat(); 64 | devCtrlStat.bit.RES = resolution - 11; 65 | LM73::setCtrlStat(devCtrlStat); 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /Arduino/LM73/LM73.h: -------------------------------------------------------------------------------- 1 | // LM73 I2C class 2 | // Based on Texas Instruments datasheet http://www.ti.com/lit/ds/symlink/lm73.pdf 3 | // Note that this is a bare-bones driver and does not support all of the features 4 | // of the LM73. I only added what I needed. 5 | // 12/03/2012 Abe Erdos (abe@erdosmiller.com) 6 | 7 | #ifndef _LM73_H_ 8 | #define _LM73_H_ 9 | 10 | #include "I2Cdev.h" 11 | 12 | // LM73-0 13 | #define LM73_0_ADDRESS_ADDR_FLT 0x48 // address pin is floating 14 | #define LM73_0_ADDRESS_ADDR_GND 0x49 // address pin low (GND) 15 | #define LM73_0_ADDRESS_ADDR_VDD 0x4A // address pin high (VDD) 16 | #define LM73_1_ADDRESS_ADDR_FLT 0x4C // address pin if floating 17 | #define LM73_1_ADDRESS_ADDR_GND 0x4D // address pin low (GND) 18 | #define LM73_1_ADDRESS_ADDR_VDD 0x4E // address pin high (VDD) 19 | #define LM73_DEFAULT_ADDRESS LM73_0_ADDRESS_ADDR_FLT 20 | 21 | #define LM73_RA_TEMP 0x00 22 | #define LM73_RA_CONFIG 0x01 23 | #define LM73_RA_HI_THRESH 0x02 24 | #define LM73_RA_LO_THRESH 0x03 25 | #define LM73_RA_CTRL_STAT 0x04 26 | #define LM73_RA_ID 0x07 27 | 28 | typedef struct { 29 | unsigned :2; // reserved 30 | unsigned ONE_SHOT:1; // one shot (write 1 to start a conversion when PD == 1) 31 | unsigned ALRT_RST:1; // alert reset (write 1 to reset, always reads 0) 32 | unsigned ALRT_POL:1; // alert polarity (1 == active high, 0 == active low0 33 | unsigned nALRT_EN:1; // alert enable (0 == alert enabled) 34 | unsigned :1; // reserved 35 | unsigned PD:1; // power down bit (0 == enabled) 36 | } LM73ConfigBits; 37 | 38 | typedef union { 39 | LM73ConfigBits bit; 40 | uint8_t all; 41 | } LM73ConfigReg; 42 | 43 | typedef struct { 44 | unsigned DAV:1; // data available flag 45 | unsigned TLOW:1; // temperature low flag 46 | unsigned THI:1; // temperature high flag 47 | unsigned ALRT_STAT:1; // alert pin status 48 | unsigned :1; // reserved 49 | unsigned RES:2; // resolution (00 == 11 bit res, 11 == 14 bit res) 50 | unsigned TO_DIS:1; // SMB timeout disable 51 | } LM73CtrlStatBits; 52 | 53 | typedef union { 54 | LM73CtrlStatBits bit; 55 | uint8_t all; 56 | } LM73CtrlStatReg; 57 | 58 | class LM73 { 59 | public: 60 | LM73(); 61 | LM73(uint8_t address); 62 | 63 | void initialize(); 64 | bool testConnection(); 65 | 66 | LM73ConfigReg getConfig(); 67 | void setConfig(LM73ConfigReg value); 68 | LM73CtrlStatReg getCtrlStat(); 69 | void setCtrlStat(LM73CtrlStatReg value); 70 | uint8_t getResolution(); // returns resolution in bits (including sign bit) 71 | void setResolution(uint8_t resolution); // enter resolution in bits (including sign bit) 72 | float getTemp(); // return temperature in C 73 | 74 | private: 75 | uint8_t devAddr; 76 | uint8_t buffer[1]; 77 | LM73ConfigReg devConfig; 78 | LM73CtrlStatReg devCtrlStat; 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /Arduino/LM73/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-LM73", 3 | "version": "1.0.0", 4 | "keywords": "temperature, sensor, i2cdevlib, i2c", 5 | "description": "The LM73 is an integrated, digital-output temperature sensor featuring an incremental Delta-Sigma ADC", 6 | "include": "Arduino/LM73", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/MPR121/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-MPR121", 3 | "version": "1.0.0", 4 | "keywords": "touch, capacitance, proximity, sensor, i2cdevlib, i2c", 5 | "description": "The MPR121 is a 12-bit proximity capacitive touch sensor", 6 | "include": "Arduino/MPR121", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/MPU6050/examples/MPU6050_DMP6_using_DMP_V6.12/MPUplane/data/diffuse_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrowberg/i2cdevlib/170bad1f4a97b074cd33238a5523c7382a3d8f1e/Arduino/MPU6050/examples/MPU6050_DMP6_using_DMP_V6.12/MPUplane/data/diffuse_512.png -------------------------------------------------------------------------------- /Arduino/MPU6050/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-MPU6050", 3 | "version": "1.0.0", 4 | "keywords": "gyroscope, accelerometer, sensor, i2cdevlib, i2c", 5 | "description": "The MPU6050 combines a 3-axis gyroscope and a 3-axis accelerometer on the same silicon die together with an onboard Digital Motion Processor(DMP) which processes complex 6-axis MotionFusion algorithms", 6 | "include": "Arduino/MPU6050", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/MPU9150/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-MPU9150", 3 | "version": "1.0.0", 4 | "keywords": "gyroscope, accelerometer, compass, sensor, i2cdevlib, i2c", 5 | "description": "The MPU-9150 combines two chips: the MPU-6050, which contains a 3-axis gyroscope, 3-axis accelerometer and the AK8975, a 3-axis digital compass", 6 | "include": "Arduino/MPU9150", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/MPU9250/BMP180.h: -------------------------------------------------------------------------------- 1 | /* 2 | Barometer library V1.0 3 | 2010 Copyright (c) Seeed Technology Inc. All right reserved. 4 | 5 | Original Author: LG 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef __BAROMETER_H__ 22 | #define __BAROMETER_H__ 23 | 24 | #include 25 | #include 26 | 27 | const unsigned char OSS = 0; 28 | #define BMP180_ADDRESS 0x77 29 | class BMP180 30 | { 31 | public: 32 | void init(void); 33 | long PressureCompensate; 34 | float bmp180GetTemperature(unsigned int ut); 35 | long bmp180GetPressure(unsigned long up); 36 | float calcAltitude(float pressure); 37 | unsigned int bmp180ReadUT(void); 38 | unsigned long bmp180ReadUP(void); 39 | 40 | private: 41 | int ac1; 42 | int ac2; 43 | int ac3; 44 | unsigned int ac4; 45 | unsigned int ac5; 46 | unsigned int ac6; 47 | int b1; 48 | int b2; 49 | int mb; 50 | int mc; 51 | int md; 52 | char bmp180Read(unsigned char address); 53 | int bmp180ReadInt(unsigned char address); 54 | void writeRegister(int deviceAddress, byte address, byte val); 55 | int readRegister(int deviceAddress, byte address); 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /Arduino/MPU9250/README.md: -------------------------------------------------------------------------------- 1 | # IMU_10DOF 2 | 3 | This library is for Grove - IMU 10DOF and Xadow - IMU 10DOF modules. All the mentioned modules are combination of MPU-9250 and BMP180. So this library is the combination of: 4 | 5 | * Library for MPU9250 - thanks to Jeff Rowberg , the MIT license 6 | * Library for BMP180 - thanks to LG, LGPL license 7 | 8 | 9 | ---- 10 | 11 | Contributing to this software is warmly welcomed. You can do this basically by
12 | [forking](https://help.github.com/articles/fork-a-repo), committing modifications and then [pulling requests](https://help.github.com/articles/using-pull-requests) (follow the links above
13 | for operating guide). Adding change log and your contact into file header is encouraged.
14 | Thanks for your contribution. 15 | 16 | Seeed Studio is an open hardware facilitation company based in Shenzhen, China.
17 | Benefiting from local manufacture power and convenient global logistic system,
18 | we integrate resources to serve new era of innovation. Seeed also works with
19 | global distributors and partners to push open hardware movement.
20 | 21 | 22 | 23 | [![Analytics](https://ga-beacon.appspot.com/UA-46589105-3/IMU_10DOF)](https://github.com/igrigorik/ga-beacon) -------------------------------------------------------------------------------- /Arduino/MS5803/examples/test_MS5803/test_MS5803.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | //const uint8_t MS_MODEL = 1; // MS5803-01BA 8 | //const uint8_t MS_MODEL = 2; // MS5803-02BA 9 | const uint8_t MS_MODEL = 5; // MS5803-05BA 10 | //const uint8_t MS_MODEL = 14; // MS5803-14BA 11 | //const uint8_t MS_MODEL = 30; // MS5803-30BA 12 | 13 | MS5803 presstemp(0x76); 14 | const uint8_t loop_delay = 10; // Seconds between readings 15 | uint32_t wake_time = millis(); 16 | 17 | 18 | void setup() { 19 | Serial.begin(57600); 20 | Wire.begin(); 21 | // Start up and get Calibration constants. 22 | presstemp.initialize(MS_MODEL); 23 | if ( presstemp.testConnection() ) Serial.println("We are communicating with MS5803 via I2C."); 24 | else Serial.println("I2C Communications with MS5803 failed."); 25 | } 26 | void loop(){ 27 | Serial.print("Getting temperature"); 28 | presstemp.calcMeasurements(ADC_4096); 29 | Serial.print("The temperature is "); Serial.print(presstemp.getTemp_C()); Serial.println(" C"); 30 | Serial.print("The pressure is "); Serial.print(presstemp.getPress_mBar()); Serial.println(" mBar"); 31 | delay(2000); 32 | } -------------------------------------------------------------------------------- /Arduino/MS5803/keywords.txt: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Datatypes (KEYWORD1) 3 | ########################################### 4 | 5 | MS5803 KEYWORD1 6 | 7 | ########################################### 8 | # Methods and Functions (KEYWORD2) 9 | ########################################### 10 | setAddress KEYWORD2 11 | getAddress KEYWORD2 12 | initialize KEYWORD2 13 | testConnection KEYWORD2 14 | setAtmospheric KEYWORD2 15 | calcMeasurements KEYWORD2 16 | getD1Pressure KEYWORD2 17 | getD2Temperature KEYWORD2 18 | getTemp_C KEYWORD2 19 | getPress_mBar KEYWORD2 20 | getPress_kPa KEYWORD2 21 | initialized KEYWORD2 22 | getDebug KEYWORD2 23 | setDebug KEYWORD2 24 | 25 | ########################################### 26 | # Constants (LITERAL1) 27 | ########################################### 28 | MS5803_ADDRESS LITERAL1 29 | MS5803_ADDRESS_AD0_LOW LITERAL1 30 | MS5803_ADDRESS_AD0_HIGH LITERAL1 31 | MS5803_DEFAULT_ADDRESS LITERAL1 32 | MS5803_RESET LITERAL1 33 | MS5803_PROM_BASE LITERAL1 34 | MS5803_PROM_C1 LITERAL1 35 | MS5803_PROM_C2 LITERAL1 36 | MS5803_PROM_C3 LITERAL1 37 | MS5803_PROM_C4 LITERAL1 38 | MS5803_PROM_C5 LITERAL1 39 | MS5803_PROM_C6 LITERAL1 40 | MS5803_PROM_CRC LITERAL1 41 | MS5803_ADC_READ LITERAL1 42 | CMD_ADC_CONV LITERAL1 -------------------------------------------------------------------------------- /Arduino/SSD1308/example.pde: -------------------------------------------------------------------------------- 1 | // SSD1308 device demonstration Arduino sketch 2 | // 9/02/2011 by Andrew Schamp 3 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 4 | 5 | /* ============================================ 6 | SSD1308 device library code is placed under the MIT license 7 | Copyright (c) 2011 Andrew Schamp 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | =============================================== 27 | */ 28 | 29 | #include 30 | 31 | #define SSD1308_USE_FONT 32 | #include "SSD1308.h" 33 | #undef SSD1308_USE_FONT 34 | 35 | SSD1308 oled; 36 | 37 | void setup() { 38 | // join I2C bus 39 | Wire.begin(); 40 | 41 | // initialize serial communication 42 | Serial.begin(38400); 43 | 44 | // initialize all devices 45 | Serial.println("Initializing I2C devices..."); 46 | oled.initialize(); 47 | 48 | } 49 | 50 | void loop() { 51 | oled.setDisplayOff(); 52 | Serial.println("display off."); 53 | delay(1000); 54 | oled.setDisplayOn(); 55 | Serial.println("display on."); 56 | delay(1000); 57 | oled.clearDisplay(); 58 | Serial.println("display cleared."); 59 | delay(1000); 60 | oled.fillDisplay(); 61 | Serial.println("display filled."); 62 | delay(1000); 63 | oled.clearDisplay(); 64 | Serial.println("display cleared."); 65 | delay(1000); 66 | oled.writeString(0, 0, 8, "Foobar!!"); 67 | Serial.println("printed something."); 68 | delay(5000); 69 | oled.writeString(1, 8, 8, "baz quux"); 70 | Serial.println("printed something."); 71 | delay(5000); 72 | oled.writeString(2, 0, 272, "a long, rather lengthy, extended string passage thing, eh, that just goes on, and on, and on, and on, and on, and on, and on, yes, further, continuing, extending, expanding beyond all reason or sanity!!!!! and yet, there's more! so much more! for ever and ever, oh yeah"); 73 | Serial.println("printed something."); 74 | delay(5000); 75 | delay(3000); 76 | } 77 | -------------------------------------------------------------------------------- /Arduino/SSD1308/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-SSD1308", 3 | "version": "1.0.0", 4 | "keywords": "oled, pled, display, driver, i2cdevlib, i2c", 5 | "description": "SSD1308 is a single-chip CMOS OLED/PLED driver with controller for organic / polymer light emitting diode dot-matrix graphic display system", 6 | "include": "Arduino/SSD1308", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /Arduino/TCA6424A/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-TCA6424A", 3 | "version": "1.0.0", 4 | "keywords": "io, expander, i2cdevlib, i2c", 5 | "description": "The TCA6424A is a low-voltage 24-Bit I2C and SMBus I/O expander with interrupt output, reset and configuration registers", 6 | "include": "Arduino/TCA6424A", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "jrowberg/I2Cdevlib-Core": "*" 15 | }, 16 | "frameworks": "arduino", 17 | "platforms": "*" 18 | } 19 | -------------------------------------------------------------------------------- /BeagleBoneBlack/I2Cdev/I2Cdev.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - Main I2C device class 2 | // Abstracts bit and byte I2C R/W functions into a convenient class 3 | // Based on Arduino's I2Cdev by Jeff Rowberg 4 | // BeagleBone Black (potencially other linux boards) port by Mateus Amarante 5 | // 6 | // Changelog: 7 | // 2018-03-02 - Initial release 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | =============================================== 27 | */ 28 | 29 | #ifndef _I2CDEV_H_ 30 | #define _I2CDEV_H_ 31 | 32 | #include 33 | 34 | #define DEFAULT_BBB_I2C_BUS 2 35 | 36 | class I2Cdev 37 | { 38 | public: 39 | I2Cdev(); 40 | I2Cdev(uint8_t busAddr); 41 | 42 | static int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data); 43 | static int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data); 44 | static int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data); 45 | static int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data); 46 | static int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data); 47 | static int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data); 48 | static int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 49 | static int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 50 | 51 | static bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); 52 | static bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); 53 | static bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); 54 | static bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); 55 | static bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); 56 | static bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); 57 | static bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 58 | static bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 59 | 60 | private: 61 | char path_[13]; // up to "/dev/i2c-255" 62 | }; 63 | 64 | #endif /* _I2CDEV_H_ */ 65 | -------------------------------------------------------------------------------- /EFM32/I2Cdev/I2Cdev.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - Main I2C device class 2 | // Abstracts bit and byte I2C R/W functions into a convenient class 3 | // EFM32 stub port by Nicolas Baldeck 4 | // Based on Arduino's I2Cdev by Jeff Rowberg 5 | // 6 | // Changelog: 7 | // 2015-01-02 - Initial release 8 | 9 | 10 | /* ============================================ 11 | I2Cdev device library code is placed under the MIT license 12 | Copyright (c) 2015 Jeff Rowberg, Nicolas Baldeck 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. 31 | =============================================== 32 | */ 33 | 34 | #ifndef _I2CDEV_H_ 35 | #define _I2CDEV_H_ 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | #define I2C_SDA_PORT gpioPortA 42 | #define I2C_SDA_PIN 0 43 | #define I2C_SDA_MODE gpioModeWiredAnd 44 | #define I2C_SDA_DOUT 1 45 | 46 | #define I2C_SCL_PORT gpioPortA 47 | #define I2C_SCL_PIN 1 48 | #define I2C_SCL_MODE gpioModeWiredAnd 49 | #define I2C_SCL_DOUT 1 50 | 51 | #define I2CDEV_DEFAULT_READ_TIMEOUT 1000000 52 | 53 | class I2Cdev { 54 | public: 55 | I2Cdev(); 56 | 57 | static void initialize(); 58 | static void enable(bool isEnabled); 59 | 60 | static int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); 61 | //TODO static int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); 62 | static int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); 63 | //TODO static int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); 64 | static int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); 65 | //TODO static int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); 66 | static int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); 67 | //TODO static int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); 68 | 69 | static bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); 70 | //TODO static bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); 71 | static bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); 72 | //TODO static bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); 73 | static bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); 74 | //TODO static bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); 75 | //TODO static bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 76 | //TODO static bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 77 | 78 | static uint16_t readTimeout; 79 | 80 | private: 81 | static I2C_TransferReturn_TypeDef transfer(I2C_TransferSeq_TypeDef *seq, uint16_t timeout=I2Cdev::readTimeout); 82 | }; 83 | 84 | #endif /* _I2CDEV_H_ */ 85 | -------------------------------------------------------------------------------- /ESP32_ESP-IDF/.idea/ESP32_ESP-IDF.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ESP32_ESP-IDF/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ESP32_ESP-IDF/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /ESP32_ESP-IDF/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ESP32_ESP-IDF/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ESP32_ESP-IDF/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /ESP32_ESP-IDF/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(ESP32_ESP-IDF) -------------------------------------------------------------------------------- /ESP32_ESP-IDF/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := app-template 7 | 8 | include $(IDF_PATH)/make/project.mk 9 | 10 | -------------------------------------------------------------------------------- /ESP32_ESP-IDF/README.md: -------------------------------------------------------------------------------- 1 | I2CDev library rewritted to match esp-idf. DMP should work, only need is to setup 2 | mpu.setXGyroOffset(220); 3 | mpu.setYGyroOffset(76); 4 | mpu.setZGyroOffset(-85); 5 | mpu.setZAccelOffset(1788); 6 | and eventually change last value in components/MPU6050/MPU6050_6Axis_MotionApps20.h. 7 | -------------------------------------------------------------------------------- /ESP32_ESP-IDF/components/I2Cdev/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "I2Cdev.cpp" 2 | INCLUDE_DIRS "." 3 | ) -------------------------------------------------------------------------------- /ESP32_ESP-IDF/components/I2Cdev/I2Cdev.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - Main I2C device class 2 | // Abstracts bit and byte I2C R/W functions into a convenient class 3 | // EFM32 stub port by Nicolas Baldeck 4 | // Based on Arduino's I2Cdev by Jeff Rowberg 5 | // 6 | // Changelog: 7 | // 2015-01-02 - Initial release 8 | 9 | 10 | /* ============================================ 11 | I2Cdev device library code is placed under the MIT license 12 | Copyright (c) 2015 Jeff Rowberg, Nicolas Baldeck 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. 31 | =============================================== 32 | */ 33 | 34 | #ifndef _I2CDEV_H_ 35 | #define _I2CDEV_H_ 36 | 37 | #include 38 | 39 | #define I2C_SDA_PORT gpioPortA 40 | #define I2C_SDA_PIN 0 41 | #define I2C_SDA_MODE gpioModeWiredAnd 42 | #define I2C_SDA_DOUT 1 43 | 44 | #define I2C_SCL_PORT gpioPortA 45 | #define I2C_SCL_PIN 1 46 | #define I2C_SCL_MODE gpioModeWiredAnd 47 | #define I2C_SCL_DOUT 1 48 | 49 | #define I2CDEV_DEFAULT_READ_TIMEOUT 1000 50 | 51 | class I2Cdev { 52 | public: 53 | I2Cdev(); 54 | 55 | static void initialize(); 56 | static void enable(bool isEnabled); 57 | 58 | static int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); 59 | //TODO static int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); 60 | static int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); 61 | //TODO static int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); 62 | static int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); 63 | static int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); 64 | static int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); 65 | //TODO static int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); 66 | 67 | static bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); 68 | //TODO static bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); 69 | static bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); 70 | //TODO static bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); 71 | static bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); 72 | static bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); 73 | static bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 74 | //TODO static bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 75 | 76 | static uint16_t readTimeout; 77 | 78 | //private: 79 | static void SelectRegister(uint8_t dev, uint8_t reg); 80 | //static I2C_TransferReturn_TypeDef transfer(I2C_TransferSeq_TypeDef *seq, uint16_t timeout=I2Cdev::readTimeout); 81 | }; 82 | 83 | #endif /* _I2CDEV_H_ */ 84 | -------------------------------------------------------------------------------- /ESP32_ESP-IDF/components/I2Cdev/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main component makefile. 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | 10 | COMPONENT_ADD_INCLUDEDIRS=. -------------------------------------------------------------------------------- /ESP32_ESP-IDF/components/MPU6050/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "MPU6050.cpp" 2 | INCLUDE_DIRS "." 3 | REQUIRES I2Cdev 4 | ) -------------------------------------------------------------------------------- /ESP32_ESP-IDF/components/MPU6050/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main component makefile. 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | 10 | COMPONENT_ADD_INCLUDEDIRS=. -------------------------------------------------------------------------------- /ESP32_ESP-IDF/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_SRCS "main.cpp example.cpp") 2 | set(COMPONENT_ADD_INCLUDEDIRS ".") 3 | 4 | register_component() 5 | -------------------------------------------------------------------------------- /ESP32_ESP-IDF/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main component makefile. 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | -------------------------------------------------------------------------------- /ESP32_ESP-IDF/main/example.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Display.c 3 | * 4 | * Created on: 14.08.2017 5 | * Author: darek 6 | */ 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "MPU6050.h" 13 | #include "MPU6050_6Axis_MotionApps20.h" 14 | #include "sdkconfig.h" 15 | 16 | #define PIN_SDA 21 17 | #define PIN_CLK 22 18 | 19 | Quaternion q; // [w, x, y, z] quaternion container 20 | VectorFloat gravity; // [x, y, z] gravity vector 21 | float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector 22 | uint16_t packetSize = 42; // expected DMP packet size (default is 42 bytes) 23 | uint16_t fifoCount; // count of all bytes currently in FIFO 24 | uint8_t fifoBuffer[64]; // FIFO storage buffer 25 | uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU 26 | 27 | void task_initI2C(void *ignore) { 28 | i2c_config_t conf; 29 | conf.mode = I2C_MODE_MASTER; 30 | conf.sda_io_num = (gpio_num_t)PIN_SDA; 31 | conf.scl_io_num = (gpio_num_t)PIN_CLK; 32 | conf.sda_pullup_en = GPIO_PULLUP_ENABLE; 33 | conf.scl_pullup_en = GPIO_PULLUP_ENABLE; 34 | conf.master.clk_speed = 400000; 35 | ESP_ERROR_CHECK(i2c_param_config(I2C_NUM_0, &conf)); 36 | ESP_ERROR_CHECK(i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0)); 37 | vTaskDelete(NULL); 38 | } 39 | 40 | void task_display(void*){ 41 | MPU6050 mpu = MPU6050(); 42 | mpu.initialize(); 43 | mpu.dmpInitialize(); 44 | 45 | // This need to be setup individually 46 | // mpu.setXGyroOffset(220); 47 | // mpu.setYGyroOffset(76); 48 | // mpu.setZGyroOffset(-85); 49 | // mpu.setZAccelOffset(1788); 50 | mpu.CalibrateAccel(6); 51 | mpu.CalibrateGyro(6); 52 | 53 | mpu.setDMPEnabled(true); 54 | 55 | while(1){ 56 | mpuIntStatus = mpu.getIntStatus(); 57 | // get current FIFO count 58 | fifoCount = mpu.getFIFOCount(); 59 | 60 | if ((mpuIntStatus & 0x10) || fifoCount == 1024) { 61 | // reset so we can continue cleanly 62 | mpu.resetFIFO(); 63 | 64 | // otherwise, check for DMP data ready interrupt frequently) 65 | } else if (mpuIntStatus & 0x02) { 66 | // wait for correct available data length, should be a VERY short wait 67 | while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); 68 | 69 | // read a packet from FIFO 70 | 71 | mpu.getFIFOBytes(fifoBuffer, packetSize); 72 | mpu.dmpGetQuaternion(&q, fifoBuffer); 73 | mpu.dmpGetGravity(&gravity, &q); 74 | mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); 75 | printf("YAW: %3.1f, ", ypr[0] * 180/M_PI); 76 | printf("PITCH: %3.1f, ", ypr[1] * 180/M_PI); 77 | printf("ROLL: %3.1f \n", ypr[2] * 180/M_PI); 78 | } 79 | 80 | //Best result is to match with DMP refresh rate 81 | // Its last value in components/MPU6050/MPU6050_6Axis_MotionApps20.h file line 310 82 | // Now its 0x13, which means DMP is refreshed with 10Hz rate 83 | // vTaskDelay(5/portTICK_PERIOD_MS); 84 | } 85 | 86 | vTaskDelete(NULL); 87 | } 88 | -------------------------------------------------------------------------------- /ESP32_ESP-IDF/main/main.cpp: -------------------------------------------------------------------------------- 1 | #include "freertos/FreeRTOS.h" 2 | #include "sdkconfig.h" 3 | #include "freertos/task.h" 4 | 5 | extern "C" { 6 | void app_main(void); 7 | } 8 | 9 | extern void task_initI2C(void*); 10 | extern void task_display(void*); 11 | 12 | void app_main(void) 13 | { 14 | xTaskCreate(&task_initI2C, "mpu_task", 2048, NULL, 5, NULL); 15 | vTaskDelay(500/portTICK_PERIOD_MS); 16 | xTaskCreate(&task_display, "disp_task", 8192, NULL, 5, NULL); 17 | } 18 | -------------------------------------------------------------------------------- /Jennic/I2Cdev/I2Cdev.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - Main I2C device class header file 2 | // Abstracts bit and byte I2C R/W functions into a convenient class 3 | // 6/9/2012 by Jeff Rowberg 4 | // 11/28/2014 by Marton Sebok 5 | // 24/06/2015 by Grégoire Surrel 6 | // 7 | // Changelog: 8 | // 2014-11-28 - ported to PIC18 peripheral library from Arduino code 9 | 10 | /* ============================================ 11 | I2Cdev device library code is placed under the MIT license 12 | Copyright (c) 2013 Jeff Rowberg 13 | Copyright (c) 2014 Marton Sebok 14 | Copyright (c) 2015 Grégoire Surrel 15 | 16 | Permission is hereby granted, free of charge, to any person obtaining a copy 17 | of this software and associated documentation files (the "Software"), to deal 18 | in the Software without restriction, including without limitation the rights 19 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20 | copies of the Software, and to permit persons to whom the Software is 21 | furnished to do so, subject to the following conditions: 22 | 23 | The above copyright notice and this permission notice shall be included in 24 | all copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 32 | THE SOFTWARE. 33 | =============================================== 34 | */ 35 | 36 | #ifndef _I2CDEV_H_ 37 | #define _I2CDEV_H_ 38 | 39 | #include 40 | 41 | int8 I2Cdev_readBit(uint8 devAddr, uint8 regAddr, uint8 bitNum, uint8 *data); 42 | int8 I2Cdev_readBitW(uint8 devAddr, uint8 regAddr, uint8 bitNum, uint16 *data); 43 | int8 I2Cdev_readBits(uint8 devAddr, uint8 regAddr, uint8 bitStart, uint8 length, uint8 *data); 44 | int8 I2Cdev_readBitsW(uint8 devAddr, uint8 regAddr, uint8 bitStart, uint8 length, uint16 *data); 45 | int8 I2Cdev_readByte(uint8 devAddr, uint8 regAddr, uint8 *data); 46 | int8 I2Cdev_readWord(uint8 devAddr, uint8 regAddr, uint16 *data); 47 | int8 I2Cdev_readBytes(uint8 devAddr, uint8 regAddr, uint8 length, uint8 *data); 48 | int8 I2Cdev_readWords(uint8 devAddr, uint8 regAddr, uint8 length, uint16 *data); 49 | 50 | uint8 I2Cdev_writeBit(uint8 devAddr, uint8 regAddr, uint8 bitNum, uint8 data); 51 | uint8 I2Cdev_writeBitW(uint8 devAddr, uint8 regAddr, uint8 bitNum, uint16 data); 52 | uint8 I2Cdev_writeBits(uint8 devAddr, uint8 regAddr, uint8 bitStart, uint8 length, uint8 data); 53 | uint8 I2Cdev_writeBitsW(uint8 devAddr, uint8 regAddr, uint8 bitStart, uint8 length, uint16 data); 54 | uint8 I2Cdev_writeByte(uint8 devAddr, uint8 regAddr, uint8 data); 55 | uint8 I2Cdev_writeWord(uint8 devAddr, uint8 regAddr, uint16 data); 56 | uint8 I2Cdev_writeBytes(uint8 devAddr, uint8 regAddr, uint8 length, uint8 *data); 57 | uint8 I2Cdev_writeWords(uint8 devAddr, uint8 regAddr, uint8 length, uint16 *data); 58 | 59 | #endif /* _I2CDEV_H_ */ 60 | -------------------------------------------------------------------------------- /Jennic/README.md: -------------------------------------------------------------------------------- 1 | # I2C Device Library for Jennic 2 | 3 | ## I2Cdev 4 | We use JenOS peripheral libraries. 5 | 6 | ## Devices 7 | Currently only MPU6050 is supported without DMP functions. There is no address set dynamically so currently only one MPU6050 can be read (or address must be changed manually each time before reading/writing) 8 | 9 | Adding more functions and devices should be straighforward after reading the source code. 10 | 11 | ## Licence 12 | I2Cdev device library code is placed under the MIT license. 13 | 14 | _Copyright (c) 2011 Jeff Rowberg. Copyright (c) 2014 Marton Sebok. Copyright (c) 2015 Grégoire Surrel._ 15 | -------------------------------------------------------------------------------- /MSP430/AK8975/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-AK8975", 3 | "version": "1.0.0", 4 | "keywords": "compass, sensor, i2cdevlib, i2c", 5 | "description": "AK8975 is 3-axis electronic compass IC with high sensitive Hall sensor technology", 6 | "include": "MSP430/AK8975", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | [ 14 | { 15 | "name": "I2Cdevlib-Core", 16 | "platforms": "timsp430" 17 | }, 18 | { 19 | "name": "I2Cdevlib-MPU6050", 20 | "platforms": "timsp430" 21 | } 22 | ], 23 | "frameworks": "energia", 24 | "platforms": "timsp430" 25 | } 26 | -------------------------------------------------------------------------------- /MSP430/I2Cdev/ArduinoWrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ArduinoWrapper.h 3 | * 4 | * Created on: Mar 27, 2013 5 | * Author: zoellner 6 | */ 7 | 8 | #ifndef ARDUINOWRAPPER_H_ 9 | #define ARDUINOWRAPPER_H_ 10 | 11 | 12 | 13 | //Standard Libraries 14 | #include 15 | #include 16 | #include "msp430_i2c.h" 17 | 18 | //TODO functions that need wrapper: millis(), Serial.print 19 | 20 | #define millis() 0 21 | 22 | #endif /* ARDUINOWRAPPER_H_ */ 23 | -------------------------------------------------------------------------------- /MSP430/I2Cdev/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For I2Cdev 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | I2Cdev KEYWORD1 9 | 10 | ####################################### 11 | # Methods and Functions (KEYWORD2) 12 | ####################################### 13 | 14 | readBit KEYWORD2 15 | readBitW KEYWORD2 16 | readBits KEYWORD2 17 | readBitsW KEYWORD2 18 | readByte KEYWORD2 19 | readBytes KEYWORD2 20 | readWord KEYWORD2 21 | readWords KEYWORD2 22 | writeBit KEYWORD2 23 | writeBitW KEYWORD2 24 | writeBits KEYWORD2 25 | writeBitsW KEYWORD2 26 | writeByte KEYWORD2 27 | writeBytes KEYWORD2 28 | writeWord KEYWORD2 29 | writeWords KEYWORD2 30 | 31 | ####################################### 32 | # Instances (KEYWORD2) 33 | ####################################### 34 | 35 | ####################################### 36 | # Constants (LITERAL1) 37 | ####################################### 38 | 39 | -------------------------------------------------------------------------------- /MSP430/I2Cdev/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-Core", 3 | "version": "1.0.0", 4 | "keywords": "i2cdevlib, i2c", 5 | "description": "The I2C Device Library (I2Cdevlib) is a collection of uniform and well-documented classes to provide simple and intuitive interfaces to I2C devices.", 6 | "include": "MSP430/I2Cdev", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "frameworks": "energia", 13 | "platforms": "timsp430" 14 | } 15 | -------------------------------------------------------------------------------- /MSP430/MPU6050/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-MPU6050", 3 | "version": "1.0.0", 4 | "keywords": "gyroscope, accelerometer, sensor, i2cdevlib, i2c", 5 | "description": "The MPU6050 combines a 3-axis gyroscope and a 3-axis accelerometer on the same silicon die together with an onboard Digital Motion Processor(DMP) which processes complex 6-axis MotionFusion algorithms", 6 | "include": "MSP430/MPU6050", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/jrowberg/i2cdevlib.git" 11 | }, 12 | "dependencies": 13 | { 14 | "name": "I2Cdevlib-Core", 15 | "platforms": "timsp430" 16 | }, 17 | "frameworks": "energia", 18 | "platforms": "timsp430" 19 | } 20 | -------------------------------------------------------------------------------- /PIC18/I2Cdev/I2Cdev.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - Main I2C device class header file 2 | // Abstracts bit and byte I2C R/W functions into a convenient class 3 | // 6/9/2012 by Jeff Rowberg 4 | // 11/28/2014 by Marton Sebok 5 | // 6 | // Changelog: 7 | // 2014-11-28 - ported to PIC18 peripheral library from Arduino code 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2013 Jeff Rowberg 12 | Copyright (c) 2014 Marton Sebok 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. 31 | =============================================== 32 | */ 33 | 34 | #ifndef _I2CDEV_H_ 35 | #define _I2CDEV_H_ 36 | 37 | #ifndef __XC8 38 | #error Use XC8 for compiling 39 | #endif 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | int8_t I2Cdev_readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data); 47 | int8_t I2Cdev_readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data); 48 | int8_t I2Cdev_readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data); 49 | int8_t I2Cdev_readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data); 50 | int8_t I2Cdev_readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data); 51 | int8_t I2Cdev_readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data); 52 | int8_t I2Cdev_readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 53 | int8_t I2Cdev_readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 54 | 55 | bool I2Cdev_writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); 56 | bool I2Cdev_writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); 57 | bool I2Cdev_writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); 58 | bool I2Cdev_writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); 59 | bool I2Cdev_writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); 60 | bool I2Cdev_writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); 61 | bool I2Cdev_writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 62 | bool I2Cdev_writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 63 | 64 | #endif /* _I2CDEV_H_ */ 65 | -------------------------------------------------------------------------------- /PIC18/MPU6050/Examples/MPU6050_raw.X/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # There exist several targets which are by default empty and which can be 3 | # used for execution of your targets. These targets are usually executed 4 | # before and after some main targets. They are: 5 | # 6 | # .build-pre: called before 'build' target 7 | # .build-post: called after 'build' target 8 | # .clean-pre: called before 'clean' target 9 | # .clean-post: called after 'clean' target 10 | # .clobber-pre: called before 'clobber' target 11 | # .clobber-post: called after 'clobber' target 12 | # .all-pre: called before 'all' target 13 | # .all-post: called after 'all' target 14 | # .help-pre: called before 'help' target 15 | # .help-post: called after 'help' target 16 | # 17 | # Targets beginning with '.' are not intended to be called on their own. 18 | # 19 | # Main targets can be executed directly, and they are: 20 | # 21 | # build build a specific configuration 22 | # clean remove built files from a configuration 23 | # clobber remove all built files 24 | # all build all configurations 25 | # help print help mesage 26 | # 27 | # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and 28 | # .help-impl are implemented in nbproject/makefile-impl.mk. 29 | # 30 | # Available make variables: 31 | # 32 | # CND_BASEDIR base directory for relative paths 33 | # CND_DISTDIR default top distribution directory (build artifacts) 34 | # CND_BUILDDIR default top build directory (object files, ...) 35 | # CONF name of current configuration 36 | # CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) 37 | # CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) 38 | # CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) 39 | # CND_PACKAGE_DIR_${CONF} directory of package (current configuration) 40 | # CND_PACKAGE_NAME_${CONF} name of package (current configuration) 41 | # CND_PACKAGE_PATH_${CONF} path to package (current configuration) 42 | # 43 | # NOCDDL 44 | 45 | 46 | # Environment 47 | MKDIR=mkdir 48 | CP=cp 49 | CCADMIN=CCadmin 50 | RANLIB=ranlib 51 | 52 | 53 | # build 54 | build: .build-post 55 | 56 | .build-pre: 57 | # Add your pre 'build' code here... 58 | 59 | .build-post: .build-impl 60 | # Add your post 'build' code here... 61 | 62 | 63 | # clean 64 | clean: .clean-post 65 | 66 | .clean-pre: 67 | # Add your pre 'clean' code here... 68 | # WARNING: the IDE does not call this target since it takes a long time to 69 | # simply run make. Instead, the IDE removes the configuration directories 70 | # under build and dist directly without calling make. 71 | # This target is left here so people can do a clean when running a clean 72 | # outside the IDE. 73 | 74 | .clean-post: .clean-impl 75 | # Add your post 'clean' code here... 76 | 77 | 78 | # clobber 79 | clobber: .clobber-post 80 | 81 | .clobber-pre: 82 | # Add your pre 'clobber' code here... 83 | 84 | .clobber-post: .clobber-impl 85 | # Add your post 'clobber' code here... 86 | 87 | 88 | # all 89 | all: .all-post 90 | 91 | .all-pre: 92 | # Add your pre 'all' code here... 93 | 94 | .all-post: .all-impl 95 | # Add your post 'all' code here... 96 | 97 | 98 | # help 99 | help: .help-post 100 | 101 | .help-pre: 102 | # Add your pre 'help' code here... 103 | 104 | .help-post: .help-impl 105 | # Add your post 'help' code here... 106 | 107 | 108 | 109 | # include project implementation makefile 110 | include nbproject/Makefile-impl.mk 111 | 112 | # include project make variables 113 | include nbproject/Makefile-variables.mk 114 | -------------------------------------------------------------------------------- /PIC18/MPU6050/Examples/MPU6050_raw.X/funclist: -------------------------------------------------------------------------------- 1 | _MPU6050_initialize: CODE, 6334 0 24 2 | _I2Cdev_writeBytes: CODE, 5202 0 156 3 | _MPU6050_getDeviceID: CODE, 6310 0 24 4 | __stringdata: SMALLCONST, 3851 0 193 5 | _putch: CODE, 6552 0 12 6 | _MPU6050_getXGyroOffset: CODE, 6188 0 42 7 | _MPU6050_getYGyroOffset: CODE, 6104 0 42 8 | _MPU6050_getZGyroOffset: CODE, 6020 0 42 9 | _dpowers: SMALLCONST, 3841 0 10 10 | _I2Cdev_readByte: CODE, 6514 0 20 11 | _I2Cdev_writeBit: CODE, 5474 0 110 12 | _main: CODE, 4046 0 342 13 | _I2Cdev_readBits: CODE, 5584 0 108 14 | _MPU6050_setFullScaleGyroRange: CODE, 6358 0 24 15 | _MPU6050_setSleepEnabled: CODE, 6474 0 20 16 | _MPU6050: CODE, 6584 0 8 17 | _MPU6050_setClockSource: CODE, 6406 0 24 18 | __initialization: CODE, 6430 0 12 19 | ___lwdiv: CODE, 5884 0 74 20 | _MPU6050_setFullScaleAccelRange: CODE, 6382 0 24 21 | _baud1USART: CODE, 6576 0 8 22 | _Write1USART: CODE, 6534 0 18 23 | _printf: CODE, 4706 0 294 24 | ___lwmod: CODE, 5958 0 62 25 | _MPU6050_testConnection: CODE, 6564 0 12 26 | _ReadI2C1: CODE, 6272 0 38 27 | _MPU6050_getXAccelOffset: CODE, 6230 0 42 28 | _MPU6050_getYAccelOffset: CODE, 6146 0 42 29 | _MPU6050_getZAccelOffset: CODE, 6062 0 42 30 | _WriteI2C1: CODE, 5692 0 108 31 | _I2Cdev_writeByte: CODE, 6494 0 20 32 | _Open1USART: CODE, 5800 0 84 33 | _I2Cdev_readBytes: CODE, 4388 0 318 34 | _I2Cdev_writeBits: CODE, 5358 0 116 35 | _MPU6050_getMotion6: CODE, 5000 0 202 36 | _OpenI2C1: CODE, 6452 0 22 37 | Total: 2739 -------------------------------------------------------------------------------- /PIC18/MPU6050/Examples/MPU6050_raw.X/l.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrowberg/i2cdevlib/170bad1f4a97b074cd33238a5523c7382a3d8f1e/PIC18/MPU6050/Examples/MPU6050_raw.X/l.obj -------------------------------------------------------------------------------- /PIC18/MPU6050/Examples/MPU6050_raw.X/nbproject/Makefile-genesis.properties: -------------------------------------------------------------------------------- 1 | # 2 | #Fri Nov 28 22:55:53 CET 2014 3 | default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc8\\v1.32\\bin 4 | com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=20b996ec0591c93034157100c3d90ac3 5 | default.languagetoolchain.version=1.32 6 | host.platform=windows 7 | conf.ids=default 8 | default.com-microchip-mplab-nbide-toolchainXC8-XC8LanguageToolchain.md5=533e5c34133c5d768bcb87ffcec948e1 9 | -------------------------------------------------------------------------------- /PIC18/MPU6050/Examples/MPU6050_raw.X/nbproject/Makefile-impl.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated Makefile - do not edit! 3 | # 4 | # Edit the Makefile in the project folder instead (../Makefile). Each target 5 | # has a pre- and a post- target defined where you can add customization code. 6 | # 7 | # This makefile implements macros and targets common to all configurations. 8 | # 9 | # NOCDDL 10 | 11 | 12 | # Building and Cleaning subprojects are done by default, but can be controlled with the SUB 13 | # macro. If SUB=no, subprojects will not be built or cleaned. The following macro 14 | # statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf 15 | # and .clean-reqprojects-conf unless SUB has the value 'no' 16 | SUB_no=NO 17 | SUBPROJECTS=${SUB_${SUB}} 18 | BUILD_SUBPROJECTS_=.build-subprojects 19 | BUILD_SUBPROJECTS_NO= 20 | BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} 21 | CLEAN_SUBPROJECTS_=.clean-subprojects 22 | CLEAN_SUBPROJECTS_NO= 23 | CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} 24 | 25 | 26 | # Project Name 27 | PROJECTNAME=MPU6050_raw.X 28 | 29 | # Active Configuration 30 | DEFAULTCONF=default 31 | CONF=${DEFAULTCONF} 32 | 33 | # All Configurations 34 | ALLCONFS=default 35 | 36 | 37 | # build 38 | .build-impl: .build-pre 39 | ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf 40 | 41 | 42 | # clean 43 | .clean-impl: .clean-pre 44 | ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf 45 | 46 | # clobber 47 | .clobber-impl: .clobber-pre .depcheck-impl 48 | ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default clean 49 | 50 | 51 | 52 | # all 53 | .all-impl: .all-pre .depcheck-impl 54 | ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default build 55 | 56 | 57 | 58 | # dependency checking support 59 | .depcheck-impl: 60 | # @echo "# This code depends on make tool being used" >.dep.inc 61 | # @if [ -n "${MAKE_VERSION}" ]; then \ 62 | # echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \ 63 | # echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ 64 | # echo "include \$${DEPFILES}" >>.dep.inc; \ 65 | # echo "endif" >>.dep.inc; \ 66 | # else \ 67 | # echo ".KEEP_STATE:" >>.dep.inc; \ 68 | # echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ 69 | # fi 70 | -------------------------------------------------------------------------------- /PIC18/MPU6050/Examples/MPU6050_raw.X/nbproject/Makefile-local-default.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated Makefile - do not edit! 3 | # 4 | # 5 | # This file contains information about the location of compilers and other tools. 6 | # If you commmit this file into your revision control server, you will be able to 7 | # to checkout the project and build it from the command line with make. However, 8 | # if more than one person works on the same project, then this file might show 9 | # conflicts since different users are bound to have compilers in different places. 10 | # In that case you might choose to not commit this file and let MPLAB X recreate this file 11 | # for each user. The disadvantage of not commiting this file is that you must run MPLAB X at 12 | # least once so the file gets created and the project can be built. Finally, you can also 13 | # avoid using this file at all if you are only building from the command line with make. 14 | # You can invoke make with the values of the macros: 15 | # $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ... 16 | # 17 | SHELL=cmd.exe 18 | PATH_TO_IDE_BIN=C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/ 19 | # Adding MPLAB X bin directory to path. 20 | PATH:=C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/:$(PATH) 21 | # Path to java used to run MPLAB X when this makefile was created 22 | MP_JAVA_PATH="C:\Program Files (x86)\Microchip\MPLABX\sys\java\jre1.7.0_25-windows-x64\java-windows/bin/" 23 | OS_CURRENT="$(shell uname -s)" 24 | MP_CC="C:\Program Files (x86)\Microchip\xc8\v1.32\bin\xc8.exe" 25 | # MP_CPPC is not defined 26 | # MP_BC is not defined 27 | MP_AS="C:\Program Files (x86)\Microchip\xc8\v1.32\bin\xc8.exe" 28 | # MP_LD is not defined 29 | # MP_AR is not defined 30 | DEP_GEN=${MP_JAVA_PATH}java -jar "C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/extractobjectdependencies.jar" 31 | MP_CC_DIR="C:\Program Files (x86)\Microchip\xc8\v1.32\bin" 32 | # MP_CPPC_DIR is not defined 33 | # MP_BC_DIR is not defined 34 | MP_AS_DIR="C:\Program Files (x86)\Microchip\xc8\v1.32\bin" 35 | # MP_LD_DIR is not defined 36 | # MP_AR_DIR is not defined 37 | # MP_BC_DIR is not defined 38 | -------------------------------------------------------------------------------- /PIC18/MPU6050/Examples/MPU6050_raw.X/nbproject/Makefile-variables.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated - do not edit! 3 | # 4 | # NOCDDL 5 | # 6 | CND_BASEDIR=`pwd` 7 | # default configuration 8 | CND_ARTIFACT_DIR_default=dist/default/production 9 | CND_ARTIFACT_NAME_default=MPU6050_raw.X.production.hex 10 | CND_ARTIFACT_PATH_default=dist/default/production/MPU6050_raw.X.production.hex 11 | CND_PACKAGE_DIR_default=${CND_DISTDIR}/default/package 12 | CND_PACKAGE_NAME_default=mpu6050raw.x.tar 13 | CND_PACKAGE_PATH_default=${CND_DISTDIR}/default/package/mpu6050raw.x.tar 14 | -------------------------------------------------------------------------------- /PIC18/MPU6050/Examples/MPU6050_raw.X/nbproject/Package-default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # 4 | # Generated - do not edit! 5 | # 6 | 7 | # Macros 8 | TOP=`pwd` 9 | CND_CONF=default 10 | CND_DISTDIR=dist 11 | TMPDIR=build/${CND_CONF}/${IMAGE_TYPE}/tmp-packaging 12 | TMPDIRNAME=tmp-packaging 13 | OUTPUT_PATH=dist/${CND_CONF}/${IMAGE_TYPE}/MPU6050_raw.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} 14 | OUTPUT_BASENAME=MPU6050_raw.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} 15 | PACKAGE_TOP_DIR=mpu6050raw.x/ 16 | 17 | # Functions 18 | function checkReturnCode 19 | { 20 | rc=$? 21 | if [ $rc != 0 ] 22 | then 23 | exit $rc 24 | fi 25 | } 26 | function makeDirectory 27 | # $1 directory path 28 | # $2 permission (optional) 29 | { 30 | mkdir -p "$1" 31 | checkReturnCode 32 | if [ "$2" != "" ] 33 | then 34 | chmod $2 "$1" 35 | checkReturnCode 36 | fi 37 | } 38 | function copyFileToTmpDir 39 | # $1 from-file path 40 | # $2 to-file path 41 | # $3 permission 42 | { 43 | cp "$1" "$2" 44 | checkReturnCode 45 | if [ "$3" != "" ] 46 | then 47 | chmod $3 "$2" 48 | checkReturnCode 49 | fi 50 | } 51 | 52 | # Setup 53 | cd "${TOP}" 54 | mkdir -p ${CND_DISTDIR}/${CND_CONF}/package 55 | rm -rf ${TMPDIR} 56 | mkdir -p ${TMPDIR} 57 | 58 | # Copy files and create directories and links 59 | cd "${TOP}" 60 | makeDirectory ${TMPDIR}/mpu6050raw.x/bin 61 | copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 62 | 63 | 64 | # Generate tar file 65 | cd "${TOP}" 66 | rm -f ${CND_DISTDIR}/${CND_CONF}/package/mpu6050raw.x.tar 67 | cd ${TMPDIR} 68 | tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/package/mpu6050raw.x.tar * 69 | checkReturnCode 70 | 71 | # Cleanup 72 | cd "${TOP}" 73 | rm -rf ${TMPDIR} 74 | -------------------------------------------------------------------------------- /PIC18/MPU6050/Examples/MPU6050_raw.X/nbproject/project.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrowberg/i2cdevlib/170bad1f4a97b074cd33238a5523c7382a3d8f1e/PIC18/MPU6050/Examples/MPU6050_raw.X/nbproject/project.properties -------------------------------------------------------------------------------- /PIC18/MPU6050/Examples/MPU6050_raw.X/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | com.microchip.mplab.nbide.embedded.makeproject 3 | 4 | 5 | MPU6050_raw 6 | 84892e89-df8e-441e-9542-2524d6b2dc5a 7 | 0 8 | c 9 | 10 | h 11 | 12 | UTF-8 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /PIC18/README.md: -------------------------------------------------------------------------------- 1 | # I2C Device Library for PIC18 2 | 3 | ## I2Cdev 4 | We use XC8's peripheral libraries (_plib_), read timeout is not implemented. 5 | 6 | ## Devices 7 | Currently only MPU6050 is supported without DMP functions. There's an example MPLABX project showing how to read raw data from the MPU. 8 | 9 | Adding more functions and devices should be straighforward after reading the source code. 10 | 11 | ## Licence 12 | I2Cdev device library code is placed under the MIT license. 13 | 14 | _Copyright (c) 2011 Jeff Rowberg. Copyright (c) 2014 Marton Sebok._ 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # I2C Device Library 2 | 3 | The I2C Device Library (i2cdevlib) is a collection of mostly uniform and well-documented classes to provide simple and intuitive interfaces to I2C devices. Each device is built to make use of the generic "I2Cdev" class, which abstracts the I2C bit- and byte-level communication away from each specific device class, making it easy to keep the device class clean while providing a simple way to modify just one class to port the I2C communication code onto different platforms (Arduino, PIC, MSP430, Jennic, simple bit-banging, etc.). Device classes are designed to provide complete coverage of all functionality described by each device's documentation, plus any generic convenience functions that are helpful. 4 | 5 | There are examples in many of the classes that demonstrate basic usage patterns. The I2Cdev class is built to be used statically, reducing the memory requirement if you have multiple I2C devices in your project. Only one instance of the I2Cdev class is required. Recent additions as of late 2021 have also made it possible to pass in non-default `Wire` objects (in the Arduino environment) to allow using multiple I2C transceivers at the same time, specifically because of the number of people who wanted to use up to four MPU-6050 IMUs without I2C mux ICs involved. 6 | 7 | Documentation for each class is created using Doxygen-style comments placed in each class definition file, based on the information available in each device's datasheet. This documentation is available in HTML format on the i2cdevlib.com website, which also holds helpful information for most of the classes present here on the repository. 8 | 9 | ## Installation 10 | 11 | Due to my...ahem...unfortunate ignorance way back when I first created this project, the entire codebase (all platforms, cores, and device libraries) are all inside of this one giant repository. That means there's no easy IDE integration the way most libraries work in the Arduino world and elsewhere. Instead, do the following: 12 | 13 | 1. Clone or [download a .zip archive](https://github.com/jrowberg/i2cdevlib/archive/refs/heads/master.zip) of the repo 14 | 2. Move or copy the relevant core and device drivers into your project tree or library subfolder
(For Arduino, this means the `/Arduino/I2Cdev` and `/Arduino/MPU6050` folders, for example) 15 | 3. Rescan libraries or restart your IDE if necessary 16 | 17 | For both usage and development, I've found that it's best to clone using the git client of your choice, and then create symlinks as needed from the master repository sources into your development location(s). This is usually more intuitive for people who use Linux, but it can be done in Windows as well using the `mklink /D` command. See [this page](https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/) for a set of Windows-specific instructions with screenshots. 18 | 19 | ## Usage 20 | 21 | Exact usage varies from device to device, but most (especially the more popular ones) include example projects demonstrating the basics. Refer to those examples for the best material currently available. 22 | 23 | ## Contributing 24 | 25 | Want a library for a device that isn't up on the repository? You can either request it in the discussion area for this repo on Github, or fork the code and write it yourself. 26 | 27 | Realistically, Option B is more reliable. Try to mimic the structure and code conventions of the existing codebase as much as possible. If you go this route, please use the following approach: 28 | 29 | 1. Fork the repository to your own user 30 | 2. Create a new branch specific to your new code 31 | 3. Write, test, and commit your new code 32 | 4. Submit a pull request from your branch back to the original source 33 | 34 | I and a few others will review the pull request and comment as needed, and then hopefully merge it. 35 | 36 |
37 | 38 | ***Note: additional details about this project can be found at https://www.i2cdevlib.com*** 39 | 40 | ***Another note: this project has a fledgling successor that aims to [address all of its shortcomings](https://community.perilib.io/t/perilib-i2cdevlib-reborn/15), which can be found at https://github.com/perilib*** 41 | -------------------------------------------------------------------------------- /RP2040/I2Cdev/I2Cdev.h: -------------------------------------------------------------------------------- 1 | // Raspberry Pi Pico port for: 2 | // I2Cdev library collection - Main I2C device class 3 | // Abstracts bit and byte I2C R/W functions into a convenient class 4 | // 2013-06-05 by Jeff Rowberg 5 | // 6 | // Changelog: 7 | // 2021-09-29 - Initial port release by Gino Ipóliti. 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2013 Jeff Rowberg 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | =============================================== 31 | */ 32 | 33 | #ifndef _I2CDEV_PICO_WRAPPER_H_ 34 | #define _I2CDEV_PICO_WRAPPER_H_ 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include "pico/stdlib.h" 41 | #include "hardware/i2c.h" 42 | 43 | // 1000ms default read timeout (modify with "I2Cdev::readTimeout = [ms];") 44 | #define I2CDEV_DEFAULT_READ_TIMEOUT ((uint32_t)1000000) // RP2040 I2C functions with timeout use microseconds so we have to multiply by 10^3 45 | 46 | class I2Cdev { 47 | public: 48 | I2Cdev(); 49 | 50 | static int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint32_t timeout=I2Cdev::readTimeout); 51 | static int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint32_t timeout=I2Cdev::readTimeout); 52 | static int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint32_t timeout=I2Cdev::readTimeout); 53 | static int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint32_t timeout=I2Cdev::readTimeout); 54 | static int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint32_t timeout=I2Cdev::readTimeout); 55 | static int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint32_t timeout=I2Cdev::readTimeout); 56 | static int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint32_t timeout=I2Cdev::readTimeout); 57 | static int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint32_t timeout=I2Cdev::readTimeout); 58 | 59 | static bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); 60 | static bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); 61 | static bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); 62 | static bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); 63 | static bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); 64 | static bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); 65 | static bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 66 | static bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 67 | 68 | static uint32_t readTimeout; 69 | 70 | }; 71 | 72 | #endif /* _I2CDEV_PICO_WRAPPER_H_ */ 73 | -------------------------------------------------------------------------------- /RP2040/MPU6050/examples/README.md: -------------------------------------------------------------------------------- 1 | These are examples for the Raspberry Pi Pico development board and have serial output enabled through USB. 2 | Also, if the libraries files (I2Cdev.h, I2Cdev.cpp, MPU6050.h, MPU6050.cpp, MPU6050\_6Axis\_MotionApps\_V6\_12.h, helper\_3dmath.h) are not in a common include directory, you will have to copy them to the example folder (whichever you want to build), unless you modify the CMakeLists.txt and specify the path. 3 | 4 | #### Instructions for building examples 5 | 1. ```cd``` to the folder of the example you want to build. 6 | 2. If you have PICO W (PICO board with Infineon CYW43439 wireless chip), you need to uncommented 3 lines in CMakeLists.txt file. 7 | 3. ```mkdir build && cd build``` 8 | 4. ```cmake ..``` 9 | 5. ```make``` 10 | 6. Copy the uf2 file to your Pico board, using ```cp``` or the file explorer you have. 11 | 7. ```sudo minicom -D /dev/ttyACM0``` to watch the serial output. Use ```sudo```, otherwise minicom will fail to open the device and show no warnings. On Windows you can use PuTTY, choosing the COM port that was assigned (check the Device Manager) and a baudrate of 115200. 12 | 13 | #### Sensor calibration 14 | You will get better results if you measure the gyro and accelerometer offsets for your sensor *(e.g. with the accompanying calibration example)*. Set the initial offsets using `mpu.setXAccelOffset()` and friends in mpu6050_DMP_port.cpp after the call to `mpu.dmpInitialize()`. 15 | 16 | Alternatively you could call `mpu.CalibrateAccel(6)` and `mpu.CalibrateGyro(6)` in the same location (6 loops should be enough). 17 | -------------------------------------------------------------------------------- /RP2040/MPU6050/examples/mpu6050_DMP_V6.12/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Generated Cmake Pico project file 2 | 3 | cmake_minimum_required(VERSION 3.13) 4 | # Pull in SDK (must be before project) 5 | # set(PICO_BOARD pico_w) # Needed only for PICO W 6 | # set(CYW43_LWIP 1) # Needed only for PICO W 7 | include(pico_sdk_import.cmake) 8 | 9 | project(mpu6050_DMP_port C CXX ASM) 10 | set(CMAKE_C_STANDARD 11) 11 | set(CMAKE_CXX_STANDARD 17) 12 | 13 | # Initialise the Raspberry Pi Pico SDK 14 | pico_sdk_init() 15 | 16 | # Add executable. Default name is the project name, version 0.1 17 | 18 | add_executable(mpu6050_DMP_port 19 | mpu6050_DMP_port.cpp 20 | MPU6050.cpp 21 | I2Cdev.cpp 22 | ) 23 | 24 | # Add any user requested libraries 25 | target_link_libraries(mpu6050_DMP_port 26 | pico_stdlib 27 | # pico_cyw43_arch_none # we need Wifi to access the GPIO. Needed only for PICO W 28 | hardware_i2c 29 | pico_double 30 | ) 31 | 32 | pico_set_program_name(mpu6050_DMP_port "mpu6050_DMP_port") 33 | pico_set_program_version(mpu6050_DMP_port "0.1") 34 | 35 | pico_enable_stdio_uart(mpu6050_DMP_port 0) 36 | pico_enable_stdio_usb(mpu6050_DMP_port 1) 37 | 38 | 39 | # create map/bin/hex file etc. 40 | pico_add_extra_outputs(mpu6050_DMP_port) 41 | 42 | -------------------------------------------------------------------------------- /RP2040/MPU6050/examples/mpu6050_DMP_V6.12/pico_sdk_import.cmake: -------------------------------------------------------------------------------- 1 | # This is a copy of /external/pico_sdk_import.cmake 2 | 3 | # This can be dropped into an external project to help locate this SDK 4 | # It should be include()ed prior to project() 5 | 6 | if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) 7 | set(PICO_SDK_PATH $ENV{PICO_SDK_PATH}) 8 | message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')") 9 | endif () 10 | 11 | if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT)) 12 | set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT}) 13 | message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')") 14 | endif () 15 | 16 | if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH)) 17 | set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH}) 18 | message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')") 19 | endif () 20 | 21 | set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK") 22 | set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable") 23 | set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK") 24 | 25 | if (NOT PICO_SDK_PATH) 26 | if (PICO_SDK_FETCH_FROM_GIT) 27 | include(FetchContent) 28 | set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR}) 29 | if (PICO_SDK_FETCH_FROM_GIT_PATH) 30 | get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") 31 | endif () 32 | # GIT_SUBMODULES_RECURSE was added in 3.17 33 | if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0") 34 | FetchContent_Declare( 35 | pico_sdk 36 | GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk 37 | GIT_TAG master 38 | GIT_SUBMODULES_RECURSE FALSE 39 | ) 40 | else () 41 | FetchContent_Declare( 42 | pico_sdk 43 | GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk 44 | GIT_TAG master 45 | ) 46 | endif () 47 | 48 | if (NOT pico_sdk) 49 | message("Downloading Raspberry Pi Pico SDK") 50 | FetchContent_Populate(pico_sdk) 51 | set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR}) 52 | endif () 53 | set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) 54 | else () 55 | message(FATAL_ERROR 56 | "SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git." 57 | ) 58 | endif () 59 | endif () 60 | 61 | get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") 62 | if (NOT EXISTS ${PICO_SDK_PATH}) 63 | message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found") 64 | endif () 65 | 66 | set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake) 67 | if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE}) 68 | message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK") 69 | endif () 70 | 71 | set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE) 72 | 73 | include(${PICO_SDK_INIT_CMAKE_FILE}) 74 | -------------------------------------------------------------------------------- /RP2040/MPU6050/examples/mpu6050_calibration/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Generated Cmake Pico project file 2 | 3 | cmake_minimum_required(VERSION 3.13) 4 | # Pull in SDK (must be before project) 5 | # set(PICO_BOARD pico_w) # Needed only for PICO W 6 | # set(CYW43_LWIP 1) # Needed only for PICO W 7 | include(pico_sdk_import.cmake) 8 | 9 | project(mpu6050_calibration C CXX ASM) 10 | set(CMAKE_C_STANDARD 11) 11 | set(CMAKE_CXX_STANDARD 17) 12 | 13 | # Initialise the Raspberry Pi Pico SDK 14 | pico_sdk_init() 15 | 16 | # Add executable. Default name is the project name, version 0.1 17 | 18 | add_executable( mpu6050_calibration 19 | mpu6050_calibration.cpp 20 | MPU6050.cpp 21 | I2Cdev.cpp 22 | ) 23 | 24 | # Add any user requested libraries 25 | target_link_libraries( mpu6050_calibration 26 | pico_stdlib 27 | # pico_cyw43_arch_none # we need Wifi to access the GPIO. Needed only for PICO W 28 | hardware_i2c 29 | ) 30 | 31 | pico_set_program_name(mpu6050_calibration "mpu6050_calibration") 32 | pico_set_program_version(mpu6050_calibration "0.1") 33 | 34 | pico_enable_stdio_uart(mpu6050_calibration 0) 35 | pico_enable_stdio_usb(mpu6050_calibration 1) 36 | 37 | # create map/bin/hex file etc. 38 | pico_add_extra_outputs( mpu6050_calibration) 39 | 40 | -------------------------------------------------------------------------------- /RP2040/MPU6050/examples/mpu6050_calibration/pico_sdk_import.cmake: -------------------------------------------------------------------------------- 1 | # This is a copy of /external/pico_sdk_import.cmake 2 | 3 | # This can be dropped into an external project to help locate this SDK 4 | # It should be include()ed prior to project() 5 | 6 | if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) 7 | set(PICO_SDK_PATH $ENV{PICO_SDK_PATH}) 8 | message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')") 9 | endif () 10 | 11 | if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT)) 12 | set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT}) 13 | message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')") 14 | endif () 15 | 16 | if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH)) 17 | set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH}) 18 | message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')") 19 | endif () 20 | 21 | set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK") 22 | set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable") 23 | set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK") 24 | 25 | if (NOT PICO_SDK_PATH) 26 | if (PICO_SDK_FETCH_FROM_GIT) 27 | include(FetchContent) 28 | set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR}) 29 | if (PICO_SDK_FETCH_FROM_GIT_PATH) 30 | get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") 31 | endif () 32 | # GIT_SUBMODULES_RECURSE was added in 3.17 33 | if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0") 34 | FetchContent_Declare( 35 | pico_sdk 36 | GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk 37 | GIT_TAG master 38 | GIT_SUBMODULES_RECURSE FALSE 39 | ) 40 | else () 41 | FetchContent_Declare( 42 | pico_sdk 43 | GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk 44 | GIT_TAG master 45 | ) 46 | endif () 47 | 48 | if (NOT pico_sdk) 49 | message("Downloading Raspberry Pi Pico SDK") 50 | FetchContent_Populate(pico_sdk) 51 | set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR}) 52 | endif () 53 | set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) 54 | else () 55 | message(FATAL_ERROR 56 | "SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git." 57 | ) 58 | endif () 59 | endif () 60 | 61 | get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") 62 | if (NOT EXISTS ${PICO_SDK_PATH}) 63 | message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found") 64 | endif () 65 | 66 | set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake) 67 | if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE}) 68 | message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK") 69 | endif () 70 | 71 | set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE) 72 | 73 | include(${PICO_SDK_INIT_CMAKE_FILE}) 74 | -------------------------------------------------------------------------------- /RaspberryPi_bcm2835/ADXL345/examples/ADXL345_example_1.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | I2Cdev library collection - ADXL345 RPi example 3 | Based on the example in Arduino/ADXL345/ 4 | 5 | ============================================== 6 | I2Cdev device library code is placed under the MIT license 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | =============================================== 26 | 27 | To compile on a Raspberry Pi (1 or 2) 28 | 1. install the bcm2835 library, see http://www.airspayce.com/mikem/bcm2835/index.html 29 | 2. enable i2c on your RPi , see https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c 30 | 3. connect your i2c devices 31 | 4. then from bash 32 | $ PATH_I2CDEVLIB=~/i2cdevlib/ 33 | $ gcc -o ADXL345_example_1 ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/ADXL345/examples/ADXL345_example_1.cpp \ 34 | -I ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/I2Cdev ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/I2Cdev/I2Cdev.cpp \ 35 | -I ${PATH_I2CDEVLIB}/Arduino/ADXL345/ ${PATH_I2CDEVLIB}/Arduino/ADXL345/ADXL345.cpp -l bcm2835 -l m 36 | $ sudo ./ADXL345_example_1 37 | 38 | */ 39 | 40 | #include 41 | #include 42 | #include "I2Cdev.h" 43 | #include "ADXL345.h" 44 | 45 | int main(int argc, char **argv) { 46 | printf("ADXL345 3-axis acceleromter example program\n"); 47 | I2Cdev::initialize(); 48 | ADXL345 accel ; 49 | if ( accel.testConnection() ) 50 | printf("ADXL345 connection test successful\n") ; 51 | else { 52 | fprintf( stderr, "ADXL345 connection test failed! exiting ...\n"); 53 | return 1; 54 | } 55 | accel.initialize(); 56 | int16_t ax, ay, az; 57 | while (true) { 58 | accel.getAcceleration(&ax, &ay, &az); 59 | printf(" x_raw: 0x%04X y_raw: 0x%04X z_raw: 0x%04X\r", ax, ay, az); 60 | fflush(stdout); 61 | bcm2835_delay(200); 62 | } 63 | return 1; 64 | } 65 | -------------------------------------------------------------------------------- /RaspberryPi_bcm2835/BMP085/examples/BMP085_basic.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | I2Cdev library collection - BMP085 RPi example 3 | Based on the example in Arduino/BMP085/ 4 | 5 | ============================================== 6 | I2Cdev device library code is placed under the MIT license 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | =============================================== 26 | 27 | To compile on a Raspberry Pi (1 or 2) 28 | 1. install the bcm2835 library, see http://www.airspayce.com/mikem/bcm2835/index.html 29 | 2. enable i2c on your RPi , see https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c 30 | 3. connect your i2c devices 31 | 4. then from bash 32 | $ PATH_I2CDEVLIB=~/i2cdevlib/ 33 | $ gcc -o BMP085_basic_example ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/BMP085/examples/BMP085_basic.cpp \ 34 | -I ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/I2Cdev ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/I2Cdev/I2Cdev.cpp \ 35 | -I ${PATH_I2CDEVLIB}/Arduino/BMP085/ ${PATH_I2CDEVLIB}/Arduino/BMP085/BMP085.cpp -l bcm2835 -l m 36 | $ sudo ./BMP085_basic_example 37 | 38 | */ 39 | 40 | #include 41 | #include 42 | #include "I2Cdev.h" 43 | #include "BMP085.h" 44 | 45 | int main(int argc, char **argv) { 46 | printf("BMPO85 examples program\n"); 47 | I2Cdev::initialize(); 48 | BMP085 barometer ; // BMP085 class default I2C address is 0x77, specific I2C addresses may be passed as a parameter here 49 | if ( barometer.testConnection() ) 50 | printf("BMP085 connection test successful\n") ; 51 | else { 52 | fprintf( stderr, "BMP085 connection test failed! exiting ...\n"); 53 | return 1; 54 | } 55 | barometer.loadCalibration(); 56 | float temperature; 57 | float pressure; 58 | float altitude; 59 | while (true) { 60 | barometer.setControl(BMP085_MODE_TEMPERATURE); 61 | bcm2835_delay(5); // wait 5 ms for conversion 62 | temperature = barometer.getTemperatureC(); 63 | barometer.setControl(BMP085_MODE_PRESSURE_3) ; //taking reading in highest accuracy measurement mode 64 | bcm2835_delay( barometer.getMeasureDelayMicroseconds() / 1000 ); 65 | pressure = barometer.getPressure(); 66 | altitude = barometer.getAltitude(pressure); 67 | printf(" Temperature: %3.1f deg C Pressure %3.3f kPa altitude %3.1f m\r", temperature, pressure/1000.0, altitude); 68 | fflush(stdout); 69 | bcm2835_delay(200); 70 | } 71 | return 1; 72 | } 73 | -------------------------------------------------------------------------------- /RaspberryPi_bcm2835/HMC5883L/examples/HMC5883L_example_1.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | I2Cdev library collection - HMC5883L RPi example 3 | Based on the example in Arduino/HMC5883L/ 4 | 5 | ============================================== 6 | I2Cdev device library code is placed under the MIT license 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | =============================================== 26 | 27 | To compile on a Raspberry Pi (1 or 2) 28 | 1. install the bcm2835 library, see http://www.airspayce.com/mikem/bcm2835/index.html 29 | 2. enable i2c on your RPi , see https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c 30 | 3. connect your i2c devices 31 | 4. then from bash 32 | $ PATH_I2CDEVLIB=~/i2cdevlib/ 33 | $ gcc -o HMC5883L_example_1 ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/HMC5883L/examples/HMC5883L_example_1.cpp \ 34 | -I ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/I2Cdev ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/I2Cdev/I2Cdev.cpp \ 35 | -I ${PATH_I2CDEVLIB}/Arduino/HMC5883L/ ${PATH_I2CDEVLIB}/Arduino/HMC5883L/HMC5883L.cpp -l bcm2835 -l m 36 | $ sudo ./HMC5883L_example_1 37 | 38 | */ 39 | 40 | #include 41 | #include 42 | #include "I2Cdev.h" 43 | #include "HMC5883L.h" 44 | #include 45 | 46 | #define PI 3.14159265 47 | 48 | int main(int argc, char **argv) { 49 | printf("HMC5883L 3-axis acceleromter example program\n"); 50 | I2Cdev::initialize(); 51 | HMC5883L mag ; 52 | if ( mag.testConnection() ) 53 | printf("HMC5883L connection test successful\n") ; 54 | else { 55 | fprintf( stderr, "HMC5883L connection test failed! something maybe wrong, continueing anyway though ...\n"); 56 | //return 1; 57 | } 58 | mag.initialize(); 59 | mag.setSampleAveraging(HMC5883L_AVERAGING_8); 60 | mag.setGain(HMC5883L_GAIN_1090); 61 | int16_t mx, my, mz; 62 | float heading ; 63 | while (true) { 64 | mag.getHeading(&mx, &my, &mz); 65 | heading = atan2(my, mx) * 180 / PI; 66 | printf(" mx: %d my: %d mz: %d heading: %3.1f deg\r", mx, my, mz, heading); 67 | fflush(stdout); 68 | bcm2835_delay(200); 69 | } 70 | return 1; 71 | } 72 | -------------------------------------------------------------------------------- /RaspberryPi_bcm2835/I2Cdev/I2Cdev.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - Main I2C device class 2 | // Abstracts bit and byte I2C R/W functions into a convenient class 3 | // RaspberryPi bcm2835 library port: bcm2835 library available at http://www.airspayce.com/mikem/bcm2835/index.html 4 | // Based on Arduino's I2Cdev by Jeff Rowberg 5 | // 6 | 7 | /* ============================================ 8 | I2Cdev device library code is placed under the MIT license 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | =============================================== 28 | */ 29 | 30 | #ifndef _I2CDEV_H_ 31 | #define _I2CDEV_H_ 32 | 33 | #ifndef __cplusplus 34 | #error A C++ compiler is required! 35 | #endif 36 | 37 | #include 38 | #include // required for BMP180 39 | #include // required for MPU6060 40 | #include // required for MPU6060 41 | 42 | 43 | #define set_I2C_pins false 44 | /* used to boolean for setting RPi I2C pins P1-03 (SDA) and P1-05 (SCL) to alternate function ALT0, which enables those pins for I2C interface. 45 | setI2Cpin should be false, if the I2C are already configured in alt mode ... */ 46 | 47 | #define i2c_baudrate 400000 48 | //uint32_t i2c_baudrate = 400000 ; //400 kHz, 49 | 50 | class I2Cdev { 51 | public: 52 | I2Cdev(); 53 | 54 | static void initialize(); 55 | static void enable(bool isEnabled); 56 | 57 | static int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data); 58 | //TODO static int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data); 59 | static int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data); 60 | //TODO static int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data); 61 | static int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data); 62 | static int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data); 63 | static int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 64 | static int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 65 | 66 | static bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); 67 | //TODO static bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); 68 | static bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); 69 | //TODO static bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); 70 | static bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); 71 | static bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); 72 | static bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 73 | static bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 74 | }; 75 | 76 | #endif /* _I2CDEV_H_ */ 77 | -------------------------------------------------------------------------------- /RaspberryPi_bcm2835/MPU6050/examples/MPU6050_example_1.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | I2Cdev library collection - MPU6050 RPi example 3 | Based on the example in Arduino/MPU6050/ 4 | 5 | ============================================== 6 | I2Cdev device library code is placed under the MIT license 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | =============================================== 26 | 27 | To compile on a Raspberry Pi (1 or 2) 28 | 1. install the bcm2835 library, see http://www.airspayce.com/mikem/bcm2835/index.html 29 | 2. enable i2c on your RPi , see https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c 30 | 3. connect your i2c devices 31 | 4. then from bash 32 | $ PATH_I2CDEVLIB=~/i2cdevlib/ 33 | $ gcc -o MPU6050_example_1 ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/MPU6050/examples/MPU6050_example_1.cpp \ 34 | -I ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/I2Cdev ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/I2Cdev/I2Cdev.cpp \ 35 | -I ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/MPU6050/ ${PATH_I2CDEVLIB}RaspberryPi_bcm2835/MPU6050/MPU6050.cpp -l bcm2835 -l m 36 | $ sudo ./MPU6050_example_1 37 | 38 | */ 39 | 40 | #include 41 | #include 42 | #include "I2Cdev.h" 43 | #include "MPU6050.h" 44 | #include 45 | 46 | int main(int argc, char **argv) { 47 | printf("MPU6050 3-axis acceleromter example program\n"); 48 | I2Cdev::initialize(); 49 | MPU6050 accelgyro ; 50 | int16_t ax, ay, az; 51 | int16_t gx, gy, gz; 52 | if ( accelgyro.testConnection() ) 53 | printf("MPU6050 connection test successful\n") ; 54 | else { 55 | fprintf( stderr, "MPU6050 connection test failed! something maybe wrong, continuing anyway though ...\n"); 56 | //return 1; 57 | } 58 | accelgyro.initialize(); 59 | // use the code below to change accel/gyro offset values 60 | /* 61 | printf("Updating internal sensor offsets...\n"); 62 | // -76 -2359 1688 0 0 0 63 | printf("%i \t %i \t %i \t %i \t %i \t %i\n", 64 | accelgyro.getXAccelOffset(), 65 | accelgyro.getYAccelOffset(), 66 | accelgyro.getZAccelOffset(), 67 | accelgyro.getXGyroOffset(), 68 | accelgyro.getYGyroOffset(), 69 | accelgyro.getZGyroOffset()); 70 | accelgyro.setXGyroOffset(220); 71 | accelgyro.setYGyroOffset(76); 72 | accelgyro.setZGyroOffset(-85); 73 | printf("%i \t %i \t %i \t %i \t %i \t %i\n", 74 | accelgyro.getXAccelOffset(), 75 | accelgyro.getYAccelOffset(), 76 | accelgyro.getZAccelOffset(), 77 | accelgyro.getXGyroOffset(), 78 | accelgyro.getYGyroOffset(), 79 | accelgyro.getZGyroOffset()); 80 | */ 81 | 82 | printf("\n"); 83 | printf(" ax \t ay \t az \t gx \t gy \t gz:\n"); 84 | while (true) { 85 | accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); 86 | printf(" %d \t %d \t %d \t %d \t %d \t %d\r", ax, ay, az, gx, gy, gz); 87 | fflush(stdout); 88 | bcm2835_delay(100); 89 | } 90 | return 1; 91 | } 92 | -------------------------------------------------------------------------------- /STM32/I2Cdev.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - Main I2C device class header file 2 | // Abstracts bit and byte I2C R/W functions into a convenient class 3 | // 6/9/2012 by Jeff Rowberg 4 | // 03/28/2017 by Kamnev Yuriy 5 | // 6 | // Changelog: 7 | // 2017-03-28 - ported to STM32 using Keil MDK Pack 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2013 Jeff Rowberg 12 | Copyright (c) 2017 Kamnev Yuriy 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | =============================================== 31 | */ 32 | 33 | 34 | #ifndef SRC_I2CDEVLIB_I2CDEV_H_ 35 | #define SRC_I2CDEVLIB_I2CDEV_H_ 36 | 37 | #include 38 | 39 | #define I2CDev_Driver Driver_I2C2 40 | 41 | 42 | int8_t I2Cdev_readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data); 43 | int8_t I2Cdev_readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data); 44 | int8_t I2Cdev_readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data); 45 | int8_t I2Cdev_readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data); 46 | int8_t I2Cdev_readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data); 47 | int8_t I2Cdev_readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data); 48 | int8_t I2Cdev_readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 49 | int8_t I2Cdev_readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 50 | 51 | int8_t I2Cdev_writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); 52 | int8_t I2Cdev_writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); 53 | int8_t I2Cdev_writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); 54 | int8_t I2Cdev_writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); 55 | int8_t I2Cdev_writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); 56 | int8_t I2Cdev_writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); 57 | int8_t I2Cdev_writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 58 | int8_t I2Cdev_writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 59 | 60 | 61 | #endif /* SRC_I2CDEVLIB_I2CDEV_H_ */ 62 | -------------------------------------------------------------------------------- /STM32/QMC5883L/QMC5883L.c: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - QMC5883L I2C device class header file 2 | // Based on QST QMC5883L datasheet 1.0, 02/2016 3 | /* ============================================ 4 | I2Cdev device library code is placed under the MIT license 5 | Copyright (c) 2011 Jeff Rowberg 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | =============================================== 25 | */ 26 | #include 27 | #include 28 | 29 | static const uint8_t chip_addr = QMC5883L_DEFAULT_ADDR; 30 | 31 | bool QMC5883L_soft_reset() { 32 | if (I2Cdev_writeByte(chip_addr, QMC5883L_REG_CTRL_2, 0x80) == 0) return false; 33 | return true; 34 | } 35 | 36 | bool QMC5883L_fbr_set(uint8_t fbr) { 37 | if (I2Cdev_writeByte(chip_addr, QMC5883L_REG_SR_PERIOD, fbr) == 0) return false; 38 | return true; 39 | } 40 | 41 | bool QMC5883L_control_1_set(uint8_t value) { 42 | if (I2Cdev_writeByte(chip_addr, QMC5883L_REG_CTRL_1, value) == 0) return false; 43 | return true; 44 | } 45 | 46 | bool QMC5883L_statusGet(uint8_t *data) { 47 | if (I2Cdev_readByte(chip_addr, QMC5883L_REG_STATUS, data) == 0) return false; 48 | return true; 49 | } 50 | 51 | bool QMC5883L_magGet(int16_t *v_mag) { 52 | uint8_t bytes[6]; 53 | if (I2Cdev_readBytes(chip_addr, QMC5883L_REG_DATA_X_LSB, 6, bytes) == 0) return false; 54 | 55 | v_mag[0] = (((uint16_t)bytes[1]) << 8) | bytes[0]; 56 | v_mag[1] = (((uint16_t)bytes[3]) << 8) | bytes[2]; 57 | v_mag[2] = (((uint16_t)bytes[5]) << 8) | bytes[4]; 58 | 59 | return true; 60 | } 61 | 62 | bool QMC5883L_tempGet(int16_t *temp) { 63 | uint8_t bytes[2]; 64 | if (I2Cdev_readBytes(chip_addr, QMC5883L_REG_TEMP_LSB, 2, bytes) == 0) return false; 65 | 66 | *temp = (((uint16_t)bytes[1]) << 8) | bytes[0]; 67 | 68 | return true; 69 | } 70 | -------------------------------------------------------------------------------- /STM32/QMC5883L/QMC5883L.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - QMC5883L I2C device class header file 2 | // Based on QST QMC5883L datasheet 1.0, 02/2016 3 | /* ============================================ 4 | I2Cdev device library code is placed under the MIT license 5 | Copyright (c) 2011 Jeff Rowberg 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | =============================================== 25 | */ 26 | 27 | #ifndef _QMC5883L_H_ 28 | #define _QMC5883L_H_ 29 | 30 | #include 31 | #include 32 | 33 | #define QMC5883L_DEFAULT_ADDR 0x0D 34 | 35 | /* register addresses */ 36 | #define QMC5883L_REG_DATA_X_LSB 0x00 37 | #define QMC5883L_REG_DATA_X_MSB 0x01 38 | #define QMC5883L_REG_DATA_Y_LSB 0x02 39 | #define QMC5883L_REG_DATA_Y_MSB 0x03 40 | #define QMC5883L_REG_DATA_Z_LSB 0x04 41 | #define QMC5883L_REG_DATA_Z_MSB 0x05 42 | #define QMC5883L_REG_STATUS 0x06 43 | #define QMC5883L_REG_TEMP_LSB 0x07 44 | #define QMC5883L_REG_TEMP_MSB 0x08 45 | #define QMC5883L_REG_CTRL_1 0x09 46 | #define QMC5883L_REG_CTRL_2 0x0A 47 | #define QMC5883L_REG_SR_PERIOD 0x0B 48 | 49 | /* values for control_1 register */ 50 | #define QMC5883L_OVERSAMPLE_512 0b00 51 | #define QMC5883L_OVERSAMPLE_256 0b01 52 | #define QMC5883L_OVERSAMPLE_128 0b10 53 | #define QMC5883L_OVERSAMPLE_64 0b11 54 | 55 | #define QMC5883L_SCALE_2G 0b00 56 | #define QMC5883L_SCALE_8G 0b01 57 | 58 | #define QMC5883L_OUTPUT_RATE_10HZ 0b00 59 | #define QMC5883L_OUTPUT_RATE_50HZ 0b01 60 | #define QMC5883L_OUTPUT_RATE_100HZ 0b10 61 | #define QMC5883L_OUTPUT_RATE_200HZ 0b11 62 | 63 | #define QMC5883L_MODE_STBY 0b00 64 | #define QMC5883L_MODE_CONT 0b01 65 | 66 | #define QMC5883L_CTRL1_VALUE(_mode_, _output_rate_, _scale_, _oversample_) \ 67 | ((_mode_) | ((_output_rate_) << 2) | ((_scale_) << 4) | ((_oversample_) << 6)) 68 | 69 | /* QMC5883L_soft_reset: does a soft reset */ 70 | bool QMC5883L_soft_reset(); 71 | 72 | /* QMC5883L_fbr_set: SET/RESET Period FBR; recommended value: 1 */ 73 | bool QMC5883L_fbr_set(uint8_t fbr); 74 | 75 | /* QMC5883L_control_1_set: set value for control register (mode, output rate, scale, oversampling) */ 76 | bool QMC5883L_control_1_set(uint8_t value); 77 | 78 | bool QMC5883L_statusGet(uint8_t *data); 79 | 80 | /* QMC5883L_magGet: 81 | * parameters: 82 | * v_mag: int16_t array of length 3 83 | * returns: 84 | * success: true 85 | * failure: false 86 | */ 87 | bool QMC5883L_magGet(int16_t *v_mag); 88 | 89 | bool QMC5883L_tempGet(int16_t *temp); 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /STM32/README.md: -------------------------------------------------------------------------------- 1 | # I2C Device Library for STM32 2 | 3 | ## I2Cdev 4 | For implementing I2Cdev [Keil MDK Pack](https://www.keil.com/dd2/pack/) is used. It has many advantages comparing to HAL/SPL. The most 5 | crucial one is that of compatibility: using it makes I2Cdev compatible with any device listed on MDK Pack software page. All you need is to download pack for your device, enable your driver and specify used peripherial in I2Cdev.h. 6 | 7 | ## Devices 8 | Supported devices are MPU6050 without DMP and HMC5883. Actually I did not find any differences in registers between HMC5883 and HMC5983 therefore the latter might work as well. 9 | 10 | Porting other devices should be easy and any help is appreciated. 11 | 12 | ## Licence 13 | I2Cdev device library code is placed under the MIT license. 14 | 15 | _Copyright (c) 2011 Jeff Rowberg. Copyright (c) 2017 Kamnev Yuriy._ 16 | -------------------------------------------------------------------------------- /STM32HAL/APDS9960/README.md: -------------------------------------------------------------------------------- 1 | Ported to C and HAL for STM32 from [Arduino driver](https://github.com/sparkfun/SparkFun_APDS-9960_Sensor_Arduino_Library) 2 | -------------------------------------------------------------------------------- /STM32HAL/I2Cdev/I2Cdev.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - Main I2C device class header file 2 | // Abstracts bit and byte I2C R/W functions into a convenient class 3 | // 6/9/2012 by Jeff Rowberg 4 | // 6/6/2015 by Andrey Voloshin 5 | // 6 | // Changelog: 7 | // 2015-06-06 - ported to STM32 HAL library from Arduino code 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2013 Jeff Rowberg 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | =============================================== 31 | */ 32 | 33 | #ifndef _I2CDEV_H_ 34 | #define _I2CDEV_H_ 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | // TODO: include depending on chip family 41 | //#include "stm32f1xx_hal.h" 42 | //#include "stm32f2xx_hal.h" 43 | //#include "stm32f3xx_hal.h" 44 | #include "stm32f4xx_hal.h" 45 | 46 | typedef int bool; 47 | #define true 1 48 | #define false 0 49 | 50 | extern uint16_t I2Cdev_readTimeout; 51 | 52 | // 1000ms default read timeout (modify with "I2Cdev::readTimeout = [ms];") 53 | #define I2CDEV_DEFAULT_READ_TIMEOUT 1000 54 | 55 | void I2Cdev_init(I2C_HandleTypeDef * hi2c); 56 | 57 | uint8_t I2Cdev_readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout); 58 | uint8_t I2Cdev_readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout); 59 | uint8_t I2Cdev_readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout); 60 | uint8_t I2Cdev_readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout); 61 | uint8_t I2Cdev_readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout); 62 | uint8_t I2Cdev_readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout); 63 | uint8_t I2Cdev_readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout); 64 | uint8_t I2Cdev_readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout); 65 | 66 | uint16_t I2Cdev_writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); 67 | uint16_t I2Cdev_writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); 68 | uint16_t I2Cdev_writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); 69 | uint16_t I2Cdev_writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); 70 | uint16_t I2Cdev_writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); 71 | uint16_t I2Cdev_writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); 72 | uint16_t I2Cdev_writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 73 | uint16_t I2Cdev_writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 74 | 75 | #endif /* _I2CDEV_H_ */ 76 | -------------------------------------------------------------------------------- /STM32HAL/README.md: -------------------------------------------------------------------------------- 1 | # I2C Device Library for STM32 2 | 3 | ## Devices 4 | Currently MPU6050 (with DMP), HMC5883L and BMP180/BMP085 are ported (GY-87 board). ADXL345 is coming soon. 5 | Adding more functions and devices should be straighforward after reading the source code of the driver. 6 | Porting drivers should be as simple, as renaming public methods from *DRIVER::func()* to *DRIVER_func()* and moving private fields and functions to *.c file 7 | 8 | ## BMP180 Example for STM32F429I-DISCO board 9 | ```C 10 | #include "stm32f4xx.h" 11 | #include "stm32f4xx_hal.h" 12 | #include 13 | #include 14 | #include 15 | #include "I2Cdev.h" 16 | #include "BMP085.h" 17 | 18 | I2C_HandleTypeDef hi2c3; 19 | 20 | int main(void) 21 | { 22 | SystemInit(); 23 | HAL_Init(); 24 | 25 | GPIO_InitTypeDef GPIO_InitStruct; 26 | 27 | /**I2C3 GPIO Configuration 28 | PC9 ------> I2C3_SDA 29 | PA8 ------> I2C3_SCL 30 | */ 31 | 32 | __GPIOA_CLK_ENABLE(); 33 | __GPIOC_CLK_ENABLE(); 34 | 35 | GPIO_InitStruct.Pin = GPIO_PIN_9; 36 | GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; 37 | GPIO_InitStruct.Pull = GPIO_PULLUP; 38 | GPIO_InitStruct.Speed = GPIO_SPEED_FAST; 39 | GPIO_InitStruct.Alternate = GPIO_AF4_I2C3; 40 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 41 | 42 | GPIO_InitStruct.Pin = GPIO_PIN_8; 43 | GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; 44 | GPIO_InitStruct.Pull = GPIO_PULLUP; 45 | GPIO_InitStruct.Speed = GPIO_SPEED_FAST; 46 | GPIO_InitStruct.Alternate = GPIO_AF4_I2C3; 47 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 48 | 49 | __I2C3_CLK_ENABLE(); 50 | 51 | hi2c3.Instance = I2C3; 52 | hi2c3.Init.ClockSpeed = 400000; 53 | hi2c3.Init.DutyCycle = I2C_DUTYCYCLE_2; 54 | hi2c3.Init.OwnAddress1 = 0x10; 55 | hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; 56 | hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED; 57 | hi2c3.Init.OwnAddress2 = 0x11; 58 | hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED; 59 | hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; 60 | 61 | HAL_I2C_Init(&hi2c3); 62 | 63 | I2Cdev_init(&hi2c3); // init of i2cdevlib. 64 | // You can select other i2c device anytime and 65 | // call the same driver functions on other sensors 66 | 67 | while(!BMP085_testConnection()) ; 68 | 69 | BMP085_initialize(); 70 | char buf[128]; 71 | while (1) 72 | { 73 | BMP085_setControl(BMP085_MODE_TEMPERATURE); 74 | HAL_Delay(BMP085_getMeasureDelayMilliseconds(BMP085_MODE_TEMPERATURE)); 75 | float t = BMP085_getTemperatureC(); 76 | 77 | BMP085_setControl(BMP085_MODE_PRESSURE_3); 78 | HAL_Delay(BMP085_getMeasureDelayMilliseconds(BMP085_MODE_PRESSURE_3)); 79 | float p = BMP085_getPressure(); 80 | 81 | float a = BMP085_getAltitude(p, 101325); 82 | } 83 | } 84 | 85 | void SysTick_Handler() 86 | { 87 | HAL_IncTick(); 88 | HAL_SYSTICK_IRQHandler(); 89 | } 90 | ``` 91 | 92 | ## Licence 93 | I2Cdev device library code is placed under the MIT license. 94 | 95 | _Copyright (c) 2011 Jeff Rowberg. Copyright (c) 2015 Andrey Voloshin._ 96 | -------------------------------------------------------------------------------- /dsPIC30F/I2Cdev/I2Cdev.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - Main I2C device class header file 2 | // Abstracts bit and byte I2C R/W functions into a convenient class 3 | // 6/9/2012 by Jeff Rowberg 4 | // 11/28/2014 by Marton Sebok 5 | // 6 | // Changelog: 7 | // 2014-11-28 - ported to PIC18 peripheral library from Arduino code 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2013 Jeff Rowberg 12 | Copyright (c) 2014 Marton Sebok 13 | Copyright (c) 2017 Daichou 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy 16 | of this software and associated documentation files (the "Software"), to deal 17 | in the Software without restriction, including without limitation the rights 18 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19 | copies of the Software, and to permit persons to whom the Software is 20 | furnished to do so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in 23 | all copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 31 | THE SOFTWARE. 32 | =============================================== 33 | */ 34 | 35 | #ifndef _I2CDEV_H_ 36 | #define _I2CDEV_H_ 37 | 38 | #ifndef __XC16 39 | #error Use XC16 for compiling 40 | #endif 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | #define I2C_DATA_WAIT 152 //(20*I2C_DATA_WAIT*20 - 1) cycle 48 | 49 | 50 | int8_t I2Cdev_readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data); 51 | int8_t I2Cdev_readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data); 52 | int8_t I2Cdev_readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data); 53 | int8_t I2Cdev_readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data); 54 | int8_t I2Cdev_readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data); 55 | int8_t I2Cdev_readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data); 56 | int8_t I2Cdev_readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 57 | int8_t I2Cdev_readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 58 | 59 | bool I2Cdev_writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); 60 | bool I2Cdev_writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); 61 | bool I2Cdev_writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); 62 | bool I2Cdev_writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); 63 | bool I2Cdev_writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); 64 | bool I2Cdev_writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); 65 | bool I2Cdev_writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 66 | bool I2Cdev_writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 67 | 68 | #endif /* _I2CDEV_H_ */ 69 | -------------------------------------------------------------------------------- /dsPIC30F/I2Cdev/I2CdevdsPic30F.X/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.microchip.mplab.nbide.embedded.makeproject 4 | 5 | 6 | I2CdevdsPic30F 7 | 231209f4-6ed3-4604-8ec8-3340e931ead8 8 | 0 9 | c 10 | 11 | h 12 | 13 | ISO-8859-1 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /dsPIC30F/MPU6050/Examples/MPU6050_example.X/I2Cdev.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - Main I2C device class header file 2 | // Abstracts bit and byte I2C R/W functions into a convenient class 3 | // 6/9/2012 by Jeff Rowberg 4 | // 11/28/2014 by Marton Sebok 5 | // 6 | // Changelog: 7 | // 2014-11-28 - ported to PIC18 peripheral library from Arduino code 8 | 9 | /* ============================================ 10 | I2Cdev device library code is placed under the MIT license 11 | Copyright (c) 2013 Jeff Rowberg 12 | Copyright (c) 2014 Marton Sebok 13 | Copyright (c) 2017 Daichou 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy 16 | of this software and associated documentation files (the "Software"), to deal 17 | in the Software without restriction, including without limitation the rights 18 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19 | copies of the Software, and to permit persons to whom the Software is 20 | furnished to do so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in 23 | all copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 31 | THE SOFTWARE. 32 | =============================================== 33 | */ 34 | 35 | #ifndef _I2CDEV_H_ 36 | #define _I2CDEV_H_ 37 | 38 | #ifndef __XC16 39 | #error Use XC16 for compiling 40 | #endif 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | #define I2C_DATA_WAIT 152 //(20*I2C_DATA_WAIT*20 - 1) cycle 48 | 49 | 50 | int8_t I2Cdev_readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data); 51 | int8_t I2Cdev_readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data); 52 | int8_t I2Cdev_readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data); 53 | int8_t I2Cdev_readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data); 54 | int8_t I2Cdev_readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data); 55 | int8_t I2Cdev_readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data); 56 | int8_t I2Cdev_readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 57 | int8_t I2Cdev_readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 58 | 59 | bool I2Cdev_writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); 60 | bool I2Cdev_writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); 61 | bool I2Cdev_writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); 62 | bool I2Cdev_writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); 63 | bool I2Cdev_writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); 64 | bool I2Cdev_writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); 65 | bool I2Cdev_writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 66 | bool I2Cdev_writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 67 | 68 | #endif /* _I2CDEV_H_ */ 69 | -------------------------------------------------------------------------------- /dsPIC30F/MPU6050/Examples/MPU6050_example.X/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # There exist several targets which are by default empty and which can be 3 | # used for execution of your targets. These targets are usually executed 4 | # before and after some main targets. They are: 5 | # 6 | # .build-pre: called before 'build' target 7 | # .build-post: called after 'build' target 8 | # .clean-pre: called before 'clean' target 9 | # .clean-post: called after 'clean' target 10 | # .clobber-pre: called before 'clobber' target 11 | # .clobber-post: called after 'clobber' target 12 | # .all-pre: called before 'all' target 13 | # .all-post: called after 'all' target 14 | # .help-pre: called before 'help' target 15 | # .help-post: called after 'help' target 16 | # 17 | # Targets beginning with '.' are not intended to be called on their own. 18 | # 19 | # Main targets can be executed directly, and they are: 20 | # 21 | # build build a specific configuration 22 | # clean remove built files from a configuration 23 | # clobber remove all built files 24 | # all build all configurations 25 | # help print help mesage 26 | # 27 | # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and 28 | # .help-impl are implemented in nbproject/makefile-impl.mk. 29 | # 30 | # Available make variables: 31 | # 32 | # CND_BASEDIR base directory for relative paths 33 | # CND_DISTDIR default top distribution directory (build artifacts) 34 | # CND_BUILDDIR default top build directory (object files, ...) 35 | # CONF name of current configuration 36 | # CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) 37 | # CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) 38 | # CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) 39 | # CND_PACKAGE_DIR_${CONF} directory of package (current configuration) 40 | # CND_PACKAGE_NAME_${CONF} name of package (current configuration) 41 | # CND_PACKAGE_PATH_${CONF} path to package (current configuration) 42 | # 43 | # NOCDDL 44 | 45 | 46 | # Environment 47 | MKDIR=mkdir 48 | CP=cp 49 | CCADMIN=CCadmin 50 | RANLIB=ranlib 51 | 52 | 53 | # build 54 | build: .build-post 55 | 56 | .build-pre: 57 | # Add your pre 'build' code here... 58 | 59 | .build-post: .build-impl 60 | # Add your post 'build' code here... 61 | 62 | 63 | # clean 64 | clean: .clean-post 65 | 66 | .clean-pre: 67 | # Add your pre 'clean' code here... 68 | # WARNING: the IDE does not call this target since it takes a long time to 69 | # simply run make. Instead, the IDE removes the configuration directories 70 | # under build and dist directly without calling make. 71 | # This target is left here so people can do a clean when running a clean 72 | # outside the IDE. 73 | 74 | .clean-post: .clean-impl 75 | # Add your post 'clean' code here... 76 | 77 | 78 | # clobber 79 | clobber: .clobber-post 80 | 81 | .clobber-pre: 82 | # Add your pre 'clobber' code here... 83 | 84 | .clobber-post: .clobber-impl 85 | # Add your post 'clobber' code here... 86 | 87 | 88 | # all 89 | all: .all-post 90 | 91 | .all-pre: 92 | # Add your pre 'all' code here... 93 | 94 | .all-post: .all-impl 95 | # Add your post 'all' code here... 96 | 97 | 98 | # help 99 | help: .help-post 100 | 101 | .help-pre: 102 | # Add your pre 'help' code here... 103 | 104 | .help-post: .help-impl 105 | # Add your post 'help' code here... 106 | 107 | 108 | 109 | # include project implementation makefile 110 | include nbproject/Makefile-impl.mk 111 | 112 | # include project make variables 113 | include nbproject/Makefile-variables.mk 114 | -------------------------------------------------------------------------------- /dsPIC30F/MPU6050/Examples/MPU6050_example.X/nbproject/Makefile-genesis.properties: -------------------------------------------------------------------------------- 1 | # 2 | #Wed Apr 26 15:57:55 CST 2017 3 | default.com-microchip-mplab-nbide-toolchainXC16-XC16LanguageToolchain.md5=10deee1b358b9eb8b4aaaeb9dce00420 4 | default.languagetoolchain.dir=/opt/microchip/xc16/v1.31/bin 5 | configurations-xml=fd1da04a6257bc2861900a03a85b49c1 6 | com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=68c66d83550b716fa3e84319671e802c 7 | default.languagetoolchain.version=1.31 8 | host.platform=linux 9 | conf.ids=default 10 | -------------------------------------------------------------------------------- /dsPIC30F/MPU6050/Examples/MPU6050_example.X/nbproject/Makefile-impl.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated Makefile - do not edit! 3 | # 4 | # Edit the Makefile in the project folder instead (../Makefile). Each target 5 | # has a pre- and a post- target defined where you can add customization code. 6 | # 7 | # This makefile implements macros and targets common to all configurations. 8 | # 9 | # NOCDDL 10 | 11 | 12 | # Building and Cleaning subprojects are done by default, but can be controlled with the SUB 13 | # macro. If SUB=no, subprojects will not be built or cleaned. The following macro 14 | # statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf 15 | # and .clean-reqprojects-conf unless SUB has the value 'no' 16 | SUB_no=NO 17 | SUBPROJECTS=${SUB_${SUB}} 18 | BUILD_SUBPROJECTS_=.build-subprojects 19 | BUILD_SUBPROJECTS_NO= 20 | BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} 21 | CLEAN_SUBPROJECTS_=.clean-subprojects 22 | CLEAN_SUBPROJECTS_NO= 23 | CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} 24 | 25 | 26 | # Project Name 27 | PROJECTNAME=MPU6050_example.X 28 | 29 | # Active Configuration 30 | DEFAULTCONF=default 31 | CONF=${DEFAULTCONF} 32 | 33 | # All Configurations 34 | ALLCONFS=default 35 | 36 | 37 | # build 38 | .build-impl: .build-pre 39 | ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf 40 | 41 | 42 | # clean 43 | .clean-impl: .clean-pre 44 | ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf 45 | 46 | # clobber 47 | .clobber-impl: .clobber-pre .depcheck-impl 48 | ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default clean 49 | 50 | 51 | 52 | # all 53 | .all-impl: .all-pre .depcheck-impl 54 | ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default build 55 | 56 | 57 | 58 | # dependency checking support 59 | .depcheck-impl: 60 | # @echo "# This code depends on make tool being used" >.dep.inc 61 | # @if [ -n "${MAKE_VERSION}" ]; then \ 62 | # echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \ 63 | # echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ 64 | # echo "include \$${DEPFILES}" >>.dep.inc; \ 65 | # echo "endif" >>.dep.inc; \ 66 | # else \ 67 | # echo ".KEEP_STATE:" >>.dep.inc; \ 68 | # echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ 69 | # fi 70 | -------------------------------------------------------------------------------- /dsPIC30F/MPU6050/Examples/MPU6050_example.X/nbproject/Makefile-local-default.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated Makefile - do not edit! 3 | # 4 | # 5 | # This file contains information about the location of compilers and other tools. 6 | # If you commmit this file into your revision control server, you will be able to 7 | # to checkout the project and build it from the command line with make. However, 8 | # if more than one person works on the same project, then this file might show 9 | # conflicts since different users are bound to have compilers in different places. 10 | # In that case you might choose to not commit this file and let MPLAB X recreate this file 11 | # for each user. The disadvantage of not commiting this file is that you must run MPLAB X at 12 | # least once so the file gets created and the project can be built. Finally, you can also 13 | # avoid using this file at all if you are only building from the command line with make. 14 | # You can invoke make with the values of the macros: 15 | # $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ... 16 | # 17 | PATH_TO_IDE_BIN=/opt/microchip/mplabx/v3.60/mplab_ide/platform/../mplab_ide/modules/../../bin/ 18 | # Adding MPLAB X bin directory to path. 19 | PATH:=/opt/microchip/mplabx/v3.60/mplab_ide/platform/../mplab_ide/modules/../../bin/:$(PATH) 20 | # Path to java used to run MPLAB X when this makefile was created 21 | MP_JAVA_PATH="/opt/microchip/mplabx/v3.60/sys/java/jre1.8.0_121/bin/" 22 | OS_CURRENT="$(shell uname -s)" 23 | MP_CC="/opt/microchip/xc16/v1.31/bin/xc16-gcc" 24 | # MP_CPPC is not defined 25 | # MP_BC is not defined 26 | MP_AS="/opt/microchip/xc16/v1.31/bin/xc16-as" 27 | MP_LD="/opt/microchip/xc16/v1.31/bin/xc16-ld" 28 | MP_AR="/opt/microchip/xc16/v1.31/bin/xc16-ar" 29 | DEP_GEN=${MP_JAVA_PATH}java -jar "/opt/microchip/mplabx/v3.60/mplab_ide/platform/../mplab_ide/modules/../../bin/extractobjectdependencies.jar" 30 | MP_CC_DIR="/opt/microchip/xc16/v1.31/bin" 31 | # MP_CPPC_DIR is not defined 32 | # MP_BC_DIR is not defined 33 | MP_AS_DIR="/opt/microchip/xc16/v1.31/bin" 34 | MP_LD_DIR="/opt/microchip/xc16/v1.31/bin" 35 | MP_AR_DIR="/opt/microchip/xc16/v1.31/bin" 36 | # MP_BC_DIR is not defined 37 | -------------------------------------------------------------------------------- /dsPIC30F/MPU6050/Examples/MPU6050_example.X/nbproject/Makefile-variables.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Generated - do not edit! 3 | # 4 | # NOCDDL 5 | # 6 | CND_BASEDIR=`pwd` 7 | # default configuration 8 | CND_ARTIFACT_DIR_default=dist/default/production 9 | CND_ARTIFACT_NAME_default=MPU6050_example.X.production.hex 10 | CND_ARTIFACT_PATH_default=dist/default/production/MPU6050_example.X.production.hex 11 | CND_PACKAGE_DIR_default=${CND_DISTDIR}/default/package 12 | CND_PACKAGE_NAME_default=mpu6050example.x.tar 13 | CND_PACKAGE_PATH_default=${CND_DISTDIR}/default/package/mpu6050example.x.tar 14 | -------------------------------------------------------------------------------- /dsPIC30F/MPU6050/Examples/MPU6050_example.X/nbproject/Package-default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # 4 | # Generated - do not edit! 5 | # 6 | 7 | # Macros 8 | TOP=`pwd` 9 | CND_CONF=default 10 | CND_DISTDIR=dist 11 | TMPDIR=build/${CND_CONF}/${IMAGE_TYPE}/tmp-packaging 12 | TMPDIRNAME=tmp-packaging 13 | OUTPUT_PATH=dist/${CND_CONF}/${IMAGE_TYPE}/MPU6050_example.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} 14 | OUTPUT_BASENAME=MPU6050_example.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} 15 | PACKAGE_TOP_DIR=mpu6050example.x/ 16 | 17 | # Functions 18 | function checkReturnCode 19 | { 20 | rc=$? 21 | if [ $rc != 0 ] 22 | then 23 | exit $rc 24 | fi 25 | } 26 | function makeDirectory 27 | # $1 directory path 28 | # $2 permission (optional) 29 | { 30 | mkdir -p "$1" 31 | checkReturnCode 32 | if [ "$2" != "" ] 33 | then 34 | chmod $2 "$1" 35 | checkReturnCode 36 | fi 37 | } 38 | function copyFileToTmpDir 39 | # $1 from-file path 40 | # $2 to-file path 41 | # $3 permission 42 | { 43 | cp "$1" "$2" 44 | checkReturnCode 45 | if [ "$3" != "" ] 46 | then 47 | chmod $3 "$2" 48 | checkReturnCode 49 | fi 50 | } 51 | 52 | # Setup 53 | cd "${TOP}" 54 | mkdir -p ${CND_DISTDIR}/${CND_CONF}/package 55 | rm -rf ${TMPDIR} 56 | mkdir -p ${TMPDIR} 57 | 58 | # Copy files and create directories and links 59 | cd "${TOP}" 60 | makeDirectory ${TMPDIR}/mpu6050example.x/bin 61 | copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 62 | 63 | 64 | # Generate tar file 65 | cd "${TOP}" 66 | rm -f ${CND_DISTDIR}/${CND_CONF}/package/mpu6050example.x.tar 67 | cd ${TMPDIR} 68 | tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/package/mpu6050example.x.tar * 69 | checkReturnCode 70 | 71 | # Cleanup 72 | cd "${TOP}" 73 | rm -rf ${TMPDIR} 74 | -------------------------------------------------------------------------------- /dsPIC30F/MPU6050/Examples/MPU6050_example.X/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.microchip.mplab.nbide.embedded.makeproject 4 | 5 | 6 | MPU6050_example 7 | 04e5589e-1a03-434e-ace3-9ef3c9c9d958 8 | 0 9 | c 10 | 11 | h 12 | 13 | ISO-8859-1 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /dsPIC30F/README.md: -------------------------------------------------------------------------------- 1 | # I2C Device Library for dsPIC30F(under construction) 2 | 3 | ## I2Cdev 4 | We use XC16's peripheral libraries (_plib_), read timeout is not implemented. 5 | 6 | ## Devices 7 | Currently only MPU6050 is supported without DMP functions. There's an example MPLABX project showing how to read raw data from the MPU. 8 | 9 | Adding more functions and devices should be straighforward after reading the source code. 10 | 11 | ## Licence 12 | I2Cdev device library code is placed under the MIT license. 13 | 14 | _Copyright (c) 2011 Jeff Rowberg. Copyright (c) 2014 Marton Sebok._ Copyright (c) 2017 Daichou. 15 | -------------------------------------------------------------------------------- /nRF51/I2CDev/I2Cdev.h: -------------------------------------------------------------------------------- 1 | // I2Cdev library collection - Main I2C device class 2 | // Abstracts bit and byte I2C R/W functions into a convenient class 3 | // EFM32 stub port by Nicolas Baldeck 4 | // Based on Arduino's I2Cdev by Jeff Rowberg 5 | // 6 | // Changelog: 7 | // 2015-01-02 - Initial release 8 | 9 | 10 | /* ============================================ 11 | I2Cdev device library code is placed under the MIT license 12 | Copyright (c) 2015 Jeff Rowberg, Nicolas Baldeck 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. 31 | =============================================== 32 | */ 33 | 34 | #ifndef _I2CDEV_H_ 35 | #define _I2CDEV_H_ 36 | #include 37 | #include "compiler_abstraction.h" 38 | #include "nrf.h" 39 | #ifdef SOFTDEVICE_PRESENT 40 | #include "nrf_soc.h" 41 | #include "app_error.h" 42 | #endif 43 | 44 | 45 | #define I2C_SDA_PORT gpioPortA 46 | #define I2C_SDA_PIN 0 47 | #define I2C_SDA_MODE gpioModeWiredAnd 48 | #define I2C_SDA_DOUT 1 49 | 50 | #define I2C_SCL_PORT gpioPortA 51 | #define I2C_SCL_PIN 1 52 | #define I2C_SCL_MODE gpioModeWiredAnd 53 | #define I2C_SCL_DOUT 1 54 | 55 | #define I2CDEV_DEFAULT_READ_TIMEOUT 0 56 | 57 | class I2Cdev { 58 | public: 59 | I2Cdev(); 60 | 61 | static void initialize(); 62 | static void enable(bool isEnabled); 63 | 64 | static int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); 65 | //TODO static int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); 66 | static int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); 67 | //TODO static int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); 68 | static int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); 69 | //TODO static int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); 70 | static int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); 71 | //TODO static int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); 72 | 73 | static bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); 74 | //TODO static bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); 75 | static bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); 76 | //TODO static bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); 77 | static bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); 78 | static bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); 79 | static bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 80 | static bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 81 | 82 | static uint16_t readTimeout; 83 | }; 84 | 85 | #endif /* _I2CDEV_H_ */ 86 | --------------------------------------------------------------------------------