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.
Fork of IM920_sample by
Diff: main.cpp
- Revision:
- 0:512667e240df
- Child:
- 1:0deed3031dfc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Dec 26 15:51:58 2014 +0000 @@ -0,0 +1,42 @@ +#include "mbed.h" +#include "IM920.h" + +DigitalOut myled(LED1); +Serial pc(USBTX, USBRX); +IM920 im920(p28, p27, p29); + +void callback () { + int i; + char buf[65]; + + i = im920.recv(buf, 64); + buf[i] = 0; + printf("recv: '%s' (%d)\r\n", buf, i); +} + +int main() { + int i = 0; + char buf[65]; + + pc.baud(115200); + pc.printf("*** IM920\r\n"); + im920.init(10, callback); + myled = 1; + + for (;;) { + im920.poll(); + if (pc.readable()) { + char c = pc.getc(); + if (c == '\r') { + buf[i] = 0; + printf("send: %s\r\n", buf); + im920.send(buf, i); + i = 0; + } else + if (i < 64) { + buf[i] = c; + i ++; + } + } + } +}