1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
void* task_fcn(void* arg) {
long sec1 = 1000000000L;
int n =0;
int isOn = 0; //0: LED currently off, 1: currently on
unsigned int tmp; //temp variable to compute LED pattern
pthread_make_periodic_np( pthread_self(), gethrtime(), sec1/2 );
//periode de 0.5 s
while (n<100) {
pthread_wait_np();
//Laisse eteint pdt 0.5 s et allume la LED pdt 0.5 s
rtl_printf("n=%d\n", n); //debug only
++n;
tmp = 0;
if (!isOn) {
isOn =1;
//c'est la partie moche et artificielle qui fait attendre 2 s
pthread_wait_np();
pthread_wait_np();
pthread_wait_np();
pthread_wait_np();
//allumage de la LED pdt un cycle = 0.5 s
//tmp |= 1; //Srl-lock
tmp |= 2; //Num-lock
//tmp |= 4; //Cap-lock
} else { isOn=0; }
setLED( tmp );
}//end while
return 0;
} |
Partager