author | greg |
Wed, 16 Sep 2009 15:19:58 +0200 | |
changeset 592 | b98df76c6fd5 |
parent 587 | c175351a6994 |
child 611 | 3e0c776da33b |
permissions | -rw-r--r-- |
0 | 1 |
/* |
208 | 2 |
This file is part of CanFestival, a library implementing CanOpen |
3 |
Stack. |
|
4 |
||
5 |
Copyright (C): Edouard TISSERANT and Francis DUPIN |
|
6 |
||
7 |
See COPYING file for copyrights details. |
|
8 |
||
9 |
This library is free software; you can redistribute it and/or |
|
10 |
modify it under the terms of the GNU Lesser General Public |
|
11 |
License as published by the Free Software Foundation; either |
|
12 |
version 2.1 of the License, or (at your option) any later version. |
|
13 |
||
14 |
This library is distributed in the hope that it will be useful, |
|
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
17 |
Lesser General Public License for more details. |
|
18 |
||
19 |
You should have received a copy of the GNU Lesser General Public |
|
20 |
License along with this library; if not, write to the Free Software |
|
21 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|
22 |
USA |
|
0 | 23 |
*/ |
24 |
#include "pdo.h" |
|
25 |
#include "objacces.h" |
|
149 | 26 |
#include "canfestival.h" |
370
6fecf36df407
Fixed some endianization problems caused by switch to UNS16 for cob_id member in CAN messages. To be continued.
etisserant
parents:
365
diff
changeset
|
27 |
#include "sysdep.h" |
0 | 28 |
|
208 | 29 |
/*! |
30 |
** @file pdo.c |
|
31 |
** @author Edouard TISSERANT and Francis DUPIN |
|
32 |
** @date Tue Jun 5 09:32:32 2007 |
|
33 |
** |
|
34 |
** @brief |
|
35 |
** |
|
36 |
** |
|
37 |
*/ |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
38 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
39 |
/*! |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
40 |
** |
208 | 41 |
** |
42 |
** @param d |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
43 |
** @param TPDO_com TPDO communication parameters OD entry |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
44 |
** @param TPDO_map TPDO mapping parameters OD entry |
208 | 45 |
** |
46 |
** @return |
|
47 |
**/ |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
48 |
|
524 | 49 |
UNS8 buildPDO (CO_Data * d, UNS8 numPdo, Message * pdo) |
425 | 50 |
{ |
51 |
const indextable *TPDO_com = d->objdict + d->firstIndex->PDO_TRS + numPdo; |
|
524 | 52 |
const indextable *TPDO_map = d->objdict + d->firstIndex->PDO_TRS_MAP + numPdo; |
425 | 53 |
|
54 |
UNS8 prp_j = 0x00; |
|
587 | 55 |
UNS32 offset = 0x00000000; |
425 | 56 |
const UNS8 *pMappingCount = (UNS8 *) TPDO_map->pSubindex[0].pObject; |
57 |
||
428 | 58 |
pdo->cob_id = UNS16_LE(*(UNS32*)TPDO_com->pSubindex[1].pObject & 0x7FF); |
425 | 59 |
pdo->rtr = NOT_A_REQUEST; |
60 |
||
61 |
MSG_WAR (0x3009, " PDO CobId is : ", |
|
62 |
*(UNS32 *) TPDO_com->pSubindex[1].pObject); |
|
63 |
MSG_WAR (0x300D, " Number of objects mapped : ", *pMappingCount); |
|
64 |
||
65 |
do |
|
66 |
{ |
|
67 |
UNS8 dataType; /* Unused */ |
|
68 |
UNS8 tmp[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; /* temporary space to hold bits */ |
|
69 |
||
70 |
/* pointer fo the var which holds the mapping parameter of an mapping entry */ |
|
71 |
UNS32 *pMappingParameter = |
|
72 |
(UNS32 *) TPDO_map->pSubindex[prp_j + 1].pObject; |
|
73 |
UNS16 index = (UNS16) ((*pMappingParameter) >> 16); |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
524
diff
changeset
|
74 |
UNS32 Size = (UNS32) (*pMappingParameter & (UNS32) 0x000000FF); /* Size in bits */ |
425 | 75 |
|
76 |
/* get variable only if Size != 0 and Size is lower than remaining bits in the PDO */ |
|
77 |
if (Size && ((offset + Size) <= 64)) |
|
78 |
{ |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
524
diff
changeset
|
79 |
UNS32 ByteSize = 1 + ((Size - 1) >> 3); /*1->8 => 1 ; 9->16 => 2, ... */ |
425 | 80 |
UNS8 subIndex = |
81 |
(UNS8) (((*pMappingParameter) >> (UNS8) 8) & (UNS32) 0x000000FF); |
|
82 |
||
83 |
MSG_WAR (0x300F, " got mapping parameter : ", *pMappingParameter); |
|
84 |
MSG_WAR (0x3050, " at index : ", TPDO_map->index); |
|
85 |
MSG_WAR (0x3051, " sub-index : ", prp_j + 1); |
|
86 |
||
87 |
if (getODentry (d, index, subIndex, tmp, &ByteSize, &dataType, 0) != |
|
88 |
OD_SUCCESSFUL) |
|
89 |
{ |
|
90 |
MSG_ERR (0x1013, |
|
91 |
" Couldn't find mapped variable at index-subindex-size : ", |
|
92 |
(UNS16) (*pMappingParameter)); |
|
93 |
return 0xFF; |
|
94 |
} |
|
95 |
/* copy bit per bit in little endian */ |
|
587 | 96 |
CopyBits ((UNS8) Size, ((UNS8 *) tmp), 0, 0, |
97 |
(UNS8 *) & pdo->data[offset >> 3], (UNS8)(offset % 8), 0); |
|
425 | 98 |
|
99 |
offset += Size; |
|
100 |
} |
|
101 |
prp_j++; |
|
102 |
} |
|
103 |
while (prp_j < *pMappingCount); |
|
104 |
||
587 | 105 |
pdo->len = (UNS8)(1 + ((offset - 1) >> 3)); |
425 | 106 |
|
107 |
MSG_WAR (0x3015, " End scan mapped variable", 0); |
|
108 |
||
109 |
return 0; |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
110 |
} |
208 | 111 |
|
112 |
/*! |
|
113 |
** |
|
114 |
** |
|
115 |
** @param d |
|
116 |
** @param cobId |
|
117 |
** |
|
118 |
** @return |
|
119 |
**/ |
|
425 | 120 |
UNS8 |
121 |
sendPDOrequest (CO_Data * d, UNS16 RPDOIndex) |
|
122 |
{ |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
123 |
UNS32 *pwCobId; |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
124 |
UNS16 offset = d->firstIndex->PDO_RCV; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
125 |
UNS16 lastIndex = d->lastIndex->PDO_RCV; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
126 |
|
215 | 127 |
/* Sending the request only if the cobid have been found on the PDO |
208 | 128 |
receive */ |
215 | 129 |
/* part dictionary */ |
425 | 130 |
|
131 |
MSG_WAR (0x3930, "sendPDOrequest RPDO Index : ", RPDOIndex); |
|
132 |
||
133 |
if (offset && RPDOIndex >= 0x1400) |
|
134 |
{ |
|
135 |
offset += RPDOIndex - 0x1400; |
|
136 |
if (offset <= lastIndex) |
|
137 |
{ |
|
138 |
/* get the CobId */ |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
139 |
pwCobId = d->objdict[offset].pSubindex[1].pObject; |
425 | 140 |
|
141 |
MSG_WAR (0x3930, "sendPDOrequest cobId is : ", *pwCobId); |
|
142 |
{ |
|
143 |
Message pdo; |
|
587 | 144 |
pdo.cob_id = (UNS16)UNS16_LE(*pwCobId); |
425 | 145 |
pdo.rtr = REQUEST; |
146 |
pdo.len = 0; |
|
147 |
return canSend (d->canHandle, &pdo); |
|
148 |
} |
|
149 |
} |
|
208 | 150 |
} |
425 | 151 |
MSG_ERR (0x1931, "sendPDOrequest : RPDO Index not found : ", RPDOIndex); |
0 | 152 |
return 0xFF; |
153 |
} |
|
154 |
||
155 |
||
208 | 156 |
/*! |
157 |
** |
|
158 |
** |
|
159 |
** @param d |
|
160 |
** @param m |
|
161 |
** |
|
162 |
** @return |
|
163 |
**/ |
|
425 | 164 |
UNS8 |
165 |
proceedPDO (CO_Data * d, Message * m) |
|
166 |
{ |
|
167 |
UNS8 numPdo; |
|
168 |
UNS8 numMap; /* Number of the mapped varable */ |
|
169 |
UNS8 *pMappingCount = NULL; /* count of mapped objects... */ |
|
215 | 170 |
/* pointer to the var which is mapped to a pdo... */ |
171 |
/* void * pMappedAppObject = NULL; */ |
|
172 |
/* pointer fo the var which holds the mapping parameter of an |
|
208 | 173 |
mapping entry */ |
425 | 174 |
UNS32 *pMappingParameter = NULL; |
175 |
UNS8 *pTransmissionType = NULL; /* pointer to the transmission |
|
176 |
type */ |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
177 |
UNS32 *pwCobId = NULL; |
425 | 178 |
UNS8 Size; |
179 |
UNS8 offset; |
|
180 |
UNS8 status; |
|
181 |
UNS32 objDict; |
|
182 |
UNS16 offsetObjdict; |
|
183 |
UNS16 lastIndex; |
|
184 |
||
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
185 |
status = state2; |
208 | 186 |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
187 |
MSG_WAR (0x3935, "proceedPDO, cobID : ", (UNS16_LE(m->cob_id) & 0x7ff)); |
0 | 188 |
offset = 0x00; |
189 |
numPdo = 0; |
|
190 |
numMap = 0; |
|
425 | 191 |
if ((*m).rtr == NOT_A_REQUEST) |
192 |
{ /* The PDO received is not a |
|
193 |
request. */ |
|
194 |
||
195 |
offsetObjdict = d->firstIndex->PDO_RCV; |
|
196 |
lastIndex = d->lastIndex->PDO_RCV; |
|
197 |
||
198 |
/* study of all the PDO stored in the dictionary */ |
|
199 |
if (offsetObjdict) |
|
200 |
while (offsetObjdict <= lastIndex) |
|
201 |
{ |
|
202 |
||
203 |
switch (status) |
|
204 |
{ |
|
205 |
||
206 |
case state2: |
|
207 |
/* get CobId of the dictionary correspondant to the received |
|
208 |
PDO */ |
|
209 |
pwCobId = |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
210 |
d->objdict[offsetObjdict].pSubindex[1].pObject; |
425 | 211 |
/* check the CobId coherance */ |
212 |
/*pwCobId is the cobId read in the dictionary at the state 3 |
|
213 |
*/ |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
214 |
if (*pwCobId == UNS16_LE(m->cob_id)) |
425 | 215 |
{ |
216 |
/* The cobId is recognized */ |
|
217 |
status = state4; |
|
218 |
MSG_WAR (0x3936, "cobId found at index ", |
|
219 |
0x1400 + numPdo); |
|
220 |
break; |
|
221 |
} |
|
222 |
else |
|
223 |
{ |
|
224 |
/* cobId received does not match with those write in the |
|
225 |
dictionnary */ |
|
226 |
numPdo++; |
|
227 |
offsetObjdict++; |
|
228 |
status = state2; |
|
229 |
break; |
|
230 |
} |
|
231 |
||
232 |
case state4: /* Get Mapped Objects Number */ |
|
233 |
/* The cobId of the message received has been found in the |
|
234 |
dictionnary. */ |
|
235 |
offsetObjdict = d->firstIndex->PDO_RCV_MAP; |
|
236 |
lastIndex = d->lastIndex->PDO_RCV_MAP; |
|
237 |
pMappingCount = |
|
238 |
(UNS8 *) (d->objdict + offsetObjdict + |
|
239 |
numPdo)->pSubindex[0].pObject; |
|
240 |
numMap = 0; |
|
241 |
while (numMap < *pMappingCount) |
|
242 |
{ |
|
243 |
UNS8 tmp[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
524
diff
changeset
|
244 |
UNS32 ByteSize; |
425 | 245 |
pMappingParameter = |
246 |
(UNS32 *) (d->objdict + offsetObjdict + |
|
247 |
numPdo)->pSubindex[numMap + 1].pObject; |
|
248 |
if (pMappingParameter == NULL) |
|
249 |
{ |
|
250 |
MSG_ERR (0x1937, "Couldn't get mapping parameter : ", |
|
251 |
numMap + 1); |
|
252 |
return 0xFF; |
|
253 |
} |
|
254 |
/* Get the addresse of the mapped variable. */ |
|
255 |
/* detail of *pMappingParameter : */ |
|
256 |
/* The 16 hight bits contains the index, the medium 8 bits |
|
257 |
contains the subindex, */ |
|
258 |
/* and the lower 8 bits contains the size of the mapped |
|
259 |
variable. */ |
|
260 |
||
261 |
Size = (UNS8) (*pMappingParameter & (UNS32) 0x000000FF); |
|
262 |
||
497 | 263 |
/* set variable only if Size != 0 and |
264 |
* Size is lower than remaining bits in the PDO */ |
|
425 | 265 |
if (Size && ((offset + Size) <= (m->len << 3))) |
266 |
{ |
|
267 |
/* copy bit per bit in little endian */ |
|
268 |
CopyBits (Size, (UNS8 *) & m->data[offset >> 3], |
|
269 |
offset % 8, 0, ((UNS8 *) tmp), 0, 0); |
|
497 | 270 |
/*1->8 => 1 ; 9->16 =>2, ... */ |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
524
diff
changeset
|
271 |
ByteSize = (UNS32)(1 + ((Size - 1) >> 3)); |
425 | 272 |
|
273 |
objDict = |
|
274 |
setODentry (d, (UNS16) ((*pMappingParameter) >> 16), |
|
275 |
(UNS8) (((*pMappingParameter) >> 8) & |
|
276 |
0xFF), tmp, &ByteSize, 0); |
|
277 |
||
278 |
if (objDict != OD_SUCCESSFUL) |
|
279 |
{ |
|
280 |
MSG_ERR (0x1938, |
|
281 |
"error accessing to the mapped var : ", |
|
282 |
numMap + 1); |
|
283 |
MSG_WAR (0x2939, " Mapped at index : ", |
|
284 |
(*pMappingParameter) >> 16); |
|
285 |
MSG_WAR (0x2940, " subindex : ", |
|
286 |
((*pMappingParameter) >> 8) & 0xFF); |
|
287 |
return 0xFF; |
|
288 |
} |
|
289 |
||
290 |
MSG_WAR (0x3942, |
|
497 | 291 |
"Variable updated by PDO cobid : ", |
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
292 |
UNS16_LE(m->cob_id)); |
425 | 293 |
MSG_WAR (0x3943, " Mapped at index : ", |
294 |
(*pMappingParameter) >> 16); |
|
295 |
MSG_WAR (0x3944, " subindex : ", |
|
296 |
((*pMappingParameter) >> 8) & 0xFF); |
|
297 |
offset += Size; |
|
298 |
} |
|
299 |
numMap++; |
|
300 |
} /* end loop while on mapped variables */ |
|
301 |
||
302 |
return 0; |
|
303 |
||
304 |
} /* end switch status */ |
|
305 |
} /* end while */ |
|
306 |
} /* end if Donnees */ |
|
307 |
else if ((*m).rtr == REQUEST) |
|
308 |
{ |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
309 |
MSG_WAR (0x3946, "Receive a PDO request cobId : ", UNS16_LE(m->cob_id)); |
425 | 310 |
status = state1; |
311 |
offsetObjdict = d->firstIndex->PDO_TRS; |
|
312 |
lastIndex = d->lastIndex->PDO_TRS; |
|
313 |
if (offsetObjdict) |
|
314 |
while (offsetObjdict <= lastIndex) |
|
315 |
{ |
|
316 |
/* study of all PDO stored in the objects dictionary */ |
|
317 |
||
318 |
switch (status) |
|
319 |
{ |
|
320 |
||
321 |
case state1: /* check the CobId */ |
|
322 |
/* get CobId of the dictionary which match to the received PDO |
|
323 |
*/ |
|
324 |
pwCobId = |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
325 |
(d->objdict + |
425 | 326 |
offsetObjdict)->pSubindex[1].pObject; |
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
327 |
if (*pwCobId == UNS16_LE(m->cob_id)) |
425 | 328 |
{ |
329 |
status = state4; |
|
330 |
break; |
|
331 |
} |
|
332 |
else |
|
333 |
{ |
|
334 |
numPdo++; |
|
335 |
offsetObjdict++; |
|
336 |
} |
|
337 |
status = state1; |
|
338 |
break; |
|
339 |
||
340 |
||
341 |
case state4: /* check transmission type */ |
|
342 |
pTransmissionType = |
|
343 |
(UNS8 *) d->objdict[offsetObjdict].pSubindex[2].pObject; |
|
344 |
/* If PDO is to be sampled and send on RTR, do it */ |
|
345 |
if ((*pTransmissionType == TRANS_RTR)) |
|
346 |
{ |
|
347 |
status = state5; |
|
348 |
break; |
|
349 |
} |
|
497 | 350 |
/* RTR_SYNC means data prepared at SYNC, transmitted on RTR */ |
425 | 351 |
else if ((*pTransmissionType == TRANS_RTR_SYNC)) |
352 |
{ |
|
353 |
if (d->PDO_status[numPdo]. |
|
354 |
transmit_type_parameter & PDO_RTR_SYNC_READY) |
|
355 |
{ |
|
356 |
/*Data ready, just send */ |
|
357 |
canSend (d->canHandle, |
|
358 |
&d->PDO_status[numPdo].last_message); |
|
359 |
return 0; |
|
360 |
} |
|
361 |
else |
|
362 |
{ |
|
497 | 363 |
/* if SYNC did never occur, transmit current data */ |
425 | 364 |
/* DS301 do not tell what to do in such a case... */ |
365 |
MSG_ERR (0x1947, |
|
366 |
"Not ready RTR_SYNC TPDO send current data : ", |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
367 |
UNS16_LE(m->cob_id)); |
425 | 368 |
status = state5; |
369 |
} |
|
370 |
break; |
|
371 |
} |
|
372 |
else if ((*pTransmissionType == TRANS_EVENT_PROFILE) || |
|
373 |
(*pTransmissionType == TRANS_EVENT_SPECIFIC)) |
|
374 |
{ |
|
375 |
/* Zap all timers and inhibit flag */ |
|
376 |
d->PDO_status[numPdo].event_timer = |
|
377 |
DelAlarm (d->PDO_status[numPdo].event_timer); |
|
378 |
d->PDO_status[numPdo].inhibit_timer = |
|
379 |
DelAlarm (d->PDO_status[numPdo].inhibit_timer); |
|
380 |
d->PDO_status[numPdo].transmit_type_parameter &= |
|
381 |
~PDO_INHIBITED; |
|
497 | 382 |
/* Call PDOEventTimerAlarm for this TPDO, |
383 |
* this will trigger emission et reset timers */ |
|
425 | 384 |
PDOEventTimerAlarm (d, numPdo); |
385 |
return 0; |
|
386 |
} |
|
387 |
else |
|
388 |
{ |
|
389 |
/* The requested PDO is not to send on request. So, does |
|
390 |
nothing. */ |
|
391 |
MSG_WAR (0x2947, "PDO is not to send on request : ", |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
392 |
UNS16_LE(m->cob_id)); |
425 | 393 |
return 0xFF; |
394 |
} |
|
395 |
||
396 |
case state5: /* build and send requested PDO */ |
|
397 |
{ |
|
398 |
Message pdo; |
|
399 |
if (buildPDO (d, numPdo, &pdo)) |
|
400 |
{ |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
401 |
MSG_ERR (0x1948, " Couldn't build TPDO n�", numPdo); |
425 | 402 |
return 0xFF; |
403 |
} |
|
404 |
canSend (d->canHandle, &pdo); |
|
405 |
return 0; |
|
406 |
} |
|
407 |
} /* end switch status */ |
|
408 |
} /* end while */ |
|
409 |
} /* end if Requete */ |
|
208 | 410 |
|
0 | 411 |
return 0; |
412 |
} |
|
413 |
||
208 | 414 |
/*! |
415 |
** |
|
416 |
** |
|
417 |
** @param NbBits |
|
418 |
** @param SrcByteIndex |
|
419 |
** @param SrcBitIndex |
|
420 |
** @param SrcBigEndian |
|
421 |
** @param DestByteIndex |
|
422 |
** @param DestBitIndex |
|
423 |
** @param DestBigEndian |
|
424 |
**/ |
|
425 | 425 |
void |
426 |
CopyBits (UNS8 NbBits, UNS8 * SrcByteIndex, UNS8 SrcBitIndex, |
|
427 |
UNS8 SrcBigEndian, UNS8 * DestByteIndex, UNS8 DestBitIndex, |
|
428 |
UNS8 DestBigEndian) |
|
429 |
{ |
|
430 |
/* This loop copy as many bits that it can each time, crossing */ |
|
431 |
/* successively bytes */ |
|
208 | 432 |
// boundaries from LSB to MSB. |
425 | 433 |
while (NbBits > 0) |
208 | 434 |
{ |
425 | 435 |
/* Bit missalignement between src and dest */ |
208 | 436 |
INTEGER8 Vect = DestBitIndex - SrcBitIndex; |
437 |
||
425 | 438 |
/* We can now get src and align it to dest */ |
439 |
UNS8 Aligned = |
|
440 |
Vect > 0 ? *SrcByteIndex << Vect : *SrcByteIndex >> -Vect; |
|
441 |
||
442 |
/* Compute the nb of bit we will be able to copy */ |
|
443 |
UNS8 BoudaryLimit = (Vect > 0 ? 8 - DestBitIndex : 8 - SrcBitIndex); |
|
208 | 444 |
UNS8 BitsToCopy = BoudaryLimit > NbBits ? NbBits : BoudaryLimit; |
445 |
||
425 | 446 |
/* Create a mask that will serve in: */ |
447 |
UNS8 Mask = |
|
448 |
((0xff << (DestBitIndex + BitsToCopy)) | |
|
449 |
(0xff >> (8 - DestBitIndex))); |
|
450 |
||
451 |
/* - Filtering src */ |
|
208 | 452 |
UNS8 Filtered = Aligned & ~Mask; |
453 |
||
425 | 454 |
/* - and erase bits where we write, preserve where we don't */ |
208 | 455 |
*DestByteIndex &= Mask; |
456 |
||
425 | 457 |
/* Then write. */ |
458 |
*DestByteIndex |= Filtered; |
|
459 |
||
460 |
/*Compute next time cursors for src */ |
|
461 |
if ((SrcBitIndex += BitsToCopy) > 7) /* cross boundary ? */ |
|
208 | 462 |
{ |
425 | 463 |
SrcBitIndex = 0; /* First bit */ |
464 |
SrcByteIndex += (SrcBigEndian ? -1 : 1); /* Next byte */ |
|
215 | 465 |
} |
466 |
||
467 |
||
425 | 468 |
/*Compute next time cursors for dest */ |
469 |
if ((DestBitIndex += BitsToCopy) > 7) |
|
208 | 470 |
{ |
425 | 471 |
DestBitIndex = 0; /* First bit */ |
472 |
DestByteIndex += (DestBigEndian ? -1 : 1); /* Next byte */ |
|
215 | 473 |
} |
474 |
||
425 | 475 |
/*And decrement counter. */ |
208 | 476 |
NbBits -= BitsToCopy; |
477 |
} |
|
201 | 478 |
|
479 |
} |
|
425 | 480 |
|
208 | 481 |
/*! |
482 |
** |
|
483 |
** |
|
484 |
** @param d |
|
485 |
** |
|
486 |
** @return |
|
487 |
**/ |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
488 |
|
425 | 489 |
UNS8 |
490 |
sendPDOevent (CO_Data * d) |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
491 |
{ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
492 |
/* Calls _sendPDOevent specifying it is not a sync event */ |
425 | 493 |
return _sendPDOevent (d, 0); |
494 |
} |
|
495 |
||
496 |
||
497 |
void |
|
498 |
PDOEventTimerAlarm (CO_Data * d, UNS32 pdoNum) |
|
499 |
{ |
|
500 |
/* This is needed to avoid deletion of re-attribuated timer */ |
|
501 |
d->PDO_status[pdoNum].event_timer = TIMER_NONE; |
|
502 |
/* force emission of PDO by artificially changing last emitted */ |
|
503 |
d->PDO_status[pdoNum].last_message.cob_id = 0; |
|
504 |
_sendPDOevent (d, 0); /* not a Sync Event */ |
|
505 |
} |
|
506 |
||
507 |
void |
|
508 |
PDOInhibitTimerAlarm (CO_Data * d, UNS32 pdoNum) |
|
509 |
{ |
|
510 |
/* This is needed to avoid deletion of re-attribuated timer */ |
|
511 |
d->PDO_status[pdoNum].inhibit_timer = TIMER_NONE; |
|
512 |
/* Remove inhibit flag */ |
|
513 |
d->PDO_status[pdoNum].transmit_type_parameter &= ~PDO_INHIBITED; |
|
514 |
_sendPDOevent (d, 0); /* not a Sync Event */ |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
515 |
} |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
516 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
517 |
/*! |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
518 |
** |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
519 |
** |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
520 |
** @param d |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
521 |
** @param isSyncEvent |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
522 |
** |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
523 |
** @return |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
524 |
**/ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
525 |
|
425 | 526 |
UNS8 |
527 |
_sendPDOevent (CO_Data * d, UNS8 isSyncEvent) |
|
528 |
{ |
|
529 |
UNS8 pdoNum = 0x00; /* number of the actual processed pdo-nr. */ |
|
530 |
UNS8 *pTransmissionType = NULL; |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
531 |
UNS8 status = state3; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
532 |
UNS16 offsetObjdict = d->firstIndex->PDO_TRS; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
533 |
UNS16 offsetObjdictMap = d->firstIndex->PDO_TRS_MAP; |
425 | 534 |
UNS16 lastIndex = d->lastIndex->PDO_TRS; |
535 |
||
536 |
/* study all PDO stored in the objects dictionary */ |
|
537 |
if (offsetObjdict) |
|
538 |
{ |
|
497 | 539 |
Message pdo;/* = Message_Initializer;*/ |
540 |
memset(&pdo, 0, sizeof(pdo)); |
|
425 | 541 |
while (offsetObjdict <= lastIndex) |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
542 |
{ |
425 | 543 |
switch (status) |
544 |
{ |
|
545 |
case state3: |
|
497 | 546 |
if ( /* bSubCount always 5 with objdictedit -> check disabled */ |
547 |
/*d->objdict[offsetObjdict].bSubCount < 5 ||*/ |
|
425 | 548 |
/* check if TPDO is not valid */ |
549 |
*(UNS32 *) d->objdict[offsetObjdict].pSubindex[1]. |
|
550 |
pObject & 0x80000000) |
|
551 |
{ |
|
552 |
MSG_WAR (0x3960, "Not a valid PDO ", 0x1800 + pdoNum); |
|
553 |
/*Go next TPDO */ |
|
554 |
status = state11; |
|
555 |
break; |
|
556 |
} |
|
557 |
/* get the PDO transmission type */ |
|
558 |
pTransmissionType = |
|
559 |
(UNS8 *) d->objdict[offsetObjdict].pSubindex[2].pObject; |
|
560 |
MSG_WAR (0x3962, "Reading PDO at index : ", 0x1800 + pdoNum); |
|
561 |
||
562 |
/* check if transmission type is SYNCRONOUS */ |
|
497 | 563 |
/* message transmited every n SYNC with n=TransmissionType */ |
425 | 564 |
if (isSyncEvent && |
565 |
(*pTransmissionType >= TRANS_SYNC_MIN) && |
|
566 |
(*pTransmissionType <= TRANS_SYNC_MAX) && |
|
567 |
(++d->PDO_status[pdoNum].transmit_type_parameter == |
|
568 |
*pTransmissionType)) |
|
569 |
{ |
|
570 |
/*Reset count of SYNC */ |
|
571 |
d->PDO_status[pdoNum].transmit_type_parameter = 0; |
|
572 |
MSG_WAR (0x3964, " PDO is on SYNCHRO. Trans type : ", |
|
573 |
*pTransmissionType); |
|
497 | 574 |
memset(&pdo, 0, sizeof(pdo)); |
575 |
/*{ |
|
425 | 576 |
Message msg_init = Message_Initializer; |
577 |
pdo = msg_init; |
|
497 | 578 |
}*/ |
425 | 579 |
if (buildPDO (d, pdoNum, &pdo)) |
580 |
{ |
|
581 |
MSG_ERR (0x1906, " Couldn't build TPDO number : ", |
|
582 |
pdoNum); |
|
583 |
status = state11; |
|
584 |
break; |
|
585 |
} |
|
586 |
status = state5; |
|
587 |
/* If transmission RTR, with data sampled on SYNC */ |
|
588 |
} |
|
589 |
else if (isSyncEvent && (*pTransmissionType == TRANS_RTR_SYNC)) |
|
590 |
{ |
|
591 |
if (buildPDO |
|
592 |
(d, pdoNum, &d->PDO_status[pdoNum].last_message)) |
|
593 |
{ |
|
594 |
MSG_ERR (0x1966, " Couldn't build TPDO number : ", |
|
595 |
pdoNum); |
|
596 |
d->PDO_status[pdoNum].transmit_type_parameter &= |
|
597 |
~PDO_RTR_SYNC_READY; |
|
598 |
} |
|
599 |
else |
|
600 |
{ |
|
601 |
d->PDO_status[pdoNum].transmit_type_parameter |= |
|
602 |
PDO_RTR_SYNC_READY; |
|
603 |
} |
|
604 |
status = state11; |
|
605 |
break; |
|
606 |
/* If transmission on Event and not inhibited, check for changes */ |
|
607 |
} |
|
426
8011552b1319
Preliminary support for TRANS_SYNC_ACYCLIC (0) transmit type.
etisserant
parents:
425
diff
changeset
|
608 |
else |
8011552b1319
Preliminary support for TRANS_SYNC_ACYCLIC (0) transmit type.
etisserant
parents:
425
diff
changeset
|
609 |
if ((isSyncEvent |
8011552b1319
Preliminary support for TRANS_SYNC_ACYCLIC (0) transmit type.
etisserant
parents:
425
diff
changeset
|
610 |
&& (*pTransmissionType == TRANS_SYNC_ACYCLIC)) |
8011552b1319
Preliminary support for TRANS_SYNC_ACYCLIC (0) transmit type.
etisserant
parents:
425
diff
changeset
|
611 |
|| |
8011552b1319
Preliminary support for TRANS_SYNC_ACYCLIC (0) transmit type.
etisserant
parents:
425
diff
changeset
|
612 |
((*pTransmissionType == TRANS_EVENT_PROFILE |
8011552b1319
Preliminary support for TRANS_SYNC_ACYCLIC (0) transmit type.
etisserant
parents:
425
diff
changeset
|
613 |
|| *pTransmissionType == TRANS_EVENT_SPECIFIC) |
8011552b1319
Preliminary support for TRANS_SYNC_ACYCLIC (0) transmit type.
etisserant
parents:
425
diff
changeset
|
614 |
&& !(d->PDO_status[pdoNum]. |
8011552b1319
Preliminary support for TRANS_SYNC_ACYCLIC (0) transmit type.
etisserant
parents:
425
diff
changeset
|
615 |
transmit_type_parameter & PDO_INHIBITED))) |
425 | 616 |
{ |
617 |
MSG_WAR (0x3968, " PDO is on EVENT. Trans type : ", |
|
618 |
*pTransmissionType); |
|
497 | 619 |
memset(&pdo, 0, sizeof(pdo)); |
620 |
/*{ |
|
425 | 621 |
Message msg_init = Message_Initializer; |
622 |
pdo = msg_init; |
|
497 | 623 |
}*/ |
425 | 624 |
if (buildPDO (d, pdoNum, &pdo)) |
625 |
{ |
|
626 |
MSG_ERR (0x3907, " Couldn't build TPDO number : ", |
|
627 |
pdoNum); |
|
628 |
status = state11; |
|
629 |
break; |
|
630 |
} |
|
631 |
||
632 |
/*Compare new and old PDO */ |
|
633 |
if (d->PDO_status[pdoNum].last_message.cob_id == pdo.cob_id |
|
497 | 634 |
&& d->PDO_status[pdoNum].last_message.len == pdo.len |
635 |
&& memcmp(d->PDO_status[pdoNum].last_message.data, |
|
474
09c8c4b6c7df
Fixed alignments problems on some 32bit target such as ARM or Xscale.
etisserant
parents:
447
diff
changeset
|
636 |
pdo.data, 8) == 0 |
425 | 637 |
) |
638 |
{ |
|
639 |
/* No changes -> go to next pdo */ |
|
640 |
status = state11; |
|
641 |
} |
|
642 |
else |
|
643 |
{ |
|
644 |
||
524 | 645 |
TIMEVAL EventTimerDuration; |
646 |
TIMEVAL InhibitTimerDuration; |
|
425 | 647 |
|
648 |
MSG_WAR (0x306A, "Changes TPDO number : ", pdoNum); |
|
649 |
/* Changes detected -> transmit message */ |
|
650 |
EventTimerDuration = |
|
651 |
*(UNS16 *) d->objdict[offsetObjdict].pSubindex[5]. |
|
652 |
pObject; |
|
653 |
InhibitTimerDuration = |
|
654 |
*(UNS16 *) d->objdict[offsetObjdict].pSubindex[3]. |
|
655 |
pObject; |
|
656 |
||
657 |
status = state5; |
|
658 |
||
659 |
/* Start both event_timer and inhibit_timer */ |
|
660 |
if (EventTimerDuration) |
|
661 |
{ |
|
662 |
DelAlarm (d->PDO_status[pdoNum].event_timer); |
|
663 |
d->PDO_status[pdoNum].event_timer = |
|
664 |
SetAlarm (d, pdoNum, &PDOEventTimerAlarm, |
|
665 |
MS_TO_TIMEVAL (EventTimerDuration), 0); |
|
666 |
} |
|
667 |
||
668 |
if (InhibitTimerDuration) |
|
669 |
{ |
|
670 |
DelAlarm (d->PDO_status[pdoNum].inhibit_timer); |
|
671 |
d->PDO_status[pdoNum].inhibit_timer = |
|
672 |
SetAlarm (d, pdoNum, &PDOInhibitTimerAlarm, |
|
673 |
US_TO_TIMEVAL (InhibitTimerDuration * |
|
674 |
100), 0); |
|
675 |
/* and inhibit TPDO */ |
|
676 |
d->PDO_status[pdoNum].transmit_type_parameter |= |
|
677 |
PDO_INHIBITED; |
|
678 |
} |
|
679 |
||
680 |
} |
|
681 |
} |
|
682 |
else |
|
683 |
{ |
|
684 |
MSG_WAR (0x306C, |
|
685 |
" PDO is not on EVENT or synchro or not at this SYNC. Trans type : ", |
|
686 |
*pTransmissionType); |
|
687 |
status = state11; |
|
688 |
} |
|
689 |
break; |
|
690 |
case state5: /*Send the pdo */ |
|
691 |
/*store_as_last_message */ |
|
692 |
d->PDO_status[pdoNum].last_message = pdo; |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
428
diff
changeset
|
693 |
MSG_WAR (0x396D, "sendPDO cobId :", UNS16_LE(pdo.cob_id)); |
425 | 694 |
MSG_WAR (0x396E, " Nb octets : ", pdo.len); |
695 |
||
696 |
canSend (d->canHandle, &pdo); |
|
697 |
status = state11; |
|
698 |
break; |
|
699 |
case state11: /*Go to next TPDO */ |
|
700 |
pdoNum++; |
|
701 |
offsetObjdict++; |
|
702 |
offsetObjdictMap++; |
|
703 |
MSG_WAR (0x3970, "next pdo index : ", pdoNum); |
|
704 |
status = state3; |
|
705 |
break; |
|
706 |
||
707 |
default: |
|
708 |
MSG_ERR (0x1972, "Unknown state has been reached : %d", status); |
|
709 |
return 0xFF; |
|
710 |
} /* end switch case */ |
|
711 |
||
712 |
} /* end while */ |
|
713 |
} |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
714 |
return 0; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
715 |
} |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
716 |
|
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
717 |
/*! |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
718 |
** |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
719 |
** |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
720 |
** @param d |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
721 |
** @param OD_entry |
524 | 722 |
** @param bSubindex |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
723 |
** @return always 0 |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
724 |
**/ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
725 |
|
425 | 726 |
UNS32 |
727 |
TPDO_Communication_Parameter_Callback (CO_Data * d, |
|
728 |
const indextable * OD_entry, |
|
729 |
UNS8 bSubindex) |
|
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
730 |
{ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
731 |
/* If PDO are actives */ |
425 | 732 |
if (d->CurrentCommunicationState.csPDO) |
733 |
switch (bSubindex) |
|
734 |
{ |
|
735 |
case 2: /* Changed transmition type */ |
|
736 |
case 3: /* Changed inhibit time */ |
|
737 |
case 5: /* Changed event time */ |
|
738 |
{ |
|
739 |
const indextable *TPDO_com = d->objdict + d->firstIndex->PDO_TRS; |
|
740 |
UNS8 numPdo = OD_entry - TPDO_com; /* number of the actual processed pdo-nr. */ |
|
741 |
||
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
742 |
/* Zap all timers and inhibit flag */ |
425 | 743 |
d->PDO_status[numPdo].event_timer = |
744 |
DelAlarm (d->PDO_status[numPdo].event_timer); |
|
745 |
d->PDO_status[numPdo].inhibit_timer = |
|
746 |
DelAlarm (d->PDO_status[numPdo].inhibit_timer); |
|
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
747 |
d->PDO_status[numPdo].transmit_type_parameter = 0; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
748 |
/* Call PDOEventTimerAlarm for this TPDO, this will trigger emission et reset timers */ |
425 | 749 |
PDOEventTimerAlarm (d, numPdo); |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
750 |
return 0; |
425 | 751 |
} |
752 |
||
753 |
default: /* other subindex are ignored */ |
|
754 |
break; |
|
755 |
} |
|
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
756 |
return 0; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
757 |
} |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
758 |
|
425 | 759 |
void |
760 |
PDOInit (CO_Data * d) |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
761 |
{ |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
762 |
/* For each TPDO mapping parameters */ |
425 | 763 |
UNS16 pdoIndex = 0x1800; /* OD index of TDPO */ |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
764 |
|
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
765 |
UNS16 offsetObjdict = d->firstIndex->PDO_TRS; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
766 |
UNS16 lastIndex = d->lastIndex->PDO_TRS; |
425 | 767 |
if (offsetObjdict) |
768 |
while (offsetObjdict <= lastIndex) |
|
769 |
{ |
|
770 |
/* Assign callbacks to sensible TPDO mapping subindexes */ |
|
771 |
UNS32 errorCode; |
|
772 |
ODCallback_t *CallbackList; |
|
773 |
/* Find callback list */ |
|
774 |
scanIndexOD (d, pdoIndex, &errorCode, &CallbackList); |
|
775 |
if (errorCode == OD_SUCCESSFUL && CallbackList) |
|
776 |
{ |
|
777 |
/*Assign callbacks to corresponding subindex */ |
|
778 |
/* Transmission type */ |
|
779 |
CallbackList[2] = &TPDO_Communication_Parameter_Callback; |
|
780 |
/* Inhibit time */ |
|
781 |
CallbackList[3] = &TPDO_Communication_Parameter_Callback; |
|
782 |
/* Event timer */ |
|
783 |
CallbackList[5] = &TPDO_Communication_Parameter_Callback; |
|
784 |
} |
|
785 |
pdoIndex++; |
|
786 |
offsetObjdict++; |
|
787 |
} |
|
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
788 |
|
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
789 |
/* Trigger a non-sync event */ |
425 | 790 |
_sendPDOevent (d, 0); |
791 |
} |
|
792 |
||
793 |
void |
|
794 |
PDOStop (CO_Data * d) |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
795 |
{ |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
796 |
/* For each TPDO mapping parameters */ |
425 | 797 |
UNS8 pdoNum = 0x00; /* number of the actual processed pdo-nr. */ |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
798 |
UNS16 offsetObjdict = d->firstIndex->PDO_TRS; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
799 |
UNS16 lastIndex = d->lastIndex->PDO_TRS; |
425 | 800 |
if (offsetObjdict) |
801 |
while (offsetObjdict <= lastIndex) |
|
802 |
{ |
|
803 |
/* Delete TPDO timers */ |
|
804 |
d->PDO_status[pdoNum].event_timer = |
|
805 |
DelAlarm (d->PDO_status[pdoNum].event_timer); |
|
806 |
d->PDO_status[pdoNum].inhibit_timer = |
|
807 |
DelAlarm (d->PDO_status[pdoNum].inhibit_timer); |
|
808 |
/* Reset transmit type parameter */ |
|
809 |
d->PDO_status[pdoNum].transmit_type_parameter = 0; |
|
810 |
d->PDO_status[pdoNum].last_message.cob_id = 0; |
|
811 |
pdoNum++; |
|
812 |
offsetObjdict++; |
|
813 |
} |
|
814 |
} |