Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- vsupacha
- Date:
- 2017-05-08
- Revision:
- 3:e38819a2b38c
- Parent:
- 2:d117505b89ce
- Child:
- 4:3aaedd16c77b
File content as of revision 3:e38819a2b38c:
/**
* @brief Main loop: XBee protocol handler
* @author Supachai Vorapojpisut,Vissarut Prakobpon , Natanich Bunsila
* @date May 8, 2017
*/
#include "mbed.h"
DigitalOut led1(LED1);
RawSerial pc(USBTX, USBRX); // use USB-serial for testing purpose
Mail<char, 2> mbx; // use Mail API to forward data
/**
* @brief ISR code: reception of XBee API frame
*/
void rxHandler() {
char *mail = mbx.alloc();
*mail = pc.getc();
mbx.put(mail);
}
/**
* @brief Main code: initial serial RX handler, then wait for detected frame
*/
int main() {
pc.attach(rxHandler);
while (true) {
osEvent evt = mbx.get();
if (evt.status == osEventMail) {
char *mail = (mail_t*)evt.value.p;
pc.printf("Got %c\n", *mail);
mbx.free(mail);
}
}
}
