Revision 29
minor changes and comments
lab2.c | ||
---|---|---|
37 | 37 |
|
38 | 38 |
int(timer_test_time_base)(uint8_t timer, uint32_t freq) { |
39 | 39 |
if (timer_set_frequency(timer, freq)) return 1; |
40 |
return 0; |
|
40 |
return 0;
|
|
41 | 41 |
} |
42 | 42 |
|
43 | 43 |
extern int no_interrupts; |
44 | 44 |
|
45 | 45 |
int(timer_test_int)(uint8_t time) { |
46 |
const uint32_t frequency = 60; // Frequency asummed at 60Hz
|
|
46 |
const int frequency = 60; // Frequency asummed at 60Hz
|
|
47 | 47 |
int ipc_status, r; |
48 | 48 |
message msg; |
49 | 49 |
uint8_t hook = 0; |
50 | 50 |
no_interrupts = 0; |
51 |
timer_subscribe_int(&hook);
|
|
51 |
if (timer_subscribe_int(&hook)) return 1;
|
|
52 | 52 |
int irq_set = BIT(hook); |
53 | 53 |
while (time) { |
54 | 54 |
/* Get a request message. */ |
... | ... | |
61 | 61 |
case HARDWARE: /* hardware interrupt notification */ |
62 | 62 |
if (msg.m_notify.interrupts & irq_set) { /* subscribed interrupt */ |
63 | 63 |
timer_int_handler(); |
64 |
if (!(no_interrupts % frequency)) { |
|
64 |
if (!(no_interrupts % frequency)) { /* second elapsed */
|
|
65 | 65 |
timer_print_elapsed_time(); |
66 | 66 |
time--; |
67 | 67 |
} |
... | ... | |
74 | 74 |
/* no standart message expected: do nothing */ |
75 | 75 |
} |
76 | 76 |
} |
77 |
timer_unsubscribe_int();
|
|
78 |
return 0; |
|
77 |
if (timer_unsubscribe_int()) return 1;
|
|
78 |
return 0;
|
|
79 | 79 |
} |
Also available in: Unified diff