MX-12W Servo Library

Dependents:   DISCO_L475VG_IOT01-Sensors-BSP

Committer:
tsoul
Date:
Fri Dec 11 09:38:58 2020 +0000
Revision:
2:b4d4c281f174
Parent:
1:d0c3878f77ee
Child:
3:513956de75d7
Add GetStatus method

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tsoul 0:5e5d94ac9c80 1 #ifndef MBED_MX12_H
tsoul 0:5e5d94ac9c80 2 #define MBED_MX12_H
tsoul 0:5e5d94ac9c80 3
tsoul 0:5e5d94ac9c80 4 #include "mbed.h"
tsoul 0:5e5d94ac9c80 5
tsoul 1:d0c3878f77ee 6 #define MX12_ANSWER_MAX_SIZE 32
tsoul 1:d0c3878f77ee 7
tsoul 0:5e5d94ac9c80 8 class MX12 {
tsoul 0:5e5d94ac9c80 9 public:
tsoul 2:b4d4c281f174 10 enum Status {
tsoul 2:b4d4c281f174 11 InstructionError,
tsoul 2:b4d4c281f174 12 OverloadError,
tsoul 2:b4d4c281f174 13 ChecksumError,
tsoul 2:b4d4c281f174 14 RangeError,
tsoul 2:b4d4c281f174 15 OverheatingError,
tsoul 2:b4d4c281f174 16 AngleLimitError,
tsoul 2:b4d4c281f174 17 InputVoltageError,
tsoul 2:b4d4c281f174 18 Unknown,
tsoul 2:b4d4c281f174 19 Ok
tsoul 2:b4d4c281f174 20 };
tsoul 2:b4d4c281f174 21
tsoul 0:5e5d94ac9c80 22 MX12(PinName tx, PinName rx, int baud=115200);
tsoul 0:5e5d94ac9c80 23
tsoul 0:5e5d94ac9c80 24 void SetSpeed(unsigned char mot_id, float speed);
tsoul 2:b4d4c281f174 25 MX12::Status GetStatus();
tsoul 1:d0c3878f77ee 26 void PrintAnswer();
tsoul 0:5e5d94ac9c80 27
tsoul 1:d0c3878f77ee 28 void rw(unsigned char mot_id, char adress, char len, char *data);
tsoul 1:d0c3878f77ee 29
tsoul 1:d0c3878f77ee 30 void _ReadCallback();
tsoul 0:5e5d94ac9c80 31
tsoul 0:5e5d94ac9c80 32 private:
tsoul 0:5e5d94ac9c80 33 UnbufferedSerial _mx12;
tsoul 2:b4d4c281f174 34 MX12::Status _status;
tsoul 1:d0c3878f77ee 35
tsoul 1:d0c3878f77ee 36 char _res[MX12_ANSWER_MAX_SIZE];
tsoul 1:d0c3878f77ee 37 char _res_count;
tsoul 0:5e5d94ac9c80 38 int _baud;
tsoul 0:5e5d94ac9c80 39 };
tsoul 0:5e5d94ac9c80 40
tsoul 0:5e5d94ac9c80 41 #endif /* MBED_MX12_H */