Microchip® Advanced Software Framework

avr32/applications/evk1100-control-panel/network/ethernet.c File Reference
#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 "lwip/sys.h"
#include "lwip/api.h"
#include "lwip/tcpip.h"
#include "lwip/memp.h"
#include "lwip/stats.h"
#include "lwip/init.h"
#include "supervisor.h"
#include "shell.h"
#include "mmi.h"

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. More...
 
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. More...
 
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. More...
 
 portTASK_FUNCTION (vStartEthernetTask, pvParameters)
 create ethernet task, for ethernet management. More...
 
static void prv_v_set_default_macaddr (unsigned portCHAR aMacAddress[])
 Set the default mac addr. More...
 
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. More...
 
static void prvEthernetConfigureInterface (void *param)
 set Ethernet config, by parsing ETHERNET_CONFIG_FILE file. More...
 
static void prvlwIPInit (void)
 start lwIP layer. More...
 
static void tcpip_init_done (void *arg)
 Callback executed when the TCP/IP init is done. More...
 
void v_ethernet_stopResources (void)
 Stop the Ethernet module resources. More...
 
void vEthernetGetGWAddr (portCHAR *pcConfig)
 get the current GW address : formatted as follow : XXX.XXX.XXX.XXX More...
 
void vEthernetGetIPAddr (portCHAR *pcConfig)
 get the current IP address : formatted as follow : XXX.XXX.XXX.XXX More...
 
void vEthernetGetMACAddr (portCHAR *pcConfig)
 get the current MAC address : formatted as follow : XX:XX:XX:XX:XX:XX More...
 
void vEthernetGetSubnetMask (portCHAR *pcConfig)
 get the current Subnet mask : formatted as follow : XXX.XXX.XXX.XXX More...
 
void vStartEthernetTaskLauncher (unsigned portBASE_TYPE uxPriority)
 Create the vStartEthernetTask task. More...
 

Variables

struct netif MACB_if
 
xSemaphoreHandle xCFGMutex
 

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
xModIdInput. The module that is calling this function.
FsNavIdIgnored.
acInput. The argument counter. For this command, should be 3.
avInput. The argument vector.
ppcStringReplyInput/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.

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

Referenced by e_syscmds_cmd_get_config().

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
xModIdInput. The module that is calling this function.
FsNavIdIgnored.
acInput. The argument counter. For this command, should be 1.
avInput. The argument vector.
ppcStringReplyInput/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.

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

Referenced by e_syscmds_cmd_set_config().

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
xModIdInput. The module that is calling this function.
FsNavIdIgnored.
acInput. The argument counter. Ignored.
avInput. The argument vector. Ignored
ppcStringReplyInput/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.

References NULL, SHELL_EXECSTATUS_OK, and stats_display.

portTASK_FUNCTION ( vStartEthernetTask  ,
pvParameters   
)
static void prv_v_set_default_macaddr ( unsigned portCHAR  aMacAddress[])
static

Set the default mac addr.

Parameters
aMacAddress[]Mac address array of len 6.

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().

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
pxIpAddrpointer on Ip address struct
pxNetMaskpointer on network mask address struct
pxGatewaypointer on gateway Ip address struct

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, prv_v_set_default_macaddr(), and vMACBSetMACAddress().

Referenced by prvEthernetConfigureInterface().

static void prvlwIPInit ( void  )
static

start lwIP layer.

References ERR_OK, sys_sem_free(), sys_sem_new(), sys_sem_wait, tcpip_init(), and tcpip_init_done().

Referenced by portTASK_FUNCTION().

static void tcpip_init_done ( void *  arg)
static

Callback executed when the TCP/IP init is done.

References NULL, prvEthernetConfigureInterface(), and sys_sem_signal().

Referenced by prvlwIPInit().

void v_ethernet_stopResources ( void  )

Stop the Ethernet module resources.

References vDisableMACBOperations().

Referenced by e_syscmds_reboot().

void vEthernetGetGWAddr ( portCHAR *  pcConfig)

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

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

References netif::gw, MACB_if, ntohl, NULL, and sprintf().

Referenced by e_ethernet_cmd_get_config().

void vEthernetGetIPAddr ( portCHAR *  pcConfig)

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

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

References netif::ip_addr, MACB_if, ntohl, NULL, and sprintf().

Referenced by e_ethernet_cmd_get_config(), and prvEthernetConfigureInterface().

void vEthernetGetMACAddr ( portCHAR *  pcConfig)

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

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

References netif::hwaddr, MACB_if, NULL, and sprintf().

Referenced by e_ethernet_cmd_get_config().

void vEthernetGetSubnetMask ( portCHAR *  pcConfig)

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

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

References MACB_if, netif::netmask, ntohl, NULL, and sprintf().

Referenced by e_ethernet_cmd_get_config().

void vStartEthernetTaskLauncher ( unsigned portBASE_TYPE  uxPriority)

Create the vStartEthernetTask task.

Parameters
uxPriorityInput; priority of the task to create.

References configMINIMAL_STACK_SIZE, NULL, and xTaskCreate.

struct netif MACB_if
xSemaphoreHandle xCFGMutex

The CFG system mutex.