MBED wifi code from oxford repo
Dependencies: mbed
Fork of SerialPassthroughcjsESP8266 by
main.cpp@5:96cb82af9996, 2015-04-30 (annotated)
- Committer:
- sam_grove
- Date:
- Thu Apr 30 22:48:21 2015 +0000
- Revision:
- 5:96cb82af9996
- Parent:
- 4:ba9100d52e48
- Child:
- 6:dc4c165f6b53
Event driven with low power optimizations
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedAustin | 0:59bec1fd956e | 1 | #include "mbed.h" |
mbedAustin | 2:a8dcb07a1d00 | 2 | |
sam_grove | 5:96cb82af9996 | 3 | RawSerial pc(USBTX, USBRX); |
sam_grove | 5:96cb82af9996 | 4 | RawSerial dev(D1, D0); |
sam_grove | 5:96cb82af9996 | 5 | DigitalOut led1(LED1); |
sam_grove | 5:96cb82af9996 | 6 | DigitalOut led4(LED4); |
mbedAustin | 2:a8dcb07a1d00 | 7 | |
sam_grove | 5:96cb82af9996 | 8 | void dev_recv() |
mbedAustin | 2:a8dcb07a1d00 | 9 | { |
sam_grove | 5:96cb82af9996 | 10 | led1 = !led1; |
sam_grove | 5:96cb82af9996 | 11 | while(dev.readable()) { |
sam_grove | 5:96cb82af9996 | 12 | pc.putc(dev.getc()); |
sam_grove | 5:96cb82af9996 | 13 | } |
sam_grove | 5:96cb82af9996 | 14 | } |
sam_grove | 5:96cb82af9996 | 15 | |
sam_grove | 5:96cb82af9996 | 16 | void pc_recv() |
sam_grove | 5:96cb82af9996 | 17 | { |
sam_grove | 5:96cb82af9996 | 18 | led4 = !led4; |
sam_grove | 5:96cb82af9996 | 19 | while(pc.readable()) { |
mbedAustin | 4:ba9100d52e48 | 20 | dev.putc(pc.getc()); |
mbedAustin | 0:59bec1fd956e | 21 | } |
mbedAustin | 0:59bec1fd956e | 22 | } |
mbedAustin | 4:ba9100d52e48 | 23 | |
mbedAustin | 4:ba9100d52e48 | 24 | int main() |
mbedAustin | 4:ba9100d52e48 | 25 | { |
mbedAustin | 4:ba9100d52e48 | 26 | pc.baud(9600); |
mbedAustin | 4:ba9100d52e48 | 27 | dev.baud(9600); |
mbedAustin | 4:ba9100d52e48 | 28 | |
sam_grove | 5:96cb82af9996 | 29 | pc.attach(&pc_recv, Serial::RxIrq); |
sam_grove | 5:96cb82af9996 | 30 | dev.attach(&dev_recv, Serial::RxIrq); |
sam_grove | 5:96cb82af9996 | 31 | |
mbedAustin | 4:ba9100d52e48 | 32 | while(1) { |
sam_grove | 5:96cb82af9996 | 33 | sleep(); |
mbedAustin | 4:ba9100d52e48 | 34 | } |
mbedAustin | 4:ba9100d52e48 | 35 | } |