Hello guys, and may the force be with you,
I am new to the XMOS technology but a microcontroller-parallel computing enthousiast.
I just got the SliceKit and was checking the app_sk_gpio_simple_demo. I paste the while loop in the main function. My question is as follows. Given the intention of the second case to check whether the same button is pressed after 20ms, the underlined if statement shouldnt include in curly brackets the following 2 if statements.
A naive question, I know, but I wanted to grasp the opportunity to say hello!
while(1)
{
select
{
//checks if any button is pressed
case button => p_PORT_BUT_1 when pinsneq(button_press_1):> button_press_1:
button=0;
t:>time;
break;
//waits for 20ms and checks if the same button is pressed or not
case !button => t when timerafter(time+debounce_time):>void:
p_PORT_BUT_1:> button_press_2;
if(button_press_1==button_press_2)
if(button_press_1 == BUTTON_PRESS_VALUE) //Button 1 is pressed
{
printstrln("Button 1 Pressed");
p_led<:(led_value);
led_value=led_value<<1;
led_value|=0x01;
led_value=led_value & 0x0F;
if(led_value == 15)
{
led_value=0x0E;
}
}
if(button_press_1 == BUTTON_PRESS_VALUE-1) //Button 2 is pressed
{
data1[0]=0;data1[1]=0;
i2c_master_rx(0x28, data1, 2, i2cOne); //Read ADC value using I2C read
printstrln("Reading Temperature value....");
data1[0]=data1[0]&0x0F;
adc_value=(data1[0]<<6)|(data1[1]>>2);
printstr("Temperature is :");
printintln(linear_interpolation(adc_value));
}
button=1;
break;
}
//::Select
}
app_sk_gpio_simple_demo, forgotten curly brackets?
-
- New User
- Posts: 2
- Joined: Tue Feb 11, 2014 10:31 am
-
- XCore Expert
- Posts: 589
- Joined: Wed Feb 29, 2012 10:03 am
The app_sk_gpio_com_demo example is correct and it is okay even if the braces are not availabe. If the following line is true only then the next if statement in the gpio com demo example will be checked.
if(button_press_1==button_press_2)
if(button_press_1==button_press_2)