![XMOS XK-1A Скачать руководство пользователя страница 14](http://html1.mh-extra.com/html/xmos/xk-1a/xk-1a_manual_3536653014.webp)
XK-1A Development Board Tutorial
e l s e
led <: 0;
t i m e F += F L A S H _ P E R I O D ;
b r e a k ;
c a s e t m r C w h e n t i m e r a f t e r ( t i m e C ) : > v o i d :
l e d V a l
< <= 1;
if ( l e d V a l == 0 x10 )
l e d V a l = 1;
t i m e C += C Y C L E _ P E R I O D ;
b r e a k ;
}
}
}
v o i d r e s p o n d T o B u t t o n ( in p o r t but ) {
/* C o d e to r e s p o n d to a b u t t o n p r e s s */
w h i l e (1) {
but w h e n p i n s e q (0) : > v o i d ;
p r i n t f ( " P r e s s e d \ n " ) ;
but w h e n p i n s e q (1) : > v o i d ;
p r i n t f ( " R e l e a s e d \ n " ) ;
}
}
int m a i n ( v o i d ) {
par {
f l a s h L E D s 4 b i t P o r t ( led , F L A S H _ P E R I O D , C Y C L E _ P E R I O D ) ;
r e s p o n d T o B u t t o n ( b u t 1 ) ;
}
r e t u r n 0;
}
Before continuing to the next part of this tutorial, create a new project using this
code.
5.2
Examine the application code
Take a look at the code in the editor. In
main
, the two statements inside the braces
of the
par
are run concurrently: the current thread allocates a new hardware thread;
the current thread then runs the function
flashLEDs4bitPort
; and the new thread
runs the function
respondToButton
. The L1 device has a total of eight available
hardware threads.
To complete this part of the tutorial, perform the following tasks:
1. Build your project, create a new Run Configuration, and run it.
2. Verify that a flashing LED cycles between the four LEDs on your XK-1A. Pressing
and holding button BUT1 should cause the message “pressed” be displayed
in the
Console
and the LEDs should continue to flash. Releasing the button
should cause the message “released” to be displayed.
3. In the
Console
, click the
Terminate
button () to stop your project running.
X7366A