v1
Fork of Fork_Boss_Communication_Robot by
protocol.h@0:0c88691e3904, 2015-03-01 (annotated)
- Committer:
- soulx
- Date:
- Sun Mar 01 06:28:01 2015 +0000
- Revision:
- 0:0c88691e3904
- Child:
- 2:56c1de1612dd
create lib communication for robot
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
soulx | 0:0c88691e3904 | 1 | #ifndef ANDANTE_PROTOCOL_H |
soulx | 0:0c88691e3904 | 2 | #define ANDANTE_PROTOCOL_H |
soulx | 0:0c88691e3904 | 3 | |
soulx | 0:0c88691e3904 | 4 | #include "mbed.h" |
soulx | 0:0c88691e3904 | 5 | |
soulx | 0:0c88691e3904 | 6 | #define ANDANTE_BUFFER_SIZE 0x8F |
soulx | 0:0c88691e3904 | 7 | |
soulx | 0:0c88691e3904 | 8 | #define ANDANTE_PROTOCOL_COMMAND_RESPONSE_TIMEOUT_MS 20 |
soulx | 0:0c88691e3904 | 9 | |
soulx | 0:0c88691e3904 | 10 | #define ANDANTE_PROTOCOL_HEADER_0 0xEF |
soulx | 0:0c88691e3904 | 11 | #define ANDANTE_PROTOCOL_HEADER_1 0x0F |
soulx | 0:0c88691e3904 | 12 | |
soulx | 0:0c88691e3904 | 13 | // Errors |
soulx | 0:0c88691e3904 | 14 | #define ANDANTE_ERRBIT_NONE 0x00 |
soulx | 0:0c88691e3904 | 15 | #define ANDANTE_ERRBIT_VOLTAGE 0x01 |
soulx | 0:0c88691e3904 | 16 | #define ANDANTE_ERRBIT_ANGLE 0x02 |
soulx | 0:0c88691e3904 | 17 | #define ANDANTE_ERRBIT_OVERHEAT 0x04 |
soulx | 0:0c88691e3904 | 18 | #define ANDANTE_ERRBIT_RANGE 0x08 |
soulx | 0:0c88691e3904 | 19 | #define ANDANTE_ERRBIT_CHECKSUM 0x10 |
soulx | 0:0c88691e3904 | 20 | #define ANDANTE_ERRBIT_OVERLOAD 0x20 |
soulx | 0:0c88691e3904 | 21 | #define ANDANTE_ERRBIT_INSTRUCTION 0x40 |
soulx | 0:0c88691e3904 | 22 | |
soulx | 0:0c88691e3904 | 23 | // Extra errors |
soulx | 0:0c88691e3904 | 24 | #define ANDANTE_ERRBIT_WRITE_TIMEOUT 0xFD |
soulx | 0:0c88691e3904 | 25 | #define ANDANTE_ERRBIT_READ_TIMEOUT 0xFE |
soulx | 0:0c88691e3904 | 26 | #define ANDANTE_ERRBIT_MASTER_CHECKSUM 0xFF |
soulx | 0:0c88691e3904 | 27 | |
soulx | 0:0c88691e3904 | 28 | |
soulx | 0:0c88691e3904 | 29 | struct ANDANTE_PROTOCOL_PACKET |
soulx | 0:0c88691e3904 | 30 | { |
soulx | 0:0c88691e3904 | 31 | uint8_t robotId; |
soulx | 0:0c88691e3904 | 32 | uint8_t length; |
soulx | 0:0c88691e3904 | 33 | uint8_t instructionErrorId; |
soulx | 0:0c88691e3904 | 34 | uint8_t parameter[ANDANTE_BUFFER_SIZE]; |
soulx | 0:0c88691e3904 | 35 | uint8_t checkSum; |
soulx | 0:0c88691e3904 | 36 | }; |
soulx | 0:0c88691e3904 | 37 | |
soulx | 0:0c88691e3904 | 38 | enum ANDANTE_PROTOCOL_ENCODER_DECODER_STATE |
soulx | 0:0c88691e3904 | 39 | { |
soulx | 0:0c88691e3904 | 40 | WAIT_ON_HEADER_0, |
soulx | 0:0c88691e3904 | 41 | WAIT_ON_HEADER_1, |
soulx | 0:0c88691e3904 | 42 | WAIT_ON_ROBOT_ID, |
soulx | 0:0c88691e3904 | 43 | WAIT_ON_LENGTH, |
soulx | 0:0c88691e3904 | 44 | WAIT_ON_INSTRUCTION_ERROR_ID, |
soulx | 0:0c88691e3904 | 45 | WAIT_ON_PARAMETER, |
soulx | 0:0c88691e3904 | 46 | WAIT_ON_CHECK_SUM |
soulx | 0:0c88691e3904 | 47 | }; |
soulx | 0:0c88691e3904 | 48 | |
soulx | 0:0c88691e3904 | 49 | #endif // ANDANTE_PROTOCOL_H |