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"
|
|
52 |
#include "objdict.h"
|
|
53 |
|
54
|
54 |
// Variables defined in the object dictionary (See objdict.c)
|
|
55 |
extern UNS16 acceptanceFilter1; // Mapped at index 0x2015, subindex 0x00
|
|
56 |
extern UNS16 acceptanceFilter2; // Mapped at index 0x2016, subindex 0x00
|
|
57 |
extern UNS16 acceptanceFilter3; // Mapped at index 0x2017, subindex 0x00
|
|
58 |
extern UNS16 acceptanceFilter4; // Mapped at index 0x2018, subindex 0x00
|
|
59 |
extern UNS16 mask1; // Mapped at index 0x2019, subindex 0x00
|
|
60 |
extern UNS16 mask2; // Mapped at index 0x2020, subindex 0x00
|
|
61 |
extern UNS16 mask3; // Mapped at index 0x2021, subindex 0x00
|
|
62 |
extern UNS16 mask4; // Mapped at index 0x2022, subindex 0x00
|
|
63 |
extern UNS8 applyDownloadedFilters;
|
|
64 |
|
|
65 |
|
|
66 |
|
0
|
67 |
|
|
68 |
// HCS12 configuration
|
|
69 |
// -----------------------------------------------------
|
|
70 |
|
|
71 |
enum E_CanBaudrate
|
|
72 |
{
|
|
73 |
CAN_BAUDRATE_250K,
|
|
74 |
CAN_BAUDRATE_500K,
|
|
75 |
CAN_BAUDRATE_1M,
|
|
76 |
};
|
|
77 |
|
|
78 |
|
|
79 |
const canBusTime CAN_Baudrates[] =
|
|
80 |
{
|
|
81 |
{
|
|
82 |
1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */
|
|
83 |
3, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */
|
|
84 |
0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */
|
|
85 |
0, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */
|
|
86 |
1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */
|
|
87 |
12, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */
|
|
88 |
|
|
89 |
/*
|
|
90 |
With these values,
|
|
91 |
- The width of the bit time is 16 time quantum :
|
|
92 |
- 1 tq for the SYNC segment (could not be modified)
|
|
93 |
- 13 tq for the TIME 1 segment (tseg1 = 12)
|
|
94 |
- 2 tq for the TIME 2 segment (tseg2 = 1)
|
|
95 |
- Because the bus clock of the MSCAN is 16 MHZ, and the
|
|
96 |
freq of the time quantum is 4 MHZ (brp = 3+1), and there are 16 tq in the bit time,
|
|
97 |
so the freq of the bit time is 250 kHz.
|
|
98 |
*/
|
|
99 |
},
|
|
100 |
|
|
101 |
{
|
|
102 |
1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */
|
|
103 |
1, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */
|
|
104 |
0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */
|
|
105 |
0, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */
|
|
106 |
1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */
|
|
107 |
12, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */
|
|
108 |
|
|
109 |
/*
|
|
110 |
With these values,
|
|
111 |
- The width of the bit time is 16 time quantum :
|
|
112 |
- 1 tq for the SYNC segment (could not be modified)
|
|
113 |
- 13 tq for the TIME 1 segment (tseg1 = 12)
|
|
114 |
- 2 tq for the TIME 2 segment (tseg2 = 1)
|
|
115 |
- Because the bus clock of the MSCAN is 16 MHZ, and the
|
|
116 |
freq of the time quantum is 8 MHZ (brp = 1+1), and there are 16 tq in the bit time,
|
|
117 |
so the freq of the bit time is 500 kHz.
|
|
118 |
*/
|
|
119 |
},
|
|
120 |
|
|
121 |
{
|
|
122 |
1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */
|
|
123 |
1, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */
|
|
124 |
0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */
|
|
125 |
0, /* samp : chose btw 0 and 3 (2 bits) (samp +MSG_WAR(0x3F33, "Je suis le noeud ", getNodeId()); 1 ) samples per bit */
|
|
126 |
1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */
|
|
127 |
4, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */
|
|
128 |
|
|
129 |
/*
|
|
130 |
With these values,
|
|
131 |
- The width of the bit time is 16 time quantum :
|
|
132 |
- 1 tq for the SYNC segment (could not be modified)
|
|
133 |
- 5 tq for the TIME 1 segment (tseg1 = 4)
|
|
134 |
- 2 tq for the TIME 2 segment (tseg2 = 1)
|
|
135 |
- Because the bus clock of the MSCAN is 16 MHZ, and the
|
|
136 |
freq of the time quantum is 8 MHZ (brp = 1+1), and there are 8 tq in the bit time,
|
|
137 |
so the freq of the bit time is 1 MHz.
|
|
138 |
*/
|
|
139 |
}
|
|
140 |
};
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
/**************************prototypes*****************************************/
|
|
146 |
|
54
|
147 |
//Init can bus and Canopen
|
0
|
148 |
void initCanopencapteur (void);
|
54
|
149 |
// Init the sensor
|
0
|
150 |
void initSensor(void);
|
|
151 |
void initPortB(void);
|
54
|
152 |
void initPortH(void);
|
|
153 |
|
|
154 |
// Functions needed by Canfestival
|
|
155 |
// Notice that gene_SYNC is the name of the sensor defined in python GUI.
|
|
156 |
// Do not change it !.
|
|
157 |
void gene_SYNC_initialisation(void);
|
|
158 |
void gene_SYNC_preOperational(void);
|
|
159 |
void gene_SYNC_operational(void);
|
|
160 |
void gene_SYNC_stopped(void);
|
|
161 |
void gene_SYNC_post_sync(void);
|
|
162 |
|
0
|
163 |
|
|
164 |
//------------------------------------------------------------------------------
|
|
165 |
//Initialisation of the port B for the leds.
|
|
166 |
void initPortB(void)
|
|
167 |
{
|
|
168 |
// Port B is output
|
|
169 |
IO_PORTS_8(DDRB)= 0XFF;
|
|
170 |
// RAZ
|
|
171 |
IO_PORTS_8(PORTB) = 0xFF;
|
|
172 |
}
|
|
173 |
|
54
|
174 |
//------------------------------------------------------------------------------
|
|
175 |
// Init of port H to choose the CAN rate by switch, and the nodeId
|
|
176 |
void initPortH(void)
|
|
177 |
{
|
|
178 |
// Port H is input
|
|
179 |
IO_PORTS_8(DDRH)= 0X00;
|
|
180 |
// Enable pull device
|
|
181 |
IO_PORTS_8(PERH) = 0XFF;
|
|
182 |
// Choose the pull-up device
|
|
183 |
IO_PORTS_8(PPSH) = 0X00;
|
|
184 |
}
|
0
|
185 |
|
|
186 |
//------------------------------------------------------------------------------
|
|
187 |
void initSensor(void)
|
|
188 |
{
|
54
|
189 |
UNS8 baudrate = 0;
|
|
190 |
UNS8 nodeId = 0;
|
0
|
191 |
// Init led control
|
|
192 |
initPortB();
|
|
193 |
IO_PORTS_8(PORTB) &= ~ 0x01; //One led ON
|
54
|
194 |
initPortH();
|
|
195 |
|
|
196 |
/* Defining the node Id */
|
|
197 |
// Uncomment to have a fixed nodeId
|
|
198 |
//setNodeId(&gene_SYNC_Data, 0x03);
|
|
199 |
|
|
200 |
// Comment below to have a fixed nodeId
|
|
201 |
nodeId = ~(IO_PORTS_8(PTH)) & 0x3F;
|
|
202 |
if (nodeId == 0) {
|
|
203 |
MSG_WAR(0x3F33, "Using default nodeId : ", getNodeId(&gene_SYNC_Data));
|
|
204 |
}
|
|
205 |
else
|
|
206 |
setNodeId(&gene_SYNC_Data, nodeId);
|
|
207 |
|
|
208 |
MSG_WAR(0x3F33, "My nodeId is : ", getNodeId(&gene_SYNC_Data));
|
0
|
209 |
|
|
210 |
canBusInit bi0 = {
|
|
211 |
0, /* no low power */
|
|
212 |
0, /* no time stamp */
|
|
213 |
1, /* enable MSCAN */
|
|
214 |
0, /* clock source : oscillator (In fact, it is not used) */
|
|
215 |
0, /* no loop back */
|
|
216 |
0, /* no listen only */
|
|
217 |
0, /* no low pass filter for wk up */
|
|
218 |
CAN_Baudrates[CAN_BAUDRATE_250K],
|
|
219 |
{
|
|
220 |
0x00, /* Filter on 16 bits. See Motorola Block Guide V02.14 fig 4-3 */
|
|
221 |
0x00, 0xFF, /* filter 0 hight accept all msg */
|
|
222 |
0x00, 0xFF, /* filter 0 low accept all msg */
|
|
223 |
0x00, 0xFF, /* filter 1 hight filter all of msg */
|
|
224 |
0x00, 0xFF, /* filter 1 low filter all of msg */
|
|
225 |
0x00, 0xFF, /* filter 2 hight filter most of msg */
|
|
226 |
0x00, 0xFF, /* filter 2 low filter most of msg */
|
|
227 |
0x00, 0xFF, /* filter 3 hight filter most of msg */
|
|
228 |
0x00, 0xFF, /* filter 3 low filter most of msg */
|
|
229 |
}
|
|
230 |
};
|
|
231 |
|
|
232 |
//Init the HCS12 microcontroler for CanOpen
|
|
233 |
initHCS12();
|
|
234 |
|
54
|
235 |
// Chose the CAN rate (On our board, whe have switch for all purpose)
|
|
236 |
// 7 8
|
|
237 |
// ON ON => 1000 kpbs
|
|
238 |
// OFF ON => 500 kpbs
|
|
239 |
// ON OFF => 250 kpbs
|
|
240 |
|
|
241 |
baudrate = ~(IO_PORTS_8(PTH)) & 0xC0;
|
|
242 |
|
|
243 |
// Uncomment to have a fixed baudrate of 250 kbps
|
|
244 |
//baudrate = 1;
|
|
245 |
|
0
|
246 |
switch (baudrate) {
|
54
|
247 |
case 0x40:
|
0
|
248 |
bi0.clk = CAN_Baudrates[CAN_BAUDRATE_250K];
|
|
249 |
MSG_WAR(0x3F30, "CAN 250 kbps ", 0);
|
|
250 |
break;
|
54
|
251 |
case 0x80:
|
0
|
252 |
bi0.clk = CAN_Baudrates[CAN_BAUDRATE_500K];
|
|
253 |
MSG_WAR(0x3F31, "CAN 500 kbps ", 0);
|
|
254 |
break;
|
54
|
255 |
case 0xC0:
|
0
|
256 |
bi0.clk = CAN_Baudrates[CAN_BAUDRATE_1M];
|
|
257 |
MSG_WAR(0x3F31, "CAN 1000 kbps ", 0);
|
|
258 |
break;
|
|
259 |
default:
|
54
|
260 |
bi0.clk = CAN_Baudrates[CAN_BAUDRATE_1M];
|
|
261 |
MSG_WAR(0x2F32, "CAN BAUD RATE NOT DEFINED => 250 kbps ", 0);
|
0
|
262 |
}
|
|
263 |
|
54
|
264 |
|
|
265 |
|
|
266 |
MSG_WAR(0x3F33, "SYNC signal generator ", 0);
|
0
|
267 |
|
|
268 |
canInit(CANOPEN_LINE_NUMBER_USED, bi0); //initialize filters...
|
|
269 |
initTimer(); // Init hcs12 timer used by CanFestival. (see timerhw.c)
|
|
270 |
unlock(); // Allow interruptions
|
|
271 |
}
|
|
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
|
279 |
// FUNCTIONS WHICH ARE PART OF CANFESTIVAL and *must* be implemented here.
|
|
280 |
|
|
281 |
//------------------------------------------------------------------------------
|
|
282 |
void gene_SYNC_heartbeatError( UNS8 heartbeatID )
|
|
283 |
{
|
|
284 |
|
|
285 |
MSG_ERR(0x1F00, "HeartBeat not received from node : ", heartbeatID);
|
|
286 |
}
|
|
287 |
|
|
288 |
//------------------------------------------------------------------------------
|
|
289 |
void gene_SYNC_SDOtimeoutError (UNS8 line)
|
|
290 |
{
|
|
291 |
MSG_ERR(0x1F01, "SDO timeout for line : ", line);
|
|
292 |
}
|
|
293 |
|
|
294 |
//------------------------------------------------------------------------------
|
|
295 |
UNS8 gene_SYNC_canSend(Message *m)
|
|
296 |
{
|
|
297 |
// HCS12 driver function to send the CAN msg
|
|
298 |
canMsgTransmit(CAN0, *m);
|
|
299 |
return 0;
|
|
300 |
}
|
|
301 |
|
|
302 |
//------------------------------------------------------------------------------
|
|
303 |
void gene_SYNC_initialisation()
|
|
304 |
{
|
|
305 |
MSG_WAR (0x3F00, "Entering in INIT ", 0);
|
54
|
306 |
initSensor();
|
|
307 |
|
0
|
308 |
IO_PORTS_8(PORTB) &= ~ 0x01; // led 0 : ON
|
|
309 |
IO_PORTS_8(PORTB) |= 0x0E; // leds 1, 2, 3 : OFF
|
54
|
310 |
|
0
|
311 |
}
|
|
312 |
|
|
313 |
|
|
314 |
//------------------------------------------------------------------------------
|
|
315 |
void gene_SYNC_preOperational()
|
|
316 |
{
|
|
317 |
MSG_WAR (0x3F01, "Entering in PRE-OPERATIONAL ", 0);
|
|
318 |
IO_PORTS_8(PORTB) &= ~ 0x03; // leds 0, 1 : ON
|
|
319 |
IO_PORTS_8(PORTB) |= 0x0C; // leds 2, 3 : OFF
|
54
|
320 |
/* default values for the msg CAN filters */
|
|
321 |
/* Accept all */
|
|
322 |
{
|
|
323 |
canBusFilterInit filterConfiguration =
|
|
324 |
{
|
|
325 |
0x01, /* Filter on 16 bits. See Motorola Block Guide V02.14 */
|
|
326 |
/*canidarx, canidmrx */
|
|
327 |
0x00, 0xFF, /* filter 0 */
|
|
328 |
0x00, 0xFF, /* filter 0 */
|
|
329 |
0x00, 0xFF, /* filter 1 */
|
|
330 |
0x00, 0xFF, /* filter 1 */
|
|
331 |
0x00, 0xFF, /* filter 2 */
|
|
332 |
0x00, 0xFF, /* filter 2 */
|
|
333 |
0x00, 0xFF, /* filter 3 */
|
|
334 |
0x00, 0xFF, /* filter 3 */
|
|
335 |
};
|
|
336 |
canChangeFilter(CANOPEN_LINE_NUMBER_USED, filterConfiguration);
|
|
337 |
}
|
|
338 |
// Reset the automatic change by SDO
|
|
339 |
applyDownloadedFilters = 0;
|
|
340 |
|
0
|
341 |
}
|
|
342 |
|
|
343 |
|
|
344 |
//------------------------------------------------------------------------------
|
|
345 |
void gene_SYNC_operational()
|
|
346 |
{
|
|
347 |
MSG_WAR (0x3F02, "Entering in OPERATIONAL ", 0);
|
|
348 |
IO_PORTS_8(PORTB) &= ~ 0x07; // leds 0, 1, 2 : ON
|
|
349 |
IO_PORTS_8(PORTB) |= 0x08; // leds 3 : OFF
|
54
|
350 |
|
|
351 |
// Filtering the CAN received msgs.
|
|
352 |
// 2 ways
|
|
353 |
// First :applying an automatic filter
|
|
354 |
// Second : The values of the filtering registers are mapped in the object dictionary,
|
|
355 |
// So that a filtering configuration can be downloaded by SDO in pre-operational mode
|
|
356 |
|
|
357 |
if (applyDownloadedFilters == 0) {// No downloaded configuration to apply
|
|
358 |
UNS16 accept1 = 0x0000; // Accept NMT
|
|
359 |
UNS16 mask1 = 0x0FFF; // Mask NMT
|
|
360 |
UNS16 accept2 = 0xE000; // Accept NMT error control (heartbeat, nodeguard)
|
|
361 |
UNS16 mask2 = 0x0FFF; // Mask NMT error control (heartbeat, nodeguard)
|
|
362 |
|
|
363 |
canBusFilterInit filterConfiguration =
|
|
364 |
{// filters 3 and 4 not used, so configured like filter 1.
|
|
365 |
0x01, /* Filter on 16 bits. See Motorola Block Guide V02.14 */
|
|
366 |
/*canidarx, canidmrx */
|
|
367 |
(UNS8)(accept1 >> 8), (UNS8)(mask1 >> 8), /* filter 1 id10...3*/
|
|
368 |
(UNS8)accept1 , (UNS8)mask1, /* filter 1 id2 ... */
|
|
369 |
(UNS8)(accept2 >> 8), (UNS8)(mask2 >> 8), /* filter 2 id10...3*/
|
|
370 |
(UNS8)accept2 , (UNS8)mask2, /* filter 2 id2 ... */
|
|
371 |
(UNS8)(accept1 >> 8), (UNS8)(mask1 >> 8), /* filter 3 id10...3*/
|
|
372 |
(UNS8)accept1 , (UNS8)mask1, /* filter 3 id2 ... */
|
|
373 |
(UNS8)(accept1 >> 8), (UNS8)(mask1 >> 8), /* filter 4 id10...3*/
|
|
374 |
(UNS8)accept1 , (UNS8)mask1 /* filter 4 id2 ... */
|
|
375 |
};
|
|
376 |
canChangeFilter(CANOPEN_LINE_NUMBER_USED, filterConfiguration);
|
|
377 |
MSG_WAR (0x3F03, "Internal CAN Rcv filter applied ", 0);
|
|
378 |
}
|
|
379 |
else { // Apply filters downnloaded
|
|
380 |
canBusFilterInit filterConfiguration =
|
|
381 |
{// filters 3 and 4 not used, so configured like filter 1.
|
|
382 |
0x01, /* Filter on 16 bits. See Motorola Block Guide V02.14 */
|
|
383 |
/*canidarx, canidmrx */
|
|
384 |
(UNS8)( acceptanceFilter1>> 8), (UNS8)(mask1 >> 8), /* filter 1 id10...3*/
|
|
385 |
(UNS8)acceptanceFilter1 , (UNS8)mask1, /* filter 1 id2 ... */
|
|
386 |
(UNS8)(acceptanceFilter2 >> 8), (UNS8)(mask2 >> 8), /* filter 2 id10...3*/
|
|
387 |
(UNS8)acceptanceFilter2 , (UNS8)mask2, /* filter 2 id2 ... */
|
|
388 |
(UNS8)(acceptanceFilter3 >> 8), (UNS8)(mask3 >> 8), /* filter 3 id10...3*/
|
|
389 |
(UNS8)acceptanceFilter3 , (UNS8)mask3, /* filter 3 id2 ... */
|
|
390 |
(UNS8)(acceptanceFilter4 >> 8), (UNS8)(mask4 >> 8), /* filter 4 id10...3*/
|
|
391 |
(UNS8)acceptanceFilter4 , (UNS8)mask4 /* filter 4 id2 ... */
|
|
392 |
};
|
|
393 |
canChangeFilter(CANOPEN_LINE_NUMBER_USED, filterConfiguration);
|
|
394 |
MSG_WAR (0x3F04, "Downloaded CAN Rcv filter applied ", 0);
|
|
395 |
}
|
0
|
396 |
}
|
|
397 |
|
|
398 |
//------------------------------------------------------------------------------
|
|
399 |
void gene_SYNC_stopped()
|
|
400 |
{
|
|
401 |
MSG_WAR (0x3F02, "Entering in STOPPED ", 0);
|
54
|
402 |
IO_PORTS_8(PORTB) |= 0x0E; // leds 1, 2, 3, 4 : OFF
|
0
|
403 |
}
|
|
404 |
|
|
405 |
//------------------------------------------------------------------------------
|
|
406 |
void gene_SYNC_post_sync()
|
|
407 |
{
|
|
408 |
}
|
|
409 |
|
|
410 |
//------------------------------------------------------------------------------
|
|
411 |
void gene_SYNC_post_TPDO()
|
|
412 |
{
|
|
413 |
}
|
|
414 |
|
|
415 |
// End functions which are part of Canfestival
|
|
416 |
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
|
417 |
|
|
418 |
|
|
419 |
/******************************************************************************/
|
|
420 |
/********************************* MAIN ***************************************/
|
|
421 |
/******************************************************************************/
|
|
422 |
|
|
423 |
|
|
424 |
UNS8 main (void)
|
|
425 |
{
|
|
426 |
|
54
|
427 |
MSG_WAR(0x3F34, "Entering in the main ", 0);
|
0
|
428 |
//----------------------------- INITIALISATION --------------------------------
|
54
|
429 |
|
0
|
430 |
/* Put the node in Initialisation mode */
|
54
|
431 |
MSG_WAR(0x3F35, "Will entering in INIT ", 0);
|
0
|
432 |
setState(&gene_SYNC_Data, Initialisation);
|
|
433 |
|
|
434 |
//----------------------------- START -----------------------------------------
|
|
435 |
/* Put the node in pre-operational mode */
|
|
436 |
//MSG_WAR(0x3F36, "va passer en pre-op", 0);
|
|
437 |
//setState(&gene_SYNC_Data, Pre_operational);
|
|
438 |
|
54
|
439 |
// Loop of receiving messages
|
|
440 |
while (1) {
|
0
|
441 |
Message m;
|
|
442 |
if (f_can_receive(0, &m)) {
|
54
|
443 |
//MSG_WAR(0x3F36, "Msg received", m.cob_id.w);
|
0
|
444 |
canDispatch(&gene_SYNC_Data, &m);
|
54
|
445 |
}
|
|
446 |
}
|
0
|
447 |
|
|
448 |
return (0);
|
|
449 |
}
|
|
450 |
|
|
451 |
|
|
452 |
|