xx

Committer:
sype
Date:
Tue Nov 24 15:01:49 2015 +0000
Revision:
1:f76058f9f548
Parent:
0:af5cf35e1a25
Child:
2:a2c141d922b3
GotoThet

Who changed what in which revision?

UserRevisionLine numberNew 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 1:f76058f9f548 40 void SpeedAccelDeccelPositionM1(unsigned char address, unsigned long accel, long speed, unsigned long deccel, long position, unsigned char flag);
sype 1:f76058f9f548 41 void SpeedAccelDeccelPositionM2(unsigned char address, unsigned long accel, long speed, unsigned long deccel, long position, unsigned char flag);
sype 1:f76058f9f548 42 void SpeedAccelDeccelPositionM1M2(unsigned char address,unsigned long accel1,unsigned long speed1,unsigned long deccel1, long position1,unsigned long accel2,unsigned long speed2,unsigned long deccel2, long position2,unsigned char flag);
sype 0:af5cf35e1a25 43
sype 0:af5cf35e1a25 44 private:
sype 0:af5cf35e1a25 45 Serial _roboclaw;
sype 0:af5cf35e1a25 46 unsigned int crc;
sype 0:af5cf35e1a25 47 void crc_clear();
sype 0:af5cf35e1a25 48 void crc_update(unsigned char data);
sype 0:af5cf35e1a25 49 unsigned int crc_get();
sype 0:af5cf35e1a25 50
sype 0:af5cf35e1a25 51 void write_n(unsigned char cnt, ...);
sype 0:af5cf35e1a25 52 void write_(unsigned char address, unsigned char command, unsigned char data, bool reading, bool crcon);
sype 0:af5cf35e1a25 53
sype 0:af5cf35e1a25 54 unsigned int crc16(unsigned char *packet, int nBytes);
sype 0:af5cf35e1a25 55 unsigned char read_(void);
sype 0:af5cf35e1a25 56 };
sype 0:af5cf35e1a25 57
sype 0:af5cf35e1a25 58 #endif