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 2015robot_main by
Diff: communicate.h
- Revision:
- 67:658a54be9212
- Parent:
- 59:9d66edf3e734
--- a/communicate.h Wed Oct 07 09:01:34 2015 +0000 +++ b/communicate.h Wed Oct 07 09:03:55 2015 +0000 @@ -7,6 +7,7 @@ inline void initializeRS485(){ RS485.format(8,Serial::Even); } +/* inline void sendData(int address, int data5) { unsigned int data; if (data5 <= 31) { @@ -14,6 +15,22 @@ RS485.putc(data); } } +*/ +inline void sendData(int address, unsigned int data8) { + int i; + unsigned int data; + if (data8 <= 15) { + data = (1 << 7) | (address << 4) | (data8 & 15); + RS485.putc(data); + } + else if (data8 <= 255) { + data = (i << 7) | (address << 4) | (data8 >> 4); + RS485.putc(data); + wait(0.0001); + data = (1 << 7) | (address << 4) | (data8 & 15); + RS485.putc(data); + } +} #ifdef IM920 /***IM920 Communication.***/