Manual

GPIO Wi-Fi Demo Quick Start Guide

sw_gpio_examples GPIO and Wi-Fi demo : Quick Start Guide

This example demonstrates the use of two Slice Cards, XA-SK-GPIO and XA-SK-WIFI slice together with the xSOFTip components for Wi-Fi, SPI, I2C and WebServer to provide access to the GPIO slice features via a simple embedded webserver.

A webpage served from the sliceKIT and accessed in a browser on a host PC has the following demo functions:
  • Turn GPIO Slice Card LEDS on and off
  • Read the room temperature via the on-board ADC and display on the web page
  • Display GPIO Slice Card button press status

Hardware Setup

The XP-SKC-L2 Slicekit Core board has four slots with edge connectors: SQUARE, CIRCLE, TRIANGLE and STAR.

To setup up the system refer to the figure and instructions below

  1. Connect the XA-SK-WIFI Slice Card to the XP-SKC-L2 Slicekit Core board using the connector marked with the TRIANGLE.
  2. Connect the XA-SK-GPIO Slice Card to the XP-SKC-L2 Slicekit Core board using the connector marked with the SQUARE.
  3. Connect the XTAG Adapter to Slicekit Core board, and connect XTAG-2 to the adapter.
  4. Connect the XTAG-2 to the host PC.
  5. Make sure your wireless access point is switched on and configured correctly.
  6. Switch on the power supply to the Slicekit Core board.
Hardware Setup for the GPIO and Wi-Fi Application Demo

/files/images/16452/5/hardware_setup.png

Import and Build the Application

  1. Open xTIMEcomposer and then open the edit perspective (Window->Open Perspective->XMOS Edit).
  2. Locate 'Slicekit GPIO Wi-Fi Demo' item in the xSOFTip Broswer window and drag it into the Project Explorer window in xTIMEcomposer. This will also cause the modules on which this application depends (in this case, module_wifi_tiwisl, module_spi_master, module_i2c_master, module_webserver) to be imported as well.
  3. Click on the Slicekit GPIO Wi-Fi Demo item in the Explorer pane then click on the build icon (hammer) in xTIMEcomposer. Check the console window to verify that the application has built successfully.

For help in using xTIMEcomposer, try the xTIMEcomposer tutorials, which you can find by selecting Help->Tutorials from the xTIMEcomposer menu.

Running the Demo

  1. Enable offline Xscope printing in the run configurations. Run Configuration -> XScope: Select Offline [Xscope] mode.
  2. Click on the Run icon (the white arrow in the green circle). A dialog will appear asking which device to connect to. Select XMOS XTAG2.
  3. xTIMEcomposer console displays the IP address obtained by the DHCP client
  4. Open a web browser on the host PC and type the IP address displayed on the xTIMEcomposer console into the browser’s address bar
  5. On hitting the return key, a web page should get loaded and displayed in the browser as shown in the figure below.
Screenshot of GPIO web page

/files/images/16452/5/gpio_web_page.png

Use the web page options to perform various actions such as
  1. Switch on all the LEDS by turning them all to ‘ON’ in the browser then clicking Submit. The LEDS should light, the ADC temperature display should be updated, and the webpage will report no buttons have been pressed.
  2. Switch off two of the LEDS by turning two to ‘OFF’ in the browser then clicking Submit. Two LEDS should go out and the ADC temperature is reported again. This time also webpage will report no buttons have been pressed.
  3. Press SW1 button on the GPIO slice card and then press submit. The web page should now report that Button 1 is pressed.
  4. Press SW2 button on the GPIO slice card and then press submit. The web page should now report that Button 2 is pressed.
  5. Just hitting Submit now displays both the buttons are not pressed. LEDs states remain unchanged unless they are explicitly changed on the web page.

Next Steps

Look at the Code

  1. Examine the application code. In xTIMEcomposer navigate to the src directory under app_sk_gpio_wifi_tiwisl_combo_demo and double click on the main.xc file within it. The file will open in the central editor window.
  2. The channel c_gpio is used between web page handler and application handler to send web page requests to the application and to collect GPIO status from the application.
  3. In the app_handler.xc file, API set_gpio_state is used by the web page in order to apply web page LED settings and similarly API get_gpio_state is used by web page to collect the current GPIO status containing LEDs, button presses and ADC temperature values.
  4. GPIO button scan logic monitors for value changes on the configured 4-bit button port (XS1_PORT_4C) in the application handler routine as defined in the app_handler.xc file. Whenever this port value changes, GPIO button states are updated accordingly.
  5. You can also observe that the ADC value is read whenever there is a web page request. This value is interpolated to get a proper temperature value and is updated in the GPIO state structure before sending it to the web page.

Building web pages for your applications

This application parses Wi-Fi data to interpret web page commands. Refer to Programming Guide section within the SliceKit GPIO Example Applications documentation linked from the front page documentation for this demo for more information on how to utilize the Embedded Webserver Function Library component in building your own custom web server applications.

GPIO Wi-Fi Demo Quick Start Guide Read More »

XA-SK-SCR480 Slice Card Hardware Guide

Pack Contents

  • One XA-SK-SCR480 Slice Card
  • One Kentec K430WQA-V4-F 480×272 Colour Resisitive Touch Screen with cable

Parallel RGB565

This slice provides power supply electronics and a 40-pin ZIF connector for the included LCD, plus a low cost resistive touch screen controller that interfaces to the LCD and to the XCore via a 2-wire interface. The touch functionality is only accesible when the Slice is placed in the TRIANGLE slot.

The parallel RGB interface is driven directly from the xSOFTip LCD controller component running on the xCORE using 1 16 bit port and 4 1-bit ports. The xSOFTip LCD controller is capable of driving screens with resolutions up to 800×600 (in conjunction with the XA-SK-SDRAM Slice Card and xSOFTip SDRAM controller component).

Resistive Touch Controller

An Analog Devices Touch Screen Controller ADC is provided on the Slice Card and interfaced to the xCORE via an I2C bus and an interrupt line. This can be used to provide resistive touch co-ordinate information to software applications written for this Slice.

This table shows the port mapping for each of the Slice Card Signal IO, and the Slicekit Slot connector pin it is located on.

Function

STAR

TRIANGLE

SQUARE

PIN

Description

1 bit

NC

1A

NC

B2

 

1 bit

NC

1D

NC

B4

 

I2C_SCL

NC

1E

NC

A3

I2C clock for touch controller

I2C_SDA

NC

1H

NC

A4

I2C data for touch controller

1 bit

1C

1K

1C

B10

LCD Vsync

PENIRQ#

1B

1J

1B

A8

Interrupt from touch controller

1 bit

1G

1I

1G

B15

LCD Hsync

LCD_DE

1F

1L

1F

A15

LCD Data Enable

LCD_R0

16A0

16B0

16A0

B6

LCD Parallel RGB Data

LCD_R1

16A1

16B1

16A1

B7

LCD Parallel RGB Data

LCD_R2

16A2

16B2

16A2

B9

LCD Parallel RGB Data

LCD_R3

16A3

16B3

16A3

B11

LCD Parallel RGB Data

LCD_R4

16A4

16B4

16A4

A9

LCD Parallel RGB Data

LCD_G0

16A5

16B5

16A5

A11

LCD Parallel RGB Data

LCD_G1

16A6

16B6

16A6

A6

LCD Parallel RGB Data

LCD_G2

16A7

16B7

16A7

A7

LCD Parallel RGB Data

LCD_G3

16A8

16B8

16A8

B12

LCD Parallel RGB Data

LCD_G4

16A9

16B9

16A9

B13

LCD Parallel RGB Data

LCD_G5

16A10

16B10

16A10

B17

LCD Parallel RGB Data

LCD_B0

16A11

16B11

16A11

B18

LCD Parallel RGB Data

LCD_B1

16A12

16B12

16A12

A17

LCD Parallel RGB Data

LCD_B2

16A13

16B13

16A13

A18

LCD Parallel RGB Data

LCD_B3

16A14

16B14

16A14

A12

LCD Parallel RGB Data

LCD_B4

16A15

16B15

16A15

A13

LCD Parallel RGB Data

XA-SK-SCR480 Slice Card Hardware Guide Read More »

XA-SK-SDRAM Slice Card hardware Guide

Pack Contents

  • One XA-SK-SDRAM Slice Card

Random Access Memory

This slice provides 8 Megebytes of random access memory via an ISSI 6400 Synchronous DRAM. It is suitable for burst access only, random access is possible but performance will be very significantly degraded. The associated SDRAM Controll xSOFTip component can operate this memory at clock speeds up to 40 MHz, yielding an aggregate performance of 80 MBytes/sec.

Reduced Pinout

The SDRAM slice uses a technique of reusing the same XCore GPIO pins for both Address and Data. This optimisation is made possible tahnks to the soft nature of the associated xSOFTip sdram controller component. In addition, a NOR gate on the slice generates the data strobes (UDQM and LDQM on the memory chip) from CAS# and WE#. These features are described more fully in the SDRAM Controller xSOFTip component documentation.

Taken together, these features permit the addition of a high performance SDRAM subsystem to any XCore application using only 20 pins.

This table shows the port mapping for each of the Slice Card Signal IO, and the Slicekit Slot connector pin it is located on.

Function

STAR

TRIANGLE

SQUARE

PIN

Description

SD_WE

1C

1K

1C

B10

SDRAM Write Enable

SD_CAS

1B

1J

1B

A8

SDRAM CAS

SD_RAS

1G

1I

1G

B15

SDRAM RAS

SD_CLK

1F

1L

1F

A15

SDRAM Clock drivern from XCore

SD_ADQ0

A0

B0

A0

B6

SDRAM Address and Data

SD_ADQ1

A1

B1

A1

B7

SDRAM Address and Data

SD_ADQ2

A2

B2

A2

B9

SDRAM Address and Data

SD_ADQ3

A3

B3

A3

B11

SDRAM Address and Data

SD_ADQ4

A4

B4

A4

A9

SDRAM Address and Data

SD_ADQ5

A5

B5

A5

A11

SDRAM Address and Data

SD_ADQ6

A6

B6

A6

A6

