author | lbessard |
Thu, 18 Oct 2007 10:23:45 +0200 | |
changeset 310 | 1975e546178b |
parent 298 | dba062c5c3c1 |
child 315 | 1d3bf87b8658 |
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" |
0 | 27 |
|
208 | 28 |
/*! |
29 |
** @file pdo.c |
|
30 |
** @author Edouard TISSERANT and Francis DUPIN |
|
31 |
** @date Tue Jun 5 09:32:32 2007 |
|
32 |
** |
|
33 |
** @brief |
|
34 |
** |
|
35 |
** |
|
36 |
*/ |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
37 |
|
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 |
** |
208 | 40 |
** |
41 |
** @param d |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
42 |
** @param TPDO_com TPDO communication parameters OD entry |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
43 |
** @param TPDO_map TPDO mapping parameters OD entry |
208 | 44 |
** |
45 |
** @return |
|
46 |
**/ |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
47 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
48 |
UNS8 buildPDO(CO_Data* d, UNS8 numPdo, Message *pdo) |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
49 |
{ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
50 |
const indextable* TPDO_com = d->objdict + d->firstIndex->PDO_TRS + numPdo; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
51 |
const indextable* TPDO_map = d->objdict + d->firstIndex->PDO_TRS_MAP + numPdo; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
52 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
53 |
UNS8 prp_j = 0x00; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
54 |
UNS8 offset = 0x00; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
55 |
const UNS8* pMappingCount = (UNS8*) TPDO_map->pSubindex[0].pObject; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
56 |
|
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
57 |
pdo->cob_id.w = *(UNS32*)TPDO_com->pSubindex[1].pObject & 0x7FF; |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
58 |
pdo->rtr = NOT_A_REQUEST; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
59 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
60 |
MSG_WAR(0x3009, " PDO CobId is : ", *(UNS32*)TPDO_com->pSubindex[1].pObject); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
61 |
MSG_WAR(0x300D, " Number of objects mapped : ",*pMappingCount ); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
62 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
63 |
do{ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
64 |
UNS8 dataType; /* Unused */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
65 |
UNS8 tmp[]= {0,0,0,0,0,0,0,0}; /* temporary space to hold bits */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
66 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
67 |
/* pointer fo the var which holds the mapping parameter of an mapping entry */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
68 |
UNS32* pMappingParameter = (UNS32*) TPDO_map->pSubindex[prp_j + 1].pObject; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
69 |
UNS16 index = (UNS16)((*pMappingParameter) >> 16); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
70 |
UNS8 Size = (UNS8)(*pMappingParameter); /* Size in bits */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
71 |
UNS8 ByteSize = 1 + ((Size - 1) >> 3); /*1->8 => 1 ; 9->16 => 2, ... */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
72 |
UNS8 subIndex = (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & (UNS32)0x000000FF); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
73 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
74 |
MSG_WAR(0x300F, " got mapping parameter : ", *pMappingParameter); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
75 |
MSG_WAR(0x3050, " at index : ", TPDO_map->index); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
76 |
MSG_WAR(0x3051, " sub-index : ", prp_j + 1); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
77 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
78 |
if( getODentry(d, index, subIndex, tmp, &ByteSize, &dataType, 0 ) != OD_SUCCESSFUL ){ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
79 |
MSG_ERR(0x1013, " Couldn't find mapped variable at index-subindex-size : ", (UNS16)(*pMappingParameter)); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
80 |
return 0xFF; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
81 |
} |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
82 |
/* copy bit per bit in little endian*/ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
83 |
CopyBits(Size, ((UNS8*)tmp), 0 , 0, (UNS8*)&pdo->data[offset>>3], offset%8, 0); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
84 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
85 |
offset += Size ; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
86 |
prp_j++; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
87 |
}while( prp_j < *pMappingCount ); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
88 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
89 |
pdo->len = 1 + ((offset - 1) >> 3); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
90 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
91 |
MSG_WAR(0x3015, " End scan mapped variable", 0); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
92 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
93 |
return 0; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
94 |
} |
208 | 95 |
|
96 |
/*! |
|
97 |
** |
|
98 |
** |
|
99 |
** @param d |
|
100 |
** @param cobId |
|
101 |
** |
|
102 |
** @return |
|
103 |
**/ |
|
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
104 |
UNS8 sendPDOrequest( CO_Data* d, UNS16 RPDOIndex ) |
208 | 105 |
{ |
106 |
UNS32 * pwCobId; |
|
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
107 |
UNS16 offset = d->firstIndex->PDO_RCV; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
108 |
UNS16 lastIndex = d->lastIndex->PDO_RCV; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
109 |
|
215 | 110 |
/* Sending the request only if the cobid have been found on the PDO |
208 | 111 |
receive */ |
215 | 112 |
/* part dictionary */ |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
113 |
|
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
114 |
MSG_WAR(0x3930, "sendPDOrequest RPDO Index : ",RPDOIndex); |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
115 |
|
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
116 |
if (offset && RPDOIndex >= 0x1400){ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
117 |
offset += RPDOIndex - 0x1400; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
118 |
if (offset <= lastIndex) { |
215 | 119 |
/* get the CobId*/ |
217
94c3f89bc3cc
Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents:
215
diff
changeset
|
120 |
pwCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject; |
208 | 121 |
|
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
122 |
MSG_WAR(0x3930, "sendPDOrequest cobId is : ",*pwCobId); |
252 | 123 |
{ |
285
dbf7695290ae
Removed struct initializer with non-constant pointer, making TI compiler fail
etisserant
parents:
252
diff
changeset
|
124 |
Message pdo; |
dbf7695290ae
Removed struct initializer with non-constant pointer, making TI compiler fail
etisserant
parents:
252
diff
changeset
|
125 |
pdo.cob_id.w = *pwCobId; |
dbf7695290ae
Removed struct initializer with non-constant pointer, making TI compiler fail
etisserant
parents:
252
diff
changeset
|
126 |
pdo.rtr = REQUEST; |
dbf7695290ae
Removed struct initializer with non-constant pointer, making TI compiler fail
etisserant
parents:
252
diff
changeset
|
127 |
pdo.len = 0; |
dbf7695290ae
Removed struct initializer with non-constant pointer, making TI compiler fail
etisserant
parents:
252
diff
changeset
|
128 |
return canSend(d->canHandle,&pdo); |
252 | 129 |
} |
208 | 130 |
} |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
131 |
} |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
132 |
MSG_ERR(0x1931, "sendPDOrequest : RPDO Index not found : ", RPDOIndex); |
0 | 133 |
return 0xFF; |
134 |
} |
|
135 |
||
136 |
||
208 | 137 |
/*! |
138 |
** |
|
139 |
** |
|
140 |
** @param d |
|
141 |
** @param m |
|
142 |
** |
|
143 |
** @return |
|
144 |
**/ |
|
0 | 145 |
UNS8 proceedPDO(CO_Data* d, Message *m) |
208 | 146 |
{ |
0 | 147 |
UNS8 numPdo; |
215 | 148 |
UNS8 numMap; /* Number of the mapped varable */ |
0 | 149 |
UNS8 i; |
215 | 150 |
UNS8 * pMappingCount = NULL; /* count of mapped objects... */ |
151 |
/* pointer to the var which is mapped to a pdo... */ |
|
152 |
/* void * pMappedAppObject = NULL; */ |
|
153 |
/* pointer fo the var which holds the mapping parameter of an |
|
208 | 154 |
mapping entry */ |
155 |
UNS32 * pMappingParameter = NULL; |
|
215 | 156 |
UNS8 * pTransmissionType = NULL; /* pointer to the transmission |
208 | 157 |
type */ |
0 | 158 |
UNS32 * pwCobId = NULL; |
159 |
UNS8 Size; |
|
160 |
UNS8 dataType; |
|
161 |
UNS8 offset; |
|
162 |
UNS8 status; |
|
163 |
UNS32 objDict; |
|
164 |
UNS16 offsetObjdict; |
|
165 |
UNS16 lastIndex; |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
166 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
167 |
status = state2; |
208 | 168 |
|
169 |
MSG_WAR(0x3935, "proceedPDO, cobID : ", ((*m).cob_id.w & 0x7ff)); |
|
0 | 170 |
offset = 0x00; |
171 |
numPdo = 0; |
|
172 |
numMap = 0; |
|
215 | 173 |
if((*m).rtr == NOT_A_REQUEST ) { /* The PDO received is not a |
208 | 174 |
request. */ |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
175 |
|
0 | 176 |
offsetObjdict = d->firstIndex->PDO_RCV; |
177 |
lastIndex = d->lastIndex->PDO_RCV; |
|
208 | 178 |
|
215 | 179 |
/* study of all the PDO stored in the dictionary */ |
0 | 180 |
if(offsetObjdict) |
208 | 181 |
while (offsetObjdict <= lastIndex) { |
182 |
||
183 |
switch( status ) { |
|
184 |
||
185 |
case state2: |
|
215 | 186 |
/* get CobId of the dictionary correspondant to the received |
208 | 187 |
PDO */ |
217
94c3f89bc3cc
Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents:
215
diff
changeset
|
188 |
pwCobId = (UNS32*) d->objdict[offsetObjdict].pSubindex[1].pObject; |
215 | 189 |
/* check the CobId coherance */ |
190 |
/*pwCobId is the cobId read in the dictionary at the state 3 |
|
208 | 191 |
*/ |
192 |
if ( *pwCobId == (*m).cob_id.w ){ |
|
215 | 193 |
/* The cobId is recognized */ |
208 | 194 |
status = state4; |
195 |
MSG_WAR(0x3936, "cobId found at index ", 0x1400 + numPdo); |
|
196 |
break; |
|
197 |
} |
|
198 |
else { |
|
215 | 199 |
/* cobId received does not match with those write in the |
208 | 200 |
dictionnary */ |
201 |
numPdo++; |
|
202 |
offsetObjdict++; |
|
203 |
status = state2; |
|
204 |
break; |
|
205 |
} |
|
206 |
||
215 | 207 |
case state4:/* Get Mapped Objects Number */ |
208 |
/* The cobId of the message received has been found in the |
|
208 | 209 |
dictionnary. */ |
210 |
offsetObjdict = d->firstIndex->PDO_RCV_MAP; |
|
211 |
lastIndex = d->lastIndex->PDO_RCV_MAP; |
|
217
94c3f89bc3cc
Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents:
215
diff
changeset
|
212 |
pMappingCount = (UNS8*) (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject; |
208 | 213 |
numMap = 0; |
214 |
while (numMap < *pMappingCount) { |
|
215 |
UNS8 tmp[]= {0,0,0,0,0,0,0,0}; |
|
216 |
UNS8 ByteSize; |
|
217
94c3f89bc3cc
Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents:
215
diff
changeset
|
217 |
pMappingParameter = (UNS32*) (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject; |
208 | 218 |
if (pMappingParameter == NULL) { |
219 |
MSG_ERR(0x1937, "Couldn't get mapping parameter : ", numMap + 1); |
|
220 |
return 0xFF; |
|
221 |
} |
|
215 | 222 |
/* Get the addresse of the mapped variable. */ |
223 |
/* detail of *pMappingParameter : */ |
|
224 |
/* The 16 hight bits contains the index, the medium 8 bits |
|
208 | 225 |
contains the subindex, */ |
215 | 226 |
/* and the lower 8 bits contains the size of the mapped |
208 | 227 |
variable. */ |
228 |
||
229 |
Size = (UNS8)(*pMappingParameter); |
|
230 |
||
215 | 231 |
/* copy bit per bit in little endian */ |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
232 |
CopyBits(Size, (UNS8*)&m->data[offset>>3], offset%8, 0, ((UNS8*)tmp), 0, 0); |
208 | 233 |
|
234 |
ByteSize = 1 + ((Size - 1) >> 3); /*1->8 => 1 ; 9->16 => |
|
235 |
2, ... */ |
|
236 |
||
237 |
objDict = setODentry(d, (UNS16)((*pMappingParameter) >> 16), |
|
238 |
(UNS8)(((*pMappingParameter) >> 8 ) & 0xFF), |
|
239 |
tmp, &ByteSize, 0 ); |
|
240 |
||
241 |
if(objDict != OD_SUCCESSFUL) { |
|
242 |
MSG_ERR(0x1938, "error accessing to the mapped var : ", numMap + 1); |
|
243 |
MSG_WAR(0x2939, " Mapped at index : ", (*pMappingParameter) >> 16); |
|
244 |
MSG_WAR(0x2940, " subindex : ", ((*pMappingParameter) >> 8 ) & 0xFF); |
|
245 |
return 0xFF; |
|
246 |
} |
|
247 |
||
248 |
MSG_WAR(0x3942, "Variable updated with value received by PDO cobid : ", m->cob_id.w); |
|
249 |
MSG_WAR(0x3943, " Mapped at index : ", (*pMappingParameter) >> 16); |
|
250 |
MSG_WAR(0x3944, " subindex : ", ((*pMappingParameter) >> 8 ) & 0xFF); |
|
215 | 251 |
/* MSG_WAR(0x3945, " data : ",*((UNS32*)pMappedAppObject)); */ |
208 | 252 |
offset += Size; |
253 |
numMap++; |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
254 |
/*TODO : check that offset is not not greater that message size (in bit) */ |
215 | 255 |
} /* end loop while on mapped variables */ |
208 | 256 |
|
257 |
offset=0x00; |
|
258 |
numMap = 0; |
|
259 |
return 0; |
|
260 |
||
215 | 261 |
}/* end switch status*/ |
262 |
}/* end while*/ |
|
263 |
}/* end if Donnees */ |
|
208 | 264 |
else if ((*m).rtr == REQUEST ){ |
265 |
MSG_WAR(0x3946, "Receive a PDO request cobId : ", m->cob_id.w); |
|
266 |
status = state1; |
|
267 |
offsetObjdict = d->firstIndex->PDO_TRS; |
|
268 |
lastIndex = d->lastIndex->PDO_TRS; |
|
269 |
if(offsetObjdict) while( offsetObjdict <= lastIndex ){ |
|
215 | 270 |
/* study of all PDO stored in the objects dictionary */ |
208 | 271 |
|
272 |
switch( status ){ |
|
273 |
||
215 | 274 |
case state1:/* check the CobId */ |
275 |
/* get CobId of the dictionary which match to the received PDO |
|
208 | 276 |
*/ |
217
94c3f89bc3cc
Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents:
215
diff
changeset
|
277 |
pwCobId = (UNS32*) (d->objdict + offsetObjdict)->pSubindex[1].pObject; |
208 | 278 |
if ( *pwCobId == (*m).cob_id.w ) { |
279 |
status = state4; |
|
280 |
break; |
|
281 |
} |
|
282 |
else { |
|
283 |
numPdo++; |
|
284 |
offsetObjdict++; |
|
285 |
} |
|
286 |
status = state1; |
|
287 |
break; |
|
288 |
||
289 |
||
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
290 |
case state4:/* check transmission type */ |
217
94c3f89bc3cc
Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents:
215
diff
changeset
|
291 |
pTransmissionType = (UNS8*) d->objdict[offsetObjdict].pSubindex[2].pObject; |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
292 |
/* If PDO is to be sampled and send on RTR, do it*/ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
293 |
if ( (*pTransmissionType == TRANS_RTR)) { |
208 | 294 |
status = state5; |
295 |
break; |
|
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
296 |
/* RTR_SYNC mean data is prepared at SYNC, and transmitted on RTR */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
297 |
}else if ((*pTransmissionType == TRANS_RTR_SYNC )) { |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
298 |
if(d->PDO_status[numPdo].transmit_type_parameter & PDO_RTR_SYNC_READY){ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
299 |
/*Data ready, just send*/ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
300 |
canSend(d->canHandle,&d->PDO_status[numPdo].last_message); |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
301 |
return 0; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
302 |
}else{ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
303 |
/* if SYNC did never occur, force emission with current data */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
304 |
/* DS301 do not tell what to do in such a case...*/ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
305 |
MSG_ERR(0x1947, "Not ready RTR_SYNC TPDO send current data : ", m->cob_id.w); |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
306 |
status = state5; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
307 |
} |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
308 |
break; |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
309 |
}else if( |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
310 |
(*pTransmissionType == TRANS_EVENT_PROFILE) || |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
311 |
(*pTransmissionType == TRANS_EVENT_SPECIFIC) ) { |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
312 |
/* Zap all timers and inhibit flag */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
313 |
d->PDO_status[numPdo].event_timer = DelAlarm(d->PDO_status[numPdo].event_timer); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
314 |
d->PDO_status[numPdo].inhibit_timer = DelAlarm(d->PDO_status[numPdo].inhibit_timer); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
315 |
d->PDO_status[numPdo].transmit_type_parameter &= ~PDO_INHIBITED; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
316 |
/* Call PDOEventTimerAlarm for this TPDO, this will trigger emission et reset timers */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
317 |
PDOEventTimerAlarm(d, numPdo); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
318 |
return 0; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
319 |
}else { |
215 | 320 |
/* The requested PDO is not to send on request. So, does |
208 | 321 |
nothing. */ |
322 |
MSG_WAR(0x2947, "PDO is not to send on request : ", m->cob_id.w); |
|
323 |
return 0xFF; |
|
324 |
} |
|
325 |
||
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
326 |
case state5:/* build and send requested PDO */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
327 |
{ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
328 |
Message pdo; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
329 |
if( buildPDO(d, numPdo, &pdo)) |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
330 |
{ |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
331 |
MSG_ERR(0x1948, " Couldn't build TPDO n°", numPdo); |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
332 |
return 0xFF; |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
333 |
} |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
334 |
canSend(d->canHandle,&pdo); |
208 | 335 |
return 0; |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
336 |
} |
215 | 337 |
}/* end switch status */ |
338 |
}/* end while */ |
|
339 |
}/* end if Requete */ |
|
208 | 340 |
|
0 | 341 |
return 0; |
342 |
} |
|
343 |
||
208 | 344 |
/*! |
345 |
** |
|
346 |
** |
|
347 |
** @param NbBits |
|
348 |
** @param SrcByteIndex |
|
349 |
** @param SrcBitIndex |
|
350 |
** @param SrcBigEndian |
|
351 |
** @param DestByteIndex |
|
352 |
** @param DestBitIndex |
|
353 |
** @param DestBigEndian |
|
354 |
**/ |
|
201 | 355 |
void CopyBits(UNS8 NbBits, UNS8* SrcByteIndex, UNS8 SrcBitIndex, UNS8 SrcBigEndian, UNS8* DestByteIndex, UNS8 DestBitIndex, UNS8 DestBigEndian) |
356 |
{ |
|
215 | 357 |
/* This loop copy as many bits that it can each time, crossing*/ |
358 |
/* successively bytes*/ |
|
208 | 359 |
// boundaries from LSB to MSB. |
360 |
while(NbBits > 0) |
|
361 |
{ |
|
215 | 362 |
/* Bit missalignement between src and dest*/ |
208 | 363 |
INTEGER8 Vect = DestBitIndex - SrcBitIndex; |
364 |
||
215 | 365 |
/* We can now get src and align it to dest*/ |
208 | 366 |
UNS8 Aligned = Vect>0 ? *SrcByteIndex << Vect : *SrcByteIndex >> -Vect; |
367 |
||
215 | 368 |
/* Compute the nb of bit we will be able to copy*/ |
208 | 369 |
UNS8 BoudaryLimit = (Vect>0 ? 8 - DestBitIndex : 8 - SrcBitIndex ); |
370 |
UNS8 BitsToCopy = BoudaryLimit > NbBits ? NbBits : BoudaryLimit; |
|
371 |
||
215 | 372 |
/* Create a mask that will serve in:*/ |
208 | 373 |
UNS8 Mask = ((0xff << (DestBitIndex + BitsToCopy)) | (0xff >> (8 - DestBitIndex))); |
374 |
||
215 | 375 |
/* - Filtering src*/ |
208 | 376 |
UNS8 Filtered = Aligned & ~Mask; |
377 |
||
215 | 378 |
/* - and erase bits where we write, preserve where we don't*/ |
208 | 379 |
*DestByteIndex &= Mask; |
380 |
||
215 | 381 |
/* Then write.*/ |
208 | 382 |
*DestByteIndex |= Filtered ; |
383 |
||
215 | 384 |
/*Compute next time cursors for src*/ |
385 |
if((SrcBitIndex += BitsToCopy)>7)/* cross boundary ?*/ |
|
208 | 386 |
{ |
215 | 387 |
SrcBitIndex = 0;/* First bit*/ |
388 |
SrcByteIndex += (SrcBigEndian ? -1 : 1);/* Next byte*/ |
|
389 |
} |
|
390 |
||
391 |
||
392 |
/*Compute next time cursors for dest*/ |
|
208 | 393 |
if((DestBitIndex += BitsToCopy)>7) |
394 |
{ |
|
215 | 395 |
DestBitIndex = 0;/* First bit*/ |
396 |
DestByteIndex += (DestBigEndian ? -1 : 1);/* Next byte*/ |
|
397 |
} |
|
398 |
||
399 |
/*And decrement counter.*/ |
|
208 | 400 |
NbBits -= BitsToCopy; |
401 |
} |
|
201 | 402 |
|
403 |
} |
|
208 | 404 |
/*! |
405 |
** |
|
406 |
** |
|
407 |
** @param d |
|
408 |
** |
|
409 |
** @return |
|
410 |
**/ |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
411 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
412 |
UNS8 sendPDOevent( CO_Data* d) |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
413 |
{ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
414 |
/* Calls _sendPDOevent specifying it is not a sync event */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
415 |
return _sendPDOevent(d, 0); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
416 |
} |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
417 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
418 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
419 |
void PDOEventTimerAlarm(CO_Data* d, UNS32 pdoNum) |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
420 |
{ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
421 |
/* This is needed to avoid deletion of re-attribuated timer */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
422 |
d->PDO_status[pdoNum].event_timer = TIMER_NONE; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
423 |
/* force emission of PDO by artificially changing last emitted*/ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
424 |
d->PDO_status[pdoNum].last_message.cob_id.w = 0; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
425 |
_sendPDOevent( d, 0 ); /* not a Sync Event*/ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
426 |
} |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
427 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
428 |
void PDOInhibitTimerAlarm(CO_Data* d, UNS32 pdoNum) |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
429 |
{ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
430 |
/* This is needed to avoid deletion of re-attribuated timer */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
431 |
d->PDO_status[pdoNum].inhibit_timer = TIMER_NONE; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
432 |
/* Remove inhibit flag */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
433 |
d->PDO_status[pdoNum].transmit_type_parameter &= ~PDO_INHIBITED; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
434 |
_sendPDOevent( d, 0 ); /* not a Sync Event*/ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
435 |
} |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
436 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
437 |
/*! |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
438 |
** |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
439 |
** |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
440 |
** @param d |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
441 |
** @param isSyncEvent |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
442 |
** |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
443 |
** @return |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
444 |
**/ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
445 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
446 |
UNS8 _sendPDOevent( CO_Data* d, UNS8 isSyncEvent ) |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
447 |
{ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
448 |
UNS8 pdoNum = 0x00; /* number of the actual processed pdo-nr. */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
449 |
UNS8* pTransmissionType = NULL; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
450 |
UNS8 status = state3; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
451 |
UNS16 offsetObjdict = d->firstIndex->PDO_TRS; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
452 |
UNS16 offsetObjdictMap = d->firstIndex->PDO_TRS_MAP; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
453 |
UNS16 lastIndex = d->lastIndex->PDO_TRS; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
454 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
455 |
/* study all PDO stored in the objects dictionary */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
456 |
if(offsetObjdict){ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
457 |
Message pdo = Message_Initializer; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
458 |
while( offsetObjdict <= lastIndex) { |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
459 |
switch( status ) { |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
460 |
case state3: |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
461 |
if (/*d->objdict[offsetObjdict].bSubCount < 5 || not necessary with objdictedit (always 5)*/ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
462 |
/* check if TPDO is not valid */ |
298 | 463 |
*(UNS32*)d->objdict[offsetObjdict].pSubindex[1].pObject & 0x80000000) { |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
464 |
MSG_WAR(0x3960, "Not a valid PDO ", 0x1800 + pdoNum); |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
465 |
/*Go next TPDO*/ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
466 |
status = state11; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
467 |
break; |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
468 |
} |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
469 |
/* get the PDO transmission type */ |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
470 |
pTransmissionType = (UNS8*) d->objdict[offsetObjdict].pSubindex[2].pObject; |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
471 |
MSG_WAR(0x3962, "Reading PDO at index : ", 0x1800 + pdoNum); |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
472 |
|
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
473 |
/* check if transmission type is SYNCRONOUS */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
474 |
/* The message is transmited every n SYNC with n=TransmissionType */ |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
475 |
if( isSyncEvent && |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
476 |
(*pTransmissionType >= TRANS_SYNC_MIN) && |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
477 |
(*pTransmissionType <= TRANS_SYNC_MAX) && |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
478 |
(++d->PDO_status[pdoNum].transmit_type_parameter == *pTransmissionType) ) { |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
479 |
/*Reset count of SYNC*/ |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
480 |
d->PDO_status[pdoNum].transmit_type_parameter = 0; |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
481 |
MSG_WAR(0x3964, " PDO is on SYNCHRO. Trans type : ", *pTransmissionType); |
252 | 482 |
{ |
483 |
Message msg_init = Message_Initializer; |
|
484 |
pdo = msg_init; |
|
485 |
} |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
486 |
if(buildPDO(d, pdoNum, &pdo)) |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
487 |
{ |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
488 |
MSG_ERR(0x1906, " Couldn't build TPDO number : ", pdoNum); |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
489 |
status = state11; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
490 |
break; |
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 |
status = state5; |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
493 |
/* If transmission RTR, with data sampled on SYNC */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
494 |
}else if( isSyncEvent && |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
495 |
(*pTransmissionType == TRANS_RTR_SYNC)) { |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
496 |
if(buildPDO(d, pdoNum, &d->PDO_status[pdoNum].last_message)) |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
497 |
{ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
498 |
MSG_ERR(0x1966, " Couldn't build TPDO number : ", pdoNum); |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
499 |
d->PDO_status[pdoNum].transmit_type_parameter &= ~PDO_RTR_SYNC_READY; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
500 |
}else{ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
501 |
d->PDO_status[pdoNum].transmit_type_parameter |= PDO_RTR_SYNC_READY; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
502 |
} |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
503 |
status = state11; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
504 |
break; |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
505 |
/* If transmission on Event and not inhibited, check for changes */ |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
506 |
}else if((*pTransmissionType == TRANS_EVENT_PROFILE || |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
507 |
*pTransmissionType == TRANS_EVENT_SPECIFIC )&& |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
508 |
!(d->PDO_status[pdoNum].transmit_type_parameter & PDO_INHIBITED)) { |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
509 |
MSG_WAR(0x3968, " PDO is on EVENT. Trans type : ", *pTransmissionType); |
252 | 510 |
{ |
511 |
Message msg_init = Message_Initializer; |
|
512 |
pdo = msg_init; |
|
513 |
} |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
514 |
if(buildPDO(d, pdoNum, &pdo)) |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
515 |
{ |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
516 |
MSG_ERR(0x3907, " Couldn't build TPDO number : ", pdoNum); |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
517 |
status = state11; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
518 |
break; |
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 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
521 |
/*Compare new and old PDO*/ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
522 |
if(d->PDO_status[pdoNum].last_message.cob_id.w == pdo.cob_id.w && |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
523 |
d->PDO_status[pdoNum].last_message.len == pdo.len && |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
524 |
*(UNS64*)(&d->PDO_status[pdoNum].last_message.data[0]) == *(UNS64*)(&pdo.data[0])){ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
525 |
/* No changes -> go to next pdo*/ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
526 |
status = state11; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
527 |
}else{ |
298 | 528 |
|
529 |
UNS16 EventTimerDuration; |
|
530 |
UNS16 InhibitTimerDuration; |
|
531 |
||
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
532 |
MSG_WAR(0x306A, "Changes TPDO number : ", pdoNum); |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
533 |
/* Changes detected -> transmit message */ |
298 | 534 |
EventTimerDuration = *(UNS16*)d->objdict[offsetObjdict].pSubindex[5].pObject; |
535 |
InhibitTimerDuration = *(UNS16*)d->objdict[offsetObjdict].pSubindex[3].pObject; |
|
297
639e5ec5a120
Fixed some transmit type issues (for 254 255) with null event and/or inhibit time
etisserant
parents:
285
diff
changeset
|
536 |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
537 |
status = state5; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
538 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
539 |
/* Start both event_timer and inhibit_timer*/ |
297
639e5ec5a120
Fixed some transmit type issues (for 254 255) with null event and/or inhibit time
etisserant
parents:
285
diff
changeset
|
540 |
if(EventTimerDuration){ |
639e5ec5a120
Fixed some transmit type issues (for 254 255) with null event and/or inhibit time
etisserant
parents:
285
diff
changeset
|
541 |
DelAlarm(d->PDO_status[pdoNum].event_timer); |
639e5ec5a120
Fixed some transmit type issues (for 254 255) with null event and/or inhibit time
etisserant
parents:
285
diff
changeset
|
542 |
d->PDO_status[pdoNum].event_timer = SetAlarm(d, pdoNum, &PDOEventTimerAlarm, MS_TO_TIMEVAL(EventTimerDuration), 0); |
639e5ec5a120
Fixed some transmit type issues (for 254 255) with null event and/or inhibit time
etisserant
parents:
285
diff
changeset
|
543 |
} |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
544 |
|
297
639e5ec5a120
Fixed some transmit type issues (for 254 255) with null event and/or inhibit time
etisserant
parents:
285
diff
changeset
|
545 |
if(InhibitTimerDuration){ |
639e5ec5a120
Fixed some transmit type issues (for 254 255) with null event and/or inhibit time
etisserant
parents:
285
diff
changeset
|
546 |
DelAlarm(d->PDO_status[pdoNum].inhibit_timer); |
639e5ec5a120
Fixed some transmit type issues (for 254 255) with null event and/or inhibit time
etisserant
parents:
285
diff
changeset
|
547 |
d->PDO_status[pdoNum].inhibit_timer = SetAlarm(d, pdoNum, &PDOInhibitTimerAlarm, US_TO_TIMEVAL(InhibitTimerDuration * 100), 0); |
639e5ec5a120
Fixed some transmit type issues (for 254 255) with null event and/or inhibit time
etisserant
parents:
285
diff
changeset
|
548 |
/* and inhibit TPDO */ |
639e5ec5a120
Fixed some transmit type issues (for 254 255) with null event and/or inhibit time
etisserant
parents:
285
diff
changeset
|
549 |
d->PDO_status[pdoNum].transmit_type_parameter |= PDO_INHIBITED; |
639e5ec5a120
Fixed some transmit type issues (for 254 255) with null event and/or inhibit time
etisserant
parents:
285
diff
changeset
|
550 |
} |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
551 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
552 |
} |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
553 |
}else{ |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
554 |
MSG_WAR(0x306C, " PDO is not on EVENT or synchro or not at this SYNC. Trans type : ", *pTransmissionType); |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
555 |
status = state11; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
556 |
} |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
557 |
break; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
558 |
case state5: /*Send the pdo*/ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
559 |
/*store_as_last_message*/ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
560 |
d->PDO_status[pdoNum].last_message = pdo; |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
561 |
MSG_WAR(0x396D, "sendPDO cobId :", pdo.cob_id.w); |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
562 |
MSG_WAR(0x396E, " Nb octets : ", pdo.len); |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
563 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
564 |
canSend(d->canHandle,&pdo); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
565 |
status = state11; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
566 |
break; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
567 |
case state11: /*Go to next TPDO*/ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
568 |
pdoNum++; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
569 |
offsetObjdict++; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
570 |
offsetObjdictMap++; |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
571 |
MSG_WAR(0x3970, "next pdo index : ", pdoNum); |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
572 |
status = state3; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
573 |
break; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
574 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
575 |
default: |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
576 |
MSG_ERR(0x1972,"Unknown state has been reached : %d",status); |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
577 |
return 0xFF; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
578 |
}/* end switch case */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
579 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
580 |
}/* end while */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
581 |
} |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
582 |
return 0; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
583 |
} |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
584 |
|
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
585 |
/*! |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
586 |
** |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
587 |
** |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
588 |
** @param d |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
589 |
** @param OD_entry |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
590 |
** @param bSubindex |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
591 |
** @return always 0 |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
592 |
**/ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
593 |
|
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
594 |
UNS32 TPDO_Communication_Parameter_Callback(CO_Data* d, const indextable * OD_entry, UNS8 bSubindex) |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
595 |
{ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
596 |
/* If PDO are actives */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
597 |
if(d->CurrentCommunicationState.csPDO) switch(bSubindex) |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
598 |
{ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
599 |
case 2: /* Changed transmition type */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
600 |
case 3: /* Changed inhibit time */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
601 |
case 5: /* Changed event time */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
602 |
{ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
603 |
UNS8 pTransmissionType = *(UNS8*) OD_entry->pSubindex[2].pObject; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
604 |
const indextable* TPDO_com = d->objdict + d->firstIndex->PDO_TRS; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
605 |
UNS8 numPdo = OD_entry - TPDO_com; /* number of the actual processed pdo-nr. */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
606 |
|
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
607 |
/* Zap all timers and inhibit flag */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
608 |
d->PDO_status[numPdo].event_timer = DelAlarm(d->PDO_status[numPdo].event_timer); |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
609 |
d->PDO_status[numPdo].inhibit_timer = DelAlarm(d->PDO_status[numPdo].inhibit_timer); |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
610 |
d->PDO_status[numPdo].transmit_type_parameter = 0; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
611 |
/* Call PDOEventTimerAlarm for this TPDO, this will trigger emission et reset timers */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
612 |
PDOEventTimerAlarm(d, numPdo); |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
613 |
return 0; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
614 |
} |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
615 |
|
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
616 |
default: /* other subindex are ignored*/ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
617 |
break; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
618 |
} |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
619 |
return 0; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
620 |
} |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
621 |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
622 |
void PDOInit(CO_Data* d) |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
623 |
{ |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
624 |
/* For each TPDO mapping parameters */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
625 |
UNS16 pdoIndex = 0x1800; /* OD index of TDPO */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
626 |
|
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
627 |
UNS16 offsetObjdict = d->firstIndex->PDO_TRS; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
628 |
UNS16 lastIndex = d->lastIndex->PDO_TRS; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
629 |
if(offsetObjdict) while( offsetObjdict <= lastIndex) { |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
630 |
/* Assign callbacks to sensible TPDO mapping subindexes */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
631 |
UNS32 errorCode; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
632 |
ODCallback_t *CallbackList; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
633 |
/* Find callback list */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
634 |
scanIndexOD (d, pdoIndex, &errorCode, &CallbackList); |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
635 |
if(errorCode == OD_SUCCESSFUL && CallbackList) |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
636 |
{ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
637 |
/*Assign callbacks to corresponding subindex*/ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
638 |
/* Transmission type */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
639 |
CallbackList[2] = &TPDO_Communication_Parameter_Callback; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
640 |
/* Inhibit time */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
641 |
CallbackList[3] = &TPDO_Communication_Parameter_Callback; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
642 |
/* Event timer */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
643 |
CallbackList[5] = &TPDO_Communication_Parameter_Callback; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
644 |
} |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
645 |
pdoIndex++; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
646 |
offsetObjdict++; |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
647 |
} |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
648 |
|
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
649 |
/* Trigger a non-sync event */ |
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
650 |
_sendPDOevent( d, 0 ); |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
651 |
} |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
652 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
653 |
void PDOStop(CO_Data* d) |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
654 |
{ |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
655 |
/* For each TPDO mapping parameters */ |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
656 |
UNS8 pdoNum = 0x00; /* number of the actual processed pdo-nr. */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
657 |
UNS16 offsetObjdict = d->firstIndex->PDO_TRS; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
658 |
UNS16 lastIndex = d->lastIndex->PDO_TRS; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
659 |
if(offsetObjdict) while( offsetObjdict <= lastIndex) { |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
660 |
/* Delete TPDO timers */ |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
661 |
d->PDO_status[pdoNum].event_timer = DelAlarm(d->PDO_status[pdoNum].event_timer); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
662 |
d->PDO_status[pdoNum].inhibit_timer = DelAlarm(d->PDO_status[pdoNum].inhibit_timer); |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
663 |
/* Reset transmit type parameter */ |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
664 |
d->PDO_status[pdoNum].transmit_type_parameter = 0; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
665 |
d->PDO_status[pdoNum].last_message.cob_id.w = 0; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
666 |
pdoNum++; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
667 |
offsetObjdict++; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
668 |
} |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
217
diff
changeset
|
669 |
} |