Vybhav Kadaba
/
EV-PRO-MW1001_Development_code_cleaup
Removed unwanted enums and unused functions
Diff: src/admw_1001.c
- Revision:
- 55:215da406282b
- Parent:
- 54:31921ad29828
- Child:
- 56:38b36e947602
--- a/src/admw_1001.c Wed Feb 19 10:08:13 2020 +0000 +++ b/src/admw_1001.c Mon Feb 24 07:04:35 2020 +0000 @@ -52,7 +52,7 @@ #include "admw1001/ADMW1001_REGISTERS.h" #include "admw1001/admw1001_lut_data.h" #include "admw1001/admw1001_host_comms.h" - +#include "inc/mbedVersion.h" #include "crc16.h" #define VERSIONID_MAJOR 2 #define VERSIONID_MINOR 0 @@ -405,6 +405,11 @@ } return ADMW_SUCCESS; } +ADMW_RESULT admw_readMbedVersion() +{ + ADMW_LOG_INFO("Mbed Firmware version is %X.%X.%X",MBED_HOST_MAJOR,MBED_HOST_MINOR,MBED_HOST_BUILD); +} + static ADMW_RESULT executeCommand( ADMW_DEVICE_HANDLE const hDevice, ADMW_CORE_Command_Special_Command const command, @@ -1262,14 +1267,11 @@ else diagnosticsControlReg.Diag_Meas_En = 1; - if(pDiagnosticsConfig->osdFrequency <= 0x7F) - { - diagnosticsControlReg.Diag_OSD_Freq = pDiagnosticsConfig->osdFrequency; - } - else - { + if(pDiagnosticsConfig->osdFrequency <= 0x7F) { + diagnosticsControlReg.Diag_OSD_Freq = pDiagnosticsConfig->osdFrequency; + } else { ADMW_LOG_ERROR("Invalid open-sensor diagnostic frequency %d specified", - pDiagnosticsConfig->osdFrequency); + pDiagnosticsConfig->osdFrequency); return ADMW_INVALID_PARAM; } WRITE_REG_U8(hDevice, diagnosticsControlReg.VALUE8, CORE_DIAGNOSTICS_CONTROL); @@ -2438,66 +2440,59 @@ 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: + 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; - 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; + 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) - { + if (calculatedCrc != pDesc->crc16) { ADMW_LOG_ERROR("CRC validation failed on LUT table %u (expected 0x%04X, actual 0x%04X)", - i, pDesc->crc16, calculatedCrc); + i, pDesc->crc16, calculatedCrc); return ADMW_CRC_ERROR; } @@ -2507,17 +2502,15 @@ 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; }