SDRAM Address and Data

SD_ADQ7

A7

B7

A7

A7

SDRAM Address and Data

SD_ADQ8

A8

B8

A8

B12

SDRAM Address and Data

SD_ADQ9

A9

B9

A9

B13

SDRAM Address and Data

SD_ADQ10

A10

B10

A10

B17

SDRAM Address and Data

SD_ADQ11

A11

B11

A11

B18

SDRAM Address and Data

SD_ADQ12

A12

B12

A12

A17

SDRAM Address and Data

SD_DQ13/BA0

A13

B13

A13

A18

SDRAM Bank Address and Data

SD_DQ14/BA1

A14

B14

A14

A12

SDRAM Bank Address and Data

SD_DQ15

A15

B15

A15

A13

SDRAM Data

XA-SK-SDRAM Slice Card hardware Guide Read More »

XA-SK-UART-8 Slice Card Hardware Guide

Pack Contents

  • One XA-SK-UART-8 Slice Card

RS232 Capability

8 Uarts are provided on two 8-bit ports. An RS232 signalling level optn is provided by four SP3222EB RS232 transceivers, each handling 4 tx or 4 rx lines. The EN_N enable pins of the transceivers are controlled by populating a jumper between pins 25 and 26 of header J3. If that jumper is populated then RS232 is disabled and TTL inputs/outputs for all uarts can be accessed via J3, otherwise RS232 inputs/outputs for all uarts can be accessed via J4.

Fixed Oscillator

A 1.8432 MHZ oscillator provides a fixed master reference frequency which is input into the XCore on a 1-bit port to allow the sc_multi_uart transmitter module software to obtain precise timing against standard UART baud rates.

DB9 Connector

Uart channel 0 (RX and TX) can be accessed either via pins 1 and 2 of J3 or J4, or via the DB9 connector. In the latter case, RS232 mode needs to be enabled as above.

This table shows the port mapping for each of the Slice Card Signal IO, and the Slicekit Slot connector pin it is located on.

Function

STAR

TRIANGLE

SQUARE

CIRCLE

PIN

Description

CLK_OUT

1F

1L

1F

1L

B2

1 Bit port free for GPIO

RXD0

8A0

8C0

8A0

8C0

B6

Rx Data for Uart #0

RXD1

8A1

8C1

8A1

8C1

B7

Rx Data for Uart #1

RXD2

8A2

8C2

8A2

8C2

A6

Rx Data for Uart #2

RXD3

8A3

8C3

8A3

8C3

A7

Rx Data for Uart #3

RXD4

8A4

8C4

8A4

NC

B9

Rx Data for Uart #4

RXD5

8A5

8C5

8A5

NC

B11

Rx Data for Uart #5

RXD6

8A6

8C6

8A6

NC

A9

Rx Data for Uart #6

RXD7

8A7

8C7

8A7

NC

A11

Rx Data for Uart #7

TXD0

8B0

8D0

8B0

8D0

B12

Tx Data for Uart #0

TXD1

8B1

8D1

8B1

8D1

B13

Tx Data for Uart #1

TXD2

8B2

8D2

8B2

8D2

B17

Tx Data for Uart #2

TXD3

8B3

8D3

8B3

8D3

B18

Tx Data for Uart #3

TXD4

8B4

8D4

8B4

NC

A18

Tx Data for Uart #4

TXD5

8B5

8D5

8B5

NC

A17

Tx Data for Uart #5

TXD6

8B6

8D6

8B6

NC

A12

Tx Data for Uart #6

TXD7

8B7

8D7

8B7

NC

A13

Tx Data for Uart #7

XA-SK-UART-8 Slice Card Hardware Guide Read More »

Display Controller Demo Quickstart Guide

In this demonstration we use the following hardware and software:
  • XA-SK-SCR480 Slice Card,
  • XA-SK-SDRAM Slice Card,
  • module_sdram,
  • module_lcd,
  • module_display_controller,
  • module_slicekit_support,

together to create a double buffered LCD controller. This application showcases some of the key software features and serves as an example on how to use an LCD without the real-time contraint of having to update the LCD line buffer.

Hardware Setup

The XP-SKC-L2 Slicekit Core board has four slots with edge conectors: SQUARE, CIRCLE, TRIANGLE and STAR.

To setup up the system:

  1. Connect XA-SK-SDRAM Slice Card to the XP-SKC-L2 Slicekit Core board using the connector marked with the TRIANGLE.
  2. Connect XA-SK-SCR480 Slice Card to the XP-SKC-L2 Slicekit Core board using the connector marked with the STAR.
  3. Connect the XTAG Adapter to Slicekit Core board, and connect XTAG-2 to the adapter.
  4. Connect the XTAG-2 to host PC. Note that the USB cable is not provided with the Slicekit starter kit.
  5. Set the XMOS LINK on the to OFF on the XTAG Adapter(XA-SK-XTAG2).
  6. Ensure the jumper on the XA-SK-SCR480 is bridged if the back light is required.
  7. Switch on the power supply to the Slicekit Core board.
Hardware Setup for Simple GPIO Demo

/files/images/15954/1/hardware_setup.jpg

Import and Build the Application

  1. Open xTIMEcomposer and check that it is operating in online mode. Open the edit perspective (Window->Open Perspective->XMOS Edit).
  2. Locate the 'Display Controller Demo' item in the xSOFTip pane on the bottom left of the window and drag it into the Project Explorer window in the xTIMEcomposer. This will also cause the modules on which this application depends to be imported as well.
  3. Click on the app_display_controller_demo item in the Explorer pane then click on the build icon (hammer) in xTIMEcomposer. Check the console window to verify that the application has built successfully.

For help in using xTIMEcomposer, try the xTIMEcomposer tutorial. FIXME add link.

Note that the Developer Column in the xTIMEcomposer on the right hand side of your screen provides information on the xSOFTip components you are using. Select the module_display_controller component in the Project Explorer, and you will see its description together with API documentation. Having done this, click the back icon until you return to this quickstart guide within the Developer Column.

Run the Application

Now that the application has been compiled, the next step is to run it on the Slicekit Core Board using the tools to load the application over JTAG (via the XTAG2 and Xtag Adaptor card) into the xCORE multicore microcontroller.

  1. Click on the Run icon (the white arrow in the green circle).
  2. Wait until the images have loaded over the XTAG connector from the host.
  3. There should be a series of 6 images the transition from one to another.

Next Steps

  1. Trying changing the files that are loaded form the host. To do this, produce an image of 480 by 272 pixels, save it in tga format uncompressed in “top left” format (“bottom left” will also work but the image will have to be upside-down). Save the file(s) into the app_display_controller_demo directory within your workspace.
  2. Each transition has a frame count that depecits the speed of the transition, try adjusting them and observe the results.
  3. Try writing an exciting transition effect. To do this begin with the template shown below, and refer to the Display Controller API documentation at Configuration Defines
    :
::
static void transition_exciting_impl(chanend server, unsigned next_image_fb,

unsigned image_from, unsigned image_to, unsigned line) {
//insert code here

}
unsigned transition_exciting(chanend server, unsigned frame_buf[2],

unsigned from, unsigned to, unsigned frames, unsigned cur_fb_index) {
unsigned next_fb_index;
for (unsigned frame = 0; frame < frames; frame++) {

next_fb_index = (cur_fb_index + 1) & 1;
for (unsigned line = 0; line < LCD_HEIGHT; line++)

transition_exciting_impl(server, frame_buf[next_fb_index], from, to, line);

frame_buffer_commit(server, frame_buf[next_fb_index]);
cur_fb_index = next_fb_index;

}
return cur_fb_index;

}

Display Controller Demo Quickstart Guide Read More »

Ethernet TCP/IP Component Programming Guide

The XMOS TCP/IP component provides a IP/UDP/TCP stack that connects to
the XMOS ethernet component. It enables several
clients to connect to it and send and receive on multiple TCP or UDP
connections. The stack has been designed for a low memory
embedded programming environment and despite its low memory footprint
provides a complete stack including ARP, IP, UDP, TCP, DHCP, IPv4LL,
ICMP and IGMP protocols.

The stack is based on the open-source stack uIP with modifications to
work efficiently on the XMOS architecture and communicate between tasks
using XC channels.

The TCP stack can either interface to a separate ethernet MAC or work
with an integrated MAC taking only 2 logical cores.

Seperate MAC + TCP/IP stack properties

  • Layer 2 packets can be sent and received independently of layer 3
  • Integrated support for high priority Qtagged packets
  • Integrated support for 802.1 Qav rate control
  • Packet filtering in an independent logical core
  • Works on a 400 MHz part

Two core ethernet plus integrated TCP/IP stack properties

  • Uses only 2 logical cores
  • High throughput
  • Uses lower memory footprint
  • Only TCP/IP sourced packets can be transmitted
  • 500 MHz parts only (MII core requires 62.5 MIPS)

Component Summary

Functionality

Provides a lightweight IP/UDP/TCP stack

Supported Standards

IP, UDP, TCP, DHCP, IPv4LL, ICMP, IGMP

Supported Devices

Requirements

XMOS Desktop Tools

v12.0 or later

XMOS Ethernet Component

2.2.0 or later

Software Architecture

The following Figure shows the architecture of the TCP/IP stack when
attaching to an independent Ethernet MAC through an XC channel:

XTCP software architecture

/files/images/15951/12/xtcp_arch-crop.png

The server runs on a single logical core and connects to the XMOS Ethernet
MAC component. It can then connect to several client
tasks over XC channels. To enable this option the define
XTCP_USE_SEPARATE_MAC needs to be set to 1 in the
xtcp_conf.h file in your application and run the
xtcp_server()
function.

Alternatively, the TCP/IP server and Ethernet server can be run as
an integrated system on two logical cores. This can be started by
running the ethernet_xtcp_server()
function.

IP Configuration

The server will determine its IP configuration based on the arguments
passed into the xtcp_server()
or ethernet_xtcp_server()

function.
If an address is supplied then that address will be used (a static IP address
configuration).

