Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 2:20e71c579204
- Parent:
- 1:58d6707580cb
- Child:
- 3:6cc7d6600a30
--- a/main.cpp Tue Jan 05 17:00:56 2016 +0000
+++ b/main.cpp Tue Jan 05 17:38:13 2016 +0000
@@ -17,7 +17,8 @@
DigitalOut red_led(LED_RED);
// flag - must be volatile as changes within ISR
-volatile int sw2_flag = 0;
+// g_ prefix makes it easier to distinguish it as global
+volatile int g_sw2_flag = 0;
// function prototypes
void sw2_isr();
@@ -37,8 +38,8 @@
while (1) {
// check if flag i.e. interrupt has occured
- if (sw2_flag) {
- sw2_flag = 0; // if it has, clear the flag
+ if (g_sw2_flag) {
+ g_sw2_flag = 0; // if it has, clear the flag
// DO TASK HERE
}
@@ -52,5 +53,5 @@
// SW2 event-triggered interrupt
void sw2_isr()
{
- sw2_flag = 1; // set flag in ISR
+ g_sw2_flag = 1; // set flag in ISR
}