* Ethercat DS402 node execution code
IEC_UINT __InactiveMask = 0x4f;
IEC_UINT __ActiveMask = 0x6f;
static __DS402Node __DS402Node_%(location)s;
%(located_variables_declaration)s
extern uint8_t *domain1_pd;
%(extern_pdo_entry_configuration)s
int __init_%(location)s()
void __cleanup_%(location)s()
void __retrieve_%(location)s()
IEC_UINT statusword_inactive = __DS402Node_%(location)s.StatusWord & __InactiveMask;
IEC_UINT statusword_active = __DS402Node_%(location)s.StatusWord & __ActiveMask;
// DS402 input entries extraction
// DS402 node state computation
__DS402Node_%(location)s.state = __Unknown;
switch (statusword_inactive) {
__DS402Node_%(location)s.state = __NotReadyToSwitchOn;
__DS402Node_%(location)s.state = __SwitchOnDisabled;
__DS402Node_%(location)s.state = __FaultReactionActive;
__DS402Node_%(location)s.state = __Fault;
switch (statusword_active) {
__DS402Node_%(location)s.state = __ReadyToSwitchOn;
__DS402Node_%(location)s.state = __SwitchedOn;
__DS402Node_%(location)s.state = __OperationEnabled;
__DS402Node_%(location)s.state = __QuickStopActive;
if (__DS402Node_%(location)s.state == __Unknown) {
void __publish_%(location)s()
// DS402 node state transition computation
switch (__DS402Node_%(location)s.state) {
__DS402Node_%(location)s.ControlWord = (__DS402Node_%(location)s.ControlWord & ~0x87) | 0x06;
__DS402Node_%(location)s.ControlWord = (__DS402Node_%(location)s.ControlWord & ~0x8f) | 0x07;
// __DS402Node_%(location)s.ControlWord = (__DS402Node_%(location)s.ControlWord & ~0x8f) | 0x0f;
// __DS402Node_%(location)s.ControlWord = (__DS402Node_%(location)s.ControlWord & ~0x8f) | 0x07;
__DS402Node_%(location)s.ControlWord = (__DS402Node_%(location)s.ControlWord & ~0x8f) | 0x80;
// DS402 output entries setting