common_edc_ethercat_protocol.h
Go to the documentation of this file.
1 //
2 // © 2010 Shadow Robot Company Limited.
3 //
4 // FileName: common_edc_ethercat_protocol.h
5 // Dependencies:
6 // Processor: PIC32
7 // Compiler: MPLAB® C32
8 //
9 // +------------------------------------------------------------------------+
10 // | This file is part of The Shadow Robot PIC32 firmware code base. |
11 // | |
12 // | It is free software: you can redistribute it and/or modify |
13 // | it under the terms of the GNU General Public License as published by |
14 // | the Free Software Foundation, either version 3 of the License, or |
15 // | (at your option) any later version. |
16 // | |
17 // | It is distributed in the hope that it will be useful, |
18 // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 // | GNU General Public License for more details. |
21 // | |
22 // | You should have received a copy of the GNU General Public License |
23 // | along with this code repository. The text of the license can be found |
24 // | in Pic32/License/gpl.txt. If not, see <http://www.gnu.org/licenses/>. |
25 // +------------------------------------------------------------------------+
26 //
27 //
28 //
29 // Doxygen
30 // -------
31 //
42 //
43 
44 #ifndef COMMON_EDC_ETHERCAT_PROTOCOL_H_INCLUDED
45 #define COMMON_EDC_ETHERCAT_PROTOCOL_H_INCLUDED
46 
48 typedef enum
49 {
55 
56  //EDC_COMMAND_TEST_RESULTS, //!< Might be used in the future for running automated tests inside the firmware.
58 
59 
60 
61 #ifndef NO_STRINGS // The PIC compiler doesn't deal well with strings.
62 
63  static const char* slow_data_types[17] = { "Invalid", // 0x0000
64  "SVN revision", // 0x0001
65  "SVN revision on server at build time", // 0x0002
66 
67  "Modified from SVN revision", // 0x0003
68  "Serial number low", // 0x0004
69  "Serial number high", // 0x0005
70  "Motor gear ratio", // 0x0006
71  "Assembly date year", // 0x0007
72  "Assembly date month, day", // 0x0008
73 
74  "Controller F", // 0x0009
75  "Controller P", // 0x000A
76  "Controller I", // 0x000B
77  "Controller Imax", // 0x000D
78  "Controller D", // 0x000E
79  "Controller deadband and sign", // 0x000F
80 
81  "Controller loop frequency Hz" // 0x0010
82  };
83 
84 #endif
85 
86 
89 typedef enum
90 {
96 
97 
98 #define MESSAGE_ID_DIRECTION_BITS 0b11000000000
99 #define MESSAGE_ID_MOTOR_ID_BITS 0b00111100000
100 #define MESSAGE_ID_ACK_BIT 0b00000010000
101 #define MESSAGE_ID_TYPE_BITS 0b00000001111
102  // or for the TO_MUSCLE_DATA_TYPE or FROM_MUSCLE_DATA_TYPE
103 
104 #define MESSAGE_ID_DIRECTION_SHIFT_POS 9
105 
106 
107 //Check this against the SENSORS_NUM_0320 and SENSORS_NUM_0220
108 #define SENSORS_NUM_0X20 ((int)36)
109 
111 //Check this against the JOINTS_NUM_0320 and JOINTS_NUM_0220
112 #define JOINTS_NUM_0X20 ((int)28)
113 
115 
116 
117 #ifndef NO_STRINGS // The PIC compiler doesn't deal well with strings.
118 
119  static const char* joint_names[JOINTS_NUM_0X20] = { "FFJ0", "FFJ1", "FFJ2", "FFJ3", "FFJ4",
120  "MFJ0", "MFJ1", "MFJ2", "MFJ3", "MFJ4",
121  "RFJ0", "RFJ1", "RFJ2", "RFJ3", "RFJ4",
122  "LFJ0", "LFJ1", "LFJ2", "LFJ3", "LFJ4","LFJ5",
123  "THJ1", "THJ2", "THJ3", "THJ4", "THJ5",
124  "WRJ1", "WRJ2"
125  };
126 
127 
129 
130  static const char* sensor_names[SENSORS_NUM_0X20] = {"FFJ1", "FFJ2", "FFJ3", "FFJ4", // [00..03] ADC readings from First finger
131  "MFJ1", "MFJ2", "MFJ3", "MFJ4", // [04..07] ADC readings from Middle finger
132  "RFJ1", "RFJ2", "RFJ3", "RFJ4", // [08..11] ADC readings from Ring finger
133  "LFJ1", "LFJ2", "LFJ3", "LFJ4", "LFJ5", // [12..16] ADC readings from Little finger
134  "THJ1", "THJ2", "THJ3", "THJ4", "THJ5A", "THJ5B", // [17..22] ADC readings from Thumb
135  "WRJ1A", "WRJ1B", "WRJ2", // [23..25] ADC readings from Wrist
136  "ACCX", "ACCY", "ACCZ", // [26..28] ADC readings from Accelerometer
137  "GYRX", "GYRY", "GYRZ", // [29..31] ADC readings from Gyroscope
138  "AN0", "AN1", "AN2", "AN3" // [32..35] ADC readings from auxillary ADC port.
139  };
140 #endif
141 
142 
144 typedef enum
145 {
146  FFJ1=0, FFJ2, FFJ3, FFJ4, // [ 0...3]
147  MFJ1, MFJ2, MFJ3, MFJ4, // [ 4...7]
148  RFJ1, RFJ2, RFJ3, RFJ4, // [ 8..11]
149  LFJ1, LFJ2, LFJ3, LFJ4, LFJ5, // [12..16]
150  THJ1, THJ2, THJ3, THJ4, THJ5A, THJ5B, // [17..22]
151  WRJ1A, WRJ1B, WRJ2, // [23..25]
152 
153  ACCX, ACCY, ACCZ, // [26..28]
154  GYRX, GYRY, GYRZ, // [29..32]
155 
156  ANA0, ANA1, ANA2, ANA3, // [31..35]
157  IGNORE // [36]
159 
160 
161 
162 
163 typedef enum
164 {
168 
169 
170 
171 #define INSERT_CRC_CALCULATION_HERE crc_i = (int8u) (crc_result&0xff); \
172  crc_i ^= crc_byte; \
173  crc_result >>= 8; \
174  if(crc_i & 0x01) crc_result ^= 0x3096; \
175  if(crc_i & 0x02) crc_result ^= 0x612c; \
176  if(crc_i & 0x04) crc_result ^= 0xc419; \
177  if(crc_i & 0x08) crc_result ^= 0x8832; \
178  if(crc_i & 0x10) crc_result ^= 0x1064; \
179  if(crc_i & 0x20) crc_result ^= 0x20c8; \
180  if(crc_i & 0x40) crc_result ^= 0x4190; \
181  if(crc_i & 0x80) crc_result ^= 0x8320;
182 
183 
184 #endif
Normal operating value. Palm transmits ADC readings.
Requesting that motors send back status data (AKA Start of Frame)
Instead of sending ADC readings, send the channel number, so the host can confirm the firmware is cor...
Instead of sending ADC readings, send the chip select channel, so the host can confirm the firmware i...
static const char * joint_names[JOINTS_NUM_0X20]
This needs to be a #define for symmetry with SENSORS_NUM.
static const char * sensor_names[SENSORS_NUM_0X20]
This array defines the names of the joints. The names and order should match the enum SENSOR_NAMES_EN...
static const char * slow_data_types[17]
#define SENSORS_NUM_0X20
Might be used in the future for running automated tests inside the firmware.
Message contains status data from a motor.
SENSOR_NAME_ENUM
This enum defines which ADC reading goes into which sensors[].
Reading an empty mailbox on the ET1200 results in a zero.
Message contains command data being sent to the motors.
#define JOINTS_NUM_0X20
This needs to be a #define because it&#39;s used to dimension an array.
EDC_COMMAND
The host can request different types of data from the palm.
Message has something to do with boot-loading.


sr_external_dependencies
Author(s): Ugo Cupcic
autogenerated on Tue Oct 13 2020 04:01:56