etherlab/etherlab_ext.c
changeset 2086 8e4992e0f147
child 2165 02a2b5dee5e3
equal deleted inserted replaced
2085:ae263886ae92 2086:8e4992e0f147
       
     1 #include "iec_types_all.h"
       
     2 
       
     3 #define FREE 0
       
     4 #define ACQUIRED 1
       
     5 #define ANSWERED 2
       
     6 
       
     7 long SDOLock = FREE;
       
     8 extern long AtomicCompareExchange(long* atomicvar,long compared, long exchange);
       
     9 
       
    10 int AcquireSDOLock() {
       
    11 	return AtomicCompareExchange(&SDOLock, FREE, ACQUIRED) == FREE;
       
    12 }
       
    13 
       
    14 void SDOAnswered() {
       
    15 	AtomicCompareExchange(&SDOLock, ACQUIRED, ANSWERED);
       
    16 }
       
    17 
       
    18 int HasAnswer() {
       
    19 	return SDOLock == ANSWERED;
       
    20 }
       
    21 
       
    22 void ReleaseSDOLock() {
       
    23 	AtomicCompareExchange(&SDOLock, ANSWERED, FREE);
       
    24 }
       
    25 
       
    26 int __init_etherlab_ext()
       
    27 {
       
    28     SDOLock = FREE;
       
    29     return 0;
       
    30 }
       
    31 
       
    32 void __cleanup_etherlab_ext()
       
    33 {
       
    34 }
       
    35 
       
    36 void __retrieve_etherlab_ext()
       
    37 {
       
    38 }
       
    39 
       
    40 void __publish_etherlab_ext()
       
    41 {
       
    42 }