This function reads the next byte from the flash memory at index in mg_u16MemIdx. The byte value is used to recalculate the flash memory CRC. When reaching the end of monitored memory area, the index variable is reset to 0 to start again and the calculated CRC will be compared with the stored CRC value. In case of a CRC divergency, safety_SafeMode() will be called.
Definition at line 199 of file safety.c. References CRC32POLY, mg_u16MemIdx, mg_u32ApplCRC, mg_u32CalcCRC, and safety_SafeMode(). Referenced by main(). {
UINT8 u8Help;
UINT8 u8Idx;
u8Help = pgm_read_byte(mg_u16MemIdx);
/* Calculate CRC */
for(u8Idx = 8U; u8Idx; u8Idx--)
{
if(((mg_u32CalcCRC & 0x80000000) ? 1U : 0U) != (u8Help & 1U))
{
mg_u32CalcCRC = (mg_u32CalcCRC << 1U) ^ CRC32POLY;
}
else
{
mg_u32CalcCRC <<= 1U;
}
u8Help >>= 1U;
}
mg_u16MemIdx++;
if(mg_u16MemIdx >= MEMPOS_CRC)
{
mg_u32CalcCRC ^= 0xFFFFFFFFUL;
/* compare CRC values */
if(mg_u32ApplCRC != mg_u32CalcCRC)
{
safety_SafeMode(); /* this function never returns */
}
mg_u16MemIdx = 0U;
mg_u32CalcCRC = 0xFFFFFFFFUL;
}
}
Here is the call graph for this function:
![]()
Here is the caller graph for this function:
![]() |
1.7.2