Move DC config to the applications

pull/52/head
Andreas Karlsson 2019-01-30 10:31:02 +01:00 committed by Hans-Erik Floryd
parent 446b79d456
commit ca48f9db21
4 changed files with 9 additions and 107 deletions

View File

@ -250,51 +250,16 @@ uint16_t ESC_checkDC (void)
uint16_t ret = 0;
uint8_t sync_act = ESC_SYNCactivation();
uint32_t sync0_cycletime = ESC_SYNC0cycletime();
uint16_t sync_type_supported1c32 = 0;
uint32_t mincycletime = 0;
/* Do we need to check sync settings? */
if((sync_act & (ESCREG_SYNC_ACT_ACTIVATED | ESCREG_SYNC_AUTO_ACTIVATED)) > 0)
{
/* If the sync unit is active at least on signal should be activated */
if(COE_getSyncMgrPara(0x1c32, 0x4, &sync_type_supported1c32, DTYPE_UNSIGNED16) == 0)
/* Trigger a by the application given DC check handler, return error if
* non is given
*/
ret = ALERR_DCINVALIDSYNCCFG;
if(ESCvar.esc_check_dc_handler != NULL)
{
ret = ALERR_DCINVALIDSYNCCFG;
}
else if(COE_getSyncMgrPara(0x1c32, 0x5, &mincycletime, DTYPE_UNSIGNED32) == 0)
{
ret = ALERR_DCINVALIDSYNCCFG;
}
else if(COE_getSyncMgrPara(0x10F1, 0x2, &ESCvar.synccounterlimit, DTYPE_UNSIGNED16) == 0)
{
ret = ALERR_DCINVALIDSYNCCFG;
}
else if((sync_act & (ESCREG_SYNC_SYNC0_EN | ESCREG_SYNC_SYNC1_EN)) == 0)
{
ret = ALERR_DCINVALIDSYNCCFG;
}
/* Do we support activated signals */
else if(((sync_type_supported1c32 & SYNCTYPE_SUPPORT_DCSYNC0) == 0) &&
((sync_act & ESCREG_SYNC_SYNC0_EN) > 0))
{
ret = ALERR_DCINVALIDSYNCCFG;
}
/* Do we support activated signals */
else if(((sync_type_supported1c32 & SYNCTYPE_SUPPORT_DCSYNC1) == 0) &&
((sync_act & ESCREG_SYNC_SYNC1_EN) > 0))
{
ret = ALERR_DCINVALIDSYNCCFG;
}
else if((sync0_cycletime != 0) && (sync0_cycletime < mincycletime))
{
ret = ALERR_DCSYNC0CYCLETIME;
}
else
{
ESCvar.dcsync = 1;
ESCvar.synccounter = 0;
ret = (ESCvar.esc_check_dc_handler)();
}
}
else
@ -1188,4 +1153,5 @@ void ESC_config (esc_cfg_t * cfg)
ESCvar.esc_hw_interrupt_enable = cfg->esc_hw_interrupt_enable;
ESCvar.esc_hw_interrupt_disable = cfg->esc_hw_interrupt_disable;
ESCvar.esc_hw_eep_handler = cfg->esc_hw_eep_handler;
ESCvar.esc_check_dc_handler = cfg->esc_check_dc_handler;
}

View File

@ -251,6 +251,7 @@ typedef struct esc_cfg
void (*esc_hw_interrupt_enable) (uint32_t mask);
void (*esc_hw_interrupt_disable) (uint32_t mask);
void (*esc_hw_eep_handler) (void);
uint16_t (*esc_check_dc_handler) (void);
} esc_cfg_t;
typedef struct
@ -362,6 +363,7 @@ typedef struct
void (*esc_hw_interrupt_enable) (uint32_t mask);
void (*esc_hw_interrupt_disable) (uint32_t mask);
void (*esc_hw_eep_handler) (void);
uint16_t (*esc_check_dc_handler) (void);
uint8_t MBXrun;
size_t activembxsize;
sm_cfg_t * activemb0;

View File

@ -61,71 +61,6 @@ int32_t SDO_findobject (uint16_t index)
return n;
}
/** Get the value for requested SDO 0x1C32 or 0x1C33 sub index
*
* @param[in] index = value on index of object we want to locate
* @param[in] subindex = value on subindex of object we want to locate
* @param[out] buf = buf to copy value to
* @param[in] datatype = EtherCAT datatype of buf
* @return 1 if value was found, else 0.
*/
int COE_getSyncMgrPara (uint16_t index, uint8_t subindex, void * buf, uint16_t datatype)
{
int result = 0;
int32_t nidx;
int32_t snidx;
const _objd *objd;
nidx = SDO_findobject(index);
if(nidx < 0)
{
return result;
}
else if((index != 0x1c32) && (index != 0x1c33) && (index != 0x10F1))
{
return result;
}
snidx = SDO_findsubindex(nidx, subindex);
if(snidx >= 0)
{
objd = SDOobjects[nidx].objdesc;
if((objd[snidx].data != NULL) &&
(objd[snidx].datatype == datatype))
{
memcpy(buf, objd[snidx].data, objd[snidx].bitlength / 8 );
result = 1;
}
else
{
if((datatype == DTYPE_UNSIGNED32) &&
(objd[snidx].datatype == datatype))
{
*(uint32_t *)buf = objd[snidx].value;
result = 1;
}
else if((datatype == DTYPE_UNSIGNED16) &&
(objd[snidx].datatype == datatype))
{
*(uint16_t *)buf = (uint16_t)objd[snidx].value;
result = 1;
}
else if((datatype == DTYPE_UNSIGNED8) &&
(objd[snidx].datatype == datatype))
{
*(uint8_t *)buf = (uint8_t)objd[snidx].value;
result = 1;
}
}
}
return result;
}
/** Init default values for SDO Sync Objects
*
*/

View File

@ -88,7 +88,6 @@ void ESC_coeprocess (void);
uint16_t sizeOfPDO (uint16_t index);
void SDO_abort (uint16_t index, uint8_t subindex, uint32_t abortcode);
void COE_initDefaultSyncMgrPara (void);
int COE_getSyncMgrPara (uint16_t index, uint8_t subindex, void * buf, uint16_t datatype);
extern void ESC_objecthandler (uint16_t index, uint8_t subindex);
extern int ESC_pre_objecthandler (uint16_t index, uint8_t subindex);