sample K64F program using the RTOS (fully updated + Mbed sdk updated) with EthernetInterface added
Dependencies: EthernetInterface mbed-rtos mbed
Revision 0:12187df41036, committed 2014-12-13
- Comitter:
- ansond
- Date:
- Sat Dec 13 23:37:15 2014 +0000
- Commit message:
- updated
Changed in this revision
diff -r 000000000000 -r 12187df41036 EthernetInterface.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Sat Dec 13 23:37:15 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/EthernetInterface/#de796e2a5e98
diff -r 000000000000 -r 12187df41036 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Dec 13 23:37:15 2014 +0000 @@ -0,0 +1,43 @@ +#include "mbed.h" +#include "rtos.h" + +DigitalOut led1(LED1); +InterruptIn sw2(SW2); +uint32_t button_pressed; +Thread *thread2; + +void sw2_press(void) +{ + thread2->signal_set(0x1); +} + +void led_thread(void const *argument) +{ + while (true) { + led1 = !led1; + Thread::wait(1000); + } +} + +void button_thread(void const *argument) +{ + while (true) { + Thread::signal_wait(0x1); + button_pressed++; + } +} + +int main() +{ + Thread thread(led_thread); + thread2 = new Thread(button_thread); + + button_pressed = 0; + sw2.fall(&sw2_press); + while (true) { + Thread::wait(5000); + printf("SW2 was pressed (last 5 seconds): %d \n", button_pressed); + fflush(stdout); + button_pressed = 0; + } +}
diff -r 000000000000 -r 12187df41036 mbed-rtos.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Sat Dec 13 23:37:15 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#f1ef95efa5ad
diff -r 000000000000 -r 12187df41036 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Dec 13 23:37:15 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file