author | Laurent Bessard |
Wed, 24 Apr 2013 17:27:31 +0200 | |
changeset 2133 | ba0b2ca7db26 |
parent 2086 | 8e4992e0f147 |
child 2165 | 02a2b5dee5e3 |
permissions | -rw-r--r-- |
2086
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
1 |
#include "iec_types_all.h" |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
2 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
3 |
#define FREE 0 |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
4 |
#define ACQUIRED 1 |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
5 |
#define ANSWERED 2 |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
6 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
7 |
long SDOLock = FREE; |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
8 |
extern long AtomicCompareExchange(long* atomicvar,long compared, long exchange); |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
9 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
10 |
int AcquireSDOLock() { |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
11 |
return AtomicCompareExchange(&SDOLock, FREE, ACQUIRED) == FREE; |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
12 |
} |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
13 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
14 |
void SDOAnswered() { |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
15 |
AtomicCompareExchange(&SDOLock, ACQUIRED, ANSWERED); |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
16 |
} |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
17 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
18 |
int HasAnswer() { |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
19 |
return SDOLock == ANSWERED; |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
20 |
} |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
21 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
22 |
void ReleaseSDOLock() { |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
23 |
AtomicCompareExchange(&SDOLock, ANSWERED, FREE); |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
24 |
} |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
25 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
26 |
int __init_etherlab_ext() |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
27 |
{ |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
28 |
SDOLock = FREE; |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
29 |
return 0; |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
30 |
} |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
31 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
32 |
void __cleanup_etherlab_ext() |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
33 |
{ |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
34 |
} |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
35 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
36 |
void __retrieve_etherlab_ext() |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
37 |
{ |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
38 |
} |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
39 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
40 |
void __publish_etherlab_ext() |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
41 |
{ |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
diff
changeset
|
42 |
} |