edouard@2165: /*
edouard@2165: 
edouard@2165: Template C code used to produce target Ethercat C code.
edouard@2165: 
edouard@2165: Copyright (C) 2011-2014: Laurent BESSARD, Edouard TISSERANT
edouard@2165: 
edouard@2165: Distributed under the terms of the GNU Lesser General Public License as
edouard@2165: published by the Free Software Foundation; either version 2 of the License, or
edouard@2165: (at your option) any later version.
edouard@2165: 
edouard@2165: See COPYING file for copyrights details.
edouard@2165: 
edouard@2165: */
edouard@2165: 
Laurent@2086: #include "iec_types_all.h"
Laurent@2086: 
Laurent@2086: #define FREE 0
Laurent@2086: #define ACQUIRED 1
Laurent@2086: #define ANSWERED 2
Laurent@2086: 
Laurent@2086: long SDOLock = FREE;
Laurent@2086: extern long AtomicCompareExchange(long* atomicvar,long compared, long exchange);
Laurent@2086: 
Laurent@2086: int AcquireSDOLock() {
Laurent@2086: 	return AtomicCompareExchange(&SDOLock, FREE, ACQUIRED) == FREE;
Laurent@2086: }
Laurent@2086: 
Laurent@2086: void SDOAnswered() {
Laurent@2086: 	AtomicCompareExchange(&SDOLock, ACQUIRED, ANSWERED);
Laurent@2086: }
Laurent@2086: 
Laurent@2086: int HasAnswer() {
Laurent@2086: 	return SDOLock == ANSWERED;
Laurent@2086: }
Laurent@2086: 
Laurent@2086: void ReleaseSDOLock() {
Laurent@2086: 	AtomicCompareExchange(&SDOLock, ANSWERED, FREE);
Laurent@2086: }
Laurent@2086: 
Laurent@2086: int __init_etherlab_ext()
Laurent@2086: {
Laurent@2086:     SDOLock = FREE;
Laurent@2086:     return 0;
Laurent@2086: }
Laurent@2086: 
Laurent@2086: void __cleanup_etherlab_ext()
Laurent@2086: {
Laurent@2086: }
Laurent@2086: 
Laurent@2086: void __retrieve_etherlab_ext()
Laurent@2086: {
Laurent@2086: }
Laurent@2086: 
Laurent@2086: void __publish_etherlab_ext()
Laurent@2086: {
Laurent@2086: }