This library assign registar and send 4bytes data in serial. Auto attachment interruption.
Dependents: WRS_mechanamu_test
PacketSerial.h@2:ea92ff9abc8c, 2018-06-29 (annotated)
- Committer:
- sgrsn
- Date:
- Fri Jun 29 12:50:08 2018 +0000
- Revision:
- 2:ea92ff9abc8c
- Parent:
- 0:56fce4868747
change baudrate
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sgrsn | 0:56fce4868747 | 1 | #ifndef SERIAL_H |
sgrsn | 0:56fce4868747 | 2 | #define SERIAL_H |
sgrsn | 0:56fce4868747 | 3 | #include "mbed.h" |
sgrsn | 0:56fce4868747 | 4 | |
sgrsn | 0:56fce4868747 | 5 | #define HEAD_BYTE 0x7E |
sgrsn | 0:56fce4868747 | 6 | #define ESCAPE_BYTE 0x7D |
sgrsn | 0:56fce4868747 | 7 | #define ESCAPE_MASK 0x20 |
sgrsn | 0:56fce4868747 | 8 | |
sgrsn | 0:56fce4868747 | 9 | class PacketSerial : public Serial |
sgrsn | 0:56fce4868747 | 10 | { |
sgrsn | 0:56fce4868747 | 11 | public: |
sgrsn | 2:ea92ff9abc8c | 12 | PacketSerial(PinName tx, PinName rx, int32_t* registar, int baudrate = 115200); |
sgrsn | 0:56fce4868747 | 13 | void writeData(int32_t data, uint8_t reg); |
sgrsn | 0:56fce4868747 | 14 | void writeFloatData(float data, uint8_t reg); |
sgrsn | 0:56fce4868747 | 15 | float getFloatData(uint8_t reg); |
sgrsn | 0:56fce4868747 | 16 | |
sgrsn | 0:56fce4868747 | 17 | private: |
sgrsn | 0:56fce4868747 | 18 | void readData(); |
sgrsn | 0:56fce4868747 | 19 | int32_t* _registar; |
sgrsn | 0:56fce4868747 | 20 | }; |
sgrsn | 0:56fce4868747 | 21 | |
sgrsn | 0:56fce4868747 | 22 | #endif |