MCPcopy Create free account
hub / github.com/CANopenNode/CANopenNode / OD_write_1019

Function OD_write_1019

301/CO_SYNC.c:138–169  ·  view source on GitHub ↗

* Custom function for writing OD object "Synchronous counter overflow value" * * For more information see file CO_ODinterface.h, OD_IO_t. */

Source from the content-addressed store, hash-verified

136 * For more information see file CO_ODinterface.h, OD_IO_t.
137 */
138static ODR_t
139OD_write_1019(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_t* countWritten) {
140 if ((stream == NULL) || (stream->subIndex != 0U) || (buf == NULL) || (count != sizeof(uint8_t))
141 || (countWritten == NULL)) {
142 return ODR_DEV_INCOMPAT;
143 }
144
145 CO_SYNC_t* SYNC = stream->object;
146 uint8_t syncCounterOvf = CO_getUint8(buf);
147
148 /* verify written value */
149 if ((syncCounterOvf == 1U) || (syncCounterOvf > 240U)) {
150 return ODR_INVALID_VALUE;
151 }
152 if (*SYNC->OD_1006_period != 0U) {
153 return ODR_DATA_DEV_STATE;
154 }
155
156 /* Configure CAN transmit buffer */
157 SYNC->CANtxBuff = CO_CANtxBufferInit(SYNC->CANdevTx, SYNC->CANdevTxIdx, SYNC->CAN_ID, false,
158 (syncCounterOvf != 0U) ? 1U : 0U, false);
159
160 if (SYNC->CANtxBuff == NULL) {
161 SYNC->isProducer = false;
162 return ODR_DEV_INCOMPAT;
163 }
164
165 SYNC->counterOverflowValue = syncCounterOvf;
166
167 /* write value to the original location in the Object Dictionary */
168 return OD_writeOriginal(stream, buf, count, countWritten);
169}
170#endif /* (CO_CONFIG_SYNC) & CO_CONFIG_SYNC_PRODUCER */
171#endif /* (CO_CONFIG_SYNC) & CO_CONFIG_FLAG_OD_DYNAMIC */
172

Callers

nothing calls this directly

Calls 3

CO_getUint8Function · 0.85
CO_CANtxBufferInitFunction · 0.85
OD_writeOriginalFunction · 0.85

Tested by

no test coverage detected