if(( pulseCntCalc < 0) || (pulseCntCalc > UINT16_MAX))
{
// you can print log and handle invalid range
}
I saw many cases fall into if statement. Is it ok to intentionally truncate the data here?
Or set PulseCnt to certain fixed value?
if((pulseCntCalc < 0) || (pulseCntCalc > UINT16_MAX))
{
//Intentionally truncate data
pulseCntCalc = pulseCntCalc & 0x0000FFFF;
pulseCnt = (uint16_t)pulseCntCalc;
}