1
0
Fork 0

Format comments in the .c files.

This commit is contained in:
Janez 2024-07-06 21:48:21 +02:00
parent 95c1705e76
commit 82c95a2bc9
19 changed files with 183 additions and 282 deletions

View file

@ -88,8 +88,7 @@ OD_write_1014(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_t*
return ODR_INVALID_VALUE;
}
/* store values. If default CAN-ID is used, then store only value of
* CO_CAN_ID_EMERGENCY without node id. */
/* store values. If default CAN-ID is used, then store only value of CO_CAN_ID_EMERGENCY without node id. */
em->producerEnabled = newEnabled;
em->producerCanId = (newCanId == ((uint16_t)CO_CAN_ID_EMERGENCY + em->nodeId)) ? CO_CAN_ID_EMERGENCY : newCanId;
@ -273,9 +272,8 @@ OD_write_statusBits(OD_stream_t* stream, const void* buf, OD_size_t count, OD_si
/*
* Read received message from CAN module.
*
* Function will be called (by CAN receive interrupt) every time, when CAN
* message with correct identifier will be received. For more information and
* description of parameters see file CO_driver.h.
* Function will be called (by CAN receive interrupt) every time, when CAN message with correct identifier
* will be received. For more information and description of parameters see file CO_driver.h.
*/
static void
CO_EM_receive(void* object, void* msg) {
@ -392,9 +390,8 @@ CO_EM_init(CO_EM_t* em, CO_CANmodule_t* CANdevTx, const OD_entry_t* OD_1001_errR
/* following two variables are used inside OD_read_1014 and OD_write_1014 */
em->producerCanId = producerCanId;
em->CANdevTxIdx = CANdevTxIdx;
/* if default producerCanId is used, then value of CO_CAN_ID_EMERGENCY
* (0x80) is stored into non-volatile memory. In that case it is necessary
* to add nodeId of this node to the stored value. */
/* if default producerCanId is used, then value of CO_CAN_ID_EMERGENCY (0x80) is stored into non-volatile
* memory. In that case it is necessary to add nodeId of this node to the stored value. */
if (producerCanId == CO_CAN_ID_EMERGENCY) {
producerCanId += nodeId;
}
@ -597,8 +594,7 @@ CO_EM_process(CO_EM_t* em, bool_t NMTisPreOrOperational, uint32_t timeDifference
fifoPpPtr++;
em->fifoPpPtr = (fifoPpPtr < em->fifoSize) ? fifoPpPtr : 0U;
/* verify message buffer overflow. Clear error condition if all
* messages from fifo buffer are processed */
/* verify message buffer overflow. Clear error condition if all messages from fifo buffer are processed */
if (em->fifoOverflow == 1U) {
em->fifoOverflow = 2;
CO_errorReport(em, CO_EM_EMERGENCY_BUFFER_FULL, CO_EMC_GENERIC, 0);
@ -673,7 +669,7 @@ CO_error(CO_EM_t* em, bool_t setError, const uint8_t errorBit, uint16_t errorCod
}
#if ((CO_CONFIG_EM) & (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY)) != 0
/* prepare emergency message. Error register will be added in post-process*/
/* prepare emergency message. Error register will be added in post-process */
uint32_t errMsg = ((uint32_t)errorBit << 24) | CO_SWAP_16(errorCode);
#if ((CO_CONFIG_EM)&CO_CONFIG_EM_PRODUCER) != 0
uint32_t infoCodeSwapped = CO_SWAP_32(infoCode);
@ -715,8 +711,7 @@ CO_error(CO_EM_t* em, bool_t setError, const uint8_t errorBit, uint16_t errorCod
#if ((CO_CONFIG_EM)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0
#if ((CO_CONFIG_EM)&CO_CONFIG_EM_PRODUCER) != 0
/* Optional signal to RTOS, which can resume task, which handles
* CO_EM_process */
/* Optional signal to RTOS, which can resume task, which handles CO_EM_process */
if ((em->pFunctSignalPre != NULL) && em->producerEnabled) {
em->pFunctSignalPre(em->functSignalObjectPre);
}

View file

@ -22,7 +22,7 @@
#if ((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_ENABLE) != 0
/* Verify HB consumer configuration *******************************************/
/* Verify HB consumer configuration */
#if (((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_CALLBACK_CHANGE) != 0) \
&& (((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_CALLBACK_MULTI) != 0)
#error CO_CONFIG_HB_CONS_CALLBACK_CHANGE and CO_CONFIG_HB_CONS_CALLBACK_MULTI cannot be set simultaneously!
@ -31,9 +31,8 @@
/*
* Read received message from CAN module.
*
* Function will be called (by CAN receive interrupt) every time, when CAN
* message with correct identifier will be received. For more information and
* description of parameters see file CO_driver.h.
* Function will be called (by CAN receive interrupt) every time, when CAN message with correct identifier
* will be received. For more information and description of parameters see file CO_driver.h.
*/
static void
CO_HBcons_receive(void* object, void* msg) {
@ -57,8 +56,7 @@ CO_HBcons_receive(void* object, void* msg) {
/*
* Initialize one Heartbeat consumer entry
*
* This function is called from the @ref CO_HBconsumer_init() or when writing
* to OD entry 1016.
* This function is called from the @ref CO_HBconsumer_init() or when writing to OD entry 1016.
*
* @param HBcons This object.
* @param idx index of the node in HBcons object
@ -317,7 +315,7 @@ CO_HBconsumer_process(CO_HBconsumer_t* HBcons, bool_t NMTisPreOrOperational, uin
/* Verify if received message is heartbeat or bootup */
if (CO_FLAG_READ(monitoredNode->CANrxNew)) {
if (monitoredNode->NMTstate == CO_NMT_INITIALIZING) {
/* bootup message*/
/* bootup message */
#if ((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_CALLBACK_MULTI) != 0
if (monitoredNode->pFunctSignalRemoteReset != NULL) {
monitoredNode->pFunctSignalRemoteReset(monitoredNode->nodeId, i,

View file

@ -23,9 +23,8 @@
/*
* Read received message from CAN module.
*
* Function will be called (by CAN receive interrupt) every time, when CAN
* message with correct identifier will be received. For more information and
* description of parameters see file CO_driver.h.
* Function will be called (by CAN receive interrupt) every time, when CAN message with correct identifier
* will be received. For more information and description of parameters see file CO_driver.h.
*/
static void
CO_NMT_receive(void* object, void* msg) {
@ -184,7 +183,7 @@ CO_NMT_process(CO_NMT_t* NMT, CO_NMT_internalState_t* NMTstate, uint32_t timeDif
/* Send heartbeat producer message if:
* - First start, send bootup message or
* - HB producer enabled and: Timer expired or NMT->operatingState changed*/
* - HB producer enabled and: Timer expired or NMT->operatingState changed */
if (NNTinit
|| ((NMT->HBproducerTime_us != 0U)
&& ((NMT->HBproducerTimer == 0U) || (NMTstateCpy != NMT->operatingStatePrev)))) {
@ -197,17 +196,15 @@ CO_NMT_process(CO_NMT_t* NMT, CO_NMT_internalState_t* NMTstate, uint32_t timeDif
? CO_NMT_OPERATIONAL
: CO_NMT_PRE_OPERATIONAL;
} else {
/* Start timer from the beginning. If OS is slow, time sliding may
* occur. However, heartbeat is not for synchronization, it is for
* health report. In case of initializing, timer is set in the
* CO_NMT_init() function with pre-defined value. */
/* Start timer from the beginning. If OS is slow, time sliding may occur. However,
* heartbeat is not for synchronization, it is for health report. In case of
* initializing, timer is set in the CO_NMT_init() function with pre-defined value. */
NMT->HBproducerTimer = NMT->HBproducerTime_us;
}
}
NMT->operatingStatePrev = NMTstateCpy;
/* process internal NMT commands, received from CO_NMT_receive() or
* CO_NMT_sendCommand() */
/* process internal NMT commands, received from CO_NMT_receive() or CO_NMT_sendCommand() */
if (NMT->internalCommand != CO_NMT_NO_COMMAND) {
switch (NMT->internalCommand) {
case CO_NMT_ENTER_OPERATIONAL: NMTstateCpy = CO_NMT_OPERATIONAL; break;

View file

@ -25,9 +25,8 @@
/*
* Read received message from CAN module.
*
* Function will be called (by CAN receive interrupt) every time, when CAN
* message with correct identifier will be received. For more information and
* description of parameters see file CO_driver.h.
* Function will be called (by CAN receive interrupt) every time, when CAN message with correct identifier
* will be received. For more information and description of parameters see file CO_driver.h.
*/
static void
CO_ngs_receive(void* object, void* msg) {
@ -235,9 +234,8 @@ CO_nodeGuardingSlave_process(CO_nodeGuardingSlave_t* ngs, CO_NMT_internalState_t
/*
* Read received message from CAN module.
*
* Function will be called (by CAN receive interrupt) every time, when CAN
* message with correct identifier will be received. For more information and
* description of parameters see file CO_driver.h.
* Function will be called (by CAN receive interrupt) every time, when CAN message with correct identifier
* will be received. For more information and description of parameters see file CO_driver.h.
*
* Function receives messages from CAN identifier from 0x700 to 0x7FF. It
* searches matching node->ident from nodes array.
@ -283,8 +281,7 @@ CO_nodeGuardingMaster_init(CO_nodeGuardingMaster_t* ngm, CO_EM_t* em, CO_CANmodu
/* Configure object variables */
ngm->em = em;
/* configure CAN reception. One buffer will receive all messages
* from CAN-id 0x700 to 0x7FF. */
/* configure CAN reception. One buffer will receive all messages from CAN-id 0x700 to 0x7FF. */
ret = CO_CANrxBufferInit(CANdevRx, CANdevRxIdx, CO_CAN_ID_HEARTBEAT, 0x780, false, (void*)ngm, CO_ngm_receive);
if (ret != CO_ERROR_NO) {
return ret;

View file

@ -78,9 +78,8 @@ OD_writeOriginal(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_
ODR_t returnCode = ODR_OK;
/* If previous write was partial or OD variable length is larger than
* current buffer size, then data was (will be) written in several
* segments */
/* If previous write was partial or OD variable length is larger than current buffer size,
* then data was (will be) written in several segments */
if ((stream->dataOffset > 0U) || (dataLenToCopy > count)) {
if (stream->dataOffset >= dataLenToCopy) {
return ODR_DEV_INCOMPAT;
@ -117,7 +116,7 @@ OD_writeOriginal(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_
return returnCode;
}
/* Read value from variable from Object Dictionary disabled, see OD_IO_t*/
/* Read value from variable from Object Dictionary disabled, see OD_IO_t */
static ODR_t
OD_readDisabled(OD_stream_t* stream, void* buf, OD_size_t count, OD_size_t* countRead) {
(void)stream;
@ -146,9 +145,8 @@ OD_find(OD_t* od, uint16_t index) {
uint16_t min = 0;
uint16_t max = od->size - 1U;
/* Fast search in ordered Object Dictionary. If indexes are mixed,
* this won't work. If Object Dictionary has up to N entries, then the
* max number of loop passes is log2(N) */
/* Fast search in ordered Object Dictionary. If indexes are mixed, this won't work. If Object
* Dictionary has up to N entries, then the max number of loop passes is log2(N) */
while (min < max) {
/* get entry between min and max */
uint16_t cur = (min + max) >> 1;

View file

@ -70,8 +70,7 @@ OD_read_dummy(OD_stream_t* stream, void* buf, OD_size_t count, OD_size_t* countR
/*
* Find mapped variable in Object Dictionary and configure entry in RPDO or TPDO
*
* @param PDO This object will be configured. If map is erroneous, then it will
* stay unchanged.
* @param PDO This object will be configured. If map is erroneous, then it will stay unchanged.
* @param map PDO mapping parameter.
* @param mapIndex from 0 to CO_PDO_MAX_MAPPED_ENTRIES
* @param isRPDO True for RPDO and false for TPDO.
@ -412,7 +411,7 @@ OD_read_PDO_commParam(OD_stream_t* stream, void* buf, OD_size_t count, OD_size_t
/*
* @defgroup CO_PDO_receiveErrors_t States for RPDO->receiveError indicates received RPDOs with wrong length.
* @{
*
*
*/
#define CO_RPDO_RX_ACK_NO_ERROR 0U /* No error */
#define CO_RPDO_RX_ACK_ERROR 1U /* Error is acknowledged */
@ -421,14 +420,13 @@ OD_read_PDO_commParam(OD_stream_t* stream, void* buf, OD_size_t count, OD_size_t
#define CO_RPDO_RX_SHORT 12U /* Too short RPDO received, not acknowledged */
#define CO_RPDO_RX_LONG 13U /* Too long RPDO received, not acknowledged */
/** @} */ /* CO_PDO_receiveErrors_t */
/* @} */ /* CO_PDO_receiveErrors_t */
/*
* Read received message from CAN module.
*
* Function will be called (by CAN receive interrupt) every time, when CAN
* message with correct identifier will be received. For more information and
* description of parameters see file CO_driver.h.
* Function will be called (by CAN receive interrupt) every time, when CAN message with correct identifier
* will be received. For more information and description of parameters see file CO_driver.h.
* If new message arrives and previous message wasn't processed yet, then
* previous message will be lost and overwritten by the new message.
*/
@ -466,8 +464,7 @@ CO_PDO_receive(void* object, void* msg) {
CO_FLAG_SET(RPDO->CANrxNew[bufNo]);
#if ((CO_CONFIG_PDO)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0
/* Optional signal to RTOS, which can resume task, which handles
* the RPDO. */
/* Optional signal to RTOS, which can resume task, which handles the RPDO. */
if (RPDO->pFunctSignalPre != NULL) {
RPDO->pFunctSignalPre(RPDO->functSignalObjectPre);
}
@ -505,9 +502,8 @@ OD_write_14xx(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_t*
uint16_t CAN_ID = (uint16_t)(COB_ID & 0x7FFU);
bool_t valid = (COB_ID & 0x80000000U) == 0U;
/* bits 11...29 must be zero, PDO must be disabled on change,
* CAN_ID == 0 is not allowed, mapping must be configured before
* enabling the PDO */
/* bits 11...29 must be zero, PDO must be disabled on change, CAN_ID == 0 is
* not allowed, mapping must be configured before enabling the PDO */
if (((COB_ID & 0x3FFFF800U) != 0U) || (valid && PDO->valid && (CAN_ID != PDO->configuredCanId))
|| (valid && CO_IS_RESTRICTED_CAN_ID(CAN_ID)) || (valid && (PDO->mappedObjectsCount == 0U))) {
return ODR_INVALID_VALUE;
@ -835,7 +831,7 @@ CO_RPDO_process(CO_RPDO_t* RPDO,
#endif /* (CO_CONFIG_PDO) & CO_CONFIG_RPDO_TIMERS_ENABLE */
} /* if (PDO->valid && NMTisOperational) */
else {
/* not valid and operational, clear CAN receive flags and timeoutTimer*/
/* not valid and operational, clear CAN receive flags and timeoutTimer */
#if ((CO_CONFIG_PDO)&CO_CONFIG_PDO_SYNC_ENABLE) != 0
if (!PDO->valid || !NMTisOperational) {
CO_FLAG_CLEAR(RPDO->CANrxNew[0]);
@ -882,9 +878,8 @@ OD_write_18xx(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_t*
uint16_t CAN_ID = (uint16_t)(COB_ID & 0x7FFU);
bool_t valid = (COB_ID & 0x80000000U) == 0U;
/* bits 11...29 must be zero, PDO must be disabled on change,
* CAN_ID == 0 is not allowed, mapping must be configured before
* enabling the PDO */
/* bits 11...29 must be zero, PDO must be disabled on change, CAN_ID == 0 is
* not allowed, mapping must be configured before enabling the PDO */
if (((COB_ID & 0x3FFFF800U) != 0U) || (valid && (PDO->valid && (CAN_ID != PDO->configuredCanId)))
|| (valid && CO_IS_RESTRICTED_CAN_ID(CAN_ID)) || (valid && (PDO->mappedObjectsCount == 0U))) {
return ODR_INVALID_VALUE;
@ -1147,8 +1142,7 @@ CO_TPDOsend(CO_TPDO_t* TPDO) {
dataTPDOCopy = dataTPDO;
}
/* Set stream.dataOffset to zero, perform OD_IO.read()
* and store mappedLength back to stream.dataOffset */
/* Set stream.dataOffset to zero, perform OD_IO.read() and store mappedLength back to stream.dataOffset */
stream->dataOffset = 0;
OD_size_t countRd;
OD_IO->read(stream, dataTPDOCopy, ODdataLength, &countRd);
@ -1252,7 +1246,7 @@ CO_TPDO_process(CO_TPDO_t* TPDO,
}
#endif
}
#endif /*((CO_CONFIG_PDO)&CO_CONFIG_TPDO_TIMERS_ENABLE)||(OD_FLAGS_PDO_SIZE>0)*/
#endif /* ((CO_CONFIG_PDO)&CO_CONFIG_TPDO_TIMERS_ENABLE)||(OD_FLAGS_PDO_SIZE>0) */
/* Send PDO by application request or by Event timer */
if (TPDO->transmissionType >= (uint8_t)CO_PDO_TRANSM_TYPE_SYNC_EVENT_LO) {
@ -1299,8 +1293,7 @@ CO_TPDO_process(CO_TPDO_t* TPDO,
TPDO->syncCounter = (TPDO->transmissionType / 2U) + 1U;
}
}
/* If the syncStartValue is in use, start first TPDO after SYNC
* with matched syncStartValue. */
/* If the syncStartValue is in use, start first TPDO after SYNC with matched syncStartValue. */
if (TPDO->syncCounter == 254U) {
if (TPDO->SYNC->counter == TPDO->syncStartValue) {
TPDO->syncCounter = TPDO->transmissionType;

View file

@ -50,9 +50,8 @@
/*
* Read received message from CAN module.
*
* Function will be called (by CAN receive interrupt) every time, when CAN
* message with correct identifier will be received. For more information and
* description of parameters see file CO_driver.h.
* Function will be called (by CAN receive interrupt) every time, when CAN message with correct identifier
* will be received. For more information and description of parameters see file CO_driver.h.
*/
static void
CO_SDOclient_receive(void* object, void* msg) {
@ -94,8 +93,7 @@ CO_SDOclient_receive(void* object, void* msg) {
/* is this the last segment? */
if ((data[0] & 0x80U) != 0U) {
/* copy data to temporary buffer, because we don't know the
* number of bytes not containing data */
/* copy data to temporary buffer, because we don't know the number of bytes not containing data */
(void)memcpy((void*)&SDO_C->block_dataUploadLast[0], (const void*)&data[1], 7);
SDO_C->finished = true;
state = CO_SDO_ST_UPLOAD_BLK_SUBBLOCK_CRSP;
@ -110,9 +108,8 @@ CO_SDOclient_receive(void* object, void* msg) {
}
}
}
/* If message is duplicate or sequence didn't start yet, ignore
* it. Otherwise seqno is wrong, so break sub-block. Data after
* last good seqno will be re-transmitted. */
/* If message is duplicate or sequence didn't start yet, ignore it. Otherwise seqno is wrong,
* so break sub-block. Data after last good seqno will be re-transmitted. */
else if ((seqno != SDO_C->block_seqno) && (SDO_C->block_seqno != 0U)) {
state = CO_SDO_ST_UPLOAD_BLK_SUBBLOCK_CRSP;
#ifdef CO_DEBUG_SDO_CLIENT
@ -136,8 +133,7 @@ CO_SDOclient_receive(void* object, void* msg) {
CO_FLAG_CLEAR(SDO_C->CANrxNew);
SDO_C->state = state;
#if ((CO_CONFIG_SDO_CLI)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0
/* Optional signal to RTOS, which can resume task, which handles
* SDO client processing. */
/* Optional signal to RTOS, which can resume task, which handles SDO client processing. */
if (SDO_C->pFunctSignal != NULL) {
SDO_C->pFunctSignal(SDO_C->functSignalObject);
}
@ -383,8 +379,7 @@ CO_SDOclientDownloadInitiate(CO_SDOclient_t* SDO_C, uint16_t index, uint8_t subI
CO_fifo_reset(&SDO_C->bufFifo);
#if ((CO_CONFIG_SDO_CLI)&CO_CONFIG_SDO_CLI_LOCAL) != 0
/* if node-ID of the SDO server is the same as node-ID of this node, then
* transfer data within this node */
/* if node-ID of the SDO server is the same as node-ID of this node, then transfer data within this node */
if ((SDO_C->OD != NULL) && (SDO_C->nodeId != 0U) && (SDO_C->nodeIDOfTheSDOServer == SDO_C->nodeId)) {
SDO_C->OD_IO.write = NULL;
SDO_C->state = CO_SDO_ST_DOWNLOAD_LOCAL_TRANSFER;
@ -442,7 +437,7 @@ CO_SDOclientDownload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t s
ret = CO_SDO_RT_ok_communicationEnd;
}
#if ((CO_CONFIG_SDO_CLI)&CO_CONFIG_SDO_CLI_LOCAL) != 0
/* Transfer data locally **************************************************/
/* Transfer data locally */
else if ((SDO_C->state == CO_SDO_ST_DOWNLOAD_LOCAL_TRANSFER) && !send_abort) {
/* search object dictionary in first pass */
if (SDO_C->OD_IO.write == NULL) {
@ -499,10 +494,9 @@ CO_SDOclientDownload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t s
#endif
OD_size_t sizeInOd = SDO_C->OD_IO.stream.dataLength;
/* If dataType is string, then size of data downloaded may be
* shorter than size of OD data buffer. If so, add two zero
* bytes to terminate (unicode) string. Shorten also OD data
* size, (temporary, send info about EOF into OD_IO.write) */
/* If dataType is string, then size of data downloaded may be shorter than size of
* OD data buffer. If so, add two zero bytes to terminate (unicode) string. Shorten
* also OD data size, (temporary, send info about EOF into OD_IO.write) */
if (((SDO_C->OD_IO.stream.attribute & (OD_attr_t)ODA_STR) != 0U)
&& ((sizeInOd == 0U) || (SDO_C->sizeTran < sizeInOd))) {
buf[count] = 0;
@ -541,16 +535,14 @@ CO_SDOclientDownload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t s
abortCode = (CO_SDO_abortCode_t)OD_getSDOabCode(odRet);
ret = CO_SDO_RT_endedWithServerAbort;
}
/* error if OD variable was written completely,
* but SDO download still has data */
/* error if OD variable was written completely, but SDO download still has data */
else if (bufferPartial && (odRet == ODR_OK)) {
abortCode = CO_SDO_AB_DATA_LONG;
ret = CO_SDO_RT_endedWithClientAbort;
}
/* is end of transfer? */
else if (!bufferPartial) {
/* error if OD variable was not written completely, but SDO
* download finished */
/* error if OD variable was not written completely, but SDO download finished */
if (odRet == ODR_PARTIAL) {
abortCode = CO_SDO_AB_DATA_SHORT;
ret = CO_SDO_RT_endedWithClientAbort;
@ -577,7 +569,7 @@ CO_SDOclientDownload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t s
#endif
}
#endif /* CO_CONFIG_SDO_CLI_LOCAL */
/* CAN data received ******************************************************/
/* CAN data received */
else if (CO_FLAG_READ(SDO_C->CANrxNew)) {
/* is SDO abort */
if (SDO_C->CANrxData[0] == 0x80U) {
@ -689,8 +681,7 @@ CO_SDOclientDownload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t s
if (SDO_C->CANrxData[0] == 0xA2U) {
/* check number of segments */
if (SDO_C->CANrxData[1] < SDO_C->block_seqno) {
/* NOT all segments transferred successfully.
* Re-transmit data after erroneous segment. */
/* NOT all segments transferred successfully. Re-transmit data after erroneous segment. */
size_t cntFailed = (size_t)(SDO_C->block_seqno) - (size_t)(SDO_C->CANrxData[1]);
cntFailed = (cntFailed * 7U) - SDO_C->block_noData;
SDO_C->sizeTran -= cntFailed;
@ -778,7 +769,7 @@ CO_SDOclientDownload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t s
} else { /* MISRA C 2004 14.10 */
}
/* Timeout timers and transmit bufferFull flag ****************************/
/* Timeout timers and transmit bufferFull flag */
if (ret == CO_SDO_RT_waitingResponse) {
if (SDO_C->timeoutTimer < SDO_C->SDOtimeoutTime_us) {
SDO_C->timeoutTimer += timeDifference_us;
@ -802,7 +793,7 @@ CO_SDOclientDownload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t s
}
}
/* Transmit CAN data ******************************************************/
/* Transmit CAN data */
if (ret == CO_SDO_RT_waitingResponse) {
size_t count;
(void)memset((void*)&SDO_C->CANtxBuff->data[0], 0, 8);
@ -1070,8 +1061,7 @@ CO_SDOclientUploadInitiate(CO_SDOclient_t* SDO_C, uint16_t index, uint8_t subInd
#endif
#if ((CO_CONFIG_SDO_CLI)&CO_CONFIG_SDO_CLI_LOCAL) != 0
/* if node-ID of the SDO server is the same as node-ID of this node, then
* transfer data within this node */
/* if node-ID of the SDO server is the same as node-ID of this node, then transfer data within this node */
if (((SDO_C->OD != NULL) && (SDO_C->nodeId != 0U)) && (SDO_C->nodeIDOfTheSDOServer == SDO_C->nodeId)) {
SDO_C->OD_IO.read = NULL;
SDO_C->state = CO_SDO_ST_UPLOAD_LOCAL_TRANSFER;
@ -1107,7 +1097,7 @@ CO_SDOclientUpload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t sen
ret = CO_SDO_RT_ok_communicationEnd;
}
#if ((CO_CONFIG_SDO_CLI)&CO_CONFIG_SDO_CLI_LOCAL) != 0
/* Transfer data locally **************************************************/
/* Transfer data locally */
else if ((SDO_C->state == CO_SDO_ST_UPLOAD_LOCAL_TRANSFER) && !send_abort) {
/* search object dictionary in first pass */
if (SDO_C->OD_IO.read == NULL) {
@ -1208,7 +1198,7 @@ CO_SDOclientUpload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t sen
#endif
}
#endif /* CO_CONFIG_SDO_CLI_LOCAL */
/* CAN data received ******************************************************/
/* CAN data received */
else if (CO_FLAG_READ(SDO_C->CANrxNew)) {
/* is SDO abort */
if (SDO_C->CANrxData[0] == 0x80U) {
@ -1481,7 +1471,7 @@ CO_SDOclientUpload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t sen
} else { /* MISRA C 2004 14.10 */
}
/* Timeout timers and transmit bufferFull flag ****************************/
/* Timeout timers and transmit bufferFull flag */
if (ret == CO_SDO_RT_waitingResponse) {
if (SDO_C->timeoutTimer < SDO_C->SDOtimeoutTime_us) {
SDO_C->timeoutTimer += timeDifference_us;
@ -1516,7 +1506,7 @@ CO_SDOclientUpload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t sen
}
if (SDO_C->block_timeoutTimer >= SDO_C->block_SDOtimeoutTime_us) {
/* SDO_C->state will change, processing will continue in this
* thread. Make memory barrier here with CO_FLAG_CLEAR() call.*/
* thread. Make memory barrier here with CO_FLAG_CLEAR() call. */
SDO_C->state = CO_SDO_ST_UPLOAD_BLK_SUBBLOCK_CRSP;
CO_FLAG_CLEAR(SDO_C->CANrxNew);
}
@ -1538,7 +1528,7 @@ CO_SDOclientUpload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t sen
}
}
/* Transmit CAN data ******************************************************/
/* Transmit CAN data */
if (ret == CO_SDO_RT_waitingResponse) {
#if ((CO_CONFIG_SDO_CLI)&CO_CONFIG_SDO_CLI_BLOCK) != 0
size_t count;
@ -1613,7 +1603,7 @@ CO_SDOclientUpload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t sen
SDO_C->block_seqno = 0;
SDO_C->block_crc = 0;
/* Block segments will be received in different thread. Make memory
* barrier here with CO_FLAG_CLEAR() call. */
* barrier here with CO_FLAG_CLEAR() call. */
SDO_C->state = CO_SDO_ST_UPLOAD_BLK_SUBBLOCK_SREQ;
CO_FLAG_CLEAR(SDO_C->CANrxNew);
(void)CO_CANsend(SDO_C->CANdevTx, SDO_C->CANtxBuff);
@ -1666,7 +1656,7 @@ CO_SDOclientUpload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t sen
SDO_C->block_blksize = (uint8_t)count;
SDO_C->block_seqno = 0;
/* Block segments will be received in different thread. Make
* memory barrier here with CO_FLAG_CLEAR() call. */
* memory barrier here with CO_FLAG_CLEAR() call. */
SDO_C->state = CO_SDO_ST_UPLOAD_BLK_SUBBLOCK_SREQ;
CO_FLAG_CLEAR(SDO_C->CANrxNew);
}

View file

@ -44,9 +44,8 @@
/*
* Read received message from CAN module.
*
* Function will be called (by CAN receive interrupt) every time, when CAN
* message with correct identifier will be received. For more information and
* description of parameters see file CO_driver.h.
* Function will be called (by CAN receive interrupt) every time, when CAN message with correct identifier
* will be received. For more information and description of parameters see file CO_driver.h.
*/
static void
CO_SDO_receive(void* object, void* msg) {
@ -94,9 +93,8 @@ CO_SDO_receive(void* object, void* msg) {
state = CO_SDO_ST_DOWNLOAD_BLK_SUBBLOCK_RSP;
}
}
/* If message is duplicate or sequence didn't start yet, ignore
* it. Otherwise seqno is wrong, so break sub-block. Data after
* last good seqno will be re-transmitted. */
/* If message is duplicate or sequence didn't start yet, ignore it. Otherwise seqno is wrong,
* so break sub-block. Data after last good seqno will be re-transmitted. */
else if (seqno != SDO->block_seqno && SDO->block_seqno != 0U) {
state = CO_SDO_ST_DOWNLOAD_BLK_SUBBLOCK_RSP;
#ifdef CO_DEBUG_SDO_SERVER
@ -114,14 +112,12 @@ CO_SDO_receive(void* object, void* msg) {
#endif
if (state != CO_SDO_ST_DOWNLOAD_BLK_SUBBLOCK_REQ) {
/* SDO->state has changed, processing will continue in
* another thread. Make memory barrier here with
* CO_FLAG_CLEAR() call. */
/* SDO->state has changed, processing will continue in another thread.
* Make memory barrier here with CO_FLAG_CLEAR() call. */
CO_FLAG_CLEAR(SDO->CANrxNew);
SDO->state = state;
#if ((CO_CONFIG_SDO_SRV)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0
/* Optional signal to RTOS, which can resume task, which
* handles SDO server processing. */
/* Optional signal to RTOS, which can resume task, which handles SDO server processing. */
if (SDO->pFunctSignalPre != NULL) {
SDO->pFunctSignalPre(SDO->functSignalObjectPre);
}
@ -133,13 +129,11 @@ CO_SDO_receive(void* object, void* msg) {
}
#endif /* (CO_CONFIG_SDO_SRV) & CO_CONFIG_SDO_SRV_BLOCK */
else {
/* copy data and set 'new message' flag, data will be processed in
* CO_SDOserver_process() */
/* copy data and set 'new message' flag, data will be processed in CO_SDOserver_process() */
(void)memcpy(SDO->CANrxData, data, DLC);
CO_FLAG_SET(SDO->CANrxNew);
#if ((CO_CONFIG_SDO_SRV)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0
/* Optional signal to RTOS, which can resume task, which handles
* SDO server processing. */
/* Optional signal to RTOS, which can resume task, which handles SDO server processing. */
if (SDO->pFunctSignalPre != NULL) {
SDO->pFunctSignalPre(SDO->functSignalObjectPre);
}
@ -148,7 +142,7 @@ CO_SDO_receive(void* object, void* msg) {
}
}
/* helper for configuring CANrx and CANtx *************************************/
/* helper for configuring CANrx and CANtx */
static CO_ReturnError_t
CO_SDOserver_init_canRxTx(CO_SDOserver_t* SDO, CO_CANmodule_t* CANdevRx, uint16_t CANdevRxIdx, uint16_t CANdevTxIdx,
uint32_t COB_IDClientToServer, uint32_t COB_IDServerToClient) {
@ -189,8 +183,7 @@ CO_SDOserver_init_canRxTx(CO_SDOserver_t* SDO, CO_CANmodule_t* CANdevRx, uint16_
#if ((CO_CONFIG_SDO_SRV)&CO_CONFIG_FLAG_OD_DYNAMIC) != 0
/*
* Custom function for writing OD object _SDO server parameter_, additional
* channels
* Custom function for writing OD object _SDO server parameter_, additional channels
*
* For more information see file CO_ODinterface.h, OD_IO_t.
*/
@ -392,17 +385,15 @@ reverseBytes(void* start, OD_size_t size) {
#endif
#if ((CO_CONFIG_SDO_SRV)&CO_CONFIG_SDO_SRV_SEGMENTED) != 0
/** Helper function for writing data to Object dictionary. Function swaps data
* if necessary, calcualtes (and verifies CRC) writes data to OD and verifies
* data lengths.
/* Helper function for writing data to Object dictionary. Function swaps data if necessary,
* calcualtes (and verifies CRC) writes data to OD and verifies data lengths.
*
* @param SDO SDO server
* @param [out] abortCode SDO abort code in case of error
* @param crcOperation 0=none, 1=calculate, 2=calculate and compare
* @parma crcClient crc checksum to campare with
*
* Returns true on success, otherwise write also abortCode and sets state to
* CO_SDO_ST_ABORT */
* Returns true on success, otherwise write also abortCode and sets state to CO_SDO_ST_ABORT */
static bool_t
validateAndWriteToOD(CO_SDOserver_t* SDO, CO_SDO_abortCode_t* abortCode, uint8_t crcOperation, uint16_t crcClient) {
OD_size_t bufOffsetWrOrig = SDO->bufOffsetWr;
@ -424,10 +415,9 @@ validateAndWriteToOD(CO_SDOserver_t* SDO, CO_SDO_abortCode_t* abortCode, uint8_t
OD_size_t sizeInOd = SDO->OD_IO.stream.dataLength;
/* If dataType is string, then size of data downloaded may be
* shorter than size of OD data buffer. If so, add two zero bytes
* to terminate (unicode) string. Shorten also OD data size,
* (temporary, send information about EOF into OD_IO.write) */
/* If dataType is string, then size of data downloaded may be shorter than size of the
* OD data buffer. If so, add two zero bytes to terminate (unicode) string. Shorten
* also OD data size, (temporary, send information about EOF into OD_IO.write) */
if (((SDO->OD_IO.stream.attribute & (OD_attr_t)ODA_STR) != 0U)
&& ((sizeInOd == 0U) || (SDO->sizeTran < sizeInOd))
&& ((SDO->bufOffsetWr + 2U) <= CO_CONFIG_SDO_SRV_BUFFER_SIZE)) {
@ -441,7 +431,7 @@ validateAndWriteToOD(CO_SDOserver_t* SDO, CO_SDO_abortCode_t* abortCode, uint8_t
}
SDO->OD_IO.stream.dataLength = SDO->sizeTran;
}
/* Indicate OD data size, if not indicated. Can be used for EOF check.*/
/* Indicate OD data size, if not indicated. Can be used for EOF check. */
else if (sizeInOd == 0U) {
SDO->OD_IO.stream.dataLength = SDO->sizeTran;
}
@ -497,7 +487,7 @@ validateAndWriteToOD(CO_SDOserver_t* SDO, CO_SDO_abortCode_t* abortCode, uint8_t
SDO->state = CO_SDO_ST_ABORT;
return false;
} else if (!SDO->finished && (odRet == ODR_OK)) {
/* OD variable was written completely, but SDO download still has data*/
/* OD variable was written completely, but SDO download still has data */
*abortCode = CO_SDO_AB_DATA_LONG;
SDO->state = CO_SDO_ST_ABORT;
return false;
@ -507,17 +497,14 @@ validateAndWriteToOD(CO_SDOserver_t* SDO, CO_SDO_abortCode_t* abortCode, uint8_t
return true;
}
/** Helper function for reading data from Object dictionary. Function also swaps
* data if necessary and calcualtes CRC.
/* Helper function for reading data from Object dictionary. Function also swaps data if necessary and calcualtes CRC.
*
* @param SDO SDO server
* @param [out] abortCode SDO abort code in case of error
* @parma countMinimum if data size in buffer is less than countMinimum, then
* buffer is refilled from OD variable
* @parma countMinimum if data size in buffer is less than countMinimum, then buffer is refilled from OD variable
* @param calculateCrc if true, crc is calculated
*
* Returns true on success, otherwise write also abortCode and sets state to
* CO_SDO_ST_ABORT */
* Returns true on success, otherwise write also abortCode and sets state to CO_SDO_ST_ABORT */
static bool_t
readFromOd(CO_SDOserver_t* SDO, CO_SDO_abortCode_t* abortCode, OD_size_t countMinimum, bool_t calculateCrc) {
#if ((CO_CONFIG_SDO_SRV)&CO_CONFIG_SDO_SRV_BLOCK) == 0
@ -618,8 +605,7 @@ CO_SDOserver_process(CO_SDOserver_t* SDO, bool_t NMTisPreOrOperational, uint32_t
/* Idle and nothing new */
ret = CO_SDO_RT_ok_communicationEnd;
} else if (!NMTisPreOrOperational || !SDO->valid) {
/* SDO is allowed only in operational or pre-operational NMT state
* and must be valid */
/* SDO is allowed only in operational or pre-operational NMT state and must be valid */
SDO->state = CO_SDO_ST_IDLE;
CO_FLAG_CLEAR(SDO->CANrxNew);
ret = CO_SDO_RT_ok_communicationEnd;
@ -735,10 +721,9 @@ CO_SDOserver_process(CO_SDOserver_t* SDO, bool_t NMTisPreOrOperational, uint32_t
}
#endif
/* If dataType is string, then size of data downloaded may be
* shorter as size of OD data buffer. If so, add two zero bytes
* to terminate (unicode) string. Shorten also OD data size,
* (temporary, send information about EOF into OD_IO.write) */
/* If dataType is string, then size of data downloaded may be shorter as size of
* the OD data buffer. If so, add two zero bytes to terminate (unicode) string.
* Shorten also OD data size, (temporary, send information about EOF into OD_IO.write) */
if (((SDO->OD_IO.stream.attribute & (OD_attr_t)ODA_STR) != 0U)
&& ((sizeInOd == 0U) || (dataSizeToWrite < sizeInOd))) {
OD_size_t delta = sizeInOd - dataSizeToWrite;
@ -918,8 +903,7 @@ CO_SDOserver_process(CO_SDOserver_t* SDO, bool_t NMTisPreOrOperational, uint32_t
case CO_SDO_ST_DOWNLOAD_BLK_END_REQ: {
if ((SDO->CANrxData[0] & 0xE3) == 0xC1) {
/* Get number of data bytes in last segment, that do not
* contain data. Then reduce buffer. */
/* Get number of data bytes in last segment, that do not contain data. Then reduce buffer. */
uint8_t noData = ((SDO->CANrxData[0] >> 2) & 0x07);
if (SDO->bufOffsetWr <= noData) {
/* just in case, should never happen */
@ -950,7 +934,7 @@ CO_SDOserver_process(CO_SDOserver_t* SDO, bool_t NMTisPreOrOperational, uint32_t
case CO_SDO_ST_UPLOAD_BLK_INITIATE_REQ: {
/* if pst (protocol switch threshold, byte5) is larger than data
* size of OD variable, then switch to segmented transfer */
* size of OD variable, then switch to segmented transfer */
if (SDO->sizeInd > 0 && SDO->CANrxData[5] > 0 && SDO->CANrxData[5] >= SDO->sizeInd) {
SDO->state = CO_SDO_ST_UPLOAD_INITIATE_RSP;
} else {
@ -1004,8 +988,7 @@ CO_SDOserver_process(CO_SDOserver_t* SDO, bool_t NMTisPreOrOperational, uint32_t
/* check number of segments */
if (SDO->CANrxData[1] < SDO->block_seqno) {
/* NOT all segments transferred successfully.
* Re-transmit data after erroneous segment. */
/* NOT all segments transferred successfully. Re-transmit data after erroneous segment. */
OD_size_t cntFailed = SDO->block_seqno - SDO->CANrxData[1];
cntFailed = cntFailed * 7 - SDO->block_noData;
SDO->bufOffsetRd -= cntFailed;
@ -1109,7 +1092,7 @@ CO_SDOserver_process(CO_SDOserver_t* SDO, bool_t NMTisPreOrOperational, uint32_t
}
if (SDO->block_timeoutTimer >= SDO->block_SDOtimeoutTime_us) {
/* SDO->state will change, processing will continue in this
* thread. Make memory barrier here with CO_FLAG_CLEAR() call.*/
* thread. Make memory barrier here with CO_FLAG_CLEAR() call. */
SDO->state = CO_SDO_ST_DOWNLOAD_BLK_SUBBLOCK_RSP;
CO_FLAG_CLEAR(SDO->CANrxNew);
}
@ -1323,7 +1306,7 @@ CO_SDOserver_process(CO_SDOserver_t* SDO, bool_t NMTisPreOrOperational, uint32_t
SDO->block_timeoutTimer = 0;
/* Block segments will be received in different thread. Make memory
* barrier here with CO_FLAG_CLEAR() call. */
* barrier here with CO_FLAG_CLEAR() call. */
SDO->state = CO_SDO_ST_DOWNLOAD_BLK_SUBBLOCK_REQ;
CO_FLAG_CLEAR(SDO->CANrxNew);
(void)CO_CANsend(SDO->CANdevTx, SDO->CANtxBuff);
@ -1362,7 +1345,7 @@ CO_SDOserver_process(CO_SDOserver_t* SDO, bool_t NMTisPreOrOperational, uint32_t
SDO->block_blksize = (uint8_t)count;
SDO->block_seqno = 0;
/* Block segments will be received in different thread. Make
* memory barrier here with CO_FLAG_CLEAR() call. */
* memory barrier here with CO_FLAG_CLEAR() call. */
SDO->state = CO_SDO_ST_DOWNLOAD_BLK_SUBBLOCK_REQ;
CO_FLAG_CLEAR(SDO->CANrxNew);
}

View file

@ -25,9 +25,8 @@
/*
* Read received message from CAN module.
*
* Function will be called (by CAN receive interrupt) every time, when CAN
* message with correct identifier will be received. For more information and
* description of parameters see file CO_driver.h.
* Function will be called (by CAN receive interrupt) every time, when CAN message with correct identifier
* will be received. For more information and description of parameters see file CO_driver.h.
*/
static void
CO_SYNC_receive(void* object, void* msg) {
@ -58,7 +57,7 @@ CO_SYNC_receive(void* object, void* msg) {
CO_FLAG_SET(SYNC->CANrxNew);
#if ((CO_CONFIG_SYNC)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0
/* Optional signal to RTOS, which can resume task, which handles SYNC.*/
/* Optional signal to RTOS, which can resume task, which handles SYNC. */
if (SYNC->pFunctSignalPre != NULL) {
SYNC->pFunctSignalPre(SYNC->functSignalObjectPre);
}
@ -237,8 +236,7 @@ CO_SYNC_init(CO_SYNC_t* SYNC, CO_EM_t* em, OD_entry_t* OD_1005_cobIdSync, OD_ent
return CO_ERROR_OD_PARAMETERS;
}
/* get and verify optional "Synchronous counter overflow value" from OD and
* configure extension */
/* get and verify optional "Synchronous counter overflow value" from OD and configure extension */
uint8_t syncCounterOvf = 0;
if (OD_1019_syncCounterOvf != NULL) {

View file

@ -27,9 +27,8 @@
/*
* Read received message from CAN module.
*
* Function will be called (by CAN receive interrupt) every time, when CAN
* message with correct identifier will be received. For more information and
* description of parameters see file CO_driver.h.
* Function will be called (by CAN receive interrupt) every time, when CAN message with correct identifier
* will be received. For more information and description of parameters see file CO_driver.h.
*/
static void
CO_TIME_receive(void* object, void* msg) {
@ -42,7 +41,7 @@ CO_TIME_receive(void* object, void* msg) {
CO_FLAG_SET(TIME->CANrxNew);
#if ((CO_CONFIG_TIME)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0
/* Optional signal to RTOS, which can resume task, which handles TIME.*/
/* Optional signal to RTOS, which can resume task, which handles TIME. */
if (TIME->pFunctSignalPre != NULL) {
TIME->pFunctSignalPre(TIME->functSignalObjectPre);
}

View file

@ -430,7 +430,7 @@ CO_fifo_readToken(CO_fifo_t* fifo, char* buf, size_t count, uint8_t* closed, boo
*closed = delimCommandFound ? 1U : 0U;
}
/* token was larger then size of the buffer, all was cleaned, return empty*/
/* token was larger then size of the buffer, all was cleaned, return empty */
if (tokenSize == count) {
tokenSize = 0;
}
@ -444,11 +444,10 @@ CO_fifo_readToken(CO_fifo_t* fifo, char* buf, size_t count, uint8_t* closed, boo
#endif /* (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_COMMANDS */
#if ((CO_CONFIG_FIFO)&CO_CONFIG_FIFO_ASCII_DATATYPES) != 0
/* Tables for mime-base64 encoding, as specified in RFC 2045, (without CR-LF,
* but one long string). Base64 is used for encoding binary data into easy
* transferable printable characters. In general, each three bytes of binary
* data are translated into four characters, where characters are selected from
* 64 characters long table. See https://en.wikipedia.org/wiki/Base64 */
/* Tables for mime-base64 encoding, as specified in RFC 2045, (without CR-LF, but one long string).
* Base64 is used for encoding binary data into easy transferable printable characters. In general,
* each three bytes of binary data are translated into four characters, where characters are
* selected from 64 characters long table. See https://en.wikipedia.org/wiki/Base64 */
static const char base64EncTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const uint8_t base64DecTable[] = {
@ -1257,8 +1256,7 @@ CO_fifo_cpyTok2Vs(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status) {
step = (uint8_t)dest->aux;
}
/* repeat until destination space available and no error and not finished
* and source characters available */
/* repeat until destination space available and no error and not finished and source characters available */
while ((destSpace > 0U) && ((st & CO_fifo_st_errMask) == 0U) && !finished) {
uint8_t c;
if (!CO_fifo_getc(src, &c)) {
@ -1283,7 +1281,7 @@ CO_fifo_cpyTok2Vs(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status) {
case 2: /* inside string, single word, no quotes */
if (c == DELIM_DQUOTE) {
/* double quote found, this may be end of the string or escaped
* double quote (with two double quotes) */
* double quote (with two double quotes) */
step += 2U;
} else if ((isgraph((int)c) == 0) && (step == 2U)) {
/* end of single word string */
@ -1410,8 +1408,7 @@ CO_fifo_cpyTok2B64(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status) {
dword = dest->aux & 0xFFFFFFU;
}
/* repeat until destination space available and no error and not finished
* and source characters available */
/* repeat until destination space available and no error and not finished and source characters available */
while ((destSpace >= 3U) && ((st & CO_fifo_st_errMask) == 0U) && !finished) {
uint8_t c;
if (!CO_fifo_getc(src, &c)) {

View file

@ -1,4 +1,4 @@
/**
/*
* CANopen Global fail-safe command protocol.
*
* @file CO_GFC.c

View file

@ -1,4 +1,4 @@
/**
/*
* CANopen Safety Related Data Object protocol.
*
* @file CO_SRDO.c
@ -138,7 +138,8 @@ OD_read_dummy(OD_stream_t* stream, void* buf, OD_size_t count, OD_size_t* countR
#ifdef CO_CONFORMANCE_TEST_TOOL_ADAPTATION
static bool_t
OD_not_write_same_value(OD_stream_t* stream, const void* buf, OD_size_t count) {
// The conformance test tool does not recognize CANopen Safety and on all object dictionaty tries to read and write the same value
/* The conformance test tool does not recognize CANopen Safety and on all object
* dictionaty tries to read and write the same value */
OD_size_t countRead = 0;
uint8_t bufRead[6] = {0};
if (count > 6U) {
@ -379,8 +380,7 @@ CO_SRDOGuard_init(CO_SRDOGuard_t* SRDOGuard, OD_entry_t* OD_13FE_configurationVa
SRDOGuard->OD_13FF_extension.write = OD_write_13FF;
(void)OD_extension_init(OD_13FF_safetyConfigurationSignature, &SRDOGuard->OD_13FF_extension);
/* Configure SRDOGuard->OD_IO_configurationValid variable.
* It will be used for writing 0 to OD variable 13FE,00 */
/* Configure SRDOGuard->OD_IO_configurationValid variable. It will be used for writing 0 to OD variable 13FE,00 */
odRet = OD_getSub(OD_13FE_configurationValid, 0, &SRDOGuard->OD_IO_configurationValid, false);
if ((odRet != ODR_OK) || (SRDOGuard->OD_IO_configurationValid.stream.dataLength != 1U)) {
if (errInfo != NULL) {
@ -734,7 +734,7 @@ CO_SRDO_process(CO_SRDO_t* SRDO, uint32_t timeDifference_us, uint32_t* timerNext
/* Detect transition to NMT operational */
if (!SRDO->NMTisOperationalPrevious) {
SRDO->cycleTimer = (SRDO->informationDirection == CO_SRDO_TX)
? ((uint32_t)SRDO->nodeId * 500U) /* 0.5ms * node-ID delay*/
? ((uint32_t)SRDO->nodeId * 500U) /* 0.5ms * node-ID delay */
: SRDO->cycleTime_us;
SRDO->validationTimer = SRDO->cycleTime_us;
SRDO->internalState = CO_SRDO_state_initializing;

View file

@ -28,19 +28,17 @@
/*
* @defgroup CO_LSSmaster_state_t
* @{
* LSS master slave select state machine. Compared to #CO_LSS_state_t this
* has information if we currently have selected one or all slaves. This
* allows for some basic error checking.
* LSS master slave select state machine. Compared to #CO_LSS_state_t this has information if we
* currently have selected one or all slaves. This allows for some basic error checking.
*/
#define CO_LSSmaster_STATE_WAITING 0x00U
#define CO_LSSmaster_STATE_CFG_SLECTIVE 0x01U
#define CO_LSSmaster_STATE_CFG_GLOBAL 0x02U
/** @} */ /* CO_LSSmaster_state_t */
/* @} */ /* CO_LSSmaster_state_t */
/*
* @defgroup CO_LSSmaster_command_t LSS master slave command state machine
* @{
*
*/
#define CO_LSSmaster_COMMAND_WAITING 0x00U
#define CO_LSSmaster_COMMAND_SWITCH_STATE 0x01U
@ -53,7 +51,7 @@
#define CO_LSSmaster_COMMAND_INQUIRE_SERIAL 0x08U
#define CO_LSSmaster_COMMAND_INQUIRE 0x09U
#define CO_LSSmaster_COMMAND_IDENTIFY_FASTSCAN 0x0AU
/** @} */ /* CO_LSSmaster_command_t */
/* @} */ /* CO_LSSmaster_command_t */
/*
* @defgroup CO_LSSmaster_fs_t LSS master fastscan state machine
@ -63,14 +61,13 @@
#define CO_LSSmaster_FS_STATE_SCAN 0x01U
#define CO_LSSmaster_FS_STATE_VERIFY 0x02U
/** @} */ /* CO_LSSmaster_fs_t */
/* @} */ /* CO_LSSmaster_fs_t */
/*
* Read received message from CAN module.
*
* Function will be called (by CAN receive interrupt) every time, when CAN
* message with correct identifier will be received. For more information and
* description of parameters see file CO_driver.h.
* Function will be called (by CAN receive interrupt) every time, when CAN message with correct identifier
* will be received. For more information and description of parameters see file CO_driver.h.
*/
static void
CO_LSSmaster_receive(void* object, void* msg) {
@ -80,7 +77,7 @@ CO_LSSmaster_receive(void* object, void* msg) {
LSSmaster = (CO_LSSmaster_t*)object; /* this is the correct pointer type of the first argument */
/* verify message length and message overflow (previous message was not processed yet) */
/* verify message length and message overflow (previous message was not processed yet). */
if ((DLC == 8U) && !CO_FLAG_READ(LSSmaster->CANrxNew) && (LSSmaster->command != CO_LSSmaster_COMMAND_WAITING)) {
/* copy data and set 'new message' flag */
@ -100,9 +97,8 @@ CO_LSSmaster_receive(void* object, void* msg) {
/*
* Check LSS timeout.
*
* Generally, we do not really care if the message has been received before
* or after the timeout expired. Only if no message has been received we have
* to check for timeouts
* Generally, we do not really care if the message has been received before or after the timeout
* expired. Only if no message has been received we have to check for timeouts.
*/
static inline CO_LSSmaster_return_t
CO_LSSmaster_check_timeout(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference_us) {
@ -304,9 +300,8 @@ CO_LSSmaster_swStateDeselect(CO_LSSmaster_t* LSSmaster) {
* - byte 0 -> cs
* - byte 1 -> Error Code, where
* - 0 = OK
* - 1 .. FE = Values defined by CiA. All currently defined values
* are slave rejects. No further distinction on why the
* slave did reject the request.
* - 1 .. FE = Values defined by CiA. All currently defined values are slave rejects.
* No further distinction on why the slave did reject the request.
* - FF = Manufacturer Error Code in byte 2
* - byte 2 -> Manufacturer Error, currently not used
*
@ -791,8 +786,7 @@ CO_LSSmaster_FsVerifyInitiate(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference
}
/*
* Helper function - verify 32 bit LSS address, request node(s) to switch
* their state machine to the next state
* Helper function - verify 32 bit LSS address, request node(s) to switch their state machine to the next state
*/
static CO_LSSmaster_return_t
CO_LSSmaster_FsVerifyWait(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference_us, CO_LSSmaster_scantype_t scan,
@ -833,15 +827,13 @@ CO_LSSmaster_FsSearchNext(CO_LSSmaster_t* LSSmaster, const CO_LSSmaster_fastscan
uint8_t i;
/* we search for the next LSS address part to scan for, beginning with the
* one after the current one. If there is none remaining, scanning is
* finished */
* one after the current one. If there is none remaining, scanning is finished */
for (i = LSSmaster->fsLssSub + 1U; i <= CO_LSS_FASTSCAN_SERIAL; i++) {
if (fastscan->scan[i] != CO_LSSmaster_FS_SKIP) {
return i;
}
}
/* node selection is triggered by switching node state machine back
* to initial state */
/* node selection is triggered by switching node state machine back to initial state */
return CO_LSS_FASTSCAN_VENDOR_ID;
}
@ -894,7 +886,8 @@ CO_LSSmaster_IdentifyFastscan(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference
/* continue with evaluating fastscan state machine */
}
/* evaluate fastscan state machine. The state machine is evaluated as following
/*
* evaluate fastscan state machine. The state machine is evaluated as following
* - check for non-configured nodes
* - scan for vendor ID
* - verify vendor ID, switch node state
@ -904,9 +897,9 @@ CO_LSSmaster_IdentifyFastscan(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference
* - verify revision number, switch node state
* - scan for serial number
* - verify serial number, switch node to LSS configuration mode
* Certain steps can be skipped as mentioned in the function description.
* If one step is not ack'ed by a node, the scanning process is terminated
* and the correspondign error is returned. */
* Certain steps can be skipped as mentioned in the function description. If one step is
* not ack'ed by a node, the scanning process is terminated and the correspondign error is returned.
*/
switch (LSSmaster->fsState) {
case CO_LSSmaster_FS_STATE_CHECK:
ret = CO_LSSmaster_FsCheckWait(LSSmaster, timeDifference_us);
@ -924,9 +917,8 @@ CO_LSSmaster_IdentifyFastscan(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference
case CO_LSSmaster_FS_STATE_SCAN:
ret = CO_LSSmaster_FsScanWait(LSSmaster, timeDifference_us, fastscan->scan[LSSmaster->fsLssSub]);
if (ret == CO_LSSmaster_SCAN_FINISHED) {
/* scanning finished, initiate verifcation. The verification
* message also contains the node state machine "switch to
* next state" request */
/* scanning finished, initiate verifcation. The verification message also contains
* the node state machine "switch to next state" request */
next = CO_LSSmaster_FsSearchNext(LSSmaster, fastscan);
ret = CO_LSSmaster_FsVerifyInitiate(LSSmaster, timeDifference_us, fastscan->scan[LSSmaster->fsLssSub],
fastscan->match.addr[LSSmaster->fsLssSub], next);
@ -940,19 +932,16 @@ CO_LSSmaster_IdentifyFastscan(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference
if (ret == CO_LSSmaster_SCAN_FINISHED) {
/* verification successful:
* - assumed node id is correct
* - node state machine has switched to the requested state,
* mirror that in the local copy */
* - node state machine has switched to the requested state, mirror that in the local copy */
next = CO_LSSmaster_FsSearchNext(LSSmaster, fastscan);
if (next == CO_LSS_FASTSCAN_VENDOR_ID) {
/* fastscan finished, one node is now in LSS configuration
* mode */
/* fastscan finished, one node is now in LSS configuration mode */
LSSmaster->state = CO_LSSmaster_STATE_CFG_SLECTIVE;
} else {
/* initiate scan for next part of LSS address */
ret = CO_LSSmaster_FsScanInitiate(LSSmaster, timeDifference_us, fastscan->scan[next], next);
if (ret == CO_LSSmaster_SCAN_FINISHED) {
/* Scanning is not requested. Initiate verification
* step in next function call */
/* Scanning is not requested. Initiate verification step in next function call */
ret = CO_LSSmaster_WAIT_SLAVE;
}

View file

@ -36,9 +36,8 @@
/*
* Read received message from CAN module.
*
* Function will be called (by CAN receive interrupt) every time, when CAN
* message with correct identifier will be received. For more information and
* description of parameters see file CO_driver.h.
* Function will be called (by CAN receive interrupt) every time, when CAN message with correct identifier
* will be received. For more information and description of parameters see file CO_driver.h.
*/
static void
CO_LSSslave_receive(void* object, void* msg) {
@ -58,7 +57,7 @@ CO_LSSslave_receive(void* object, void* msg) {
if ((LSSslave->lssState == CO_LSS_STATE_CONFIGURATION)
&& (LSSslave->activeNodeID == CO_LSS_NODE_ID_ASSIGNMENT)
&& (*LSSslave->pendingNodeID != CO_LSS_NODE_ID_ASSIGNMENT)) {
/* Slave process function will request NMT Reset comm.*/
/* Slave process function will request NMT Reset comm. */
LSSslave->service = cs;
request_LSSslave_process = true;
}
@ -170,8 +169,7 @@ CO_LSSslave_receive(void* object, void* msg) {
if (request_LSSslave_process) {
CO_FLAG_SET(LSSslave->sendResponse);
#if ((CO_CONFIG_LSS)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0
/* Optional signal to RTOS, which can resume task,
* which handles further processing. */
/* Optional signal to RTOS, which can resume task, which handles further processing. */
if (LSSslave->pFunctSignalPre != NULL) {
LSSslave->pFunctSignalPre(LSSslave->functSignalObjectPre);
}

View file

@ -312,8 +312,8 @@ static const CO_GTWA_dataType_t dataTypes[] = {
{(char*)"r32", 4, CO_fifo_readR322a, CO_fifo_cpyTok2R32}, /* REAL32 */
{(char*)"r64", 8, CO_fifo_readR642a, CO_fifo_cpyTok2R64}, /* REAL64 */
{(char*)"vs", 0, CO_fifo_readVs2a, CO_fifo_cpyTok2Vs}, /* VISIBLE_STRING */
{(char*)"os", 0, CO_fifo_readB642a, CO_fifo_cpyTok2B64}, /* OCTET_STRING base64*/
{(char*)"us", 0, CO_fifo_readB642a, CO_fifo_cpyTok2B64}, /* UNICODE_STRING base64*/
{(char*)"os", 0, CO_fifo_readB642a, CO_fifo_cpyTok2B64}, /* OCTET_STRING base64 */
{(char*)"us", 0, CO_fifo_readB642a, CO_fifo_cpyTok2B64}, /* UNICODE_STRING base64 */
{(char*)"d", 0, CO_fifo_readB642a, CO_fifo_cpyTok2B64} /* DOMAIN - base64 */
};
@ -577,8 +577,7 @@ CO_GTWA_process(CO_GTWA_t* gtwa, bool_t enable, uint32_t timeDifference_us, uint
return;
}
/* If there is some more output data for application, read them first.
* Hold on this state, if necessary. */
/* If there is some more output data for application, read them first. Hold on this state, if necessary. */
if (gtwa->respHold) {
timeDifference_us += gtwa->timeDifference_us_cumulative;
@ -606,8 +605,7 @@ CO_GTWA_process(CO_GTWA_t* gtwa, bool_t enable, uint32_t timeDifference_us, uint
/* parse mandatory token '"["<sequence>"]"' */
closed = 0xFFU;
n = CO_fifo_readToken(&gtwa->commFifo, tok, sizeof(tok), &closed, &err);
/* Break if error in token or token was found, but closed with
* command delimiter. */
/* Break if error in token or token was found, but closed with command delimiter. */
if (err || ((n > 0U) && (closed != 0U))) {
err = true;
break;
@ -1053,7 +1051,7 @@ CO_GTWA_process(CO_GTWA_t* gtwa, bool_t enable, uint32_t timeDifference_us, uint
}
}
/* NMT reset (node or communication) - 'reset <node|comm[unication]>'*/
/* NMT reset (node or communication) - 'reset <node|comm[unication]>' */
else if (tok_is_reset) {
CO_ReturnError_t ret;
bool_t NodeErr = checkNetNode(gtwa, net, node, 0, &respErrorCode);
@ -1208,8 +1206,7 @@ CO_GTWA_process(CO_GTWA_t* gtwa, bool_t enable, uint32_t timeDifference_us, uint
break;
}
/* First parameter is table selector. We only support the CiA
* bit timing table from CiA301 ("0") */
/* First parameter is table selector. We only support the CiA bit timing table from CiA301 ("0") */
closed = 0U;
(void)CO_fifo_readToken(&gtwa->commFifo, tok, sizeof(tok), &closed, &err);
(void)getU32(tok, 0, 0, &err);
@ -1303,7 +1300,7 @@ CO_GTWA_process(CO_GTWA_t* gtwa, bool_t enable, uint32_t timeDifference_us, uint
gtwa->state = CO_GTWA_ST_LSS_INQUIRE_ADDR_ALL;
}
}
/* LSS inquire node-ID command - 'lss_get_node'*/
/* LSS inquire node-ID command - 'lss_get_node' */
else if (tok_is_lss_get_node) {
bool_t NodeErr = checkNet(gtwa, net, &respErrorCode);
@ -1317,7 +1314,7 @@ CO_GTWA_process(CO_GTWA_t* gtwa, bool_t enable, uint32_t timeDifference_us, uint
gtwa->state = CO_GTWA_ST_LSS_INQUIRE;
}
/* LSS identify fastscan. This is a manufacturer specific command as
* the one in DSP309 is quite useless - '_lss_fastscan [<timeout_ms>]'*/
* the one in DSP309 is quite useless - '_lss_fastscan [<timeout_ms>]' */
else if (tok_is__lss_fastscan) {
bool_t NodeErr = checkNet(gtwa, net, &respErrorCode);
uint16_t timeout_ms = 0;
@ -1354,17 +1351,14 @@ CO_GTWA_process(CO_GTWA_t* gtwa, bool_t enable, uint32_t timeDifference_us, uint
* <scanType0=0..2> <vendorId> <scanType1=0..2> <productCode>
* <scanType2=0..2> <revisionNo> <scanType3=0..2> <serialNo>]]' */
else if (tok_is_lss_allnodes) {
/* Request node enumeration by LSS identify fastscan.
* This initiates node enumeration by the means of LSS fastscan
* mechanism. When this function is finished:
* - All nodes that match the given criteria are assigned a node ID
* beginning with nodeId. If 127 is reached, the process
* is stopped, no matter if there are nodes remaining or not.
/* Request node enumeration by LSS identify fastscan. This initiates node enumeration
* by the means of LSS fastscan mechanism. When this function is finished:
* - All nodes that match the given criteria are assigned a node ID beginning with nodeId.
* If 127 is reached, the process is stopped, no matter if there are nodes remaining or not.
* - No IDs are assigned because:
* - the given criteria do not match any node,
* - all nodes are already configured.
* This function needs that no node is selected when starting the
* scan process. */
* This function needs that no node is selected when starting the scan process. */
bool_t NodeErr = checkNet(gtwa, net, &respErrorCode);
uint16_t timeout_ms = 0;
@ -1389,8 +1383,7 @@ CO_GTWA_process(CO_GTWA_t* gtwa, bool_t enable, uint32_t timeDifference_us, uint
gtwa->lssSubState = 0;
if (closed == 1U) {
/* No other arguments, as by CiA specification for this command.
* Do full scan. */
/* No other arguments, as by CiA specification for this command. Do full scan. */
/* use start node ID 2. Should work in most cases */
gtwa->lssNID = 2;
/* store node ID in node's NVM */
@ -1587,10 +1580,10 @@ CO_GTWA_process(CO_GTWA_t* gtwa, bool_t enable, uint32_t timeDifference_us, uint
}
/* Empty SDO fifo buffer in multiple cycles. Repeat until
* application runs out of space (respHold) or fifo empty. */
* application runs out of space (respHold) or fifo empty. */
do {
/* read SDO fifo (partially) and print specific data type as
* ascii into intermediate respBuf */
* ascii into intermediate respBuf */
gtwa->respBufCount += gtwa->SDOdataType->dataTypePrint(
&gtwa->SDO_C->bufFifo, &gtwa->respBuf[gtwa->respBufCount],
(CO_GTWA_RESP_BUF_SIZE - 2U) - gtwa->respBufCount, ret == CO_SDO_RT_ok_communicationEnd);
@ -1645,8 +1638,7 @@ CO_GTWA_process(CO_GTWA_t* gtwa, bool_t enable, uint32_t timeDifference_us, uint
}
}
if (gtwa->state == CO_GTWA_ST_WRITE_ABORTED) {
/* Stay in this state, until all data transferred via commFifo
* will be purged. */
/* Stay in this state, until all data transferred via commFifo will be purged. */
if (!CO_fifo_purge(&gtwa->SDO_C->bufFifo) || (closed == 1U)) {
gtwa->state = CO_GTWA_ST_IDLE;
}
@ -1654,8 +1646,7 @@ CO_GTWA_process(CO_GTWA_t* gtwa, bool_t enable, uint32_t timeDifference_us, uint
}
}
/* If not all data were transferred, make sure, there is enough data in
* SDO buffer, to continue communication. Otherwise wait and check for
* timeout */
* SDO buffer, to continue communication. Otherwise wait and check for timeout */
if (gtwa->SDOdataCopyStatus) {
if (CO_fifo_getOccupied(&gtwa->SDO_C->bufFifo) < (CO_CONFIG_GTW_BLOCK_DL_LOOP * 7U)) {
if (gtwa->stateTimeoutTmr > CO_GTWA_STATE_TIMEOUT_TIME_US) {
@ -2001,8 +1992,7 @@ CO_GTWA_process(CO_GTWA_t* gtwa, bool_t enable, uint32_t timeDifference_us, uint
} /* switch (gtwa->state) */
}
/* execute next CANopen processing immediately, if idle and more commands
* available */
/* execute next CANopen processing immediately, if idle and more commands available */
if ((timerNext_us != NULL) && (gtwa->state == CO_GTWA_ST_IDLE)) {
if (CO_fifo_CommSearch(&gtwa->commFifo, false)) {
*timerNext_us = 0;

View file

@ -37,8 +37,7 @@
* - calculate number of CANrx and CYNtx messages: CO_RX_CNT_xx and CO_TX_CNT_xx
* - set optional undefined OD_ENTRY_Hxxxx to NULL.
* - calculate indexes: CO_RX_IDX_xx and CO_TX_IDX_xx
* - calculate total count of CAN message buffers: CO_CNT_ALL_RX_MSGS and
* CO_CNT_ALL_TX_MSGS. */
* - calculate total count of CAN message buffers: CO_CNT_ALL_RX_MSGS and CO_CNT_ALL_TX_MSGS. */
#if OD_CNT_NMT != 1
#error OD_CNT_NMT from OD.h not correct!
#endif
@ -264,9 +263,8 @@
#endif
#endif
/* Indexes of CO_CANrx_t and CO_CANtx_t objects in CO_CANmodule_t and total
* number of them. Indexes are sorted in a way, that objects with highest
* priority of the CAN identifier are listed first. */
/* Indexes of CO_CANrx_t and CO_CANtx_t objects in CO_CANmodule_t and total number of them. Indexes
* are sorted in a way, that objects with highest priority of the CAN identifier are listed first. */
#define CO_RX_IDX_NMT_SLV 0U
#define CO_RX_IDX_GFC (CO_RX_IDX_NMT_SLV + (uint16_t)CO_RX_CNT_NMT_SLV)
#define CO_RX_IDX_SYNC (CO_RX_IDX_GFC + (uint16_t)CO_RX_CNT_GFC)
@ -315,10 +313,7 @@
#undef CO_free
#endif
/*
* Allocate memory for number of elements, each of specific size
* Allocated memory must be reset to all zeros
*/
/* Allocate memory for number of elements, each of specific size Allocated memory must be reset to all zeros */
#define CO_alloc(num, size) calloc((num), (size))
#define CO_free(ptr) free((ptr))
@ -354,9 +349,7 @@ CO_new(CO_config_t* config, uint32_t* heapMemoryUsed) {
* - use config structure
* - calculate number of CANrx and CYNtx messages: RX_CNT_xx and TX_CNT_xx
* - calculate indexes: RX_IDX_xx and TX_IDX_xx
* - calculate total count of CAN message buffers: CNT_ALL_RX_MSGS and
* CNT_ALL_TX_MSGS. */
* - calculate total count of CAN message buffers: CNT_ALL_RX_MSGS and CNT_ALL_TX_MSGS. */
do {
#ifdef CO_MULTIPLE_OD
/* verify arguments */
@ -546,9 +539,8 @@ CO_new(CO_config_t* config, uint32_t* heapMemoryUsed) {
#endif
#ifdef CO_MULTIPLE_OD
/* Indexes of CO_CANrx_t and CO_CANtx_t objects in CO_CANmodule_t and
* total number of them. Indexes are sorted in a way, that objects with
* highest priority of the CAN identifier are listed first. */
/* Indexes of CO_CANrx_t and CO_CANtx_t objects in CO_CANmodule_t and total number of them. Indexes
* are sorted in a way, that objects with highest priority of the CAN identifier are listed first. */
int16_t idxRx = 0;
co->RX_IDX_NMT_SLV = idxRx;
idxRx += RX_CNT_NMT_SLV;
@ -930,7 +922,6 @@ CO_isLSSslaveEnabled(CO_t* co) {
return en;
}
/******************************************************************************/
CO_ReturnError_t
CO_CANinit(CO_t* co, void* CANptr, uint16_t bitRate) {
CO_ReturnError_t err;
@ -949,7 +940,6 @@ CO_CANinit(CO_t* co, void* CANptr, uint16_t bitRate) {
return err;
}
/******************************************************************************/
#if ((CO_CONFIG_LSS)&CO_CONFIG_LSS_SLAVE) != 0
CO_ReturnError_t
CO_LSSinit(CO_t* co, CO_LSS_address_t* lssAddress, uint8_t* pendingNodeID, uint16_t* pendingBitRate) {
@ -968,7 +958,6 @@ CO_LSSinit(CO_t* co, CO_LSS_address_t* lssAddress, uint8_t* pendingNodeID, uint1
}
#endif /* (CO_CONFIG_LSS) & CO_CONFIG_LSS_SLAVE */
/******************************************************************************/
CO_ReturnError_t
CO_CANopenInit(CO_t* co, CO_NMT_t* NMT, CO_EM_t* em, OD_t* od, OD_entry_t* OD_statusBits, uint16_t NMTcontrol,
uint16_t firstHBTime_ms, uint16_t SDOserverTimeoutTime_ms, uint16_t SDOclientTimeoutTime_ms,
@ -1194,7 +1183,6 @@ CO_CANopenInit(CO_t* co, CO_NMT_t* NMT, CO_EM_t* em, OD_t* od, OD_entry_t* OD_st
return CO_ERROR_NO;
}
/******************************************************************************/
CO_ReturnError_t
CO_CANopenInitPDO(CO_t* co, CO_EM_t* em, OD_t* od, uint8_t nodeId, uint32_t* errInfo) {
if (co == NULL) {
@ -1267,7 +1255,6 @@ CO_CANopenInitPDO(CO_t* co, CO_EM_t* em, OD_t* od, uint8_t nodeId, uint32_t* err
return CO_ERROR_NO;
}
/******************************************************************************/
#if (((CO_CONFIG_GFC)&CO_CONFIG_GFC_ENABLE) != 0) || (((CO_CONFIG_SRDO)&CO_CONFIG_SRDO_ENABLE) != 0)
CO_ReturnError_t
CO_CANopenInitSRDO(CO_t* co, CO_EM_t* em, OD_t* od, uint8_t nodeId, uint32_t* errInfo) {
@ -1320,7 +1307,6 @@ CO_CANopenInitSRDO(CO_t* co, CO_EM_t* em, OD_t* od, uint8_t nodeId, uint32_t* er
}
#endif
/******************************************************************************/
CO_NMT_reset_cmd_t
CO_process(CO_t* co, bool_t enableGateway, uint32_t timeDifference_us, uint32_t* timerNext_us) {
(void)enableGateway; /* may be unused */
@ -1417,7 +1403,6 @@ CO_process(CO_t* co, bool_t enableGateway, uint32_t timeDifference_us, uint32_t*
return reset;
}
/******************************************************************************/
#if ((CO_CONFIG_SYNC)&CO_CONFIG_SYNC_ENABLE) != 0
bool_t
CO_process_SYNC(CO_t* co, uint32_t timeDifference_us, uint32_t* timerNext_us) {
@ -1444,7 +1429,6 @@ CO_process_SYNC(CO_t* co, uint32_t timeDifference_us, uint32_t* timerNext_us) {
}
#endif
/******************************************************************************/
#if ((CO_CONFIG_PDO)&CO_CONFIG_RPDO_ENABLE) != 0
void
CO_process_RPDO(CO_t* co, bool_t syncWas, uint32_t timeDifference_us, uint32_t* timerNext_us) {
@ -1466,7 +1450,6 @@ CO_process_RPDO(CO_t* co, bool_t syncWas, uint32_t timeDifference_us, uint32_t*
}
#endif
/******************************************************************************/
#if ((CO_CONFIG_PDO)&CO_CONFIG_TPDO_ENABLE) != 0
void
CO_process_TPDO(CO_t* co, bool_t syncWas, uint32_t timeDifference_us, uint32_t* timerNext_us) {
@ -1488,7 +1471,6 @@ CO_process_TPDO(CO_t* co, bool_t syncWas, uint32_t timeDifference_us, uint32_t*
}
#endif
/******************************************************************************/
#if ((CO_CONFIG_SRDO)&CO_CONFIG_SRDO_ENABLE) != 0
CO_SRDO_state_t
CO_process_SRDO(CO_t* co, uint32_t timeDifference_us, uint32_t* timerNext_us) {

View file

@ -75,10 +75,10 @@ If OD object has OD extension enabled, then direct access to its OD variables mu
#include ODxyz.h
void myFuncGlob(void) {
//Direct address instead of OD_find()
/* Direct address instead of OD_find() */
OD_entry_t *entry_errReg = ODxyz_1001_errorRegister;
//Direct access to OD variable
/* Direct access to OD variable */
uint32_t devType = ODxyz_0.x1000_deviceType;
ODxyz_0.x1018_identity.serialNumber = 0x12345678;
}

View file

@ -134,8 +134,7 @@ CO_CANtxBufferInit(CO_CANmodule_t* CANmodule, uint16_t index, uint16_t ident, bo
/* get specific buffer */
buffer = &CANmodule->txArray[index];
/* CAN identifier, DLC and rtr, bit aligned with CAN module transmit buffer.
* Microcontroller specific. */
/* CAN identifier, DLC and rtr, bit aligned with CAN module transmit buffer, microcontroller specific. */
buffer->ident = ((uint32_t)ident & 0x07FFU) | ((uint32_t)(((uint32_t)noOfBytes & 0xFU) << 11U))
| ((uint32_t)(rtr ? 0x8000U : 0U));
@ -182,7 +181,7 @@ CO_CANclearPendingSyncPDOs(CO_CANmodule_t* CANmodule) {
CO_LOCK_CAN_SEND(CANmodule);
/* Abort message from CAN module, if there is synchronous TPDO.
* Take special care with this functionality. */
if (/*messageIsOnCanBuffer && */ CANmodule->bufferInhibitFlag) {
if (/* messageIsOnCanBuffer && */ CANmodule->bufferInhibitFlag) {
/* clear TXREQ */
CANmodule->bufferInhibitFlag = false;
tpdoDeleted = 1U;
@ -209,8 +208,7 @@ CO_CANclearPendingSyncPDOs(CO_CANmodule_t* CANmodule) {
}
}
/* Get error counters from the module. If necessary, function may use
* different way to determine errors. */
/* Get error counters from the module. If necessary, function may use different way to determine errors. */
static uint16_t rxErrors = 0, txErrors = 0, overflow = 0;
void
@ -282,8 +280,7 @@ CO_CANinterrupt(CO_CANmodule_t* CANmodule) {
rcvMsg = 0; /* get message from module here */
rcvMsgIdent = rcvMsg->ident;
if (CANmodule->useCANrxFilters) {
/* CAN module filters are used. Message with known 11-bit identifier has */
/* been received */
/* CAN module filters are used. Message with known 11-bit identifier has been received */
index = 0; /* get index of the received message here. Or something similar */
if (index < CANmodule->rxSize) {
buffer = &CANmodule->rxArray[index];