From e44b0692dfd01073a133f7786ef23da5a0495f27 Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Thu, 15 Aug 2019 13:23:18 -0600 Subject: [PATCH 1/3] Move I2C and SPI examples into their directories --- .../Example0_Compilation.ino | 16 ---------------- .../examples/Example1_SPI/Example1_SPI.ino} | 0 .../examples/Example1_Wire/Example1_Wire.ino} | 0 .../Example2_MoreI2CPorts.ino} | 0 4 files changed, 16 deletions(-) delete mode 100644 libraries/Examples/examples/Example0_Compilation/Example0_Compilation.ino rename libraries/{Examples/examples/Example6_SPI/Example6_SPI.ino => SPI/examples/Example1_SPI/Example1_SPI.ino} (100%) rename libraries/{Examples/examples/Example5_Wire/Example5_Wire.ino => Wire/examples/Example1_Wire/Example1_Wire.ino} (100%) rename libraries/{Examples/examples/Advanced/Additional_I2C_Ports/Additional_I2C_Ports.ino => Wire/examples/Example2_MoreI2CPorts/Example2_MoreI2CPorts.ino} (100%) diff --git a/libraries/Examples/examples/Example0_Compilation/Example0_Compilation.ino b/libraries/Examples/examples/Example0_Compilation/Example0_Compilation.ino deleted file mode 100644 index 6db03cbc..00000000 --- a/libraries/Examples/examples/Example0_Compilation/Example0_Compilation.ino +++ /dev/null @@ -1,16 +0,0 @@ -/* Author: Owen Lyke - Created: April 2 2019 - License: MIT. See SparkFun Arduino Apollo3 Project for more information - - This example demonstrates that the IDE is able to compile the Ambiq Apollo3 HAL - Turn on verbose output and find the output path (i.e. ~/arduino_build_######/example0_compilation.ino.bin) - Use the Ambiq SDK + tools to upload the binary to your microcontroller -*/ - -void setup() { - // put your setup code here, to run once: -} - -void loop() { - // put your main code here, to run repeatedly: -} diff --git a/libraries/Examples/examples/Example6_SPI/Example6_SPI.ino b/libraries/SPI/examples/Example1_SPI/Example1_SPI.ino similarity index 100% rename from libraries/Examples/examples/Example6_SPI/Example6_SPI.ino rename to libraries/SPI/examples/Example1_SPI/Example1_SPI.ino diff --git a/libraries/Examples/examples/Example5_Wire/Example5_Wire.ino b/libraries/Wire/examples/Example1_Wire/Example1_Wire.ino similarity index 100% rename from libraries/Examples/examples/Example5_Wire/Example5_Wire.ino rename to libraries/Wire/examples/Example1_Wire/Example1_Wire.ino diff --git a/libraries/Examples/examples/Advanced/Additional_I2C_Ports/Additional_I2C_Ports.ino b/libraries/Wire/examples/Example2_MoreI2CPorts/Example2_MoreI2CPorts.ino similarity index 100% rename from libraries/Examples/examples/Advanced/Additional_I2C_Ports/Additional_I2C_Ports.ino rename to libraries/Wire/examples/Example2_MoreI2CPorts/Example2_MoreI2CPorts.ino From 75699f86271a54859a048fd5533637f51e5dd491 Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Thu, 15 Aug 2019 13:31:30 -0600 Subject: [PATCH 2/3] Re-arrange examples --- .../Example1_GetPut/Example1_GetPut.ino} | 0 .../Example2_AllFunctions.ino} | 0 .../Example4_ToggleAllPins.ino} | 0 .../Example3_Delay.ino} | 16 ++++++--- .../Example4_analogRead.ino} | 0 .../Example5_analogWrite.ino} | 0 .../Example6_ArduinoReferenceFunctions.ino} | 0 .../Example7_AttachInterrupts.ino} | 35 +++++++++++-------- 8 files changed, 32 insertions(+), 19 deletions(-) rename libraries/{Examples/examples/Advanced/EEPROM_GetPut/EEPROM_GetPut.ino => EEPROM/examples/Example1_GetPut/Example1_GetPut.ino} (100%) rename libraries/EEPROM/examples/{Apollo_EEPROM/Apollo_EEPROM.ino => Example2_AllFunctions/Example2_AllFunctions.ino} (100%) rename libraries/Examples/examples/{Example4_TestAllGPIOs/Example4_TestAllGPIOs.ino => Advanced/Example4_ToggleAllPins/Example4_ToggleAllPins.ino} (100%) rename libraries/Examples/examples/{Example8_millis/Example8_millis.ino => Example3_Delay/Example3_Delay.ino} (64%) rename libraries/Examples/examples/{Example7_analogRead/Example7_analogRead.ino => Example4_analogRead/Example4_analogRead.ino} (100%) rename libraries/Examples/examples/{Example9_analogWrite/Example9_analogWrite.ino => Example5_analogWrite/Example5_analogWrite.ino} (100%) rename libraries/Examples/examples/{Example11_BitsAndBytes/Example11_BitsAndBytes.ino => Example6_ArduinoReferenceFunctions/Example6_ArduinoReferenceFunctions.ino} (100%) rename libraries/Examples/examples/{Example10_Interrupts/Example10_Interrupts.ino => Example7_AttachInterrupts/Example7_AttachInterrupts.ino} (63%) diff --git a/libraries/Examples/examples/Advanced/EEPROM_GetPut/EEPROM_GetPut.ino b/libraries/EEPROM/examples/Example1_GetPut/Example1_GetPut.ino similarity index 100% rename from libraries/Examples/examples/Advanced/EEPROM_GetPut/EEPROM_GetPut.ino rename to libraries/EEPROM/examples/Example1_GetPut/Example1_GetPut.ino diff --git a/libraries/EEPROM/examples/Apollo_EEPROM/Apollo_EEPROM.ino b/libraries/EEPROM/examples/Example2_AllFunctions/Example2_AllFunctions.ino similarity index 100% rename from libraries/EEPROM/examples/Apollo_EEPROM/Apollo_EEPROM.ino rename to libraries/EEPROM/examples/Example2_AllFunctions/Example2_AllFunctions.ino diff --git a/libraries/Examples/examples/Example4_TestAllGPIOs/Example4_TestAllGPIOs.ino b/libraries/Examples/examples/Advanced/Example4_ToggleAllPins/Example4_ToggleAllPins.ino similarity index 100% rename from libraries/Examples/examples/Example4_TestAllGPIOs/Example4_TestAllGPIOs.ino rename to libraries/Examples/examples/Advanced/Example4_ToggleAllPins/Example4_ToggleAllPins.ino diff --git a/libraries/Examples/examples/Example8_millis/Example8_millis.ino b/libraries/Examples/examples/Example3_Delay/Example3_Delay.ino similarity index 64% rename from libraries/Examples/examples/Example8_millis/Example8_millis.ino rename to libraries/Examples/examples/Example3_Delay/Example3_Delay.ino index 7569da75..af92d0c3 100644 --- a/libraries/Examples/examples/Example8_millis/Example8_millis.ino +++ b/libraries/Examples/examples/Example3_Delay/Example3_Delay.ino @@ -5,18 +5,24 @@ This example demonstrates how to use millis() and micros() */ -void setup() { +void setup() +{ Serial.begin(9600); - while(!Serial){}; //Wait for user to open terminal window + while (!Serial) + { + }; //Wait for user to open terminal window - Serial.println("SparkFun Arduino Apollo3 STimer Example"); + Serial.println("SparkFun Arduino Apollo3 Delay Example"); Serial.printf("Compiled on %s, %s\n\n", __DATE__, __TIME__); } void loop() { Serial.printf("Sec: %d, millis: %d, micros: %d, systicks: 0x%08X, sysoverflows: 0x%08X\n", secs(), millis(), micros(), systicks(), sysoverflows()); - delay(1111); //Arbitrary delay -} + + delay(1111); //Arbitrary millisecond delay + + delayMicroseconds(50); //Arbitrary microsecond delay +} \ No newline at end of file diff --git a/libraries/Examples/examples/Example7_analogRead/Example7_analogRead.ino b/libraries/Examples/examples/Example4_analogRead/Example4_analogRead.ino similarity index 100% rename from libraries/Examples/examples/Example7_analogRead/Example7_analogRead.ino rename to libraries/Examples/examples/Example4_analogRead/Example4_analogRead.ino diff --git a/libraries/Examples/examples/Example9_analogWrite/Example9_analogWrite.ino b/libraries/Examples/examples/Example5_analogWrite/Example5_analogWrite.ino similarity index 100% rename from libraries/Examples/examples/Example9_analogWrite/Example9_analogWrite.ino rename to libraries/Examples/examples/Example5_analogWrite/Example5_analogWrite.ino diff --git a/libraries/Examples/examples/Example11_BitsAndBytes/Example11_BitsAndBytes.ino b/libraries/Examples/examples/Example6_ArduinoReferenceFunctions/Example6_ArduinoReferenceFunctions.ino similarity index 100% rename from libraries/Examples/examples/Example11_BitsAndBytes/Example11_BitsAndBytes.ino rename to libraries/Examples/examples/Example6_ArduinoReferenceFunctions/Example6_ArduinoReferenceFunctions.ino diff --git a/libraries/Examples/examples/Example10_Interrupts/Example10_Interrupts.ino b/libraries/Examples/examples/Example7_AttachInterrupts/Example7_AttachInterrupts.ino similarity index 63% rename from libraries/Examples/examples/Example10_Interrupts/Example10_Interrupts.ino rename to libraries/Examples/examples/Example7_AttachInterrupts/Example7_AttachInterrupts.ino index f2382c69..086f49e1 100644 --- a/libraries/Examples/examples/Example10_Interrupts/Example10_Interrupts.ino +++ b/libraries/Examples/examples/Example7_AttachInterrupts/Example7_AttachInterrupts.ino @@ -18,29 +18,34 @@ The edge-based interrupts will clear the flag automatically. static uint32_t count = 0; bool interruptsEnabled = false; -void setup() { +void setup() +{ // put your setup code here, to run once: Serial.begin(9600); Serial.println("Interrupt testing"); pinMode(INT_PIN, INPUT_PULLUP); - + attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, RISING); -// attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, FALLING); -// attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, LOW); -// attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, HIGH); + // attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, FALLING); + // attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, LOW); + // attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, HIGH); + // attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, CHANGE); -// // attaching a different interrupt to the same pin overwrites the existing ISR -// attachInterruptArg(digitalPinToInterrupt(INT_PIN), myISRArg, &count, RISING); + // // attaching a different interrupt to the same pin overwrites the existing ISR + // attachInterruptArg(digitalPinToInterrupt(INT_PIN), myISRArg, &count, RISING); interruptsEnabled = true; } -void loop() { +void loop() +{ count++; - if( count > 5 ){ - if(interruptsEnabled){ + if (count > 5) + { + if (interruptsEnabled) + { detachInterrupt(digitalPinToInterrupt(INT_PIN)); interruptsEnabled = false; } @@ -48,11 +53,13 @@ void loop() { delay(1000); } -void myISR( void ){ +void myISR(void) +{ Serial.println("Hi i am an ISR!"); } -void myISRArg( void* arg ){ - uint32_t* local_count = (uint32_t*)arg; - Serial.printf("The time is %d seconds\n", *(local_count) ); +void myISRArg(void *arg) +{ + uint32_t *local_count = (uint32_t *)arg; + Serial.printf("The time is %d seconds\n", *(local_count)); } From 749efed73887a1450c8b11e75e5cec4f4c998c91 Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Thu, 15 Aug 2019 13:34:03 -0600 Subject: [PATCH 3/3] Rename a few examples --- .../Serial_FlowControl.ino} | 0 .../ToggleAllPins.ino} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename libraries/Examples/examples/Advanced/{ClassFunctions/ClassFunctions.ino => Serial_FlowControl/Serial_FlowControl.ino} (100%) rename libraries/Examples/examples/Advanced/{Example4_ToggleAllPins/Example4_ToggleAllPins.ino => ToggleAllPins/ToggleAllPins.ino} (100%) diff --git a/libraries/Examples/examples/Advanced/ClassFunctions/ClassFunctions.ino b/libraries/Examples/examples/Advanced/Serial_FlowControl/Serial_FlowControl.ino similarity index 100% rename from libraries/Examples/examples/Advanced/ClassFunctions/ClassFunctions.ino rename to libraries/Examples/examples/Advanced/Serial_FlowControl/Serial_FlowControl.ino diff --git a/libraries/Examples/examples/Advanced/Example4_ToggleAllPins/Example4_ToggleAllPins.ino b/libraries/Examples/examples/Advanced/ToggleAllPins/ToggleAllPins.ino similarity index 100% rename from libraries/Examples/examples/Advanced/Example4_ToggleAllPins/Example4_ToggleAllPins.ino rename to libraries/Examples/examples/Advanced/ToggleAllPins/ToggleAllPins.ino