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
{
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
>
assigns LED value to 1 which cycles LEDs by
>
button press
{
led_value =0 x01 ;
}
}
if( data == BUTTON_2 ) // Displays Temperature on console if
>
Button 2 is pressed
{
adc_value = read_adc_value ();
data_arr [0]=( linear_interpolation ( adc_value ));
printstr (" Temperature is :");
printint ( linear_interpolation ( adc_value ));
printstrln (" C");
}
break ;
case uart_rx_get_byte_byref ( c_uartRX , rxState , buffer ):
//:: Command start
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'
{
REV A