MDX-15,20の制御用library
Revision 1:1751fee99a0d, committed 2016-10-15
- Comitter:
- suupen
- Date:
- Sat Oct 15 23:32:34 2016 +0000
- Parent:
- 0:46f110f747c6
- Child:
- 2:8446eb1774c4
- Commit message:
- library?????????
Changed in this revision
MDX20.cpp | Show annotated file Show diff for this revision Revisions of this file |
MDX20.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MDX20.cpp Sat Oct 15 22:23:18 2016 +0000 +++ b/MDX20.cpp Sat Oct 15 23:32:34 2016 +0000 @@ -0,0 +1,41 @@ +#include "MDX20.h" +#include "BufferedSerial.h" + + +MDX20::MDX20(PinName tx, PinName rx, PinName cts) : _serial(tx, rx), _cts(cts, PullUp) +{ + + _serial.baud(9600); + _serial.format(8,Serial::None,1); +} + +MDX20::~MDX20() +{ +} + +/** +* MDX-15/20へのデータ送信 +* @@para *data : データ一行の先頭アドレス +* @@para uint8_t : 0:送信キャンセル 1:送信完了 +*/ +uint8_t MDX20::sendData(char* data) +{ + uint8_t ans = 0; // 0:送信キャンセル 1:送信完了 + + if(_cts == 0) { + wait(0.1); // このwait timeがないとMDX-20からのwait指示を読み飛ばす + printf("%s\r\n",data); + _serial.printf("%s\r\n",data); + ans = 1; + } else { + // nothing + } + return (ans); +} + +int MDX20::putc(int c) +{ + _serial.putc(c); + return c; +} +
--- a/MDX20.h Sat Oct 15 22:23:18 2016 +0000 +++ b/MDX20.h Sat Oct 15 23:32:34 2016 +0000 @@ -0,0 +1,24 @@ +#ifndef MBED_MDX20_H +#define MBED_MDX20_H + +#include "mbed.h" +#include "BufferedSerial.h" +class MDX20 +{ +public: + MDX20(PinName tx, PinName rx, PinName cts); + + ~MDX20(); + + uint8_t sendData(char* data); + + int putc(int c); + +private: + BufferedSerial _serial; // tx, rx(NC) + DigitalIn _cts; + + char B_masterTx[0xff]; +}; + +#endif // MBED_MDX20_H \ No newline at end of file