Project

General

Profile

Revision 23

better prototype for timer_int_handler

View differences:

lab2.c
4 4
#include <stdbool.h>
5 5
#include <stdint.h>
6 6

  
7
int no_interrupts = 0;
7
extern int no_interrupts;
8 8

  
9 9
int main(int argc, char *argv[]) {
10 10
  // sets the language of LCF messages (can be either EN-US or PT-PT)
......
45 45
int(timer_test_int)(uint8_t time) {
46 46
    int ipc_status, r;
47 47
    message msg;
48

  
49 48
    uint8_t irq_set = 1;
50 49
    uint8_t hook = 0;
51
    int no_interrupts = 0;
50
    no_interrupts = 0;
52 51
    int freq = 60; // better way to get the frequency of the timer????
53 52

  
54 53
    timer_subscribe_int(&hook);
55 54

  
56
    while (no_interrupts < time * freq) {
55
    while (time) {
57 56
        /* Get a request message. */
58 57
        if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) {
59 58
            printf("driver_receive failed with %d", r);
......
72 71
        } else { /* received standart message, not a notification */
73 72
            /* no standart message expected: do nothing */
74 73
        }
75
        if (!(no_interrupts % freq))
74
        if (!(no_interrupts % freq)) {
76 75
            timer_print_elapsed_time();
76
            time--;
77
        }
77 78
    }
78 79

  
79 80
    timer_unsubscribe_int();

Also available in: Unified diff