XMOS SliceKit GPIO Gpio Example Applications page 11

Table of Contents

Advertisement

SliceKit GPIO Example Applications
pin the it echoes the data back to the uart Transmit pin until > character is received in the input
data.
select
{
//:: Command start
REV A
case c_end : > data :
c_end : > data ;
if ( data == BUTTON_1 ) // Cycle LEDs on button 1 press
{
printstrln ( " Button 1 Pressed " ) ;
p_led <:( led_value ) ;
led_value = led_value < <1;
if ( led_value == 16) // If LED value is 16 then
{
}
}
if ( data == BUTTON_2 ) // Displays Temperature on console if
Button 2 is pressed
{
adc_value = read_adc_value () ;
data_arr [0]=( l i n e a r _ i n t e r p o l a t i o n ( adc_value ) ) ;
printstr ( " Temperature is : " ) ;
printint ( l i n e a r _ i n t e r p o l a t i o n ( adc_value ) ) ;
printstrln ( " C " ) ;
}
break ;
case u a r t _ r x _ g e t _ b y t e _ b y r e f ( c_uartRX , rxState , buffer ) :
if ( buffer == ' > ') // IUF received data is '>' character
then expects cmd to endter into command mode
{
j =0;
u a r t _ r x _ g e t _ b y t e _ b y r e f ( c_uartRX , rxState , buffer )
cmd_rcvbuffer [ j ]= buffer ;
if (( cmd_rcvbuffer [ j ] == 'C ' ) || ( cmd_rcvbuffer [ j ]
{
assigns LED value to 1 which cycles LEDs by
button press
led_value =0 x01 ;
;
== 'c ') ) // Checks if received data is 'C ' or
'c '
j ++;
u a r t _ r x _ g e t _ b y t e _ b y r e f ( c_uartRX , rxState ,
buffer ) ;
cmd_rcvbuffer [ j ]= buffer ;
if (( cmd_rcvbuffer [ j ] == 'm ' ) || (
cmd_rcvbuffer [ j ] == 'M ') ) // Checks if
received data is 'M ' or 'm '
{
j ++;
u a r t _ r x _ g e t _ b y t e _ b y r e f ( c_uartRX ,
rxState , buffer ) ;
cmd_rcvbuffer [ j ]= buffer ;
if (( cmd_rcvbuffer [ j ] == 'D ' ) || (
cmd_rcvbuffer [ j ] == 'd ') ) //
Checks if received data is '
D ' or 'd '
{
11/24

Advertisement

Table of Contents
loading

This manual is also suitable for:

Slicekit

Table of Contents