iLLD_TC29x  1.0
IfxFft.h
Go to the documentation of this file.
1 /**
2  * \file IfxFft.h
3  * \brief FFT basic functionality
4  * \ingroup IfxLld_Fft
5  *
6  * \version iLLD_1_0_0_11_0
7  * \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
8  *
9  *
10  * IMPORTANT NOTICE
11  *
12  *
13  * Infineon Technologies AG (Infineon) is supplying this file for use
14  * exclusively with Infineon's microcontroller products. This file can be freely
15  * distributed within development tools that are supporting such microcontroller
16  * products.
17  *
18  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
22  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
23  *
24  * \defgroup IfxLld_Fft_Std_Enumerations Enumerations
25  * \ingroup IfxLld_Fft_Std
26  * \defgroup IfxLld_Fft_Std_UtilityFunctions Utility Functions
27  * \ingroup IfxLld_Fft_Std
28  */
29 
30 #ifndef IFXFFT_H
31 #define IFXFFT_H 1
32 
33 /******************************************************************************/
34 /*----------------------------------Includes----------------------------------*/
35 /******************************************************************************/
36 
37 #include "_Impl/IfxFft_cfg.h"
39 #include "Src/Std/IfxSrc.h"
40 #include "IfxFft_reg.h"
41 #include "IfxLmu_reg.h"
42 
43 /******************************************************************************/
44 /*--------------------------------Enumerations--------------------------------*/
45 /******************************************************************************/
46 
47 /** \addtogroup IfxLld_Fft_Std_Enumerations
48  * \{ */
49 /** \brief Input format
50  * Definition in Ifx_FFT.CSR.B.IN.FMT
51  */
52 typedef enum
53 {
54  IfxFft_Input_complexSInt32 = 0, /**< \brief 1 complex 32-bit data per 64-bit word */
55  IfxFft_Input_realSInt32 = 1, /**< \brief 2 real 32-bit data per 64-bit word */
56  IfxFft_Input_complexSInt16 = 2, /**< \brief 2 complex 16-bit data per 64-bit word */
57  IfxFft_Input_realSInt16 = 3 /**< \brief 4 real 16-bit data per 64-bit word */
58 } IfxFft_Input;
59 
60 /** \brief Length of transform. Log base 2 of the required transform size.
61  * Length must be between 3 (transform of 8) and 11 (transform of 2048).
62  * Definition in Ifx_FFT.CSR.B.LENGTH
63  */
64 typedef enum
65 {
66  IfxFft_Length_8 = 3, /**< \brief transform of 8 */
67  IfxFft_Length_16 = 4, /**< \brief transform of 16 */
68  IfxFft_Length_32 = 5, /**< \brief transform of 32 */
69  IfxFft_Length_64 = 6, /**< \brief transform of 64 */
70  IfxFft_Length_128 = 7, /**< \brief transform of 128 */
71  IfxFft_Length_256 = 8, /**< \brief transform of 256 */
72  IfxFft_Length_512 = 9, /**< \brief transform of 512 */
73  IfxFft_Length_1024 = 10 /**< \brief transform of 1024 */
75 
76 /** \brief Operation (FFT / IFFT)
77  * Definition in Ifx_FFT.CSR.B.IFFT
78  */
79 typedef enum
80 {
81  IfxFft_Operation_fft = 0, /**< \brief perform FFT */
82  IfxFft_Operation_ifft = 1 /**< \brief perform IFFT */
84 
85 /** \brief Output format
86  * Definition in Ifx_FFT.CSR.B.OUT.FMT
87  */
88 typedef enum
89 {
90  IfxFft_Output_complexSInt32 = 0, /**< \brief 1 complex 32-bit data per 64-bit word */
91  IfxFft_Output_complexSInt16 = 1 /**< \brief 2 complex 16-bit data per 64-bit word */
93 
94 /** \} */
95 
96 /** \addtogroup IfxLld_Fft_Std_UtilityFunctions
97  * \{ */
98 
99 /******************************************************************************/
100 /*-------------------------Inline Function Prototypes-------------------------*/
101 /******************************************************************************/
102 
103 /** \brief Enables the FFT module and also the LMU interface
104  * \param fft pointer to FFT registers
105  * \param lmu pointer to LMU registers
106  * \return None
107  */
108 IFX_INLINE void IfxFft_enableModule(Ifx_FFT *fft, Ifx_LMU *lmu);
109 
110 /** \brief Returns the input format
111  * \param fft pointer to FFT registers
112  * \return Input format
113  */
115 
116 /** \brief Returns the length of the transform (length code, 3 to 10)
117  * \param fft pointer to FFT registers
118  * \return Length of the transform (length code)
119  */
121 
122 /** \brief Converts the given input length into the transform length code, to write into Ifx_FFT.CSR.B.LENGTH
123  * \param length Input length of the transform
124  * \return Length of the transform (code, 3 to 10)
125  */
127 
128 /** \brief Retruns the actual length of the transform from the length code
129  * \param length Length of transform
130  * \return Actual length of the transform
131  */
133 
134 /** \brief Returns the output format
135  * \param fft pointer to FFT registers
136  * \return Output format
137  */
139 
140 /** \brief Returns the status of FFT DONE request
141  * \param fft pointer to FFT registers
142  * \return Status of FFT DONE request
143  */
144 IFX_INLINE volatile Ifx_SRC_SRCR *IfxFft_getSrcPointerDone(Ifx_FFT *fft);
145 
146 /** \brief Returns the status of FFT RFS request
147  * \param fft pointer to FFT registers
148  * \return Status of FFT RFS request
149  */
150 IFX_INLINE volatile Ifx_SRC_SRCR *IfxFft_getSrcPointerRfs(Ifx_FFT *fft);
151 
152 /** \brief Returns the actual length of the transform
153  * \param fft pointer to FFT registers
154  * \return Actual length of the transform ()
155  */
157 
158 /** \brief Returns the status of whether the FFT Engine is Idle or has at least one transform in operation.
159  * \param fft pointer to FFT registers
160  * \return (true / false)
161  */
162 IFX_INLINE boolean IfxFft_isEngineBusy(Ifx_FFT *fft);
163 
164 /** \brief Returns the status of whether the module is enabled or not
165  * \param fft pointer to FFT registers
166  * \return (true / false)
167  */
168 IFX_INLINE boolean IfxFft_isModuleEnabled(Ifx_FFT *fft);
169 
170 /** \brief Returns the status of whether the module can accept a START operation or not
171  * \param fft Pointer to FFT registers
172  * \return (true / false)
173  */
174 IFX_INLINE boolean IfxFft_isReadyForStart(Ifx_FFT *fft);
175 
176 /** \} */
177 
178 /******************************************************************************/
179 /*---------------------Inline Function Implementations------------------------*/
180 /******************************************************************************/
181 
182 IFX_INLINE void IfxFft_enableModule(Ifx_FFT *fft, Ifx_LMU *lmu)
183 {
184  // FFT clock enable
185  fft->CLC.U = 0x0;
186 }
187 
188 
190 {
191  return (IfxFft_Input)fft->CSR.B.IN_FMT;
192 }
193 
194 
196 {
197  return (IfxFft_Length)fft->CSR.B.LENGTH;
198 }
199 
200 
202 {
203  return (IfxFft_Length)(31 - __clz((uint32)length));
204 }
205 
206 
208 {
209  return 1 << (uint32)length;
210 }
211 
212 
214 {
215  return (IfxFft_Output)fft->CSR.B.OUT_FMT;
216 }
217 
218 
219 IFX_INLINE volatile Ifx_SRC_SRCR *IfxFft_getSrcPointerDone(Ifx_FFT *fft)
220 {
221  // only a single FFT available, therefore no check for the fft pointer required
222  return &MODULE_SRC.FFT.FFT[0].DONE;
223 }
224 
225 
226 IFX_INLINE volatile Ifx_SRC_SRCR *IfxFft_getSrcPointerRfs(Ifx_FFT *fft)
227 {
228  // only a single FFT available, therefore no check for the fft pointer required
229  return &MODULE_SRC.FFT.FFT[0].RFS;
230 }
231 
232 
234 {
235  return 1U << fft->CSR.B.LENGTH;
236 }
237 
238 
239 IFX_INLINE boolean IfxFft_isEngineBusy(Ifx_FFT *fft)
240 {
241  return fft->CSR.B.BUSY != 0;
242 }
243 
244 
245 IFX_INLINE boolean IfxFft_isModuleEnabled(Ifx_FFT *fft)
246 {
247  return fft->CLC.B.DISS == 0;
248 }
249 
250 
251 IFX_INLINE boolean IfxFft_isReadyForStart(Ifx_FFT *fft)
252 {
253  return fft->CSR.B.RFS != 0;
254 }
255 
256 
257 #endif /* IFXFFT_H */