| 304 | |
| 305 | #if ((CO_CONFIG_PDO)&CO_CONFIG_PDO_OD_IO_ACCESS) == 0 |
| 306 | static CO_ReturnError_t |
| 307 | PDO_initMapping(CO_PDO_common_t* PDO, OD_t* OD, OD_entry_t* OD_PDOMapPar, bool_t isRPDO, uint32_t* errInfo, |
| 308 | uint32_t* erroneousMap) { |
| 309 | ODR_t odRet; |
| 310 | size_t pdoDataLength = 0; |
| 311 | |
| 312 | /* number of mapped application objects in PDO */ |
| 313 | uint8_t mappedObjectsCount = 0; |
| 314 | odRet = OD_get_u8(OD_PDOMapPar, 0, &mappedObjectsCount, true); |
| 315 | if (odRet != ODR_OK) { |
| 316 | if (errInfo != NULL) { |
| 317 | *errInfo = ((uint32_t)OD_getIndex(OD_PDOMapPar)) << 8; |
| 318 | } |
| 319 | return CO_ERROR_OD_PARAMETERS; |
| 320 | } |
| 321 | if (mappedObjectsCount > CO_PDO_MAX_MAPPED_ENTRIES) { |
| 322 | *erroneousMap = 1; |
| 323 | return CO_ERROR_NO; |
| 324 | } |
| 325 | |
| 326 | /* iterate mapped OD variables */ |
| 327 | for (uint8_t i = 0; i < mappedObjectsCount; i++) { |
| 328 | uint32_t map = 0; |
| 329 | |
| 330 | odRet = OD_get_u32(OD_PDOMapPar, i + 1, &map, true); |
| 331 | if (odRet != ODR_OK) { |
| 332 | if (errInfo != NULL) { |
| 333 | *errInfo = (((uint32_t)OD_getIndex(OD_PDOMapPar)) << 8) | i; |
| 334 | } |
| 335 | return CO_ERROR_OD_PARAMETERS; |
| 336 | } |
| 337 | uint16_t index = (uint16_t)(map >> 16); |
| 338 | uint8_t subIndex = (uint8_t)(map >> 8); |
| 339 | uint8_t mappedLengthBits = (uint8_t)map; |
| 340 | uint8_t mappedLength = mappedLengthBits >> 3; |
| 341 | uint8_t pdoDataStart = pdoDataLength; |
| 342 | pdoDataLength += mappedLength; |
| 343 | |
| 344 | if ((mappedLengthBits & 0x07) != 0 || pdoDataLength > CO_PDO_MAX_SIZE) { |
| 345 | *erroneousMap = map; |
| 346 | return CO_ERROR_NO; |
| 347 | } |
| 348 | |
| 349 | /* is there a reference to the dummy entry */ |
| 350 | if (index < 0x20 && subIndex == 0) { |
| 351 | for (uint8_t j = pdoDataStart; j < pdoDataLength; j++) { |
| 352 | static uint8_t dummyTX = 0; |
| 353 | static uint8_t dummyRX; |
| 354 | PDO->mapPointer[j] = isRPDO ? &dummyRX : &dummyTX; |
| 355 | } |
| 356 | continue; |
| 357 | } |
| 358 | |
| 359 | /* find entry in the Object Dictionary, original location */ |
| 360 | OD_IO_t OD_IO; |
| 361 | OD_entry_t* entry = OD_find(OD, index); |
| 362 | OD_attr_t testAttribute = isRPDO ? ODA_RPDO : ODA_TPDO; |
| 363 |
no test coverage detected