![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
first compiled version
Dependencies: mbed-rtos mbed C12832_lcd LM75B
main.cpp@0:7ae4f23f84a3, 2014-02-26 (annotated)
- Committer:
- nleoni
- Date:
- Wed Feb 26 05:29:44 2014 +0000
- Revision:
- 0:7ae4f23f84a3
- Child:
- 1:83bc9f91d154
RTOS first compile
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nleoni | 0:7ae4f23f84a3 | 1 | #include "mbed.h" |
nleoni | 0:7ae4f23f84a3 | 2 | #include "rtos.h" |
nleoni | 0:7ae4f23f84a3 | 3 | |
nleoni | 0:7ae4f23f84a3 | 4 | AnalogIn pot1(p19); |
nleoni | 0:7ae4f23f84a3 | 5 | Queue<float,10> potReadingQueue; |
nleoni | 0:7ae4f23f84a3 | 6 | |
nleoni | 0:7ae4f23f84a3 | 7 | void lcdUpdate(void const*){ |
nleoni | 0:7ae4f23f84a3 | 8 | while(1){ |
nleoni | 0:7ae4f23f84a3 | 9 | osEvent evt = potReadingQueue.get(); |
nleoni | 0:7ae4f23f84a3 | 10 | if (evt.status == osEventMail) { |
nleoni | 0:7ae4f23f84a3 | 11 | float *queue = (float*)evt.value.p; |
nleoni | 0:7ae4f23f84a3 | 12 | printf("\nVoltage: %.2f V\n\r" , *queue); |
nleoni | 0:7ae4f23f84a3 | 13 | |
nleoni | 0:7ae4f23f84a3 | 14 | Thread::wait(1000); |
nleoni | 0:7ae4f23f84a3 | 15 | } |
nleoni | 0:7ae4f23f84a3 | 16 | } |
nleoni | 0:7ae4f23f84a3 | 17 | } |
nleoni | 0:7ae4f23f84a3 | 18 | |
nleoni | 0:7ae4f23f84a3 | 19 | void readPOT(void const*){ |
nleoni | 0:7ae4f23f84a3 | 20 | while(1){ |
nleoni | 0:7ae4f23f84a3 | 21 | float *queue; |
nleoni | 0:7ae4f23f84a3 | 22 | *queue = pot1; |
nleoni | 0:7ae4f23f84a3 | 23 | potReadingQueue.put(queue); |
nleoni | 0:7ae4f23f84a3 | 24 | |
nleoni | 0:7ae4f23f84a3 | 25 | Thread::wait(10000); |
nleoni | 0:7ae4f23f84a3 | 26 | } |
nleoni | 0:7ae4f23f84a3 | 27 | |
nleoni | 0:7ae4f23f84a3 | 28 | } |
nleoni | 0:7ae4f23f84a3 | 29 | |
nleoni | 0:7ae4f23f84a3 | 30 | void readTemp(void const*){ |
nleoni | 0:7ae4f23f84a3 | 31 | |
nleoni | 0:7ae4f23f84a3 | 32 | } |
nleoni | 0:7ae4f23f84a3 | 33 | |
nleoni | 0:7ae4f23f84a3 | 34 | void threadCookie(void const*){ |
nleoni | 0:7ae4f23f84a3 | 35 | |
nleoni | 0:7ae4f23f84a3 | 36 | } |
nleoni | 0:7ae4f23f84a3 | 37 | |
nleoni | 0:7ae4f23f84a3 | 38 | DigitalOut myled(LED1); |
nleoni | 0:7ae4f23f84a3 | 39 | |
nleoni | 0:7ae4f23f84a3 | 40 | int main() { |
nleoni | 0:7ae4f23f84a3 | 41 | Thread threadLCD(lcdUpdate); |
nleoni | 0:7ae4f23f84a3 | 42 | Thread threadPOT(readPOT); |
nleoni | 0:7ae4f23f84a3 | 43 | Thread threadTemp(readTemp); |
nleoni | 0:7ae4f23f84a3 | 44 | |
nleoni | 0:7ae4f23f84a3 | 45 | while(1) { |
nleoni | 0:7ae4f23f84a3 | 46 | } |
nleoni | 0:7ae4f23f84a3 | 47 | } |