If no address is supplied then the server will first
try to find a DHCP server on the network to obtain an address
automatically. If it cannot obtain an address from DHCP, it will determine
a link local address (in the range 169.254/16) automatically using the
Zeroconf IPV4LL protocol.

To use dynamic address, the xtcp_server()
or
ethernet_xtcp_server()
function can be passed a null to
the ip configuration parameter.

Events and Connections

The TCP/IP stack client interface is a low-level event based
interface. This is to allow applications to manage buffering and
connection management in the most efficient way possible for the
application.

Example event sequence

/files/images/15951/12/events-crop.png

Each client will receive events from the server. These events
usually have an associated connection. In addition to receiving
these events the client can send commands to the server to initiate
new connections and so on.

The above Figure shows an example event/command sequence of a
client making a connection, sending some data, receiving some data and
then closing the connection. Note that sending and receiving may be
split into several events/commands since the server itself performs no
buffering.

If the client is handling multiple connections then the server may
interleave events for each connection so the client has to hold a
persistent state for each connection.

The connection and event model is the same from both TCP connections
and UDP connections. Full details of both the possible events and
possible commands can be found in Section API
.

TCP and UDP

The XTCP API treats UDP and TCP connections in the same way. The only
difference is when the protocol is specified on initializing
connections with xtcp_connect()
or xtcp_listen()
.

New Connections

New connections are made in two different ways. Either the
xtcp_connect()
function is used to initiate a connection with
a remote host as a client or the xtcp_listen()
function is
used to listen on a port for other hosts to connect to the application
. In either
case once a connection is established then the
XTCP_NEW_CONNECTION event is triggered.

In the Berkley sockets API, a listening UDP connection merely reports
data received on the socket, indepedent of the source IP address. In
XTCP, a XTCP_NEW_CONNECTION event is sent each time data
arrives from a new source. The API function xtcp_close()

should be called after the connection is no longer needed.

Receiving Data

When data is received by a connection, the XTCP_RECV_DATA
event is triggered and communicated to the client. At this point the
client must call the xtcp_recv()
function to receive the
data.

Data is sent from host to client as the UDP or TCP packets come
in. There is no buffering in the server so it will wait for the client
to handle the event before processing new incoming packets.

As an alternative to the low level interface, a higher level buffered
interface is available. See section Buffered API
.

Sending Data

When sending data, the client is responsible for dividing the data
into chunks for the server and re-transmitting the previous chunk if a
transmission error occurs.

Note that re-transmission may be needed on
both TCP and UDP connections. On UDP connections, the
transmission may fail if the server has not yet established
a connection between the destination IP address and layer 2
MAC address.

The client can initiate a send transaction with the
xtcp_init_send()
function. At this point no sending has been
done but the server is notified of a wish to send. The client must
then wait for a XTCP_REQUEST_DATA event at which point it
must respond with a call to xtcp_send()
.

After this data is sent to the server, two things can happen: Either
the server will respond with an XTCP_SENT_DATA event, in
which case the next chunk of data can be sent or with an
XTCP_RESEND_DATA event in which case the client must
re-transmit the previous chunk of data.

The command/event exchange continues until the client calls the
xtcp_complete_send()
function to finish the send
transaction. After this the server will not trigger any more
XTCP_SENT_DATA events.

As well as events related to connections. The server may also send
link status events to the client. The events XTCP_IFUP and
XTCP_IFDOWN indicate to a client when the link goes up or down.

Configuration

The server is configured via arguments passed to the
xtcp_server()
function and the defines described in Section
Configuration Defines
.

Client connections are configured via the client API described in
Section Configuration Defines
.

Buffered API

As an alternative to the low level interface, a buffered interface is
available as a utility layer.

To set up the buffered interface, the application must receive or make
a new connection. As part of the new connection processing a buffer
must be associated with it, by calling xtcp_buffered_set_rx_buffer()

and xtcp_buffered_set_tx_buffer()
.

When sending using the buffered interface, a call to xtcp_buffered_send()

is all that is required. When processing the XTCP_SENT_DATA,
XTCP_REQUEST_DATA and XTCP_RESEND_DATA, the function
xtcp_buffered_send_handler()
should be called.

When processing a XTCP_RECV_DATA event, either the function
xtcp_buffered_recv()
or xtcp_buffered_recv_upto()
can be
called. These either return the data requested, or zero. If some data
is returned, indicated by a non-zero return value, then the application
should process the data, and call the receive function again. Only when
the function returns zero can the application stop trying to receive and
process the data.

Two example applications are provided. app_buffered_protocol_demo shows
the use of the buffered API used with fixed length packets, and
app_buffered_protocol_demo_2 shows the use of the delimited token
mechanism.

Ethernet Slice Simple Webserver Application Quickstart

This simple demonstration of xTIMEcomposer Studio functionality uses
the sliceKIT Ethernet Slice together with the xSOFTip TCP/IP Ethernet
component to:

  • Run a TCP/IP stack on the xCORE
  • Run a very simple HTTP server to display a “hello world” webpage

Hardware setup

The sliceKIT Core Board has four slots with edge conectors: SQUARE, CIRCLE, TRIANGLE and STAR.

To setup up the system:

  1. Connect the Ethernet Slice Card to the sliceKIT Core Board using the connector marked with the CIRCLE.
  2. Connect the xTAG Adapter to sliceKIT Core Board and connect XTAG-2 to the adapter.
  3. Connect the xTAG-2 to host PC. Note that a USB cable is not provided with the sliceKIT starter kit.
  4. Plug the power supply into the sliceKIT Core Board and turn the
    power supply on.
Hardware Setup for Simple HTTP Demo

/files/images/15952/22/slicekit_eth_setup.jpg

Import and build the application

  1. On your PC, open xTIMEcomposer. You need to be in the
    edit perspective (Window->Open Perspective->XMOS Edit).
    If the XMOS Edit option isn’t in the list, you are
    already in the edit perspective.
  2. Locate the 'Simple HTTP Demo' item in the xSOFTip pane on the
    bottom left of the window and drag it into the Project Explorer
    window in the xTIMEcomposer. This will also cause the modules on
    which this application depends to be imported as well.
  3. Click on the app_simple_webserver item in the Explorer pane then
    click on the build icon (hammer) in xTIMEcomposer. Check the
    console window to verify that the application has built successfully.

For help in using xTIMEcomposer, try the xTIMEcomposer tutorials, which you can find by selecting Help->Tutorials from the xTIMEcomposer menu.

Note that the Developer Column in the xTIMEcomposer on the right hand
side of your screen provides information on the xSOFTip components you
are using. Select the module_xtcp component in the Project
Explorer, and you will see its description together with API
documentation (reached by double clicking on the Documentation
item within the project). If you view other documentation, you can get
back to this quickstart guide by cliking the back icon in the
Developer Column until you return to this quickstart guide.

Run the application

Now that the application has been compiled, the next step is to run it
on the sliceKIT Core Board using the tools to load the application
over JTAG (via the XTAG-2 and XTAG Adaptor Card)
into the xCORE multicore microcontroller.

  1. Click on the Run icon (the white arrow in the green
    circle). The debug console window in xTIMEcomposer should then
    display the message:

    **WELCOME TO THE SIMPLE WEBSERVER DEMO**
    

    This has been generated from the application code via a call to
    the printstr() function.

  2. Connect the sliceKIT Ethernet Slice your network via an ethernet
    cable. The application is configured by default to use DHCP to
    obtain an IP address. If you wish to change this to a static IP
    address edit the main.xc file in the application (you can
    reach this via the Project Explorer in the xTIMEcomposer) and
    change the ipconfig data structure.
  3. The console window should display a message like:
    IP Address: 192.168.0.4
    

    the actual IP address will depend on your local network.

  4. From a PC connected to the same network, open a web browser and
    open the link:

    http://192.168.0.4
    

    using the IP adress printed out by the application. This should
    display a “hello world” webpage. You have now got the ethernet
    slice up and running.

Troubleshooting

If the demo does not work try the following:

  • Ensure the Ethernet Slice Card is connected to the CIRCLE
    connector of the core board.
  • Ensure the slice network cable is fully connected. There are
    activity LEDs next to the ethernet connector that should
    illuminate if connected.
  • Ensure that both the PC and Ethernet Slice card are connected to the
    same network and can route to each other. If you are using a
    dynamically allocated address, make sure your DHCP server is
    configured correctly. If using a static address, make sure your PC
    is configured to talk to that address (in Windows you need to
    check your Network Adapter TCP/IP settings).

Next steps

Look at the Code

  1. Examine the application code. In xTIMEcomposer navigate to the src directory under app_simple_webserver and double click on the main.xc file within it. The file will open in the central editor window.
  2. Find the main function and note that it runs the
    ethernet_xtcp_server() (which runs the ethernet driver and tcp
    stack) and the xhttpd() function in parallel.
  3. Look at the xhttpd.xc and httpd.xc files. These
    implement the webserver logic that connects to the TCP/IP
    stack. In particular the httpd_handle_event function that
    responds to a TCP event over an xC channel and performs the
    functions of the webserver. See the TCP/IP programming guide for
    details on how the xtcp stack works.

Look at Other Examples

For a more complex embedded wbeserver demo that allows user interaction try the Slicekit GPIO and Ethernet Combo Demo demo application which can be found under sliceKIT->Demos categroy in the xSOFTip Explorer pane within xTIMEcomposer.

Go through this code in detail

This last section is optional and walks through the main application code in detail.

The toplevel main of this application sets up the different components
running on different logical cores on the device. It can be found in the
file main.xc.

First the TCP/IP server is run on the tile given by the define
ETHERNET_DEFAULT_TILE (supplied by the
ethernet_board_support.h header which gives defines for common
XMOS development boards.). It is run via the function
ethernet_xtcp_server()
. The server runs both the ethernet code to
communicate with the ethernet phy and the tcp server on two logical cores.

on ETHERNET_DEFAULT_TILE:
   ethernet_xtcp_server(xtcp_ports,
                        ipconfig,
                        c_xtcp,
                        1);



The client to the TCP/IP server is run as a separate task
and connected to the TCP/IP server via the first element c_xtcp
channel array. The function xhttpd implements the web server.

on tile[0]: xhttpd(c_xtcp[0]);


