before test

Fork of Communication_Robot by Betago

Committer:
icyzkungz
Date:
Tue Jun 07 16:16:27 2016 +0000
Revision:
14:2b253d0b4e63
Parent:
9:dd0f35b36473
before test

Who changed what in which revision?

UserRevisionLine numberNew 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
icyzkungz 14:2b253d0b4e63 6 //#define ANDANTE_BUFFER_SIZE 0x8F
icyzkungz 14:2b253d0b4e63 7 #define ANDANTE_BUFFER_SIZE 0x1F4
soulx 0:0c88691e3904 8
icyzkungz 14:2b253d0b4e63 9 //#define ANDANTE_PROTOCOL_COMMAND_RESPONSE_TIMEOUT_MS 20
icyzkungz 14:2b253d0b4e63 10 #define ANDANTE_PROTOCOL_COMMAND_RESPONSE_TIMEOUT_MS 60
soulx 0:0c88691e3904 11
soulx 2:56c1de1612dd 12 #define ANDANTE_PROTOCOL_HEADER_0 0xFF
soulx 2:56c1de1612dd 13 #define ANDANTE_PROTOCOL_HEADER_1 0xFF
soulx 0:0c88691e3904 14
soulx 0:0c88691e3904 15 // Errors
soulx 0:0c88691e3904 16 #define ANDANTE_ERRBIT_NONE 0x00
soulx 0:0c88691e3904 17 #define ANDANTE_ERRBIT_VOLTAGE 0x01
soulx 0:0c88691e3904 18 #define ANDANTE_ERRBIT_ANGLE 0x02
soulx 0:0c88691e3904 19 #define ANDANTE_ERRBIT_OVERHEAT 0x04
soulx 0:0c88691e3904 20 #define ANDANTE_ERRBIT_RANGE 0x08
soulx 0:0c88691e3904 21 #define ANDANTE_ERRBIT_CHECKSUM 0x10
soulx 0:0c88691e3904 22 #define ANDANTE_ERRBIT_OVERLOAD 0x20
soulx 0:0c88691e3904 23 #define ANDANTE_ERRBIT_INSTRUCTION 0x40
soulx 0:0c88691e3904 24
soulx 0:0c88691e3904 25 // Extra errors
soulx 0:0c88691e3904 26 #define ANDANTE_ERRBIT_WRITE_TIMEOUT 0xFD
soulx 0:0c88691e3904 27 #define ANDANTE_ERRBIT_READ_TIMEOUT 0xFE
soulx 0:0c88691e3904 28 #define ANDANTE_ERRBIT_MASTER_CHECKSUM 0xFF
soulx 0:0c88691e3904 29
soulx 0:0c88691e3904 30
soulx 3:2f334f0cee75 31 //Instruction Control
soulx 3:2f334f0cee75 32 #define ANDANTE_SPEED_CONTROL 0x01
soulx 3:2f334f0cee75 33 #define ANDANTE_FRONT_ANGLE 0x02
soulx 3:2f334f0cee75 34 #define ANDANTE_REAR_ANGLE 0x04
soulx 3:2f334f0cee75 35
soulx 3:2f334f0cee75 36 //Instruction Sensor
soulx 3:2f334f0cee75 37
soulx 3:2f334f0cee75 38
soulx 0:0c88691e3904 39 struct ANDANTE_PROTOCOL_PACKET
soulx 0:0c88691e3904 40 {
soulx 0:0c88691e3904 41 uint8_t robotId;
icyzkungz 14:2b253d0b4e63 42 uint16_t length;
soulx 0:0c88691e3904 43 uint8_t instructionErrorId;
soulx 0:0c88691e3904 44 uint8_t parameter[ANDANTE_BUFFER_SIZE];
soulx 0:0c88691e3904 45 uint8_t checkSum;
soulx 0:0c88691e3904 46 };
soulx 0:0c88691e3904 47
soulx 0:0c88691e3904 48 enum ANDANTE_PROTOCOL_ENCODER_DECODER_STATE
soulx 0:0c88691e3904 49 {
soulx 0:0c88691e3904 50 WAIT_ON_HEADER_0,
soulx 0:0c88691e3904 51 WAIT_ON_HEADER_1,
soulx 0:0c88691e3904 52 WAIT_ON_ROBOT_ID,
soulx 0:0c88691e3904 53 WAIT_ON_LENGTH,
soulx 0:0c88691e3904 54 WAIT_ON_INSTRUCTION_ERROR_ID,
soulx 0:0c88691e3904 55 WAIT_ON_PARAMETER,
soulx 0:0c88691e3904 56 WAIT_ON_CHECK_SUM
soulx 0:0c88691e3904 57 };
soulx 0:0c88691e3904 58
soulx 0:0c88691e3904 59 #endif // ANDANTE_PROTOCOL_H