Type assumption
[link: Type assumption]
Bitfield values should not be assumed as Boolean.
Correct:
{
return dma->CH[channelId].CHCSR.B.LXO != 0;
}
Wrong:
{
return dma->CH[channelId].CHCSR.B.LXO;
}
Variable names
[link: Variable names]
Use explicit names for variable.
Example:
With
Ifx_DMA* dma;
dma->source = 0x123;
the code can be easier understand than with
Ifx_DMA* baseAddr;
baseAddr->source = 0x123;
Avoid numbers, use constant instead
[link: Avoid numbers, use constant instead]
Correct:
#define IFXDMA_DMA_ENABLE_SHADOW_ADDRESS (2) // Position of the shadow address enable bit
{
...
if( config->
shadowControl & (1 << IFXDMA_DMA_ENABLE_SHADOW_ADDRESS) )
{
}
}
Wrong:
. Example(1 << 2) below
[Previous page] [Next page]