iLLD_TC27xD  1.0
IfxEth.h
Go to the documentation of this file.
1 /**
2  * \file IfxEth.h
3  * \brief ETH basic functionality
4  * \ingroup IfxLld_Eth
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_Eth_Std_DataStructures Data Structures
25  * \ingroup IfxLld_Eth_Std
26  * \defgroup IfxLld_Eth_Std_Unions Unions
27  * \ingroup IfxLld_Eth_Std
28  * \defgroup IfxLld_Eth_Std_Configuration Configuration Functions
29  * \ingroup IfxLld_Eth_Std
30  * \defgroup IfxLld_Eth_Std_Utility Utility Functions
31  * \ingroup IfxLld_Eth_Std
32  * \defgroup IfxLld_Eth_Std_Initialisation Initialisation Functions
33  * \ingroup IfxLld_Eth_Std
34  * \defgroup IfxLld_Eth_Std_Enum Enumerations
35  * \ingroup IfxLld_Eth_Std
36  */
37 
38 #ifndef IFXET_H
39 #define IFXET_H 1
40 
41 /******************************************************************************/
42 /*----------------------------------Includes----------------------------------*/
43 /******************************************************************************/
44 
45 #include "_Impl/IfxEth_cfg.h"
46 #include "Cpu/Std/Ifx_Types.h"
47 #include "IfxEth_reg.h"
48 #include "IfxEth_bf.h"
49 #include "_PinMap/IfxEth_PinMap.h"
50 #include "Src/Std/IfxSrc.h"
51 #include "Scu/Std/IfxScuWdt.h"
52 #include "_Utilities/Ifx_Assert.h"
53 #include "Cpu/Std/IfxCpu.h"
54 
55 /******************************************************************************/
56 /*-----------------------------------Macros-----------------------------------*/
57 /******************************************************************************/
58 
59 /** \brief Size of one ethernet frame buffer
60  */
61 #ifndef IFXETH_RTX_BUFFER_SIZE
62 #define IFXETH_RTX_BUFFER_SIZE 1536
63 #endif
64 
65 #ifndef IFXETH_TX_BUFFER_BY_USER
66 #define IFXETH_TX_BUFFER_BY_USER 0
67 #endif
68 
69 #ifndef IFXETH_RX_BUFFER_BY_USER
70 #define IFXETH_RX_BUFFER_BY_USER 0
71 #endif
72 
73 /** \brief Rx buffers (ring mode)
74  */
75 #ifndef IFXETH_MAX_RX_BUFFERS
76 #define IFXETH_MAX_RX_BUFFERS 8
77 #endif
78 
79 /** \brief Tx buffers (ring mode)
80  */
81 #ifndef IFXETH_MAX_TX_BUFFERS
82 #define IFXETH_MAX_TX_BUFFERS 16
83 #endif
84 
85 /** \brief 4 DWORDS (16 bytes)
86  */
87 #define IFXETH_DESCR_SIZE 4
88 
89 /******************************************************************************/
90 /*--------------------------------Enumerations--------------------------------*/
91 /******************************************************************************/
92 
93 /** \addtogroup IfxLld_Eth_Std_Enum
94  * \{ */
95 typedef enum
96 {
102 
103 /** \brief External Phy Interface RMII Mode
104  */
105 typedef enum
106 {
107  IfxEth_PhyInterfaceMode_mii, /**< \brief MII mode */
108  IfxEth_PhyInterfaceMode_rmii /**< \brief RMII mode */
110 
111 /** \brief indicates the Receive DMA FSM state
112  */
113 typedef enum
114 {
115  IfxEth_ReceiveProcessState_reset, /**< \brief Stopped: Reset or Stop Receive Command issued */
116  IfxEth_ReceiveProcessState_fetching, /**< \brief Running: Fetching Receive Transfer Descriptor */
117  IfxEth_ReceiveProcessState_none, /**< \brief Reserved for future use */
118  IfxEth_ReceiveProcessState_waiting, /**< \brief Running: Waiting for receive packet */
119  IfxEth_ReceiveProcessState_suspended, /**< \brief Suspended: Receive Descriptor Unavailable */
120  IfxEth_ReceiveProcessState_closing, /**< \brief Running: Closing Receive Descriptor */
121  IfxEth_ReceiveProcessState_timestampWrite, /**< \brief TIME_STAMP write state */
122  IfxEth_ReceiveProcessState_transfering /**< \brief Running: Transferring the receive packet data from receive buffer to host memory */
124 
125 /** \brief indicates the Transmit DMA FSM state
126  */
127 typedef enum
128 {
129  IfxEth_TransmitProcessState_reset, /**< \brief Stopped; Reset or Stop Transmit Command issued */
130  IfxEth_TransmitProcessState_fetching, /**< \brief Running; Fetching Transmit Transfer Descriptor */
131  IfxEth_TransmitProcessState_waiting, /**< \brief Running; Waiting for status */
132  IfxEth_TransmitProcessState_reading, /**< \brief Running; Reading Data from host memory buffer and queuing it to transmit buffer (Tx FIFO) */
133  IfxEth_TransmitProcessState_timestampWrite, /**< \brief TIME_STAMP write state */
134  IfxEth_TransmitProcessState_none, /**< \brief Reserved for future use */
135  IfxEth_TransmitProcessState_suspended, /**< \brief Suspended; Transmit Descriptor Unavailable or Transmit Buffer Underflow */
136  IfxEth_TransmitProcessState_closing /**< \brief Running; Closing Transmit Descriptor */
138 
139 /** \} */
140 
141 /******************************************************************************/
142 /*-----------------------------Data Structures--------------------------------*/
143 /******************************************************************************/
144 
145 /** \addtogroup IfxLld_Eth_Std_DataStructures
146  * \{ */
147 /** \brief Structure for Alternate/Enhanced RX descriptor DWORD 0 Bit field access
148  */
149 typedef struct
150 {
151  uint32 ext : 1; /**< \brief Extended Status Available/Rx MAC Address */
152  uint32 CE : 1; /**< \brief CRC Error */
153  uint32 DBE : 1; /**< \brief Dribble Bit Error */
154  uint32 RE : 1; /**< \brief Receive Error */
155  uint32 RWT : 1; /**< \brief Receive Watchdog Timeout */
156  uint32 FT : 1; /**< \brief Frame Type */
157  uint32 LC : 1; /**< \brief Late Collision */
158  uint32 IPC : 1; /**< \brief IPC Checksum Error/Giant Frame */
159  uint32 LS : 1; /**< \brief Last Descriptor */
160  uint32 FS : 1; /**< \brief First Descriptor */
161  uint32 VLAN : 1; /**< \brief VLAN Tag */
162  uint32 OE : 1; /**< \brief Overflow Error */
163  uint32 LE : 1; /**< \brief Length Error */
164  uint32 SAF : 1; /**< \brief Source Address Filter Fail */
165  uint32 DE : 1; /**< \brief Descriptor Error */
166  uint32 ES : 1; /**< \brief Error Summary, ES = PCE | CE | RE | RWT | LC | IPC | OE | DE */
167  uint32 FL : 14; /**< \brief Frame Length */
168  uint32 AFM : 1; /**< \brief Destination Address Filter Fail */
169  uint32 OWN : 1; /**< \brief Own Bit, 1 = own by DMA */
171 
172 /** \brief Structure for Alternate/Enhanced RX descriptor DWORD 1 Bit field access
173  */
174 typedef struct
175 {
176  uint32 RBS1 : 13; /**< \brief Receive Buffer 1 Size */
177  uint32 resv1 : 1; /**< \brief reserved */
178  uint32 RCH : 1; /**< \brief Second Address Chained */
179  uint32 RER : 1; /**< \brief Receive End of Ring */
180  uint32 RBS2 : 13; /**< \brief Receive Buffer 2 Size */
181  uint32 resv : 2; /**< \brief reserved) */
182  uint32 DIC : 1; /**< \brief Disable Interrupt on Completion */
184 
185 /** \brief Structure for Alternate/Enhanced TX descriptor DWORD 0 Bit field access
186  */
187 typedef struct
188 {
189  uint32 DB : 1; /**< \brief Deferred bit */
190  uint32 UF : 1; /**< \brief Underflow error */
191  uint32 ED : 1; /**< \brief Excessive deferral */
192  uint32 CC : 4; /**< \brief Collision count */
193  uint32 VLAN : 1; /**< \brief VLAN TAG */
194  uint32 EC : 1; /**< \brief Excessive Collision */
195  uint32 LC : 1; /**< \brief Late Collision */
196  uint32 NC : 1; /**< \brief No Carrier */
197  uint32 LOC : 1; /**< \brief Loss of Carrier */
198  uint32 PCE : 1; /**< \brief Payload Checksum Error */
199  uint32 FF : 1; /**< \brief Frame Flushed */
200  uint32 JT : 1; /**< \brief Jabber Timeout */
201  uint32 ES : 1; /**< \brief Error Summary, ES = JT | FF | LOC | NC | LC | EC | ED | UF */
202  uint32 IHE : 1; /**< \brief IP Header Error */
203  uint32 TTSS : 1; /**< \brief Transmit Time Stamp Status */
204  uint32 resv : 2; /**< \brief (reserved) */
205  uint32 TCH : 1; /**< \brief Second Address Chained */
206  uint32 TER : 1; /**< \brief Transmit End of Ring */
207  uint32 CIC : 2; /**< \brief Checksum Insertion Control */
208  uint32 resv1 : 1; /**< \brief (Reserved) */
209  uint32 TTSE : 1; /**< \brief Transmit Time Stamp Enable */
210  uint32 DP : 1; /**< \brief Disable Padding */
211  uint32 DC : 1; /**< \brief Disable CRC */
212  uint32 FS : 1; /**< \brief First Segment */
213  uint32 LS : 1; /**< \brief Last Segment */
214  uint32 IC : 1; /**< \brief Interrupt on Completion */
215  uint32 OWN : 1; /**< \brief Own Bit, 1 = own by DMA */
217 
218 /** \brief Structure for Alternate/Enhanced TX descriptor DWORD 1 Bit field access
219  */
220 typedef struct
221 {
222  uint32 TBS1 : 13; /**< \brief Transmit Buffer 1 Size */
223  uint32 resv1 : 3; /**< \brief (reserved) */
224  uint32 TBS2 : 13; /**< \brief Transmit Buffer 2 Size */
225  uint32 resv2 : 3; /**< \brief (reserved) */
227 
228 /** \} */
229 
230 /** \addtogroup IfxLld_Eth_Std_Unions
231  * \{ */
232 /** \brief Union for RX descriptor DWORD 0
233  */
234 typedef union
235 {
236  IfxEth_AltRxDescr0_Bits A; /**< \brief Structure for RX descriptor DWORD 0 Bit field access */
237  uint32 U; /**< \brief Unsigned long access */
239 
240 /** \brief Union for RX descriptor DWORD 1
241  */
242 typedef union
243 {
244  IfxEth_AltRxDescr1_Bits A; /**< \brief Structure for RX descriptor DWORD 1 Bit field access */
245  uint32 U; /**< \brief unsigned long access */
247 
248 /** \brief Union for RX descriptor DWORD 2
249  */
250 typedef union
251 {
252  uint32 U; /**< \brief unsigned long access */
254 
255 /** \brief Union for RX descriptor DWORD 3
256  */
257 typedef union
258 {
259  uint32 U; /**< \brief unsigned long access */
261 
262 /** \brief Union for TX descriptor DWORD 0
263  */
264 typedef union
265 {
266  IfxEth_AltTxDescr0_Bits A; /**< \brief Structure for TX descriptor DWORD 0 Bit field access */
267  uint32 U; /**< \brief Unsigned long access */
269 
270 /** \brief Union for TX descriptor DWORD 1
271  */
272 typedef union
273 {
274  IfxEth_AltTxDescr1_Bits A; /**< \brief Structure for RX descriptor DWORD 1 Bit field access */
275  uint32 U; /**< \brief unsigned long access */
277 
278 /** \brief Union for TX descriptor DWORD 2
279  */
280 typedef union
281 {
282  uint32 U; /**< \brief unsigned long access */
284 
285 /** \brief Union for TX descriptor DWORD 3
286  */
287 typedef union
288 {
289  uint32 U; /**< \brief unsigned long access */
291 
292 /** \} */
293 
294 /** \addtogroup IfxLld_Eth_Std_DataStructures
295  * \{ */
296 /** \brief Normal RX descriptor
297  */
298 typedef struct
299 {
300  IfxEth_RxDescr0 RDES0; /**< \brief RX descriptor DWORD 0 */
301  IfxEth_RxDescr1 RDES1; /**< \brief RX descriptor DWORD 1 */
302  IfxEth_RxDescr2 RDES2; /**< \brief RX descriptor DWORD 2 */
303  IfxEth_RxDescr3 RDES3; /**< \brief RX descriptor DWORD 3 */
305 
306 /** \brief Normal TX descriptor
307  */
308 typedef struct
309 {
310  IfxEth_TxDescr0 TDES0; /**< \brief TX descriptor DWORD 0 */
311  IfxEth_TxDescr1 TDES1; /**< \brief TX descriptor DWORD 1 */
312  IfxEth_TxDescr2 TDES2; /**< \brief TX descriptor DWORD 2 */
313  IfxEth_TxDescr3 TDES3; /**< \brief TX descriptor DWORD 3 */
315 
316 /** \} */
317 
318 /** \addtogroup IfxLld_Eth_Std_DataStructures
319  * \{ */
320 /** \brief Port pins for MII mode configuration
321  */
322 typedef struct
323 {
324  IfxEth_Crs_In *crs; /**< \brief pointer to CRS input pin config */
325  IfxEth_Col_In *col; /**< \brief pointer to COL input pin config */
326  IfxEth_Txclk_In *txClk; /**< \brief Pointer to TXCLK input pin config */
327  IfxEth_Rxclk_In *rxClk; /**< \brief Pointer to RXCLK input pin config */
328  IfxEth_Rxdv_In *rxDv; /**< \brief Pointer to RXDV input pin config */
329  IfxEth_Rxer_In *rxEr; /**< \brief Pointer to RXER input pin config */
330  IfxEth_Rxd_In *rxd0; /**< \brief Pointer to RXD0 input pin config */
331  IfxEth_Rxd_In *rxd1; /**< \brief Pointer to RXD1 input pin config */
332  IfxEth_Rxd_In *rxd2; /**< \brief Pointer to RXD2 input pin config */
333  IfxEth_Rxd_In *rxd3; /**< \brief Pointer to RXD3 input pin config */
334  IfxEth_Txen_Out *txEn; /**< \brief Pointer to TXEN output pin config */
335  IfxEth_Txer_Out *txEr; /**< \brief Pointer to TXER output pin config */
336  IfxEth_Txd_Out *txd0; /**< \brief Pointer to TXD0 output pin config */
337  IfxEth_Txd_Out *txd1; /**< \brief Pointer to TXD1 output pin config */
338  IfxEth_Txd_Out *txd2; /**< \brief Pointer to TXD2 output pin config */
339  IfxEth_Txd_Out *txd3; /**< \brief Pointer to TXD3 output pin config */
341 
342 /** \brief Port pins for RMII mode configuration
343  */
344 typedef struct
345 {
346  IfxEth_Crsdv_In *crsDiv; /**< \brief pointer to CRSDIV input pin config */
347  IfxEth_Refclk_In *refClk; /**< \brief Pointer to REFCLK input pin config */
348  IfxEth_Rxd_In *rxd0; /**< \brief Pointer to RXD0 input pin config */
349  IfxEth_Rxd_In *rxd1; /**< \brief Pointer to RXD1 input pin config */
350  IfxEth_Mdc_Out *mdc; /**< \brief Pointer to MDC output pin config */
351  IfxEth_Mdio_InOut *mdio; /**< \brief Pointer to MDIO pin config */
352  IfxEth_Txd_Out *txd0; /**< \brief Pointer to TXD0 output pin config */
353  IfxEth_Txd_Out *txd1; /**< \brief Pointer to TXD1 output pin config */
354  IfxEth_Txen_Out *txEn; /**< \brief Pointer to TXEN output pin config */
356 
357 /** \} */
358 
359 /** \addtogroup IfxLld_Eth_Std_Unions
360  * \{ */
361 typedef union
362 {
366 
367 typedef union
368 {
372 
373 /** \} */
374 
375 /** \addtogroup IfxLld_Eth_Std_DataStructures
376  * \{ */
377 /** \brief ETH configuration structure
378  */
379 typedef struct
380 {
381  uint8 macAddress[6]; /**< \brief MAC address for the ethernet, should be unique in the network */
382  uint32 (*phyInit)(void); /**< \brief Pointer to the transceiver init function */
383  boolean (*phyLink)(void); /**< \brief Pointer to the transceiver link function */
384  IfxEth_PhyInterfaceMode phyInterfaceMode; /**< \brief Phy Interface mode */
385  const IfxEth_RmiiPins *rmiiPins; /**< \brief Pointer to port pins configuration of RMII mode */
386  const IfxEth_MiiPins *miiPins; /**< \brief Pointer to port pins configuration of MII mode */
387  Ifx_Priority isrPriority; /**< \brief Interrupt service priority */
388  IfxSrc_Tos isrProvider; /**< \brief Interrupt service provider */
389  Ifx_ETH *ethSfr; /**< \brief Pointer to register base */
390  IfxEth_RxDescrList *rxDescr; /**< \brief pointer to RX descriptor RAM */
391  IfxEth_TxDescrList *txDescr; /**< \brief pointer to TX descriptor RAM */
392 } IfxEth_Config;
393 
394 /** \} */
395 
396 /** \addtogroup IfxLld_Eth_Std_DataStructures
397  * \{ */
398 /** \brief ETH driver structure
399  */
400 typedef struct
401 {
402  Ifx_ETH_STATUS status; /**< \brief Intermediate variable to use register content in control structure */
403  uint32 rxCount; /**< \brief Number of frames received */
404  uint32 txCount; /**< \brief Number of frames transmitted */
405  uint32 error; /**< \brief Indicate an error has occurred during execution */
406  sint32 isrRxCount; /**< \brief Count of RX ISR */
407  sint32 isrTxCount; /**< \brief Count of TX ISR */
408  sint32 txDiff; /**< \brief Difference between isrTxCount and txCount */
409  sint32 rxDiff; /**< \brief Difference between isrRxCount and rxCount */
410  sint32 isrCount; /**< \brief count of all ISR */
411  IfxEth_Config config; /**< \brief Copy of the configuration passed through IfxEth_init() */
412  IfxEth_RxDescrList *rxDescr; /**< \brief pointer to RX descriptor RAM */
413  IfxEth_TxDescrList *txDescr; /**< \brief pointer to TX descriptor RAM */
416  Ifx_ETH *ethSfr; /**< \brief Pointer to register base */
417 } IfxEth;
418 
419 /** \brief Structure for RX descriptor DWORD 0 Bit field access
420  */
421 typedef struct
422 {
423  uint32 PCE : 1; /**< \brief Rx MAC Address/Payload Checksum Error */
424  uint32 CE : 1; /**< \brief CRC Error */
425  uint32 DBE : 1; /**< \brief Dribble Bit Error */
426  uint32 RE : 1; /**< \brief Receive Error */
427  uint32 RWT : 1; /**< \brief Receive Watchdog Timeout */
428  uint32 FT : 1; /**< \brief Frame Type */
429  uint32 LC : 1; /**< \brief Late Collision */
430  uint32 IPC : 1; /**< \brief IPC Checksum Error/Giant Frame */
431  uint32 LS : 1; /**< \brief Last Descriptor */
432  uint32 FS : 1; /**< \brief First Descriptor */
433  uint32 VLAN : 1; /**< \brief VLAN Tag */
434  uint32 OE : 1; /**< \brief Overflow Error */
435  uint32 LE : 1; /**< \brief Length Error */
436  uint32 SAF : 1; /**< \brief Source Address Filter Fail */
437  uint32 DE : 1; /**< \brief Descriptor Error */
438  uint32 ES : 1; /**< \brief Error Summary, ES = PCE | CE | RE | RWT | LC | IPC | OE | DE */
439  uint32 FL : 14; /**< \brief Frame Length */
440  uint32 AFM : 1; /**< \brief Destination Address Filter Fail */
441  uint32 OWN : 1; /**< \brief Own Bit, 1 = own by DMA */
443 
444 /** \brief Structure for RX descriptor DWORD 1 Bit field access
445  */
446 typedef struct
447 {
448  uint32 RBS1 : 11; /**< \brief Receive Buffer 1 Size */
449  uint32 RBS2 : 11; /**< \brief Receive Buffer 2 Size */
450  uint32 resv : 2; /**< \brief (reserved) */
451  uint32 RCH : 1; /**< \brief Second Address Chained */
452  uint32 RER : 1; /**< \brief Receive End of Ring */
453  uint32 resv2 : 5; /**< \brief (reserved) */
454  uint32 DIC : 1; /**< \brief Disable Interrupt on Completion */
456 
457 /** \brief Structure for TX descriptor DWORD 0 Bit field access
458  */
459 typedef struct
460 {
461  uint32 DB : 1; /**< \brief Deferred Bit */
462  uint32 UF : 1; /**< \brief Underflow Error */
463  uint32 ED : 1; /**< \brief Excessive Deferral */
464  uint32 CC : 4; /**< \brief Collision Count */
465  uint32 VLAN : 1; /**< \brief VLAN Tag */
466  uint32 EC : 1; /**< \brief Excessive Collision */
467  uint32 LC : 1; /**< \brief Late Collision */
468  uint32 NC : 1; /**< \brief No Carrier */
469  uint32 LOC : 1; /**< \brief Loss of Carrier */
470  uint32 PCE : 1; /**< \brief Payload Checksum Error */
471  uint32 FF : 1; /**< \brief Frame Flushed */
472  uint32 JT : 1; /**< \brief Jabber Timeout */
473  uint32 ES : 1; /**< \brief Error Summary, ES = JT | FF | LOC | NC | LC | EC | ED | UF */
474  uint32 IHE : 1; /**< \brief IP Header Error */
475  uint32 TTSS : 1; /**< \brief Tx Time Stamp Status */
476  uint32 resv : 13; /**< \brief (reserved) */
477  uint32 OWN : 1; /**< \brief Own Bit, 1 = own by DMA */
479 
480 /** \brief Structure for TX descriptor DWORD 1 Bit field access
481  */
482 typedef struct
483 {
484  uint32 TBS1 : 11; /**< \brief Transmit Buffer 1 Size */
485  uint32 TBS2 : 11; /**< \brief Transmit Buffer 2 Size */
486  uint32 TTSE : 1; /**< \brief Transmit Time Stamp Enable */
487  uint32 DP : 1; /**< \brief Disable Padding */
488  uint32 TCH : 1; /**< \brief Second Address Chained */
489  uint32 TER : 1; /**< \brief Transmit End of Ring */
490  uint32 DC : 1; /**< \brief Disable CRC */
491  uint32 CIC : 2; /**< \brief Checksum Insertion Control */
492  uint32 FS : 1; /**< \brief First Segment */
493  uint32 LS : 1; /**< \brief Last Segment */
494  uint32 IC : 1; /**< \brief Interrupt on Completion */
496 
497 /** \} */
498 
499 /** \addtogroup IfxLld_Eth_Std_Configuration
500  * \{ */
501 
502 /******************************************************************************/
503 /*-------------------------Inline Function Prototypes-------------------------*/
504 /******************************************************************************/
505 
506 /** \brief Set buffer of an RX descriptor
507  * \param descr descr Pointer to an RX descriptor
508  * \param buffer pointer to buffer
509  * \return None
510  */
511 IFX_INLINE void IfxEth_RxDescr_setBuffer(IfxEth_RxDescr *descr, void *buffer);
512 
513 /** \brief Get pointer to next TX descriptor
514  * \param descr descr Pointer to a TX descriptor
515  * \return next Tx descriptor
516  */
518 
519 /** \brief Return TRUE if a TX descriptor is available for setup
520  * \param descr pointer to descriptor
521  */
523 
524 /** \brief Set buffer of a TX descriptor
525  * \param descr Entdescr Pointer to a TX descriptorer_String_here
526  * \param buffer pointer to Buffer
527  * \return None
528  */
529 IFX_INLINE void IfxEth_TxDescr_setBuffer(IfxEth_TxDescr *descr, void *buffer);
530 
531 /** \brief Applies the Software Reset
532  * \param eth ETH driver structure
533  * \return None
534  */
536 
537 /** \brief Clear receive interrupt request
538  * \param eth ETH driver structure
539  * \return None
540  */
542 
543 /** \brief Clear transmit interrupt request
544  * \param eth ETH driver structure
545  * \return None
546  */
548 
549 /** \brief Returns the status of Software Reset
550  * \param eth ETH driver structure
551  * \return Status
552  */
554 
555 /** \brief Sets the loopback mode
556  * \param eth ETH driver structure
557  * \param loopbackMode loopback mode enable/disbale
558  * \return None
559  */
560 IFX_INLINE void IfxEth_setLoopbackMode(IfxEth *eth, boolean loopbackMode);
561 
562 /** \brief Sets the Phy Interface mode
563  * \param eth ETH driver structure
564  * \param mode Phy interface mode
565  * \return None
566  */
568 
569 /** \brief Sets receive descriptor address
570  * \param eth pointer to the ethernet module
571  * \param address Address
572  * \return None
573  */
574 IFX_INLINE void IfxEth_setReceiveDescriptorAddress(Ifx_ETH *eth, void *address);
575 
576 /** \brief Sets transmit descriptor address
577  * \param eth pointer to the ethernet module
578  * \param address Address
579  * \return None
580  */
581 IFX_INLINE void IfxEth_setTransmitDescriptorAddress(Ifx_ETH *eth, void *address);
582 
583 /** \brief Waits for one TX buffer becomes available
584  * \param eth ETH driver structure
585  * retval non NULL_PTR TX buffer is available at the address pointed by the returned value
586  * retval NULL_PTR TX buffer is busy.
587  */
589 
590 /******************************************************************************/
591 /*-------------------------Global Function Prototypes-------------------------*/
592 /******************************************************************************/
593 
594 /** \brief Free the receive buffer, enabling it for the further reception
595  * \param eth ETH driver structure
596  * \return None
597  */
599 
600 /** \brief Request to send the transmit buffer
601  *
602  * The transmit buffer is the last one specified by IfxEth_getTransmitBuffer()
603  * \param eth ETH driver structure
604  * \param len Length of the data put in the transmit buffer (in bytes)
605  * \return None
606  */
608 
609 /** \brief Sets the MAC address
610  * \param eth ETH driver structure
611  * \param macAddress MAC address
612  * \return None
613  */
614 IFX_EXTERN void IfxEth_setMacAddress(IfxEth *eth, const uint8 *macAddress);
615 
616 /** \brief Start the receiver functions
617  * \param eth ETH driver structure
618  * \return None
619  */
621 
622 /** \brief writes the header format into buffrer
623  * \param eth ETH driver structure
624  * \param txBuffer pointer to tx buffer
625  * \param destinationAddress pointer to destination address
626  * \param sourceAddress pointer to source address
627  * \param packetSize size of the packet
628  * \return None
629  */
630 IFX_EXTERN void IfxEth_writeHeader(IfxEth *eth, uint8 *txBuffer, uint8 *destinationAddress, uint8 *sourceAddress, uint32 packetSize);
631 
632 /** \} */
633 
634 /** \addtogroup IfxLld_Eth_Std_Utility
635  * \{ */
636 
637 /******************************************************************************/
638 /*-------------------------Inline Function Prototypes-------------------------*/
639 /******************************************************************************/
640 
641 /** \brief Get pointer to next RX descriptor
642  * \param descr descr Pointer to an RX descriptor
643  * \return next RX descriptor
644  */
646 
647 /** \brief release RX descriptor
648  * \param descr pointer to Rx descriptor
649  * \return None
650  */
652 
653 /** \brief Release a TX descriptor for transmit queue
654  * \param descr Enter_String_herdescr Pointer to a TX descriptore
655  * \return None
656  */
658 
659 /** \brief Get pointer to actual RX descriptor
660  * \param eth eth ETH driver structure
661  */
663 
664 /**
665  */
667 
668 /** \brief Get pointer to actual TX descriptor
669  * \param eth eth ETH driver structure
670  */
672 
673 /** \brief Get pointer to base RX descriptor
674  * \param eth eth ETH driver structure
675  */
677 
678 /** \brief Get pointer to base TX descriptor
679  * \param eth eth ETH driver structure
680  */
682 
683 /** \brief returns the status of th eloopback mode
684  * \param eth ETH driver structure
685  * \return Loop back mode status (TRUE / FALSE)
686  */
688 
689 /** \brief Returns pointer to the MAC address configured for this ETH
690  * \param eth ETH driver structure
691  */
693 
694 /** \brief returns the Receive Process State
695  * \param eth ETH driver structure
696  * \return Receive Process State
697  */
699 
700 /** \brief Returns length of the oldest available RX data
701  * \param eth ETH driver structure
702  * \return Data length
703  */
705 
706 /** \brief returns the Transmit Process State
707  * \param eth ETH driver structure
708  * \return Transmit Process State
709  */
711 
712 /** \brief Checks whether physical connection is active
713  * \param eth ETH driver structure
714  * \return retval zero Connection is inactive
715  * retval non zero Connection is active
716  */
718 
719 /**
720  * \param eth pointer to ETH driver structure
721  */
723 
724 /** \brief Checks whether one or more RX data is available
725  * \param eth ETH driver structure
726  * \return retval TRUE one or more RX data is available
727  * retval FALSE no RX data is available
728  */
730 
731 /** \brief Checks whether receive interrupt is requested
732  * \param eth ETH driver structure
733  * \return TRUE/FALSE
734  */
736 
737 /** \brief Checks whether transmit interrupt is requested
738  * \param eth ETH driver structure
739  * \return TRUE/FALSE
740  */
742 
743 /** \brief reads the status of all flags
744  * \param eth ETH driver structure
745  * \return None
746  */
748 
749 /** \brief Shuffle to next RX descriptor
750  * \param eth eth ETH driver structure
751  * \return None
752  */
754 
755 /** \brief Shuffle to next TX descriptor
756  * \param eth eth ETH driver structure
757  * \return None
758  */
760 
761 /******************************************************************************/
762 /*-------------------------Global Function Prototypes-------------------------*/
763 /******************************************************************************/
764 
765 /** \brief Enable ETH Module
766  * \return None
767  */
769 
770 /** \brief Gets receive buffer\n
771  * note: IfxEth_freeReceiveBuffer() shall be called after the data from the RX buffer has been processed
772  * \param eth ETH driver structure
773  * \return retval NULL_PTR no received frame
774  * retval !NULL_PTR a frame has been received
775  */
777 
778 /** \brief Get a free transmit buffer
779  * \param eth ETH driver structure
780  * \return retval NULL_PTR no free transmit buffer is available
781  * retval !NULL_PTR a free transmit buffer is available
782  */
784 
785 /** \brief Reads the MAC address from module register
786  * \param eth ETH driver structure
787  * \param macAddress MAC address
788  * \return None
789  */
790 IFX_EXTERN void IfxEth_readMacAddress(IfxEth *eth, uint8 *macAddress);
791 
792 /** \brief resets Ethernet kernel
793  * \return None
794  */
795 IFX_EXTERN void IfxEth_resetModule(void);
796 
797 /**
798  * \param eth pointer to ETH driver structure
799  * \param len length of buffer
800  * \return None
801  */
802 IFX_EXTERN void IfxEth_setAndSendTransmitBuffer(IfxEth *eth, void *buffer, uint16 len);
803 
804 /** \brief Set up checksum Engine
805  * \param eth eth ETH driver structure
806  * \param mode specifies checksum mode
807  * \return None
808  */
810 
811 /** \brief Start the transmitter functions
812  * \param eth eth ETH driver structure
813  * \return None
814  */
816 
817 /** \brief Stop the transmitter functions
818  * \param eth eth ETH driver structure
819  * \return None
820  */
822 
823 /** \brief Wakeup the receiver functions
824  * \param eth eth ETH driver structure
825  * \return None
826  */
828 
829 /** \brief Wakeup the transmitter functions
830  * \param eth eth ETH driver structure
831  * \return None
832  */
834 
835 /** \} */
836 
837 /** \addtogroup IfxLld_Eth_Std_Initialisation
838  * \{ */
839 
840 /******************************************************************************/
841 /*-------------------------Inline Function Prototypes-------------------------*/
842 /******************************************************************************/
843 
844 /** \brief Setup some properties of a TX descriptor
845  * \param descr Enter_Sdescr Pointer to a TX descriptortring_here
846  * \param length specifies length of transmit descriptor
847  * \param firstSegment specifies first segment of frame
848  * \param lastSegment specifies last segment of frame
849  * \return None
850  */
851 IFX_INLINE void IfxEth_TxDescr_setup(IfxEth_TxDescr *descr, uint16 length, boolean firstSegment, boolean lastSegment);
852 
853 /******************************************************************************/
854 /*-------------------------Global Function Prototypes-------------------------*/
855 /******************************************************************************/
856 
857 /** \brief Initialises the driver
858  * \param eth ETH driver structure
859  * \param config ETH configuration structure
860  * \return None
861  */
862 IFX_EXTERN void IfxEth_init(IfxEth *eth, const IfxEth_Config *config);
863 
864 /** \brief Initialises the configuration Structure
865  * \param config ETH configuration structure
866  * \param ethSfr Pointer to register base
867  * \return None
868  */
869 IFX_EXTERN void IfxEth_initConfig(IfxEth_Config *config, Ifx_ETH *ethSfr);
870 
871 /** \brief Initialises the receive descriptors
872  * \param eth ETH driver structure
873  * \return None
874  */
876 
877 /** \brief Initialises transmit descriptors
878  * \param eth pointer to ETH driver structure
879  * \return None
880  */
882 
883 /** \brief Set up MII mode input pins
884  * \param eth eth pointer to ETH driver structure
885  * \param miiPins pin of port to be set
886  * \return None
887  */
888 IFX_EXTERN void IfxEth_setupMiiInputPins(IfxEth *eth, const IfxEth_MiiPins *miiPins);
889 
890 /** \brief setup MII mode output pins
891  * \param eth eth pointer to ETH driver structure
892  * \param miiPins pin of port to be set
893  * \return None
894  */
895 IFX_EXTERN void IfxEth_setupMiiOutputPins(IfxEth *eth, const IfxEth_MiiPins *miiPins);
896 
897 /** \brief Set up input pins
898  * \param eth eth pointer to ETH driver structure
899  * \param rmiiPins pin of port to be set
900  * \return None
901  */
902 IFX_EXTERN void IfxEth_setupRmiiInputPins(IfxEth *eth, const IfxEth_RmiiPins *rmiiPins);
903 
904 /** \brief set output pin of port
905  * \param eth eth pointer to ETH driver structure
906  * \param rmiiPins pin of port to be set
907  * \return None
908  */
909 IFX_EXTERN void IfxEth_setupRmiiOutputPins(IfxEth *eth, const IfxEth_RmiiPins *rmiiPins);
910 
911 /** \} */
912 
913 /******************************************************************************/
914 /*-------------------Global Exported Variables/Constants----------------------*/
915 /******************************************************************************/
916 
917 /** \brief receive buffers
918  */
920 
922 
923 /** \brief Transmit buffers
924  */
926 
928 
929 /******************************************************************************/
930 /*---------------------Inline Function Implementations------------------------*/
931 /******************************************************************************/
932 
934 {
935  return (IfxEth_RxDescr *)(descr->RDES3.U);
936 }
937 
938 
940 {
941  descr->RDES0.A.OWN = 1U;
942 }
943 
944 
946 {
947  descr->RDES2.U = (uint32)IFXCPU_GLB_ADDR_DSPR(IfxCpu_getCoreId(), buffer);
948 }
949 
950 
952 {
953  return (IfxEth_TxDescr *)(descr->TDES3.U);
954 }
955 
956 
958 {
959  return (descr->TDES0.A.OWN == 0) ? TRUE : FALSE;
960 }
961 
962 
964 {
965  descr->TDES0.A.OWN = 1U;
966 }
967 
968 
970 {
971  descr->TDES2.U = (uint32)IFXCPU_GLB_ADDR_DSPR(IfxCpu_getCoreId(), buffer);
972 }
973 
974 
975 IFX_INLINE void IfxEth_TxDescr_setup(IfxEth_TxDescr *descr, uint16 length, boolean firstSegment, boolean lastSegment)
976 {
977  IfxEth_TxDescr0 tdes0;
978 
979  tdes0.U = descr->TDES0.U;
980  tdes0.A.FS = firstSegment;
981  tdes0.A.LS = lastSegment;
982  descr->TDES0.U = tdes0.U;
983  descr->TDES1.U = length;
984 }
985 
986 
988 {
989  (void)eth;
990  ETH_BUS_MODE.B.SWR = 1; /* reset module */
991 }
992 
993 
995 {
996  (void)eth;
997  MODULE_ETH.STATUS.U = (uint32)((1 << IFX_ETH_STATUS_NIS_OFF) | (1 << IFX_ETH_STATUS_RI_OFF));
998 }
999 
1000 
1002 {
1003  (void)eth;
1004  MODULE_ETH.STATUS.U = (uint32)((1 << IFX_ETH_STATUS_NIS_OFF) | (1 << IFX_ETH_STATUS_TI_OFF));
1005 }
1006 
1007 
1009 {
1010  return eth->pRxDescr;
1011 }
1012 
1013 
1015 {
1016  uint32 offset = (uint32)eth->pRxDescr - (uint32)IfxEth_getBaseRxDescriptor(eth);
1017  return offset / sizeof(IfxEth_RxDescr);
1018 }
1019 
1020 
1022 {
1023  return eth->pTxDescr;
1024 }
1025 
1026 
1028 {
1029  return eth->rxDescr->items;
1030 }
1031 
1032 
1034 {
1035  return eth->txDescr->items;
1036 }
1037 
1038 
1040 {
1041  (void)eth;
1042  return (ETH_MAC_CONFIGURATION.B.LM != 0) ? TRUE : FALSE;
1043 }
1044 
1045 
1047 {
1048  return (void *)eth->config.macAddress;
1049 }
1050 
1051 
1053 {
1054  (void)eth;
1055  return (IfxEth_ReceiveProcessState)MODULE_ETH.STATUS.B.RS;
1056 }
1057 
1058 
1060 {
1061  uint16 length = 0;
1062 
1063  if (IfxEth_isRxDataAvailable(eth) != FALSE)
1064  {
1065  length = (uint16)IfxEth_getActualRxDescriptor(eth)->RDES0.A.FL;
1066  }
1067 
1068  return length;
1069 }
1070 
1071 
1073 {
1074  (void)eth;
1075  return (IfxEth_TransmitProcessState)MODULE_ETH.STATUS.B.TS;
1076 }
1077 
1078 
1080 {
1081  return eth->config.phyLink() != 0;
1082 }
1083 
1084 
1086 {
1088  boolean error = (descr->RDES0.A.IPC != 0);
1089  descr->RDES0.A.IPC = 0;
1090 
1091  return error;
1092 }
1093 
1094 
1096 {
1097  //return (IfxEth_rxDescr[eth->rxIndex][0] & (1U << 31)) == 0);
1098  return IfxEth_getActualRxDescriptor(eth)->RDES0.A.OWN == 0;
1099 }
1100 
1101 
1103 {
1104  (void)eth;
1105 
1106  return MODULE_ETH.STATUS.B.RI != 0;
1107 }
1108 
1109 
1111 {
1112  (void)eth;
1113  return ETH_BUS_MODE.B.SWR == 0 ? 1 : 0;
1114 }
1115 
1116 
1118 {
1119  (void)eth;
1120 
1121  return MODULE_ETH.STATUS.B.TI != 0;
1122 }
1123 
1124 
1126 {
1127  eth->status.U = ETH_STATUS.U;
1128 }
1129 
1130 
1131 IFX_INLINE void IfxEth_setLoopbackMode(IfxEth *eth, boolean loopbackMode)
1132 {
1133  (void)eth;
1134  ETH_MAC_CONFIGURATION.B.LM = loopbackMode ? 1 : 0;
1135 }
1136 
1137 
1139 {
1140  (void)eth;
1141  ETH_GPCTL.B.EPR = mode;
1142 }
1143 
1144 
1145 IFX_INLINE void IfxEth_setReceiveDescriptorAddress(Ifx_ETH *eth, void *address)
1146 {
1147  eth->RECEIVE_DESCRIPTOR_LIST_ADDRESS.U = (uint32)address;
1148 }
1149 
1150 
1151 IFX_INLINE void IfxEth_setTransmitDescriptorAddress(Ifx_ETH *eth, void *address)
1152 {
1153  eth->TRANSMIT_DESCRIPTOR_LIST_ADDRESS.U = (uint32)address;
1154 }
1155 
1156 
1158 {
1160 }
1161 
1162 
1164 {
1166 }
1167 
1168 
1170 {
1171  void *tx;
1172 
1173  do
1174  {
1175  tx = IfxEth_getTransmitBuffer(eth);
1176  } while (tx == NULL_PTR);
1177 
1178  return tx;
1179 }
1180 
1181 
1182 #endif /* IFXET_H */