]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RX600_RX62N-RSK_IAR/webserver/r_ether.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / RX600_RX62N-RSK_IAR / webserver / r_ether.h
1 /******************************************************************************\r
2 * DISCLAIMER\r
3 * Please refer to http://www.renesas.com/disclaimer\r
4 ******************************************************************************\r
5   Copyright (C) 2008. Renesas Technology Corp., All Rights Reserved.\r
6 *******************************************************************************\r
7 * File Name    : r_ether.h\r
8 * Version      : 1.02\r
9 * Description  : Ethernet module device driver\r
10 ******************************************************************************\r
11 * History : DD.MM.YYYY Version Description\r
12 *         : 15.02.2010 1.00    First Release\r
13 *         : 03.03.2010 1.01    Buffer size is aligned on the 32-byte boundary.\r
14 *         : 04.06.2010 1.02    RX62N changes\r
15 ******************************************************************************/\r
16 \r
17 #ifndef R_ETHER_H\r
18 #define R_ETHER_H\r
19 \r
20 /******************************************************************************\r
21 Includes   <System Includes> , "Project Includes"\r
22 ******************************************************************************/\r
23 #include <stdint.h>\r
24 \r
25 /******************************************************************************\r
26 Typedef definitions\r
27 ******************************************************************************/\r
28 struct Descriptor\r
29 {\r
30          unsigned long  status;\r
31 #if __LITTLE_ENDIAN__ == 1\r
32 /* Little endian */\r
33          unsigned short size;\r
34          unsigned short bufsize;\r
35 #else\r
36 /* Big endian */\r
37          unsigned short bufsize;\r
38          unsigned short size;\r
39 \r
40 #endif\r
41         char                                    *buf_p;\r
42         struct Descriptor               *next;\r
43 };\r
44 \r
45 typedef struct Descriptor ethfifo;\r
46 \r
47 typedef enum _NETLNK\r
48 {\r
49     PHY_NO_LINK = 0,\r
50     PHY_LINK_10H,\r
51     PHY_LINK_10F,\r
52     PHY_LINK_100H,\r
53     PHY_LINK_100F\r
54 \r
55 } NETLNK;\r
56 \r
57 /******************************************************************************\r
58 Macro definitions\r
59 ******************************************************************************/\r
60 #define BUFSIZE   256                   /* Must be 32-bit aligned */\r
61 #define ENTRY     8                     /* Number of RX and TX buffers */\r
62 \r
63 #define  ACT      0x80000000\r
64 #define  DL       0x40000000\r
65 #define  FP1      0x20000000\r
66 #define  FP0      0x10000000\r
67 #define  FE       0x08000000\r
68 \r
69 #define  RFOVER   0x00000200\r
70 #define  RAD      0x00000100\r
71 #define  RMAF     0x00000080\r
72 #define  RRF      0x00000010\r
73 #define  RTLF     0x00000008\r
74 #define  RTSF     0x00000004\r
75 #define  PRE      0x00000002\r
76 #define  CERF     0x00000001\r
77 \r
78 #define  TAD      0x00000100\r
79 #define  CND      0x00000008\r
80 #define  DLC      0x00000004\r
81 #define  CD       0x00000002\r
82 #define  TRO      0x00000001\r
83 \r
84 /**\r
85  * Renesas Ethernet API return defines\r
86  **/\r
87 #define R_ETHER_OK          0\r
88 #define R_ETHER_ERROR       -1\r
89 \r
90 /*      Ether Interface definitions     */\r
91 #define ETH_RMII_MODE   0\r
92 #define ETH_MII_MODE    1\r
93 /*      Select Ether Interface Mode     */\r
94 #define ETH_MODE_SEL    ETH_MII_MODE\r
95 \r
96 /******************************************************************************\r
97 Variable Externs\r
98 ******************************************************************************/\r
99 \r
100 /******************************************************************************\r
101 Functions Prototypes\r
102 ******************************************************************************/\r
103 /**\r
104  * Renesas Ethernet API prototypes\r
105  **/\r
106 int32_t R_Ether_Open(unsigned long ch, unsigned char mac_addr[]);\r
107 int32_t R_Ether_Close(unsigned long ch);\r
108 int32_t R_Ether_Write(unsigned long ch, void *buf, unsigned long len);\r
109 int32_t R_Ether_Read(unsigned long ch, void *buf);\r
110 \r
111 /**\r
112  * FreeRTOS Ethernet API prototypes.\r
113  */\r
114 \r
115 /*\r
116  * Configure all the ethernet components (MAC, DMA, PHY) ready for communication.\r
117  */\r
118 void vInitEmac( void );\r
119 \r
120 /*\r
121  * Auto negotiate the link, returning pass or fail depending on whether a link\r
122  * was established or not.\r
123  */\r
124 long lEMACWaitForLink( void );\r
125 \r
126 /*\r
127  * Check the Rx status, and return the number of bytes received if any.\r
128  */\r
129 unsigned long ulEMACRead( void );\r
130 \r
131 /*\r
132  * Send uip_len bytes from uip_buf to the Tx descriptors and initiate a Tx.\r
133  */\r
134 void vEMACWrite( void );\r
135 \r
136 \r
137 \r
138 \r
139 /****************************************************/\r
140 /* Ethernet statistic collection data */\r
141 struct enet_stats\r
142 {\r
143   unsigned long  rx_packets;      /* total packets received    */\r
144   unsigned long  tx_packets;      /* total packets transmitted  */\r
145   unsigned long  rx_errors;       /* bad packets received      */\r
146   unsigned long  tx_errors;       /* packet transmit problems    */\r
147   unsigned long  rx_dropped;      /* no space in buffers      */\r
148   unsigned long  tx_dropped;      /* no space available      */\r
149   unsigned long  multicast;       /* multicast packets received  */\r
150   unsigned long  collisions;\r
151 \r
152   /* detailed rx_errors: */\r
153   unsigned long  rx_length_errors;\r
154   unsigned long  rx_over_errors;    /* receiver ring buffer overflow  */\r
155   unsigned long  rx_crc_errors;     /* recved pkt with crc error  */\r
156   unsigned long  rx_frame_errors;   /* recv'd frame alignment error  */\r
157   unsigned long  rx_fifo_errors;    /* recv'r fifo overrun      */\r
158   unsigned long  rx_missed_errors;  /* receiver missed packet    */\r
159 \r
160   /* detailed tx_errors */\r
161   unsigned long  tx_aborted_errors;\r
162   unsigned long  tx_carrier_errors;\r
163   unsigned long  tx_fifo_errors;\r
164   unsigned long  tx_heartbeat_errors;\r
165   unsigned long  tx_window_errors;\r
166 };\r
167 \r
168 struct ei_device\r
169 {\r
170   const char      *name;\r
171   unsigned char   open;\r
172   unsigned char   Tx_act;\r
173   unsigned char   Rx_act;\r
174   unsigned char   txing;        /* Transmit Active */\r
175   unsigned char   irqlock;      /* EDMAC's interrupt disabled when '1'. */\r
176   unsigned char   dmaing;       /* EDMAC Active */\r
177   ethfifo         *rxcurrent;   /* current receive discripter */\r
178   ethfifo         *txcurrent;   /* current transmit discripter */\r
179   unsigned char   save_irq;     /* Original dev->irq value. */\r
180   struct enet_stats stat;\r
181   unsigned char   mac_addr[6];\r
182 };\r
183 \r
184 #endif /* R_ETHER_H */\r
185 \r