SliceKit GPIO Example Applications
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. The part of code which explains about
the command mode is as blow.
if( buffer == '>') // IUF received data is '>' character then expects cmd to endter into
>
command mode
{
j =0;
uart_rx_get_byte_byref ( c_uartRX , rxState , buffer );
cmd_rcvbuffer [j]= buffer ;
if (( cmd_rcvbuffer [j] == 'C' )|| ( cmd_rcvbuffer [j] =='c ')) // Checks if received
>
data is 'C' or 'c'
{
j ++;
uart_rx_get_byte_byref ( 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 ++;
uart_rx_get_byte_byref ( 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'
{
uart_tx_send_byte ( c_uartTX , '\r ');
uart_tx_send_byte ( c_uartTX , '\n ');
uart_tx_string ( c_uartTX , CONSOLE_MESSAGES [0]) ;
COMMAND_MODE =1; // activates command mode as received data
>
is '>cmd '
uart_tx_send_byte ( c_uartTX , '\r ');
uart_tx_send_byte ( c_uartTX , '\n ');
uart_tx_send_byte ( c_uartTX , '>'); // displays '>' if
>
command mode is activated
}
else
{
uart_tx_send_byte ( c_uartTX , '>');
for ( int i =0;i <3; i ++)
uart_tx_send_byte ( c_uartTX , cmd_rcvbuffer [i]); //
>
if received dta is not 'c' displays back
>
the received data
}
}
else
{
uart_tx_send_byte ( c_uartTX , '>'); // if received data is not 'm'
>
displays the received data
for ( int i =0;i <2; i ++)
uart_tx_send_byte ( c_uartTX , cmd_rcvbuffer [i]);
}
}
REV A