iLLD_TC27xD  1.0
IfxPsi5_Psi5.h
Go to the documentation of this file.
1 /**
2  * \file IfxPsi5_Psi5.h
3  * \brief PSI5 PSI5 details
4  * \ingroup IfxLld_Psi5
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_Psi5_Psi5_Usage How to use the PSI5 PSI5 Interface driver?
25  * \ingroup IfxLld_Psi5
26  *
27  * PSI5 communicates with the external world via one input/output line for each channel.
28  *
29  * In the following sections it will be described, how to integrate the driver into the application framework.
30  *
31  * \section IfxLld_Psi5_Psi5_Preparation Preparation
32  * \subsection IfxLld_Psi5_Psi5_Include Include Files
33  *
34  * Include following header file into your C code:
35  * \code
36  * #include <Psi5/Psi5/IfxPsi5_Psi5.h>
37  * \endcode
38  *
39  * \subsection IfxLld_Psi5_Psi5_Variables Variables
40  * //used globally
41  * \code
42  * IfxPsi5_Psi5_Channel psi5Channel[IFXPSI5_PINMAP_NUM_CHANNELS];
43  * \endcode
44  *
45  * \subsection IfxLld_Psi5_Psi5_Module Module Initialisation
46  * \code
47  * // create module config
48  * IfxPsi5_Psi5_Config psi5Config;
49  * IfxPsi5_Psi5_initModuleConfig(&psi5Config, &MODULE_PSI5);
50  *
51  * // initialize module
52  * IfxPsi5_Psi5 psi5;
53  * IfxPsi5_Psi5_initModule(&psi5, &psi5Config);
54  * \endcode
55  *
56  * \subsection IfxLld_Psi5_Psi5_Channel Channel Initialisation
57  * \code
58  * // create channel config
59  * IfxPsi5_Psi5_ChannelConfig psi5ChannelConfig;
60  * IfxPsi5_Psi5_initChannelConfig(&psi5ChannelConfig, &psi5);
61  *
62  * psi5ChannelConfig.watchdogTimerLimit[0] = 0x32; // initial delay before slot 0 starts
63  * psi5ChannelConfig.watchdogTimerLimit[1] = 0x90;
64  * psi5ChannelConfig.watchdogTimerLimit[2] = 0x10;
65  * psi5ChannelConfig.watchdogTimerLimit[3] = 0x10;
66  * psi5ChannelConfig.watchdogTimerLimit[4] = 0x10;
67  * psi5ChannelConfig.watchdogTimerLimit[5] = 0x10;
68  * psi5ChannelConfig.watchdogTimerLimit[6] = 0x10;
69  *
70  * for(int slot=0; slot<6; ++slot) {
71  * psi5ChannelConfig.receiveControl.payloadLength[slot] = 8;
72  * if( slot == 0 )
73  * psi5ChannelConfig.receiveControl.frameExpectation[slot] = IfxPsi5_FrameExpectation_expected;
74  * else
75  * psi5ChannelConfig.receiveControl.frameExpectation[slot] = IfxPsi5_FrameExpectation_notExpected;
76  * }
77  *
78  * // initialize channels
79  * for(int chn=0; chn<IFXPSI5_PINMAP_NUM_CHANNELS; ++chn) {
80  * psi5ChannelConfig.channelId = (IfxPsi5_ChannelId)chn;
81  *
82  * // TODO: currently no IOCRx.ALTI config field
83  * unsigned alti = 0;
84  *
85  * IfxPsi5_Psi5_PinsConfig pinsConfig;
86  * for(int module=0;module<IFXPSI5_PINMAP_NUM_MODULES;module++)
87  * {
88  * pinsConfig.in = IfxPsi5_Rx_In_pinTable[module][chn][alti];
89  * pinsConfig.inMode = IfxPort_InputMode_pullUp;
90  * pinsConfig.out = IfxPsi5_Tx_Out_pinTable[module][chn][alti];
91  * }
92  * pinsConfig.outMode = IfxPort_OutputMode_pushPull;
93  * pinsConfig.pinDriver = IfxPort_PadDriver_cmosAutomotiveSpeed1;
94  *
95  * psi5ChannelConfig.pinsConfig = &pinsConfig;
96  *
97  * IfxPsi5_Psi5_initChannel(&psi5Channel[chn], &psi5ChannelConfig);
98  * }
99  * \endcode
100  *
101  * \subsection IfxLld_Psi5_Psi5_readChannelFrame read channel frame
102  * \code
103  * for(int i=0; i<5; ++i) {
104  * for(int chn=0; chn<IFXPSI5_PINMAP_NUM_CHANNELS; ++chn) {
105  * IfxPsi5_Psi5_Frame frame;
106  *
107  * while( !IfxPsi5_Psi5_readChannelFrame(&psi5Channel[chn], &frame) );
108  *
109  * }
110  * }
111  * \endcode
112  *
113  * \defgroup IfxLld_Psi5_Psi5 PSI5
114  * \ingroup IfxLld_Psi5
115  * \defgroup IfxLld_Psi5_Psi5_Structures Data Structures
116  * \ingroup IfxLld_Psi5_Psi5
117  * \defgroup IfxLld_Psi5_Psi5_Module Module Initialisation functions
118  * \ingroup IfxLld_Psi5_Psi5
119  * \defgroup IfxLld_Psi5_Psi5_Channel Channel functions
120  * \ingroup IfxLld_Psi5_Psi5
121  * \defgroup IfxLld_Psi5_Psi5_Clock Clock Intialisation functions
122  * \ingroup IfxLld_Psi5_Psi5
123  */
124 
125 #ifndef IFXPSI5_PSI5_H
126 #define IFXPSI5_PSI5_H 1
127 
128 /******************************************************************************/
129 /*----------------------------------Includes----------------------------------*/
130 /******************************************************************************/
131 
132 #include "Psi5/Std/IfxPsi5.h"
133 #include "Scu/Std/IfxScuCcu.h"
134 #include "IfxPsi5_bf.h"
135 
136 /******************************************************************************/
137 /*-----------------------------Data Structures--------------------------------*/
138 /******************************************************************************/
139 
140 /** \addtogroup IfxLld_Psi5_Psi5_Structures
141  * \{ */
142 /** \brief PSI5 handle data structure
143  */
144 typedef struct
145 {
146  Ifx_PSI5 *psi5; /**< \brief Specifies the pointer to the PSI5 module registers */
147 } IfxPsi5_Psi5;
148 
149 /** \brief channel trigger configuration structure
150  */
151 typedef struct
152 {
153  uint32 channelTriggerValue; /**< \brief Specifies the channel trigger value CTV */
154  uint32 channelTriggerCounter; /**< \brief Specifies the channel trigger counter */
156 
157 /** \brief Clock configuration data structure
158  */
159 typedef struct
160 {
161  uint32 frequency; /**< \brief Specifies the frequency for the clock */
162  IfxPsi5_DividerMode mode; /**< \brief Specifies the mode of division for the clock */
163  IfxPsi5_ClockType type; /**< \brief Specifies the type of clock (fracDiv / slow 125kHz / fast 189 kHz / timestamp) */
165 
166 /** \brief Psi5 frame data structure with individual members
167  */
168 typedef struct
169 {
170  uint8 crcError : 1; /**< \brief Crc error flag */
171  uint8 crc : 3; /**< \brief Received crc */
172  uint32 readData : 28; /**< \brief Received data */
173  uint32 timestamp : 24; /**< \brief Timestamp */
174  uint8 slotCounter : 3; /**< \brief Slot counter */
175  uint8 timeslotError : 1; /**< \brief Time slot error flag */
176  uint8 numberOfBitsError : 1; /**< \brief Number of bits error flag */
177  uint8 messagingBitsError : 1; /**< \brief Messaging bits error flag */
178  uint8 noFrameReceivedError : 1; /**< \brief No frame received flag */
179  uint8 receiveMemoryOverflowError : 1; /**< \brief Receive buffer overflow error flag */
181 
182 /** \brief Input output configuration structure
183  */
184 typedef struct
185 {
186  boolean outputInverterEnabled; /**< \brief Specifies the pulse polarity of the output */
187  boolean inputInverterEnabled; /**< \brief Specifies the pulse polarity of the input */
188  IfxPsi5_DigitalInputFilterDepth digitalInputFilterDepth; /**< \brief Specifies the the number of port input samples considered for floating average */
190 
191 /** \brief Psi5 serial message with individual members
192  */
193 typedef struct
194 {
195  uint16 serialData : 16; /**< \brief Serial message data */
196  uint8 messageId : 8; /**< \brief Serial message Id */
197  uint8 crc : 6; /**< \brief Serial message crc */
198  uint8 serialMessageCRCFailedError : 1; /**< \brief Serial message crc error flag */
199  uint8 configuration : 1; /**< \brief Serial message configuration */
201 
202 /** \brief Sync pulse generation configuration structure
203  */
204 typedef struct
205 {
206  uint32 pulseLength; /**< \brief Specifies the standard pulse width without data coding for standard pulse width or for coding a '0' */
207  uint32 delayLength; /**< \brief Specifies the additional length of the pulse width for coding a '1' */
208  IfxPsi5_TimeBase timeBaseSelect; /**< \brief Specifies the clock source for CTV as internal or external */
209  IfxPsi5_Trigger externalTimeBaseSelect; /**< \brief Specifies the clock source for CTV in the case of external */
210  IfxPsi5_TriggerType periodicOrExternalOrBypass; /**< \brief Specifies whether periodic trigger or external trigger or bypass is selected */
211  IfxPsi5_Trigger externalTriggerSelect; /**< \brief Specifies the trigger source in case of external triggerring */
212  uint32 blankoutTime; /**< \brief Specifies the duration of blank out period */
214 
215 /** \brief Psi5 frame in double word format
216  */
217 typedef struct
218 {
219  uint32 lowWord; /**< \brief Lower 32 bits of the Psi5 frame */
220  uint32 highWord; /**< \brief Upper 32 bits of the Psi5 frame */
222 
223 /** \brief Psi5 serial message as unsigned 32 bit value
224  */
225 typedef struct
226 {
227  uint32 value; /**< \brief 32 bit value of the Psi5 serial message */
229 
230 /** \brief Receive control configuration structure
231  */
232 typedef struct
233 {
234  boolean asynchronousModeSelected; /**< \brief Specifies the asynchronous mode of operation */
235  uint32 fifoWarningLevel; /**< \brief Specifies the fifo warning level */
236  uint32 payloadLength[IFXPSI5_NUM_SLOTS]; /**< \brief Specifies the payload length for the slots 0 to 5 */
237  IfxPsi5_Verbose verboseForAsynchronousMode; /**< \brief Specifies the verbose mode selection in asynchronous mode of operation */
238  IfxPsi5_MessagingBits messagingBitsPresence[IFXPSI5_NUM_SLOTS]; /**< \brief Specifies the presence or absence of messaging bits in the slots 0 to 5 */
239  IfxPsi5_CRCorParity crcOrParity[IFXPSI5_NUM_SLOTS]; /**< \brief Specifies the crc or parity selection for the slots 0 to 5 */
240  IfxPsi5_FrameExpectation frameExpectation[IFXPSI5_NUM_SLOTS]; /**< \brief Specifies whether the frame is expected or not in the slots 0 to 5 */
241  IfxPsi5_Verbose verbose[IFXPSI5_NUM_SLOTS]; /**< \brief Specifies the verbose is enabled or disabled for the slots 0 to 5 */
242  IfxPsi5_BaudRate baudrateSelect; /**< \brief Specifies the baudrate selection */
243  IfxPsi5_TimestampRegister pulseTimestampSelect; /**< \brief Specifies the timestamp register selection for pulses */
244  IfxPsi5_TimestampRegister frameTimestampSelect; /**< \brief Specifies the timestamp register selection for start of frames */
245  IfxPsi5_ReceiveDataRegisterTimestamp receiveDataRegisterTimestamp; /**< \brief Specifies the pulse or start of frame based timestamp to be stored in receive data register RDRH */
247 
248 /** \brief Timestamp configuration data structure
249  */
250 typedef struct
251 {
252  IfxPsi5_Trigger externalTimeBaseSelect; /**< \brief Specifies the clock base for counter CTS in the case of external */
253  IfxPsi5_TimeBase timeBaseSelect; /**< \brief Specifies the clock source for CTS as internal or external */
255 
256 /** \brief Transmit control configuration structure
257  */
258 typedef struct
259 {
260  boolean enhancedProtocolSelected; /**< \brief Specifies whether the enhanced protocol is selected or not */
261  boolean bitStuffingEnabled; /**< \brief Specifies whether the bit stuffing is turned on or not */
262  boolean crcGenerationEnabled; /**< \brief Specifies whether the crc generation is turned on or not */
263  boolean startSequenceGenerationEnabled; /**< \brief Specifies whether the start sequence generation is turned on or not */
264  boolean inhibitingAutomaticTransferEnabled; /**< \brief Specifies whether automatic transfer from the shift registers SSRL/H to SORL/H is inhibited or not */
265  uint32 payloadLength; /**< \brief Specifies the payload length to be sent */
266  uint32 ssrPayloadLength; /**< \brief Specifies the payload length of SSR */
267  uint32 sorPayloadLength; /**< \brief Specifies the payload length of SOR */
269 
270 /** \} */
271 
272 /** \brief Pin Configuration structure
273  */
274 typedef struct
275 {
276  const IfxPsi5_Rx_In *in; /**< \brief The RX Pin which should be configured */
277  IfxPort_InputMode inMode; /**< \brief The pin input mode which should be configured */
278  const IfxPsi5_Tx_Out *out; /**< \brief The TX Pin which should be configured */
279  IfxPort_OutputMode outMode; /**< \brief The pin output mode which should be configured */
280  IfxPort_PadDriver pinDriver; /**< \brief The pad driver mode which should be configured */
282 
283 /** \addtogroup IfxLld_Psi5_Psi5_Structures
284  * \{ */
285 /** \brief Channel handle data structure
286  */
287 typedef struct
288 {
289  IfxPsi5_Psi5 *module; /**< \brief The PSI5 handle structure */
290  Ifx_PSI5_CH *channel; /**< \brief Pointer to the channel registers */
291  IfxPsi5_ChannelId channelId; /**< \brief Specifies the channel index */
293 
294 /** \brief Channel configuration structure
295  */
296 typedef struct
297 {
298  const IfxPsi5_Psi5 *module; /**< \brief Specifies pointer to the IfxPsi5_Psi5 module handle */
299  uint32 watchdogTimerLimit[IFXPSI5_NUM_WDTS]; /**< \brief Specifies the watchdog timer limit for each of the slots 0 to 6 */
300  IfxPsi5_ChannelId channelId; /**< \brief Specifies the channel index */
301  IfxPsi5_Psi5_PulseGeneration pulseGeneration; /**< \brief Specifies the configuration for sync pulse generation */
302  IfxPsi5_Psi5_ChannelTrigger channelTrigger; /**< \brief Specifies the configuration for channel trigger */
303  IfxPsi5_Psi5_ReceiveControl receiveControl; /**< \brief Specifies the configuration for reception */
304  IfxPsi5_Psi5_TransmitControl sendControl; /**< \brief Specifies the configuration for transmission */
305  IfxPsi5_Psi5_InputOutputControl inputOutputControl; /**< \brief Specifies the configuration for input output control */
306  const IfxPsi5_Psi5_PinsConfig *pinsConfig; /**< \brief Pin Configuration structure */
308 
309 /** \brief PSI5 module configuration structure
310  */
311 typedef struct
312 {
313  Ifx_PSI5 *psi5; /**< \brief Specifies the pointer to the PSI5 module registers */
314  IfxPsi5_Psi5_Clock fracDiv; /**< \brief Specifies fractionally divided clock properties */
315  IfxPsi5_Psi5_Clock slowClock; /**< \brief Specifies the slower f125 clock properties */
316  IfxPsi5_Psi5_Clock fastClock; /**< \brief Specifies the faster f189 clock properties */
317  IfxPsi5_Psi5_Clock timestampClock; /**< \brief Specifies the time stamp clock properties */
318  IfxPsi5_Psi5_TimeStampConfig timestampCounterA; /**< \brief Specifies the time stamp counter A properties */
319  IfxPsi5_Psi5_TimeStampConfig timestampCounterB; /**< \brief Specifies the time stamp counter B properties */
320  IfxPsi5_Psi5_TimeStampConfig timestampCounterC; /**< \brief Specifies the time stamp counter C properties */
322 
323 /** \brief Psi5 frame data union
324  */
325 typedef union
326 {
327  IfxPsi5_Psi5_Rdm rdm; /**< \brief Psi5 frame in double word format */
328  IfxPsi5_Psi5_FrameData frame; /**< \brief Psi5 frame data structure with individual members */
330 
331 /** \brief Psi5 serial message data structure
332  */
333 typedef union
334 {
335  IfxPsi5_Psi5_Rds rds; /**< \brief Psi5 serial message as unsigned 32 bit value */
336  IfxPsi5_Psi5_Message message; /**< \brief Psi5 serial message with individual members */
338 
339 /** \brief startup related options TBD
340  */
341 typedef struct
342 {
343  uint8 a : 1; /**< \brief TBD */
344  uint32 b : 31; /**< \brief TBD */
346 
347 /** \} */
348 
349 /** \addtogroup IfxLld_Psi5_Psi5_Module
350  * \{ */
351 
352 /******************************************************************************/
353 /*-------------------------Global Function Prototypes-------------------------*/
354 /******************************************************************************/
355 
356 /** \brief Resets the PSI5 module
357  * \param psi5 pointer to the PSI5 module
358  * \return None
359  */
361 
362 /** \brief Initialise the PSI5 with the supplied configureation
363  * \param psi5 pointer to the PSI5 module
364  * \param config pointer to the PSI5 configuration
365  * \return return TRUE on success & FALSE if configuration not valid
366  *
367  * A coding example can be found in \ref IfxLld_Psi5_Psi5_Usage
368  *
369  */
371 
372 /** \brief Initialise buffer with default PSI5 configuration
373  * \param config pointer to the PSI5 module configuration
374  * \param psi5 base address of the PSI5 register space
375  * \return None
376  *
377  * A coding example can be found in \ref IfxLld_Psi5_Psi5_Usage
378  *
379  */
380 IFX_EXTERN void IfxPsi5_Psi5_initModuleConfig(IfxPsi5_Psi5_Config *config, Ifx_PSI5 *psi5);
381 
382 /** \} */
383 
384 /** \addtogroup IfxLld_Psi5_Psi5_Channel
385  * \{ */
386 
387 /******************************************************************************/
388 /*-------------------------Inline Function Prototypes-------------------------*/
389 /******************************************************************************/
390 
391 /** \brief start the channel with the selected options
392  * \param channel pointer to the PSI5 channel
393  * \param options startup related options
394  * \return TRUE if successful; FALSE otherwise
395  *
396  * A coding example can be found in \ref IfxLld_Psi5_Psi5_Usage
397  *
398  */
400 
401 /******************************************************************************/
402 /*-------------------------Global Function Prototypes-------------------------*/
403 /******************************************************************************/
404 
405 /** \brief Initialize the channel with the supplied configuration
406  * \param channel pointer to the PSI5 channel
407  * \param config pointer to the PSI5 channel configuration
408  * \return TRUE on success & FALSE if configuration not valid
409  *
410  * A coding example can be found in \ref IfxLld_Psi5_Psi5_Usage
411  *
412  */
414 
415 /** \brief Get the current channel configuration (e.g. sample settings)
416  * \param config pointer to the PSI5 channel configuration
417  * \param psi5 pointer to the PSI5 module
418  * \return None
419  *
420  * A coding example can be found in \ref IfxLld_Psi5_Psi5_Usage
421  *
422  */
424 
425 /** \brief Gets the received psi5 frame for the channel
426  * \param channel pointer to the PSI5 channel
427  * \param frame pointer to the PSI5 frame buffer
428  * \return TRUE if successful; FALSE if no frame available
429  *
430  * A coding example can be found in \ref IfxLld_Psi5_Psi5_Usage
431  *
432  */
434 
435 /** \brief Get the received serial message for the channel
436  * \param channel pointer to the PSI5 channel
437  * \param slot Slot Id
438  * \param message pointer to the PSI5 serial message buffer
439  * \return TRUE if successful; FALSE if no serial message available
440  */
442 
443 /** \brief Transmit the data through the channel
444  * \param channel pointer to the PSI5 channel
445  * \param data data to be sent
446  * \return TRUE if successful; FALSE otherwise
447  *
448  * A coding example can be found in \ref IfxLld_Psi5_Psi5_Usage
449  *
450  */
452 
453 /** \} */
454 
455 /******************************************************************************/
456 /*---------------------Inline Function Implementations------------------------*/
457 /******************************************************************************/
458 
460 {
461  return TRUE;
462 }
463 
464 
465 #endif /* IFXPSI5_PSI5_H */