void testTimer(void) { unsigned int count = 0; signed int ms = 0; signed int ss = 0; timerClearCount(HW_TIMER2); timerBegin(__CLK__FREQUENCY,__GSM_MODEM_TIMEOUT_US,HW_TIMER2); timerEnableInterrupt(HW_TIMER2); timerStart(HW_TIMER2); while(1) { if(timerCount2 >= 1000) { timerCount2 = 0; ms++; /* if(ms == 1000) { ms = 0; ss++; SerialIntWrite(ss,10); Serialwrite(LF); }*/ SerialIntWrite(ms,10); Serialwrite(LF); } } }
void ourtosStart() { _started = true; EnableInterrupts; timerEnableInterrupt(); /* Loop until the users stops the RTOS. At this point, return. */ for (;;) { DisableInterrupts; if (!_started) { break; } EnableInterrupts; // TODO: do we need dis? { asm NOP; } } EnableInterrupts; }
/*--------------------------------------------------------------------------* * --- Lancer le systeme --- * * Entree : Adresse de la premiere tache a lancer * * Sortie : Neant * * Descrip: Active la tache et lance le systeme * * * * * * Err. fatale: Neant * * * *--------------------------------------------------------------------------*/ void start(TACHE_ADR adr_tache) { short j; register unsigned int sp asm("sp"); for (j=0; j<MAX_TACHES; j++) { /* initialisation de l'etat des taches */ _contexte[j].status = NCREE; } /* Initialisation de la variable Haut de la pile des tâches */ _tos = sp; /* initialisation de la file */ file_init(); /* initialisation de la tache courante */ _tache_c = cree(adr_tache); /* ajout de la tache a la file */ ajoute(_tache_c); /* Passer en mode IRQ */ _set_arm_mode_(ARMMODE_IRQ); /* sp_irq initial */ sp = _contexte[_tache_c].sp_irq; /* Repasser en mode SYS */ _set_arm_mode_(ARMMODE_SYS); /* on interdit les interruptions */ _irq_disable_(); /* Initialisation du timer à 100 Hz */ timerInit(TIMER1, IRQ_FREQ); /* Initialisation de l'AITC */ timerEnableInterrupt(TIMER1); interruptEnableSource(INTERRUPT_TIMER1); /* creation et activation premiere tache */ active(_tache_c); schedule(); }