equal
deleted
inserted
replaced
|
1 /* |
|
2 |
|
3 Template C code used to produce target Ethercat C code. |
|
4 |
|
5 Copyright (C) 2011-2014: Laurent BESSARD, Edouard TISSERANT |
|
6 |
|
7 Distributed under the terms of the GNU Lesser General Public License as |
|
8 published by the Free Software Foundation; either version 2 of the License, or |
|
9 (at your option) any later version. |
|
10 |
|
11 See COPYING file for copyrights details. |
|
12 |
|
13 */ |
|
14 |
|
15 #include "iec_types_all.h" |
|
16 |
|
17 #define FREE 0 |
|
18 #define ACQUIRED 1 |
|
19 #define ANSWERED 2 |
|
20 |
|
21 long SDOLock = FREE; |
|
22 extern long AtomicCompareExchange(long* atomicvar,long compared, long exchange); |
|
23 |
|
24 int AcquireSDOLock() { |
|
25 return AtomicCompareExchange(&SDOLock, FREE, ACQUIRED) == FREE; |
|
26 } |
|
27 |
|
28 void SDOAnswered() { |
|
29 AtomicCompareExchange(&SDOLock, ACQUIRED, ANSWERED); |
|
30 } |
|
31 |
|
32 int HasAnswer() { |
|
33 return SDOLock == ANSWERED; |
|
34 } |
|
35 |
|
36 void ReleaseSDOLock() { |
|
37 AtomicCompareExchange(&SDOLock, ANSWERED, FREE); |
|
38 } |
|
39 |
|
40 int __init_etherlab_ext() |
|
41 { |
|
42 SDOLock = FREE; |
|
43 return 0; |
|
44 } |
|
45 |
|
46 void __cleanup_etherlab_ext() |
|
47 { |
|
48 } |
|
49 |
|
50 void __retrieve_etherlab_ext() |
|
51 { |
|
52 } |
|
53 |
|
54 void __publish_etherlab_ext() |
|
55 { |
|
56 } |