0230_palm_edc_ethercat_protocol.h
Go to the documentation of this file.
1 //
2 // © 2010 Shadow Robot Company Limited.
3 //
4 // FileName: this_node.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 PALM_EDC_0230_ETHERCAT_PROTOCOL_H_INCLUDED
45 #define PALM_EDC_0230_ETHERCAT_PROTOCOL_H_INCLUDED
46 
47 #include "../0220_palm_edc/0220_palm_edc_ethercat_protocol.h"
48 
50 typedef struct
51 {
52  EDC_COMMAND EDC_command;
53 
57  // Joint data & Mid/Prox Tactile data //
58  int16u sensors[SENSORS_NUM_0220+1];
59  TACTILE_SENSOR_MID_PROX tactile_mid_prox[5];
60 
62  // Fingertip Tactile data //
63  int32u tactile_data_type;
64  int16u tactile_data_valid;
66 
68  // Aux SPI port data //
71 
73 
74  // Motor data //
75  FROM_MOTOR_DATA_TYPE motor_data_type;
76  int16s which_motors;
79 
82  int32u which_motor_data_arrived;
83  int32u which_motor_data_had_errors;
84 
85  MOTOR_DATA_PACKET motor_data_packet[10];
86  // TOTAL MOTOR DATA = 54 bytes
88 
89 
90  int16u idle_time_us;
91 
93 } __attribute__((packed)) ETHERCAT_DATA_STRUCTURE_0230_PALM_EDC_STATUS;
94 
95 #define STATUS_HEADER_START 0
96 #define STATUS_TACTILE_START (offsetof(ETHERCAT_DATA_STRUCTURE_0230_PALM_EDC_STATUS, tactile_data_type))
97 #define STATUS_AUX_START (offsetof(ETHERCAT_DATA_STRUCTURE_0230_PALM_EDC_STATUS, aux_spi_data_type))
98 #define STATUS_MOTOR_START (offsetof(ETHERCAT_DATA_STRUCTURE_0230_PALM_EDC_STATUS, motor_data_type))
99 #define STATUS_IDLETIME_START (offsetof(ETHERCAT_DATA_STRUCTURE_0230_PALM_EDC_STATUS, idle_time_us))
100 
101 #define STATUS_TOTAL_LENGTH (sizeof(ETHERCAT_DATA_STRUCTURE_0230_PALM_EDC_STATUS))
102 #define STATUS_JOINTS_LENGTH (STATUS_TACTILE_START - STATUS_HEADER_START)
103 #define STATUS_TACTILE_LENGTH (STATUS_AUX_START - STATUS_TACTILE_START)
104 #define STATUS_AUX_LENGTH (STATUS_MOTOR_START - STATUS_AUX_START)
105 #define STATUS_MOTOR_LENGTH (STATUS_IDLETIME_START - STATUS_MOTOR_START)
106 #define STATUS_IDLETIME_LENGTH (STATUS_TOTAL_LENGTH - STATUS_IDLETIME_START)
107 
108 
109 
111 typedef struct
112 {
113  EDC_COMMAND EDC_command;
114 
116  FROM_MOTOR_DATA_TYPE from_motor_data_type;
117  int16s which_motors;
118 
120  TO_MOTOR_DATA_TYPE to_motor_data_type;
121  int32u tactile_data_type;
123 
124 
125  int16s motor_data[NUM_MOTORS];
126 
127 } __attribute__((packed)) ETHERCAT_DATA_STRUCTURE_0230_PALM_EDC_COMMAND;
128 
129 
130 #define PALM_0230_ETHERCAT_COMMAND_HEADER_SIZE ( sizeof(EDC_COMMAND) + \
131  sizeof(FROM_MOTOR_DATA_TYPE) + \
132  sizeof(int16s) + \
133  sizeof(TO_MOTOR_DATA_TYPE) + \
134  sizeof(int32u) )
135 
136 #define PALM_0230_ETHERCAT_STATUS_DATA_SIZE sizeof(ETHERCAT_DATA_STRUCTURE_0230_PALM_EDC_STATUS)
137 #define PALM_0230_ETHERCAT_COMMAND_DATA_SIZE sizeof(ETHERCAT_DATA_STRUCTURE_0230_PALM_EDC_COMMAND)
138 
139  // Now we need to be *sure* that the Host and the Slave definitely
140  // agree on the size of the EtherCAT packets, even if the host is a
141  // 64-bit machine or something. So we have these calculated sizes.
142  // The host and slave can ASSERT that the sizeof() the packets
143  // matches the agreed sizes.
144 #define ETHERCAT_STATUS_0230_AGREED_SIZE 416
145 #define ETHERCAT_COMMAND_0230_AGREED_SIZE 62
146 
147 
148 
160 
161 #define PALM_0230_ETHERCAT_COMMAND_DATA_ADDRESS 0x1000
162 #define PALM_0230_ETHERCAT_CAN_BRIDGE_DATA_COMMAND_ADDRESS (PALM_0230_ETHERCAT_COMMAND_DATA_ADDRESS + PALM_0230_ETHERCAT_COMMAND_DATA_SIZE)
163 
164 #define PALM_0230_ETHERCAT_STATUS_DATA_ADDRESS (PALM_0230_ETHERCAT_CAN_BRIDGE_DATA_COMMAND_ADDRESS + ETHERCAT_CAN_BRIDGE_DATA_SIZE)
165 #define PALM_0230_ETHERCAT_CAN_BRIDGE_DATA_STATUS_ADDRESS (PALM_0230_ETHERCAT_STATUS_DATA_ADDRESS + PALM_0230_ETHERCAT_STATUS_DATA_SIZE)
166 
167 
168 
169 #endif
unsigned short int16u
This needs to be a #define for symmetry with SENSORS_NUM.
unsigned int int32u
int32u aux_data_type
Request for specific aux data.
EDC_COMMAND
The host can request different types of data from the palm.
#define SENSORS_NUM_0220
signed short int16s


sr_external_dependencies
Author(s): Ugo Cupcic
autogenerated on Mon Feb 28 2022 23:50:40