Project

General

Profile

Revision 23

better prototype for timer_int_handler

View differences:

lab2/i8254.h
49 49
#define TIMER_MODE_3ALT 0x7              /**< @brief Alternative notation for mode 3 */
50 50
#define TIMER_MODE_RED2 0x03             /**< @brief Reduce 3-bit mode to 2-bit mode */
51 51

  
52

  
53 52
/* Counting mode: bit 0 */
54 53

  
55 54
#define TIMER_BCD 0x01 /**< @brief Count in BCD */
lab2/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();
lab2/timer.c
5 5

  
6 6
#include "i8254.h"
7 7

  
8
int no_interrupts = 0;
9

  
8 10
int (timer_set_frequency)(uint8_t timer, uint32_t freq) {
9 11

  
10 12
    // Frequencies out this range are not supported (by limitation of hardware)
......
62 64
}
63 65

  
64 66
void (timer_int_handler)() {
65
    int no_interrupts = 0; //should be the global
66

  
67 67
    no_interrupts++;
68 68
}
69 69

  

Also available in: Unified diff