|
| 1 | +/* |
| 2 | +********************************************************************************************************* |
| 3 | +* uC/TCP-IP |
| 4 | +* The Embedded TCP/IP Suite |
| 5 | +* |
| 6 | +* Copyright 2004-2020 Silicon Laboratories Inc. www.silabs.com |
| 7 | +* |
| 8 | +* SPDX-License-Identifier: APACHE-2.0 |
| 9 | +* |
| 10 | +* This software is subject to an open source license and is distributed by |
| 11 | +* Silicon Laboratories Inc. pursuant to the terms of the Apache License, |
| 12 | +* Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. |
| 13 | +* |
| 14 | +********************************************************************************************************* |
| 15 | +*/ |
| 16 | + |
| 17 | +/* |
| 18 | +********************************************************************************************************* |
| 19 | +* |
| 20 | +* NETWORK BOARD SUPPORT PACKAGE (BSP) FUNCTIONS |
| 21 | +* |
| 22 | +* TEMPLATE |
| 23 | +* |
| 24 | +* Filename : bsp_net_eth.c |
| 25 | +* Version : V3.06.00 |
| 26 | +********************************************************************************************************* |
| 27 | +*/ |
| 28 | + |
| 29 | + |
| 30 | +/* |
| 31 | +********************************************************************************************************* |
| 32 | +* INCLUDE FILES |
| 33 | +********************************************************************************************************* |
| 34 | +*/ |
| 35 | + |
| 36 | +#include <IF/net_if_ether.h> |
| 37 | + |
| 38 | + |
| 39 | +/* |
| 40 | +********************************************************************************************************* |
| 41 | +* LOCAL DEFINES |
| 42 | +********************************************************************************************************* |
| 43 | +*/ |
| 44 | + |
| 45 | + |
| 46 | +/* |
| 47 | +********************************************************************************************************* |
| 48 | +* LOCAL CONSTANTS |
| 49 | +********************************************************************************************************* |
| 50 | +*/ |
| 51 | + |
| 52 | + |
| 53 | +/* |
| 54 | +********************************************************************************************************* |
| 55 | +* LOCAL DATA TYPES |
| 56 | +********************************************************************************************************* |
| 57 | +*/ |
| 58 | + |
| 59 | + |
| 60 | +/* |
| 61 | +********************************************************************************************************* |
| 62 | +* LOCAL TABLES |
| 63 | +********************************************************************************************************* |
| 64 | +*/ |
| 65 | + |
| 66 | + |
| 67 | +/* |
| 68 | +********************************************************************************************************* |
| 69 | +* LOCAL GLOBAL VARIABLES |
| 70 | +********************************************************************************************************* |
| 71 | +*/ |
| 72 | + |
| 73 | + |
| 74 | +/* |
| 75 | +********************************************************************************************************* |
| 76 | +* ETHERNET DEVICE INTERFACE NUMBERS |
| 77 | +* |
| 78 | +* Note(s) : (1) Each network device maps to a unique network interface number. |
| 79 | +********************************************************************************************************* |
| 80 | +*/ |
| 81 | + |
| 82 | +static NET_IF_NBR Board_IF_Nbr = NET_IF_NBR_NONE; |
| 83 | + |
| 84 | + |
| 85 | +/* |
| 86 | +********************************************************************************************************* |
| 87 | +* LOCAL FUNCTION PROTOTYPES |
| 88 | +********************************************************************************************************* |
| 89 | +*/ |
| 90 | + |
| 91 | +#ifdef NET_IF_ETHER_MODULE_EN |
| 92 | + |
| 93 | +static void BSP_NET_Template_CfgClk (NET_IF *p_if, |
| 94 | + NET_ERR *p_err); |
| 95 | + |
| 96 | +static void BSP_NET_Template_CfgIntCtrl(NET_IF *p_if, |
| 97 | + NET_ERR *p_err); |
| 98 | + |
| 99 | +static void BSP_NET_Template_CfgGPIO (NET_IF *p_if, |
| 100 | + NET_ERR *p_err); |
| 101 | + |
| 102 | +static CPU_INT32U BSP_NET_Template_ClkFreqGet(NET_IF *p_if, |
| 103 | + NET_ERR *p_err); |
| 104 | + |
| 105 | + void BSP_NET_Template_IntHandler(void); |
| 106 | + |
| 107 | + |
| 108 | +/* |
| 109 | +********************************************************************************************************* |
| 110 | +* ETHERNET DEVICE BSP INTERFACE |
| 111 | +********************************************************************************************************* |
| 112 | +*/ |
| 113 | + |
| 114 | +const NET_DEV_BSP_ETHER NET_DrvBSP_Template = { |
| 115 | + &BSP_NET_Template_CfgClk, |
| 116 | + &BSP_NET_Template_CfgIntCtrl, |
| 117 | + &BSP_NET_Template_CfgGPIO, |
| 118 | + &BSP_NET_Template_ClkFreqGet |
| 119 | + }; |
| 120 | + |
| 121 | + |
| 122 | +/* |
| 123 | +********************************************************************************************************* |
| 124 | +* LOCAL CONFIGURATION ERRORS |
| 125 | +********************************************************************************************************* |
| 126 | +*/ |
| 127 | + |
| 128 | + |
| 129 | +/* |
| 130 | +********************************************************************************************************* |
| 131 | +********************************************************************************************************* |
| 132 | +* LOCAL FUNCTIONS |
| 133 | +********************************************************************************************************* |
| 134 | +********************************************************************************************************* |
| 135 | +*/ |
| 136 | + |
| 137 | +/* |
| 138 | +********************************************************************************************************* |
| 139 | +* BSP_NET_Template_CfgClk() |
| 140 | +* |
| 141 | +* Description : Configure clocks for the specified interface/device. |
| 142 | +* |
| 143 | +* Argument(s) : p_if Pointer to network interface to configure. |
| 144 | +* |
| 145 | +* p_err Pointer to variable that will receive the return error code from this function: |
| 146 | +* |
| 147 | +* NET_DEV_ERR_NONE Device clock(s) successfully configured. |
| 148 | +* |
| 149 | +* Return(s) : none. |
| 150 | +* |
| 151 | +* Note(s) : none. |
| 152 | +********************************************************************************************************* |
| 153 | +*/ |
| 154 | + |
| 155 | +static void BSP_NET_Template_CfgClk (NET_IF *p_if, |
| 156 | + NET_ERR *p_err) |
| 157 | +{ |
| 158 | + (void)p_if; /* Prevent 'variable unused' compiler warning. */ |
| 159 | + |
| 160 | + /* $$$$ Insert code to configure each network interface's/device's clocks. */ |
| 161 | + |
| 162 | + *p_err = NET_DEV_ERR_NONE; |
| 163 | +} |
| 164 | + |
| 165 | + |
| 166 | +/* |
| 167 | +********************************************************************************************************* |
| 168 | +* BSP_NET_Template_CfgIntCtrl() |
| 169 | +* |
| 170 | +* Description : Configure interrupts and/or interrupt controller for the specified interface/device. |
| 171 | +* |
| 172 | +* Argument(s) : p_if Pointer to network interface to configure. |
| 173 | +* |
| 174 | +* p_err Pointer to variable that will receive the return error code from this function: |
| 175 | +* |
| 176 | +* NET_DEV_ERR_NONE Device interrupt(s) successfully configured. |
| 177 | +* |
| 178 | +* Return(s) : none. |
| 179 | +* |
| 180 | +* Note(s) : none. |
| 181 | +********************************************************************************************************* |
| 182 | +*/ |
| 183 | + |
| 184 | +static void BSP_NET_Template_CfgIntCtrl (NET_IF *p_if, |
| 185 | + NET_ERR *p_err) |
| 186 | +{ |
| 187 | + Board_IF_Nbr = p_if->Nbr; /* Configure BSP instance with specific interface nbr. */ |
| 188 | + |
| 189 | + /* $$$$ Insert code to configure each network interface's/device's interrupt(s)/controller. */ |
| 190 | + |
| 191 | + *p_err = NET_DEV_ERR_NONE; |
| 192 | +} |
| 193 | + |
| 194 | + |
| 195 | +/* |
| 196 | +********************************************************************************************************* |
| 197 | +* BSP_NET_Template_CfgGPIO() |
| 198 | +* |
| 199 | +* Description : Configure general-purpose I/O (GPIO) for the specified interface/device. |
| 200 | +* |
| 201 | +* Argument(s) : p_if Pointer to network interface to configure. |
| 202 | +* |
| 203 | +* p_err Pointer to variable that will receive the return error code from this function: |
| 204 | +* |
| 205 | +* NET_DEV_ERR_NONE Device GPIO successfully configured. |
| 206 | +* |
| 207 | +* Return(s) : none. |
| 208 | +* |
| 209 | +* Note(s) : none. |
| 210 | +********************************************************************************************************* |
| 211 | +*/ |
| 212 | + |
| 213 | +static void BSP_NET_Template_CfgGPIO (NET_IF *p_if, |
| 214 | + NET_ERR *p_err) |
| 215 | +{ |
| 216 | + (void)p_if; /* Prevent 'variable unused' compiler warning. */ |
| 217 | + |
| 218 | + /* $$$$ Insert code to configure each network interface's/device's GPIO. */ |
| 219 | + |
| 220 | + *p_err = NET_DEV_ERR_NONE; |
| 221 | +} |
| 222 | + |
| 223 | + |
| 224 | +/* |
| 225 | +********************************************************************************************************* |
| 226 | +* BSP_NET_Template_ClkFreqGet() |
| 227 | +* |
| 228 | +* Description : Get device clock frequency. |
| 229 | +* |
| 230 | +* Argument(s) : p_if Pointer to network interface to get clock frequency. |
| 231 | +* |
| 232 | +* p_err Pointer to variable that will receive the return error code from this function: |
| 233 | +* |
| 234 | +* NET_DEV_ERR_NONE Device clock frequency successfully returned. |
| 235 | +* |
| 236 | +* Return(s) : Device clock frequency (in Hz). |
| 237 | +* |
| 238 | +* Note(s) : none. |
| 239 | +********************************************************************************************************* |
| 240 | +*/ |
| 241 | + |
| 242 | +static CPU_INT32U BSP_NET_Template_ClkFreqGet (NET_IF *p_if, |
| 243 | + NET_ERR *p_err) |
| 244 | +{ |
| 245 | + CPU_INT32U clk_freq; |
| 246 | + |
| 247 | + |
| 248 | + (void)p_if; /* Prevent 'variable unused' compiler warning. */ |
| 249 | + (void)clk_freq; |
| 250 | + |
| 251 | + /* $$$$ Insert code to return each network interface's/device's clock frequency. */ |
| 252 | + |
| 253 | + *p_err = NET_DEV_ERR_NONE; |
| 254 | + |
| 255 | + return (clk_freq); |
| 256 | +} |
| 257 | + |
| 258 | + |
| 259 | +/* |
| 260 | +********************************************************************************************************* |
| 261 | +* BSP_NET_Template_IntHandler() |
| 262 | +* |
| 263 | +* Description : BSP-level ISR handler(s) for device interrupts. |
| 264 | +* |
| 265 | +* Argument(s) : none. |
| 266 | +* |
| 267 | +* Return(s) : none. |
| 268 | +* |
| 269 | +* Note(s) : none. |
| 270 | +********************************************************************************************************* |
| 271 | +*/ |
| 272 | + |
| 273 | +void BSP_NET_Template_IntHandler (void) |
| 274 | +{ |
| 275 | + NET_ERR err; |
| 276 | + |
| 277 | + |
| 278 | + /* $$$$ Insert code to handle each network interface's/device's interrupt(s) [see Note #1a] : */ |
| 279 | + |
| 280 | + NetIF_ISR_Handler(Board_IF_Nbr, NET_DEV_ISR_TYPE_UNKNOWN, &err); |
| 281 | + |
| 282 | + (void)err; |
| 283 | + |
| 284 | + /* $$$$ Insert code to clear each network interface's/device's interrupt(s), if necessary. */ |
| 285 | +} |
| 286 | + |
| 287 | + |
| 288 | +/* |
| 289 | +********************************************************************************************************* |
| 290 | +* MODULE END |
| 291 | +********************************************************************************************************* |
| 292 | +*/ |
| 293 | + |
| 294 | +#endif /* NET_IF_ETHER_MODULE_EN */ |
0 commit comments