Course project for LE484 at Thammasat University, class of 2016

Committer:
vsupacha
Date:
Mon May 08 05:11:22 2017 +0000
Revision:
12:845639da2f03
Fix wrong code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vsupacha 12:845639da2f03 1 /**
vsupacha 12:845639da2f03 2 * @brief Main loop: XBee protocol handler
vsupacha 12:845639da2f03 3 * @author Supachai Vorapojpisut,Vissarut Prakobpon , Natanich Bunsila
vsupacha 12:845639da2f03 4 * @date May 8, 2017
vsupacha 12:845639da2f03 5 */
vsupacha 12:845639da2f03 6
vsupacha 12:845639da2f03 7 #include "mbed.h"
vsupacha 12:845639da2f03 8 #include "platform.h"
vsupacha 12:845639da2f03 9
vsupacha 12:845639da2f03 10
vsupacha 12:845639da2f03 11 RawSerial pc(USBTX, USBRX); // use USB-serial for testing purpose
vsupacha 12:845639da2f03 12 Mail<char, 2> mbx; // use Mail API to forward data
vsupacha 12:845639da2f03 13 Thread ledThred;
vsupacha 12:845639da2f03 14
vsupacha 12:845639da2f03 15
vsupacha 12:845639da2f03 16 /**
vsupacha 12:845639da2f03 17 * @brief ISR code: reception of XBee API frame
vsupacha 12:845639da2f03 18 */
vsupacha 12:845639da2f03 19 void rxHandler() {
vsupacha 12:845639da2f03 20 char *mail = mbx.alloc();
vsupacha 12:845639da2f03 21 *mail = pc.getc();
vsupacha 12:845639da2f03 22 mbx.put(mail);
vsupacha 12:845639da2f03 23 }
vsupacha 12:845639da2f03 24
vsupacha 12:845639da2f03 25
vsupacha 12:845639da2f03 26 /**
vsupacha 12:845639da2f03 27 * @brief Main code: initial serial RX handler, then wait for detected frame
vsupacha 12:845639da2f03 28 */
vsupacha 12:845639da2f03 29 int main() {
vsupacha 12:845639da2f03 30 ledThread.start(led1_thread);
vsupacha 12:845639da2f03 31 while(1);
vsupacha 12:845639da2f03 32 }
vsupacha 12:845639da2f03 33