Skip to content

Repository files navigation

💾 107-Arduino-CriticalSection

Arduino Library BadgeCompile ExamplesArduino Lintkeywords.txt ChecksGeneral Formatting ChecksSpell Check

This library provides a consistent critical section interface over various Arduino platforms.

This library works for

Example

#include<107-Arduino-CriticalSection.h>volatileint button_evt_counter = 0;
voidsetup() {
Serial.begin(9600);
while (!Serial) { }
attachInterrupt(0, onButton_1_Pressed, RISING);
attachInterrupt(1, onButton_2_Pressed, RISING);
}
voidloop() {
int copy_button_evt_counter;
{
/* Prevent change of button_evt_counter during readout. */
CriticalSection crit_sec;
copy_button_evt_counter = button_evt_counter;
}
Serial.println(copy_button_evt_counter);
}
voidonButton_1_Pressed() {
CriticalSection crit_sec;
button_evt_counter++;
}
voidonButton_2_Pressed() {
CriticalSection crit_sec;
button_evt_counter++;
}

About

Arduino library for providing a consistent critical section interface over various Arduino platforms.

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages