Advertisement

Quick Links

SliceKit GPIO Example Applications
REV A
Publication Date: 2012/10/23
XMOS © 2012, All Rights Reserved.

Advertisement

Table of Contents
loading

Summary of Contents for XMOS SliceKit GPIO

  • Page 1 SliceKit GPIO Example Applications REV A Publication Date: 2012/10/23 XMOS © 2012, All Rights Reserved.
  • Page 2: Table Of Contents

    SliceKit GPIO Example Applications 2/24 Table of Contents 1 Overview 2 Evaluation Platforms 2.1 Recommended Hardware ........
  • Page 3: Overview

    1 Overview This document covers two example applications that demonstrate various features of the XA-SK-GPIO Slice Card including the ADC, LEDs, UART connector and buttons, the I2C master xSOFTip component, as well as various basic features of the xCORE processor. Low level details of how the application is implemented are covered here, with information about how to modify and experiment with them.
  • Page 4: Evaluation Platforms

    2 Evaluation Platforms IN TH I S C H A P T ER Recommended Hardware Example Applications 2.1 Recommended Hardware This application may be evaluated using the Slicekit Modular Development Platform, available from digikey. Required board SKUs are: XP-SKC-L2 (Slicekit L2 Core Board) plus XA-SK-GPIO plus XA-SK-XTAG2 (Slicekit XTAG adaptor) plus XTAG2 (debug adaptor), 2.2 Example Applications 2.2.1 app_slicekit_simple_demo...
  • Page 5 SliceKit GPIO Example Applications 5/24 Cycles Through LEDs on button Press Displays temperature value and button press events on the terminal console of a host PC via the UART REV A...
  • Page 6: Programming Guide

    3 Programming Guide IN TH I S C H A P T ER Simple Demo COM Port Demo 3.1 Simple Demo 3.1.1 Structure All of the files required for operation are located in the app_sk_gpio_simple_demo/src directory. The files that are need to be included for use of this component in an application are: File Description Header file for API interfaces and Look up tables for thermistor.
  • Page 7: Usage And Implementation

    SliceKit GPIO Example Applications 7/24 This function returns: Returns linear interpolated Temperature value int read_adc_value() Read ADC value using I2C. This function returns: Returns ADC value 3.1.3 Usage and Implementation The port declaration for the LEDs, Buttons and I2C are declared as below. LEDs and Buttons use 4 bit ports and I2C uses 1 bit port for SCL(I2c Clock) and SDA (I2C data).
  • Page 8 SliceKit GPIO Example Applications 8/24 led_value = led_value & 0 x0F ; if ( led_value == 15) led_value =0 x0E ; if ( but ton_pr ess_1 == BUTTON_PRESS_VALUE -1) // Button 2 is pressed data1 [0]=0; data1 [1]=0; i2c_master_rx (0 x28 , data1 , 2 , i2cOne ) ; // Read ADC value using I2C read printstrln ( "...
  • Page 9: Com Port Demo

    SliceKit GPIO Example Applications 9/24 3.2 COM Port Demo 3.2.1 Structure All of the files required for operation are located in the app_slicekit_simple_demo/src directory. The files that are need to be included for use of this component in an application are:...
  • Page 10: Usage And Implementation

    SliceKit GPIO Example Applications 10/24 Channel to receive data from app Uart TX Thread c_uartTX Buffer to store array of characters message int linear_interpolation(int adc_value) Calculates temperatue based on linear interpolation. This function has the following parameters: int value read from ADC...
  • Page 11 SliceKit GPIO Example Applications 11/24 pin the it echoes the data back to the uart Transmit pin until > character is received in the input data. select case c_end : > data : c_end : > data ; if ( data == BUTTON_1 ) // Cycle LEDs on button 1 press printstrln ( "...
  • Page 12 SliceKit GPIO Example Applications 12/24 ua rt_ tx_ sen d_b yt e ( c_uartTX , '\r ') ; ua rt_ tx_ sen d_b yt e ( c_uartTX , '\n ') ; uart_tx_string ( c_uartTX , CONSO LE_MESSAGES [0]) COMMAND_MODE =1; //...
  • Page 13 SliceKit GPIO Example Applications 13/24 u a r t _ t x_ se nd_ byt e ( c_uartTX , buffer ) ; // Echoes back the input characters if not in command mode //:: Command while ( COMMAND_MODE ) // Command mode activated j =0;...
  • Page 14 SliceKit GPIO Example Applications 14/24 for ( int inc =0; inc <20; inc ++) // Clears the command buffer cmd_rcvbuffer [ inc ]= '0 '; j =0; break ; //:: Send case c_end : > data : if ( data != EXIT && data !=...
  • Page 15 SliceKit GPIO Example Applications 15/24 data = data xE ; p_led <: data break ; case CLEAR_LED_1 :// Read port Value and Set LED 1 p_led : > data p_led <: data &0 x1 break ; case SET_LED_2 : // Read port...
  • Page 16 SliceKit GPIO Example Applications 16/24 break ; case CLEAR_LED_3 : // Read port Value and Set LED 3 p_led : > data p_led <: data &0 x4 break ; case SET_LED_4 : // Read port Value and Set LED 4 ON p_led : >...
  • Page 17 SliceKit GPIO Example Applications 17/24 : // Checks if button is pressed c_end : > button if ( button BUTTON_1 ) // Prints Button pressed Uart C O NS O L E_ M ES S AG [4][9]= '1 uart _tx_s tring...
  • Page 18 SliceKit GPIO Example Applications 18/24 button2_press break ; case HELP : // Displays help messages on Uart uart_tx_string c_uartTX C O NS O LE _ ME S SA G ES [14]) uart_tx_string c_uartTX C O NS O LE _ ME S SA G ES...
  • Page 19 SliceKit GPIO Example Applications 19/24 c_uartTX , '\ r ') ; ua r t_ t x_ s en d_ b yt e c_uartTX , '\ n ') ; break ; case READ_ADC : // Displays temperature value on the Uart...
  • Page 20 SliceKit GPIO Example Applications 20/24 input is invalid command on the Uart uart_tx_string c_uartTX C O NS O LE _ ME S SA G ES [2]) break ; case CHK_BUTTONS : // Checks if button are pressed and displays on...
  • Page 21 SliceKit GPIO Example Applications 21/24 Dipslays Button pressed if ( ! button1_press && button2_press uart _tx_s tring c_uartTX CO N SO L E_ M [5]) Displays Buttons pressed button1_press button2_press break ; if ( data != EXIT ) // Exits...
  • Page 22 SliceKit GPIO Example Applications 22/24 j =0; }// command mode break ; }// main select If the received data is > character the it waits to see if the next received successive bytes are c , m and d . If the successive received data is >cmd then the application activates comman mode otherwise the data is echoed back to the Uart Transmit pin.
  • Page 23 SliceKit GPIO Example Applications 23/24 else u a r t _ t x _ s e n d _ b y t e ( c_uartTX , ' > ') ; u a r t _ t x _ s e n d _ b y t e ( c_uartTX , cmd_rcvbuffer [ j ]) ;...
  • Page 24 XMOS and the XMOS logo are registered trademarks of Xmos Ltd. in the United Kingdom and other countries, and may not be used without written permission. All other trademarks are property of their respective owners.

This manual is also suitable for:

Slicekit

Table of Contents