Revision 15
Finished set_frequency
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