From 00bcabb0eda57eb059460af27be85cc14a2121e9 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Mon, 8 Feb 2021 15:14:12 +0000 Subject: [PATCH] Clarifying the license --- README.md | 6 +-- .../Example1_Basics/Example1_Basics.ino | 19 ++++--- .../Example2_Advanced/Example2_Advanced.ino | 39 +++++++------- .../Example3_Interrupts.ino | 53 +++++++++---------- .../Example999_Portable.ino | 37 +++++++------ 5 files changed, 75 insertions(+), 79 deletions(-) diff --git a/README.md b/README.md index 90c09ce..9401cb7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ SparkFun_ICM-20948_ArduinoLibrary ======================================== -This is the library for the [SparkFun 9DoF IMU Breakout - ICM-20948 (Qwiic)](https://www.sparkfun.com/products/15335). +This is the library for the [SparkFun 9DoF IMU Breakout - ICM-20948 (Qwiic)](https://www.sparkfun.com/products/15335). Repository Contents @@ -18,7 +18,7 @@ Documentation * **[Hookup Guide](https://learn.sparkfun.com/tutorials/sparkfun-9dof-imu-icm-20948-breakout-hookup-guide)** - Basic hookup guide for the SparkFun 9DoF IMU Breakout. * **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library. -Products that use this Library +Products that use this Library --------------------------------- * [SparkFun 9DoF IMU Breakout - ICM-20948 (Qwiic)](https://www.sparkfun.com/products/15335) @@ -28,7 +28,7 @@ License Information This product is _**open source**_! -The **code** is released under the GPL v3 license. See the included LICENSE.md for more information. +Please see the included [License.md](./License.md) for more information. Distributed as-is; no warranty is given. diff --git a/examples/Arduino/Example1_Basics/Example1_Basics.ino b/examples/Arduino/Example1_Basics/Example1_Basics.ino index da91073..47edad7 100644 --- a/examples/Arduino/Example1_Basics/Example1_Basics.ino +++ b/examples/Arduino/Example1_Basics/Example1_Basics.ino @@ -1,13 +1,12 @@ /**************************************************************** * Example1_Basics.ino - * ICM 20948 Arduino Library Demo + * ICM 20948 Arduino Library Demo * Use the default configuration to stream 9-axis IMU data * Owen Lyke @ SparkFun Electronics * Original Creation Date: April 17 2019 - * - * This code is beerware; if you see me (or any other SparkFun employee) at the - * local, and you've found our code helpful, please buy us a round! - * + * + * Please see License.md for the license information. + * * Distributed as-is; no warranty is given. ***************************************************************/ #include "ICM_20948.h" // Click here to get the library: http://librarymanager/All#SparkFun_ICM_20948_IMU @@ -20,8 +19,8 @@ #define CS_PIN 2 // Which pin you connect CS to. Used only when "USE_SPI" is defined #define WIRE_PORT Wire // Your desired Wire port. Used when "USE_SPI" is not defined -#define AD0_VAL 1 // The value of the last bit of the I2C address. - // On the SparkFun 9DoF IMU breakout the default is 1, and when +#define AD0_VAL 1 // The value of the last bit of the I2C address. + // On the SparkFun 9DoF IMU breakout the default is 1, and when // the ADR jumper is closed the value becomes 0 #ifdef USE_SPI @@ -42,12 +41,12 @@ void setup() { WIRE_PORT.begin(); WIRE_PORT.setClock(400000); #endif - + bool initialized = false; while( !initialized ){ #ifdef USE_SPI - myICM.begin( CS_PIN, SPI_PORT ); + myICM.begin( CS_PIN, SPI_PORT ); #else myICM.begin( WIRE_PORT, AD0_VAL ); #endif @@ -74,7 +73,7 @@ void loop() { Serial.println("Waiting for data"); delay(500); } - + } diff --git a/examples/Arduino/Example2_Advanced/Example2_Advanced.ino b/examples/Arduino/Example2_Advanced/Example2_Advanced.ino index 38406aa..1948395 100644 --- a/examples/Arduino/Example2_Advanced/Example2_Advanced.ino +++ b/examples/Arduino/Example2_Advanced/Example2_Advanced.ino @@ -1,13 +1,12 @@ /**************************************************************** * Example2_Advanced.ino - * ICM 20948 Arduino Library Demo + * ICM 20948 Arduino Library Demo * Shows how to use granular configuration of the ICM 20948 * Owen Lyke @ SparkFun Electronics * Original Creation Date: April 17 2019 - * - * This code is beerware; if you see me (or any other SparkFun employee) at the - * local, and you've found our code helpful, please buy us a round! - * + * + * Please see License.md for the license information. + * * Distributed as-is; no warranty is given. ***************************************************************/ #include "ICM_20948.h" // Click here to get the library: http://librarymanager/All#SparkFun_ICM_20948_IMU @@ -21,8 +20,8 @@ #define CS_PIN 2 // Which pin you connect CS to. Used only when "USE_SPI" is defined #define WIRE_PORT Wire // Your desired Wire port. Used when "USE_SPI" is not defined -#define AD0_VAL 1 // The value of the last bit of the I2C address. - // On the SparkFun 9DoF IMU breakout the default is 1, and when +#define AD0_VAL 1 // The value of the last bit of the I2C address. + // On the SparkFun 9DoF IMU breakout the default is 1, and when // the ADR jumper is closed the value becomes 0 #ifdef USE_SPI @@ -30,7 +29,7 @@ #else ICM_20948_I2C myICM; // Otherwise create an ICM_20948_I2C object #endif - + void setup() { @@ -43,12 +42,12 @@ void setup() { WIRE_PORT.begin(); WIRE_PORT.setClock(400000); #endif - + bool initialized = false; while( !initialized ){ #ifdef USE_SPI - myICM.begin( CS_PIN, SPI_PORT, SPI_FREQ ); // Here we are using the user-defined SPI_FREQ as the clock speed of the SPI bus + myICM.begin( CS_PIN, SPI_PORT, SPI_FREQ ); // Here we are using the user-defined SPI_FREQ as the clock speed of the SPI bus #else myICM.begin( WIRE_PORT, AD0_VAL ); #endif @@ -73,7 +72,7 @@ void setup() { SERIAL_PORT.println(myICM.statusString()); } delay(250); - + // Now wake the sensor up myICM.sleep( false ); myICM.lowPower( false ); @@ -83,7 +82,7 @@ void setup() { // Set Gyro and Accelerometer to a particular sample mode // options: ICM_20948_Sample_Mode_Continuous // ICM_20948_Sample_Mode_Cycled - myICM.setSampleMode( (ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), ICM_20948_Sample_Mode_Continuous ); + myICM.setSampleMode( (ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), ICM_20948_Sample_Mode_Continuous ); if( myICM.status != ICM_20948_Stat_Ok){ SERIAL_PORT.print(F("setSampleMode returned: ")); SERIAL_PORT.println(myICM.statusString()); @@ -91,20 +90,20 @@ void setup() { // Set full scale ranges for both acc and gyr ICM_20948_fss_t myFSS; // This uses a "Full Scale Settings" structure that can contain values for all configurable sensors - + myFSS.a = gpm2; // (ICM_20948_ACCEL_CONFIG_FS_SEL_e) // gpm2 // gpm4 // gpm8 // gpm16 - + myFSS.g = dps250; // (ICM_20948_GYRO_CONFIG_1_FS_SEL_e) // dps250 // dps500 // dps1000 // dps2000 - - myICM.setFullScale( (ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), myFSS ); + + myICM.setFullScale( (ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), myFSS ); if( myICM.status != ICM_20948_Stat_Ok){ SERIAL_PORT.print(F("setFullScale returned: ")); SERIAL_PORT.println(myICM.statusString()); @@ -131,7 +130,7 @@ void setup() { // gyr_d11bw6_n17bw8 // gyr_d5bw7_n8bw9 // gyr_d361bw4_n376bw5 - + myICM.setDLPFcfg( (ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), myDLPcfg ); if( myICM.status != ICM_20948_Stat_Ok){ SERIAL_PORT.print(F("setDLPcfg returned: ")); @@ -146,11 +145,11 @@ void setup() { SERIAL_PORT.print(F("Enable DLPF for Gyroscope returned: ")); SERIAL_PORT.println(myICM.statusString(gyrDLPEnableStat)); SERIAL_PORT.println(); - SERIAL_PORT.println(F("Configuration complete!")); + SERIAL_PORT.println(F("Configuration complete!")); } void loop() { - + if( myICM.dataReady() ){ myICM.getAGMT(); // The values are only updated when you call 'getAGMT' // printRawAGMT( myICM.agmt ); // Uncomment this to see the raw values, taken directly from the agmt structure @@ -160,7 +159,7 @@ void loop() { Serial.println("Waiting for data"); delay(500); } - + } diff --git a/examples/Arduino/Example3_Interrupts/Example3_Interrupts.ino b/examples/Arduino/Example3_Interrupts/Example3_Interrupts.ino index 25fe99d..ae9ec48 100644 --- a/examples/Arduino/Example3_Interrupts/Example3_Interrupts.ino +++ b/examples/Arduino/Example3_Interrupts/Example3_Interrupts.ino @@ -1,16 +1,15 @@ /**************************************************************** * Example3_Interrupts.ino - * ICM 20948 Arduino Library Demo + * ICM 20948 Arduino Library Demo * Builds on Example2_Advanced.ino to set up interrupts when data is ready * Owen Lyke @ SparkFun Electronics * Original Creation Date: June 5 2019 - * - * For this example you must connect the interrupt pin "INT" on the breakout + * + * For this example you must connect the interrupt pin "INT" on the breakout * board to the pin specified by "INT_PIN" on your microcontroller. - * - * This code is beerware; if you see me (or any other SparkFun employee) at the - * local, and you've found our code helpful, please buy us a round! - * + * + * Please see License.md for the license information. + * * Distributed as-is; no warranty is given. ***************************************************************/ #include "ICM_20948.h" // Click here to get the library: http://librarymanager/All#SparkFun_ICM_20948_IMU @@ -29,8 +28,8 @@ #define CS_PIN 2 // Which pin you connect CS to. Used only when "USE_SPI" is defined #define WIRE_PORT Wire // Your desired Wire port. Used when "USE_SPI" is not defined -#define AD0_VAL 1 // The value of the last bit of the I2C address. - // On the SparkFun 9DoF IMU breakout the default is 1, and when +#define AD0_VAL 1 // The value of the last bit of the I2C address. + // On the SparkFun 9DoF IMU breakout the default is 1, and when // the ADR jumper is closed the value becomes 0 #ifdef USE_SPI @@ -61,12 +60,12 @@ void setup() { WIRE_PORT.begin(); WIRE_PORT.setClock(400000); #endif - + bool initialized = false; while( !initialized ){ #ifdef USE_SPI - myICM.begin( CS_PIN, SPI_PORT, SPI_FREQ ); // Here we are using the user-defined SPI_FREQ as the clock speed of the SPI bus + myICM.begin( CS_PIN, SPI_PORT, SPI_FREQ ); // Here we are using the user-defined SPI_FREQ as the clock speed of the SPI bus #else myICM.begin( WIRE_PORT, AD0_VAL ); #endif @@ -91,7 +90,7 @@ void setup() { SERIAL_PORT.println(myICM.statusString()); } delay(250); - + // Now wake the sensor up myICM.sleep( sensorSleep ); myICM.lowPower( false ); @@ -101,7 +100,7 @@ void setup() { // Set Gyro and Accelerometer to a particular sample mode // options: ICM_20948_Sample_Mode_Continuous // ICM_20948_Sample_Mode_Cycled - myICM.setSampleMode( (ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), ICM_20948_Sample_Mode_Cycled ); + myICM.setSampleMode( (ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), ICM_20948_Sample_Mode_Cycled ); SERIAL_PORT.print(F("setSampleMode returned: ")); SERIAL_PORT.println(myICM.statusString()); @@ -111,23 +110,23 @@ void setup() { myICM.setSampleRate( ICM_20948_Internal_Gyr, mySmplrt ); SERIAL_PORT.print(F("setSampleRate returned: ")); SERIAL_PORT.println(myICM.statusString()); - + // Set full scale ranges for both acc and gyr ICM_20948_fss_t myFSS; // This uses a "Full Scale Settings" structure that can contain values for all configurable sensors - + myFSS.a = gpm2; // (ICM_20948_ACCEL_CONFIG_FS_SEL_e) // gpm2 // gpm4 // gpm8 // gpm16 - + myFSS.g = dps250; // (ICM_20948_GYRO_CONFIG_1_FS_SEL_e) // dps250 // dps500 // dps1000 // dps2000 - - myICM.setFullScale( (ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), myFSS ); + + myICM.setFullScale( (ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), myFSS ); if( myICM.status != ICM_20948_Stat_Ok){ SERIAL_PORT.print(F("setFullScale returned: ")); SERIAL_PORT.println(myICM.statusString()); @@ -154,7 +153,7 @@ void setup() { // gyr_d11bw6_n17bw8 // gyr_d5bw7_n8bw9 // gyr_d361bw4_n376bw5 - + myICM.setDLPFcfg( (ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), myDLPcfg ); if( myICM.status != ICM_20948_Stat_Ok){ SERIAL_PORT.print(F("setDLPcfg returned: ")); @@ -193,7 +192,7 @@ void setup() { myICM.cfgIntLatch(true); // Latch the interrupt until cleared SERIAL_PORT.print(F("cfgIntLatch returned: ")); SERIAL_PORT.println(myICM.statusString()); - + myICM.intEnableRawDataReady(true); // enable interrupts on raw data ready SERIAL_PORT.print(F("intEnableRawDataReady returned: ")); SERIAL_PORT.println(myICM.statusString()); @@ -207,7 +206,7 @@ void setup() { // ICM_20948_execute_w( &myICM._device, AGB0_REG_INT_ENABLE, (uint8_t*)&zero_0, sizeof(uint8_t) ); SERIAL_PORT.println(); - SERIAL_PORT.println(F("Configuration complete!")); + SERIAL_PORT.println(F("Configuration complete!")); } void loop() { @@ -217,19 +216,19 @@ void loop() { // myICM.clearInterrupts(); // This would be efficient... but not compatible with Uno } - myICM.clearInterrupts(); // clear interrupts for next time - - // usually you'd do this only if an interrupt has occurred, however + myICM.clearInterrupts(); // clear interrupts for next time - + // usually you'd do this only if an interrupt has occurred, however // on the 328p I2C usage can block interrupts. This means that sometimes // an interrupt is missed. When missed, if using an edge-based interrupt - // and only clearing interrupts when one was detected there will be no more - // edges to respond to, so no more interrupts will be detected. Here are + // and only clearing interrupts when one was detected there will be no more + // edges to respond to, so no more interrupts will be detected. Here are // some possible solutions: // 1. use a level based interrupt // 2. use the pulse-based interrupt in ICM settings (set cfgIntLatch to false) // 3. use a microcontroller with nestable interrupts // 4. clear the interrupts often - - + + if( (millis()%1000) < 5){ // This is a method to turn the sensor on and off once per second without using delays if( canToggle ){ sensorSleep = !sensorSleep; diff --git a/examples/PortableC/Example999_Portable/Example999_Portable.ino b/examples/PortableC/Example999_Portable/Example999_Portable.ino index 0883dea..3e8d9b8 100644 --- a/examples/PortableC/Example999_Portable/Example999_Portable.ino +++ b/examples/PortableC/Example999_Portable/Example999_Portable.ino @@ -1,13 +1,12 @@ /**************************************************************** * Example999_Portable.ino - * ICM 20948 Arduino Library Demo + * ICM 20948 Arduino Library Demo * Uses underlying portable C skeleton with user-defined read/write functions * Owen Lyke @ SparkFun Electronics * Original Creation Date: April 17 2019 - * - * This code is beerware; if you see me (or any other SparkFun employee) at the - * local, and you've found our code helpful, please buy us a round! - * + * + * Please see License.md for the license information. + * * Distributed as-is; no warranty is given. ***************************************************************/ #include "ICM_20948.h" // Click here to get the library: http://librarymanager/All#SparkFun_ICM_20948_IMU @@ -27,7 +26,7 @@ #endif -// These are the interface functions that you would define for your system. They can use either I2C or SPI, +// These are the interface functions that you would define for your system. They can use either I2C or SPI, // or really **any** protocol as long as it successfully reads / writes the desired data into the ICM in the end #ifdef USE_SPI ICM_20948_Status_e my_write_spi(uint8_t reg, uint8_t* data, uint32_t len, void* user); @@ -42,13 +41,13 @@ const ICM_20948_Serif_t mySerif = { my_write_spi, // write my_read_spi, // read - NULL, // this pointer is passed into your functions when they are called. + NULL, // this pointer is passed into your functions when they are called. }; #else const ICM_20948_Serif_t mySerif = { my_write_i2c, // write my_read_i2c, // read - NULL, + NULL, }; #endif @@ -56,7 +55,7 @@ ICM_20948_Device_t myICM; void setup() { - + // Perform platform initialization Serial.begin(115200); @@ -125,7 +124,7 @@ uint8_t whoami = 0x00; void loop() { delay(1000); - + ICM_20948_AGMT_t agmt = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0}}; if(ICM_20948_get_agmt( &myICM, &agmt ) == ICM_20948_Stat_Ok){ printRawAGMT( agmt ); @@ -151,10 +150,10 @@ void loop() { SPI_PORT.endTransaction(); delayMicroseconds(5); digitalWrite(CS_PIN, HIGH); - + return ICM_20948_Stat_Ok; } - + ICM_20948_Status_e my_read_spi(uint8_t reg, uint8_t* buff, uint32_t len, void* user){ digitalWrite(CS_PIN, LOW); delayMicroseconds(5); @@ -166,10 +165,10 @@ void loop() { SPI_PORT.endTransaction(); delayMicroseconds(5); digitalWrite(CS_PIN, HIGH); - + return ICM_20948_Stat_Ok; } - + #else ICM_20948_Status_e my_write_i2c(uint8_t reg, uint8_t* data, uint32_t len, void* user){ @@ -177,23 +176,23 @@ void loop() { WIRE_PORT.write(reg); WIRE_PORT.write(data, len); WIRE_PORT.endTransmission(); - + return ICM_20948_Stat_Ok; } - + ICM_20948_Status_e my_read_i2c(uint8_t reg, uint8_t* buff, uint32_t len, void* user){ WIRE_PORT.beginTransmission(I2C_ADDR); WIRE_PORT.write(reg); WIRE_PORT.endTransmission(false); // Send repeated start - + uint32_t num_received = WIRE_PORT.requestFrom(I2C_ADDR, len); if(num_received == len){ - for(uint32_t i = 0; i < len; i++){ + for(uint32_t i = 0; i < len; i++){ buff[i] = WIRE_PORT.read(); } } WIRE_PORT.endTransmission(); - + return ICM_20948_Stat_Ok; }