The webserver mainloop

The webserver is implemented in the xhttpd function in
xhttpd.xc. This function implements a simple loop that just
responds to events from the TCP/IP server. When an event occurs it is
passed onto the httpd_handle_event handler.

void xhttpd(chanend tcp_svr)
{
  xtcp_connection_t conn;
  printstrln("**WELCOME TO THE SIMPLE WEBSERVER DEMO**");
  // Initiate the HTTP state
  httpd_init(tcp_svr);

  // Loop forever processing TCP events
  while(1)
    {
      select
        {
        case xtcp_event(tcp_svr, conn):
          httpd_handle_event(tcp_svr, conn);
          break;
        }

    }
}


The webserver event handler

The event handler is implemented in httpd.c and contains the main
logic of the web server. The server can handle several connections at
once. However, events for each connection may be interleaved so the
handler needs to store separate state for each one. The
httpd_state_t structures holds this state:

typedef struct httpd_state_t {
  int active;      //< Whether this state structure is being used
                   //  for a connection
  int conn_id;     //< The connection id
  char *dptr;      //< Pointer to the remaining data to send
  int dlen;        //< The length of remaining data to send
  char *prev_dptr; //< Pointer to the previously sent item of data
} httpd_state_t;

httpd_state_t connection_states[NUM_HTTPD_CONNECTIONS];

The http_init function is called at the start of the
application. It initializes the connection state array and makes a
request to accept incoming new TCP connections on port 80 (using the
xtcp_listen()
function):

void httpd_init(chanend tcp_svr)
{
  int i;
  // Listen on the http port
  xtcp_listen(tcp_svr, 80, XTCP_PROTOCOL_TCP);

  for ( i = 0; i < NUM_HTTPD_CONNECTIONS; i++ )
    {
      connection_states[i].active = 0;
      connection_states[i].dptr = NULL;
    }
}

When an event occurs the httpd_handle_event function is
called. The behaviour of this function depends on the event
type. Firstly, link status events are ignored:

void httpd_handle_event(chanend tcp_svr, xtcp_connection_t *conn)
{
  // We have received an event from the TCP stack, so respond
  // appropriately

  // Ignore events that are not directly relevant to http
  switch (conn->event)
    {
    case XTCP_IFUP: {
      xtcp_ipconfig_t ipconfig;
      xtcp_get_ipconfig(tcp_svr, &ipconfig);

#if IPV6
      unsigned short a;
      unsigned int i;
      int f;
      xtcp_ipaddr_t *addr = &ipconfig.ipaddr;
      printstr("IPV6 Address = [");
      for(i = 0, f = 0; i < sizeof(xtcp_ipaddr_t); i += 2) {
        a = (addr->u8[i] << 8) + addr->u8[i + 1];
        if(a == 0 && f >= 0) {
          if(f++ == 0) {
            printstr("::");
           }
        } else {
            if(f > 0) {
              f = -1;
            } else if(i > 0) {
                printstr(":");
            }
          printhex(a);
        }
      }
      printstrln("]");
#else
      printstr("IP Address: ");
      printint(ipconfig.ipaddr[0]);printstr(".");
      printint(ipconfig.ipaddr[1]);printstr(".");
      printint(ipconfig.ipaddr[2]);printstr(".");
      printint(ipconfig.ipaddr[3]);printstr("\n");
#endif
      }
      return;
    case XTCP_IFDOWN:
    case XTCP_ALREADY_HANDLED:
      return;
    default:
      break;
    }


For other events, we first check that the connection is definitely an
http connection (is directed at port 80) and then call one of several
event handlers for each type of event. The is a separate function for
new connections, receiving data, sending data and closing connections:

  if (conn->local_port == 80) {
    switch (conn->event)
      {
      case XTCP_NEW_CONNECTION:
        httpd_init_state(tcp_svr, conn);
        break;
      case XTCP_RECV_DATA:
        httpd_recv(tcp_svr, conn);
        break;
      case XTCP_SENT_DATA:
      case XTCP_REQUEST_DATA:
      case XTCP_RESEND_DATA:
          httpd_send(tcp_svr, conn);
          break;
      case XTCP_TIMED_OUT:
      case XTCP_ABORTED:
      case XTCP_CLOSED:
          httpd_free_state(conn);
          break;
      default:
        // Ignore anything else
        break;
      }
    conn->event = XTCP_ALREADY_HANDLED;
  }

The following sections describe the four handler functions.

Handling Connections

When a XTCP_NEW_CONNECTION event occurs we need to
associate some state with the connection. So the connection_states
array is searched for a free state structure.

void httpd_init_state(chanend tcp_svr, xtcp_connection_t *conn)
{
  int i;

  // Try and find an empty connection slot
  for (i=0;i<NUM_HTTPD_CONNECTIONS;i++)
    {
      if (!connection_states[i].active)
        break;
    }


If we don’t find a free state we cannot handle the connection so
xtcp_abort`() is called to abort the connection.

  if ( i == NUM_HTTPD_CONNECTIONS )
    {
      xtcp_abort(tcp_svr, conn);
    }

If we can allocate the state structure then the elements of the
structure are initialized. The function
xtcp_set_connection_appstate()
is then called to associate the
state with the connection. This means when a subsequent event is
signalled on this connection the state can be recovered.

  else
    {
      connection_states[i].active = 1;
      connection_states[i].conn_id = conn->id;
      connection_states[i].dptr = NULL;
      xtcp_set_connection_appstate(
           tcp_svr,
           conn,
           (xtcp_appstate_t) &connection_states[i]);

When a XTCP_TIMED_OUT, XTCP_ABORTED or
XTCP_CLOSED event is received then the state associated
with the connection can be freed up. This is done in the
httpd_free_state function:

void httpd_free_state(xtcp_connection_t *conn)
{
  int i;

  for ( i = 0; i < NUM_HTTPD_CONNECTIONS; i++ )
    {
      if (connection_states[i].conn_id == conn->id)
        {
          connection_states[i].active = 0;
        }
    }
}

Receiving Data

When an XTCP_RECV_DATA event occurs the httpd_recv
function is called. The first thing this function does is call the
xtcp_recv()
function to place the received data in the
data array. (Note that all TCP/IP clients must call
xtcp_recv()
directly after receiving this kind of event).

void httpd_recv(chanend tcp_svr, xtcp_connection_t *conn)
{
  struct httpd_state_t *hs = (struct httpd_state_t *) conn->appstate;
  char data[XTCP_CLIENT_BUF_SIZE];
  int len;

  // Receive the data from the TCP stack
  len = xtcp_recv(tcp_svr, data);


The hs variable points to the connection state. This was recovered
from the appstate member of the connection structure which
was previously associated with application state when the connection
was set up. As a safety check we only proceed if this state has been
set up and the hs variable is non-null.

  if ( hs == NULL || hs->dptr != NULL)
    {
      return;
    }


Now the connection state is known and the
incoming data buffer filled. To keep things simple, this server makes
the assumption that a single tcp packet gives us enough information to
parse the http request. However, many applications will need to
concatenate each tcp packet to a different buffer and handle data after
several tcp packets have come in. The next step in the code is to call
the parse_http_request function:

  parse_http_request(hs, &data[0], len);


This function examines the incoming packet and checks if it is a
GET request. If so, then it always serves the same page. We signal
that a page is ready to the callee by setting the data pointer
(dptr) and data length (dlen) members of the connection state.

void parse_http_request(httpd_state_t *hs, char *data, int len)
{
  // Return if we have data already
  if (hs->dptr != NULL)
    {
      return;
    }

  // Test if we received a HTTP GET request
  if (strncmp(data, "GET ", 4) == 0)
    {
      // Assign the default page character array as the data to send
      hs->dptr = &page[0];
      hs->dlen = strlen(&page[0]);
    }
  else
    {
      // We did not receive a get request, so do nothing
    }
}

The final part of the receive handler checks if the
parse_http_request function set the dptr data pointer. If so,
then it signals to the tcp/ip server that we wish to send some data on
this connection. The actual sending of data is handled when an
XTCP_REQUEST_DATA event is signalled by the tcp/ip server.

  if (hs->dptr != NULL)
    {
      // Initate a send request with the TCP stack.
      // It will then reply with event XTCP_REQUEST_DATA
      // when it's ready to send
      xtcp_init_send(tcp_svr, conn);
    }

Sending Data

To send data the connection state keeps track of three variables:

Name

Description

dptr

A pointer to the next piece of data to send

dlen

The amount of data left to send

prev_dptr

The previous value of dptr before the last send

We keep the previous value of dptr in case the tcp/ip server asks
for a resend.

On receiving an XTCP_REQUEST_DATA,
XTCP_SENT_DATA or XTCP_RESEND_DATA event the
function httpd_send is called.

The first thing the function does is check whether we have been asked
to resend data. In this case it sends the previous amount of data
using the prev_dptr pointer.

  if (conn->event == XTCP_RESEND_DATA) {
    xtcp_send(tcp_svr, hs->prev_dptr, (hs->dptr - hs->prev_dptr));
    return;
  }


If the request is for the next piece of data, then the function first
checks that we have data left to send. If not, the function
xtcp_complete_send()
is called to finish the send transaction
and then the connection is closed down with xtcp_close()

(since HTTP only does one transfer per connection).

  if (hs->dlen == 0 || hs->dptr == NULL)
    {
      // Terminates the send process
      xtcp_complete_send(tcp_svr);
      // Close the connection
      xtcp_close(tcp_svr, conn);
    }

If we have data to send, then first the amount of data to send is
calculated. This is based on the amount of data we have left
(hs->dlen) and the maximum we can send (conn->mss). Having
calculated this length, the data is sent using the xtcp_send()

function.

Once the data is sent, all that is left to do is update the dptr,
dlen and prev_dptr variables in the connection state.

  else {
    int len = hs->dlen;

    if (len > conn->mss)
      len = conn->mss;

    xtcp_send(tcp_svr, hs->dptr, len);

    hs->prev_dptr = hs->dptr;
    hs->dptr += len;
    hs->dlen -= len;
  }

Ethernet Slice Simple Webserver Application Quickstart Read More »

Display Controller Component

The display controller component is used to drive a single graphics LCD screen up to 800 * 600 pixels incorporating a managed double buffer.

Features

  • Non-blocking SDRAM management.
  • Real time servicing of the LCD.
  • Touch interactive display
  • Image memory manager to simplify handling of images.
  • No real time constraints on the application.

Memory requirements

Resource

Usage

Stack

6198 bytes

Program

11306 bytes

Resource requirements

Resource

Usage

Channels

3

Timers

0

Clocks

0

Threads

1

Performance

The achievable effective bandwidth varies according to the avaliable XCore MIPS. The maximum pixel clock supported is 25MHz.

Slicekit

This module may be evaluated using the Slicekit Modular Development Platform, available from digikey. Required board SKUs are:

  • XP-SKC-L2 (Slicekit L2 Core Board)
  • XA-SK-SCR480 plus XA-SK-XTAG2 (Slicekit XTAG adaptor)

Demonstration Applications

Display Controller Application

  • Package: sw_display_controller
  • Application: app_display_controller

This combination demo employs the module_lcd along with the module_sdram, module_touch_controller_lib, module_i2c_master and the module_display_controller framebuffer framework component to implement a 480×272 display controller.

Required board SKUs for this demo are:

  • XP-SKC-L2 (Slicekit L2 Core Board) plus XA-SK-XTAG2 (Slicekit XTAG adaptor)
  • XA-SK-SDRAM
  • XA-SK-SCR480 (which includes a 480×272 color touch screen)

To build a project including the module_display_controller the following components are required:
  • component: sc_sdram_burst which handles the SDRAM
  • component: sc_lcd which handles the LCD

The below section details the APIs in the application. For details about the LCD and SDRAM APIs please refer to the respective repositories.

Configuration Defines

The module_display_controller can be configured via the header display_controller_conf.h. The module requires nothing to be additionally defined however any of the defines can be overridden by adding the header display_controller_conf.h to the application project and adding the define that needs overridding. The possible defines are:

DISPLAY_CONTROLLER_MAX_IMAGES

This defines the storage space allocated to the display controller for it to store image metadata. When an image is registered with the display controller its dimensions and location in SDRAM address space are stored in a table. The define specifies how many entries are allowed in that table. Note, there is no overflow checking by default.

DISPLAY_CONTROLLER_VERBOSE

This define switches on the error checking for memory overflows and causes verbose error warnings to be emitted in the event of an error.

API

The“module_display_controller“ functionality is defined in
  • display_controller_client.xc
  • display_controller_internal.h
  • display_controller.xc
  • display_controller.h
  • transitions.h
  • transitions.xc

The display controller handles the double buffering of the image data to the LCD as a real time service and manages the I/O to the SDRAM as a non-real time service.

The display controller API is as follows:
.. doxygenfunction:: display_controller
.. doxygenfunction:: image_read_line
.. doxygenfunction:: image_read_line_p
.. doxygenfunction:: image_write_line
.. doxygenfunction:: image_write_line_p
.. doxygenfunction:: image_read_partial_line
.. doxygenfunction:: image_read_partial_line_p
.. doxygenfunction:: register_image
.. doxygenfunction:: wait_until_idle
.. doxygenfunction:: wait_until_idle_p
.. doxygenfunction:: frame_buffer_commit
.. doxygenfunction:: frame_buffer_init

The transition API is as follows:
.. doxygenfunction:: transition_wipe
.. doxygenfunction:: transition_slide
.. doxygenfunction:: transition_roll
.. doxygenfunction:: transition_dither
.. doxygenfunction:: transition_alpha_blend

The transitions use the display controller API.

Source code structure

Project structure

Project

File

Description

module_display_controller

display_controller.h

Header file containing the APIs for the display controller component.

 

display_controller.xc

File containing the implementation of the display controller component.

 

display_controller_client.xc

File containing the implementation of the display controller client functions.

 

display_controller_internal.h

Header file containing the user configurable defines for the display controller component.

 

transitions.h

Header file containing the APIs for the display controller transitions.

 

transitions.xc

File containing the implementation of the display controller transitions.

Executing The Project

The module by itself cannot be built or executed separately – it must be linked in to an application. Once the module is linked to the application, the application can be built and tested for driving a LCD screen.

The following should be done in order to link the component to the application project
  1. The module name module_display_controller should be added to the list of MODULES in the application project build options.
  2. The module name module_lcd should be added to the list of MODULES in the application project build options.
  3. The module name module_sdram should be added to the list of MODULES in the application project build options.
  4. The module name module_touch_controller_lib should be added to the list of MODULES in the application project build options.
  5. The module name module_i2c_master should be added to the list of MODULES in the application project build options.
  6. Now the module is linked to the application and can be used directly

Software Requirements

The module is built on XDE Tool version 12.0
The module can be used in version 12.0 or any higher version of xTIMEcomposer.

This tutorial describes the demo applications included in the XMOS Display Controller software component. Recommended Hardware
describes the required hardware setup to run the demos.

app_display_controller_demo

This application demonstrates how the lcd_module is used to write image data to the LCD screen whilst imposing no real time constraints on the application. The purpose of this demonstration is to show how data is passed to the display_controller. This application also demonstrates an interactive display using touch_controller module.

Application Notes

Getting Started

  1. Plug the XA-SK-LCD Slice Card into the ‘TRIANGLE’ slot of the Slicekit Core Board
  2. Plug the XA-SK-SDRAM Slice Card into the ‘STAR’ slot of the Slicekit Core Board
  3. Open app_display_controller_demo.xc and build the project.
  4. run the program ensuring that it is run from the project directory where the tga images are.

The output produced should look like a series of images transitioning on the LCD when the screen is touched.

Display Controller Component Read More »

XMOS Layer 2 Ethernet MAC Component

The layer 2 MAC component implements a layer 2 ethernet MAC. It
provides both MII communication to the PHY and MAC transport layer for
ethernet packets and enables several clients to connect
to it and send and receive
packets.

Two independent implementations are available. The FULL implementation
runs on 5 logical cores, allows multiple clients with
independent buffering per client and supports accurate packet
timestamping, priority
queuing, and 802.1Qav traffic shaping. The LITE implementation runs on two
logical cores but is restricted to a single receive and trasnmit client
and does not support any advanced features.

Component Summary

Functionality

Provides MII ethernet interface and MAC with customizable
filtering and accurate packet timestamping.

Supported Standards

Ethernet

IEEE 802.3u (MII)

Supported Devices

XMOS Devices

XS1-G4

 

XS1-L2

 

XS1-L1

Requirements

XMOS Desktop Tools

v12.0 or later

Ethernet

MII compatible 100Mbit PHY

Licensing and Support

Component code provided without charge from XMOS.
Component code is maintained by XMOS.

The ethernet MAC runs on two or five logical cores depending on the
chosen implementation and communicates to client
tasks over channels. The server
can connect to several clients and each channel connection to the
server is for either RX (receiving packets from the MAC) or TX
(transmitting packets to the MAC) operation.

MAC component (FULL implementation)

/files/images/15949/10/mac.png

FULL Implementation

Buffers and Queues

The MAC maintains a two sets of buffers: one for incoming packets and
one for outgoing packets. These buffers are arranged into several
queues.

Incoming buffers move around the different queues as follows:

  • Empty buffers are in the incoming queue awaiting a packet coming
    in from the MII interfaces
  • Buffers received from the MII interface are filtered (see below)
    and if they need to be kept then are moved into a forwarding
    queue.
  • Buffers in the forwarding queue are moved into a client queue
    depending on which client registered for that type of
    packet.
  • Once the data from a buffer has been sent to a client the buffer
    is moved back into the incoming queue.

Outgoing buffers move around the different queues as follows:

  • Empty buffers are an empty queue awaiting a packet coming
    in from a client.
  • Once the data is received the buffer is moved into a transmit
    queue awaiting output on the MII interface.
  • Once the data is transmitted, the buffer is released back to the
    empty queue.

The number of buffers available can be set in the ethernet_conf.h
configuration file (see Configuration Defines
).

Filtering

After incoming packets are received they are filtered. An initial
filter is done where the packet is dropped unless:

  1. The packet is destined for the host’s MAC address or
  2. The packet is destined for a MAC address with the broadcast bit
    set

After this initial filter, a user filter is supplied. To maintain the
maximum amount of flexibility and efficiency the application must
supply custom code to perform this filtering.

The user must supply a definition of the function
mac_custom_filter()
. This function can inspect incoming
packets in any manner suitable for applications and then returns
either 0 if the packet is to be dropped or a number which the clients
can then use to determine which packets they wish to receive (using
the client function mac_set_custom_filter()
.

Timestamping

On receipt of a ethernet frame over MII a timestamp is taken of the
100Mhz reference timer on the core that the ethernet server is
running on. The timestamp is taken at the end of the preamble
immediately before the frame itself. This timestamp will be accurate
to within 40ns. The timestamp is stored with the buffer data and can
be retrieved by the client by using the mac_rx_timed()
function.

On transmission of a ethernet frame over MII a timestamp is also
taken. The timestamp is also taken at the end of the preamble
immediately before the frame itself and is accurate to within 40ns.
The client can retreive the timestamp using the mac_tx_timed()

function. In this case the timestamp is stored on transmission and
placed in a queue to be sent back to the client thread.

LITE implementation

The LITE implementation does not support timestamping or multiple
queues/buffering. The MAC will filter packets based on MAC address and
the broadcast bit of the incoming MAC address. Any further filtering
must be done by the single receive client of the ethernet server.

MAC Address Storage

The MAC address used for the server is set on instantiation of the
server (as an argument to the ethernet_server()
function).
This address should be unique for each device. For all XMOS develop
boards, a unique mac address is stored in the one time programmable
rom (OTP). To retreive this address otp_board_info_get_mac
function is provided in the module module_otp_board_info.

For information on programming MAC addresses into OTP please contact
XMOS for detalis.

This section provides information on how to program applications using
the ethernet MAC component.

Getting started

Installation

You can import the layer 2 MAC component and example applications from
the xSOFTip browser in the xTIMEcomposer tool.

Source code structure

Source code can be found across several modules:

  • module_ethernet contains the main MAC code
  • module_ethernet_smi contains the code for controlling an
    ethernet phy via the SMI configuration protocol
  • module_ethernet_board_support contains header files for common
    XMOS development boards allowing easy initialization of port
    structures.

Which modules are compiled into the
application is controlled by the USED_MODULES define in your
application Makefile.

Key Files

The following header files contain prototypes of all functions
required to use the ethernet component. The API is described in
Ethernet API
.

Key Files

File

Description

ethernet.h

Ethernet main header file (includes other headers)

ethernet_server.h

Ethernet Server API header file

ethernet_rx_client.h

Ethernet Client API header file (RX)

ethernet_tx_client.h

Ethernet Client API header file (TX)

A Sample Ethernet Application (tutorial)

This tutorial describes a demo included in the xmos ethernet
package. The demo can be found in the directory app_ethernet_demo and
provides a simple ethernet application that responds to ICMP ping
requests. It assumes a basic knowledge of XC programming. For
information on XMOS programming, you can find reference material at the XMOS website
.

To write an ethernet enabled application for an XMOS device requires
several things:

  1. Write a Makefile for our application
  2. Provide an ethernet_conf.h configuration file
  3. Provide a custom filter function
  4. Write the application code that uses the component

Makefile

The Makefile is found in the top level directory of the
application. It uses the general XMOS makefile in module_xmos_common
which compiles all the source files in the application and the modules
that the application uses. We only have to add a couple of
configuration options.

Firstly, this application is for a sliceKIT Core Board
(the SLICEKIT-L2 target) so the
TARGET variable needs to be set in the Makefile.

# The TARGET variable determines what target system the application is
# compiled for. It either refers to an XN file in the source directories
# or a valid argument for the --target option when compiling.

TARGET = SLICEKIT-L2

Secondly, the application will use the ethernet module (and the locks
module which is required by the ethernet module). So we state that the
application uses these.

# The USED_MODULES variable lists other module used by the application.

USED_MODULES = module_ethernet module_ethernet_board_support \
               module_otp_board_info module_slicekit_support

Given this information, the common Makefiles will build all the files
in the required modules when building the application. This works from
the command line (using xmake) or from Eclipse.

ethernet_conf.h

The ethernet_conf.h file is found in the src/ directory of the
application. This file contains a series of #defines that configure
the ethernet stack. The possible #defines that can be set are
described in Configuration Defines
.

Within this application we set the maximum packet size we can receive
to be the maximum possible allowed in the ethernet standard and set
the number of buffers to be 5 packets for incoming packets and 5 for
outgoing.

The maximum number of ethernet clients (chanends we can connect to the
ethernet server) is set to 4 (even though we only have one client in
this example).

// Copyright (c) 2011, XMOS Ltd, All rights reserved
// This software is freely distributable under a derivative of the
// University of Illinois/NCSA Open Source License posted in
// LICENSE.txt and at <http://github.xcore.com/>

#ifdef CONFIG_FULL

#define ETHERNET_DEFAULT_IMPLEMENTATION full

#define MAX_ETHERNET_PACKET_SIZE (1518)

#define MAX_ETHERNET_CLIENTS   (4)    

#else

#define ETHERNET_DEFAULT_IMPLEMENTATION lite

#endif




This application has two build configurations – one for the full
implementation and one for the lite.

mac_custom_filter

The mac_custom_filter function allows use to decide which packets get
passed through the MAC. To do this, we have to provide the
mac_custom_filter.h header file and a definition of the
mac_custom_filter function itself.

The header file in this example just prototypes the mac_custom_filter
function itself.

// Copyright (c) 2011, XMOS Ltd, All rights reserved
// This software is freely distributable under a derivative of the
// University of Illinois/NCSA Open Source License posted in
// LICENSE.txt and at <http://github.xcore.com/>

extern int mac_custom_filter(unsigned int data[]);

The module requires the application to provide the header to cater for
the case where the function is describe as an inline function for
performance. In this case it is just prototyped and the definition of
mac_custom_filter is in our main application code file demo.xc

int mac_custom_filter(unsigned int data[]){
	if (is_ethertype((data,char[]), ethertype_arp)){
		return 1;
	}else if (is_ethertype((data,char[]), ethertype_ip)){
		return 1;
	}

	return 0;
}

This function returns 0 if we do not want to handle the packet and
non-zero otherwise. The non-zero value is used later to distribute to
different clients. In this case we detect ARP packets and ICMP packets
which match our own mac address as a destination. In this case the
function returns 1. The defintions os is_broadcast, is_ethertype and
is_mac_addr are in demo.xc

Top level program structure

Now that we have the basic ethernet building blocks, we can build our
application. This application is contained in demo.xc. Within this
file is the main() function which declares some variables (primarily
XC channels). It also contains a top level par construct which sets
the various functional units running that make up the program.

We run the ethernet server (this is set to run on
the tile ETHERNET_DEFAULT_TILE which is supplied by the board support
module).
First, the function otp_board_info_get_mac() reads the device mac address from ROM. The
functions eth_phy_reset(), smi_config() and
eth_phy_config()
initialize the phy and then the main function
ethernet_server()
runs the ethernet component. The server
communicates with other tasks via the rx and tx channel arrays.

      on ETHERNET_DEFAULT_TILE:
      {
        char mac_address[6];
        otp_board_info_get_mac(otp_ports, 0, mac_address);
        eth_phy_reset(eth_rst);
        smi_init(smi);
        eth_phy_config(1, smi);
        ethernet_server(mii,
                        null,
                        mac_address,
                        rx, 1,
                        tx, 1);
      }

On tile 0 we run the demo() function as a task which takes ethernet packets and
responds to ICMP ping requests. This function is described in the next section.

      on ETHERNET_DEFAULT_TILE : demo(tx[0], rx[0]);

Ethernet packet processing

The demo() function does the actual ethernet packet processing. First
the application gets the device mac address from the ethernet server.

  mac_get_macaddr(tx, own_mac_addr);

Then the packet filter is set up. The mask value passed to
mac_set_custom_filter()
is used within the mac. After the
custom_mac_filter function is run, if the result is non-zero then the
result is and-ed against the mask. If this is non-zero then the packet
is forwarded to the client.

So in this case, the mask is 1 so all packets that get a result of 1 from
custom_mac_filter function will get passed to this client.

#ifdef CONFIG_FULL
  mac_set_custom_filter(rx, 0x1);
#endif

Note that this is only for build configuration that uses the FULL
configuration. If we are using the LITE configuration the filtering is
done after the client recieves the packet later on.

After we are set up to receive the correct packets we can go into the
main loop that responds to ARP and ICMP packets.

The first task in the loop is to receive a packet into the rxbuf
buffer using the mac_rx()
function.

  while (1)
  {
    unsigned int src_port;
    unsigned int nbytes;
    mac_rx(rx, (rxbuf,char[]), nbytes, src_port);
#ifdef CONFIG_LITE
    if (!is_broadcast((rxbuf,char[])) && !is_mac_addr((rxbuf,char[]), own_mac_addr))
      continue;
    if (mac_custom_filter(rxbuf) != 0x1)
      continue;
#endif



Here we can see the filtering that needs to be done for the LITE configuration.

When the packet is received it may be an ARP or IP packet since both
get past our filter. First we check if it is an ARP packet, if so then
we build the response (in the txbuf array) and send it out over
ethernet using the mac_tx()
function. The functions
is_valid_arp_packet and build_arp_response are defined demo.xc.

    if (is_valid_arp_packet((rxbuf,char[]), nbytes))
      {
        build_arp_response((rxbuf,char[]), txbuf, own_mac_addr);
        mac_tx(tx, txbuf, nbytes, ETH_BROADCAST);
        printstr("ARP response sent\n");
      }

If the packet is not an ARP packet we check if it is an ICMP packet
and in the same way build a response and send it out.

    else if (is_valid_icmp_packet((rxbuf,char[]), nbytes))
      {
        build_icmp_response((rxbuf,char[]), (txbuf, unsigned char[]), own_mac_addr);
        mac_tx(tx, txbuf, nbytes, ETH_BROADCAST);
        printstr("ICMP response sent\n");
      }

Running the application

To test the application the following define in demo.xc needs to be
set to an IP address that is routable in the network that the
application is to be tested on.

// NOTE: YOU MAY NEED TO REDEFINE THIS TO AN IP ADDRESS THAT WORKS
// FOR YOUR NETWORK
#define OWN_IP_ADDRESS {192, 168, 1, 178}

Once this is done, the demo can be compiled and the XC-2 connected to
a PC. Pinging the IP address defined should now get a response e.g.:

PING 192.168.0.3 (192.168.0.3) 56(84) bytes of data.
64 bytes from 192.168.0.3: icmp_seq=1 ttl=64 time=2.97 ms
64 bytes from 192.168.0.3: icmp_seq=2 ttl=64 time=2.93 ms
64 bytes from 192.168.0.3: icmp_seq=3 ttl=64 time=2.91 ms
64 bytes from 192.168.0.3: icmp_seq=4 ttl=64 time=2.96 ms
...

Configuration Defines

The file ethernet_conf.h may be provided in the application source
code. This file can set the following defines:

ETHERNET_DEFAULT_IMPLEMENTATION

This define can be set to full or lite and determines which
implementation is chosen by default when the application makes
calls to ethernet_server etc.

Configuration Defines for FULL implementation

MAX_ETHERNET_PACKET_SIZE

This define sets the largest packet size in bytes that the ethernet mac
will receive. The default is the largest possible ethernet packet
size (1518 bytes). Setting this to a smaller value will save
memory but restrict the type of packets you can receieve.

NUM_MII_RX_BUF

Number of incoming packets that will be buffered within the MAC.

NUM_MII_TX_BUF

Number of outgoing packets that will be buffered within the MAC.

MAX_ETHERNET_CLIENTS

The maximum number of clients that can be connected to the
ethernet_server()
function via the rx and tx channel arrays.

NUM_ETHERNET_PORTS

The number of ethernet ports to support. Maximum value is 2 in
the current implementation.

ETHERNET_TX_HP_QUEUE

Define this constant to include the high priority transmit queueing
mechanism. This enables frames which have an ethernet VLAN priority
tag to be queued in a high priority queue, which in turn can be
managed with the 802.1qav transmit traffic shaper.

ETHERNET_RX_HP_QUEUE

Define this constant to include high priority reception of ethernet
VLAN priority tagged traffic. This traffic will be queued into a
fast queue and delivered to the clients ahead of non-tagged traffic.

ETHERNET_TRAFFIC_SHAPER

If high priority transmit queueing is in use (see ETHERNET_TX_HP_QUEUE)
then this enables the 802.1qav traffic shaping algorithm.

MII_RX_BUFSIZE_HIGH_PRIORITY

The number of quadlets (4 byte integers) of space in the high
priority receive buffer. The buffer will actually be two full
packets longer than this to avoid the need to be circular. This
constant applies when the high priority receive queue is in use.

MII_RX_BUFSIZE_LOW_PRIORITY

The number of quadlets (4 byte integers) of space in the low
priority receive buffer. The buffer will actually be two full
packets longer than this to avoid the need to be circular. This
constant applies when the high priority receive is in use.

MII_RX_BUFSIZE

The number of quadlets (4 byte integers) of space in the low
priority receive buffer. The buffer will actually be two full
packets longer than this to avoid the need to be circular. This
constant applies when the high priority receive is not in use.

MII_TX_BUFSIZE

The number of quadlets (4 byte integers) of space in the low
priority transmit buffer. The buffer will actually be two full
packets longer than this to avoid the need to be circular.

MII_TX_BUFSIZE_HIGH_PRIORITY

The number of quadlets (4 byte integers) of space in the high
priority transmit buffer. The buffer will actually be two full
packets longer than this to avoid the need to be circular. This
constant applies when the high priority receive is in use.

ENABLE_ETHERNET_SOURCE_ADDRESS_WRITE

By defining this preprocessor symbol, the source MAC address
will be automatically filled in with the MAC address passed
to the port during initialization.

Configuration defines for LITE implementation

Custom Filter Function

For the FULL implementation, every application is required to
provide this function. It also needs
to be prototyped (or defined as an inline definition) in the header
file mac_custom_filter.h.

  • int mac_custom_filter(unsigned int data[])

    This function examines an ethernet packet and returns a filter
    number to allow different clients to obtain different types of packet.
    The function must run within 6us to allow 100Mbit filtering of
    packets.

    Parameters

    • data

      This array contains the ethernet packet. It does not
      include the preamble but does include the layer 2
      header or the packet.

    Returns

    0 if the packet is not wanted by the application or
    a number that can be registed by
    mac_set_custom_filter()
    by a client. Clients
    register a mask so the number is usually made up of a
    bit per unique client destination for the packet.

Data Structures

Depending on the implementation you must supply a different port
structure. The type mii_interface_t will be set to one of this
structures depending on the ETHERNET_DEFAULT_IMPLEMENTATION define.

  • mii_interface_full_t

    Structure containing resources required for the MII ethernet interface.

    This structure contains resources required to make up an MII interface. It consists of 7 ports and 2 clock blocks.

    The clock blocks can be any available clock blocks and will be clocked of incoming rx/tx clock pins.

    Structure Members:

    • clock clk_mii_rx

      MII RX Clock Block.

    • clock clk_mii_tx

      MII TX Clock Block.

    • in port p_mii_rxclk

      MII RX clock wire.

    • in port p_mii_rxer

      MII RX error wire.

    • in buffered port:32 p_mii_rxd

      MII RX data wire.

    • in port p_mii_rxdv

      MII RX data valid wire.

    • in port p_mii_txclk

      MII TX clock wire.

    • out port p_mii_txen

      MII TX enable wire.

    • out buffered port:32 p_mii_txd

      MII TX data wire.

  • mii_interface_lite_t

    Structure Members:

    • clock clk_mii_rx

      MII RX Clock Block.

    • clock clk_mii_tx

      MII TX Clock Block.

    • in port p_mii_rxclk

      MII RX clock wire.

    • in port p_mii_rxer

      MII RX error wire.

    • in buffered port:32 p_mii_rxd

      MII RX data wire.

    • in port p_mii_rxdv

      MII RX data valid wire.

    • in port p_mii_txclk

      MII TX clock wire.

    • out port p_mii_txen

      MII TX enable wire.

    • out buffered port:32 p_mii_txd

      MII TX data wire.

    • in port p_mii_timing

      A port that is not used for anything, used by the LLD for timing purposes.

      Must be clocked of the reference clock

MAC Server API

  • void ethernet_server(mii_interface_t &mii, smi_interface_t
    & ?smi, char mac_address[], chanend rx[], int num_rx, chanend tx[], int num_tx)

    Single MII port MAC/ethernet server.

    This function provides both MII layer and MAC layer functionality. It runs in 5 threads and communicates to clients over the channel array parameters.

    The clients connected via the rx/tx channels can communicate with the server using the APIs found in ethernet_rx_client.h and ethernet_tx_client.h

    Parameters

    • mii

      The mii interface resources that the server will connect to

    • mac_address

      The mac_address the server will use. This should be a two-word array that stores the 6-byte macaddr in a little endian manner (so reinterpreting the array as a char array is as one would expect)

    • rx

      An array of chanends to connect to clients of the server who wish to receive packets.

    • num_rx

      The number of clients connected to the rx array

    • tx

      An array of chanends to connect to clients of the server who wish to transmit packets.

    • num_tx

      The number of clients connected to the txx array

    • smi

      An optional parameter of resources to connect to a PHY (via SMI) to check when the link is up.

RX Client API

Packet Receive Functions

  • void mac_rx(chanend c_mac, unsigned char buffer[], unsigned int &len, unsigned int &src_port)

    This function receives a complete frame (i.e.

    src/dest MAC address, type & payload), excluding pre-amble, SoF & CRC32 from the ethernet server.

    This function is selectable i.e. it can be used as a case in a select e.g.

    select {
       ...
       case mac_rx(...):
          break;
        ...
      }
    

    Parameters

    • c_mac

      A chanend connected to the ethernet server

    • buffer

      The buffer to fill with the incoming packet

    • src_port

      A reference parameter to be filled with the ethernet port the packet came from.

    • len

      A reference parameter to be filled with the length of the received packet in bytes.

  • void mac_rx_timed(chanend c_mac, unsigned char buffer[], unsigned int &len, unsigned int &time, unsigned int &src_port)

    This function receives a complete frame (i.e.

    src/dest MAC address, type & payload), excluding pre-amble, SoF & CRC32. It also timestamps the arrival of the frame.

    This function is selectable.

    Parameters

    • c_mac

      A chanend connected to the ethernet server

    • buffer

      The buffer to fill with the incoming packet

    • time

      A reference parameter to be filled with the timestamp of the packet

    • len

      A reference parameter to be filled with the length of the received packet in bytes.

    • src_port

      A reference parameter to be filled with the ethernet port the packet came from.

  • void safe_mac_rx(chanend c_mac, unsigned char buffer[], unsigned int &len, unsigned int &src_port, int n)

    This function receives a complete frame (i.e.

    src/dest MAC address, type & payload), excluding pre-amble, SoF & CRC32. In addition it will only fill the given buffer up to a specified length.

    This function is selectable.

    Parameters

    • c_mac

      A chanend connected to the ethernet server

    • buffer

      The buffer to fill with the incoming packet

    • len

      A reference parameter to be filled with the length of the received packet in bytes.

    • src_port

      A reference parameter to be filled with the ethernet port the packet came from.

    • n

      The maximum number of bytes to fill the supplied buffer with.

  • void safe_mac_rx_timed(chanend c_mac, unsigned char buffer[], unsigned int &len, unsigned int &time, unsigned int &src_port, int n)

    This function receives a complete frame (i.e.

    src/dest MAC address, type & payload), excluding pre-amble, SoF & CRC32 from the ethernet server. In addition it will only fill the given buffer up to a specified length.

    This function is selectable i.e. it can be used as a case in a select.

    Parameters

    • c_mac

      A chanend connected to the ethernet server

    • buffer

      The buffer to fill with the incoming packet

    • src_port

      A reference parameter to be filled with the ethernet port the packet came from.

    • len

      A reference parameter to be filled with the length of the received packet in bytes.

    • n

      The maximum number of bytes to fill the supplied buffer with.

  • void mac_rx_offset2(chanend c_mac, unsigned char buffer[], unsigned int &len, unsigned int &src_port)

    Receive a packet starting at the second byte of a buffer.

    This is useful when the contents of the packet should be aligned on a different boundary.

    Parameters

    • c_mac

      chanend of receive server.

    • buffer

      The buffer to fill with the incoming packet

    • len

      A reference parameter to be filled with the length of the received packet in bytes.

    • src_port

      A reference parameter to be filled with the ethernet port the packet came from.

Configuration Functions

  • void mac_set_drop_packets(chanend c_mac_svr, int x)

    Setup whether a link should drop packets or block if the link is not ready.

    NOTE: setting no dropped packets does not mean no packets will be dropped. If packets are not dropped at the mac layer, it will block the mii fifo. The Mii fifo could possibly overflow and frames for other links could be dropped.

    Parameters

    • c_mac_svr

      chanend of receive server.

    • x

      boolean value as to whether packets should be dropped at mac layer.

  • void mac_set_queue_size(chanend c_mac_svr, int x)

    Setup the size of the buffer queue within the mac attached to this link.

    Parameters

    • c_mac_svr

      chanend connected to the mac

    • x

      the required size of the queue

  • void mac_set_custom_filter(chanend c_mac_svr, int x)

    Setup the custom filter up on a link.

    For each packet, the filter value is &-ed against the result of the mac_custom_filter function. If the result is non-zero then the packet is transmitted down the link.

    Parameters

    • c_mac_svr

      chanend of receive server.

    • x

      filter value

TX Client API

Packet Transmit Functions

  • void mac_tx(chanend c_mac, unsigned int buffer[], int nbytes, int ifnum)

    Sends an ethernet frame.

    Frame includes dest/src MAC address(s), type and payload.

    Parameters

    • c_mac

      channel end to tx server.

    • buffer[]

      byte array containing the ethernet frame. This must be word aligned

    • nbytes

      number of bytes in buffer

    • ifnum

      the number of the eth interface to transmit to (use ETH_BROADCAST transmits to all ports)

  • void mac_tx_timed(chanend c_mac, unsigned int buffer[], int nbytes, unsigned int &time, int ifnum)

    Sends an ethernet frame and gets the timestamp of the send.

    Frame includes dest/src MAC address(s), type and payload.

    This is a blocking call and returns the actual time the frame is sent to PHY according to the XCore 100Mhz 32-bit timer on the core the ethernet server is running.

    NOTE: This function will block until the packet is sent to PHY.

    Parameters

    • c_mac

      channel end connected to ethernet server.

    • buffer[]

      byte array containing the ethernet frame. This must be word aligned

    • nbytes

      number of bytes in buffer

    • ifnum

      the number of the eth interface to transmit to (use ETH_BROADCAST transmits to all ports)

    • time

      A reference paramater that is set to the time the packet is sent to the phy

  • void mac_tx_offset2(chanend c_mac, unsigned int buffer[], int nbytes, int ifnum)

    Sends an ethernet frame.

    Frame includes dest/src MAC address(s), type and payload.

    The packet should start at offset 2 in the buffer. This allows the packet to be constructed with alignment on a different boundary, allowing for more efficient construction where many word values are not naturally aligned on word boundaries.

    Parameters

    • c_mac

      channel end to tx server.

    • buffer[]

      byte array containing the ethernet frame. This must be word aligned

    • nbytes

      number of bytes in buffer

    • ifnum

      the number of the eth interface to transmit to (use ETH_BROADCAST transmits to all ports)

Ethernet function synonyms

Synonym

Function

ethernet_send_frame

ethernet_send_frame

ethernet_send_frame_getTime

ethernet_send_frame_getTime

ethernet_send_frame_offset2

mac_tx_offset2

ethernet_get_my_mac_adrs

mac_get_macaddr

Configuration Functions

  • int mac_get_macaddr(chanend c_mac, unsigned char macaddr[])

    Get the device MAC address.

    This function gets the MAC address of the device (the address passed into the ethernet_server()
    function.

    Parameters

    • c_mac

      chanend end connected to ethernet server

    • macaddr[]

      an array of type char where the MAC address is placed (in network order).

    Returns

    zero on success and non-zero on failure.

The module module_ethernet_smi
is written to support SMI independently of the MII interface.
Typically, Ethernet PHYs are configured on reset automatically, but the SMI
interface may be useful for setting and testing register values
dynamically.

There are two ways to interface SMI:
using a pair of 1-bit ports, or using
a single multi-bit port.

Configuration Defines

These defines can either be set in ethernet_conf.h or
smi_conf.h from within your application directory.

SMI_COMBINE_MDC_MDIO

This define should be set to 1 if you want to combine MDC and MDIO
onto a single bit port.

SMI_MDC_BIT

This defines the bit number on the shared port where the MDC line is.
Only define this if you have a port that drives both MDC and MDIO.

SMI_MDIO_BIT

This defines the bit number on the shared port where the MDIO line is.
Only define this if you have a port that drives both MDC and MDIO.

Data Structures

  • smi_interface_t

    Structure containing resources required for the SMI ethernet phy interface.

    This structure can be filled in two ways. One indicate that the SMI interface is connected using two 1-bit port, the other indicates that the interface is connected using a single multi-bit port.

    If used with two 1-bit ports, set the phy_address, p_smi_mdio and p_smi_mdc as normal.

    If SMI_COMBINE_MDC_MDIO is 1 then p_smi_mdio is ommited and p_mdc is assumbed to multibit port containing both mdio and mdc.

    Structure Members:

    • int phy_address

      Address of PHY, typically 0 or 0x1F.

    • port p_smi_mdio

      MDIO port.

    • port p_smi_mdc

      MDC port.

Phy API

  • void smi_init(smi_interface_t
     &smi)

    Function that configures the SMI ports.

    No clock block is needed. Note that there is no deinit function.

    Parameters

    • smi

      structure containing the clock and data ports for SMI.

  • void eth_phy_config(int eth100, smi_interface_t
     &smi)

    Function that configures the Ethernet PHY explicitly to set to autonegotiate.

    Parameters

    • If

      eth100 is non-zero, 100BaseT is advertised to the link peer Full duplex is always advertised

    • smi

      structure that defines the ports to use for SMI

  • void eth_phy_config_noauto(int eth100, smi_interface_t
     &smi)

    Function that configures the Ethernet PHY to not autonegotiate.

    Parameters

    • If

      eth100 is non-zero, it is set to 100, else to 10 Mbits/s

    • smi

      structure that defines the ports to use for SMI

  • void eth_phy_loopback(int enable, smi_interface_t
     &smi)

    Function that can enable or disable loopback in the phy.

    Parameters

    • enable

      boolean; set to 1 to enable loopback, or 0 to disable loopback.

    • smi

      structure containing the ports

  • int eth_phy_id(smi_interface_t
     &smi)

    Function that returns the PHY identification.

    Parameters

    • smi

      structure containing the ports

    Returns

    the 32-bit identifier.

  • Function that polls whether the link is alive.

    Parameters

    • smi

      structure containing the ports

    Returns

    non-zero if the link is alive; zero otherwise.

The module module_ethernet_board_support provides defines to allow
you to easily use an XMOS development board. To use the module include
the following header:

#include "ethernet_board_support.h"

The contents of this header varies depending on the TARGET defined
in your Makefile.

With this header included you can intialize ethernet port structures
using the following defines:

smi_interface_t smi = ETHERNET_DEFAULT_SMI_INIT;
mii_interface_t mii = ETHERNET_DEFAULT_MII_INIT;
ethernet_reset_interface_t eth_rst = ETHERNET_DEFAULT_RESET_INTERFACE_INIT;

You can also use the define ETHERNET_DEFAULT_TILE to refer to the
tile that the ethernet ports are on.

sliceKIT Core Board

For the sliceKIT Core Board the ethernet slice could be in any of the
four slots. To choose which slot the defines refer to you can set the
define one of the following defines to be 1 in ethernet_conf.h:

  • ETHERNET_USE_CIRCLE_SLOT
  • ETHERNET_USE_SQUARE_SLOT
  • ETHERNET_USE_STAR_SLOT (Not compatible with the 1v1 Core Board)
  • ETHERNET_USE_TRIANGLE_SLOT (Not compatible with the 1v1 Core Board)

XMOS Layer 2 Ethernet MAC Component Read More »

LCD Demo Quickstart Guide

This simple demonstration of xTIMEcomposer Studio functionality uses the XA-SK-SCR480 Slice Card together with the xSOFTip module_lcd to demonstrate how the module is used to write to an LCD screen.

Hardware Setup

The XP-SKC-L2 Slicekit Core board has four slots with edge conectors: SQUARE, CIRCLE, TRIANGLE and STAR.

To setup up the system:

  1. Connect XA-SK-SCR480 Slice Card to the XP-SKC-L2 Slicekit Core board using the connector marked with the STAR.
  2. Connect the XTAG Adapter to Slicekit Core board, and connect XTAG-2 to the adapter.
  3. Connect the XTAG-2 to host PC. Note that the USB cable is not provided with the Slicekit starter kit.
  4. Set the XMOS LINK to OFF on the XTAG Adapter.
  5. Ensure the jumper on the XA-SK-SCR480 is bridged if the back light is required.
  6. Switch on the power supply to the Slicekit Core board.
Hardware Setup for LCD Demo

/files/images/15937/2/hardware_setup.jpg

Import and Build the Application

  1. Open xTIMEcomposer and check that it is operating in online mode. Open the edit perspective (Window->Open Perspective->XMOS Edit).
  2. Locate the 'Slicekit LCD Demo' item in the xSOFTip pane on the bottom left of the window and drag it into the Project Explorer window in the xTIMEcomposer. This will also cause the modules on which this application depends (in this case, module_lcd) to be imported as well.
  3. Click on the app_lcd_demo item in the Explorer pane then click on the build icon (hammer) in xTIMEcomposer. Check the console window to verify that the application has built successfully.

For help in using xTIMEcomposer, try the xTIMEcomposer tutorial. FIXME add link.

Note that the Developer Column in the xTIMEcomposer on the right hand side of your screen provides information on the xSOFTip components you are using. Select the module_lcd component in the Project Explorer, and you will see its description together with API documentation. Having done this, click the back icon until you return to this quickstart guide within the Developer Column.

Run the Application

Now that the application has been compiled, the next step is to run it on the Slicekit Core Board using the tools to load the application over JTAG (via the XTAG2 and Xtag Adaptor card) into the xCORE multicore microcontroller.

  1. Click on the Run icon (the white arrow in the green circle). The output produced should look like a bouncing “X” on the LCD screen.

Next Steps

  1. Trying changing the int x=20, y=0, vx=1, vy=2; variables, they represent: initial x coord, initial y coord, x velocity and y velocity respectivly.
  2. In the sub() function what would you expect to see if the line: buffer[i] = BACK_COLOUR; was changed to buffer[i] = 0x12345678;?

Look at the Code

  1. Examine the application code. In xTIMEcomposer navigate to the src directory under app_sdram_demo and double click on the app_sdram_demo.xc file within it. The file will open in the central editor window.
  2. Find the main function and note that it runs the demo() function on a single logical core.

Try the Full Display Controller Demo

These applications are necessarily limited since there is no external memory available for a proper framebuffer, and the internal memory of an XCore Tile is too small to buffer a full screen colour image. The Display Controller demo combines the functionality of this LCD module with the SDRAM Controller component and SDRAM Slice Card to implement a fully functioning LCD Display Controller by adding the memory controller and a component that takes care of framebuffer management.

Once you have both the XA-SK-SDRAM< and XA-SK-SCR480 slices you can try the Display Controller demo by

???

LCD Demo Quickstart Guide Read More »

Scroll to Top