xx
RoboClaw.h@0:af5cf35e1a25, 2015-11-16 (annotated)
- Committer:
- sype
- Date:
- Mon Nov 16 11:32:35 2015 +0000
- Revision:
- 0:af5cf35e1a25
- Child:
- 1:f76058f9f548
oklm
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sype | 0:af5cf35e1a25 | 1 | #ifndef ROBOCLAW_H |
sype | 0:af5cf35e1a25 | 2 | #define ROBOCLAW_H |
sype | 0:af5cf35e1a25 | 3 | #include "mbed.h" |
sype | 0:af5cf35e1a25 | 4 | #include "registers.h" |
sype | 0:af5cf35e1a25 | 5 | |
sype | 0:af5cf35e1a25 | 6 | /** |
sype | 0:af5cf35e1a25 | 7 | * |
sype | 0:af5cf35e1a25 | 8 | */ |
sype | 0:af5cf35e1a25 | 9 | |
sype | 0:af5cf35e1a25 | 10 | class RoboClaw |
sype | 0:af5cf35e1a25 | 11 | { |
sype | 0:af5cf35e1a25 | 12 | public: |
sype | 0:af5cf35e1a25 | 13 | RoboClaw(int baudrate, PinName rx, PinName tx); |
sype | 0:af5cf35e1a25 | 14 | |
sype | 0:af5cf35e1a25 | 15 | void ForwardM1(unsigned char address, int speed); |
sype | 0:af5cf35e1a25 | 16 | void BackwardM1(unsigned char address, int speed); |
sype | 0:af5cf35e1a25 | 17 | void ForwardM2(unsigned char address, int speed); |
sype | 0:af5cf35e1a25 | 18 | void BackwardM2(unsigned char address, int speed); |
sype | 0:af5cf35e1a25 | 19 | |
sype | 0:af5cf35e1a25 | 20 | void Forward(unsigned char address, int speed); |
sype | 0:af5cf35e1a25 | 21 | void Backward(unsigned char address, int speed); |
sype | 0:af5cf35e1a25 | 22 | |
sype | 0:af5cf35e1a25 | 23 | void ReadFirm(unsigned char address); |
sype | 0:af5cf35e1a25 | 24 | |
sype | 0:af5cf35e1a25 | 25 | long ReadEncM1(unsigned char address); |
sype | 0:af5cf35e1a25 | 26 | long ReadEncM2(unsigned char address); |
sype | 0:af5cf35e1a25 | 27 | long ReadSpeedM1(unsigned char address); |
sype | 0:af5cf35e1a25 | 28 | long ReadSpeedM2(unsigned char address); |
sype | 0:af5cf35e1a25 | 29 | |
sype | 0:af5cf35e1a25 | 30 | void ResetEnc(unsigned char address); |
sype | 0:af5cf35e1a25 | 31 | |
sype | 0:af5cf35e1a25 | 32 | void SpeedM1(unsigned char address, long speed); |
sype | 0:af5cf35e1a25 | 33 | void SpeedM2(unsigned char address, long speed); |
sype | 0:af5cf35e1a25 | 34 | void SpeedAccelM1(unsigned char address, long accel, long speed); |
sype | 0:af5cf35e1a25 | 35 | void SpeedAccelM2(unsigned char address, long accel, long speed); |
sype | 0:af5cf35e1a25 | 36 | void SpeedDistanceM1(unsigned char address, long speed, unsigned long distance, unsigned char buffer); |
sype | 0:af5cf35e1a25 | 37 | void SpeedDistanceM2(unsigned char address, long speed, unsigned long distance, unsigned char buffer); |
sype | 0:af5cf35e1a25 | 38 | void SpeedAccelDistanceM1(unsigned char address, long accel, long speed, unsigned long distance, unsigned char buffer); |
sype | 0:af5cf35e1a25 | 39 | void SpeedAccelDistanceM2(unsigned char address, long accel, long speed, unsigned long distance, unsigned char buffer); |
sype | 0:af5cf35e1a25 | 40 | void SpeedAccelDeccelPositionM1(unsigned char address, unsigned long accel, long speed, unsigned long deccel, unsigned long position, unsigned char flag); |
sype | 0:af5cf35e1a25 | 41 | void SpeedAccelDeccelPositionM2(unsigned char address, unsigned long accel, long speed, unsigned long deccel, unsigned long position, unsigned char flag); |
sype | 0:af5cf35e1a25 | 42 | |
sype | 0:af5cf35e1a25 | 43 | private: |
sype | 0:af5cf35e1a25 | 44 | Serial _roboclaw; |
sype | 0:af5cf35e1a25 | 45 | unsigned int crc; |
sype | 0:af5cf35e1a25 | 46 | void crc_clear(); |
sype | 0:af5cf35e1a25 | 47 | void crc_update(unsigned char data); |
sype | 0:af5cf35e1a25 | 48 | unsigned int crc_get(); |
sype | 0:af5cf35e1a25 | 49 | |
sype | 0:af5cf35e1a25 | 50 | void write_n(unsigned char cnt, ...); |
sype | 0:af5cf35e1a25 | 51 | void write_(unsigned char address, unsigned char command, unsigned char data, bool reading, bool crcon); |
sype | 0:af5cf35e1a25 | 52 | |
sype | 0:af5cf35e1a25 | 53 | unsigned int crc16(unsigned char *packet, int nBytes); |
sype | 0:af5cf35e1a25 | 54 | unsigned char read_(void); |
sype | 0:af5cf35e1a25 | 55 | }; |
sype | 0:af5cf35e1a25 | 56 | |
sype | 0:af5cf35e1a25 | 57 | #endif |