0
|
1 |
/*
|
|
2 |
This file is part of CanFestival, a library implementing CanOpen Stack.
|
|
3 |
|
|
4 |
Copyright (C): Edouard TISSERANT and Francis DUPIN
|
|
5 |
|
|
6 |
See COPYING file for copyrights details.
|
|
7 |
|
|
8 |
This library is free software; you can redistribute it and/or
|
|
9 |
modify it under the terms of the GNU Lesser General Public
|
|
10 |
License as published by the Free Software Foundation; either
|
|
11 |
version 2.1 of the License, or (at your option) any later version.
|
|
12 |
|
|
13 |
This library is distributed in the hope that it will be useful,
|
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
16 |
Lesser General Public License for more details.
|
|
17 |
|
|
18 |
You should have received a copy of the GNU Lesser General Public
|
|
19 |
License along with this library; if not, write to the Free Software
|
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
21 |
*/
|
|
22 |
|
54
|
23 |
// Uncomment if you don't need console informations.
|
0
|
24 |
#define DEBUG_WAR_CONSOLE_ON
|
|
25 |
#define DEBUG_ERR_CONSOLE_ON
|
|
26 |
|
|
27 |
#include <stddef.h> /* for NULL */
|
|
28 |
|
|
29 |
#include <asm-m68hc12/portsaccess.h>
|
|
30 |
#include <asm-m68hc12/ports_def.h>
|
|
31 |
#include <asm-m68hc12/ports.h>
|
|
32 |
#include <interrupt.h>
|
|
33 |
|
54
|
34 |
#include "../include/data.h"
|
0
|
35 |
#include <applicfg.h>
|
|
36 |
|
|
37 |
|
|
38 |
|
54
|
39 |
#include "../include/hcs12/candriver.h"
|
|
40 |
#include "../include/hcs12/canOpenDriver.h"
|
0
|
41 |
#include "../include/def.h"
|
|
42 |
#include "../include/can.h"
|
|
43 |
#include "../include/objdictdef.h"
|
|
44 |
#include "../include/objacces.h"
|
|
45 |
#include "../include/sdo.h"
|
|
46 |
#include "../include/pdo.h"
|
|
47 |
#include "../include/timer.h"
|
|
48 |
#include "../include/lifegrd.h"
|
|
49 |
#include "../include/sync.h"
|
|
50 |
|
|
51 |
#include "../include/nmtSlave.h"
|
61
|
52 |
|
|
53 |
// File created by the GUI
|
0
|
54 |
#include "objdict.h"
|
|
55 |
|
54
|
56 |
|
|
57 |
|
|
58 |
|
0
|
59 |
|
|
60 |
// HCS12 configuration
|
|
61 |
// -----------------------------------------------------
|
|
62 |
|
|
63 |
enum E_CanBaudrate
|
|
64 |
{
|
|
65 |
CAN_BAUDRATE_250K,
|
|
66 |
CAN_BAUDRATE_500K,
|
|
67 |
CAN_BAUDRATE_1M,
|
|
68 |
};
|
|
69 |
|
|
70 |
|
|
71 |
const canBusTime CAN_Baudrates[] =
|
|
72 |
{
|
|
73 |
{
|
|
74 |
1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */
|
|
75 |
3, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */
|
|
76 |
0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */
|
|
77 |
0, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */
|
|
78 |
1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */
|
|
79 |
12, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */
|
|
80 |
|
|
81 |
/*
|
|
82 |
With these values,
|
|
83 |
- The width of the bit time is 16 time quantum :
|
|
84 |
- 1 tq for the SYNC segment (could not be modified)
|
|
85 |
- 13 tq for the TIME 1 segment (tseg1 = 12)
|
|
86 |
- 2 tq for the TIME 2 segment (tseg2 = 1)
|
|
87 |
- Because the bus clock of the MSCAN is 16 MHZ, and the
|
|
88 |
freq of the time quantum is 4 MHZ (brp = 3+1), and there are 16 tq in the bit time,
|
|
89 |
so the freq of the bit time is 250 kHz.
|
|
90 |
*/
|
|
91 |
},
|
|
92 |
|
|
93 |
{
|
|
94 |
1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */
|
|
95 |
1, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */
|
|
96 |
0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */
|
|
97 |
0, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */
|
|
98 |
1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */
|
|
99 |
12, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */
|
|
100 |
|
|
101 |
/*
|
|
102 |
With these values,
|
|
103 |
- The width of the bit time is 16 time quantum :
|
|
104 |
- 1 tq for the SYNC segment (could not be modified)
|
|
105 |
- 13 tq for the TIME 1 segment (tseg1 = 12)
|
|
106 |
- 2 tq for the TIME 2 segment (tseg2 = 1)
|
|
107 |
- Because the bus clock of the MSCAN is 16 MHZ, and the
|
|
108 |
freq of the time quantum is 8 MHZ (brp = 1+1), and there are 16 tq in the bit time,
|
|
109 |
so the freq of the bit time is 500 kHz.
|
|
110 |
*/
|
|
111 |
},
|
|
112 |
|
|
113 |
{
|
|
114 |
1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */
|
|
115 |
1, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */
|
|
116 |
0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */
|
|
117 |
0, /* samp : chose btw 0 and 3 (2 bits) (samp +MSG_WAR(0x3F33, "Je suis le noeud ", getNodeId()); 1 ) samples per bit */
|
|
118 |
1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */
|
|
119 |
4, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */
|
|
120 |
|
|
121 |
/*
|
|
122 |
With these values,
|
|
123 |
- The width of the bit time is 16 time quantum :
|
|
124 |
- 1 tq for the SYNC segment (could not be modified)
|
|
125 |
- 5 tq for the TIME 1 segment (tseg1 = 4)
|
|
126 |
- 2 tq for the TIME 2 segment (tseg2 = 1)
|
|
127 |
- Because the bus clock of the MSCAN is 16 MHZ, and the
|
|
128 |
freq of the time quantum is 8 MHZ (brp = 1+1), and there are 8 tq in the bit time,
|
|
129 |
so the freq of the bit time is 1 MHz.
|
|
130 |
*/
|
|
131 |
}
|
|
132 |
};
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
/**************************prototypes*****************************************/
|
|
138 |
|
54
|
139 |
//Init can bus and Canopen
|
0
|
140 |
void initCanopencapteur (void);
|
54
|
141 |
// Init the sensor
|
0
|
142 |
void initSensor(void);
|
|
143 |
void initPortB(void);
|
54
|
144 |
void initPortH(void);
|
|
145 |
|
0
|
146 |
|
|
147 |
//------------------------------------------------------------------------------
|
|
148 |
//Initialisation of the port B for the leds.
|
|
149 |
void initPortB(void)
|
|
150 |
{
|
|
151 |
// Port B is output
|
|
152 |
IO_PORTS_8(DDRB)= 0XFF;
|
|
153 |
// RAZ
|
|
154 |
IO_PORTS_8(PORTB) = 0xFF;
|
|
155 |
}
|
|
156 |
|
54
|
157 |
//------------------------------------------------------------------------------
|
|
158 |
// Init of port H to choose the CAN rate by switch, and the nodeId
|
|
159 |
void initPortH(void)
|
|
160 |
{
|
|
161 |
// Port H is input
|
|
162 |
IO_PORTS_8(DDRH)= 0X00;
|
|
163 |
// Enable pull device
|
|
164 |
IO_PORTS_8(PERH) = 0XFF;
|
|
165 |
// Choose the pull-up device
|
|
166 |
IO_PORTS_8(PPSH) = 0X00;
|
|
167 |
}
|
0
|
168 |
|
|
169 |
//------------------------------------------------------------------------------
|
|
170 |
void initSensor(void)
|
|
171 |
{
|
54
|
172 |
UNS8 baudrate = 0;
|
|
173 |
UNS8 nodeId = 0;
|
0
|
174 |
// Init led control
|
|
175 |
initPortB();
|
|
176 |
IO_PORTS_8(PORTB) &= ~ 0x01; //One led ON
|
54
|
177 |
initPortH();
|
|
178 |
|
|
179 |
/* Defining the node Id */
|
|
180 |
// Uncomment to have a fixed nodeId
|
|
181 |
//setNodeId(&gene_SYNC_Data, 0x03);
|
|
182 |
|
|
183 |
// Comment below to have a fixed nodeId
|
|
184 |
nodeId = ~(IO_PORTS_8(PTH)) & 0x3F;
|
|
185 |
if (nodeId == 0) {
|
|
186 |
MSG_WAR(0x3F33, "Using default nodeId : ", getNodeId(&gene_SYNC_Data));
|
|
187 |
}
|
|
188 |
else
|
|
189 |
setNodeId(&gene_SYNC_Data, nodeId);
|
|
190 |
|
|
191 |
MSG_WAR(0x3F33, "My nodeId is : ", getNodeId(&gene_SYNC_Data));
|
0
|
192 |
|
|
193 |
canBusInit bi0 = {
|
|
194 |
0, /* no low power */
|
|
195 |
0, /* no time stamp */
|
|
196 |
1, /* enable MSCAN */
|
|
197 |
0, /* clock source : oscillator (In fact, it is not used) */
|
|
198 |
0, /* no loop back */
|
|
199 |
0, /* no listen only */
|
|
200 |
0, /* no low pass filter for wk up */
|
|
201 |
CAN_Baudrates[CAN_BAUDRATE_250K],
|
|
202 |
{
|
|
203 |
0x00, /* Filter on 16 bits. See Motorola Block Guide V02.14 fig 4-3 */
|
|
204 |
0x00, 0xFF, /* filter 0 hight accept all msg */
|
|
205 |
0x00, 0xFF, /* filter 0 low accept all msg */
|
|
206 |
0x00, 0xFF, /* filter 1 hight filter all of msg */
|
|
207 |
0x00, 0xFF, /* filter 1 low filter all of msg */
|
|
208 |
0x00, 0xFF, /* filter 2 hight filter most of msg */
|
|
209 |
0x00, 0xFF, /* filter 2 low filter most of msg */
|
|
210 |
0x00, 0xFF, /* filter 3 hight filter most of msg */
|
|
211 |
0x00, 0xFF, /* filter 3 low filter most of msg */
|
|
212 |
}
|
|
213 |
};
|
|
214 |
|
|
215 |
//Init the HCS12 microcontroler for CanOpen
|
|
216 |
initHCS12();
|
|
217 |
|
54
|
218 |
// Chose the CAN rate (On our board, whe have switch for all purpose)
|
|
219 |
// 7 8
|
|
220 |
// ON ON => 1000 kpbs
|
|
221 |
// OFF ON => 500 kpbs
|
|
222 |
// ON OFF => 250 kpbs
|
|
223 |
|
|
224 |
baudrate = ~(IO_PORTS_8(PTH)) & 0xC0;
|
|
225 |
|
|
226 |
// Uncomment to have a fixed baudrate of 250 kbps
|
|
227 |
//baudrate = 1;
|
|
228 |
|
0
|
229 |
switch (baudrate) {
|
54
|
230 |
case 0x40:
|
0
|
231 |
bi0.clk = CAN_Baudrates[CAN_BAUDRATE_250K];
|
|
232 |
MSG_WAR(0x3F30, "CAN 250 kbps ", 0);
|
|
233 |
break;
|
54
|
234 |
case 0x80:
|
0
|
235 |
bi0.clk = CAN_Baudrates[CAN_BAUDRATE_500K];
|
|
236 |
MSG_WAR(0x3F31, "CAN 500 kbps ", 0);
|
|
237 |
break;
|
54
|
238 |
case 0xC0:
|
0
|
239 |
bi0.clk = CAN_Baudrates[CAN_BAUDRATE_1M];
|
|
240 |
MSG_WAR(0x3F31, "CAN 1000 kbps ", 0);
|
|
241 |
break;
|
|
242 |
default:
|
54
|
243 |
bi0.clk = CAN_Baudrates[CAN_BAUDRATE_1M];
|
|
244 |
MSG_WAR(0x2F32, "CAN BAUD RATE NOT DEFINED => 250 kbps ", 0);
|
0
|
245 |
}
|
|
246 |
|
54
|
247 |
|
|
248 |
|
|
249 |
MSG_WAR(0x3F33, "SYNC signal generator ", 0);
|
0
|
250 |
|
|
251 |
canInit(CANOPEN_LINE_NUMBER_USED, bi0); //initialize filters...
|
|
252 |
initTimer(); // Init hcs12 timer used by CanFestival. (see timerhw.c)
|
|
253 |
unlock(); // Allow interruptions
|
|
254 |
}
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
|
262 |
// FUNCTIONS WHICH ARE PART OF CANFESTIVAL and *must* be implemented here.
|
|
263 |
|
|
264 |
//------------------------------------------------------------------------------
|
|
265 |
void gene_SYNC_heartbeatError( UNS8 heartbeatID )
|
|
266 |
{
|
|
267 |
|
|
268 |
MSG_ERR(0x1F00, "HeartBeat not received from node : ", heartbeatID);
|
|
269 |
}
|
|
270 |
|
|
271 |
//------------------------------------------------------------------------------
|
|
272 |
void gene_SYNC_SDOtimeoutError (UNS8 line)
|
|
273 |
{
|
61
|
274 |
// This function was implemented for the Client's use (client = the one which initiate the dialog),
|
|
275 |
// but we can use it also for the server.
|
|
276 |
// Note : if for an other reason than a timeout, a SDO to read or write
|
|
277 |
// faile, we do not have implemented a warning function at the server side.
|
|
278 |
// Of course, there is one on the client side.
|
|
279 |
|
0
|
280 |
MSG_ERR(0x1F01, "SDO timeout for line : ", line);
|
61
|
281 |
// See the transfer structure in sdo.h to know what informations
|
|
282 |
// you can retreive.
|
|
283 |
MSG_ERR(0x1F02, " to access index ", gene_SYNC_Data.transfers[line].index);
|
|
284 |
MSG_ERR(0x1F03, " subIndex ", gene_SYNC_Data.transfers[line].subIndex);
|
0
|
285 |
}
|
|
286 |
|
|
287 |
//------------------------------------------------------------------------------
|
|
288 |
UNS8 gene_SYNC_canSend(Message *m)
|
|
289 |
{
|
|
290 |
// HCS12 driver function to send the CAN msg
|
|
291 |
canMsgTransmit(CAN0, *m);
|
|
292 |
return 0;
|
|
293 |
}
|
|
294 |
|
|
295 |
//------------------------------------------------------------------------------
|
|
296 |
void gene_SYNC_initialisation()
|
|
297 |
{
|
|
298 |
MSG_WAR (0x3F00, "Entering in INIT ", 0);
|
54
|
299 |
initSensor();
|
|
300 |
|
0
|
301 |
IO_PORTS_8(PORTB) &= ~ 0x01; // led 0 : ON
|
|
302 |
IO_PORTS_8(PORTB) |= 0x0E; // leds 1, 2, 3 : OFF
|
54
|
303 |
|
0
|
304 |
}
|
|
305 |
|
|
306 |
|
|
307 |
//------------------------------------------------------------------------------
|
|
308 |
void gene_SYNC_preOperational()
|
|
309 |
{
|
|
310 |
MSG_WAR (0x3F01, "Entering in PRE-OPERATIONAL ", 0);
|
|
311 |
IO_PORTS_8(PORTB) &= ~ 0x03; // leds 0, 1 : ON
|
|
312 |
IO_PORTS_8(PORTB) |= 0x0C; // leds 2, 3 : OFF
|
54
|
313 |
/* default values for the msg CAN filters */
|
|
314 |
/* Accept all */
|
|
315 |
{
|
|
316 |
canBusFilterInit filterConfiguration =
|
|
317 |
{
|
|
318 |
0x01, /* Filter on 16 bits. See Motorola Block Guide V02.14 */
|
|
319 |
/*canidarx, canidmrx */
|
|
320 |
0x00, 0xFF, /* filter 0 */
|
|
321 |
0x00, 0xFF, /* filter 0 */
|
|
322 |
0x00, 0xFF, /* filter 1 */
|
|
323 |
0x00, 0xFF, /* filter 1 */
|
|
324 |
0x00, 0xFF, /* filter 2 */
|
|
325 |
0x00, 0xFF, /* filter 2 */
|
|
326 |
0x00, 0xFF, /* filter 3 */
|
|
327 |
0x00, 0xFF, /* filter 3 */
|
|
328 |
};
|
|
329 |
canChangeFilter(CANOPEN_LINE_NUMBER_USED, filterConfiguration);
|
|
330 |
}
|
|
331 |
// Reset the automatic change by SDO
|
|
332 |
applyDownloadedFilters = 0;
|
|
333 |
|
0
|
334 |
}
|
|
335 |
|
|
336 |
|
|
337 |
//------------------------------------------------------------------------------
|
|
338 |
void gene_SYNC_operational()
|
|
339 |
{
|
|
340 |
MSG_WAR (0x3F02, "Entering in OPERATIONAL ", 0);
|
|
341 |
IO_PORTS_8(PORTB) &= ~ 0x07; // leds 0, 1, 2 : ON
|
|
342 |
IO_PORTS_8(PORTB) |= 0x08; // leds 3 : OFF
|
54
|
343 |
|
|
344 |
// Filtering the CAN received msgs.
|
|
345 |
// 2 ways
|
|
346 |
// First :applying an automatic filter
|
|
347 |
// Second : The values of the filtering registers are mapped in the object dictionary,
|
|
348 |
// So that a filtering configuration can be downloaded by SDO in pre-operational mode
|
|
349 |
|
|
350 |
if (applyDownloadedFilters == 0) {// No downloaded configuration to apply
|
|
351 |
UNS16 accept1 = 0x0000; // Accept NMT
|
|
352 |
UNS16 mask1 = 0x0FFF; // Mask NMT
|
|
353 |
UNS16 accept2 = 0xE000; // Accept NMT error control (heartbeat, nodeguard)
|
|
354 |
UNS16 mask2 = 0x0FFF; // Mask NMT error control (heartbeat, nodeguard)
|
|
355 |
|
|
356 |
canBusFilterInit filterConfiguration =
|
|
357 |
{// filters 3 and 4 not used, so configured like filter 1.
|
|
358 |
0x01, /* Filter on 16 bits. See Motorola Block Guide V02.14 */
|
|
359 |
/*canidarx, canidmrx */
|
|
360 |
(UNS8)(accept1 >> 8), (UNS8)(mask1 >> 8), /* filter 1 id10...3*/
|
|
361 |
(UNS8)accept1 , (UNS8)mask1, /* filter 1 id2 ... */
|
|
362 |
(UNS8)(accept2 >> 8), (UNS8)(mask2 >> 8), /* filter 2 id10...3*/
|
|
363 |
(UNS8)accept2 , (UNS8)mask2, /* filter 2 id2 ... */
|
|
364 |
(UNS8)(accept1 >> 8), (UNS8)(mask1 >> 8), /* filter 3 id10...3*/
|
|
365 |
(UNS8)accept1 , (UNS8)mask1, /* filter 3 id2 ... */
|
|
366 |
(UNS8)(accept1 >> 8), (UNS8)(mask1 >> 8), /* filter 4 id10...3*/
|
|
367 |
(UNS8)accept1 , (UNS8)mask1 /* filter 4 id2 ... */
|
|
368 |
};
|
|
369 |
canChangeFilter(CANOPEN_LINE_NUMBER_USED, filterConfiguration);
|
|
370 |
MSG_WAR (0x3F03, "Internal CAN Rcv filter applied ", 0);
|
|
371 |
}
|
|
372 |
else { // Apply filters downnloaded
|
|
373 |
canBusFilterInit filterConfiguration =
|
|
374 |
{// filters 3 and 4 not used, so configured like filter 1.
|
|
375 |
0x01, /* Filter on 16 bits. See Motorola Block Guide V02.14 */
|
|
376 |
/*canidarx, canidmrx */
|
|
377 |
(UNS8)( acceptanceFilter1>> 8), (UNS8)(mask1 >> 8), /* filter 1 id10...3*/
|
|
378 |
(UNS8)acceptanceFilter1 , (UNS8)mask1, /* filter 1 id2 ... */
|
|
379 |
(UNS8)(acceptanceFilter2 >> 8), (UNS8)(mask2 >> 8), /* filter 2 id10...3*/
|
|
380 |
(UNS8)acceptanceFilter2 , (UNS8)mask2, /* filter 2 id2 ... */
|
|
381 |
(UNS8)(acceptanceFilter3 >> 8), (UNS8)(mask3 >> 8), /* filter 3 id10...3*/
|
|
382 |
(UNS8)acceptanceFilter3 , (UNS8)mask3, /* filter 3 id2 ... */
|
|
383 |
(UNS8)(acceptanceFilter4 >> 8), (UNS8)(mask4 >> 8), /* filter 4 id10...3*/
|
|
384 |
(UNS8)acceptanceFilter4 , (UNS8)mask4 /* filter 4 id2 ... */
|
|
385 |
};
|
|
386 |
canChangeFilter(CANOPEN_LINE_NUMBER_USED, filterConfiguration);
|
|
387 |
MSG_WAR (0x3F04, "Downloaded CAN Rcv filter applied ", 0);
|
|
388 |
}
|
0
|
389 |
}
|
|
390 |
|
|
391 |
//------------------------------------------------------------------------------
|
|
392 |
void gene_SYNC_stopped()
|
|
393 |
{
|
|
394 |
MSG_WAR (0x3F02, "Entering in STOPPED ", 0);
|
54
|
395 |
IO_PORTS_8(PORTB) |= 0x0E; // leds 1, 2, 3, 4 : OFF
|
0
|
396 |
}
|
|
397 |
|
|
398 |
//------------------------------------------------------------------------------
|
|
399 |
void gene_SYNC_post_sync()
|
|
400 |
{
|
|
401 |
}
|
|
402 |
|
|
403 |
//------------------------------------------------------------------------------
|
|
404 |
void gene_SYNC_post_TPDO()
|
|
405 |
{
|
|
406 |
}
|
|
407 |
|
|
408 |
// End functions which are part of Canfestival
|
|
409 |
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
|
410 |
|
|
411 |
|
|
412 |
/******************************************************************************/
|
|
413 |
/********************************* MAIN ***************************************/
|
|
414 |
/******************************************************************************/
|
|
415 |
|
|
416 |
|
|
417 |
UNS8 main (void)
|
|
418 |
{
|
|
419 |
|
54
|
420 |
MSG_WAR(0x3F34, "Entering in the main ", 0);
|
0
|
421 |
//----------------------------- INITIALISATION --------------------------------
|
54
|
422 |
|
0
|
423 |
/* Put the node in Initialisation mode */
|
54
|
424 |
MSG_WAR(0x3F35, "Will entering in INIT ", 0);
|
0
|
425 |
setState(&gene_SYNC_Data, Initialisation);
|
|
426 |
|
|
427 |
//----------------------------- START -----------------------------------------
|
|
428 |
/* Put the node in pre-operational mode */
|
|
429 |
//MSG_WAR(0x3F36, "va passer en pre-op", 0);
|
|
430 |
//setState(&gene_SYNC_Data, Pre_operational);
|
|
431 |
|
54
|
432 |
// Loop of receiving messages
|
|
433 |
while (1) {
|
0
|
434 |
Message m;
|
|
435 |
if (f_can_receive(0, &m)) {
|
54
|
436 |
//MSG_WAR(0x3F36, "Msg received", m.cob_id.w);
|
56
|
437 |
lock(); // Not to have interruptions by timer, which can corrupt the data
|
0
|
438 |
canDispatch(&gene_SYNC_Data, &m);
|
56
|
439 |
unlock();
|
54
|
440 |
}
|
|
441 |
}
|
0
|
442 |
|
|
443 |
return (0);
|
|
444 |
}
|
|
445 |
|
|
446 |
|
|
447 |
|