This library assign registar and send 4bytes data in serial. Auto attachment interruption.
Dependents: WRS_mechanamu_test
Revision 2:ea92ff9abc8c, committed 2018-06-29
- Comitter:
- sgrsn
- Date:
- Fri Jun 29 12:50:08 2018 +0000
- Parent:
- 1:ee6809d3cee3
- Commit message:
- change baudrate
Changed in this revision
PacketSerail.cpp | Show annotated file Show diff for this revision Revisions of this file |
PacketSerial.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r ee6809d3cee3 -r ea92ff9abc8c PacketSerail.cpp --- a/PacketSerail.cpp Fri Jun 29 08:37:27 2018 +0000 +++ b/PacketSerail.cpp Fri Jun 29 12:50:08 2018 +0000 @@ -36,10 +36,10 @@ *********************************************************/ -PacketSerial::PacketSerial(PinName tx, PinName rx, int32_t* registar) : Serial(tx, rx) +PacketSerial::PacketSerial(PinName tx, PinName rx, int32_t* registar, int baudrate) : Serial(tx, rx) { _registar = registar; - Serial::baud(9600); + Serial::baud(baudrate); Serial::attach(this, &PacketSerial::readData, Serial::RxIrq); }
diff -r ee6809d3cee3 -r ea92ff9abc8c PacketSerial.h --- a/PacketSerial.h Fri Jun 29 08:37:27 2018 +0000 +++ b/PacketSerial.h Fri Jun 29 12:50:08 2018 +0000 @@ -9,7 +9,7 @@ class PacketSerial : public Serial { public: - PacketSerial(PinName tx, PinName rx, int32_t* registar); + PacketSerial(PinName tx, PinName rx, int32_t* registar, int baudrate = 115200); void writeData(int32_t data, uint8_t reg); void writeFloatData(float data, uint8_t reg); float getFloatData(uint8_t reg);