
A simple microwave demo
Dependencies: C12832_lcd LM75B mbed-rtos mbed
rtos_hwk7.cpp
- Committer:
- joeroop
- Date:
- 2014-03-14
- Revision:
- 0:3a19dcea1a01
- Child:
- 1:896789dcc911
File content as of revision 0:3a19dcea1a01:
#include "mbed.h" #include "rtos.h" #include "C12832_lcd.h" //LCD interface #include "LM75B.h" //temperature interface //globals and types DigitalOut led1(LED1); DigitalOut led2(LED2); C12832_LCD lcd; //prototypes //interrupts MemoryPool<bool,10> mpool; //used to hold all messages Queue<bool,10> queue; //used to hold the messages void led1_thread(void const *args); void led2_thread(void const *args); int main(void){ Thread t1(led1_thread); Thread t2(led2_thread); bool start = false; while(1){ bool *val = mpool.alloc(); *val = start; start = !start; queue.put(val); Thread::wait(250); mpool.free(val); } } void led1_thread(void const *args){ while(1){ osEvent evt = queue.get(10); //wait for IPC to post else timeout if(evt.status == osEventMessage){ led1 = !led1; } } } void led2_thread(void const *args){ while(1){ osEvent evt = queue.get(10); //wait for IPC to post else timeout if(evt.status == osEventMessage){ led2 = !led2; } } }