iLLD_TC27xD  1.0
Coding rules

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
static void IfxDma_Dma_configureTransactionSet(Ifx_DMA_CH* channel, IfxDma_Dma_ChannelConfig* config)
{
...
if( config->shadowControl & (1 << IFXDMA_DMA_ENABLE_SHADOW_ADDRESS) )
{
channel->SHADR.U = config->shadowAddress;
}
}

Wrong:

static void IfxDma_Dma_configureTransactionSet(Ifx_DMA_CH* channel, IfxDma_Dma_ChannelConfig* config)
{
...
if( config->shadowControl & (1 << 2) )
{
channel->SHADR.U = config->shadowAddress;
}
}

. Example(1 << 2) below

[Previous page] [Next page]