void quad_every(_QUAD *self, _TIMER *timer, float interval) { /* Given an initialized _QUAD object, configures it to utilize the given _TIMER's interrupts to read the _QUAD at the specified time interval. */ timer_every(timer, interval, self -> timer_read); }
void init_leds(void) { // init the objects and set up the unified controller uint8_t i; for (i = 0; i < LEDS_NUM; i++) { leds_state[i] = 0; } leds_init(&ledbar1, 8, 0); leds_init(&ledbar2, 8, 8); leds_init(&ledbar3, 8, 16); leds_init(&ledcenter, 60, 24); IPC0 |= 0x0700; // OC1 interrupt highest priority timer_every(&timer4, 0.035, __leds_update); }
void control_init(void){ /*Inicialitza el mòdul de control. ës imprescindible cridar la funció abans d'usar el mòdul. Una vegada inicialitzat deixa els semàfors apagats i cal engegar-los explícitament.*/ /*Inicialitza el timer y activa les interrupcions.*/ //Inicialitza els Semafors A i B, amb els seus ports corresponents. semaph_init(&(SemA.state), &PORTD, 5, &PORTD, 6, &PORTD, 7); semaph_init(&(SemB.state), &PORTD, 4, &PORTC, 3, &PORTC, 2); //Posa a l'estat d'apagat els semafors. semaph_set(&(SemA.state),SemOff); semaph_set(&(SemB.state),SemOff); //Indiquem a la variable global que estemx a l'estat d'off. (control).estat = Off; timer_init(); i=timer_every(TIMER_MS(100),control_change); //Activem interrupcions sei(); }