v1

Fork of Fork_Boss_Communication_Robot by BE@R lab

Revision:
0:0c88691e3904
Child:
2:56c1de1612dd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/protocol.h	Sun Mar 01 06:28:01 2015 +0000
@@ -0,0 +1,49 @@
+#ifndef ANDANTE_PROTOCOL_H
+#define ANDANTE_PROTOCOL_H
+
+#include "mbed.h"
+
+#define ANDANTE_BUFFER_SIZE            0x8F
+
+#define ANDANTE_PROTOCOL_COMMAND_RESPONSE_TIMEOUT_MS   20
+
+#define ANDANTE_PROTOCOL_HEADER_0      0xEF
+#define ANDANTE_PROTOCOL_HEADER_1      0x0F
+
+// Errors
+#define ANDANTE_ERRBIT_NONE            0x00
+#define ANDANTE_ERRBIT_VOLTAGE         0x01
+#define ANDANTE_ERRBIT_ANGLE           0x02
+#define ANDANTE_ERRBIT_OVERHEAT        0x04
+#define ANDANTE_ERRBIT_RANGE           0x08
+#define ANDANTE_ERRBIT_CHECKSUM        0x10
+#define ANDANTE_ERRBIT_OVERLOAD        0x20
+#define ANDANTE_ERRBIT_INSTRUCTION     0x40
+
+// Extra errors
+#define ANDANTE_ERRBIT_WRITE_TIMEOUT   0xFD
+#define ANDANTE_ERRBIT_READ_TIMEOUT    0xFE
+#define ANDANTE_ERRBIT_MASTER_CHECKSUM 0xFF
+
+
+struct ANDANTE_PROTOCOL_PACKET
+{
+    uint8_t robotId;
+    uint8_t length;    
+    uint8_t instructionErrorId;   
+    uint8_t parameter[ANDANTE_BUFFER_SIZE];
+    uint8_t checkSum;
+};
+
+enum ANDANTE_PROTOCOL_ENCODER_DECODER_STATE
+{
+    WAIT_ON_HEADER_0,
+    WAIT_ON_HEADER_1,
+    WAIT_ON_ROBOT_ID,   
+    WAIT_ON_LENGTH,
+    WAIT_ON_INSTRUCTION_ERROR_ID,
+    WAIT_ON_PARAMETER,
+    WAIT_ON_CHECK_SUM
+};
+
+#endif // ANDANTE_PROTOCOL_H
\ No newline at end of file