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.
main.cpp
00001 #include "mbed.h" 00002 00003 Thread ISRthread(osPriorityAboveNormal); 00004 osThreadId ISRthreadId; 00005 00006 RawSerial pc(USBTX, USBRX); 00007 00008 DigitalOut myled(LED1); 00009 DigitalOut myled4(LED4); 00010 00011 void newInput(); 00012 void ISR_thread(); 00013 00014 int main() { 00015 00016 ISRthread.start(callback(ISR_thread)); 00017 pc.attach(&newInput); //interrupt to catch input 00018 00019 while(1) { 00020 myled4 = 1; 00021 } 00022 } 00023 00024 00025 void newInput() { 00026 pc.attach(NULL); //deatch the ISR to prevent recursive calls 00027 osSignalSet(ISRthreadId,0x01); 00028 } 00029 00030 00031 void ISR_thread() { 00032 ISRthreadId = osThreadGetId(); 00033 for(;;) { 00034 osSignalWait(0x01, osWaitForever); 00035 00036 while (pc.readable()) { 00037 pc.putc(pc.getc()); 00038 } 00039 myled = 1; 00040 osDelay(50); 00041 myled = 0; 00042 pc.attach(&newInput); //re-attach the ISR 00043 } 00044 }
Generated on Thu Jul 21 2022 11:57:19 by
1.7.2