Vybhav Kadaba
/
EV-PRO-MW1001_Development_updateFW
Bumped Mbed FW version to 01.20.0080
Diff: src/admw_1001.c
- Revision:
- 61:0f16a2e3b58b
- Parent:
- 58:aa9cd5072f66
- Child:
- 63:2655a04c00f5
--- a/src/admw_1001.c Mon Mar 16 09:54:36 2020 +0000 +++ b/src/admw_1001.c Tue Mar 31 04:50:37 2020 +0000 @@ -2355,7 +2355,8 @@ ADMW1001_LUT_HEADER *pHdr = &pLutBuffer->header; uint8_t *pLutTableData = (uint8_t *)pLutBuffer + sizeof(*pHdr); - if (sizeof(*pHdr) > nLutBufferSize) { + if (sizeof(*pHdr) > nLutBufferSize) + { ADMW_LOG_ERROR("Insufficient LUT buffer size provided"); return ADMW_INVALID_PARAM; } @@ -2371,7 +2372,8 @@ * Walk through the list of table pointers provided, appending the table * descriptor+data from each one to the provided LUT buffer */ - for (unsigned i = 0; i < nNumTables; i++) { + for (unsigned i = 0; i < nNumTables; i++) + { ADMW1001_LUT_DESCRIPTOR * const pDesc = ppDesc[i]; ADMW1001_LUT_TABLE_DATA * const pData = ppData[i]; ADMW_RESULT res; @@ -2384,9 +2386,9 @@ /* Fill in the table descriptor length and CRC fields */ pDesc->length = dataLength; - pDesc->crc16 = admw_crc16_ccitt(pData, dataLength); - if ((sizeof(*pHdr) + pHdr->totalLength + sizeof(*pDesc) + dataLength) > nLutBufferSize) { + if ((sizeof(*pHdr) + pHdr->totalLength + sizeof(*pDesc) + dataLength) > nLutBufferSize) + { ADMW_LOG_ERROR("Insufficient LUT buffer size provided"); return ADMW_INVALID_PARAM; } @@ -2406,66 +2408,64 @@ ADMW_DEVICE_HANDLE const hDevice, ADMW1001_LUT * const pLutData) { +#pragma diag_suppress=Pa039 ADMW1001_LUT_HEADER *pLutHeader = &pLutData->header; ADMW1001_LUT_TABLE *pLutTable = pLutData->tables; unsigned actualLength = 0; - if (pLutData->header.signature != ADMW_LUT_SIGNATURE) { + if (pLutData->header.signature != ADMW_LUT_SIGNATURE) + { ADMW_LOG_ERROR("LUT signature incorrect (expected 0x%X, actual 0x%X)", - ADMW_LUT_SIGNATURE, pLutHeader->signature); + ADMW_LUT_SIGNATURE, pLutHeader->signature); return ADMW_INVALID_SIGNATURE; } if ((pLutData->tables->descriptor.geometry!= ADMW1001_LUT_GEOMETRY_NES_1D) && - (pLutData->tables->data.lut1dNes.nElements > MAX_LUT_NUM_ENTRIES)) { + (pLutData->tables->data.lut1dNes.nElements > MAX_LUT_NUM_ENTRIES)) + { return ADMW_INVALID_PARAM; } - - for (unsigned i = 0; i < pLutHeader->numTables; i++) { + for (unsigned i = 0; i < pLutHeader->numTables; i++) + { ADMW1001_LUT_DESCRIPTOR *pDesc = &pLutTable->descriptor; - ADMW1001_LUT_TABLE_DATA *pData = &pLutTable->data; - unsigned short calculatedCrc; - switch (pDesc->geometry) { - case ADMW1001_LUT_GEOMETRY_COEFFS: - switch (pDesc->equation) { - case ADMW1001_LUT_EQUATION_POLYN: - case ADMW1001_LUT_EQUATION_POLYNEXP: - case ADMW1001_LUT_EQUATION_QUADRATIC: - case ADMW1001_LUT_EQUATION_STEINHART: - case ADMW1001_LUT_EQUATION_LOGARITHMIC: - case ADMW1001_LUT_EQUATION_BIVARIATE_POLYN: - break; - default: - ADMW_LOG_ERROR("Invalid equation %u specified for LUT table %u", - pDesc->equation, i); - return ADMW_INVALID_PARAM; + switch (pDesc->geometry) + { + case ADMW1001_LUT_GEOMETRY_COEFFS: + switch (pDesc->equation) + { + case ADMW1001_LUT_EQUATION_POLYN: + case ADMW1001_LUT_EQUATION_POLYNEXP: + case ADMW1001_LUT_EQUATION_QUADRATIC: + case ADMW1001_LUT_EQUATION_STEINHART: + case ADMW1001_LUT_EQUATION_LOGARITHMIC: + case ADMW1001_LUT_EQUATION_BIVARIATE_POLYN: + break; + default: + ADMW_LOG_ERROR("Invalid equation %u specified for LUT table %u", + pDesc->equation, i); + return ADMW_INVALID_PARAM; } - break; - case ADMW1001_LUT_GEOMETRY_NES_1D: - break; - default: - ADMW_LOG_ERROR("Invalid geometry %u specified for LUT table %u", - pDesc->geometry, i); - return ADMW_INVALID_PARAM; + break; + case ADMW1001_LUT_GEOMETRY_NES_1D: + break; + default: + ADMW_LOG_ERROR("Invalid geometry %u specified for LUT table %u", + pDesc->geometry, i); + return ADMW_INVALID_PARAM; } - switch (pDesc->dataType) { - case ADMW1001_LUT_DATA_TYPE_FLOAT32: - case ADMW1001_LUT_DATA_TYPE_FLOAT64: - break; - default: - ADMW_LOG_ERROR("Invalid vector format %u specified for LUT table %u", - pDesc->dataType, i); - return ADMW_INVALID_PARAM; + switch (pDesc->dataType) + { + case ADMW1001_LUT_DATA_TYPE_FLOAT32: + case ADMW1001_LUT_DATA_TYPE_FLOAT64: + break; + default: + ADMW_LOG_ERROR("Invalid vector format %u specified for LUT table %u", + pDesc->dataType, i); + return ADMW_INVALID_PARAM; } - calculatedCrc = admw_crc16_ccitt(pData, pDesc->length); - if (calculatedCrc != pDesc->crc16) { - ADMW_LOG_ERROR("CRC validation failed on LUT table %u (expected 0x%04X, actual 0x%04X)", - i, pDesc->crc16, calculatedCrc); - return ADMW_CRC_ERROR; - } actualLength += sizeof(*pDesc) + pDesc->length; @@ -2473,15 +2473,17 @@ pLutTable = (ADMW1001_LUT_TABLE *)((uint8_t *)pLutTable + sizeof(*pDesc) + pDesc->length); } - if (actualLength != pLutHeader->totalLength) { + if (actualLength != pLutHeader->totalLength) + { ADMW_LOG_ERROR("LUT table length mismatch (expected %u, actual %u)", - pLutHeader->totalLength, actualLength); + pLutHeader->totalLength, actualLength); return ADMW_WRONG_SIZE; } - if (sizeof(*pLutHeader) + pLutHeader->totalLength > ADMW_LUT_MAX_SIZE) { + if (sizeof(*pLutHeader) + pLutHeader->totalLength > ADMW_LUT_MAX_SIZE) + { ADMW_LOG_ERROR("Maximum LUT table length (%u bytes) exceeded", - ADMW_LUT_MAX_SIZE); + ADMW_LUT_MAX_SIZE); return ADMW_WRONG_SIZE; }