![XMOS XK-1A Скачать руководство пользователя страница 13](http://html1.mh-extra.com/html/xmos/xk-1a/xk-1a_manual_3536653013.webp)
XK-1A Development Board Tutorial
b r e a k ;
}
}
r e t u r n 0;
}
6. Run your application.
A flashing LED should cycle between the four LEDs on your XK-1A.
7. Verify that pressing and holding button BUT1 causes the message “pressed” be
displayed in the
Console
and the LEDs to stop flashing. Releasing the button
should cause the message “released” to be displayed and the flashing LED
should continue cycling.
Note that you may need to push the button down firmly on your XK-1A to
operate it.
8. In the
Console
, click the
Terminate
button () to stop your application running.
5
Run tasks concurrently
This part of the tutorial shows you how to run tasks concurrently on different
threads, using the XC
par
statement and channel communication.
5.1
Create a project
The program below creates two concurrent threads, which run two separate tasks
independently of each other.
# i n c l u d e < xs1 . h >
# i n c l u d e < s t d i o . h >
# d e f i n e F L A S H _ P E R I O D 1 0 0 0 0 0 0 0
# d e f i n e C Y C L E _ P E R I O D 5 0 0 0 0 0 0 0
out p o r t led = X S 1 _ P O R T _ 4 F ;
in p o r t b u t 1 = X S 1 _ P O R T _ 1 K ;
v o i d f l a s h L E D s 4 b i t P o r t ( out p o r t led , int f l a s h P e r i o d , int c y c l e P e r i o d ) {
/* C o d e to f l a s h 4 L E D s c o n n e c t e d to a 4 - bit p o r t in a c y c l e */
u n s i g n e d l e d O n = 1;
u n s i g n e d l e d V a l = 1;
t i m e r tmrF , t m r C ;
u n s i g n e d timeF , t i m e C ;
t m r F : > t i m e F ;
t m r C : > t i m e C ;
w h i l e (1) {
s e l e c t {
c a s e t m r F w h e n t i m e r a f t e r ( t i m e F ) : > v o i d :
l e d O n = ! l e d O n ;
if ( l e d O n )
led <: l e d V a l ;
X7366A