]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC/ThirdParty/LPCOpen/lpc_core/lpc_chip/chip_18xx_43xx/enet_18xx_43xx.h
Update LPC18xx FreeRTOS+UDP demo to use LPCOpen USB and Ethernet drivers.
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC / ThirdParty / LPCOpen / lpc_core / lpc_chip / chip_18xx_43xx / enet_18xx_43xx.h
1 /*\r
2  * @brief LPC18xx/43xx ethernet driver\r
3  *\r
4  * @note\r
5  * Copyright(C) NXP Semiconductors, 2012\r
6  * All rights reserved.\r
7  *\r
8  * @par\r
9  * Software that is described herein is for illustrative purposes only\r
10  * which provides customers with programming information regarding the\r
11  * LPC products.  This software is supplied "AS IS" without any warranties of\r
12  * any kind, and NXP Semiconductors and its licensor disclaim any and\r
13  * all warranties, express or implied, including all implied warranties of\r
14  * merchantability, fitness for a particular purpose and non-infringement of\r
15  * intellectual property rights.  NXP Semiconductors assumes no responsibility\r
16  * or liability for the use of the software, conveys no license or rights under any\r
17  * patent, copyright, mask work right, or any other intellectual property rights in\r
18  * or to any products. NXP Semiconductors reserves the right to make changes\r
19  * in the software without notification. NXP Semiconductors also makes no\r
20  * representation or warranty that such application will be suitable for the\r
21  * specified use without further testing or modification.\r
22  *\r
23  * @par\r
24  * Permission to use, copy, modify, and distribute this software and its\r
25  * documentation is hereby granted, under NXP Semiconductors' and its\r
26  * licensor's relevant copyrights in the software, without fee, provided that it\r
27  * is used in conjunction with NXP Semiconductors microcontrollers.  This\r
28  * copyright, permission, and disclaimer notice must appear in all copies of\r
29  * this code.\r
30  */\r
31 \r
32 #ifndef __ENET_18XX_43XX_H_\r
33 #define __ENET_18XX_43XX_H_\r
34 \r
35 #ifdef __cplusplus\r
36 extern "C" {\r
37 #endif\r
38 \r
39 /** @defgroup ENET_18XX_43XX CHIP: LPC18xx/43xx Ethernet driver\r
40  * @ingroup CHIP_18XX_43XX_Drivers\r
41  * @{\r
42  */\r
43 \r
44 /** @defgroup ENET_18XX_43XX_OPTIONS CHIP: LPC18xx/43xx Ethernet driver build options\r
45  * @ingroup ENET_18XX_43XX CHIP_18XX_43XX_DRIVER_OPTIONS\r
46  * The ethernet driver has options that configure it's operation at build-time.<br>\r
47  *\r
48  * <b>USE_RMII</b><br>\r
49  * When defined, the driver will be built for RMII operation.<br>\r
50  * When not defined, the driver will be built for MII operation.<br>\r
51  * @{\r
52  */\r
53 \r
54 /**\r
55  * @}\r
56  */\r
57 \r
58 /**\r
59  * @brief       Resets the ethernet interface\r
60  * @param       pENET   : The base of ENET peripheral on the chip\r
61  * @return      Nothing\r
62  * @note        Resets the ethernet interface. This should be called prior to\r
63  * Chip_ENET_Init with a small delay after this call.\r
64  */\r
65 STATIC INLINE void Chip_ENET_Reset(LPC_ENET_T *pENET)\r
66 {\r
67         IP_ENET_Reset(pENET);\r
68 }\r
69 \r
70 /**\r
71  * @brief       Sets the address of the interface\r
72  * @param       pENET   : The base of ENET peripheral on the chip\r
73  * @param       macAddr : Pointer to the 6 bytes used for the MAC address\r
74  * @return      Nothing\r
75  */\r
76 STATIC INLINE void Chip_ENET_SetADDR(LPC_ENET_T *pENET, const uint8_t *macAddr)\r
77 {\r
78         IP_ENET_SetADDR(pENET, macAddr);\r
79 }\r
80 \r
81 /**\r
82  * @brief       Sets up the PHY link clock divider and PHY address\r
83  * @param       pENET   : The base of ENET peripheral on the chip\r
84  * @param       div             : Divider index, not a divider value, see user manual\r
85  * @param       addr    : PHY address, used with MII read and write\r
86  * @return      Nothing\r
87  */\r
88 STATIC INLINE void Chip_ENET_SetupMII(LPC_ENET_T *pENET, uint32_t div, uint8_t addr)\r
89 {\r
90         IP_ENET_SetupMII(pENET, div, addr);\r
91 }\r
92 \r
93 /**\r
94  * @brief       Starts a PHY write via the MII\r
95  * @param       pENET   : The base of ENET peripheral on the chip\r
96  * @param       reg             : PHY register to write\r
97  * @param       data    : Data to write to PHY register\r
98  * @return      Nothing\r
99  * @note        Start a PHY write operation. Does not block, requires calling\r
100  * IP_ENET_IsMIIBusy to determine when write is complete.\r
101  */\r
102 STATIC INLINE void Chip_ENET_StartMIIWrite(LPC_ENET_T *pENET, uint8_t reg, uint16_t data)\r
103 {\r
104         IP_ENET_StartMIIWrite(pENET, reg, data);\r
105 }\r
106 \r
107 /**\r
108  * @brief       Starts a PHY read via the MII\r
109  * @param       pENET   : The base of ENET peripheral on the chip\r
110  * @param       reg             : PHY register to read\r
111  * @return      Nothing\r
112  * @note        Start a PHY read operation. Does not block, requires calling\r
113  * IP_ENET_IsMIIBusy to determine when read is complete and calling\r
114  * IP_ENET_ReadMIIData to get the data.\r
115  */\r
116 STATIC INLINE void Chip_ENET_StartMIIRead(LPC_ENET_T *pENET, uint8_t reg)\r
117 {\r
118         IP_ENET_StartMIIRead(pENET, reg);\r
119 }\r
120 \r
121 /**\r
122  * @brief       Returns MII link (PHY) busy status\r
123  * @param       pENET   : The base of ENET peripheral on the chip\r
124  * @return      Returns true if busy, otherwise false\r
125  */\r
126 STATIC INLINE bool Chip_ENET_IsMIIBusy(LPC_ENET_T *pENET)\r
127 {\r
128         return IP_ENET_IsMIIBusy(pENET);\r
129 }\r
130 \r
131 /**\r
132  * @brief       Returns the value read from the PHY\r
133  * @param       pENET   : The base of ENET peripheral on the chip\r
134  * @return      Read value from PHY\r
135  */\r
136 STATIC INLINE uint16_t Chip_ENET_ReadMIIData(LPC_ENET_T *pENET)\r
137 {\r
138         return IP_ENET_ReadMIIData(pENET);\r
139 }\r
140 \r
141 /**\r
142  * @brief       Enables ethernet transmit\r
143  * @param       pENET   : The base of ENET peripheral on the chip\r
144  * @return      Nothing\r
145  */\r
146 STATIC INLINE void Chip_ENET_TXEnable(LPC_ENET_T *pENET)\r
147 {\r
148         IP_ENET_TXEnable(pENET);\r
149 }\r
150 \r
151 /**\r
152  * @brief Disables ethernet transmit\r
153  * @param       pENET   : The base of ENET peripheral on the chip\r
154  * @return      Nothing\r
155  */\r
156 STATIC INLINE void Chip_ENET_TXDisable(LPC_ENET_T *pENET)\r
157 {\r
158         IP_ENET_TXDisable(pENET);\r
159 }\r
160 \r
161 /**\r
162  * @brief       Enables ethernet packet reception\r
163  * @param       pENET   : The base of ENET peripheral on the chip\r
164  * @return      Nothing\r
165  */\r
166 STATIC INLINE void Chip_ENET_RXEnable(LPC_ENET_T *pENET)\r
167 {\r
168         IP_ENET_RXEnable(pENET);\r
169 }\r
170 \r
171 /**\r
172  * @brief       Disables ethernet packet reception\r
173  * @param       pENET   : The base of ENET peripheral on the chip\r
174  * @return      Nothing\r
175  */\r
176 STATIC INLINE void Chip_ENET_RXDisable(LPC_ENET_T *pENET)\r
177 {\r
178         IP_ENET_RXDisable(pENET);\r
179 }\r
180 \r
181 /**\r
182  * @brief       Sets full or half duplex for the interface\r
183  * @param       pENET   : The base of ENET peripheral on the chip\r
184  * @param       full    : true to selected full duplex, false for half\r
185  * @return      Nothing\r
186  */\r
187 STATIC INLINE void Chip_ENET_SetDuplex(LPC_ENET_T *pENET, bool full)\r
188 {\r
189         IP_ENET_SetDuplex(pENET, full);\r
190 }\r
191 \r
192 /**\r
193  * @brief       Sets speed for the interface\r
194  * @param       pENET           : The base of ENET peripheral on the chip\r
195  * @param       speed100        : true to select 100Mbps mode, false for 10Mbps\r
196  * @return      Nothing\r
197  */\r
198 STATIC INLINE void Chip_ENET_SetSpeed(LPC_ENET_T *pENET, bool speed100)\r
199 {\r
200         IP_ENET_SetSpeed(pENET, speed100);\r
201 }\r
202 \r
203 /**\r
204  * @brief       Configures the initial ethernet descriptors\r
205  * @param       pENET           : The base of ENET peripheral on the chip\r
206  * @param       pTXDescs        : Pointer to TX descriptor list\r
207  * @param       pRXDescs        : Pointer to RX descriptor list\r
208  * @return      Nothing\r
209  */\r
210 STATIC INLINE void Chip_ENET_InitDescriptors(LPC_ENET_T *pENET,\r
211                                                                                          IP_ENET_001_ENHTXDESC_T *pTXDescs, IP_ENET_001_ENHRXDESC_T *pRXDescs)\r
212 {\r
213         IP_ENET_InitDescriptors(pENET, pTXDescs, pRXDescs);\r
214 }\r
215 \r
216 /**\r
217  * @brief       Starts receive polling of RX descriptors\r
218  * @param       pENET   : The base of ENET peripheral on the chip\r
219  * @return      Nothing\r
220  */\r
221 STATIC INLINE void Chip_ENET_RXStart(LPC_ENET_T *pENET)\r
222 {\r
223         IP_ENET_RXStart(pENET);\r
224 }\r
225 \r
226 /**\r
227  * @brief       Starts transmit polling of TX descriptors\r
228  * @param       pENET   : The base of ENET peripheral on the chip\r
229  * @return      Nothing\r
230  */\r
231 STATIC INLINE void Chip_ENET_TXStart(LPC_ENET_T *pENET)\r
232 {\r
233         IP_ENET_TXStart(pENET);\r
234 }\r
235 \r
236 /**\r
237  * @brief       Initialize ethernet interface\r
238  * @param       pENET   : The base of ENET peripheral on the chip\r
239  * @return      Nothing\r
240  * @note        Performs basic initialization of the ethernet interface in a default\r
241  * state. This is enough to place the interface in a usable state, but\r
242  * may require more setup outside this function.\r
243  */\r
244 void Chip_ENET_Init(LPC_ENET_T *pENET);\r
245 \r
246 /**\r
247  * @brief       De-initialize the ethernet interface\r
248  * @param       pENET   : The base of ENET peripheral on the chip\r
249  * @return      Nothing\r
250  */\r
251 void Chip_ENET_DeInit(LPC_ENET_T *pENET);\r
252 \r
253 /**\r
254  * @}\r
255  */\r
256 \r
257 #ifdef __cplusplus\r
258 }\r
259 #endif\r
260 \r
261 #endif /* __ENET_18XX_43XX_H_ */\r