Project

General

Profile

Revision 15

Finished set_frequency

View differences:

lab2/lab2.c
37 37
}
38 38

  
39 39
int(timer_test_time_base)(uint8_t timer, uint32_t freq) {
40
  /* To be implemented by the students */
41
  printf("%s is not yet implemented!\n", __func__);
40
    if (timer_set_frequency(timer, freq)) return 1;
42 41

  
43
  return 1;
42
  return 0;
44 43
}
45 44

  
46 45
int(timer_test_int)(uint8_t time) {
lab2/timer.c
25 25
    if (sys_outb(TIMER_CTRL, write_cmd)) return 1;
26 26

  
27 27
    // counter_init = clock/freq
28
    // uint16_t counter_init = (uint16_t)(TIMER_FREQ / freq);
28
    uint16_t counter_init = (uint16_t)(TIMER_FREQ / freq);
29 29

  
30 30
    int timer_port = 0;
31 31
    switch(timer) {
32 32
        case 0: timer_port = TIMER_0; break;
33 33
        case 1: timer_port = TIMER_1; break;
34 34
        case 2: timer_port = TIMER_2; break;
35
        default: return 1;           break;
35
        default: return 1;            break;
36 36
    }
37
    uint8_t lsb = 0, msb = 0;
38
    if (util_get_LSB(counter_init, &lsb)) return 1;
39
    if (util_get_MSB(counter_init, &msb)) return 1;
37 40

  
41
    if (sys_outb(timer_port, lsb)) return 1;
42
    if (sys_outb(timer_port, msb)) return 1;
38 43

  
44
    //if (sys_outw(timer_port, counter_init)) return 1;
39 45

  
40
    return 1;
46
    return 0;
41 47
}
42 48

  
43 49
int (timer_subscribe_int)(uint8_t *bit_no) {

Also available in: Unified diff