Other Parts Discussed in Thread: HALCOGEN
Dear All
I noticed that the code generated by halcogen has concerned defensive programming or maybe try to satisfy the MISRA standard.
for example:
void esmEnableInterrupt(uint64 channels)
{
/* USER CODE BEGIN (15) */
/* USER CODE END */
esmREG->IESR4 = (uint32) ((channels >> 32U) & 0xFFFFFFFFU);
esmREG->IESR1 = (uint32) (channels & 0xFFFFFFFFU);
/* USER CODE BEGIN (16) */
/* USER CODE END */
}
it is a simple function to divide a 64 bit value into two 32bits value, high 32bits and low 32bits respectively
but why it should be ORed with 0xFFFFFFFFU, and for what reason, there is a "U" followed by value?
it seems that if not ORed with 0xFFFFFFFFU, and no "U" followed, no error will occur, but I know you guy have some consideration for coding like this.
And I also noticed that, it is better to write 0xAA or 0x55 to register to avoid soft error, it can be took account as a defensive programming skill.
Please let me know if there are other defensive programming skills I didnt notice.
Leo