Introduction

 

This blog discusses about network interface through Ethernet with CYW943907AEVAL1F.

The CYW43907 integrates a high performance Ethernet MAC controller. The controller interfaces to an external PHY either over a

Media Independent Interface (MII) or a Reduced Media Independent Interface (RMII). The controller can transmit and receive data at

10 Mbps and 100 Mbps. Below table shows the signal descriptions for CYW43907 Ethernet MAC.

 

Signal Name
Type
Description
RMII_G_RXCIMII receive clock
RMII_G_COLIMII collision detection
RMII_G_CRSIMII carrier sense
RMII_G_TXCIMII/RMII transmit clock
RMII_G_TXD0OMII/RMII transmit signal
RMII_G_TXD1OMII/RMII transmit signal
RMII_G_TXD2OMII transmit signal
RMII_G_TXD3OMII transmit signal
RMII_G_RXD0IMII/RMII receive signal
RMII_G_RXD1IMII/RMII receive signal
RMII_G_RXD2IMII receive signal
RMII_G_RXD3IMII receive signal
RMII_MDIOI/OMII/RMII management data
RMII_MDCOMII/RMII management clock
RMII_G_TXENOMII/RMII transmit enable
RMII_G_RXDVIMII/RMII receive data valid

 

 

 

Application

 

Download the attached zip file, extract to folder tcp_client_ethernet and add the folder to <WICED SDK>/43xxx_Wi-Fi/apps/snip.

tcp_client_ethernet.JPG

 

Open tcp_client_ethernet.c and follow application instructions mentioned in the source code.

Appl Instructions.JPG

 

Once the program is successfully compiled and downloaded. Observe the serial terminal for message logs.

serial terminal.JPG

 

At the same time observe the message logs of TCP echo server which looks as below,

tcp_server.JPG

 

 

Application Details

 

I. The macro TCP_SERVER_IP_ADDRESS in #define TCP_SERVER_IP_ADDRESS MAKE_IPV4_ADDRESS(192,168,1,2) definition contains the IP address of TCP echo server.

II. The device_init_ip_settings in the following declaration sets the provided IPv4 address to CYW943907AEVAL1F. Assign ip_address, netmask and gateway to device_init_ip_settings depending the on the gateway and netmask values of your AP/router.

      device_init_ip_settings.JPG

The netmask and gateway values can be found by using the command ipconfig  in the command window of PC (TCP Server) connected to the same AP as CYW943907AEVAl1F.

ipconfig_edited.jpg

 

III. wiced_core_init( ) initializes platform related APIs, RTOS functions and the device configuration table.

IV. wiced_network_init( ) initializes the network interface and creates packet pools for transmission and reception.

V. The API wiced_network_up( WICED_ETHERNET_INTERFACE, WICED_USE_STATIC_IP, &device_init_ip_settings ) brings up the network as WICED_ETHERNET_INTERFACE with the IP configuration as WICED_USE_STATIC_IP and initializes IP settings to device_init_ip_settings. IP configurations can be changed to WICED_USE_EXTERNAL_DHCP_SERVER_RESTORE or WICED_USE_EXTERNAL_DHCP_SERVER and NULL can be passed to wiced_network_up() instead of &device_init_ip_settings.

Note: The network IP configuration can be changed to WICED_USE_EXTERNAL_DHCP_SERVER_RESTORE or WICED_USE_EXTERNAL_DHCP_SERVER as below.

  1. wiced_network_up( WICED_ETHERNET_INTERFACE, WICED_USE_EXTERNAL_DHCP_SERVER_RESTORE , NULL ), or
  2. wiced_network_up( WICED_ETHERNET_INTERFACE, WICED_USE_EXTERNAL_DHCP_SERVER , NULL )

WICED_USE_EXTERNAL_DHCP_SERVER_RESTORE uses an external DHCP server and restores the last saved DHCP state. Since IP configuration is set to external DHCP server, NULL is passed instead of device_init_ip_settings in wiced_network_up () and device_init_ip_settings definition has to commented.

 

VI. The API wiced_tcp_create_socket( &tcp_client_socket, WICED_ETHERNET_INTERFACE ) creates a TCP socket over the network Ethernet interface.

VII. The API wiced_tcp_bind( &tcp_client_socket, TCP_SERVER_PORT ) binds tcp_client_socket to the local port TCP_SERVER_PORT (50007).

VIII. The API wiced_rtos_register_timed_event() registers a function that will be called at a regular interval.

IX. The API wiced_tcp_connect( &tcp_client_socket, &server_ip_address, TCP_SERVER_PORT, TCP_CLIENT_CONNECT_TIMEOUT ) establishes connection between client and server over predefined over defined ports.

X. The API wiced_packet_create_tcp(&tcp_client_socket, TCP_PACKET_MAX_DATA_LENGTH, &packet, (uint8_t**)&tx_data, &available_data_length) creates a TCP packet by automatically allocating memory for the tx_data.

XI. wiced_packet_set_data_end(packet, (uint8_t*)tx_data + strlen(tx_data)) sets the end of the data portion.

XII. The API wiced_tcp_send_packet(&tcp_client_socket, packet) sends the TCP data , if the data transmission fails the packet will be deleted by wiced_packet_delete(packet) and connection will be closed by wiced_tcp_disconnect(&tcp_client_socket).

XIII. The contents of the received packet will be retrieved by the API wiced_packet_get_data(). After retrieving the contents in rx_data[ ], packet will be deleted and connection will be disconnected.

XIV. AP and Ethernet could be brought up together by following the steps below.

     1. Define a variable for access point IP settings as below,

          ap_ip_settings.JPG

     2. Bring up network with interface as WICED_AP_INTERFACE, IP configuration as WICED_USE_INTERNAL_DHCP_SERVER and static IP interface as ap_ip_settings.

          ap network up.JPG