Skip to content

Move examples #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@
This example demonstrates how to use millis() and micros()
*/

void setup() {
void setup()
{

Serial.begin(9600);

while(!Serial){}; //Wait for user to open terminal window
while (!Serial)
{
}; //Wait for user to open terminal window

Serial.println("SparkFun Arduino Apollo3 STimer Example");
Serial.println("SparkFun Arduino Apollo3 Delay Example");
Serial.printf("Compiled on %s, %s\n\n", __DATE__, __TIME__);
}

void loop()
{
Serial.printf("Sec: %d, millis: %d, micros: %d, systicks: 0x%08X, sysoverflows: 0x%08X\n", secs(), millis(), micros(), systicks(), sysoverflows());
delay(1111); //Arbitrary delay
}

delay(1111); //Arbitrary millisecond delay

delayMicroseconds(50); //Arbitrary microsecond delay
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,48 @@ The edge-based interrupts will clear the flag automatically.
static uint32_t count = 0;
bool interruptsEnabled = false;

void setup() {
void setup()
{
// put your setup code here, to run once:

Serial.begin(9600);
Serial.println("Interrupt testing");

pinMode(INT_PIN, INPUT_PULLUP);

attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, RISING);
// attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, FALLING);
// attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, LOW);
// attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, HIGH);
// attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, FALLING);
// attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, LOW);
// attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, HIGH);
// attachInterrupt(digitalPinToInterrupt(INT_PIN), myISR, CHANGE);

// // attaching a different interrupt to the same pin overwrites the existing ISR
// attachInterruptArg(digitalPinToInterrupt(INT_PIN), myISRArg, &count, RISING);
// // attaching a different interrupt to the same pin overwrites the existing ISR
// attachInterruptArg(digitalPinToInterrupt(INT_PIN), myISRArg, &count, RISING);

interruptsEnabled = true;
}

void loop() {
void loop()
{
count++;
if( count > 5 ){
if(interruptsEnabled){
if (count > 5)
{
if (interruptsEnabled)
{
detachInterrupt(digitalPinToInterrupt(INT_PIN));
interruptsEnabled = false;
}
}
delay(1000);
}

void myISR( void ){
void myISR(void)
{
Serial.println("Hi i am an ISR!");
}

void myISRArg( void* arg ){
uint32_t* local_count = (uint32_t*)arg;
Serial.printf("The time is %d seconds\n", *(local_count) );
void myISRArg(void *arg)
{
uint32_t *local_count = (uint32_t *)arg;
Serial.printf("The time is %d seconds\n", *(local_count));
}