Instead of using an interrupt to read a serial message, a thread is created within the interrupt that reads serial data coming in. Original project for LPC1768.
Revision 0:f28b116a2be0, committed 2019-03-05
- Comitter:
- Ritzerk
- Date:
- Tue Mar 05 12:16:33 2019 +0000
- Child:
- 1:5438da9e6654
- Commit message:
- RTOS Interrupt as Thread
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Mar 05 12:16:33 2019 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+
+InterruptIn button(p14);
+
+Thread ISRthread(osPriorityAboveNormal);
+osThreadId ISRthreadId;
+
+DigitalOut myled(LED1);
+DigitalOut myled3(LED3);
+
+void newInput();
+void ISR_thread();
+
+int main() {
+
+ ISRthread.start(callback(ISR_thread));
+ button.rise(&newInput); //interrupt to catch input
+
+ while(1) {
+ myled = 1;
+ osDelay(1000);
+ myled = 0;
+ osDelay(1000);
+ }
+}
+
+
+void newInput() {
+ osSignalSet(ISRthreadId,0x01);
+}
+
+
+void ISR_thread() {
+ ISRthreadId = osThreadGetId();
+ for(;;) {
+ osSignalWait(0x01, osWaitForever);
+ myled3 = 1;
+ osDelay(500);
+ myled3 = 0;
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Tue Mar 05 12:16:33 2019 +0000 @@ -0,0 +1,1 @@ +https://github.com/armmbed/mbed-os/#ecb3c8c837162c73537bd0f3592c6e2a42994045