From cc639cd9cb9eec40b9c80520bc4ea5ade6279743 Mon Sep 17 00:00:00 2001 From: Roger Clark Date: Fri, 13 May 2016 14:39:10 +1000 Subject: [PATCH] Moved examples to new dummy library item --- .../AnalogInOutSerial/AnalogInOutSerial.ino | 0 .../Analog/AnalogInSerial/AnalogInSerial.ino | 0 .../Analog/AnalogInput/AnalogInput.ino | 0 .../Analog/Calibration/Calibration.ino | 0 .../examples}/Analog/Fading/Fading.ino | 0 .../examples}/Analog/Smoothing/Smoothing.ino | 0 .../Communication/ASCIITable/ASCIITable.ino | 0 .../examples}/Communication/Dimmer/Dimmer.ino | 0 .../examples}/Communication/Graph/Graph.ino | 0 .../examples}/Communication/MIDI/Midi.ino | 0 .../PhysicalPixel/PhysicalPixel.ino | 0 .../SerialCallResponse/SerialCallResponse.ino | 0 .../SerialCallResponseASCII.ino | 0 .../SerialPassthrough/SerialPassthrough.ino | 0 .../VirtualColorMixer/VirtualColorMixer.ino | 0 .../examples}/Control/Arrays/Arrays.ino | 0 .../ForLoopIteration/ForLoopIteration.ino | 0 .../IfStatementConditional.ino | 0 .../WhileStatementConditional.ino | 0 .../Control/switchCase/switchCase.ino | 0 .../Control/switchCase2/switchCase2.ino | 0 .../examples}/Digital/Blink/Blink.ino | 0 .../BlinkWithoutDelay/BlinkWithoutDelay.ino | 74 +- .../examples}/Digital/Button/Button.ino | 2 +- .../examples}/Digital/Debounce/Debounce.ino | 0 .../Digital/MapleMorse/MapleMorse.ino | 0 .../StateChangeDetection.ino | 0 .../RowColumnScanning/RowColumnScanning.ino | 0 .../examples}/Display/barGraph/barGraph.ino | 0 .../examples}/Maple/CrudeVGA/CrudeVGA.ino | 0 .../Maple/InteractiveTest/InteractiveTest.ino | 1450 ++++++++--------- .../examples}/Maple/QASlave/QASlave.ino | 132 +- .../Maple/StressSerialUSB/StressSerialUSB.ino | 0 .../Maple/TimerInterrupts/TimerInterrupts.ino | 0 .../MrBrunetteExamples/Blink/Blink.ino | 34 +- .../BlinkNcount/BlinkNcount.ino | 70 +- .../FadingOnboard/FadingOnboard.ino | 0 .../IntegerInput/IntegerInput.ino | 92 +- .../IntegerInput_FloatOutput.ino | 100 +- .../InternalTempSensor/InternalTempSensor.ino | 160 +- .../MrBrunetteExamples/PrimeNos/PrimeNos.ino | 138 +- .../PrimeNos2/PrimeNos2.ino | 82 +- .../PrimeNos3/PrimeNos3.ino | 82 +- .../Print_Binary/Print_Binary.ino | 132 +- .../Print_Float/Print_Float.ino | 168 +- .../Print_HEX/Print_HEX.ino | 122 +- .../SerialReadUntil/SerialReadUntil.ino | 70 +- .../StringEx_Parsing/StringEx_Parsing.ino | Bin .../USB_ASCII/USB_ASCII.ino | 208 +-- .../strtol_DecEquivalents.ino | 82 +- .../examples}/Sensors/Knock/Knock.ino | 104 +- .../AnalogReadPWMWrite/AnalogReadPWMWrite.ino | 0 .../AnalogReadSerial/AnalogReadSerial.ino | 0 .../Stubs/BareMinumum/BareMinumum.ino | 0 .../DigitalReadSerial/DigitalReadSerial.ino | 0 .../DigitalReadWrite/DigitalReadWrite.ino | 0 .../examples}/Stubs/HelloWorld/HelloWorld.ino | 0 .../A_STM32_Examples/examples}/boards.txt | 0 58 files changed, 1651 insertions(+), 1651 deletions(-) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Analog/AnalogInOutSerial/AnalogInOutSerial.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Analog/AnalogInSerial/AnalogInSerial.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Analog/AnalogInput/AnalogInput.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Analog/Calibration/Calibration.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Analog/Fading/Fading.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Analog/Smoothing/Smoothing.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Communication/ASCIITable/ASCIITable.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Communication/Dimmer/Dimmer.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Communication/Graph/Graph.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Communication/MIDI/Midi.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Communication/PhysicalPixel/PhysicalPixel.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Communication/SerialCallResponse/SerialCallResponse.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Communication/SerialPassthrough/SerialPassthrough.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Communication/VirtualColorMixer/VirtualColorMixer.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Control/Arrays/Arrays.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Control/ForLoopIteration/ForLoopIteration.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Control/IfStatementConditional/IfStatementConditional.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Control/WhileStatementConditional/WhileStatementConditional.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Control/switchCase/switchCase.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Control/switchCase2/switchCase2.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Digital/Blink/Blink.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino (96%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Digital/Button/Button.ino (99%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Digital/Debounce/Debounce.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Digital/MapleMorse/MapleMorse.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Digital/StateChangeDetection/StateChangeDetection.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Display/RowColumnScanning/RowColumnScanning.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Display/barGraph/barGraph.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Maple/CrudeVGA/CrudeVGA.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Maple/InteractiveTest/InteractiveTest.ino (96%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Maple/QASlave/QASlave.ino (96%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Maple/StressSerialUSB/StressSerialUSB.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Maple/TimerInterrupts/TimerInterrupts.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/Blink/Blink.ino (97%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/BlinkNcount/BlinkNcount.ino (97%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/FadingOnboard/FadingOnboard.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/IntegerInput/IntegerInput.ino (96%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/IntegerInput_FloatOutput/IntegerInput_FloatOutput.ino (96%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/InternalTempSensor/InternalTempSensor.ino (96%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/PrimeNos/PrimeNos.ino (97%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/PrimeNos2/PrimeNos2.ino (97%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/PrimeNos3/PrimeNos3.ino (97%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/Print_Binary/Print_Binary.ino (95%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/Print_Float/Print_Float.ino (96%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/Print_HEX/Print_HEX.ino (96%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/SerialReadUntil/SerialReadUntil.ino (96%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/StringEx_Parsing/StringEx_Parsing.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/USB_ASCII/USB_ASCII.ino (96%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/MrBrunetteExamples/strtol_DecEquivalents/strtol_DecEquivalents.ino (97%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Sensors/Knock/Knock.ino (97%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Stubs/AnalogReadPWMWrite/AnalogReadPWMWrite.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Stubs/AnalogReadSerial/AnalogReadSerial.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Stubs/BareMinumum/BareMinumum.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Stubs/DigitalReadSerial/DigitalReadSerial.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Stubs/DigitalReadWrite/DigitalReadWrite.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/Stubs/HelloWorld/HelloWorld.ino (100%) rename {examples => STM32F1/libraries/A_STM32_Examples/examples}/boards.txt (100%) diff --git a/examples/Analog/AnalogInOutSerial/AnalogInOutSerial.ino b/STM32F1/libraries/A_STM32_Examples/examples/Analog/AnalogInOutSerial/AnalogInOutSerial.ino similarity index 100% rename from examples/Analog/AnalogInOutSerial/AnalogInOutSerial.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Analog/AnalogInOutSerial/AnalogInOutSerial.ino diff --git a/examples/Analog/AnalogInSerial/AnalogInSerial.ino b/STM32F1/libraries/A_STM32_Examples/examples/Analog/AnalogInSerial/AnalogInSerial.ino similarity index 100% rename from examples/Analog/AnalogInSerial/AnalogInSerial.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Analog/AnalogInSerial/AnalogInSerial.ino diff --git a/examples/Analog/AnalogInput/AnalogInput.ino b/STM32F1/libraries/A_STM32_Examples/examples/Analog/AnalogInput/AnalogInput.ino similarity index 100% rename from examples/Analog/AnalogInput/AnalogInput.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Analog/AnalogInput/AnalogInput.ino diff --git a/examples/Analog/Calibration/Calibration.ino b/STM32F1/libraries/A_STM32_Examples/examples/Analog/Calibration/Calibration.ino similarity index 100% rename from examples/Analog/Calibration/Calibration.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Analog/Calibration/Calibration.ino diff --git a/examples/Analog/Fading/Fading.ino b/STM32F1/libraries/A_STM32_Examples/examples/Analog/Fading/Fading.ino similarity index 100% rename from examples/Analog/Fading/Fading.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Analog/Fading/Fading.ino diff --git a/examples/Analog/Smoothing/Smoothing.ino b/STM32F1/libraries/A_STM32_Examples/examples/Analog/Smoothing/Smoothing.ino similarity index 100% rename from examples/Analog/Smoothing/Smoothing.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Analog/Smoothing/Smoothing.ino diff --git a/examples/Communication/ASCIITable/ASCIITable.ino b/STM32F1/libraries/A_STM32_Examples/examples/Communication/ASCIITable/ASCIITable.ino similarity index 100% rename from examples/Communication/ASCIITable/ASCIITable.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Communication/ASCIITable/ASCIITable.ino diff --git a/examples/Communication/Dimmer/Dimmer.ino b/STM32F1/libraries/A_STM32_Examples/examples/Communication/Dimmer/Dimmer.ino similarity index 100% rename from examples/Communication/Dimmer/Dimmer.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Communication/Dimmer/Dimmer.ino diff --git a/examples/Communication/Graph/Graph.ino b/STM32F1/libraries/A_STM32_Examples/examples/Communication/Graph/Graph.ino similarity index 100% rename from examples/Communication/Graph/Graph.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Communication/Graph/Graph.ino diff --git a/examples/Communication/MIDI/Midi.ino b/STM32F1/libraries/A_STM32_Examples/examples/Communication/MIDI/Midi.ino similarity index 100% rename from examples/Communication/MIDI/Midi.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Communication/MIDI/Midi.ino diff --git a/examples/Communication/PhysicalPixel/PhysicalPixel.ino b/STM32F1/libraries/A_STM32_Examples/examples/Communication/PhysicalPixel/PhysicalPixel.ino similarity index 100% rename from examples/Communication/PhysicalPixel/PhysicalPixel.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Communication/PhysicalPixel/PhysicalPixel.ino diff --git a/examples/Communication/SerialCallResponse/SerialCallResponse.ino b/STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialCallResponse/SerialCallResponse.ino similarity index 100% rename from examples/Communication/SerialCallResponse/SerialCallResponse.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialCallResponse/SerialCallResponse.ino diff --git a/examples/Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino b/STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino similarity index 100% rename from examples/Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino diff --git a/examples/Communication/SerialPassthrough/SerialPassthrough.ino b/STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialPassthrough/SerialPassthrough.ino similarity index 100% rename from examples/Communication/SerialPassthrough/SerialPassthrough.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialPassthrough/SerialPassthrough.ino diff --git a/examples/Communication/VirtualColorMixer/VirtualColorMixer.ino b/STM32F1/libraries/A_STM32_Examples/examples/Communication/VirtualColorMixer/VirtualColorMixer.ino similarity index 100% rename from examples/Communication/VirtualColorMixer/VirtualColorMixer.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Communication/VirtualColorMixer/VirtualColorMixer.ino diff --git a/examples/Control/Arrays/Arrays.ino b/STM32F1/libraries/A_STM32_Examples/examples/Control/Arrays/Arrays.ino similarity index 100% rename from examples/Control/Arrays/Arrays.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Control/Arrays/Arrays.ino diff --git a/examples/Control/ForLoopIteration/ForLoopIteration.ino b/STM32F1/libraries/A_STM32_Examples/examples/Control/ForLoopIteration/ForLoopIteration.ino similarity index 100% rename from examples/Control/ForLoopIteration/ForLoopIteration.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Control/ForLoopIteration/ForLoopIteration.ino diff --git a/examples/Control/IfStatementConditional/IfStatementConditional.ino b/STM32F1/libraries/A_STM32_Examples/examples/Control/IfStatementConditional/IfStatementConditional.ino similarity index 100% rename from examples/Control/IfStatementConditional/IfStatementConditional.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Control/IfStatementConditional/IfStatementConditional.ino diff --git a/examples/Control/WhileStatementConditional/WhileStatementConditional.ino b/STM32F1/libraries/A_STM32_Examples/examples/Control/WhileStatementConditional/WhileStatementConditional.ino similarity index 100% rename from examples/Control/WhileStatementConditional/WhileStatementConditional.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Control/WhileStatementConditional/WhileStatementConditional.ino diff --git a/examples/Control/switchCase/switchCase.ino b/STM32F1/libraries/A_STM32_Examples/examples/Control/switchCase/switchCase.ino similarity index 100% rename from examples/Control/switchCase/switchCase.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Control/switchCase/switchCase.ino diff --git a/examples/Control/switchCase2/switchCase2.ino b/STM32F1/libraries/A_STM32_Examples/examples/Control/switchCase2/switchCase2.ino similarity index 100% rename from examples/Control/switchCase2/switchCase2.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Control/switchCase2/switchCase2.ino diff --git a/examples/Digital/Blink/Blink.ino b/STM32F1/libraries/A_STM32_Examples/examples/Digital/Blink/Blink.ino similarity index 100% rename from examples/Digital/Blink/Blink.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Digital/Blink/Blink.ino diff --git a/examples/Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino b/STM32F1/libraries/A_STM32_Examples/examples/Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino similarity index 96% rename from examples/Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino index 35f7a76..72f4f7c 100644 --- a/examples/Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino @@ -1,37 +1,37 @@ -/* - Blink without delay - - Turns on and off the built-in light emitting diode (LED), without - using the delay() function. This means that other code can run at - the same time without being interrupted by the LED code. - - created 2005 - by David A. Mellis - modified 17 Jun 2009 - by Tom Igoe - modified for Maple 27 May 2011 - by Marti Bolivar -*/ - -// Variables: -int previousMillis = 0; // will store the last time the LED was updated -int interval = 1000; // interval at which to blink (in milliseconds) - -void setup() { - // Set up the built-in LED pin as output: - pinMode(33, OUTPUT); -} - -void loop() { - // Check to see if it's time to blink the LED; that is, if the - // difference between the current time and last time we blinked - // the LED is bigger than the interval at which we want to blink - // the LED. - if (millis() - previousMillis > interval) { - // Save the last time you blinked the LED - previousMillis = millis(); - - // If the LED is off, turn it on, and vice-versa: - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - } -} +/* + Blink without delay + + Turns on and off the built-in light emitting diode (LED), without + using the delay() function. This means that other code can run at + the same time without being interrupted by the LED code. + + created 2005 + by David A. Mellis + modified 17 Jun 2009 + by Tom Igoe + modified for Maple 27 May 2011 + by Marti Bolivar +*/ + +// Variables: +int previousMillis = 0; // will store the last time the LED was updated +int interval = 1000; // interval at which to blink (in milliseconds) + +void setup() { + // Set up the built-in LED pin as output: + pinMode(33, OUTPUT); +} + +void loop() { + // Check to see if it's time to blink the LED; that is, if the + // difference between the current time and last time we blinked + // the LED is bigger than the interval at which we want to blink + // the LED. + if (millis() - previousMillis > interval) { + // Save the last time you blinked the LED + previousMillis = millis(); + + // If the LED is off, turn it on, and vice-versa: + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + } +} diff --git a/examples/Digital/Button/Button.ino b/STM32F1/libraries/A_STM32_Examples/examples/Digital/Button/Button.ino similarity index 99% rename from examples/Digital/Button/Button.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Digital/Button/Button.ino index a27e92b..108aadf 100644 --- a/examples/Digital/Button/Button.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/Digital/Button/Button.ino @@ -33,4 +33,4 @@ void loop() { // If so, turn the LED from on to off, or from off to on: digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off } -} +} diff --git a/examples/Digital/Debounce/Debounce.ino b/STM32F1/libraries/A_STM32_Examples/examples/Digital/Debounce/Debounce.ino similarity index 100% rename from examples/Digital/Debounce/Debounce.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Digital/Debounce/Debounce.ino diff --git a/examples/Digital/MapleMorse/MapleMorse.ino b/STM32F1/libraries/A_STM32_Examples/examples/Digital/MapleMorse/MapleMorse.ino similarity index 100% rename from examples/Digital/MapleMorse/MapleMorse.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Digital/MapleMorse/MapleMorse.ino diff --git a/examples/Digital/StateChangeDetection/StateChangeDetection.ino b/STM32F1/libraries/A_STM32_Examples/examples/Digital/StateChangeDetection/StateChangeDetection.ino similarity index 100% rename from examples/Digital/StateChangeDetection/StateChangeDetection.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Digital/StateChangeDetection/StateChangeDetection.ino diff --git a/examples/Display/RowColumnScanning/RowColumnScanning.ino b/STM32F1/libraries/A_STM32_Examples/examples/Display/RowColumnScanning/RowColumnScanning.ino similarity index 100% rename from examples/Display/RowColumnScanning/RowColumnScanning.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Display/RowColumnScanning/RowColumnScanning.ino diff --git a/examples/Display/barGraph/barGraph.ino b/STM32F1/libraries/A_STM32_Examples/examples/Display/barGraph/barGraph.ino similarity index 100% rename from examples/Display/barGraph/barGraph.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Display/barGraph/barGraph.ino diff --git a/examples/Maple/CrudeVGA/CrudeVGA.ino b/STM32F1/libraries/A_STM32_Examples/examples/Maple/CrudeVGA/CrudeVGA.ino similarity index 100% rename from examples/Maple/CrudeVGA/CrudeVGA.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Maple/CrudeVGA/CrudeVGA.ino diff --git a/examples/Maple/InteractiveTest/InteractiveTest.ino b/STM32F1/libraries/A_STM32_Examples/examples/Maple/InteractiveTest/InteractiveTest.ino similarity index 96% rename from examples/Maple/InteractiveTest/InteractiveTest.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Maple/InteractiveTest/InteractiveTest.ino index 2cc6ffa..26925e1 100644 --- a/examples/Maple/InteractiveTest/InteractiveTest.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/Maple/InteractiveTest/InteractiveTest.ino @@ -1,725 +1,725 @@ -/* - Interactive Test Session for LeafLabs Maple - - Useful for testing Maple features and troubleshooting. - Communicates over Serial. - - This code is released into the public domain. -*/ - -// ASCII escape character -#define ESC ((uint8)27) - -// Default USART baud rate -#define BAUD 9600 - -uint8 gpio_state[BOARD_NR_GPIO_PINS]; - -const char* dummy_data = ("qwertyuiopasdfghjklzxcvbnmmmmmm,./1234567890-=" - "qwertyuiopasdfghjklzxcvbnm,./1234567890"); - -// -- setup() and loop() ------------------------------------------------------ - -void setup() { - Serial.begin(115200); // Ignored by Maple. But needed by boards using hardware serial via a USB to Serial adaptor - // Set up the LED to blink - pinMode(33, OUTPUT); - - // Start up the serial ports - Serial1.begin(BAUD); - Serial2.begin(BAUD); - Serial3.begin(BAUD); - - // Send a message out over Serial interface - Serial.println(" "); - Serial.println(" __ __ _ _"); - Serial.println(" | \\/ | __ _ _ __ | | ___| |"); - Serial.println(" | |\\/| |/ _` | '_ \\| |/ _ \\ |"); - Serial.println(" | | | | (_| | |_) | | __/_|"); - Serial.println(" |_| |_|\\__,_| .__/|_|\\___(_)"); - Serial.println(" |_|"); - Serial.println(" by leaflabs"); - Serial.println(""); - Serial.println(""); - Serial.println("Maple interactive test program (type '?' for help)"); - Serial.println("----------------------------------------------------------"); - Serial.print("> "); - -} - -void loop () { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); - - while (Serial.available()) { - uint8 input = Serial.read(); - Serial.println(input); - - switch(input) { - case '\r': - break; - - case ' ': - Serial.println("spacebar, nice!"); - break; - - case '?': - case 'h': - cmd_print_help(); - break; - - case 'u': - Serial.println("Hello World!"); - break; - - case 'w': - Serial1.println("Hello World!"); - Serial2.println("Hello World!"); - Serial3.println("Hello World!"); - break; - - case 'm': - cmd_serial1_serial3(); - break; - - case '.': - while (!Serial.available()) { - Serial1.print("."); - Serial2.print("."); - Serial3.print("."); - Serial.print("."); - } - break; - - case 'n': - cmd_adc_stats(); - break; - - case 'N': - cmd_stressful_adc_stats(); - break; - - case 'e': - cmd_everything(); - break; - - case 'W': - while (!Serial.available()) { - Serial1.print(dummy_data); - Serial2.print(dummy_data); - Serial3.print(dummy_data); - } - break; - - case 'U': - Serial.println("Dumping data to USB. Press any key."); - while (!Serial.available()) { - Serial.print(dummy_data); - } - break; - - case 'g': - cmd_sequential_gpio_writes(); - break; - - case 'G': - cmd_gpio_toggling(); - break; - - case 'f': - Serial.println("Wiggling D4 as fast as possible in bursts. " - "Press any key."); - pinMode(4, OUTPUT); - while (!Serial.available()) { - fast_gpio(4); - delay(1); - } - break; - - case 'p': - cmd_sequential_pwm_test(); - break; - - case '_': - Serial.println("Delaying for 5 seconds..."); - delay(5000); - break; - - // Be sure to update cmd_print_help() if you implement these: - - case 't': // TODO - Serial.println("Unimplemented."); - break; - - case 'T': // TODO - Serial.println("Unimplemented."); - break; - - case 's': - cmd_servo_sweep(); - break; - - case 'd': - Serial.println("Pulling down D4, D22. Press any key."); - pinMode(22, INPUT_PULLDOWN); - pinMode(4, INPUT_PULLDOWN); - while (!Serial.available()) { - continue; - } - Serial.println("Pulling up D4, D22. Press any key."); - pinMode(22, INPUT_PULLUP); - pinMode(4, INPUT_PULLUP); - while (!Serial.available()) { - continue; - } - Serial.read(); - pinMode(4, OUTPUT); - break; - - // Be sure to update cmd_print_help() if you implement these: - - case 'i': // TODO - Serial.println("Unimplemented."); - break; - - case 'I': // TODO - Serial.println("Unimplemented."); - break; - - case 'r': - cmd_gpio_monitoring(); - break; - - case 'a': - cmd_sequential_adc_reads(); - break; - - case 'b': - cmd_board_info(); - break; - - case '+': - cmd_gpio_qa(); - break; - - default: // ------------------------------- - Serial.print("Unexpected: "); - Serial.print(input); - Serial.println(", press h for help."); - } - - Serial.print("> "); - } -} - -// -- Commands ---------------------------------------------------------------- - -void cmd_print_help(void) { - Serial.println(""); - Serial.println("Command Listing"); - Serial.println("\t?: print this menu"); - Serial.println("\th: print this menu"); - Serial.println("\tw: print Hello World on all 3 USARTS"); - Serial.println("\tn: measure noise and do statistics"); - Serial.println("\tN: measure noise and do statistics with background stuff"); - Serial.println("\ta: show realtime ADC info"); - Serial.println("\t.: echo '.' until new input"); - Serial.println("\tu: print Hello World on USB"); - Serial.println("\t_: do as little as possible for a couple seconds (delay)"); - Serial.println("\tp: test all PWM channels sequentially"); - Serial.println("\tW: dump data as fast as possible on all 3 USARTS"); - Serial.println("\tU: dump data as fast as possible on USB"); - Serial.println("\tg: toggle GPIOs sequentially"); - Serial.println("\tG: toggle GPIOs at the same time"); - Serial.println("\tf: toggle pin 4 as fast as possible in bursts"); - Serial.println("\tr: monitor and print GPIO status changes"); - Serial.println("\ts: output a sweeping servo PWM on all PWM channels"); - Serial.println("\tm: output data on USART1 and USART3 with various rates"); - Serial.println("\tb: print information about the board."); - Serial.println("\t+: test shield mode (for quality assurance testing)"); - - Serial.println("Unimplemented:"); - Serial.println("\te: do everything all at once until new input"); - Serial.println("\tt: output a 1khz squarewave on all GPIOs"); - Serial.println("\tT: output a 1hz squarewave on all GPIOs"); - Serial.println("\ti: print out a bunch of info about system state"); - Serial.println("\tI: print out status of all headers"); -} - -void cmd_adc_stats(void) { - Serial.println("Taking ADC noise stats."); - digitalWrite(33, 0); - for (uint32 i = 0; i < BOARD_NR_ADC_PINS; i++) { - delay(5); - measure_adc_noise(boardADCPins[i]); - } -} - -void cmd_stressful_adc_stats(void) { - Serial.println("Taking ADC noise stats under duress."); - - for (uint32 i = 0; i < BOARD_NR_ADC_PINS; i++) { - for (uint32 j = 0; j < BOARD_NR_PWM_PINS; j++) { - if (boardADCPins[i] != boardPWMPins[j]) { - pinMode(boardPWMPins[j], PWM); - pwmWrite(boardPWMPins[j], 1000 + i); - } - } - - Serial1.print(dummy_data); - - measure_adc_noise(boardADCPins[i]); - - for (uint32 j = 0; j < BOARD_NR_PWM_PINS; j++) { - if (boardADCPins[i] != boardPWMPins[j]) { - pinMode(boardPWMPins[j], OUTPUT); - digitalWrite(boardPWMPins[j], LOW); - } - } - } -} - -void cmd_everything(void) { // TODO - // Be sure to update cmd_print_help() if you implement this. - - // print to usart - // print to usb - // toggle gpios - // enable pwm - Serial.println("Unimplemented."); -} - -void cmd_serial1_serial3(void) { - HardwareSerial *serial_1_and_3[] = {&Serial1, &Serial3}; - - Serial.println("Testing 57600 baud on USART1 and USART3. " - "Press any key to stop."); - usart_baud_test(serial_1_and_3, 2, 57600); - Serial.read(); - - Serial.println("Testing 115200 baud on USART1 and USART3. " - "Press any key to stop."); - usart_baud_test(serial_1_and_3, 2, 115200); - Serial.read(); - - Serial.println("Testing 9600 baud on USART1 and USART3. " - "Press any key to stop."); - usart_baud_test(serial_1_and_3, 2, 9600); - Serial.read(); - - Serial.println("Resetting USART1 and USART3..."); - Serial1.begin(BAUD); - Serial3.begin(BAUD); -} - -void cmd_gpio_monitoring(void) { - Serial.println("Monitoring pin state changes. Press any key to stop."); - - for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { - if (boardUsesPin(i)) - continue; - pinMode(i, INPUT_PULLDOWN); - gpio_state[i] = (uint8)digitalRead(i); - } - - while (!Serial.available()) { - for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { - if (boardUsesPin(i)) - continue; - - uint8 current_state = (uint8)digitalRead(i); - if (current_state != gpio_state[i]) { - Serial.print("State change on pin "); - Serial.print(i, DEC); - if (current_state) { - Serial.println(":\tHIGH"); - } else { - Serial.println(":\tLOW"); - } - gpio_state[i] = current_state; - } - } - } - - for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { - if (boardUsesPin(i)) - continue; - pinMode(i, OUTPUT); - } -} - -void cmd_sequential_adc_reads(void) { - Serial.print("Sequentially reading most ADC ports."); - Serial.println("Press any key for next port, or ESC to stop."); - - for (uint32 i = 0; i < BOARD_NR_ADC_PINS; i++) { - if (boardUsesPin(i)) - continue; - - Serial.print("Reading pin "); - Serial.print(boardADCPins[i], DEC); - Serial.println("..."); - pinMode(boardADCPins[i], INPUT_ANALOG); - while (!Serial.available()) { - int sample = analogRead(boardADCPins[i]); - Serial.print(boardADCPins[i], DEC); - Serial.print("\t"); - Serial.print(sample, DEC); - Serial.print("\t"); - Serial.print("|"); - for (int j = 0; j < 4096; j += 100) { - if (sample >= j) { - Serial.print("#"); - } else { - Serial.print(" "); - } - } - Serial.print("| "); - for (int j = 0; j < 12; j++) { - if (sample & (1 << (11 - j))) { - Serial.print("1"); - } else { - Serial.print("0"); - } - } - Serial.println(""); - } - pinMode(boardADCPins[i], OUTPUT); - digitalWrite(boardADCPins[i], 0); - if (Serial.read() == ESC) - break; - } -} - -bool test_single_pin_is_high(int high_pin, const char* err_msg) { - bool ok = true; - for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { - if (boardUsesPin(i)) continue; - - if (digitalRead(i) == HIGH && i != high_pin) { - Serial.println(); - Serial.print("\t*** FAILURE! pin "); - Serial.print(i, DEC); - Serial.print(' '); - Serial.println(err_msg); - ok = false; - } - } - return ok; -} - -bool wait_for_low_transition(uint8 pin) { - uint32 start = millis(); - while (millis() - start < 2000) { - if (digitalRead(pin) == LOW) { - return true; - } - } - return false; -} - -void cmd_gpio_qa(void) { - bool all_pins_ok = true; - const int not_a_pin = -1; - Serial.println("Doing QA testing for unused GPIO pins."); - - for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { - if (boardUsesPin(i)) continue; - - pinMode(i, INPUT); - } - - Serial.println("Waiting to start."); - ASSERT(!boardUsesPin(0)); - while (digitalRead(0) == LOW) continue; - - for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { - if (boardUsesPin(i)) { - Serial.print("Skipping pin "); - Serial.println(i, DEC); - continue; - } - bool pin_ok = true; - Serial.print("Checking pin "); - Serial.print(i, DEC); - while (digitalRead(i) == LOW) continue; - - pin_ok = pin_ok && test_single_pin_is_high(i, "is also HIGH"); - - if (!wait_for_low_transition(i)) { - Serial.println("Transition to low timed out; something is " - "very wrong. Aborting test."); - return; - } - - pin_ok = pin_ok && test_single_pin_is_high(not_a_pin, "is still HIGH"); - - if (pin_ok) { - Serial.println(": ok"); - } - - all_pins_ok = all_pins_ok && pin_ok; - } - - if (all_pins_ok) { - Serial.println("Finished; test passes."); - } else { - Serial.println("**** TEST FAILS *****"); - } - - for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { - if (boardUsesPin(i)) continue; - - pinMode(i, OUTPUT); - digitalWrite(i, LOW); - gpio_state[i] = 0; - } -} - -void cmd_sequential_gpio_writes(void) { - Serial.println("Sequentially toggling all unused pins. " - "Press any key for next pin, ESC to stop."); - - for (uint32 i = 0; i < BOARD_NR_GPIO_PINS; i++) { - if (boardUsesPin(i)) - continue; - - Serial.print("Toggling pin "); - Serial.print((int)i, DEC); - Serial.println("..."); - - pinMode(i, OUTPUT); - do { - gpio_toggle_bit(PIN_MAP[i].gpio_device, PIN_MAP[i].gpio_bit); - } while (!Serial.available()); - - digitalWrite(i, LOW); - if (Serial.read() == ESC) - break; - } -} - -void cmd_gpio_toggling(void) { - Serial.println("Toggling all unused pins simultaneously. " - "Press any key to stop."); - - for (uint32 i = 0; i < BOARD_NR_GPIO_PINS; i++) { - if (boardUsesPin(i)) - continue; - pinMode(i, OUTPUT); - } - - while (!Serial.available()) { - for (uint32 i = 0; i < BOARD_NR_GPIO_PINS; i++) { - if (boardUsesPin(i)) - continue; - gpio_toggle_bit(PIN_MAP[i].gpio_device, PIN_MAP[i].gpio_bit); - } - } - - for (uint32 i = 0; i < BOARD_NR_GPIO_PINS; i++) { - if (boardUsesPin(i)) - continue; - digitalWrite(i, LOW); - } -} - -void cmd_sequential_pwm_test(void) { - Serial.println("Sequentially testing PWM on all unused pins. " - "Press any key for next pin, ESC to stop."); - - for (uint32 i = 0; i < BOARD_NR_PWM_PINS; i++) { - if (boardUsesPin(i)) - continue; - - Serial.print("PWM out on header D"); - Serial.print(boardPWMPins[i], DEC); - Serial.println("..."); - pinMode(boardPWMPins[i], PWM); - pwmWrite(boardPWMPins[i], 16000); - - while (!Serial.available()) { - delay(10); - } - - pinMode(boardPWMPins[i], OUTPUT); - digitalWrite(boardPWMPins[i], 0); - if (Serial.read() == ESC) - break; - } -} - -void cmd_servo_sweep(void) { - Serial.println("Testing all PWM headers with a servo sweep. " - "Press any key to stop."); - Serial.println(); - - disable_usarts(); - init_all_timers(21); - - for (uint32 i = 0; i < BOARD_NR_PWM_PINS; i++) { - if (boardUsesPin(i)) - continue; - pinMode(boardPWMPins[i], PWM); - pwmWrite(boardPWMPins[i], 4000); - } - - // 1.25ms = 4096counts = 0deg - // 1.50ms = 4915counts = 90deg - // 1.75ms = 5734counts = 180deg - int rate = 4096; - while (!Serial.available()) { - rate += 20; - if (rate > 5734) - rate = 4096; - for (uint32 i = 0; i < BOARD_NR_PWM_PINS; i++) { - if (boardUsesPin(i)) - continue; - pwmWrite(boardPWMPins[i], rate); - } - delay(20); - } - - for (uint32 i = 0; i < BOARD_NR_PWM_PINS; i++) { - if (boardUsesPin(i)) - continue; - pinMode(boardPWMPins[i], OUTPUT); - } - init_all_timers(1); - enable_usarts(); -} - -void cmd_board_info(void) { // TODO print more information - Serial.println("Board information"); - Serial.println("================="); - - Serial.print("* Clock speed (cycles/us): "); - Serial.println(CYCLES_PER_MICROSECOND); - - Serial.print("* 33: "); - Serial.println(33); - - Serial.print("* BOARD_BUTTON_PIN: "); - Serial.println(BOARD_BUTTON_PIN); - - Serial.print("* GPIO information (BOARD_NR_GPIO_PINS = "); - Serial.print(BOARD_NR_GPIO_PINS); - Serial.println("):"); - print_board_array("ADC pins", boardADCPins, BOARD_NR_ADC_PINS); - print_board_array("PWM pins", boardPWMPins, BOARD_NR_PWM_PINS); - print_board_array("Used pins", boardUsedPins, BOARD_NR_USED_PINS); -} - -// -- Helper functions -------------------------------------------------------- - -void measure_adc_noise(uint8 pin) { - uint16 data[100]; - float mean = 0; - float delta = 0; - float M2 = 0; - pinMode(pin, INPUT_ANALOG); - - // Variance algorithm from Welford, via Knuth, by way of Wikipedia: - // http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#On-line_algorithm - for (int i = 0; i < 100; i++) { - data[i] = analogRead(pin); - delta = data[i] - mean; - mean = mean + delta / (i + 1); - M2 = M2 + delta * (data[i] - mean); - } - - Serial.print("header: D"); - Serial.print(pin, DEC); - Serial.print("\tn: "); - Serial.print(100, DEC); - Serial.print("\tmean: "); - Serial.print(mean); - Serial.print("\tvariance: "); - Serial.println(M2 / 99.0); - pinMode(pin, OUTPUT); -} - -void fast_gpio(int maple_pin) { - gpio_dev *dev = PIN_MAP[maple_pin].gpio_device; - uint32 bit = PIN_MAP[maple_pin].gpio_bit; - - gpio_write_bit(dev, bit, 1); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); - gpio_toggle_bit(dev, bit); -} - -void usart_baud_test(HardwareSerial **serials, int n, unsigned baud) { - for (int i = 0; i < n; i++) { - serials[i]->begin(baud); - } - while (!Serial.available()) { - for (int i = 0; i < n; i++) { - serials[i]->println(dummy_data); - if (serials[i]->available()) { - serials[i]->println(serials[i]->read()); - delay(1000); - } - } - } -} - -static uint16 init_all_timers_prescale = 0; - -static void set_prescale(timer_dev *dev) { - timer_set_prescaler(dev, init_all_timers_prescale); -} - -void init_all_timers(uint16 prescale) { - init_all_timers_prescale = prescale; - timer_foreach(set_prescale); -} - -void enable_usarts(void) { - // FIXME generalize after USART refactor - Serial1.begin(BAUD); - Serial2.begin(BAUD); - Serial3.begin(BAUD); -} - -void disable_usarts(void) { - // FIXME generalize after USART refactor - Serial1.end(); - Serial2.end(); - Serial3.end(); -} - -void print_board_array(const char* msg, const uint8 arr[], int len) { - Serial.print("\t"); - Serial.print(msg); - Serial.print(" ("); - Serial.print(len); - Serial.print("): "); - for (int i = 0; i < len; i++) { - Serial.print(arr[i], DEC); - if (i < len - 1) Serial.print(", "); - } - Serial.println(); -} +/* + Interactive Test Session for LeafLabs Maple + + Useful for testing Maple features and troubleshooting. + Communicates over Serial. + + This code is released into the public domain. +*/ + +// ASCII escape character +#define ESC ((uint8)27) + +// Default USART baud rate +#define BAUD 9600 + +uint8 gpio_state[BOARD_NR_GPIO_PINS]; + +const char* dummy_data = ("qwertyuiopasdfghjklzxcvbnmmmmmm,./1234567890-=" + "qwertyuiopasdfghjklzxcvbnm,./1234567890"); + +// -- setup() and loop() ------------------------------------------------------ + +void setup() { + Serial.begin(115200); // Ignored by Maple. But needed by boards using hardware serial via a USB to Serial adaptor + // Set up the LED to blink + pinMode(33, OUTPUT); + + // Start up the serial ports + Serial1.begin(BAUD); + Serial2.begin(BAUD); + Serial3.begin(BAUD); + + // Send a message out over Serial interface + Serial.println(" "); + Serial.println(" __ __ _ _"); + Serial.println(" | \\/ | __ _ _ __ | | ___| |"); + Serial.println(" | |\\/| |/ _` | '_ \\| |/ _ \\ |"); + Serial.println(" | | | | (_| | |_) | | __/_|"); + Serial.println(" |_| |_|\\__,_| .__/|_|\\___(_)"); + Serial.println(" |_|"); + Serial.println(" by leaflabs"); + Serial.println(""); + Serial.println(""); + Serial.println("Maple interactive test program (type '?' for help)"); + Serial.println("----------------------------------------------------------"); + Serial.print("> "); + +} + +void loop () { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); + + while (Serial.available()) { + uint8 input = Serial.read(); + Serial.println(input); + + switch(input) { + case '\r': + break; + + case ' ': + Serial.println("spacebar, nice!"); + break; + + case '?': + case 'h': + cmd_print_help(); + break; + + case 'u': + Serial.println("Hello World!"); + break; + + case 'w': + Serial1.println("Hello World!"); + Serial2.println("Hello World!"); + Serial3.println("Hello World!"); + break; + + case 'm': + cmd_serial1_serial3(); + break; + + case '.': + while (!Serial.available()) { + Serial1.print("."); + Serial2.print("."); + Serial3.print("."); + Serial.print("."); + } + break; + + case 'n': + cmd_adc_stats(); + break; + + case 'N': + cmd_stressful_adc_stats(); + break; + + case 'e': + cmd_everything(); + break; + + case 'W': + while (!Serial.available()) { + Serial1.print(dummy_data); + Serial2.print(dummy_data); + Serial3.print(dummy_data); + } + break; + + case 'U': + Serial.println("Dumping data to USB. Press any key."); + while (!Serial.available()) { + Serial.print(dummy_data); + } + break; + + case 'g': + cmd_sequential_gpio_writes(); + break; + + case 'G': + cmd_gpio_toggling(); + break; + + case 'f': + Serial.println("Wiggling D4 as fast as possible in bursts. " + "Press any key."); + pinMode(4, OUTPUT); + while (!Serial.available()) { + fast_gpio(4); + delay(1); + } + break; + + case 'p': + cmd_sequential_pwm_test(); + break; + + case '_': + Serial.println("Delaying for 5 seconds..."); + delay(5000); + break; + + // Be sure to update cmd_print_help() if you implement these: + + case 't': // TODO + Serial.println("Unimplemented."); + break; + + case 'T': // TODO + Serial.println("Unimplemented."); + break; + + case 's': + cmd_servo_sweep(); + break; + + case 'd': + Serial.println("Pulling down D4, D22. Press any key."); + pinMode(22, INPUT_PULLDOWN); + pinMode(4, INPUT_PULLDOWN); + while (!Serial.available()) { + continue; + } + Serial.println("Pulling up D4, D22. Press any key."); + pinMode(22, INPUT_PULLUP); + pinMode(4, INPUT_PULLUP); + while (!Serial.available()) { + continue; + } + Serial.read(); + pinMode(4, OUTPUT); + break; + + // Be sure to update cmd_print_help() if you implement these: + + case 'i': // TODO + Serial.println("Unimplemented."); + break; + + case 'I': // TODO + Serial.println("Unimplemented."); + break; + + case 'r': + cmd_gpio_monitoring(); + break; + + case 'a': + cmd_sequential_adc_reads(); + break; + + case 'b': + cmd_board_info(); + break; + + case '+': + cmd_gpio_qa(); + break; + + default: // ------------------------------- + Serial.print("Unexpected: "); + Serial.print(input); + Serial.println(", press h for help."); + } + + Serial.print("> "); + } +} + +// -- Commands ---------------------------------------------------------------- + +void cmd_print_help(void) { + Serial.println(""); + Serial.println("Command Listing"); + Serial.println("\t?: print this menu"); + Serial.println("\th: print this menu"); + Serial.println("\tw: print Hello World on all 3 USARTS"); + Serial.println("\tn: measure noise and do statistics"); + Serial.println("\tN: measure noise and do statistics with background stuff"); + Serial.println("\ta: show realtime ADC info"); + Serial.println("\t.: echo '.' until new input"); + Serial.println("\tu: print Hello World on USB"); + Serial.println("\t_: do as little as possible for a couple seconds (delay)"); + Serial.println("\tp: test all PWM channels sequentially"); + Serial.println("\tW: dump data as fast as possible on all 3 USARTS"); + Serial.println("\tU: dump data as fast as possible on USB"); + Serial.println("\tg: toggle GPIOs sequentially"); + Serial.println("\tG: toggle GPIOs at the same time"); + Serial.println("\tf: toggle pin 4 as fast as possible in bursts"); + Serial.println("\tr: monitor and print GPIO status changes"); + Serial.println("\ts: output a sweeping servo PWM on all PWM channels"); + Serial.println("\tm: output data on USART1 and USART3 with various rates"); + Serial.println("\tb: print information about the board."); + Serial.println("\t+: test shield mode (for quality assurance testing)"); + + Serial.println("Unimplemented:"); + Serial.println("\te: do everything all at once until new input"); + Serial.println("\tt: output a 1khz squarewave on all GPIOs"); + Serial.println("\tT: output a 1hz squarewave on all GPIOs"); + Serial.println("\ti: print out a bunch of info about system state"); + Serial.println("\tI: print out status of all headers"); +} + +void cmd_adc_stats(void) { + Serial.println("Taking ADC noise stats."); + digitalWrite(33, 0); + for (uint32 i = 0; i < BOARD_NR_ADC_PINS; i++) { + delay(5); + measure_adc_noise(boardADCPins[i]); + } +} + +void cmd_stressful_adc_stats(void) { + Serial.println("Taking ADC noise stats under duress."); + + for (uint32 i = 0; i < BOARD_NR_ADC_PINS; i++) { + for (uint32 j = 0; j < BOARD_NR_PWM_PINS; j++) { + if (boardADCPins[i] != boardPWMPins[j]) { + pinMode(boardPWMPins[j], PWM); + pwmWrite(boardPWMPins[j], 1000 + i); + } + } + + Serial1.print(dummy_data); + + measure_adc_noise(boardADCPins[i]); + + for (uint32 j = 0; j < BOARD_NR_PWM_PINS; j++) { + if (boardADCPins[i] != boardPWMPins[j]) { + pinMode(boardPWMPins[j], OUTPUT); + digitalWrite(boardPWMPins[j], LOW); + } + } + } +} + +void cmd_everything(void) { // TODO + // Be sure to update cmd_print_help() if you implement this. + + // print to usart + // print to usb + // toggle gpios + // enable pwm + Serial.println("Unimplemented."); +} + +void cmd_serial1_serial3(void) { + HardwareSerial *serial_1_and_3[] = {&Serial1, &Serial3}; + + Serial.println("Testing 57600 baud on USART1 and USART3. " + "Press any key to stop."); + usart_baud_test(serial_1_and_3, 2, 57600); + Serial.read(); + + Serial.println("Testing 115200 baud on USART1 and USART3. " + "Press any key to stop."); + usart_baud_test(serial_1_and_3, 2, 115200); + Serial.read(); + + Serial.println("Testing 9600 baud on USART1 and USART3. " + "Press any key to stop."); + usart_baud_test(serial_1_and_3, 2, 9600); + Serial.read(); + + Serial.println("Resetting USART1 and USART3..."); + Serial1.begin(BAUD); + Serial3.begin(BAUD); +} + +void cmd_gpio_monitoring(void) { + Serial.println("Monitoring pin state changes. Press any key to stop."); + + for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { + if (boardUsesPin(i)) + continue; + pinMode(i, INPUT_PULLDOWN); + gpio_state[i] = (uint8)digitalRead(i); + } + + while (!Serial.available()) { + for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { + if (boardUsesPin(i)) + continue; + + uint8 current_state = (uint8)digitalRead(i); + if (current_state != gpio_state[i]) { + Serial.print("State change on pin "); + Serial.print(i, DEC); + if (current_state) { + Serial.println(":\tHIGH"); + } else { + Serial.println(":\tLOW"); + } + gpio_state[i] = current_state; + } + } + } + + for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { + if (boardUsesPin(i)) + continue; + pinMode(i, OUTPUT); + } +} + +void cmd_sequential_adc_reads(void) { + Serial.print("Sequentially reading most ADC ports."); + Serial.println("Press any key for next port, or ESC to stop."); + + for (uint32 i = 0; i < BOARD_NR_ADC_PINS; i++) { + if (boardUsesPin(i)) + continue; + + Serial.print("Reading pin "); + Serial.print(boardADCPins[i], DEC); + Serial.println("..."); + pinMode(boardADCPins[i], INPUT_ANALOG); + while (!Serial.available()) { + int sample = analogRead(boardADCPins[i]); + Serial.print(boardADCPins[i], DEC); + Serial.print("\t"); + Serial.print(sample, DEC); + Serial.print("\t"); + Serial.print("|"); + for (int j = 0; j < 4096; j += 100) { + if (sample >= j) { + Serial.print("#"); + } else { + Serial.print(" "); + } + } + Serial.print("| "); + for (int j = 0; j < 12; j++) { + if (sample & (1 << (11 - j))) { + Serial.print("1"); + } else { + Serial.print("0"); + } + } + Serial.println(""); + } + pinMode(boardADCPins[i], OUTPUT); + digitalWrite(boardADCPins[i], 0); + if (Serial.read() == ESC) + break; + } +} + +bool test_single_pin_is_high(int high_pin, const char* err_msg) { + bool ok = true; + for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { + if (boardUsesPin(i)) continue; + + if (digitalRead(i) == HIGH && i != high_pin) { + Serial.println(); + Serial.print("\t*** FAILURE! pin "); + Serial.print(i, DEC); + Serial.print(' '); + Serial.println(err_msg); + ok = false; + } + } + return ok; +} + +bool wait_for_low_transition(uint8 pin) { + uint32 start = millis(); + while (millis() - start < 2000) { + if (digitalRead(pin) == LOW) { + return true; + } + } + return false; +} + +void cmd_gpio_qa(void) { + bool all_pins_ok = true; + const int not_a_pin = -1; + Serial.println("Doing QA testing for unused GPIO pins."); + + for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { + if (boardUsesPin(i)) continue; + + pinMode(i, INPUT); + } + + Serial.println("Waiting to start."); + ASSERT(!boardUsesPin(0)); + while (digitalRead(0) == LOW) continue; + + for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { + if (boardUsesPin(i)) { + Serial.print("Skipping pin "); + Serial.println(i, DEC); + continue; + } + bool pin_ok = true; + Serial.print("Checking pin "); + Serial.print(i, DEC); + while (digitalRead(i) == LOW) continue; + + pin_ok = pin_ok && test_single_pin_is_high(i, "is also HIGH"); + + if (!wait_for_low_transition(i)) { + Serial.println("Transition to low timed out; something is " + "very wrong. Aborting test."); + return; + } + + pin_ok = pin_ok && test_single_pin_is_high(not_a_pin, "is still HIGH"); + + if (pin_ok) { + Serial.println(": ok"); + } + + all_pins_ok = all_pins_ok && pin_ok; + } + + if (all_pins_ok) { + Serial.println("Finished; test passes."); + } else { + Serial.println("**** TEST FAILS *****"); + } + + for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { + if (boardUsesPin(i)) continue; + + pinMode(i, OUTPUT); + digitalWrite(i, LOW); + gpio_state[i] = 0; + } +} + +void cmd_sequential_gpio_writes(void) { + Serial.println("Sequentially toggling all unused pins. " + "Press any key for next pin, ESC to stop."); + + for (uint32 i = 0; i < BOARD_NR_GPIO_PINS; i++) { + if (boardUsesPin(i)) + continue; + + Serial.print("Toggling pin "); + Serial.print((int)i, DEC); + Serial.println("..."); + + pinMode(i, OUTPUT); + do { + gpio_toggle_bit(PIN_MAP[i].gpio_device, PIN_MAP[i].gpio_bit); + } while (!Serial.available()); + + digitalWrite(i, LOW); + if (Serial.read() == ESC) + break; + } +} + +void cmd_gpio_toggling(void) { + Serial.println("Toggling all unused pins simultaneously. " + "Press any key to stop."); + + for (uint32 i = 0; i < BOARD_NR_GPIO_PINS; i++) { + if (boardUsesPin(i)) + continue; + pinMode(i, OUTPUT); + } + + while (!Serial.available()) { + for (uint32 i = 0; i < BOARD_NR_GPIO_PINS; i++) { + if (boardUsesPin(i)) + continue; + gpio_toggle_bit(PIN_MAP[i].gpio_device, PIN_MAP[i].gpio_bit); + } + } + + for (uint32 i = 0; i < BOARD_NR_GPIO_PINS; i++) { + if (boardUsesPin(i)) + continue; + digitalWrite(i, LOW); + } +} + +void cmd_sequential_pwm_test(void) { + Serial.println("Sequentially testing PWM on all unused pins. " + "Press any key for next pin, ESC to stop."); + + for (uint32 i = 0; i < BOARD_NR_PWM_PINS; i++) { + if (boardUsesPin(i)) + continue; + + Serial.print("PWM out on header D"); + Serial.print(boardPWMPins[i], DEC); + Serial.println("..."); + pinMode(boardPWMPins[i], PWM); + pwmWrite(boardPWMPins[i], 16000); + + while (!Serial.available()) { + delay(10); + } + + pinMode(boardPWMPins[i], OUTPUT); + digitalWrite(boardPWMPins[i], 0); + if (Serial.read() == ESC) + break; + } +} + +void cmd_servo_sweep(void) { + Serial.println("Testing all PWM headers with a servo sweep. " + "Press any key to stop."); + Serial.println(); + + disable_usarts(); + init_all_timers(21); + + for (uint32 i = 0; i < BOARD_NR_PWM_PINS; i++) { + if (boardUsesPin(i)) + continue; + pinMode(boardPWMPins[i], PWM); + pwmWrite(boardPWMPins[i], 4000); + } + + // 1.25ms = 4096counts = 0deg + // 1.50ms = 4915counts = 90deg + // 1.75ms = 5734counts = 180deg + int rate = 4096; + while (!Serial.available()) { + rate += 20; + if (rate > 5734) + rate = 4096; + for (uint32 i = 0; i < BOARD_NR_PWM_PINS; i++) { + if (boardUsesPin(i)) + continue; + pwmWrite(boardPWMPins[i], rate); + } + delay(20); + } + + for (uint32 i = 0; i < BOARD_NR_PWM_PINS; i++) { + if (boardUsesPin(i)) + continue; + pinMode(boardPWMPins[i], OUTPUT); + } + init_all_timers(1); + enable_usarts(); +} + +void cmd_board_info(void) { // TODO print more information + Serial.println("Board information"); + Serial.println("================="); + + Serial.print("* Clock speed (cycles/us): "); + Serial.println(CYCLES_PER_MICROSECOND); + + Serial.print("* 33: "); + Serial.println(33); + + Serial.print("* BOARD_BUTTON_PIN: "); + Serial.println(BOARD_BUTTON_PIN); + + Serial.print("* GPIO information (BOARD_NR_GPIO_PINS = "); + Serial.print(BOARD_NR_GPIO_PINS); + Serial.println("):"); + print_board_array("ADC pins", boardADCPins, BOARD_NR_ADC_PINS); + print_board_array("PWM pins", boardPWMPins, BOARD_NR_PWM_PINS); + print_board_array("Used pins", boardUsedPins, BOARD_NR_USED_PINS); +} + +// -- Helper functions -------------------------------------------------------- + +void measure_adc_noise(uint8 pin) { + uint16 data[100]; + float mean = 0; + float delta = 0; + float M2 = 0; + pinMode(pin, INPUT_ANALOG); + + // Variance algorithm from Welford, via Knuth, by way of Wikipedia: + // http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#On-line_algorithm + for (int i = 0; i < 100; i++) { + data[i] = analogRead(pin); + delta = data[i] - mean; + mean = mean + delta / (i + 1); + M2 = M2 + delta * (data[i] - mean); + } + + Serial.print("header: D"); + Serial.print(pin, DEC); + Serial.print("\tn: "); + Serial.print(100, DEC); + Serial.print("\tmean: "); + Serial.print(mean); + Serial.print("\tvariance: "); + Serial.println(M2 / 99.0); + pinMode(pin, OUTPUT); +} + +void fast_gpio(int maple_pin) { + gpio_dev *dev = PIN_MAP[maple_pin].gpio_device; + uint32 bit = PIN_MAP[maple_pin].gpio_bit; + + gpio_write_bit(dev, bit, 1); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); + gpio_toggle_bit(dev, bit); +} + +void usart_baud_test(HardwareSerial **serials, int n, unsigned baud) { + for (int i = 0; i < n; i++) { + serials[i]->begin(baud); + } + while (!Serial.available()) { + for (int i = 0; i < n; i++) { + serials[i]->println(dummy_data); + if (serials[i]->available()) { + serials[i]->println(serials[i]->read()); + delay(1000); + } + } + } +} + +static uint16 init_all_timers_prescale = 0; + +static void set_prescale(timer_dev *dev) { + timer_set_prescaler(dev, init_all_timers_prescale); +} + +void init_all_timers(uint16 prescale) { + init_all_timers_prescale = prescale; + timer_foreach(set_prescale); +} + +void enable_usarts(void) { + // FIXME generalize after USART refactor + Serial1.begin(BAUD); + Serial2.begin(BAUD); + Serial3.begin(BAUD); +} + +void disable_usarts(void) { + // FIXME generalize after USART refactor + Serial1.end(); + Serial2.end(); + Serial3.end(); +} + +void print_board_array(const char* msg, const uint8 arr[], int len) { + Serial.print("\t"); + Serial.print(msg); + Serial.print(" ("); + Serial.print(len); + Serial.print("): "); + for (int i = 0; i < len; i++) { + Serial.print(arr[i], DEC); + if (i < len - 1) Serial.print(", "); + } + Serial.println(); +} diff --git a/examples/Maple/QASlave/QASlave.ino b/STM32F1/libraries/A_STM32_Examples/examples/Maple/QASlave/QASlave.ino similarity index 96% rename from examples/Maple/QASlave/QASlave.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Maple/QASlave/QASlave.ino index b09c7de..cb1ef44 100644 --- a/examples/Maple/QASlave/QASlave.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/Maple/QASlave/QASlave.ino @@ -1,66 +1,66 @@ -/* - Slave mode for Quality Assurance test - - Used as follows: - - 1) Connect all non-used pins on the test board to their - corresponding pins on a board running InteractiveTest. - - 2) Connect a serial monitor to the InteractiveTest board and - enter "+" (a plus sign, without the quotes). - - This program pulses each unused pin in order, starting from pin 0. - The InteractiveTest "+" command detects these pulses, and makes - sure that no other pins change state at the same time. - - If you hold the button on the board running this program, the - pulses run slower. - - Useful as a simple test of functionality for GPIO pins. - */ - -#define INTER_TOGGLE_DELAY_NORMAL 5 -#define INTER_TOGGLE_DELAY_SLOW 80 - -void interToggleDelay(void); - -void setup() { - pinMode(33, OUTPUT); - pinMode(BOARD_BUTTON_PIN, INPUT); - - // All unused pins start out low. - for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { - if (boardUsesPin(i)) - continue; - pinMode(i, OUTPUT); - digitalWrite(i, LOW); - } -} - -void loop() { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - - for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { - if (boardUsesPin(i)) - continue; - - // Bring just this pin high. - digitalWrite(i, HIGH); - // Give the master time to detect if any other pins also went high. - interToggleDelay(); - // Bring this pin back low again; all pins should now be low. - digitalWrite(i, LOW); - // Give the master time to detect if any pins are still high. - interToggleDelay(); - } -} - -void interToggleDelay(void) { - if (digitalRead(BOARD_BUTTON_PIN)) { // don't pay the debouncing time - delay(INTER_TOGGLE_DELAY_SLOW); - } else { - delay(INTER_TOGGLE_DELAY_NORMAL); - } -} +/* + Slave mode for Quality Assurance test + + Used as follows: + + 1) Connect all non-used pins on the test board to their + corresponding pins on a board running InteractiveTest. + + 2) Connect a serial monitor to the InteractiveTest board and + enter "+" (a plus sign, without the quotes). + + This program pulses each unused pin in order, starting from pin 0. + The InteractiveTest "+" command detects these pulses, and makes + sure that no other pins change state at the same time. + + If you hold the button on the board running this program, the + pulses run slower. + + Useful as a simple test of functionality for GPIO pins. + */ + +#define INTER_TOGGLE_DELAY_NORMAL 5 +#define INTER_TOGGLE_DELAY_SLOW 80 + +void interToggleDelay(void); + +void setup() { + pinMode(33, OUTPUT); + pinMode(BOARD_BUTTON_PIN, INPUT); + + // All unused pins start out low. + for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { + if (boardUsesPin(i)) + continue; + pinMode(i, OUTPUT); + digitalWrite(i, LOW); + } +} + +void loop() { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + + for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { + if (boardUsesPin(i)) + continue; + + // Bring just this pin high. + digitalWrite(i, HIGH); + // Give the master time to detect if any other pins also went high. + interToggleDelay(); + // Bring this pin back low again; all pins should now be low. + digitalWrite(i, LOW); + // Give the master time to detect if any pins are still high. + interToggleDelay(); + } +} + +void interToggleDelay(void) { + if (digitalRead(BOARD_BUTTON_PIN)) { // don't pay the debouncing time + delay(INTER_TOGGLE_DELAY_SLOW); + } else { + delay(INTER_TOGGLE_DELAY_NORMAL); + } +} diff --git a/examples/Maple/StressSerialUSB/StressSerialUSB.ino b/STM32F1/libraries/A_STM32_Examples/examples/Maple/StressSerialUSB/StressSerialUSB.ino similarity index 100% rename from examples/Maple/StressSerialUSB/StressSerialUSB.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Maple/StressSerialUSB/StressSerialUSB.ino diff --git a/examples/Maple/TimerInterrupts/TimerInterrupts.ino b/STM32F1/libraries/A_STM32_Examples/examples/Maple/TimerInterrupts/TimerInterrupts.ino similarity index 100% rename from examples/Maple/TimerInterrupts/TimerInterrupts.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Maple/TimerInterrupts/TimerInterrupts.ino diff --git a/examples/MrBrunetteExamples/Blink/Blink.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/Blink/Blink.ino similarity index 97% rename from examples/MrBrunetteExamples/Blink/Blink.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/Blink/Blink.ino index d59a711..d4383be 100644 --- a/examples/MrBrunetteExamples/Blink/Blink.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/Blink/Blink.ino @@ -1,17 +1,17 @@ -/* - Blink: Turns on the built-in LED on for one second, then off for one second, repeatedly. - Arduino 1.6.0rc1 - Sketch uses 11,900 bytes (11%) of program storage space. Maximum is 108,000 bytes. - Global variables use 2,592 bytes of dynamic memory. - Ported to Maple from the Arduino example 27 May 2011 By Marti Bolivar -*/ - -void setup() { - // Set up the built-in LED pin as an output: - pinMode(33, OUTPUT); -} - -void loop() { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(1000); // Wait for 1 second (1000 milliseconds) -} +/* + Blink: Turns on the built-in LED on for one second, then off for one second, repeatedly. + Arduino 1.6.0rc1 + Sketch uses 11,900 bytes (11%) of program storage space. Maximum is 108,000 bytes. + Global variables use 2,592 bytes of dynamic memory. + Ported to Maple from the Arduino example 27 May 2011 By Marti Bolivar +*/ + +void setup() { + // Set up the built-in LED pin as an output: + pinMode(33, OUTPUT); +} + +void loop() { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(1000); // Wait for 1 second (1000 milliseconds) +} diff --git a/examples/MrBrunetteExamples/BlinkNcount/BlinkNcount.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/BlinkNcount/BlinkNcount.ino similarity index 97% rename from examples/MrBrunetteExamples/BlinkNcount/BlinkNcount.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/BlinkNcount/BlinkNcount.ino index 5d617f6..7cabfde 100644 --- a/examples/MrBrunetteExamples/BlinkNcount/BlinkNcount.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/BlinkNcount/BlinkNcount.ino @@ -1,35 +1,35 @@ -/* - BlinkNcount for Maple Mini by m. ray burnette - Sketch uses 13,808 bytes (12%) of program storage space. Maximum is 108,000 bytes. - Global variables use 2,592 bytes of dynamic memory. - Turns on an LED on for one second, then off for one second, repeatedly. - Counts and displays the count on the attached serial monitor - This example code is in the public domain. - */ -int n = 0; - - -void setup() { - // initialize the digital pin as an output. - pinMode(33, OUTPUT); - // Initialize virtual COM over USB on Maple Mini - Serial.begin(9600); // BAUD has no effect on USB serial: placeholder for physical UART - // wait for serial monitor to be connected. - while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) - { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); // fast blink - } - Serial.println("Blink LED & count Demo"); -} - -void loop() { - digitalWrite(33, HIGH); // set the LED on - delay(500); // wait for a second - digitalWrite(33, LOW); // set the LED off - Serial.print("Loop #: "); - n++; - Serial.println(n); - - delay(500); // wait -} +/* + BlinkNcount for Maple Mini by m. ray burnette + Sketch uses 13,808 bytes (12%) of program storage space. Maximum is 108,000 bytes. + Global variables use 2,592 bytes of dynamic memory. + Turns on an LED on for one second, then off for one second, repeatedly. + Counts and displays the count on the attached serial monitor + This example code is in the public domain. + */ +int n = 0; + + +void setup() { + // initialize the digital pin as an output. + pinMode(33, OUTPUT); + // Initialize virtual COM over USB on Maple Mini + Serial.begin(9600); // BAUD has no effect on USB serial: placeholder for physical UART + // wait for serial monitor to be connected. + while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) + { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); // fast blink + } + Serial.println("Blink LED & count Demo"); +} + +void loop() { + digitalWrite(33, HIGH); // set the LED on + delay(500); // wait for a second + digitalWrite(33, LOW); // set the LED off + Serial.print("Loop #: "); + n++; + Serial.println(n); + + delay(500); // wait +} diff --git a/examples/MrBrunetteExamples/FadingOnboard/FadingOnboard.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/FadingOnboard/FadingOnboard.ino similarity index 100% rename from examples/MrBrunetteExamples/FadingOnboard/FadingOnboard.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/FadingOnboard/FadingOnboard.ino diff --git a/examples/MrBrunetteExamples/IntegerInput/IntegerInput.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/IntegerInput/IntegerInput.ino similarity index 96% rename from examples/MrBrunetteExamples/IntegerInput/IntegerInput.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/IntegerInput/IntegerInput.ino index f732b50..55a68e8 100644 --- a/examples/MrBrunetteExamples/IntegerInput/IntegerInput.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/IntegerInput/IntegerInput.ino @@ -1,46 +1,46 @@ -/* - IntegerInput by m. Ray Burnette - PUBLIC DOMAIN EXAMPLE - Maple Mini: Compiled under Arduino 1.6.0rc1 - Sketch uses 15,624 bytes (14%) of program storage space. Maximum is 108,000 bytes. - Global variables use 3,704 bytes of dynamic memory. -*/ - -#define BAUD 9600 -#define timeoutPeriod 2147483647 // Long time... about 25 days - -int a; -int b; - -void setup() -{ - // initialize the digital pin as an output. - pinMode(33, OUTPUT); - Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART - Serial.setTimeout(timeoutPeriod); // default is 1 second - // wait for serial monitor to be connected. - while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) - { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); // fast blink - } -} - -void loop() -{ - Serial.println("Enter first integer: "); - a = Serial.parseInt(); - Serial.print("a = "); - Serial.println(a); - - - Serial.println("Enter second integer: "); - b = Serial.parseInt(); - Serial.print("b = "); - Serial.println(b); - - Serial.print("Sum a + b ="); - Serial.println( a + b); - Serial.print("Dif a - b ="); - Serial.println(a - b); -} - +/* + IntegerInput by m. Ray Burnette - PUBLIC DOMAIN EXAMPLE + Maple Mini: Compiled under Arduino 1.6.0rc1 + Sketch uses 15,624 bytes (14%) of program storage space. Maximum is 108,000 bytes. + Global variables use 3,704 bytes of dynamic memory. +*/ + +#define BAUD 9600 +#define timeoutPeriod 2147483647 // Long time... about 25 days + +int a; +int b; + +void setup() +{ + // initialize the digital pin as an output. + pinMode(33, OUTPUT); + Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART + Serial.setTimeout(timeoutPeriod); // default is 1 second + // wait for serial monitor to be connected. + while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) + { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); // fast blink + } +} + +void loop() +{ + Serial.println("Enter first integer: "); + a = Serial.parseInt(); + Serial.print("a = "); + Serial.println(a); + + + Serial.println("Enter second integer: "); + b = Serial.parseInt(); + Serial.print("b = "); + Serial.println(b); + + Serial.print("Sum a + b ="); + Serial.println( a + b); + Serial.print("Dif a - b ="); + Serial.println(a - b); +} + diff --git a/examples/MrBrunetteExamples/IntegerInput_FloatOutput/IntegerInput_FloatOutput.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/IntegerInput_FloatOutput/IntegerInput_FloatOutput.ino similarity index 96% rename from examples/MrBrunetteExamples/IntegerInput_FloatOutput/IntegerInput_FloatOutput.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/IntegerInput_FloatOutput/IntegerInput_FloatOutput.ino index 0f9c6ad..6f04840 100644 --- a/examples/MrBrunetteExamples/IntegerInput_FloatOutput/IntegerInput_FloatOutput.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/IntegerInput_FloatOutput/IntegerInput_FloatOutput.ino @@ -1,50 +1,50 @@ -/* - IntegerInput_FloatOutput by m. Ray Burnette - PUBLIC DOMAIN EXAMPLE - Maple Mini: Compiled under Arduino 1.6.0rc1 - Sketch uses 19,868 bytes (18%) of program storage space. Maximum is 108,000 bytes. - Global variables use 3,704 bytes of dynamic memory. -*/ - -#define BAUD 9600 -#define timeoutPeriod 2147483647 // Long var... about 25 days - -float a; -float b; - - -void setup() -{ - // initialize the digital pin as an output. - pinMode(33, OUTPUT); - Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART - Serial.setTimeout(timeoutPeriod); // default is 1 second - // wait for serial monitor to be connected. - while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) - { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); // fast blink - } - Serial.println("Integer Input - Floating Output"); - Serial.println("You may wish to try 355 and 113 (Pi)"); -} - -void loop() -{ - Serial.println("Enter first integer: "); - - a = Serial.parseInt(); - Serial.print("a = "); - Serial.println(a); - - Serial.println("Enter second integer: "); - - b = Serial.parseInt(); - Serial.print("b = "); - Serial.println(b); - - a = a / b; - Serial.print( "a/b = "); - Serial.println(a); - Serial.println(); -} - +/* + IntegerInput_FloatOutput by m. Ray Burnette - PUBLIC DOMAIN EXAMPLE + Maple Mini: Compiled under Arduino 1.6.0rc1 + Sketch uses 19,868 bytes (18%) of program storage space. Maximum is 108,000 bytes. + Global variables use 3,704 bytes of dynamic memory. +*/ + +#define BAUD 9600 +#define timeoutPeriod 2147483647 // Long var... about 25 days + +float a; +float b; + + +void setup() +{ + // initialize the digital pin as an output. + pinMode(33, OUTPUT); + Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART + Serial.setTimeout(timeoutPeriod); // default is 1 second + // wait for serial monitor to be connected. + while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) + { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); // fast blink + } + Serial.println("Integer Input - Floating Output"); + Serial.println("You may wish to try 355 and 113 (Pi)"); +} + +void loop() +{ + Serial.println("Enter first integer: "); + + a = Serial.parseInt(); + Serial.print("a = "); + Serial.println(a); + + Serial.println("Enter second integer: "); + + b = Serial.parseInt(); + Serial.print("b = "); + Serial.println(b); + + a = a / b; + Serial.print( "a/b = "); + Serial.println(a); + Serial.println(); +} + diff --git a/examples/MrBrunetteExamples/InternalTempSensor/InternalTempSensor.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/InternalTempSensor/InternalTempSensor.ino similarity index 96% rename from examples/MrBrunetteExamples/InternalTempSensor/InternalTempSensor.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/InternalTempSensor/InternalTempSensor.ino index 6755e54..e207a31 100644 --- a/examples/MrBrunetteExamples/InternalTempSensor/InternalTempSensor.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/InternalTempSensor/InternalTempSensor.ino @@ -1,80 +1,80 @@ -/* - Re: http://leaflabs.com/docs/hardware - Arduino 1.6.0rc1 modifications by m. ray burnette - Sketch uses 31,608 bytes (29%) of program storage space. Maximum is 108,000 bytes. - Global variables use 3,752 bytes of dynamic memory. - PUBLIC DOMAIN EXAMPLE -*/ - -//#include -#include - -#define LED_PIN 33 -#define A_RANDOM_ANALOG_PIN 15 - -void setup_temperature_sensor() { - adc_reg_map *regs = ADC1->regs; - -// 3. Set the TSVREFE bit in the ADC control register 2 (ADC_CR2) to wake up the -// temperature sensor from power down mode. Do this first 'cause according to -// the Datasheet section 5.3.21 it takes from 4 to 10 uS to power up the sensor. - - regs->CR2 |= ADC_CR2_TSEREFE; - -// 2. Select a sample time of 17.1 μs -// set channel 16 sample time to 239.5 cycles -// 239.5 cycles of the ADC clock (72MHz/6=12MHz) is over 17.1us (about 20us), but no smaller -// sample time exceeds 17.1us. - - regs->SMPR1 = (0b111 << (3*6)); // set channel 16, the temp. sensor -} - -void setup(void) -{ -// Set up the LED to blink - pinMode(LED_PIN, OUTPUT); - -// set up an analog input. We want to test and make sure other analog reads don't screw this up. - pinMode(A_RANDOM_ANALOG_PIN, INPUT_ANALOG); - -// wait for serial monitor to be connected. - while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) - { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); // fast blink - } - -// init tem psensor - setup_temperature_sensor(); - -// announce start up - if(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())) - Serial.println("Temp mon startup"); -} - -// -// once per second perform a standard analog read and read the temperature sensor -// the analog read is to test whether our messing with the temp sensor will screw up analog reads -// or visa versa. -// Also compute and display the time each operation takes. -// -void loop(void) -{ - uint16 vsense, alogpin; - uint32 t1, t2, t3; - char buf[64]; - - t1 = micros(); - alogpin = analogRead(A_RANDOM_ANALOG_PIN); - t2 = micros(); - vsense = adc_read(ADC1, 16); - t3 = micros(); - if(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())) { - sprintf(buf,"%04x %08x %04x %08x" , vsense, t3-t2, alogpin, t2-t1); - Serial.println(buf); - } - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(1000); -} - - +/* + Re: http://leaflabs.com/docs/hardware + Arduino 1.6.0rc1 modifications by m. ray burnette + Sketch uses 31,608 bytes (29%) of program storage space. Maximum is 108,000 bytes. + Global variables use 3,752 bytes of dynamic memory. + PUBLIC DOMAIN EXAMPLE +*/ + +//#include +#include + +#define LED_PIN 33 +#define A_RANDOM_ANALOG_PIN 15 + +void setup_temperature_sensor() { + adc_reg_map *regs = ADC1->regs; + +// 3. Set the TSVREFE bit in the ADC control register 2 (ADC_CR2) to wake up the +// temperature sensor from power down mode. Do this first 'cause according to +// the Datasheet section 5.3.21 it takes from 4 to 10 uS to power up the sensor. + + regs->CR2 |= ADC_CR2_TSEREFE; + +// 2. Select a sample time of 17.1 μs +// set channel 16 sample time to 239.5 cycles +// 239.5 cycles of the ADC clock (72MHz/6=12MHz) is over 17.1us (about 20us), but no smaller +// sample time exceeds 17.1us. + + regs->SMPR1 = (0b111 << (3*6)); // set channel 16, the temp. sensor +} + +void setup(void) +{ +// Set up the LED to blink + pinMode(LED_PIN, OUTPUT); + +// set up an analog input. We want to test and make sure other analog reads don't screw this up. + pinMode(A_RANDOM_ANALOG_PIN, INPUT_ANALOG); + +// wait for serial monitor to be connected. + while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) + { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); // fast blink + } + +// init tem psensor + setup_temperature_sensor(); + +// announce start up + if(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())) + Serial.println("Temp mon startup"); +} + +// +// once per second perform a standard analog read and read the temperature sensor +// the analog read is to test whether our messing with the temp sensor will screw up analog reads +// or visa versa. +// Also compute and display the time each operation takes. +// +void loop(void) +{ + uint16 vsense, alogpin; + uint32 t1, t2, t3; + char buf[64]; + + t1 = micros(); + alogpin = analogRead(A_RANDOM_ANALOG_PIN); + t2 = micros(); + vsense = adc_read(ADC1, 16); + t3 = micros(); + if(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())) { + sprintf(buf,"%04x %08x %04x %08x" , vsense, t3-t2, alogpin, t2-t1); + Serial.println(buf); + } + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(1000); +} + + diff --git a/examples/MrBrunetteExamples/PrimeNos/PrimeNos.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/PrimeNos/PrimeNos.ino similarity index 97% rename from examples/MrBrunetteExamples/PrimeNos/PrimeNos.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/PrimeNos/PrimeNos.ino index 7a57000..09a7a3f 100644 --- a/examples/MrBrunetteExamples/PrimeNos/PrimeNos.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/PrimeNos/PrimeNos.ino @@ -1,69 +1,69 @@ -/* - PrimeNos: by Nick Gammon - Maple Mini port m. ray burnette: Compiled under Arduino 1.6.0rc1 - Sketch uses 13,644 bytes (12%) of program storage space. Maximum is 108,000 bytes. - Global variables use 2,656 bytes of dynamic memory. - PUBLIC DOMAIN EXAMPLE -*/ - -#define BAUD 9600 - -// just add more primes to the prime table for larger search -// byte data type to save memory - use a larger datatype with prime table entries above 255 :) -byte primes[]={ - 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, - 102, 107, 109, 113, 127, 131, 137 , 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, - 199, 211, 223, 227, 229, 233, 239, 241, 251 }; - -// if you change the datatype of primes array to int, change next line to -// "const int TopPrimeIndex = (sizeof(primes)/2) - 1;" - -const unsigned int TopPrimeIndex = sizeof(primes) - 1; -const unsigned long TopPrimeSquared = (long)primes[TopPrimeIndex] * (long)primes[TopPrimeIndex]; -int primeFlag; - - -void setup() -{ - // initialize the digital pin as an output. - pinMode(33, OUTPUT); - Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART - // wait for serial monitor to be connected. - while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) - { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); // fast blink - } - Serial.println("Prime Number Generator"); - Serial.print("Number of primes in prime table = "); - Serial.println(TopPrimeIndex); - Serial.println(); - Serial.print("Last prime in table = "); - Serial.println((unsigned int)primes[TopPrimeIndex]); - Serial.println(); - - Serial.print("Calculating primes through "); - Serial.println(TopPrimeSquared); - Serial.println(); - - -} -void loop() // run over and over again -{ - for (long x = 1; x < TopPrimeSquared; x+=2){ // skips even numbers, including 2, which is prime, but it makes algorithm tad faster - - for (long j=0; j < TopPrimeIndex; j++){ - primeFlag = true; - - if (x == primes[j]) break; - - if (x % primes[j] == 0){ // if the test number modolo (next number from prime table) == 0 - primeFlag = false; // then test number is not prime, bailout and check the next number - break; - } - } - if (primeFlag == true){ // found a prime - print it - Serial.println(x); - } - } -} +/* + PrimeNos: by Nick Gammon + Maple Mini port m. ray burnette: Compiled under Arduino 1.6.0rc1 + Sketch uses 13,644 bytes (12%) of program storage space. Maximum is 108,000 bytes. + Global variables use 2,656 bytes of dynamic memory. + PUBLIC DOMAIN EXAMPLE +*/ + +#define BAUD 9600 + +// just add more primes to the prime table for larger search +// byte data type to save memory - use a larger datatype with prime table entries above 255 :) +byte primes[]={ + 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, + 102, 107, 109, 113, 127, 131, 137 , 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, + 199, 211, 223, 227, 229, 233, 239, 241, 251 }; + +// if you change the datatype of primes array to int, change next line to +// "const int TopPrimeIndex = (sizeof(primes)/2) - 1;" + +const unsigned int TopPrimeIndex = sizeof(primes) - 1; +const unsigned long TopPrimeSquared = (long)primes[TopPrimeIndex] * (long)primes[TopPrimeIndex]; +int primeFlag; + + +void setup() +{ + // initialize the digital pin as an output. + pinMode(33, OUTPUT); + Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART + // wait for serial monitor to be connected. + while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) + { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); // fast blink + } + Serial.println("Prime Number Generator"); + Serial.print("Number of primes in prime table = "); + Serial.println(TopPrimeIndex); + Serial.println(); + Serial.print("Last prime in table = "); + Serial.println((unsigned int)primes[TopPrimeIndex]); + Serial.println(); + + Serial.print("Calculating primes through "); + Serial.println(TopPrimeSquared); + Serial.println(); + + +} +void loop() // run over and over again +{ + for (long x = 1; x < TopPrimeSquared; x+=2){ // skips even numbers, including 2, which is prime, but it makes algorithm tad faster + + for (long j=0; j < TopPrimeIndex; j++){ + primeFlag = true; + + if (x == primes[j]) break; + + if (x % primes[j] == 0){ // if the test number modolo (next number from prime table) == 0 + primeFlag = false; // then test number is not prime, bailout and check the next number + break; + } + } + if (primeFlag == true){ // found a prime - print it + Serial.println(x); + } + } +} diff --git a/examples/MrBrunetteExamples/PrimeNos2/PrimeNos2.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/PrimeNos2/PrimeNos2.ino similarity index 97% rename from examples/MrBrunetteExamples/PrimeNos2/PrimeNos2.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/PrimeNos2/PrimeNos2.ino index 2feca4b..51fe332 100644 --- a/examples/MrBrunetteExamples/PrimeNos2/PrimeNos2.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/PrimeNos2/PrimeNos2.ino @@ -1,41 +1,41 @@ -/* - PrimeNos3: by Nick Gammon - Maple Mini port m. ray burnette: Compiled under Arduino 1.6.0rc1 - Sketch uses 16,616 bytes (15%) of program storage space. Maximum is 108,000 bytes. - Global variables use 2,624 bytes of dynamic memory. - PUBLIC DOMAIN EXAMPLE -*/ - -#define BAUD 9600 -const int SHOW_EVERY = 500; // how often to echo a prime to the serial port -int candidate; -int found = 5; // Number we found -int count = found - 1; - - -void setup() { - // initialize the digital pin as an output. - pinMode(33, OUTPUT); - Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART - // wait for serial monitor to be connected. - while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) - { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); // fast blink - } - Serial.println("Prime Number Generator V2"); -} - -void loop() { - Serial.println("Prime numbers between 1 and 99999999 are:"); - Serial.println("2 \t"); - for (int i=3; i<99999999;i+=2) { - // This loop stops either when j*j>i or when i is divisible by j. - // The first condition means prime, the second, not prime. - int j=3; - for(;j*j<=i && i%j!=0; j+=2); // No loop body - - if (j*j>i) Serial.print(i);Serial.print( "\t"); - } - Serial.println("\r\n"); -} +/* + PrimeNos3: by Nick Gammon + Maple Mini port m. ray burnette: Compiled under Arduino 1.6.0rc1 + Sketch uses 16,616 bytes (15%) of program storage space. Maximum is 108,000 bytes. + Global variables use 2,624 bytes of dynamic memory. + PUBLIC DOMAIN EXAMPLE +*/ + +#define BAUD 9600 +const int SHOW_EVERY = 500; // how often to echo a prime to the serial port +int candidate; +int found = 5; // Number we found +int count = found - 1; + + +void setup() { + // initialize the digital pin as an output. + pinMode(33, OUTPUT); + Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART + // wait for serial monitor to be connected. + while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) + { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); // fast blink + } + Serial.println("Prime Number Generator V2"); +} + +void loop() { + Serial.println("Prime numbers between 1 and 99999999 are:"); + Serial.println("2 \t"); + for (int i=3; i<99999999;i+=2) { + // This loop stops either when j*j>i or when i is divisible by j. + // The first condition means prime, the second, not prime. + int j=3; + for(;j*j<=i && i%j!=0; j+=2); // No loop body + + if (j*j>i) Serial.print(i);Serial.print( "\t"); + } + Serial.println("\r\n"); +} diff --git a/examples/MrBrunetteExamples/PrimeNos3/PrimeNos3.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/PrimeNos3/PrimeNos3.ino similarity index 97% rename from examples/MrBrunetteExamples/PrimeNos3/PrimeNos3.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/PrimeNos3/PrimeNos3.ino index 55ebafe..eec3dc0 100644 --- a/examples/MrBrunetteExamples/PrimeNos3/PrimeNos3.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/PrimeNos3/PrimeNos3.ino @@ -1,41 +1,41 @@ -/* - PrimeNos3: by Nick Gammon - Maple Mini port m. ray burnette: Compiled under Arduino 1.6.0rc1 - Sketch uses 13,420 bytes (12%) of program storage space. Maximum is 108,000 bytes. - Global variables use 2,600 bytes of dynamic memory. - PUBLIC DOMAIN EXAMPLE -*/ - -#define BAUD 9600 -const int SHOW_EVERY = 500; // how often to echo a prime to the serial port -int candidate; -int found = 5; // Number we found -int count = found - 1; - - -void setup() { - // initialize the digital pin as an output. - pinMode(33, OUTPUT); - Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART - // wait for serial monitor to be connected. - while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) - { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); // fast blink - } - Serial.println("Prime Number Generator V2"); -} - -void loop() { - Serial.println("Prime numbers between 1 and 99999999 are:"); - Serial.println("2 \t"); - for (int i=3; i<99999999;i+=2) { - // This loop stops either when j*j>i or when i is divisible by j. - // The first condition means prime, the second, not prime. - int j=3; - for(;j*j<=i && i%j!=0; j+=2); // No loop body - - if (j*j>i) Serial.print(i);Serial.print( "\n\r"); - } - Serial.println("\r\n"); -} +/* + PrimeNos3: by Nick Gammon + Maple Mini port m. ray burnette: Compiled under Arduino 1.6.0rc1 + Sketch uses 13,420 bytes (12%) of program storage space. Maximum is 108,000 bytes. + Global variables use 2,600 bytes of dynamic memory. + PUBLIC DOMAIN EXAMPLE +*/ + +#define BAUD 9600 +const int SHOW_EVERY = 500; // how often to echo a prime to the serial port +int candidate; +int found = 5; // Number we found +int count = found - 1; + + +void setup() { + // initialize the digital pin as an output. + pinMode(33, OUTPUT); + Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART + // wait for serial monitor to be connected. + while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) + { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); // fast blink + } + Serial.println("Prime Number Generator V2"); +} + +void loop() { + Serial.println("Prime numbers between 1 and 99999999 are:"); + Serial.println("2 \t"); + for (int i=3; i<99999999;i+=2) { + // This loop stops either when j*j>i or when i is divisible by j. + // The first condition means prime, the second, not prime. + int j=3; + for(;j*j<=i && i%j!=0; j+=2); // No loop body + + if (j*j>i) Serial.print(i);Serial.print( "\n\r"); + } + Serial.println("\r\n"); +} diff --git a/examples/MrBrunetteExamples/Print_Binary/Print_Binary.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/Print_Binary/Print_Binary.ino similarity index 95% rename from examples/MrBrunetteExamples/Print_Binary/Print_Binary.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/Print_Binary/Print_Binary.ino index e6c02f9..c9c4b88 100644 --- a/examples/MrBrunetteExamples/Print_Binary/Print_Binary.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/Print_Binary/Print_Binary.ino @@ -1,66 +1,66 @@ -/* PRINT_BINARY - Arduino 1.6.0rc1 - Adapted to Maple Mini by m. ray burnette - Sketch uses 11,672 bytes (10%) of program storage space. Maximum is 108,000 bytes. - Global variables use 2,592 bytes of dynamic memory - Prints a positive integer in binary format with a fixed withdth - copyright, Peter H Anderson, Baltimore, MD, Nov, '07 - PUBLIC DOMAIN EXAMPLE -*/ - -#define BAUD 9600 - -void setup() -{ - // initialize the digital pin as an output. - pinMode(33, OUTPUT); - Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART - // wait for serial monitor to be connected. - while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) - { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); // fast blink - } - Serial.println("Print Binary Format"); -} - -void loop() -{ - while(1) - { - print_binary(1024+256+63, 12); - Serial.println(); - delay(1000); - - } -} - -void print_binary(int v, int num_places) -{ - int mask=0, n; - - for (n=1; n<=num_places; n++) - { - mask = (mask << 1) | 0x0001; - } - v = v & mask; // truncate v to specified number of places - - while(num_places) - { - - if (v & (0x0001 << num_places-1)) - { - Serial.print("1"); - } - else - { - Serial.print("0"); - } - - --num_places; - if(((num_places%4) == 0) && (num_places != 0)) - { - Serial.print("_"); - } - } -} - +/* PRINT_BINARY - Arduino 1.6.0rc1 + Adapted to Maple Mini by m. ray burnette + Sketch uses 11,672 bytes (10%) of program storage space. Maximum is 108,000 bytes. + Global variables use 2,592 bytes of dynamic memory + Prints a positive integer in binary format with a fixed withdth + copyright, Peter H Anderson, Baltimore, MD, Nov, '07 + PUBLIC DOMAIN EXAMPLE +*/ + +#define BAUD 9600 + +void setup() +{ + // initialize the digital pin as an output. + pinMode(33, OUTPUT); + Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART + // wait for serial monitor to be connected. + while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) + { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); // fast blink + } + Serial.println("Print Binary Format"); +} + +void loop() +{ + while(1) + { + print_binary(1024+256+63, 12); + Serial.println(); + delay(1000); + + } +} + +void print_binary(int v, int num_places) +{ + int mask=0, n; + + for (n=1; n<=num_places; n++) + { + mask = (mask << 1) | 0x0001; + } + v = v & mask; // truncate v to specified number of places + + while(num_places) + { + + if (v & (0x0001 << num_places-1)) + { + Serial.print("1"); + } + else + { + Serial.print("0"); + } + + --num_places; + if(((num_places%4) == 0) && (num_places != 0)) + { + Serial.print("_"); + } + } +} + diff --git a/examples/MrBrunetteExamples/Print_Float/Print_Float.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/Print_Float/Print_Float.ino similarity index 96% rename from examples/MrBrunetteExamples/Print_Float/Print_Float.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/Print_Float/Print_Float.ino index 671caef..289db9e 100644 --- a/examples/MrBrunetteExamples/Print_Float/Print_Float.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/Print_Float/Print_Float.ino @@ -1,84 +1,84 @@ -/* - PRINT_FLOAT - Arduino 1.6.0rc1 - Sketch uses 15,164 bytes (14%) of program storage space. Maximum is 108,000 bytes. - Global variables use 2,592 bytes of dynamic memory. - Adapted to Maple Mini by m. ray burnette - Illustrates how to display floats in the range of -999.999 to 999.999 with a specified - number of digits after the decimal point. - copyright, Peter H Anderson, Baltimore, MD, Nov, '07 - PUBLIC DOMAIN EXAMPLE -*/ - -#define BAUD 9600 - -void setup() // run once, when the sketch starts -{ - // initialize the digital pin as an output. - pinMode(33, OUTPUT); - Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART - // wait for serial monitor to be connected. - while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) - { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); // fast blink - } - Serial.println("Print Float Format"); -} - -void loop() -{ - while(1) - { - print_float(0.6, 2); // illustrate various test cases - Serial.println(); - print_float(1.2, 1); - Serial.println(); - print_float(10.27, 2); - Serial.println(); - print_float(10.345, 3); - Serial.println(); - print_float(107.345, 3); - Serial.println(); - delay(1000); - - print_float(-0.6, 2); - Serial.println(); - print_float(-1.2, 1); - Serial.println(); - print_float(-10.27, 2); - Serial.println(); - print_float(-10.345, 3); - Serial.println(); - print_float(-107.345, 3); - Serial.println(); - delay(1000); - } -} - -void print_float(float f, int num_digits) -{ - int f_int; - int pows_of_ten[4] = {1, 10, 100, 1000}; - int multiplier, whole, fract, d, n; - - multiplier = pows_of_ten[num_digits]; - if (f < 0.0) - { - f = -f; - Serial.print("-"); - } - whole = (int) f; - fract = (int) (multiplier * (f - (float)whole)); - - Serial.print(whole); - Serial.print("."); - - for (n=num_digits-1; n>=0; n--) // print each digit with no leading zero suppression - { - d = fract / pows_of_ten[n]; - Serial.print(d); - fract = fract % pows_of_ten[n]; - } -} - - +/* + PRINT_FLOAT - Arduino 1.6.0rc1 + Sketch uses 15,164 bytes (14%) of program storage space. Maximum is 108,000 bytes. + Global variables use 2,592 bytes of dynamic memory. + Adapted to Maple Mini by m. ray burnette + Illustrates how to display floats in the range of -999.999 to 999.999 with a specified + number of digits after the decimal point. + copyright, Peter H Anderson, Baltimore, MD, Nov, '07 + PUBLIC DOMAIN EXAMPLE +*/ + +#define BAUD 9600 + +void setup() // run once, when the sketch starts +{ + // initialize the digital pin as an output. + pinMode(33, OUTPUT); + Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART + // wait for serial monitor to be connected. + while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) + { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); // fast blink + } + Serial.println("Print Float Format"); +} + +void loop() +{ + while(1) + { + print_float(0.6, 2); // illustrate various test cases + Serial.println(); + print_float(1.2, 1); + Serial.println(); + print_float(10.27, 2); + Serial.println(); + print_float(10.345, 3); + Serial.println(); + print_float(107.345, 3); + Serial.println(); + delay(1000); + + print_float(-0.6, 2); + Serial.println(); + print_float(-1.2, 1); + Serial.println(); + print_float(-10.27, 2); + Serial.println(); + print_float(-10.345, 3); + Serial.println(); + print_float(-107.345, 3); + Serial.println(); + delay(1000); + } +} + +void print_float(float f, int num_digits) +{ + int f_int; + int pows_of_ten[4] = {1, 10, 100, 1000}; + int multiplier, whole, fract, d, n; + + multiplier = pows_of_ten[num_digits]; + if (f < 0.0) + { + f = -f; + Serial.print("-"); + } + whole = (int) f; + fract = (int) (multiplier * (f - (float)whole)); + + Serial.print(whole); + Serial.print("."); + + for (n=num_digits-1; n>=0; n--) // print each digit with no leading zero suppression + { + d = fract / pows_of_ten[n]; + Serial.print(d); + fract = fract % pows_of_ten[n]; + } +} + + diff --git a/examples/MrBrunetteExamples/Print_HEX/Print_HEX.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/Print_HEX/Print_HEX.ino similarity index 96% rename from examples/MrBrunetteExamples/Print_HEX/Print_HEX.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/Print_HEX/Print_HEX.ino index 0cdccd4..cfdb977 100644 --- a/examples/MrBrunetteExamples/Print_HEX/Print_HEX.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/Print_HEX/Print_HEX.ino @@ -1,61 +1,61 @@ -/* - PRINT_HEX - Arduino 1.6.0rc1 - Sketch uses 13,336 bytes (12%) of program storage space. Maximum is 108,000 bytes. - Global variables use 2,592 bytes of dynamic memory. - Adapted to the Maple Mini by m. ray burnette - Illustrates how to display a hexadecimal number with a fixed width. - opyright, Peter H Anderson, Baltimore, MD, Nov, '07 - PUBLIC DOMAIN EXAMPLE -*/ - -#define BAUD 9600 - -void setup() // run once, when the sketch starts -{ - // initialize the digital pin as an output. - pinMode(33, OUTPUT); - Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART - // wait for serial monitor to be connected. - while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) - { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); // fast blink - } - Serial.println("Print HEX Format"); -} - -void loop() -{ - while(1) - { - print_hex(1024+256+63, 13); - Serial.println(); - delay(1000); - - } -} - -void print_hex(int v, int num_places) -{ - int mask=0, n, num_nibbles, digit; - - for (n=1; n<=num_places; n++) - { - mask = (mask << 1) | 0x0001; - } - v = v & mask; // truncate v to specified number of places - - num_nibbles = num_places / 4; - if ((num_places % 4) != 0) - { - ++num_nibbles; - } - - do - { - digit = ((v >> (num_nibbles-1) * 4)) & 0x0f; - Serial.print(digit, HEX); - } while(--num_nibbles); - -} - +/* + PRINT_HEX - Arduino 1.6.0rc1 + Sketch uses 13,336 bytes (12%) of program storage space. Maximum is 108,000 bytes. + Global variables use 2,592 bytes of dynamic memory. + Adapted to the Maple Mini by m. ray burnette + Illustrates how to display a hexadecimal number with a fixed width. + opyright, Peter H Anderson, Baltimore, MD, Nov, '07 + PUBLIC DOMAIN EXAMPLE +*/ + +#define BAUD 9600 + +void setup() // run once, when the sketch starts +{ + // initialize the digital pin as an output. + pinMode(33, OUTPUT); + Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART + // wait for serial monitor to be connected. + while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) + { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); // fast blink + } + Serial.println("Print HEX Format"); +} + +void loop() +{ + while(1) + { + print_hex(1024+256+63, 13); + Serial.println(); + delay(1000); + + } +} + +void print_hex(int v, int num_places) +{ + int mask=0, n, num_nibbles, digit; + + for (n=1; n<=num_places; n++) + { + mask = (mask << 1) | 0x0001; + } + v = v & mask; // truncate v to specified number of places + + num_nibbles = num_places / 4; + if ((num_places % 4) != 0) + { + ++num_nibbles; + } + + do + { + digit = ((v >> (num_nibbles-1) * 4)) & 0x0f; + Serial.print(digit, HEX); + } while(--num_nibbles); + +} + diff --git a/examples/MrBrunetteExamples/SerialReadUntil/SerialReadUntil.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/SerialReadUntil/SerialReadUntil.ino similarity index 96% rename from examples/MrBrunetteExamples/SerialReadUntil/SerialReadUntil.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/SerialReadUntil/SerialReadUntil.ino index 1df080b..1e7d400 100644 --- a/examples/MrBrunetteExamples/SerialReadUntil/SerialReadUntil.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/SerialReadUntil/SerialReadUntil.ino @@ -1,35 +1,35 @@ - -// http://arduino.cc/forum/index.php?topic=114035.0 ` -/* Sketch uses 13,836 bytes (12%) of program storage space. Maximum is 108,000 bytes. - Global variables use 3,696 bytes of dynamic memory. - Read an unknown length string of ASCII characters terminated - with a line feed from the UART -*/ - -#define BAUD 9600 - -void setup() { - // initialize the digital pin as an output. - pinMode(33, OUTPUT); - Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UAR - // wait for serial monitor to be connected. - while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) - { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); // fast blink - } - Serial.println("Serial Read Until Example:"); - Serial.print("Type a few characters & press ENTER\r\n(make certain serial monitor sends CR+LF)"); -} - -void loop() { - char serialdata[80]; - int lf = 10; - - Serial.readBytesUntil(lf, serialdata, 80); - - Serial.println(serialdata); - -} - - + +// http://arduino.cc/forum/index.php?topic=114035.0 ` +/* Sketch uses 13,836 bytes (12%) of program storage space. Maximum is 108,000 bytes. + Global variables use 3,696 bytes of dynamic memory. + Read an unknown length string of ASCII characters terminated + with a line feed from the UART +*/ + +#define BAUD 9600 + +void setup() { + // initialize the digital pin as an output. + pinMode(33, OUTPUT); + Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UAR + // wait for serial monitor to be connected. + while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) + { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); // fast blink + } + Serial.println("Serial Read Until Example:"); + Serial.print("Type a few characters & press ENTER\r\n(make certain serial monitor sends CR+LF)"); +} + +void loop() { + char serialdata[80]; + int lf = 10; + + Serial.readBytesUntil(lf, serialdata, 80); + + Serial.println(serialdata); + +} + + diff --git a/examples/MrBrunetteExamples/StringEx_Parsing/StringEx_Parsing.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/StringEx_Parsing/StringEx_Parsing.ino similarity index 100% rename from examples/MrBrunetteExamples/StringEx_Parsing/StringEx_Parsing.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/StringEx_Parsing/StringEx_Parsing.ino diff --git a/examples/MrBrunetteExamples/USB_ASCII/USB_ASCII.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/USB_ASCII/USB_ASCII.ino similarity index 96% rename from examples/MrBrunetteExamples/USB_ASCII/USB_ASCII.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/USB_ASCII/USB_ASCII.ino index 17c7cb4..e38b176 100644 --- a/examples/MrBrunetteExamples/USB_ASCII/USB_ASCII.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/USB_ASCII/USB_ASCII.ino @@ -1,104 +1,104 @@ -/* - USBascii Example for Arduino 1.6.0rc1 on the Maple Mini STM32 platform - Sketch uses 13,572 bytes (12%) of program storage space. Maximum is 108,000 bytes. - Global variables use 2,600 bytes of dynamic memory. - Connect to the Maple Serial using the Serial Monitor, then press - any key and hit enter. - - Prints out byte values in all possible formats: - * as raw binary values - * as ASCII-encoded decimal, hex, octal, and binary values - - For more on ASCII, see: - http://www.asciitable.com - http://en.wikipedia.org/wiki/ASCII - - No external hardware needed. - - created 2006 - by Nicholas Zambetti - modified 18 Jan 2009 - by Tom Igoe - - - - Ported to the Maple 27 May 2010 - by Bryan Newbold - Minor edits by m. ray burnette for Arduino 1.6.0 - - PUBLIC DOMAIN EXAMPLE -*/ - -void setup() { - // initialize the digital pin as an output. - pinMode(33, OUTPUT); - Serial.begin(); // USB does not require BAUD - // wait for serial monitor to be connected. - while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) - { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); // fast blink - } - Serial.println("ASCII Table ~ Character Map"); - Serial.println("Press CR to start the printout"); -} - -// First visible ASCII character: '!' is number 33: -int thisByte = 33; -int junk = 0; -bool Virgin = true; -// You can also write ASCII characters in single quotes. -// for example. '!' is the same as 33, so you could also use this: -//int thisByte = '!'; - -void loop() { - Restart: - // Wait for the user to press a key - if (!Virgin) goto NextPhase; - while (!Serial.available()) - continue; - - while (Serial.available()) { - junk = Serial.read(); - } - //continue; - NextPhase: - Virgin = false ; - // Prints value unaltered, i.e. the raw binary version of the - // byte. The serial monitor interprets all bytes as - // ASCII, so 33, the first number, will show up as '!' - Serial.print(thisByte, BYTE); - - Serial.print(", dec: "); - // Prints value as string as an ASCII-encoded decimal (base 10). - // Decimal is the default format for Serial.print() and - // Serial.println(), so no modifier is needed: - Serial.print(thisByte); - // But you can declare the modifier for decimal if you want to. - // This also works if you uncomment it: - // Serial.print(thisByte, DEC); - - Serial.print(", hex: "); - // Prints value as string in hexadecimal (base 16): - Serial.print(thisByte, HEX); - - Serial.print(", oct: "); - // Prints value as string in octal (base 8); - Serial.print(thisByte, OCT); - - Serial.print(", bin: "); - // Prints value as string in binary (base 2); also prints ending - // line break: - Serial.println(thisByte, BIN); - - // If printed last visible character '~' or 126, stop: - if (thisByte == 126) { // You could also use if (thisByte == '~') { - thisByte = 33; - Virgin = true; - Serial.println("=============================="); - Serial.println("Press CR to start the printout"); - goto Restart ; - } - // Go on to the next character - thisByte++; -} +/* + USBascii Example for Arduino 1.6.0rc1 on the Maple Mini STM32 platform + Sketch uses 13,572 bytes (12%) of program storage space. Maximum is 108,000 bytes. + Global variables use 2,600 bytes of dynamic memory. + Connect to the Maple Serial using the Serial Monitor, then press + any key and hit enter. + + Prints out byte values in all possible formats: + * as raw binary values + * as ASCII-encoded decimal, hex, octal, and binary values + + For more on ASCII, see: + http://www.asciitable.com + http://en.wikipedia.org/wiki/ASCII + + No external hardware needed. + + created 2006 + by Nicholas Zambetti + modified 18 Jan 2009 + by Tom Igoe + + + + Ported to the Maple 27 May 2010 + by Bryan Newbold + Minor edits by m. ray burnette for Arduino 1.6.0 + + PUBLIC DOMAIN EXAMPLE +*/ + +void setup() { + // initialize the digital pin as an output. + pinMode(33, OUTPUT); + Serial.begin(); // USB does not require BAUD + // wait for serial monitor to be connected. + while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) + { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); // fast blink + } + Serial.println("ASCII Table ~ Character Map"); + Serial.println("Press CR to start the printout"); +} + +// First visible ASCII character: '!' is number 33: +int thisByte = 33; +int junk = 0; +bool Virgin = true; +// You can also write ASCII characters in single quotes. +// for example. '!' is the same as 33, so you could also use this: +//int thisByte = '!'; + +void loop() { + Restart: + // Wait for the user to press a key + if (!Virgin) goto NextPhase; + while (!Serial.available()) + continue; + + while (Serial.available()) { + junk = Serial.read(); + } + //continue; + NextPhase: + Virgin = false ; + // Prints value unaltered, i.e. the raw binary version of the + // byte. The serial monitor interprets all bytes as + // ASCII, so 33, the first number, will show up as '!' + Serial.print(thisByte, BYTE); + + Serial.print(", dec: "); + // Prints value as string as an ASCII-encoded decimal (base 10). + // Decimal is the default format for Serial.print() and + // Serial.println(), so no modifier is needed: + Serial.print(thisByte); + // But you can declare the modifier for decimal if you want to. + // This also works if you uncomment it: + // Serial.print(thisByte, DEC); + + Serial.print(", hex: "); + // Prints value as string in hexadecimal (base 16): + Serial.print(thisByte, HEX); + + Serial.print(", oct: "); + // Prints value as string in octal (base 8); + Serial.print(thisByte, OCT); + + Serial.print(", bin: "); + // Prints value as string in binary (base 2); also prints ending + // line break: + Serial.println(thisByte, BIN); + + // If printed last visible character '~' or 126, stop: + if (thisByte == 126) { // You could also use if (thisByte == '~') { + thisByte = 33; + Virgin = true; + Serial.println("=============================="); + Serial.println("Press CR to start the printout"); + goto Restart ; + } + // Go on to the next character + thisByte++; +} diff --git a/examples/MrBrunetteExamples/strtol_DecEquivalents/strtol_DecEquivalents.ino b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/strtol_DecEquivalents/strtol_DecEquivalents.ino similarity index 97% rename from examples/MrBrunetteExamples/strtol_DecEquivalents/strtol_DecEquivalents.ino rename to STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/strtol_DecEquivalents/strtol_DecEquivalents.ino index 4507c78..7d799af 100644 --- a/examples/MrBrunetteExamples/strtol_DecEquivalents/strtol_DecEquivalents.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/MrBrunetteExamples/strtol_DecEquivalents/strtol_DecEquivalents.ino @@ -1,41 +1,41 @@ -/* - Modified for Arduino from: http://www.cplusplus.com/reference/cstdlib/strtol/ - Convert string to long integer: Maple Mini version by m. ray burnette: PUBLIC DOMAIN - Sketch uses 13,924 bytes (12%) of program storage space. Maximum is 108,000 bytes. - Global variables use 2,664 bytes of dynamic memory. - Following C++ libs not needed after Arduino 1.0.2 - #include - #include -*/ - -template inline Print &operator <<(Print &obj, T arg) { obj.print(arg); return obj; } - - char szNumbers[] = "2001 60c0c0 -1101110100110100100000 0x6fffff"; - char * pEnd; - long int li1, li2, li3, li4; - -void setup() { - // initialize the digital pin as an output. - pinMode(33, OUTPUT); - Serial.begin(9600); - // wait for serial monitor to be connected. - while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) - { - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - delay(100); // fast blink - } - li1 = strtol (szNumbers,&pEnd,10); // BASE 10 - li2 = strtol (pEnd,&pEnd,16); // HEX - li3 = strtol (pEnd,&pEnd,2); // Binary - li4 = strtol (pEnd,NULL,0); // Integer constant with prefixed base Octal or Hex - // Serial.print ("The decimal equivalents are: %ld, %ld, %ld and %ld.\n", li1, li2, li3, li4); - Serial << "The decimal equivalents are: " << li1 << " " << li2 << " " << li3 << " " << li4; - //return 0; -} - - - -void loop() { - // put your main code here, to run repeatedly: - -} +/* + Modified for Arduino from: http://www.cplusplus.com/reference/cstdlib/strtol/ + Convert string to long integer: Maple Mini version by m. ray burnette: PUBLIC DOMAIN + Sketch uses 13,924 bytes (12%) of program storage space. Maximum is 108,000 bytes. + Global variables use 2,664 bytes of dynamic memory. + Following C++ libs not needed after Arduino 1.0.2 + #include + #include +*/ + +template inline Print &operator <<(Print &obj, T arg) { obj.print(arg); return obj; } + + char szNumbers[] = "2001 60c0c0 -1101110100110100100000 0x6fffff"; + char * pEnd; + long int li1, li2, li3, li4; + +void setup() { + // initialize the digital pin as an output. + pinMode(33, OUTPUT); + Serial.begin(9600); + // wait for serial monitor to be connected. + while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) + { + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + delay(100); // fast blink + } + li1 = strtol (szNumbers,&pEnd,10); // BASE 10 + li2 = strtol (pEnd,&pEnd,16); // HEX + li3 = strtol (pEnd,&pEnd,2); // Binary + li4 = strtol (pEnd,NULL,0); // Integer constant with prefixed base Octal or Hex + // Serial.print ("The decimal equivalents are: %ld, %ld, %ld and %ld.\n", li1, li2, li3, li4); + Serial << "The decimal equivalents are: " << li1 << " " << li2 << " " << li3 << " " << li4; + //return 0; +} + + + +void loop() { + // put your main code here, to run repeatedly: + +} diff --git a/examples/Sensors/Knock/Knock.ino b/STM32F1/libraries/A_STM32_Examples/examples/Sensors/Knock/Knock.ino similarity index 97% rename from examples/Sensors/Knock/Knock.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Sensors/Knock/Knock.ino index 70b8066..3cac24a 100644 --- a/examples/Sensors/Knock/Knock.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/Sensors/Knock/Knock.ino @@ -1,52 +1,52 @@ -/* - Knock Sensor - - This sketch reads a piezo element to detect a knocking sound. It - reads an analog pin and compares the result to a set threshold. If - the result is greater than the threshold, it writes "knock" to the - serial port, and toggles the LED on pin 13. - - The circuit: - * + connection of the piezo attached to analog in 0 - * - connection of the piezo attached to ground - * 1-megohm resistor attached from analog in 0 to ground - - http://www.arduino.cc/en/Tutorial/Knock - - created 25 Mar 2007 - by David Cuartielles - modified 30 Jun 2009 - by Tom Igoe - - Ported to the Maple - by LeafLabs -*/ - -// these constants won't change: -const int knockSensor = 0; // the piezo is connected to analog pin 0 -const int threshold = 100; // threshold value to decide when the detected sound is a knock or not - -// these variables will change: -int sensorReading = 0; // variable to store the value read from the sensor pin - -void setup() { - Serial.begin(115200); // Ignored by Maple. But needed by boards using hardware serial via a USB to Serial adaptor - // Declare the knockSensor as an analog input: - pinMode(knockSensor, INPUT_ANALOG); - // declare the built-in LED pin as an output: - pinMode(33, OUTPUT); -} - -void loop() { - // read the sensor and store it in the variable sensorReading: - sensorReading = analogRead(knockSensor); - - // if the sensor reading is greater than the threshold: - if (sensorReading >= threshold) { - // toggle the built-in LED - digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off - // send the string "Knock!" back to the computer, followed by newline - Serial.println("Knock!"); - } - delay(100); // delay to avoid printing too often -} +/* + Knock Sensor + + This sketch reads a piezo element to detect a knocking sound. It + reads an analog pin and compares the result to a set threshold. If + the result is greater than the threshold, it writes "knock" to the + serial port, and toggles the LED on pin 13. + + The circuit: + * + connection of the piezo attached to analog in 0 + * - connection of the piezo attached to ground + * 1-megohm resistor attached from analog in 0 to ground + + http://www.arduino.cc/en/Tutorial/Knock + + created 25 Mar 2007 + by David Cuartielles + modified 30 Jun 2009 + by Tom Igoe + + Ported to the Maple + by LeafLabs +*/ + +// these constants won't change: +const int knockSensor = 0; // the piezo is connected to analog pin 0 +const int threshold = 100; // threshold value to decide when the detected sound is a knock or not + +// these variables will change: +int sensorReading = 0; // variable to store the value read from the sensor pin + +void setup() { + Serial.begin(115200); // Ignored by Maple. But needed by boards using hardware serial via a USB to Serial adaptor + // Declare the knockSensor as an analog input: + pinMode(knockSensor, INPUT_ANALOG); + // declare the built-in LED pin as an output: + pinMode(33, OUTPUT); +} + +void loop() { + // read the sensor and store it in the variable sensorReading: + sensorReading = analogRead(knockSensor); + + // if the sensor reading is greater than the threshold: + if (sensorReading >= threshold) { + // toggle the built-in LED + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off + // send the string "Knock!" back to the computer, followed by newline + Serial.println("Knock!"); + } + delay(100); // delay to avoid printing too often +} diff --git a/examples/Stubs/AnalogReadPWMWrite/AnalogReadPWMWrite.ino b/STM32F1/libraries/A_STM32_Examples/examples/Stubs/AnalogReadPWMWrite/AnalogReadPWMWrite.ino similarity index 100% rename from examples/Stubs/AnalogReadPWMWrite/AnalogReadPWMWrite.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Stubs/AnalogReadPWMWrite/AnalogReadPWMWrite.ino diff --git a/examples/Stubs/AnalogReadSerial/AnalogReadSerial.ino b/STM32F1/libraries/A_STM32_Examples/examples/Stubs/AnalogReadSerial/AnalogReadSerial.ino similarity index 100% rename from examples/Stubs/AnalogReadSerial/AnalogReadSerial.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Stubs/AnalogReadSerial/AnalogReadSerial.ino diff --git a/examples/Stubs/BareMinumum/BareMinumum.ino b/STM32F1/libraries/A_STM32_Examples/examples/Stubs/BareMinumum/BareMinumum.ino similarity index 100% rename from examples/Stubs/BareMinumum/BareMinumum.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Stubs/BareMinumum/BareMinumum.ino diff --git a/examples/Stubs/DigitalReadSerial/DigitalReadSerial.ino b/STM32F1/libraries/A_STM32_Examples/examples/Stubs/DigitalReadSerial/DigitalReadSerial.ino similarity index 100% rename from examples/Stubs/DigitalReadSerial/DigitalReadSerial.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Stubs/DigitalReadSerial/DigitalReadSerial.ino diff --git a/examples/Stubs/DigitalReadWrite/DigitalReadWrite.ino b/STM32F1/libraries/A_STM32_Examples/examples/Stubs/DigitalReadWrite/DigitalReadWrite.ino similarity index 100% rename from examples/Stubs/DigitalReadWrite/DigitalReadWrite.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Stubs/DigitalReadWrite/DigitalReadWrite.ino diff --git a/examples/Stubs/HelloWorld/HelloWorld.ino b/STM32F1/libraries/A_STM32_Examples/examples/Stubs/HelloWorld/HelloWorld.ino similarity index 100% rename from examples/Stubs/HelloWorld/HelloWorld.ino rename to STM32F1/libraries/A_STM32_Examples/examples/Stubs/HelloWorld/HelloWorld.ino diff --git a/examples/boards.txt b/STM32F1/libraries/A_STM32_Examples/examples/boards.txt similarity index 100% rename from examples/boards.txt rename to STM32F1/libraries/A_STM32_Examples/examples/boards.txt