Supachai Vorapojpisut
/
le484_2016
Course project for LE484 at Thammasat University, class of 2016
main.cpp@11:8b9668e37646, 2017-05-08 (annotated)
- Committer:
- natanich
- Date:
- Mon May 08 05:06:11 2017 +0000
- Revision:
- 11:8b9668e37646
- Parent:
- 6:da3c4393efee
- Child:
- 12:845639da2f03
led_task
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vsupacha | 0:aefb68fd2505 | 1 | /** |
vsupacha | 0:aefb68fd2505 | 2 | * @brief Main loop: XBee protocol handler |
natanich | 2:d117505b89ce | 3 | * @author Supachai Vorapojpisut,Vissarut Prakobpon , Natanich Bunsila |
vsupacha | 0:aefb68fd2505 | 4 | * @date May 8, 2017 |
vsupacha | 0:aefb68fd2505 | 5 | */ |
vsupacha | 0:aefb68fd2505 | 6 | |
vsupacha | 0:aefb68fd2505 | 7 | #include "mbed.h" |
vsupacha | 5:d35cd42da2ac | 8 | #include "platform.h" |
vsupacha | 0:aefb68fd2505 | 9 | |
vsupacha | 0:aefb68fd2505 | 10 | |
vsupacha | 3:e38819a2b38c | 11 | RawSerial pc(USBTX, USBRX); // use USB-serial for testing purpose |
vsupacha | 3:e38819a2b38c | 12 | Mail<char, 2> mbx; // use Mail API to forward data |
natanich | 11:8b9668e37646 | 13 | Thread ledThred; |
natanich | 11:8b9668e37646 | 14 | |
vsupacha | 3:e38819a2b38c | 15 | |
vsupacha | 3:e38819a2b38c | 16 | /** |
vsupacha | 3:e38819a2b38c | 17 | * @brief ISR code: reception of XBee API frame |
vsupacha | 3:e38819a2b38c | 18 | */ |
vsupacha | 3:e38819a2b38c | 19 | void rxHandler() { |
vsupacha | 3:e38819a2b38c | 20 | char *mail = mbx.alloc(); |
vsupacha | 3:e38819a2b38c | 21 | *mail = pc.getc(); |
vsupacha | 3:e38819a2b38c | 22 | mbx.put(mail); |
vsupacha | 3:e38819a2b38c | 23 | } |
vsupacha | 3:e38819a2b38c | 24 | |
vsupacha | 3:e38819a2b38c | 25 | |
vsupacha | 3:e38819a2b38c | 26 | /** |
vsupacha | 3:e38819a2b38c | 27 | * @brief Main code: initial serial RX handler, then wait for detected frame |
vsupacha | 3:e38819a2b38c | 28 | */ |
vsupacha | 0:aefb68fd2505 | 29 | int main() { |
natanich | 11:8b9668e37646 | 30 | ledThread.start(led1_thread); |
natanich | 11:8b9668e37646 | 31 | while(1); |
vsupacha | 0:aefb68fd2505 | 32 | } |
vsupacha | 0:aefb68fd2505 | 33 |