Merge branch 'dergentk-newOD_fixes' into newOD
This commit is contained in:
commit
78d5f2569b
5 changed files with 17 additions and 7 deletions
|
|
@ -351,10 +351,10 @@ static void CO_EM_receive(void *object, void *msg) {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
CO_ReturnError_t CO_EM_init(CO_EM_t *em,
|
CO_ReturnError_t CO_EM_init(CO_EM_t *em,
|
||||||
|
CO_CANmodule_t *CANdevTx,
|
||||||
const OD_entry_t *OD_1001_errReg,
|
const OD_entry_t *OD_1001_errReg,
|
||||||
#if (CO_CONFIG_EM) & CO_CONFIG_EM_PRODUCER
|
#if (CO_CONFIG_EM) & CO_CONFIG_EM_PRODUCER
|
||||||
OD_entry_t *OD_1014_cobIdEm,
|
OD_entry_t *OD_1014_cobIdEm,
|
||||||
CO_CANmodule_t *CANdevTx,
|
|
||||||
uint16_t CANdevTxIdx,
|
uint16_t CANdevTxIdx,
|
||||||
#if (CO_CONFIG_EM) & CO_CONFIG_EM_PROD_INHIBIT
|
#if (CO_CONFIG_EM) & CO_CONFIG_EM_PROD_INHIBIT
|
||||||
OD_entry_t *OD_1015_InhTime,
|
OD_entry_t *OD_1015_InhTime,
|
||||||
|
|
@ -396,6 +396,9 @@ CO_ReturnError_t CO_EM_init(CO_EM_t *em,
|
||||||
/* clear the object */
|
/* clear the object */
|
||||||
memset(em, 0, sizeof(CO_EM_t));
|
memset(em, 0, sizeof(CO_EM_t));
|
||||||
|
|
||||||
|
/* set object variables */
|
||||||
|
em->CANdevTx = CANdevTx;
|
||||||
|
|
||||||
/* get and verify "Error register" from Object Dictionary */
|
/* get and verify "Error register" from Object Dictionary */
|
||||||
em->errorRegister = OD_getPtr(OD_1001_errReg, 0, sizeof(uint8_t), NULL);
|
em->errorRegister = OD_getPtr(OD_1001_errReg, 0, sizeof(uint8_t), NULL);
|
||||||
if (em->errorRegister == NULL) {
|
if (em->errorRegister == NULL) {
|
||||||
|
|
@ -451,7 +454,6 @@ CO_ReturnError_t CO_EM_init(CO_EM_t *em,
|
||||||
|
|
||||||
/* configure parameters and emergency message CAN transmission */
|
/* configure parameters and emergency message CAN transmission */
|
||||||
em->nodeId = nodeId;
|
em->nodeId = nodeId;
|
||||||
em->CANdevTx = CANdevTx;
|
|
||||||
|
|
||||||
em->CANtxBuff = CO_CANtxBufferInit(
|
em->CANtxBuff = CO_CANtxBufferInit(
|
||||||
CANdevTx, /* CAN device */
|
CANdevTx, /* CAN device */
|
||||||
|
|
|
||||||
|
|
@ -373,6 +373,8 @@ typedef struct {
|
||||||
uint8_t *errorRegister;
|
uint8_t *errorRegister;
|
||||||
/** Old CAN error status bitfield */
|
/** Old CAN error status bitfield */
|
||||||
uint16_t CANerrorStatusOld;
|
uint16_t CANerrorStatusOld;
|
||||||
|
/** From CO_EM_init() */
|
||||||
|
CO_CANmodule_t *CANdevTx;
|
||||||
|
|
||||||
#if ((CO_CONFIG_EM) & (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY)) \
|
#if ((CO_CONFIG_EM) & (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY)) \
|
||||||
|| defined CO_DOXYGEN
|
|| defined CO_DOXYGEN
|
||||||
|
|
@ -403,8 +405,6 @@ typedef struct {
|
||||||
bool_t producerEnabled;
|
bool_t producerEnabled;
|
||||||
/** Copy of CANopen node ID, from CO_EM_init() */
|
/** Copy of CANopen node ID, from CO_EM_init() */
|
||||||
uint8_t nodeId;
|
uint8_t nodeId;
|
||||||
/** From CO_EM_init() */
|
|
||||||
CO_CANmodule_t *CANdevTx;
|
|
||||||
/** CAN transmit buffer */
|
/** CAN transmit buffer */
|
||||||
CO_CANtx_t *CANtxBuff;
|
CO_CANtx_t *CANtxBuff;
|
||||||
/** Extension for OD object */
|
/** Extension for OD object */
|
||||||
|
|
@ -459,11 +459,11 @@ typedef struct {
|
||||||
* Function must be called in the communication reset section.
|
* Function must be called in the communication reset section.
|
||||||
*
|
*
|
||||||
* @param em This object will be initialized.
|
* @param em This object will be initialized.
|
||||||
|
* @param CANdevTx CAN device for Emergency transmission.
|
||||||
* @param OD_1001_errReg OD entry for 0x1001 - "Error register", entry is
|
* @param OD_1001_errReg OD entry for 0x1001 - "Error register", entry is
|
||||||
* required, without IO extension.
|
* required, without IO extension.
|
||||||
* @param OD_1014_cobIdEm OD entry for 0x1014 - "COB-ID EMCY", entry is
|
* @param OD_1014_cobIdEm OD entry for 0x1014 - "COB-ID EMCY", entry is
|
||||||
* required, IO extension is required.
|
* required, IO extension is required.
|
||||||
* @param CANdevTx CAN device for Emergency transmission.
|
|
||||||
* @param CANdevTxIdx Index of transmit buffer in the above CAN device.
|
* @param CANdevTxIdx Index of transmit buffer in the above CAN device.
|
||||||
* @param OD_1015_InhTime OD entry for 0x1015 - "Inhibit time EMCY", entry is
|
* @param OD_1015_InhTime OD entry for 0x1015 - "Inhibit time EMCY", entry is
|
||||||
* optional (can be NULL), IO extension is optional for runtime configuration.
|
* optional (can be NULL), IO extension is optional for runtime configuration.
|
||||||
|
|
@ -483,10 +483,10 @@ typedef struct {
|
||||||
* @return @ref CO_ReturnError_t CO_ERROR_NO in case of success.
|
* @return @ref CO_ReturnError_t CO_ERROR_NO in case of success.
|
||||||
*/
|
*/
|
||||||
CO_ReturnError_t CO_EM_init(CO_EM_t *em,
|
CO_ReturnError_t CO_EM_init(CO_EM_t *em,
|
||||||
|
CO_CANmodule_t *CANdevTx,
|
||||||
const OD_entry_t *OD_1001_errReg,
|
const OD_entry_t *OD_1001_errReg,
|
||||||
#if ((CO_CONFIG_EM) & CO_CONFIG_EM_PRODUCER) || defined CO_DOXYGEN
|
#if ((CO_CONFIG_EM) & CO_CONFIG_EM_PRODUCER) || defined CO_DOXYGEN
|
||||||
OD_entry_t *OD_1014_cobIdEm,
|
OD_entry_t *OD_1014_cobIdEm,
|
||||||
CO_CANmodule_t *CANdevTx,
|
|
||||||
uint16_t CANdevTxIdx,
|
uint16_t CANdevTxIdx,
|
||||||
#if ((CO_CONFIG_EM) & CO_CONFIG_EM_PROD_INHIBIT) || defined CO_DOXYGEN
|
#if ((CO_CONFIG_EM) & CO_CONFIG_EM_PROD_INHIBIT) || defined CO_DOXYGEN
|
||||||
OD_entry_t *OD_1015_InhTime,
|
OD_entry_t *OD_1015_InhTime,
|
||||||
|
|
|
||||||
|
|
@ -333,7 +333,9 @@ CO_ReturnError_t CO_SDOserver_init(CO_SDOserver_t *SDO,
|
||||||
/* Configure object variables */
|
/* Configure object variables */
|
||||||
SDO->OD = OD;
|
SDO->OD = OD;
|
||||||
SDO->nodeId = nodeId;
|
SDO->nodeId = nodeId;
|
||||||
|
#if ((CO_CONFIG_SDO_SRV) & CO_CONFIG_SDO_SRV_SEGMENTED)
|
||||||
SDO->SDOtimeoutTime_us = (uint32_t)SDOtimeoutTime_ms * 1000;
|
SDO->SDOtimeoutTime_us = (uint32_t)SDOtimeoutTime_ms * 1000;
|
||||||
|
#endif
|
||||||
#if (CO_CONFIG_SDO_SRV) & CO_CONFIG_SDO_SRV_BLOCK
|
#if (CO_CONFIG_SDO_SRV) & CO_CONFIG_SDO_SRV_BLOCK
|
||||||
SDO->block_SDOtimeoutTime_us = (uint32_t)SDOtimeoutTime_ms * 700;
|
SDO->block_SDOtimeoutTime_us = (uint32_t)SDOtimeoutTime_ms * 700;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1137,7 +1139,9 @@ CO_SDO_return_t CO_SDOserver_process(CO_SDOserver_t *SDO,
|
||||||
SDO->state = CO_SDO_ST_ABORT;
|
SDO->state = CO_SDO_ST_ABORT;
|
||||||
}
|
}
|
||||||
} /* switch (SDO->state) */
|
} /* switch (SDO->state) */
|
||||||
|
#if (CO_CONFIG_SDO_SRV) & CO_CONFIG_SDO_SRV_SEGMENTED
|
||||||
SDO->timeoutTimer = 0;
|
SDO->timeoutTimer = 0;
|
||||||
|
#endif
|
||||||
timeDifference_us = 0;
|
timeDifference_us = 0;
|
||||||
CO_FLAG_CLEAR(SDO->CANrxNew);
|
CO_FLAG_CLEAR(SDO->CANrxNew);
|
||||||
} /* if (isNew) */
|
} /* if (isNew) */
|
||||||
|
|
@ -1206,7 +1210,9 @@ CO_SDO_return_t CO_SDOserver_process(CO_SDOserver_t *SDO,
|
||||||
SDO->CANtxBuff->data[3] = SDO->subIndex;
|
SDO->CANtxBuff->data[3] = SDO->subIndex;
|
||||||
|
|
||||||
/* reset timeout timer and send message */
|
/* reset timeout timer and send message */
|
||||||
|
#if (CO_CONFIG_SDO_SRV) & CO_CONFIG_SDO_SRV_SEGMENTED
|
||||||
SDO->timeoutTimer = 0;
|
SDO->timeoutTimer = 0;
|
||||||
|
#endif
|
||||||
CO_CANsend(SDO->CANdevTx, SDO->CANtxBuff);
|
CO_CANsend(SDO->CANdevTx, SDO->CANtxBuff);
|
||||||
#if (CO_CONFIG_SDO_SRV) & CO_CONFIG_SDO_SRV_SEGMENTED
|
#if (CO_CONFIG_SDO_SRV) & CO_CONFIG_SDO_SRV_SEGMENTED
|
||||||
if (SDO->finished) {
|
if (SDO->finished) {
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,9 @@ static inline void CO_TIME_set(CO_TIME_t *TIME,
|
||||||
TIME->residual_us = 0;
|
TIME->residual_us = 0;
|
||||||
TIME->ms = ms;
|
TIME->ms = ms;
|
||||||
TIME->days = days;
|
TIME->days = days;
|
||||||
|
#if ((CO_CONFIG_TIME) & CO_CONFIG_TIME_PRODUCER)
|
||||||
TIME->producerTimer_ms = TIME->producerInterval_ms =producerInterval_ms;
|
TIME->producerTimer_ms = TIME->producerInterval_ms =producerInterval_ms;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -960,10 +960,10 @@ CO_ReturnError_t CO_CANopenInit(CO_t *co,
|
||||||
/* Emergency */
|
/* Emergency */
|
||||||
if (CO_GET_CNT(EM) == 1) {
|
if (CO_GET_CNT(EM) == 1) {
|
||||||
err = CO_EM_init(co->em,
|
err = CO_EM_init(co->em,
|
||||||
|
co->CANmodule,
|
||||||
OD_GET(H1001, OD_H1001_ERR_REG),
|
OD_GET(H1001, OD_H1001_ERR_REG),
|
||||||
#if (CO_CONFIG_EM) & CO_CONFIG_EM_PRODUCER
|
#if (CO_CONFIG_EM) & CO_CONFIG_EM_PRODUCER
|
||||||
OD_GET(H1014, OD_H1014_COBID_EMERGENCY),
|
OD_GET(H1014, OD_H1014_COBID_EMERGENCY),
|
||||||
co->CANmodule,
|
|
||||||
CO_GET_CO(TX_IDX_EM_PROD),
|
CO_GET_CO(TX_IDX_EM_PROD),
|
||||||
#if (CO_CONFIG_EM) & CO_CONFIG_EM_PROD_INHIBIT
|
#if (CO_CONFIG_EM) & CO_CONFIG_EM_PROD_INHIBIT
|
||||||
OD_GET(H1015, OD_H1015_INHIBIT_TIME_EMCY),
|
OD_GET(H1015, OD_H1015_INHIBIT_TIME_EMCY),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue