Project

General

Profile

Revision 18

Fix minor issue on set_frequency

View differences:

lab2/i8254.h
10 10
 */
11 11

  
12 12
#define TIMER_FREQ 1193182 /**< @brief clock frequency for timer in PC and AT */
13
#define TIMER_MIN_FREQ 19 /**< @brief mininum frequency for timer */
13 14
#define TIMER0_IRQ 0 /**< @brief Timer 0 IRQ line */
14 15

  
16

  
15 17
/* I/O port addresses */
16 18

  
17 19
#define TIMER_0    0x40 /**< @brief Timer 0 count register */
lab2/lab2.c
38 38

  
39 39
int(timer_test_time_base)(uint8_t timer, uint32_t freq) {
40 40
    if (timer_set_frequency(timer, freq)) return 1;
41

  
42 41
  return 0;
43 42
}
44 43

  
lab2/timer.c
6 6
#include "i8254.h"
7 7

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

  
10
    // Frequencies out this range are not supported (by limitation of hardware)
11
    if (freq > TIMER_FREQ || freq < TIMER_MIN_FREQ) return 1;
12

  
9 13
    uint8_t status = 0;
10 14
    if (timer_get_conf(timer, &status)) return 1;
11 15
    //Make command
......
41 45
    if (sys_outb(timer_port, lsb)) return 1;
42 46
    if (sys_outb(timer_port, msb)) return 1;
43 47

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

  
46 48
    return 0;
47 49
}
48 50

  

Also available in: Unified diff