typedef struct{
sint16 temperature;
uint32 Setdata;
} VariableA;
VariableA TableData[N];
static uint16 linearinterpolation(const currentdata *pcurData,const VariableA* pTableData)
{ /* Declare local variables */
sint32 deltaOut;
sint32 deltaIn;
uint16 output;
uint16 idx;
/* DeltaIn of temperatures. */
deltaIn = (sint32)(pTableData[idx].temperature) - (sint32)(pTableData[idx-1].temperature);
/* DeltaOut of Setdata */
deltaOut = (sint32)pTableData[idx].Setdata - (sint32)pTableData[idx-1].Setdata;
/* Division by 0 protection. */
if (deltaOut == 0)
{ /* if the division == 0 */
output = pTableData[idx-1].Setdata;
}
else
{ /*MISRA C:2012 Rule 10.8 */
output =(uint16)((( deltaOut / deltaIn) *((sint32)(pcurData->temperature) - (sint32)(pTableData[idx-1].temperature))) + (sint32)pTableData[idx-1].Setdata );
}
return output;
}
I have no idea to solve 10.8, does someone can explain and fix it, thank you very much.
MISRA C:2012 Rule 10.8
The value of a composite expression shall not be cast to a different essential type category or a wider essential type
Description
Rule Definition
The value of a composite expression shall not be cast to a different essential type category or a wider essential type.