SliceKit GPIO Example Applications
else
{
uart_tx_send_byte ( c_uartTX , '>');
uart_tx_send_byte ( c_uartTX , cmd_rcvbuffer [j]);
j =0;
}
}
else
{
uart_tx_send_byte ( 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 uart_rx_get_byte_byref ( c_uartRX , rxState , buffer ):
cmd_rcvbuffer [j]= buffer ;
if( cmd_rcvbuffer [j ++] == '\r ')
{
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
uart_tx_send_byte ( 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;
}
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