iLLD_TC27xC  1.0
lld_dosanddont.c
Go to the documentation of this file.
1 /*
2 * $Author: $tklose
3 * $Date: 2014-02-26 09:24:11 GMT$
4 * $Revision: $0.2
5 */
6 /**
7 \page lld_dosanddont Do's and don't
8 
9 -# \subpage lld_dosanddont_namingConvention
10 -# \subpage lld_dosanddont_codingRules
11 -# \subpage lld_dosanddont_documentation
12 -# \subpage lld_dosanddont_optimisation
13 -# \subpage lld_dosanddont_enumUsage
14 
15 
16 
17 [\ref lld_versioning "Previous page"] [\ref lld_dosanddont_namingConvention "Next page"]
18 
19 
20 \page lld_dosanddont_codingRules Coding rules
21 
22  \section typeAssumption Type assumption
23  <SPAN style="font-family:courier;font-size:small;">[link: \ref typeAssumption]</SPAN>
24 
25  Bitfield values should not be assumed as Boolean.
26 
27  Correct:
28  \code
29  IFX_INLINE boolean IfxDma_getChannelPatternDetectionOldValue(Ifx_DMA* dma,IfxDma_ChannelId channelId)
30  {
31  return dma->CH[channelId].CHCSR.B.LXO != 0;
32  }
33  \endcode
34 
35  Wrong:
36  \code
37  IFX_INLINE boolean IfxDma_getChannelPatternDetectionOldValue(Ifx_DMA* dma,IfxDma_ChannelId channelId)
38  {
39  return dma->CH[channelId].CHCSR.B.LXO;
40  }
41  \endcode
42 
43 
44  \section variableNmaes Variable names
45  <SPAN style="font-family:courier;font-size:small;">[link: \ref variableNmaes]</SPAN>
46 
47  Use explicit names for variable.
48  Example:
49  With
50  \code
51  Ifx_DMA* dma;
52  dma->source = 0x123;
53  \endcode
54  the code can be easier understand than with
55  \code
56  Ifx_DMA* baseAddr;
57  baseAddr->source = 0x123;
58  \endcode
59 
60  \section numbers Avoid numbers, use constant instead
61  <SPAN style="font-family:courier;font-size:small;">[link: \ref numbers]</SPAN>
62 
63 
64  Correct:
65  \code
66  #define IFXDMA_DMA_ENABLE_SHADOW_ADDRESS (2) // Position of the shadow address enable bit
67 
68  static void IfxDma_Dma_configureTransactionSet(Ifx_DMA_CH* channel, IfxDma_Dma_ChannelConfig* config)
69  {
70  ...
71  if( config->shadowControl & (1 << IFXDMA_DMA_ENABLE_SHADOW_ADDRESS) )
72  {
73  channel->SHADR.U = config->shadowAddress;
74  }
75  }
76  \endcode
77 
78  Wrong:
79  \code
80  static void IfxDma_Dma_configureTransactionSet(Ifx_DMA_CH* channel, IfxDma_Dma_ChannelConfig* config)
81  {
82  ...
83  if( config->shadowControl & (1 << 2) )
84  {
85  channel->SHADR.U = config->shadowAddress;
86  }
87  }
88  \endcode
89 
90  . Example(1 << 2) below
91 
92 
93 [\ref lld_dosanddont_namingConvention "Previous page"] [\ref lld_dosanddont_documentation "Next page"]
94 
95 \page lld_dosanddont_documentation Documentation
96 
97  \section theSame Avoid 'the same' in documentation
98  <SPAN style="font-family:courier;font-size:small;">[link: \ref theSame]</SPAN>
99 
100  Correct:
101  \code
102  boolean channelInterrupt; // \brief Determines the setting of the channel transfer interrupt flag and interrupt service request
103  \endcode
104 
105  Wrong(<SPAN style="font-family:courier"><SPAN style="color:red">for the same</SPAN></SPAN>):
106  \code
107  boolean channelInterrupt; // \brief Determines the setting of the channel transfer interrupt flag and interrupt service request for the same
108  \endcode
109 
110 
111 
112 [\ref lld_dosanddont_codingRules "Previous page"] [\ref lld_dosanddont_optimisation "Next page"]
113 
114 
115 */