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