EtherCAT slave that reads 3 Xsens IMU's connected to a Xbus Master

Dependencies:   MODSERIAL mbed KL25Z_ClockControl

Fork of EtherCAT by First Last

Committer:
vsluiter
Date:
Fri Sep 11 15:33:31 2015 +0000
Revision:
42:ef78d11f2bd7
Parent:
0:a8daa9348a67
Also implemented samplecounter

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vsluiter 0:a8daa9348a67 1 /*
vsluiter 0:a8daa9348a67 2 * SOES Simple Open EtherCAT Slave
vsluiter 0:a8daa9348a67 3 *
vsluiter 0:a8daa9348a67 4 * File : esc.h
vsluiter 0:a8daa9348a67 5 * Version : 1.0.0
vsluiter 0:a8daa9348a67 6 * Date : 11-07-2010
vsluiter 0:a8daa9348a67 7 * Copyright (C) 2007-2010 Arthur Ketels
vsluiter 0:a8daa9348a67 8 *
vsluiter 0:a8daa9348a67 9 * SOES is free software; you can redistribute it and/or modify it under
vsluiter 0:a8daa9348a67 10 * the terms of the GNU General Public License version 2 as published by the Free
vsluiter 0:a8daa9348a67 11 * Software Foundation.
vsluiter 0:a8daa9348a67 12 *
vsluiter 0:a8daa9348a67 13 * SOES is distributed in the hope that it will be useful, but WITHOUT ANY
vsluiter 0:a8daa9348a67 14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
vsluiter 0:a8daa9348a67 15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
vsluiter 0:a8daa9348a67 16 * for more details.
vsluiter 0:a8daa9348a67 17 *
vsluiter 0:a8daa9348a67 18 * As a special exception, if other files instantiate templates or use macros
vsluiter 0:a8daa9348a67 19 * or inline functions from this file, or you compile this file and link it
vsluiter 0:a8daa9348a67 20 * with other works to produce a work based on this file, this file does not
vsluiter 0:a8daa9348a67 21 * by itself cause the resulting work to be covered by the GNU General Public
vsluiter 0:a8daa9348a67 22 * License. However the source code for this file must still be made available
vsluiter 0:a8daa9348a67 23 * in accordance with section (3) of the GNU General Public License.
vsluiter 0:a8daa9348a67 24 *
vsluiter 0:a8daa9348a67 25 * This exception does not invalidate any other reasons why a work based on
vsluiter 0:a8daa9348a67 26 * this file might be covered by the GNU General Public License.
vsluiter 0:a8daa9348a67 27 *
vsluiter 0:a8daa9348a67 28 * The EtherCAT Technology, the trade name and logo "EtherCAT" are the intellectual
vsluiter 0:a8daa9348a67 29 * property of, and protected by Beckhoff Automation GmbH.
vsluiter 0:a8daa9348a67 30 */
vsluiter 0:a8daa9348a67 31 #ifndef __esc__
vsluiter 0:a8daa9348a67 32 #define __esc__
vsluiter 0:a8daa9348a67 33
vsluiter 0:a8daa9348a67 34 // storage modifier for data stored in flashmemory
vsluiter 0:a8daa9348a67 35 #define FLASHSTORE const
vsluiter 0:a8daa9348a67 36 //#define FLASHSTORE
vsluiter 0:a8daa9348a67 37 #define PACKED __attribute__((__packed__))
vsluiter 0:a8daa9348a67 38
vsluiter 0:a8daa9348a67 39 #define ESCREG_ADDRESS 0x0010
vsluiter 0:a8daa9348a67 40 #define ESCREG_DLSTATUS 0x0110
vsluiter 0:a8daa9348a67 41 #define ESCREG_ALCONTROL 0x0120
vsluiter 0:a8daa9348a67 42 #define ESCREG_ALSTATUS 0x0130
vsluiter 0:a8daa9348a67 43 #define ESCREG_ALERROR 0x0134
vsluiter 0:a8daa9348a67 44 #define ESCREG_ALEVENT_SM_MASK 0x0310
vsluiter 0:a8daa9348a67 45 #define ESCREG_ALEVENT_SMCHANGE 0x0010
vsluiter 0:a8daa9348a67 46 #define ESCREG_ALEVENT_CONTROL 0x0001
vsluiter 0:a8daa9348a67 47 #define ESCREG_ALEVENT_SM2 0x0400
vsluiter 0:a8daa9348a67 48 #define ESCREG_WDSTATUS 0x0440
vsluiter 0:a8daa9348a67 49 #define ESCREG_SM0 0x0800
vsluiter 0:a8daa9348a67 50 #define ESCREG_SM0STATUS ESCREG_SM0 + 5
vsluiter 0:a8daa9348a67 51 #define ESCREG_SM0PDI ESCREG_SM0 + 7
vsluiter 0:a8daa9348a67 52 #define ESCREG_SM1 ESCREG_SM0 + 0x08
vsluiter 0:a8daa9348a67 53 #define ESCREG_SM2 ESCREG_SM0 + 0x10
vsluiter 0:a8daa9348a67 54 #define ESCREG_SM3 ESCREG_SM0 + 0x18
vsluiter 0:a8daa9348a67 55 #define ESCREG_LOCALTIME 0x0910
vsluiter 0:a8daa9348a67 56 #define ESCREG_SMENABLE_BIT 0x01
vsluiter 0:a8daa9348a67 57
vsluiter 0:a8daa9348a67 58 #define ESCinit 0x01
vsluiter 0:a8daa9348a67 59 #define ESCpreop 0x02
vsluiter 0:a8daa9348a67 60 #define ESCsafeop 0x04
vsluiter 0:a8daa9348a67 61 #define ESCop 0x08
vsluiter 0:a8daa9348a67 62 #define ESCerror 0x10
vsluiter 0:a8daa9348a67 63
vsluiter 0:a8daa9348a67 64 #define INIT_TO_INIT 0x11
vsluiter 0:a8daa9348a67 65 #define INIT_TO_PREOP 0x21
vsluiter 0:a8daa9348a67 66 #define INIT_TO_BOOT 0x31
vsluiter 0:a8daa9348a67 67 #define INIT_TO_SAFEOP 0x41
vsluiter 0:a8daa9348a67 68 #define INIT_TO_OP 0x81
vsluiter 0:a8daa9348a67 69 #define PREOP_TO_INIT 0x12
vsluiter 0:a8daa9348a67 70 #define PREOP_TO_PREOP 0x22
vsluiter 0:a8daa9348a67 71 #define PREOP_TO_BOOT 0x32
vsluiter 0:a8daa9348a67 72 #define PREOP_TO_SAFEOP 0x42
vsluiter 0:a8daa9348a67 73 #define PREOP_TO_OP 0x82
vsluiter 0:a8daa9348a67 74 #define SAFEOP_TO_INIT 0x14
vsluiter 0:a8daa9348a67 75 #define SAFEOP_TO_PREOP 0x24
vsluiter 0:a8daa9348a67 76 #define SAFEOP_TO_BOOT 0x34
vsluiter 0:a8daa9348a67 77 #define SAFEOP_TO_SAFEOP 0x44
vsluiter 0:a8daa9348a67 78 #define SAFEOP_TO_OP 0x84
vsluiter 0:a8daa9348a67 79 #define OP_TO_INIT 0x18
vsluiter 0:a8daa9348a67 80 #define OP_TO_PREOP 0x28
vsluiter 0:a8daa9348a67 81 #define OP_TO_BOOT 0x38
vsluiter 0:a8daa9348a67 82 #define OP_TO_SAFEOP 0x48
vsluiter 0:a8daa9348a67 83 #define OP_TO_OP 0x88
vsluiter 0:a8daa9348a67 84
vsluiter 0:a8daa9348a67 85 #define ALERR_NONE 0x0000
vsluiter 0:a8daa9348a67 86 #define ALERR_INVALIDSTATECHANGE 0x0011
vsluiter 0:a8daa9348a67 87 #define ALERR_UNKNOWNSTATE 0x0012
vsluiter 0:a8daa9348a67 88 #define ALERR_BOOTNOTSUPPORTED 0x0013
vsluiter 0:a8daa9348a67 89 #define ALERR_INVALIDMBXCONFIG 0x0016
vsluiter 0:a8daa9348a67 90 #define ALERR_INVALIDSMCONFIG 0x0017
vsluiter 0:a8daa9348a67 91 #define ALERR_WATCHDOG 0x0019
vsluiter 0:a8daa9348a67 92 #define ALERR_INVALIDOUTPUTSM 0x001D
vsluiter 0:a8daa9348a67 93 #define ALERR_INVALIDINPUTSM 0x001E
vsluiter 0:a8daa9348a67 94
vsluiter 0:a8daa9348a67 95 #define MBXERR_SYNTAX 0x0001
vsluiter 0:a8daa9348a67 96 #define MBXERR_UNSUPPORTEDPROTOCOL 0x0002
vsluiter 0:a8daa9348a67 97 #define MBXERR_INVALIDCHANNEL 0x0003
vsluiter 0:a8daa9348a67 98 #define MBXERR_SERVICENOTSUPPORTED 0x0004
vsluiter 0:a8daa9348a67 99 #define MBXERR_INVALIDHEADER 0x0005
vsluiter 0:a8daa9348a67 100 #define MBXERR_SIZETOOSHORT 0x0006
vsluiter 0:a8daa9348a67 101 #define MBXERR_NOMOREMEMORY 0x0007
vsluiter 0:a8daa9348a67 102 #define MBXERR_INVALIDSIZE 0x0008
vsluiter 0:a8daa9348a67 103
vsluiter 0:a8daa9348a67 104 #define ABORT_NOTOGGLE 0x05030000
vsluiter 0:a8daa9348a67 105 #define ABORT_UNKNOWN 0x05040001
vsluiter 0:a8daa9348a67 106 #define ABORT_UNSUPPORTED 0x06010000
vsluiter 0:a8daa9348a67 107 #define ABORT_WRITEONLY 0x06010001
vsluiter 0:a8daa9348a67 108 #define ABORT_READONLY 0x06010002
vsluiter 0:a8daa9348a67 109 #define ABORT_NOOBJECT 0x06020000
vsluiter 0:a8daa9348a67 110 #define ABORT_TYPEMISMATCH 0x06070010
vsluiter 0:a8daa9348a67 111 #define ABORT_NOSUBINDEX 0x06090011
vsluiter 0:a8daa9348a67 112 #define ABORT_GENERALERROR 0x08000000
vsluiter 0:a8daa9348a67 113 #define ABORT_NOTINTHISSTATE 0x08000022
vsluiter 0:a8daa9348a67 114
vsluiter 0:a8daa9348a67 115 #define MBXstate_idle 0x00
vsluiter 0:a8daa9348a67 116 #define MBXstate_inclaim 0x01
vsluiter 0:a8daa9348a67 117 #define MBXstate_outclaim 0x02
vsluiter 0:a8daa9348a67 118 #define MBXstate_outreq 0x03
vsluiter 0:a8daa9348a67 119 #define MBXstate_outpost 0x04
vsluiter 0:a8daa9348a67 120 #define MBXstate_backup 0x05
vsluiter 0:a8daa9348a67 121 #define MBXstate_again 0x06
vsluiter 0:a8daa9348a67 122
vsluiter 0:a8daa9348a67 123 #define COE_DEFAULTLENGTH 0x0a
vsluiter 0:a8daa9348a67 124 #define COE_HEADERSIZE 0x0a
vsluiter 0:a8daa9348a67 125 #define COE_SEGMENTHEADERSIZE 0x03
vsluiter 0:a8daa9348a67 126 #define COE_SDOREQUEST 0x02
vsluiter 0:a8daa9348a67 127 #define COE_SDORESPONSE 0x03
vsluiter 0:a8daa9348a67 128 #define COE_SDOINFORMATION 0x08
vsluiter 0:a8daa9348a67 129 #define COE_COMMAND_SDOABORT 0x80
vsluiter 0:a8daa9348a67 130 #define COE_COMMAND_UPLOADREQUEST 0x40
vsluiter 0:a8daa9348a67 131 #define COE_COMMAND_UPLOADRESPONSE 0x40
vsluiter 0:a8daa9348a67 132 #define COE_COMMAND_UPLOADSEGMENT 0x00
vsluiter 0:a8daa9348a67 133 #define COE_COMMAND_UPLOADSEGREQ 0x60
vsluiter 0:a8daa9348a67 134 #define COE_COMMAND_DOWNLOADRESPONSE 0x60
vsluiter 0:a8daa9348a67 135 #define COE_COMMAND_LASTSEGMENTBIT 0x01
vsluiter 0:a8daa9348a67 136 #define COE_SIZE_INDICATOR 0x01
vsluiter 0:a8daa9348a67 137 #define COE_EXPEDITED_INDICATOR 0x02
vsluiter 0:a8daa9348a67 138 #define COE_COMPLETEACCESS 0x10
vsluiter 0:a8daa9348a67 139 #define COE_TOGGLEBIT 0x10
vsluiter 0:a8daa9348a67 140 #define COE_INFOERROR 0x07
vsluiter 0:a8daa9348a67 141 #define COE_GETODLISTRESPONSE 0x02
vsluiter 0:a8daa9348a67 142 #define COE_GETODRESPONSE 0x04
vsluiter 0:a8daa9348a67 143 #define COE_ENTRYDESCRIPTIONRESPONSE 0x06
vsluiter 0:a8daa9348a67 144 #define COE_VALUEINFO_ACCESS 0x01
vsluiter 0:a8daa9348a67 145 #define COE_VALUEINFO_OBJECT 0x02
vsluiter 0:a8daa9348a67 146 #define COE_VALUEINFO_MAPPABLE 0x04
vsluiter 0:a8daa9348a67 147 #define COE_VALUEINFO_TYPE 0x08
vsluiter 0:a8daa9348a67 148 #define COE_VALUEINFO_DEFAULT 0x10
vsluiter 0:a8daa9348a67 149 #define COE_VALUEINFO_MINIMUM 0x20
vsluiter 0:a8daa9348a67 150 #define COE_VALUEINFO_MAXIMUM 0x40
vsluiter 0:a8daa9348a67 151
vsluiter 0:a8daa9348a67 152 //////////////////////////////////////////////////////////
vsluiter 0:a8daa9348a67 153 #define MBXSIZE 0x80
vsluiter 0:a8daa9348a67 154 #define MBXBUFFERS 3
vsluiter 0:a8daa9348a67 155
vsluiter 0:a8daa9348a67 156 #define MBX0_sma 0x1000
vsluiter 0:a8daa9348a67 157 #define MBX0_sml MBXSIZE
vsluiter 0:a8daa9348a67 158 #define MBX0_sme MBX0_sma+MBX0_sml-1
vsluiter 0:a8daa9348a67 159 #define MBX0_smc 0x26
vsluiter 0:a8daa9348a67 160 #define MBX1_sma 0x1080
vsluiter 0:a8daa9348a67 161 #define MBX1_sml MBXSIZE
vsluiter 0:a8daa9348a67 162 #define MBX1_sme MBX1_sma+MBX1_sml-1
vsluiter 0:a8daa9348a67 163 #define MBX1_smc 0x22
vsluiter 0:a8daa9348a67 164
vsluiter 0:a8daa9348a67 165 #define SM2_sma 0x1100
vsluiter 0:a8daa9348a67 166 #define SM2_smc 0x24
vsluiter 0:a8daa9348a67 167 #define SM2_act 0x01
vsluiter 0:a8daa9348a67 168 #define SM3_sma 0x1180
vsluiter 0:a8daa9348a67 169 #define SM3_smc 0x20
vsluiter 0:a8daa9348a67 170 #define SM3_act 0x01
vsluiter 0:a8daa9348a67 171 /////////////////////////////////////////////////////////////
vsluiter 0:a8daa9348a67 172
vsluiter 0:a8daa9348a67 173 #define MBXHSIZE sizeof(_MBXh)
vsluiter 0:a8daa9348a67 174 #define MBXDSIZE MBXSIZE-MBXHSIZE
vsluiter 0:a8daa9348a67 175
vsluiter 0:a8daa9348a67 176 #define MBXERR 0x00
vsluiter 0:a8daa9348a67 177 #define MBXAOE 0x01
vsluiter 0:a8daa9348a67 178 #define MBXEOE 0x02
vsluiter 0:a8daa9348a67 179 #define MBXCOE 0x03
vsluiter 0:a8daa9348a67 180 #define MBXFOE 0x04
vsluiter 0:a8daa9348a67 181 #define MBXODL 0x10
vsluiter 0:a8daa9348a67 182 #define MBXOD 0x20
vsluiter 0:a8daa9348a67 183 #define MBXED 0x30
vsluiter 0:a8daa9348a67 184 #define MBXSEU 0x40
vsluiter 0:a8daa9348a67 185 #define MBXSED 0x50
vsluiter 0:a8daa9348a67 186
vsluiter 0:a8daa9348a67 187 #define SMRESULT_ERRSM0 0x01
vsluiter 0:a8daa9348a67 188 #define SMRESULT_ERRSM1 0x02
vsluiter 0:a8daa9348a67 189 #define SMRESULT_ERRSM2 0x04
vsluiter 0:a8daa9348a67 190 #define SMRESULT_ERRSM3 0x08
vsluiter 0:a8daa9348a67 191
vsluiter 0:a8daa9348a67 192 // Attention! this struct is always little-endian
vsluiter 0:a8daa9348a67 193 typedef struct PACKED
vsluiter 0:a8daa9348a67 194 {
vsluiter 0:a8daa9348a67 195 uint16 PSA;
vsluiter 0:a8daa9348a67 196 uint16 Length;
vsluiter 0:a8daa9348a67 197
vsluiter 0:a8daa9348a67 198 #if defined(EC_LITTLE_ENDIAN)
vsluiter 0:a8daa9348a67 199 uint8 Mode:2;
vsluiter 0:a8daa9348a67 200 uint8 Direction:2;
vsluiter 0:a8daa9348a67 201 uint8 IntECAT:1;
vsluiter 0:a8daa9348a67 202 uint8 IntPDI:1;
vsluiter 0:a8daa9348a67 203 uint8 WTE:1;
vsluiter 0:a8daa9348a67 204 uint8 R1:1;
vsluiter 0:a8daa9348a67 205
vsluiter 0:a8daa9348a67 206 uint8 IntW:1;
vsluiter 0:a8daa9348a67 207 uint8 IntR:1;
vsluiter 0:a8daa9348a67 208 uint8 R2:1;
vsluiter 0:a8daa9348a67 209 uint8 MBXstat:1;
vsluiter 0:a8daa9348a67 210 uint8 BUFstat:2;
vsluiter 0:a8daa9348a67 211 uint8 R3:2;
vsluiter 0:a8daa9348a67 212
vsluiter 0:a8daa9348a67 213 uint8 ECsm:1;
vsluiter 0:a8daa9348a67 214 uint8 ECrep:1;
vsluiter 0:a8daa9348a67 215 uint8 ECr4:4;
vsluiter 0:a8daa9348a67 216 uint8 EClatchEC:1;
vsluiter 0:a8daa9348a67 217 uint8 EClatchPDI:1;
vsluiter 0:a8daa9348a67 218
vsluiter 0:a8daa9348a67 219 uint8 PDIsm:1;
vsluiter 0:a8daa9348a67 220 uint8 PDIrep:1;
vsluiter 0:a8daa9348a67 221 uint8 PDIr5:6;
vsluiter 0:a8daa9348a67 222 #endif
vsluiter 0:a8daa9348a67 223
vsluiter 0:a8daa9348a67 224 #if defined(EC_BIG_ENDIAN)
vsluiter 0:a8daa9348a67 225 uint8 R1:1;
vsluiter 0:a8daa9348a67 226 uint8 WTE:1;
vsluiter 0:a8daa9348a67 227 uint8 IntPDI:1;
vsluiter 0:a8daa9348a67 228 uint8 IntECAT:1;
vsluiter 0:a8daa9348a67 229 uint8 Direction:2;
vsluiter 0:a8daa9348a67 230 uint8 Mode:2;
vsluiter 0:a8daa9348a67 231
vsluiter 0:a8daa9348a67 232 uint8 R3:2;
vsluiter 0:a8daa9348a67 233 uint8 BUFstat:2;
vsluiter 0:a8daa9348a67 234 uint8 MBXstat:1;
vsluiter 0:a8daa9348a67 235 uint8 R2:1;
vsluiter 0:a8daa9348a67 236 uint8 IntR:1;
vsluiter 0:a8daa9348a67 237 uint8 IntW:1;
vsluiter 0:a8daa9348a67 238
vsluiter 0:a8daa9348a67 239 uint8 EClatchPDI:1;
vsluiter 0:a8daa9348a67 240 uint8 EClatchEC:1;
vsluiter 0:a8daa9348a67 241 uint8 ECr4:4;
vsluiter 0:a8daa9348a67 242 uint8 ECrep:1;
vsluiter 0:a8daa9348a67 243 uint8 ECsm:1;
vsluiter 0:a8daa9348a67 244
vsluiter 0:a8daa9348a67 245 uint8 PDIr5:6;
vsluiter 0:a8daa9348a67 246 uint8 PDIrep:1;
vsluiter 0:a8daa9348a67 247 uint8 PDIsm:1;
vsluiter 0:a8daa9348a67 248 #endif
vsluiter 0:a8daa9348a67 249 } _ESCsm;
vsluiter 0:a8daa9348a67 250
vsluiter 0:a8daa9348a67 251 // Attention! this struct is always little-endian
vsluiter 0:a8daa9348a67 252 typedef struct PACKED
vsluiter 0:a8daa9348a67 253 {
vsluiter 0:a8daa9348a67 254 uint16 PSA;
vsluiter 0:a8daa9348a67 255 uint16 Length;
vsluiter 0:a8daa9348a67 256 uint8 Command;
vsluiter 0:a8daa9348a67 257 uint8 Status;
vsluiter 0:a8daa9348a67 258 uint8 ActESC;
vsluiter 0:a8daa9348a67 259 uint8 ActPDI;
vsluiter 0:a8daa9348a67 260 } _ESCsm2;
vsluiter 0:a8daa9348a67 261
vsluiter 0:a8daa9348a67 262 typedef FLASHSTORE struct PACKED
vsluiter 0:a8daa9348a67 263 {
vsluiter 0:a8daa9348a67 264 uint16 PSA;
vsluiter 0:a8daa9348a67 265 uint16 Length;
vsluiter 0:a8daa9348a67 266 uint8 Command;
vsluiter 0:a8daa9348a67 267 } _ESCsmCompact;
vsluiter 0:a8daa9348a67 268
vsluiter 0:a8daa9348a67 269 typedef struct
vsluiter 0:a8daa9348a67 270 {
vsluiter 0:a8daa9348a67 271 uint16 ALevent;
vsluiter 0:a8daa9348a67 272 uint16 ALstatus;
vsluiter 0:a8daa9348a67 273 uint16 ALcontrol;
vsluiter 0:a8daa9348a67 274 uint16 ALerror;
vsluiter 0:a8daa9348a67 275 uint16 DLstatus;
vsluiter 0:a8daa9348a67 276 uint16 address;
vsluiter 0:a8daa9348a67 277 uint8 mbxcnt;
vsluiter 0:a8daa9348a67 278 uint8 mbxincnt;
vsluiter 0:a8daa9348a67 279 uint8 mbxoutpost;
vsluiter 0:a8daa9348a67 280 uint8 mbxbackup;
vsluiter 0:a8daa9348a67 281 uint8 xoe;
vsluiter 0:a8daa9348a67 282 uint8 txcue;
vsluiter 0:a8daa9348a67 283 uint8 mbxfree;
vsluiter 0:a8daa9348a67 284 uint8 segmented;
vsluiter 0:a8daa9348a67 285 void *data;
vsluiter 0:a8daa9348a67 286 uint16 entries;
vsluiter 0:a8daa9348a67 287 uint16 frags;
vsluiter 0:a8daa9348a67 288 uint16 fragsleft;
vsluiter 0:a8daa9348a67 289
vsluiter 0:a8daa9348a67 290 #if defined(EC_LITTLE_ENDIAN)
vsluiter 0:a8daa9348a67 291 uint8 r1:1;
vsluiter 0:a8daa9348a67 292 uint8 toggle:1;
vsluiter 0:a8daa9348a67 293 uint8 r2:6;
vsluiter 0:a8daa9348a67 294 #endif
vsluiter 0:a8daa9348a67 295
vsluiter 0:a8daa9348a67 296 #if defined(EC_BIG_ENDIAN)
vsluiter 0:a8daa9348a67 297 uint8 r2:6;
vsluiter 0:a8daa9348a67 298 uint8 toggle:1;
vsluiter 0:a8daa9348a67 299 uint8 r1:1;
vsluiter 0:a8daa9348a67 300 #endif
vsluiter 0:a8daa9348a67 301
vsluiter 0:a8daa9348a67 302 uint8 SMtestresult;
vsluiter 0:a8daa9348a67 303 int16 temp;
vsluiter 0:a8daa9348a67 304 uint16 wdcnt;
vsluiter 0:a8daa9348a67 305 uint32 PrevTime;
vsluiter 0:a8daa9348a67 306 uint32 Time;
vsluiter 0:a8daa9348a67 307 _ESCsm SM[4];
vsluiter 0:a8daa9348a67 308 } _ESCvar;
vsluiter 0:a8daa9348a67 309
vsluiter 0:a8daa9348a67 310 typedef struct PACKED
vsluiter 0:a8daa9348a67 311 {
vsluiter 0:a8daa9348a67 312 uint16 length;
vsluiter 0:a8daa9348a67 313 uint16 address;
vsluiter 0:a8daa9348a67 314
vsluiter 0:a8daa9348a67 315 #if defined(EC_LITTLE_ENDIAN)
vsluiter 0:a8daa9348a67 316 uint8 channel:6;
vsluiter 0:a8daa9348a67 317 uint8 priority:2;
vsluiter 0:a8daa9348a67 318
vsluiter 0:a8daa9348a67 319 uint8 mbxtype:4;
vsluiter 0:a8daa9348a67 320 uint8 mbxcnt: 4;
vsluiter 0:a8daa9348a67 321 #endif
vsluiter 0:a8daa9348a67 322
vsluiter 0:a8daa9348a67 323 #if defined(EC_BIG_ENDIAN)
vsluiter 0:a8daa9348a67 324 uint8 priority:2;
vsluiter 0:a8daa9348a67 325 uint8 channel:6;
vsluiter 0:a8daa9348a67 326
vsluiter 0:a8daa9348a67 327 uint8 mbxcnt: 4;
vsluiter 0:a8daa9348a67 328 uint8 mbxtype:4;
vsluiter 0:a8daa9348a67 329 #endif
vsluiter 0:a8daa9348a67 330 } _MBXh;
vsluiter 0:a8daa9348a67 331
vsluiter 0:a8daa9348a67 332 typedef struct PACKED
vsluiter 0:a8daa9348a67 333 {
vsluiter 0:a8daa9348a67 334 _MBXh header;
vsluiter 0:a8daa9348a67 335 uint8 b[MBXDSIZE];
vsluiter 0:a8daa9348a67 336 } _MBX;
vsluiter 0:a8daa9348a67 337
vsluiter 0:a8daa9348a67 338 typedef struct PACKED
vsluiter 0:a8daa9348a67 339 {
vsluiter 0:a8daa9348a67 340 uint16 numberservice;
vsluiter 0:a8daa9348a67 341 } _COEh;
vsluiter 0:a8daa9348a67 342
vsluiter 0:a8daa9348a67 343 typedef struct PACKED
vsluiter 0:a8daa9348a67 344 {
vsluiter 0:a8daa9348a67 345 #if defined(EC_LITTLE_ENDIAN)
vsluiter 0:a8daa9348a67 346 uint8 opcode:7;
vsluiter 0:a8daa9348a67 347 uint8 incomplete:1;
vsluiter 0:a8daa9348a67 348 #endif
vsluiter 0:a8daa9348a67 349
vsluiter 0:a8daa9348a67 350 #if defined(EC_BIG_ENDIAN)
vsluiter 0:a8daa9348a67 351 uint8 incomplete:1;
vsluiter 0:a8daa9348a67 352 uint8 opcode:7;
vsluiter 0:a8daa9348a67 353 #endif
vsluiter 0:a8daa9348a67 354
vsluiter 0:a8daa9348a67 355 uint8 reserved;
vsluiter 0:a8daa9348a67 356 uint16 fragmentsleft;
vsluiter 0:a8daa9348a67 357 } _INFOh;
vsluiter 0:a8daa9348a67 358
vsluiter 0:a8daa9348a67 359 typedef struct PACKED
vsluiter 0:a8daa9348a67 360 {
vsluiter 0:a8daa9348a67 361 _MBXh mbxheader;
vsluiter 0:a8daa9348a67 362 uint16 type;
vsluiter 0:a8daa9348a67 363 uint16 detail;
vsluiter 0:a8daa9348a67 364 } _MBXerr;
vsluiter 0:a8daa9348a67 365
vsluiter 0:a8daa9348a67 366 typedef struct PACKED
vsluiter 0:a8daa9348a67 367 {
vsluiter 0:a8daa9348a67 368 _MBXh mbxheader;
vsluiter 0:a8daa9348a67 369 _COEh coeheader;
vsluiter 0:a8daa9348a67 370 uint8 command;
vsluiter 0:a8daa9348a67 371 uint16 index;
vsluiter 0:a8daa9348a67 372 uint8 subindex;
vsluiter 0:a8daa9348a67 373 uint32 size;
vsluiter 0:a8daa9348a67 374 } _COEsdo;
vsluiter 0:a8daa9348a67 375
vsluiter 0:a8daa9348a67 376 typedef struct PACKED
vsluiter 0:a8daa9348a67 377 {
vsluiter 0:a8daa9348a67 378 _MBXh mbxheader;
vsluiter 0:a8daa9348a67 379 _COEh coeheader;
vsluiter 0:a8daa9348a67 380 _INFOh infoheader;
vsluiter 0:a8daa9348a67 381 uint16 index;
vsluiter 0:a8daa9348a67 382 uint16 datatype;
vsluiter 0:a8daa9348a67 383 uint8 maxsub;
vsluiter 0:a8daa9348a67 384 uint8 objectcode;
vsluiter 0:a8daa9348a67 385 char name;
vsluiter 0:a8daa9348a67 386 } _COEobjdesc;
vsluiter 0:a8daa9348a67 387
vsluiter 0:a8daa9348a67 388 typedef struct PACKED
vsluiter 0:a8daa9348a67 389 {
vsluiter 0:a8daa9348a67 390 _MBXh mbxheader;
vsluiter 0:a8daa9348a67 391 _COEh coeheader;
vsluiter 0:a8daa9348a67 392 _INFOh infoheader;
vsluiter 0:a8daa9348a67 393 uint16 index;
vsluiter 0:a8daa9348a67 394 uint8 subindex;
vsluiter 0:a8daa9348a67 395 uint8 valueinfo;
vsluiter 0:a8daa9348a67 396 uint16 datatype;
vsluiter 0:a8daa9348a67 397 uint16 bitlength;
vsluiter 0:a8daa9348a67 398 uint16 access;
vsluiter 0:a8daa9348a67 399 char name;
vsluiter 0:a8daa9348a67 400 } _COEentdesc;
vsluiter 0:a8daa9348a67 401
vsluiter 0:a8daa9348a67 402 // state definition in mailbox
vsluiter 0:a8daa9348a67 403 // 0 : idle
vsluiter 0:a8daa9348a67 404 // 1 : claimed for inbox
vsluiter 0:a8daa9348a67 405 // 2 : claimed for outbox
vsluiter 0:a8daa9348a67 406 // 3 : request post outbox
vsluiter 0:a8daa9348a67 407 // 4 : outbox posted not send
vsluiter 0:a8daa9348a67 408 // 5 : backup outbox
vsluiter 0:a8daa9348a67 409 // 6 : mailbox needs to be transmitted again
vsluiter 0:a8daa9348a67 410 typedef struct
vsluiter 0:a8daa9348a67 411 {
vsluiter 0:a8daa9348a67 412 uint8 state;
vsluiter 0:a8daa9348a67 413 } _MBXcontrol;
vsluiter 0:a8daa9348a67 414
vsluiter 0:a8daa9348a67 415 uint16 sizeTXPDO(void);
vsluiter 0:a8daa9348a67 416 uint16 sizeRXPDO(void);
vsluiter 0:a8daa9348a67 417 uint8 ESC_read(uint16 address,void *buf,uint8 len,void *tALevent);
vsluiter 0:a8daa9348a67 418 uint8 ESC_write(uint16 address,void *buf,uint8 len,void *tALevent);
vsluiter 0:a8daa9348a67 419 void ESC_ALerror(uint16 errornumber);
vsluiter 0:a8daa9348a67 420 void ESC_ALstatus(uint8 status);
vsluiter 0:a8daa9348a67 421 void ESC_SMstatus(uint8 n);
vsluiter 0:a8daa9348a67 422 uint8 ESC_WDstatus(void);
vsluiter 0:a8daa9348a67 423 uint8 ESC_startmbx(uint8 state);
vsluiter 0:a8daa9348a67 424 void ESC_stopmbx(void);
vsluiter 0:a8daa9348a67 425 uint8 ESC_mbxprocess(void);
vsluiter 0:a8daa9348a67 426 void ESC_coeprocess(void);
vsluiter 0:a8daa9348a67 427 void ESC_xoeprocess(void);
vsluiter 0:a8daa9348a67 428 uint8 ESC_startinput(uint8 state);
vsluiter 0:a8daa9348a67 429 void ESC_stopinput(void);
vsluiter 0:a8daa9348a67 430 uint8 ESC_startoutput(uint8 state);
vsluiter 0:a8daa9348a67 431 void ESC_stopoutput(void);
vsluiter 0:a8daa9348a67 432 void ESC_ALevent(void);
vsluiter 0:a8daa9348a67 433 void ESC_state(void);
vsluiter 0:a8daa9348a67 434 extern void ESC_objecthandler(uint16 index, uint8 subindex);
vsluiter 0:a8daa9348a67 435 extern void APP_safeoutput(void);
vsluiter 0:a8daa9348a67 436
vsluiter 0:a8daa9348a67 437 extern _ESCvar ESCvar;
vsluiter 0:a8daa9348a67 438 extern _MBX MBX[MBXBUFFERS];
vsluiter 0:a8daa9348a67 439 extern _MBXcontrol MBXcontrol[MBXBUFFERS];
vsluiter 0:a8daa9348a67 440 extern uint8 MBXrun;
vsluiter 0:a8daa9348a67 441 extern uint16 SM2_sml,SM3_sml;
vsluiter 0:a8daa9348a67 442 extern uint8 SDO1C12size;
vsluiter 0:a8daa9348a67 443
vsluiter 0:a8daa9348a67 444 #endif
vsluiter 0:a8daa9348a67 445