Serial library for Ususama
Dependents: ususama_serial_demo WRS2021_mecanum_driver
ususama_serial.h@0:a0ec74fb2cb0, 2021-08-20 (annotated)
- Committer:
- sgrsn
- Date:
- Fri Aug 20 08:27:30 2021 +0000
- Revision:
- 0:a0ec74fb2cb0
- Child:
- 1:33d6c6f43306
make write and read
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sgrsn | 0:a0ec74fb2cb0 | 1 | #ifndef USUSAMA_SERIAL_H |
sgrsn | 0:a0ec74fb2cb0 | 2 | #define USUSAMA_SERIAL_H |
sgrsn | 0:a0ec74fb2cb0 | 3 | #include "mbed.h" |
sgrsn | 0:a0ec74fb2cb0 | 4 | #include <vector> |
sgrsn | 0:a0ec74fb2cb0 | 5 | |
sgrsn | 0:a0ec74fb2cb0 | 6 | #define HEAD_BYTE 0x1D |
sgrsn | 0:a0ec74fb2cb0 | 7 | #define READ_COMMAND 0xFF |
sgrsn | 0:a0ec74fb2cb0 | 8 | #define ESCAPE_BYTE 0x1E |
sgrsn | 0:a0ec74fb2cb0 | 9 | #define ESCAPE_MASK 0x1F |
sgrsn | 0:a0ec74fb2cb0 | 10 | |
sgrsn | 0:a0ec74fb2cb0 | 11 | class UsusamaSerial |
sgrsn | 0:a0ec74fb2cb0 | 12 | { |
sgrsn | 0:a0ec74fb2cb0 | 13 | public: |
sgrsn | 0:a0ec74fb2cb0 | 14 | UsusamaSerial(PinName tx, PinName rx, int32_t* registar, int baudrate = 115200); |
sgrsn | 0:a0ec74fb2cb0 | 15 | void set_bufferedserial(int baudrate); |
sgrsn | 0:a0ec74fb2cb0 | 16 | void set_unbufferedserial(int baudrate); |
sgrsn | 0:a0ec74fb2cb0 | 17 | void writeData(int32_t data, uint8_t reg); |
sgrsn | 0:a0ec74fb2cb0 | 18 | void readData(); |
sgrsn | 0:a0ec74fb2cb0 | 19 | private: |
sgrsn | 0:a0ec74fb2cb0 | 20 | |
sgrsn | 0:a0ec74fb2cb0 | 21 | int32_t* _register; |
sgrsn | 0:a0ec74fb2cb0 | 22 | char buffer_w_[64]; |
sgrsn | 0:a0ec74fb2cb0 | 23 | char buffer_r_[64]; |
sgrsn | 0:a0ec74fb2cb0 | 24 | //UnbufferedSerial port_; |
sgrsn | 0:a0ec74fb2cb0 | 25 | BufferedSerial port_; |
sgrsn | 0:a0ec74fb2cb0 | 26 | }; |
sgrsn | 0:a0ec74fb2cb0 | 27 | |
sgrsn | 0:a0ec74fb2cb0 | 28 | #endif |