iLLD_TC29x  1.0
IfxSent.h
Go to the documentation of this file.
1 /**
2  * \file IfxSent.h
3  * \brief SENT basic functionality
4  * \ingroup IfxLld_Sent
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  *
25  * \defgroup IfxLld_Sent_Std_Enumerations Enumerations
26  * \ingroup IfxLld_Sent_Std
27  * \defgroup IfxLld_Sent_Std_Configuration Configuration Functions
28  * \ingroup IfxLld_Sent_Std
29  * \defgroup IfxLld_Sent_Std_Interrupts Interrupts
30  * \ingroup IfxLld_Sent_Std
31  * \defgroup IfxLld_Sent_Std_Operative Operative Functions
32  * \ingroup IfxLld_Sent_Std
33  * \defgroup IfxLld_Sent_Std_Baudrate Baudrate Configuration
34  * \ingroup IfxLld_Sent_Std
35  * \defgroup IfxLld_Sent_Std_IO IO Pin Configuration Functions
36  * \ingroup IfxLld_Sent_Std
37  */
38 
39 #ifndef IFXSENT_H
40 #define IFXSENT_H 1
41 
42 /******************************************************************************/
43 /*----------------------------------Includes----------------------------------*/
44 /******************************************************************************/
45 
46 #include "_Impl/IfxSent_cfg.h"
47 #include "Src/Std/IfxSrc.h"
48 #include "Scu/Std/IfxScuCcu.h"
49 #include "_PinMap/IfxSent_PinMap.h"
51 #include "IfxSent_bf.h"
52 #include "IfxSent_reg.h"
53 
54 /******************************************************************************/
55 /*-----------------------------------Macros-----------------------------------*/
56 /******************************************************************************/
57 
58 #define IFXSENT_INTERRUPT_STATUS_ERROR_FLAGS (0x000037f4)
59 
60 /******************************************************************************/
61 /*--------------------------------Enumerations--------------------------------*/
62 /******************************************************************************/
63 
64 /** \addtogroup IfxLld_Sent_Std_Enumerations
65  * \{ */
66 /** \brief SENT.CH[channelId].IOCR.ALTI , Specifies alternate input for channel
67  */
68 typedef enum
69 {
70  IfxSent_AlternateInput_0 = 0, /**< \brief Specifies alternate input 0 */
71  IfxSent_AlternateInput_1, /**< \brief Specifies alternate input 1 */
72  IfxSent_AlternateInput_2, /**< \brief Specifies alternate input 2 */
73  IfxSent_AlternateInput_3 /**< \brief Specifies alternate input 3 */
75 
76 /** \brief SENT.CH[channelId].RSR.CST, Specifies the current channel status
77  */
78 typedef enum
79 {
80  IfxSent_ChannelStatus_stop = 0, /**< \brief Specifies the channel is stopped */
81  IfxSent_ChannelStatus_initialize = 1, /**< \brief Specifies the channel is initialized */
82  IfxSent_ChannelStatus_running = 2, /**< \brief Specifies the channel is running */
83  IfxSent_ChannelStatus_synchronize = 3 /**< \brief Specifies the channel is synchronized */
85 
86 /** \brief SENT.FDR.DM , Specifies clock divider mode
87  */
88 typedef enum
89 {
90  IfxSent_ClockDividerMode_off = 0, /**< \brief Specifies clock divider mode off */
91  IfxSent_ClockDividerMode_normal = 1, /**< \brief Specifies clock normal divider mode */
92  IfxSent_ClockDividerMode_fractional = 2 /**< \brief Specifies clock fractional divider mode */
94 
95 /** \brief SENT.CH[channelId].SDS.CON , Specifies received configuration bit value
96  */
97 typedef enum
98 {
99  IfxSent_ConfigBit_0 = 0, /**< \brief Specifies received configuration bit value 0 */
100  IfxSent_ConfigBit_1 /**< \brief Specifies received configuration bit value 1 */
102 
103 /** \brief SENT.CH[channelId].IOCR.DEPTH , Specifies number of port input samples
104  */
105 typedef enum
106 {
107  IfxSent_DigitalGlitchesLength_off = 0, /**< \brief Specifies port input samples off */
108  IfxSent_DigitalGlitchesLength_1 = 1, /**< \brief Specifies 1 port input samples */
109  IfxSent_DigitalGlitchesLength_2, /**< \brief Specifies 2 port input samples */
110  IfxSent_DigitalGlitchesLength_3, /**< \brief Specifies 3 port input samples */
111  IfxSent_DigitalGlitchesLength_4, /**< \brief Specifies 4 port input samples */
112  IfxSent_DigitalGlitchesLength_5, /**< \brief Specifies 5 port input samples */
113  IfxSent_DigitalGlitchesLength_6, /**< \brief Specifies 6 port input samples */
114  IfxSent_DigitalGlitchesLength_7, /**< \brief Specifies 7 port input samples */
115  IfxSent_DigitalGlitchesLength_8, /**< \brief Specifies 8 port input samples */
116  IfxSent_DigitalGlitchesLength_9, /**< \brief Specifies 9 port input samples */
117  IfxSent_DigitalGlitchesLength_10, /**< \brief Specifies 10 port input samples */
118  IfxSent_DigitalGlitchesLength_11, /**< \brief Specifies 11 port input samples */
119  IfxSent_DigitalGlitchesLength_12, /**< \brief Specifies 12 port input samples */
120  IfxSent_DigitalGlitchesLength_13, /**< \brief Specifies 13 port input samples */
121  IfxSent_DigitalGlitchesLength_14, /**< \brief Specifies 14 port input samples */
122  IfxSent_DigitalGlitchesLength_15 /**< \brief Specifies 15 port input samples */
124 
125 /** \brief SENT.CH[channelId].RCR.ESF , Specifies the serial frame structure
126  */
127 typedef enum
128 {
129  IfxSent_ExtendedSerialFrameMode_standard = 0, /**< \brief Specifies the standard serial frame structure */
130  IfxSent_ExtendedSerialFrameMode_extended = 1 /**< \brief Specifies the extended serial frame structure */
132 
133 /** \brief SENT.CH[channelId].IOCR.ETS , Specifies the external trigger line
134  */
135 typedef enum
136 {
137  IfxSent_ExternalTrigger_0 = 0, /**< \brief Specifies the external trigger line 0 */
138  IfxSent_ExternalTrigger_1, /**< \brief Specifies the external trigger line 1 */
139  IfxSent_ExternalTrigger_2, /**< \brief Specifies the external trigger line 2 */
140  IfxSent_ExternalTrigger_3, /**< \brief Specifies the external trigger line 3 */
141  IfxSent_ExternalTrigger_4, /**< \brief Specifies the external trigger line 4 */
142  IfxSent_ExternalTrigger_5, /**< \brief Specifies the external trigger line 5 */
143  IfxSent_ExternalTrigger_6, /**< \brief Specifies the external trigger line 6 */
144  IfxSent_ExternalTrigger_7, /**< \brief Specifies the external trigger line 7 */
145  IfxSent_ExternalTrigger_8, /**< \brief Specifies the external trigger line 8 */
146  IfxSent_ExternalTrigger_9 /**< \brief Specifies the external trigger line 9 */
148 
149 /** \brief SENT.CH[channelId].RCR.CFC, Specifies received frame check mode
150  */
151 typedef enum
152 {
153  IfxSent_FrameCheckMode_pastSyncPulse = 0, /**< \brief Specifies frame check mode against past sync pulse */
154  IfxSent_FrameCheckMode_futureSuncPulse = 1 /**< \brief Specifies frame check mode against future sync pulse */
156 
157 /** \brief SENT.CH[channelId].INP.X(X= RSI,RDI,RBI,TDI,TBI,ERRI,SDI,WDI),Specifies interrupt requested node for respective interrupt
158  */
159 typedef enum
160 {
161  IfxSent_InterruptNodePointer_0 = 0, /**< \brief Specifies interrupt requested node 0 */
162  IfxSent_InterruptNodePointer_1, /**< \brief Specifies interrupt requested node 1 */
163  IfxSent_InterruptNodePointer_2, /**< \brief Specifies interrupt requested node 2 */
164  IfxSent_InterruptNodePointer_3, /**< \brief Specifies interrupt requested node 3 */
165  IfxSent_InterruptNodePointer_trigo0 = 4, /**< \brief Specifies interrupt requested node TRIGO 0 */
166  IfxSent_InterruptNodePointer_trigo1, /**< \brief Specifies interrupt requested node TRIGO 1 */
167  IfxSent_InterruptNodePointer_trigo2, /**< \brief Specifies interrupt requested node TRIGO 2 */
168  IfxSent_InterruptNodePointer_trigo3, /**< \brief Specifies interrupt requested node TRIGO 3 */
169  IfxSent_InterruptNodePointer_trigo4, /**< \brief Specifies interrupt requested node TRIGO 4 */
170  IfxSent_InterruptNodePointer_trigo5 /**< \brief Specifies interrupt requested node TRIGO 5 */
172 
173 /** \brief SENT.CH[channelId].VIEW.RDNPy( y=0,1,..7 ).Specifies receive data target nibble pointer
174  */
175 typedef enum
176 {
177  IfxSent_Nibble_0 = 0, /**< \brief Specifies receive data target nibble pointer to nibble 0 */
178  IfxSent_Nibble_1, /**< \brief Specifies receive data target nibble pointer to nibble 1 */
179  IfxSent_Nibble_2, /**< \brief Specifies receive data target nibble pointer to nibble 2 */
180  IfxSent_Nibble_3, /**< \brief Specifies receive data target nibble pointer to nibble 3 */
181  IfxSent_Nibble_4, /**< \brief Specifies receive data target nibble pointer to nibble 4 */
182  IfxSent_Nibble_5, /**< \brief Specifies receive data target nibble pointer to nibble 5 */
183  IfxSent_Nibble_6, /**< \brief Specifies receive data target nibble pointer to nibble 6 */
184  IfxSent_Nibble_7 /**< \brief Specifies receive data target nibble pointer to nibble 7 */
186 
187 /** \brief Enable/disable the sensitivity of the module to sleep signal\n
188  * Definition in Ifx_SENT.CLC.B.EDIS
189  */
190 typedef enum
191 {
192  IfxSent_SleepMode_enable = 0, /**< \brief enables sleep mode */
193  IfxSent_SleepMode_disable = 1 /**< \brief disables sleep mode */
195 
196 /** \brief Specifies the SENT SPC operational mode
197  */
198 typedef enum
199 {
200  IfxSent_SpcMode_sync = 0, /**< \brief Specifies synchronous SPC mode */
201  IfxSent_SpcMode_range = 1, /**< \brief Specifies range selection SPC mode */
202  IfxSent_SpcMode_bidirectional = 2 /**< \brief Specifies bidirectional transmit SPC mode */
204 
205 /** \brief SENT.CH[channelId].SCR.BASE, Specifies selection of pulse based on time
206  */
207 typedef enum
208 {
209  IfxSent_TimeBase_measuredFrequency = 0, /**< \brief Specifies selection of pulse based on measured frequency */
210  IfxSent_TimeBase_nominalFrequency = 1 /**< \brief Specifies selection of pulse based on nomianl frequency */
212 
213 /** \brief SENT.CH[channelId].SCR.TRIG, Specifies trigger source for pulse generation
214  */
215 typedef enum
216 {
217  IfxSent_TriggerSource_off = 0, /**< \brief Specifies no pulse generation */
218  IfxSent_TriggerSource_immediate = 1, /**< \brief Specifies immediate pulse generation */
219  IfxSent_TriggerSource_fallingEdge = 2, /**< \brief Specifies pulse generation at fallingEdge */
220  IfxSent_TriggerSource_externalTrigger = 3 /**< \brief Specifies pulse generation after each external trigger */
222 
223 /** \} */
224 
225 /** \addtogroup IfxLld_Sent_Std_Configuration
226  * \{ */
227 
228 /******************************************************************************/
229 /*-------------------------Inline Function Prototypes-------------------------*/
230 /******************************************************************************/
231 
232 /** \brief Sets the operation mode of SENT kernel
233  * \param sent base address of the SENT register space
234  * \param channelId SENT channel number
235  * \param alternateInput alternate input/output pin for SENT operation
236  * \return None
237  */
238 IFX_INLINE void IfxSent_setAltiInput(Ifx_SENT *sent, IfxSent_ChannelId channelId, IfxSent_AlternateInput alternateInput);
239 
240 /** \brief Set the module time stamp pre-divider
241  * \param sent base address of the SENT register space
242  * \param timeStampPreDivider time stamp pre-divider value
243  * \return None
244  */
245 IFX_INLINE void IfxSent_setTimeStampPredivider(Ifx_SENT *sent, uint32 timeStampPreDivider);
246 
247 /** \} */
248 
249 /** \addtogroup IfxLld_Sent_Std_Interrupts
250  * \{ */
251 
252 /******************************************************************************/
253 /*-------------------------Inline Function Prototypes-------------------------*/
254 /******************************************************************************/
255 
256 /** \brief Copies the current interrupt flags into the Ifx_SENT_CH_INTSTAT structure, and clears the flags in hardware.
257  *
258  * This function should be used in an ISR to retrieve the events which triggered the interrupt.
259  * \param sent base address of the SENT register space
260  * \param channelId SENT channel number
261  * \return Interrupt flags which have been cleared.
262  */
263 IFX_INLINE Ifx_SENT_CH_INTSTAT IfxSent_getAndClearInterruptStatus(Ifx_SENT *sent, IfxSent_ChannelId channelId);
264 
265 /** \brief Gets the current channel status
266  * \param sent base address of the SENT register space
267  * \param channelId SENT channel number
268  * \return current channel interrupt status
269  */
270 IFX_INLINE Ifx_SENT_CH_INTSTAT IfxSent_getChannelInterruptStatus(Ifx_SENT *sent, IfxSent_ChannelId channelId);
271 
272 /** \brief gets the source for channel interrupt handler
273  * \param channelId SENT channel number
274  * \return interrupt source
275  */
276 IFX_INLINE volatile Ifx_SRC_SRCR *IfxSent_getChannelSrc(IfxSent_ChannelId channelId);
277 
278 /** \} */
279 
280 /** \addtogroup IfxLld_Sent_Std_Operative
281  * \{ */
282 
283 /******************************************************************************/
284 /*-------------------------Inline Function Prototypes-------------------------*/
285 /******************************************************************************/
286 
287 /** \brief Disable the channel with the channel number
288  * \param sent base address of the SENT register space
289  * \param channelId SENT channel number
290  * \return None
291  */
292 IFX_INLINE void IfxSent_disableChannel(Ifx_SENT *sent, IfxSent_ChannelId channelId);
293 
294 /** \brief Enable the channel with the channel number
295  * \param sent base address of the SENT register space
296  * \param channelId SENT channel number
297  * \return None
298  */
299 IFX_INLINE void IfxSent_enableChannel(Ifx_SENT *sent, IfxSent_ChannelId channelId);
300 
301 /** \brief Enable the SENT module
302  * \param sent base address of the SENT register space
303  * \return None
304  */
305 IFX_INLINE void IfxSent_enableModule(Ifx_SENT *sent);
306 
307 /** \brief Sets the sensitivity of the module to sleep signal
308  * \param sent pointer to SENT registers
309  * \param mode mode selection (enable / disable)
310  * \return None
311  */
312 IFX_INLINE void IfxSent_setSleepMode(Ifx_SENT *sent, IfxSent_SleepMode mode);
313 
314 /******************************************************************************/
315 /*-------------------------Global Function Prototypes-------------------------*/
316 /******************************************************************************/
317 
318 /** \brief Resets the SENT module
319  * \param sent base address of the SENT register space
320  * \return None
321  */
322 IFX_EXTERN void IfxSent_resetModule(Ifx_SENT *sent);
323 
324 /** \} */
325 
326 /** \addtogroup IfxLld_Sent_Std_Baudrate
327  * \{ */
328 
329 /******************************************************************************/
330 /*-------------------------Inline Function Prototypes-------------------------*/
331 /******************************************************************************/
332 
333 /** \brief Sets the channel fractional baudrate divider
334  * \param sent base address of the SENT register space
335  * \param channelId SENT channel number
336  * \param divider channel baudrate fractional divider
337  * \return None
338  */
339 IFX_INLINE void IfxSent_setChannelFractionalDivider(Ifx_SENT *sent, IfxSent_ChannelId channelId, uint16 divider);
340 
341 /** \brief Sets the channel baudrate pre-divider
342  * \param sent base address of the SENT register space
343  * \param channelId SENT channel number
344  * \param preDivider channel baudrate pre-divider
345  * \return None
346  */
347 IFX_INLINE void IfxSent_setChannelPreDivider(Ifx_SENT *sent, IfxSent_ChannelId channelId, uint16 preDivider);
348 
349 /******************************************************************************/
350 /*-------------------------Global Function Prototypes-------------------------*/
351 /******************************************************************************/
352 
353 /** \brief Returns the current module frequency in Hertz.
354  * \param sent base address of the SENT register space
355  * \return The current module frequency in Hertz
356  */
358 
359 /** \brief Initializes the desired unit time (f_tick) for the external SENT device connected to the given channel
360  * \param sent base address of the SENT register space
361  * \param channelId SENT channel number
362  * \param tUnit desired unit time (f_tick), e.g. 3E-6 for 3 uS
363  * \return None
364  */
365 IFX_EXTERN void IfxSent_initializeChannelUnitTime(Ifx_SENT *sent, IfxSent_ChannelId channelId, float32 tUnit);
366 
367 /** \brief Initialize and get the clock for SENT kernel
368  * \param sent base address of the SENT register space
369  * \param dividerMode Divider mode for clock output
370  * \param stepValue clock frequency for for module fractional divider
371  * \return None
372  */
373 IFX_EXTERN void IfxSent_initializeModuleClock(Ifx_SENT *sent, IfxSent_ClockDividerMode dividerMode, uint16 stepValue);
374 
375 /** \} */
376 
377 /** \addtogroup IfxLld_Sent_Std_IO
378  * \{ */
379 
380 /******************************************************************************/
381 /*-------------------------Inline Function Prototypes-------------------------*/
382 /******************************************************************************/
383 
384 /** \brief Initializes a SENT input
385  * \param sentIn the SENT Pin which should be configured
386  * \param inputMode the pin input mode which should be configured
387  * \return None
388  */
389 IFX_INLINE void IfxSent_initSentPin(const IfxSent_Sent_In *sentIn, IfxPort_InputMode inputMode);
390 
391 /** \brief Initializes a SPC output
392  * \param spcOut the SPC Pin which should be configured
393  * \param spcOutMode Port Output Mode
394  * \param padDriver the pad driver mode which should be configured
395  * \return None
396  */
397 IFX_INLINE void IfxSent_initSpcPin(const IfxSent_Spc_Out *spcOut, IfxPort_OutputMode spcOutMode, IfxPort_PadDriver padDriver);
398 
399 /** \} */
400 
401 /******************************************************************************/
402 /*-------------------------Global Function Prototypes-------------------------*/
403 /******************************************************************************/
404 
405 /** \brief Returns the current unit time (f_tick) of the given channel
406  * \param sent base address of the SENT register space
407  * \param channelId SENT channel number
408  * \return The current unit time in seconds
409  */
411 
412 /******************************************************************************/
413 /*---------------------Inline Function Implementations------------------------*/
414 /******************************************************************************/
415 
416 IFX_INLINE void IfxSent_disableChannel(Ifx_SENT *sent, IfxSent_ChannelId channelId)
417 {
418  sent->CH[channelId].RCR.B.CEN = 0;
419 }
420 
421 
422 IFX_INLINE void IfxSent_enableChannel(Ifx_SENT *sent, IfxSent_ChannelId channelId)
423 {
424  sent->CH[channelId].RCR.B.CEN = 1;
425 }
426 
427 
428 IFX_INLINE void IfxSent_enableModule(Ifx_SENT *sent)
429 {
430  sent->CLC.B.DISR = 0;
431 }
432 
433 
434 IFX_INLINE Ifx_SENT_CH_INTSTAT IfxSent_getAndClearInterruptStatus(Ifx_SENT *sent, IfxSent_ChannelId channelId)
435 {
436  Ifx_SENT_CH_INTSTAT interruptFlags;
437  interruptFlags.U = sent->CH[channelId].INTSTAT.U;
438  sent->CH[channelId].INTCLR.U = interruptFlags.U;
439  return interruptFlags;
440 }
441 
442 
443 IFX_INLINE Ifx_SENT_CH_INTSTAT IfxSent_getChannelInterruptStatus(Ifx_SENT *sent, IfxSent_ChannelId channelId)
444 {
445  Ifx_SENT_CH_INTSTAT interruptFlags;
446  interruptFlags.U = sent->CH[channelId].INTSTAT.U;
447  return interruptFlags;
448 }
449 
450 
451 IFX_INLINE volatile Ifx_SRC_SRCR *IfxSent_getChannelSrc(IfxSent_ChannelId channelId)
452 {
453  return &MODULE_SRC.SENT.SENT[0].SR[channelId];
454 }
455 
456 
458 {
459  IfxPort_setPinModeInput(sentIn->pin.port, sentIn->pin.pinIndex, inputMode);
461 }
462 
463 
465 {
466  IfxPort_setPinModeOutput(spcOut->pin.port, spcOut->pin.pinIndex, spcOutMode, spcOut->select);
467  IfxPort_setPinPadDriver(spcOut->pin.port, spcOut->pin.pinIndex, padDriver);
468 }
469 
470 
471 IFX_INLINE void IfxSent_setAltiInput(Ifx_SENT *sent, IfxSent_ChannelId channelId, IfxSent_AlternateInput alternateInput)
472 {
473  sent->CH[channelId].IOCR.B.ALTI = alternateInput;
474 }
475 
476 
478 {
479  sent->CH[channelId].CFDR.B.DIV = divider;
480 }
481 
482 
483 IFX_INLINE void IfxSent_setChannelPreDivider(Ifx_SENT *sent, IfxSent_ChannelId channelId, uint16 preDivider)
484 {
485  sent->CH[channelId].CPDR.B.PDIV = preDivider;
486 }
487 
488 
490 {
493  sent->CLC.B.EDIS = mode;
494  IfxScuWdt_setCpuEndinit(passwd);
495 }
496 
497 
498 IFX_INLINE void IfxSent_setTimeStampPredivider(Ifx_SENT *sent, uint32 timeStampPreDivider)
499 {
500  sent->TPD.B.TDIV = timeStampPreDivider;
501 }
502 
503 
504 #endif /* IFXSENT_H */