ethernet.c File Reference


Detailed Description

lwIP on ethernet entry point.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file ethernet.c.

#include <stdlib.h>
#include <string.h>
#include "conf_eth.h"
#include "conf_explorer.h"
#include "gpio.h"
#include "FreeRTOS.h"
#include "task.h"
#include "serial.h"
#include "fsaccess.h"
#include "config_file.h"
#include "conf_lwip_threads.h"
#include "ethernet.h"
#include "macb.h"
#include "BasicWEB.h"
#include "BasicSMTP.h"
#include "lwip/sys.h"
#include "lwip/api.h"
#include "lwip/tcpip.h"
#include "lwip/memp.h"
#include "lwip/stats.h"
#include "netif/loopif.h"
#include "supervisor.h"
#include "shell.h"
#include "MMI.h"

Go to the source code of this file.

Functions

eExecStatus e_ethernet_cmd_get_config (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The set sensor config command: set the value of a config field of a sensor. Takes three parameters. The first parameter is the sensor's name, the second parameter is the config field name, the third parameter is the value. Format: set_sensor_config sensorname field=value.
eExecStatus e_ethernet_cmd_set_config (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The get sensor config command: get the config fields value of a sensor. Takes one parameter, that is the sensor's name. Format: get_sensor_config sensorname.
eExecStatus e_ip_stat (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The development only ip statck stats: display the TCP/IP stack stats on COM2. No parameters. Format: ipstat.
 portTASK_FUNCTION (vStartEthernetTask, pvParameters)
 configure lwIP and MACB, start lwIP layer, start servers tasks through lwIP services.
static void prv_v_set_default_macaddr (unsigned portCHAR aMacAddress[])
 Set the default mac addr.
static void prv_v_set_default_netconfig (unsigned portCHAR aMacAddress[], struct ip_addr *pxIpAddr, struct ip_addr *pxNetMask, struct ip_addr *pxGateway)
 Set the default network configuration.
static void prvEthernetConfigureInterface (void *param)
 set ethernet config, by parsing ETHERNET_CONFIG_FILE file.
static void prvlwIPInit (void)
 start lwIP layer.
static void tcpip_init_done (void *arg)
 Callback executed when the TCP/IP init is done.
void v_ethernet_stopResources (void)
 Stop the ethernet module resources.
void vEthernetGetGWAddr (portCHAR *pcConfig)
 get the current GW address : formatted as follow : XXX.XXX.XXX.XXX
void vEthernetGetIPAddr (portCHAR *pcConfig)
 get the current IP address : formatted as follow : XXX.XXX.XXX.XXX
void vEthernetGetMACAddr (portCHAR *pcConfig)
 get the current MAC address : formatted as follow : XX:XX:XX:XX:XX:XX
void vEthernetGetSubnetMask (portCHAR *pcConfig)
 get the current Subnet mask : formatted as follow : XXX.XXX.XXX.XXX
void vStartEthernetTaskLauncher (unsigned portBASE_TYPE uxPriority)
 Create the vStartEthernetTask task.

Variables

struct netif MACB_if
xSemaphoreHandle xCFGMutex


Function Documentation

eExecStatus e_ethernet_cmd_get_config ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The set sensor config command: set the value of a config field of a sensor. Takes three parameters. The first parameter is the sensor's name, the second parameter is the config field name, the third parameter is the value. Format: set_sensor_config sensorname field=value.

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
FsNavId Ignored.
ac Input. The argument counter. For this command, should be 3.
av Input. The argument vector.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 343 of file ethernet.c.

References SHELL_ERRMSG_MEMALLOC, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, vEthernetGetGWAddr(), vEthernetGetIPAddr(), vEthernetGetMACAddr(), and vEthernetGetSubnetMask().

Referenced by e_syscmds_cmd_get_config().

00345 {
00346 portCHAR buf[18];
00347 
00348   if(ppcStringReply != NULL)
00349   {
00350     /* allocate a buffer for answer */
00351     *ppcStringReply = (signed portCHAR *)pvPortMalloc(130);
00352     if( NULL == *ppcStringReply )
00353     {
00354        *ppcStringReply = (signed portCHAR *)SHELL_ERRMSG_MEMALLOC;
00355        return( SHELL_EXECSTATUS_KO );
00356     }
00357     /* add some static data */
00358     strcpy((char *)*ppcStringReply, "macaddr=");
00359     /* get MAC addr and add it to the buffer */
00360     vEthernetGetMACAddr(buf);
00361     strcat((char *)*ppcStringReply,buf);
00362     /* add some static data */
00363     strcat((char *)*ppcStringReply,"\r\nipaddr=");
00364     /* get IP addr and add it to the buffer */
00365     vEthernetGetIPAddr(buf);
00366     strcat((char *)*ppcStringReply,buf);
00367     /* add some static data */
00368     strcat((char *)*ppcStringReply,"\r\nsubmask=");
00369     /* get Subnet Mask and add it to the buffer */
00370     vEthernetGetSubnetMask(buf);
00371     strcat((char *)*ppcStringReply,buf);
00372     /* add some static data */
00373     strcat((char *)*ppcStringReply,"\r\ngwaddr=");
00374     /* get GW addr and add it to the buffer */
00375     vEthernetGetGWAddr(buf);
00376     strcat((char *)*ppcStringReply,buf);
00377     /* add some static data */
00378     strcat((char *)*ppcStringReply,"\r\n");
00379     /* no error, return */
00380     return( SHELL_EXECSTATUS_OK );
00381   }
00382   return( SHELL_EXECSTATUS_KO );
00383 }
00384 

eExecStatus e_ethernet_cmd_set_config ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The get sensor config command: get the config fields value of a sensor. Takes one parameter, that is the sensor's name. Format: get_sensor_config sensorname.

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
FsNavId Ignored.
ac Input. The argument counter. For this command, should be 1.
av Input. The argument vector.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 298 of file ethernet.c.

References config_file_set_value(), ETHERNET_CONFIG_FILE, SHELL_ERRMSG_CONFIGERROR, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and SHELL_MSG_REBOOT.

Referenced by e_syscmds_cmd_set_config().

00300 {
00301 
00302     if (config_file_set_value(ETHERNET_CONFIG_FILE, ac, av) != 0)
00303     {
00304       if(ppcStringReply != NULL)
00305       {
00306         *ppcStringReply = (signed portCHAR *)SHELL_ERRMSG_CONFIGERROR;
00307       }
00308       return( SHELL_EXECSTATUS_KO );
00309     }
00310     if(ppcStringReply != NULL)
00311     {
00312       /* allocate a buffer for answer */
00313       *ppcStringReply = (signed portCHAR *)pvPortMalloc( strlen( SHELL_MSG_REBOOT ) +1 ); // Alloc
00314       if( NULL != *ppcStringReply )
00315       {
00316          strcpy( (char *)*ppcStringReply, SHELL_MSG_REBOOT );
00317       }
00318     }
00319     return( SHELL_EXECSTATUS_OK );
00320 }
00321 

eExecStatus e_ip_stat ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The development only ip statck stats: display the TCP/IP stack stats on COM2. No parameters. Format: ipstat.

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
FsNavId Ignored.
ac Input. The argument counter. Ignored.
av Input. The argument vector. Ignored
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 528 of file ethernet.c.

References SHELL_EXECSTATUS_OK.

00530 {
00531    if( NULL != ppcStringReply )
00532       *ppcStringReply = NULL;
00533    stats_display();
00534    return( SHELL_EXECSTATUS_OK );
00535 }
00536 

portTASK_FUNCTION ( vStartEthernetTask  ,
pvParameters   
)

configure lwIP and MACB, start lwIP layer, start servers tasks through lwIP services.

Definition at line 135 of file ethernet.c.

References CTRLPANEL_SMTP_CLIENT_PRIORITY, CTRLPANEL_SMTP_CLIENT_STACK_SIZE, CTRLPANEL_TFTP_SERVER_PRIORITY, CTRLPANEL_TFTP_SERVER_STACK_SIZE, CTRLPANEL_WEB_SERVER_PRIORITY, CTRLPANEL_WEB_SERVER_STACK_SIZE, and prvlwIPInit().

00136 {
00137 static const gpio_map_t MACB_GPIO_MAP =
00138 {
00139   {AVR32_MACB_MDC_0_PIN,    AVR32_MACB_MDC_0_FUNCTION   },
00140   {AVR32_MACB_MDIO_0_PIN,   AVR32_MACB_MDIO_0_FUNCTION  },
00141   {AVR32_MACB_RXD_0_PIN,    AVR32_MACB_RXD_0_FUNCTION   },
00142   {AVR32_MACB_TXD_0_PIN,    AVR32_MACB_TXD_0_FUNCTION   },
00143   {AVR32_MACB_RXD_1_PIN,    AVR32_MACB_RXD_1_FUNCTION   },
00144   {AVR32_MACB_TXD_1_PIN,    AVR32_MACB_TXD_1_FUNCTION   },
00145   {AVR32_MACB_TX_EN_0_PIN,  AVR32_MACB_TX_EN_0_FUNCTION },
00146   {AVR32_MACB_RX_ER_0_PIN,  AVR32_MACB_RX_ER_0_FUNCTION },
00147   {AVR32_MACB_RX_DV_0_PIN,  AVR32_MACB_RX_DV_0_FUNCTION },
00148   {AVR32_MACB_TX_CLK_0_PIN, AVR32_MACB_TX_CLK_0_FUNCTION}
00149 };
00150 
00151   // Assign GPIO to MACB
00152   gpio_enable_module(MACB_GPIO_MAP, sizeof(MACB_GPIO_MAP) / sizeof(MACB_GPIO_MAP[0]));
00153 
00154 
00155   /* Setup lwIP. */
00156   prvlwIPInit();
00157 
00158 #if (HTTP_USED == 1)
00159   /* Create the WEB server task.  This uses the lwIP RTOS abstraction layer.*/
00160   sys_thread_new( "WEB", vBasicWEBServer, ( void * ) NULL,
00161                    CTRLPANEL_WEB_SERVER_STACK_SIZE,
00162                    CTRLPANEL_WEB_SERVER_PRIORITY );
00163 #endif
00164 
00165 #if (TFTP_USED == 1)
00166   /* Create the TFTP server task.  This uses the lwIP RTOS abstraction layer.*/
00167   sys_thread_new( "TFTP", vBasicTFTPServer, ( void * ) NULL,
00168                    CTRLPANEL_TFTP_SERVER_STACK_SIZE,
00169                    CTRLPANEL_TFTP_SERVER_PRIORITY );
00170 #endif
00171 
00172 #if (SMTP_USED == 1)
00173   /* Create the SMTP Client task.  This uses the lwIP RTOS abstraction layer.*/
00174   sys_thread_new( "SMTP", vBasicSMTPClient, ( void * ) NULL,
00175                    CTRLPANEL_SMTP_CLIENT_STACK_SIZE,
00176                    CTRLPANEL_SMTP_CLIENT_PRIORITY );
00177 #endif
00178   // Kill this task.
00179   vTaskDelete(NULL);
00180 }

static void prv_v_set_default_macaddr ( unsigned portCHAR  aMacAddress[]  )  [static]

Set the default mac addr.

Parameters:
aMacAddress[] Mac address array of len 6.

Definition at line 546 of file ethernet.c.

References ETHERNET_CONF_ETHADDR0, ETHERNET_CONF_ETHADDR1, ETHERNET_CONF_ETHADDR2, ETHERNET_CONF_ETHADDR3, ETHERNET_CONF_ETHADDR4, and ETHERNET_CONF_ETHADDR5.

Referenced by prv_v_set_default_netconfig(), and prvEthernetConfigureInterface().

00546 {
00547    aMacAddress[0] = ETHERNET_CONF_ETHADDR0;
00548    aMacAddress[1] = ETHERNET_CONF_ETHADDR1;
00549    aMacAddress[2] = ETHERNET_CONF_ETHADDR2;
00550    aMacAddress[3] = ETHERNET_CONF_ETHADDR3;
00551    aMacAddress[4] = ETHERNET_CONF_ETHADDR4;
00552    aMacAddress[5] = ETHERNET_CONF_ETHADDR5;
00553 }
00554 

static void prv_v_set_default_netconfig ( unsigned portCHAR  aMacAddress[],
struct ip_addr *  pxIpAddr,
struct ip_addr *  pxNetMask,
struct ip_addr *  pxGateway 
) [static]

Set the default network configuration.

Parameters:
aMacAddress[] Mac address array of len 6
pxIpAddr pointer on Ip address struct
pxNetMask pointer on network mask address struct
pxGateway pointer on gateway Ip address struct

Definition at line 564 of file ethernet.c.

References ETHERNET_CONF_GATEWAY_ADDR0, ETHERNET_CONF_GATEWAY_ADDR1, ETHERNET_CONF_GATEWAY_ADDR2, ETHERNET_CONF_GATEWAY_ADDR3, ETHERNET_CONF_IPADDR0, ETHERNET_CONF_IPADDR1, ETHERNET_CONF_IPADDR2, ETHERNET_CONF_IPADDR3, ETHERNET_CONF_NET_MASK0, ETHERNET_CONF_NET_MASK1, ETHERNET_CONF_NET_MASK2, ETHERNET_CONF_NET_MASK3, and prv_v_set_default_macaddr().

Referenced by prvEthernetConfigureInterface().

00567 {
00568    // Default MAC addr.
00569    prv_v_set_default_macaddr( aMacAddress );
00570    // pass the MACB address to AVR32_EMAC module
00571    vMACBSetMACAddress( aMacAddress );
00572    // set MAC hardware address length to be used by lwIP
00573    // MACB_if.hwaddr_len = 6;
00574    // set MAC hardware address to be used by lwIP
00575    // memcpy(MACB_if.hwaddr, aMacAddress, MACB_if.hwaddr_len);
00576 
00577    // Default ip addr.
00578    IP4_ADDR(pxIpAddr,ETHERNET_CONF_IPADDR0,ETHERNET_CONF_IPADDR1,ETHERNET_CONF_IPADDR2,ETHERNET_CONF_IPADDR3);
00579 
00580    // Default Subnet mask.
00581    IP4_ADDR(pxNetMask,ETHERNET_CONF_NET_MASK0,ETHERNET_CONF_NET_MASK1,ETHERNET_CONF_NET_MASK2,ETHERNET_CONF_NET_MASK3);
00582 
00583    // Default Gw addr.
00584    IP4_ADDR(pxGateway,ETHERNET_CONF_GATEWAY_ADDR0,ETHERNET_CONF_GATEWAY_ADDR1,ETHERNET_CONF_GATEWAY_ADDR2,ETHERNET_CONF_GATEWAY_ADDR3);
00585 }
00586 }

static void prvEthernetConfigureInterface ( void *  param  )  [static]

set ethernet config, by parsing ETHERNET_CONFIG_FILE file.

Definition at line 407 of file ethernet.c.

References config_file_get_value(), ETHERNET_CONF_GATEWAY_ADDR0, ETHERNET_CONF_GATEWAY_ADDR1, ETHERNET_CONF_GATEWAY_ADDR2, ETHERNET_CONF_GATEWAY_ADDR3, ETHERNET_CONF_IPADDR0, ETHERNET_CONF_IPADDR1, ETHERNET_CONF_IPADDR2, ETHERNET_CONF_IPADDR3, ETHERNET_CONF_NET_MASK0, ETHERNET_CONF_NET_MASK1, ETHERNET_CONF_NET_MASK2, ETHERNET_CONF_NET_MASK3, ETHERNET_CONFIG_FILE, MACB_if, prv_v_set_default_macaddr(), prv_v_set_default_netconfig(), vEthernetGetIPAddr(), vMMI_DisplayIP(), x_supervisor_SemaphoreGive(), x_supervisor_SemaphoreTake(), and xCFGMutex.

Referenced by prvlwIPInit().

00407 {
00408 struct ip_addr xIpAddr, xNetMask, xGateway;
00409 extern err_t ethernetif_init( struct netif *netif );
00410 portCHAR token[18];
00411 portCHAR IPAddress[16];
00412 portCHAR * current;
00413 unsigned portCHAR MacAddress[6];
00414 portSHORT NbDigits = 0;
00415 unsigned int AddrByte;
00416 
00417 
00418   // We're going to access the file system to do configuration
00419   // => get the CFG mutex.
00420   if( pdFALSE == x_supervisor_SemaphoreTake( xCFGMutex, 0 ) )
00421   { // Failed to get the CFG mutex.
00422     /* Use default parameters. */
00423     prv_v_set_default_netconfig( MacAddress, &xIpAddr, &xNetMask, &xGateway );
00424   }
00425   /* open the config file */
00426   else
00427   {
00428     if (config_file_get_value(ETHERNET_CONFIG_FILE, "macaddr" , token) >= 0)
00429     {
00430       current = token;
00431       while (NbDigits < 6)
00432       {
00433         /* get two next bytes and convert as integer */
00434         sscanf(current, "%02x", &AddrByte);
00435         MacAddress[NbDigits++] = (portCHAR)AddrByte;
00436         current = strpbrk(current, ":");
00437 
00438         if ((current == NULL) && (NbDigits != 6))
00439         {
00440           prv_v_set_default_macaddr( MacAddress );
00441           break;
00442         }
00443         current++;
00444       }
00445     }
00446     else
00447     {
00448       /* can't find field in config file, use default parameters */
00449       prv_v_set_default_macaddr( MacAddress );
00450     }
00451     /* pass the MACB address to AVR32_EMAC module */
00452     vMACBSetMACAddress(MacAddress);
00453     /* set MAC hardware address length to be used by lwIP */
00454     // MACB_if.hwaddr_len = 6;
00455     /* set MAC hardware address to be used by lwIP */
00456     // memcpy((char *)MACB_if.hwaddr, MacAddress, MACB_if.hwaddr_len);
00457 
00458     if (config_file_get_value(ETHERNET_CONFIG_FILE, "ipaddr" , token) >= 0)
00459     {
00460       /* get IP address */
00461       xIpAddr.addr = inet_addr(token);
00462     }
00463     else
00464     {
00465       /* can't find field in config file, use default parameters */
00466       IP4_ADDR(&xIpAddr,ETHERNET_CONF_IPADDR0,ETHERNET_CONF_IPADDR1,ETHERNET_CONF_IPADDR2,ETHERNET_CONF_IPADDR3);
00467     }
00468 
00469     if (config_file_get_value(ETHERNET_CONFIG_FILE, "submask", token) >= 0)
00470     {
00471       /* get subnet mask */
00472       xNetMask.addr = inet_addr(token);
00473     }
00474     else
00475     {
00476       /* can't find field in config file, use default parameters */
00477       IP4_ADDR(&xNetMask,ETHERNET_CONF_NET_MASK0,ETHERNET_CONF_NET_MASK1,ETHERNET_CONF_NET_MASK2,ETHERNET_CONF_NET_MASK3);
00478     }
00479 
00480     if (config_file_get_value(ETHERNET_CONFIG_FILE, "gwaddr" , token) >= 0)
00481     {
00482       /* get GW address */
00483       xGateway.addr = inet_addr(token);
00484     }
00485     else
00486     {
00487       /* can't find field in config file, use default parameters */
00488       IP4_ADDR(&xGateway,ETHERNET_CONF_GATEWAY_ADDR0,ETHERNET_CONF_GATEWAY_ADDR1,ETHERNET_CONF_GATEWAY_ADDR2,ETHERNET_CONF_GATEWAY_ADDR3);
00489     }
00490     // Release the CFG mutex.
00491     x_supervisor_SemaphoreGive( xCFGMutex );
00492   }
00493 
00494   /* add data to netif */
00495   netif_add(&MACB_if, &xIpAddr, &xNetMask, &xGateway, NULL, ethernetif_init, tcpip_input);
00496   /* make it the default interface */
00497   netif_set_default(&MACB_if);
00498   /* bring it up */
00499   netif_set_up(&MACB_if);
00500   /* get new IP Address */
00501   vEthernetGetIPAddr(IPAddress);
00502   /* set IP Address to Display */
00503 #ifdef MMILCD_ENABLE
00504   vMMI_DisplayIP(IPAddress);
00505 #endif
00506 }
00507 

static void prvlwIPInit ( void   )  [static]

start lwIP layer.

Definition at line 390 of file ethernet.c.

References prvEthernetConfigureInterface(), and tcpip_init_done().

Referenced by portTASK_FUNCTION().

00390 {
00391   sys_sem_t sem;
00392 
00393 
00394   sem = sys_sem_new(0); // Create a new semaphore.
00395   tcpip_init(tcpip_init_done, &sem);
00396   sys_sem_wait(sem);    // Block until the lwIP stack is initialized.
00397   sys_sem_free(sem);    // Free the semaphore.
00398 
00399   /* Set hw and IP parameters, initialize MACB too */
00400   prvEthernetConfigureInterface(NULL);
00401 }
00402 

static void tcpip_init_done ( void *  arg  )  [static]

Callback executed when the TCP/IP init is done.

Definition at line 184 of file ethernet.c.

Referenced by prvlwIPInit().

00185 {
00186   sys_sem_t *sem;
00187   sem = (sys_sem_t *)arg;
00188   sys_sem_signal(*sem); // Signal the waiting thread that the TCP/IP init is done.
00189 }

void v_ethernet_stopResources ( void   ) 

Stop the ethernet module resources.

Definition at line 194 of file ethernet.c.

Referenced by e_syscmds_reboot().

00195 {
00196   // Disable the MACB.
00197   vDisableMACBOperations( &AVR32_MACB );
00198 }

void vEthernetGetGWAddr ( portCHAR *  pcConfig  ) 

get the current GW address : formatted as follow : XXX.XXX.XXX.XXX

Parameters:
pcConfig Input/Output. The response string. If Input is NULL, no response string will be output. The caller has to allocate this buffer

Definition at line 269 of file ethernet.c.

References MACB_if, and sprintf().

Referenced by e_ethernet_cmd_get_config().

00269 {
00270   if (pcConfig != NULL)
00271   {
00272     sprintf(pcConfig,"%d.%d.%d.%d", (u16_t)(ntohl((MACB_if.gw.addr) >> 24) & 0xff),
00273                                 (u16_t)(ntohl((MACB_if.gw.addr) >> 16) & 0xff),
00274                                 (u16_t)(ntohl((MACB_if.gw.addr) >> 8) & 0xff),
00275                                 (u16_t) ntohl((MACB_if.gw.addr) & 0xff ));
00276   }
00277 }
00278 

void vEthernetGetIPAddr ( portCHAR *  pcConfig  ) 

get the current IP address : formatted as follow : XXX.XXX.XXX.XXX

Parameters:
pcConfig Input/Output. The response string. If Input is NULL, no response string will be output. The caller has to allocate this buffer

Definition at line 228 of file ethernet.c.

References MACB_if, and sprintf().

Referenced by e_ethernet_cmd_get_config(), prulweb_BuildErrorTail(), and prvEthernetConfigureInterface().

00229 {
00230   if (pcConfig != NULL)
00231   {
00232     sprintf(pcConfig,"%d.%d.%d.%d", (u16_t)(ntohl((MACB_if.ip_addr.addr) >> 24) & 0xff),
00233                                 (u16_t)(ntohl((MACB_if.ip_addr.addr) >> 16) & 0xff),
00234                                 (u16_t)(ntohl((MACB_if.ip_addr.addr) >> 8) & 0xff),
00235                                 (u16_t) ntohl((MACB_if.ip_addr.addr) & 0xff ));
00236   }
00237 }

void vEthernetGetMACAddr ( portCHAR *  pcConfig  ) 

get the current MAC address : formatted as follow : XX:XX:XX:XX:XX:XX

Parameters:
pcConfig Input/Output. The response string. If Input is NULL, no response string will be output. The caller has to allocate this buffer

Definition at line 209 of file ethernet.c.

References MACB_if, and sprintf().

Referenced by e_ethernet_cmd_get_config().

00210 {
00211   if (pcConfig != NULL)
00212   {
00213     sprintf(pcConfig, "%02x:%02x:%02x:%02x:%02x:%02x", MACB_if.hwaddr[0], MACB_if.hwaddr[1],
00214                                                        MACB_if.hwaddr[2], MACB_if.hwaddr[3],
00215                                                        MACB_if.hwaddr[4], MACB_if.hwaddr[5]);
00216   }
00217 }

void vEthernetGetSubnetMask ( portCHAR *  pcConfig  ) 

get the current Subnet mask : formatted as follow : XXX.XXX.XXX.XXX

Parameters:
pcConfig Input/Output. The response string. If Input is NULL, no response string will be output. The caller has to allocate this buffer

Definition at line 249 of file ethernet.c.

References MACB_if, and sprintf().

Referenced by e_ethernet_cmd_get_config().

00249 {
00250   if (pcConfig != NULL)
00251   {
00252     sprintf(pcConfig,"%d.%d.%d.%d", (u16_t)(ntohl((MACB_if.netmask.addr) >> 24) & 0xff),
00253                                 (u16_t)(ntohl((MACB_if.netmask.addr) >> 16) & 0xff),
00254                                 (u16_t)(ntohl((MACB_if.netmask.addr) >> 8) & 0xff),
00255                                 (u16_t) ntohl((MACB_if.netmask.addr) & 0xff ));
00256   }
00257 }
00258 

void vStartEthernetTaskLauncher ( unsigned portBASE_TYPE  uxPriority  ) 

Create the vStartEthernetTask task.

Definition at line 125 of file ethernet.c.

References configMINIMAL_STACK_SIZE.

Referenced by portTASK_FUNCTION().

00126 {
00127   /* Spawn the Sentinel task. */
00128   xTaskCreate( vStartEthernetTask, ( const signed portCHAR * )"ETHLAUNCH",
00129                configMINIMAL_STACK_SIZE + 192, NULL, uxPriority, ( xTaskHandle * )NULL );
00130 }


Variable Documentation

struct netif MACB_if

xSemaphoreHandle xCFGMutex

The CFG system mutex.

Definition at line 203 of file supervisor.c.


Generated on Thu Dec 17 19:56:59 2009 for AVR32 - Control Panel demonstration. by  doxygen 1.5.5