| 266 | } |
| 267 | |
| 268 | CO_ReturnError_t |
| 269 | CO_nodeGuardingMaster_init(CO_nodeGuardingMaster_t* ngm, CO_EM_t* em, CO_CANmodule_t* CANdevRx, uint16_t CANdevRxIdx, |
| 270 | CO_CANmodule_t* CANdevTx, uint16_t CANdevTxIdx) { |
| 271 | CO_ReturnError_t ret = CO_ERROR_NO; |
| 272 | |
| 273 | /* verify arguments */ |
| 274 | if (ngm == NULL || em == NULL || CANdevRx == NULL || CANdevTx == NULL) { |
| 275 | return CO_ERROR_ILLEGAL_ARGUMENT; |
| 276 | } |
| 277 | |
| 278 | /* clear the object */ |
| 279 | (void)memset(ngm, 0, sizeof(CO_nodeGuardingMaster_t)); |
| 280 | |
| 281 | /* Configure object variables */ |
| 282 | ngm->em = em; |
| 283 | |
| 284 | /* configure CAN reception. One buffer will receive all messages from CAN-id 0x700 to 0x7FF. */ |
| 285 | ret = CO_CANrxBufferInit(CANdevRx, CANdevRxIdx, CO_CAN_ID_HEARTBEAT, 0x780, false, (void*)ngm, CO_ngm_receive); |
| 286 | if (ret != CO_ERROR_NO) { |
| 287 | return ret; |
| 288 | } |
| 289 | |
| 290 | /* configure CAN transmission */ |
| 291 | ngm->CANdevTx = CANdevTx; |
| 292 | ngm->CANdevTxIdx = CANdevTxIdx; |
| 293 | ngm->CANtxBuff = CO_CANtxBufferInit(CANdevTx, CANdevTxIdx, CO_CAN_ID_HEARTBEAT, true, 1, 0); |
| 294 | if (ngm->CANtxBuff == NULL) { |
| 295 | return CO_ERROR_ILLEGAL_ARGUMENT; |
| 296 | } |
| 297 | |
| 298 | return ret; |
| 299 | } |
| 300 | |
| 301 | CO_ReturnError_t |
| 302 | CO_nodeGuardingMaster_initNode(CO_nodeGuardingMaster_t* ngm, uint8_t index, uint8_t nodeId, uint16_t guardTime_ms) { |
no test coverage detected