Add support to choose if manual or automatic state change is done by config functions, fixes #189

feature/soem_140
Andreas Karlsson 2019-06-10 11:48:41 +02:00
parent cc417d4c0c
commit 817435066f
3 changed files with 34 additions and 7 deletions

View File

@ -589,8 +589,16 @@ int ecx_config_init(ecx_contextt *context, uint8 usetable)
}
/* some slaves need eeprom available to PDI in init->preop transition */
ecx_eeprom2pdi(context, slave);
/* request pre_op for slave */
ecx_FPWRw(context->port, configadr, ECT_REG_ALCTL, htoes(EC_STATE_PRE_OP | EC_STATE_ACK) , EC_TIMEOUTRET3); /* set preop status */
/* User may override automatic state change */
if (context->manualstatechange == 0)
{
/* request pre_op for slave */
ecx_FPWRw(context->port,
configadr,
ECT_REG_ALCTL,
htoes(EC_STATE_PRE_OP | EC_STATE_ACK),
EC_TIMEOUTRET3); /* set preop status */
}
}
}
return wkc;
@ -1273,8 +1281,16 @@ int ecx_config_map_group(ecx_contextt *context, void *pIOmap, uint8 group)
}
ecx_eeprom2pdi(context, slave); /* set Eeprom control to PDI */
ecx_FPWRw(context->port, configadr, ECT_REG_ALCTL, htoes(EC_STATE_SAFE_OP) , EC_TIMEOUTRET3); /* set safeop status */
/* User may override automatic state change */
if (context->manualstatechange == 0)
{
/* request safe_op for slave */
ecx_FPWRw(context->port,
configadr,
ECT_REG_ALCTL,
htoes(EC_STATE_SAFE_OP),
EC_TIMEOUTRET3); /* set safeop status */
}
if (context->slavelist[slave].blockLRW)
{
context->grouplist[group].blockLRW++;
@ -1409,8 +1425,16 @@ int ecx_config_overlap_map_group(ecx_contextt *context, void *pIOmap, uint8 grou
}
ecx_eeprom2pdi(context, slave); /* set Eeprom control to PDI */
ecx_FPWRw(context->port, configadr, ECT_REG_ALCTL, htoes(EC_STATE_SAFE_OP), EC_TIMEOUTRET3); /* set safeop status */
/* User may override automatic state change */
if (context->manualstatechange == 0)
{
/* request safe_op for slave */
ecx_FPWRw(context->port,
configadr,
ECT_REG_ALCTL,
htoes(EC_STATE_SAFE_OP),
EC_TIMEOUTRET3);
}
if (context->slavelist[slave].blockLRW)
{
context->grouplist[group].blockLRW++;

View File

@ -119,7 +119,8 @@ ecx_contextt ecx_context = {
&ec_SM, // .eepSM =
&ec_FMMU, // .eepFMMU =
NULL, // .FOEhook()
NULL // .EOEhook()
NULL, // .EOEhook()
0 // .manualstatechange
};
#endif

View File

@ -427,6 +427,8 @@ struct ecx_context
int (*FOEhook)(uint16 slave, int packetnumber, int datasize);
/** registered EoE hook */
int (*EOEhook)(ecx_contextt * context, uint16 slave, void * eoembx);
/** flag to control legacy automatic state change or manual state change */
int manualstatechange;
};
#ifdef EC_VER1