XMOS SliceKit GPIO Gpio Example Applications page 23

Table of Contents

Advertisement

SliceKit GPIO Example Applications
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 ]) ;
j =0;
}
}
else
{
u a rt_ tx_ s e n d _ b y t e ( c_uartTX , buffer ) ; // Echoes back the input characters if not in
command mode
}
After the command mode is active the applicaion receives all the input commands and send to the
process_data API using a channel.The part of the code is shown below.
select
{
case 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 ++] == '\r ')
{
}
break ;
The process_data thread checks if any button is pressed or checks if there is any command
from app_manager thread. If there is button press then the thread sends instructions to the
app_manager thread about the button or if command is received, then it send instructions about
teh command received. The details in the process_data thread is as shown below.
Process_data thread send instructions to the app_manager thread about the command received.
The app_manager thread then implementys the state machine according to the instructions
received from the process_data thread. The state machine of app_manager thread is as below.
REV A
skip =0;
j =0;
while ( cmd_rcvbuffer [ j ] != '\r ')
{
c_process <: cmd_rcvbuffer [ j ]; // received valid command and
send the command to the process_data theread
u a r t _ t x _ sen d_ byt e ( c_uartTX , cmd_rcvbuffer [ j ]) ;
j ++;
}
cmd_rcvbuffer [ j ]= '\0 ';
c_process <: cmd_rcvbuffer [ j ];
for ( int inc =0; inc <20; inc ++) // Clears the command buffer
cmd_rcvbuffer [ inc ]= '0 ';
j =0;
23/24

Advertisement

Table of Contents
loading

This manual is also suitable for:

Slicekit

Table of Contents