Revision 9
minor changes
lab2/timer.c | ||
---|---|---|
32 | 32 |
} |
33 | 33 |
|
34 | 34 |
int (timer_get_conf)(uint8_t timer, uint8_t *st) { |
35 |
// Write read-back command to TIMER_CTRL |
|
35 | 36 |
int write_port = TIMER_CTRL; |
36 | 37 |
u32_t cmd = TIMER_RB_CMD | TIMER_RB_COUNT_ | TIMER_RB_SEL(timer); |
37 | 38 |
if(sys_outb(write_port, cmd)) return 1; |
... | ... | |
53 | 54 |
if(field == tsf_all || field == tsf_initial){ |
54 | 55 |
in_mode = (st & TIMER_INMODE_MASK) >> TIMER_INMODE_POS; |
55 | 56 |
switch(in_mode){ |
56 |
case 0: conf.in_mode = INVAL_val ; break; |
|
57 |
case 1: conf.in_mode = LSB_only ; break; |
|
58 |
case 2: conf.in_mode = MSB_only ; break; |
|
59 |
case 3: conf.in_mode = MSB_after_LSB; break; |
|
57 |
case 0: conf.in_mode = INVAL_val ; break; //000
|
|
58 |
case 1: conf.in_mode = LSB_only ; break; //001
|
|
59 |
case 2: conf.in_mode = MSB_only ; break; //010
|
|
60 |
case 3: conf.in_mode = MSB_after_LSB; break; //011
|
|
60 | 61 |
default: return 1; break; |
61 | 62 |
} |
62 | 63 |
if(timer_print_config(timer, field, conf)) return 1; |
lab2/utils.c | ||
---|---|---|
21 | 21 |
/* To be implemented by the students */ |
22 | 22 |
if(value == NULL) return 1; |
23 | 23 |
uint32_t n = 0; |
24 |
int ret = sys_inb(port, &n);
|
|
24 |
if(sys_inb(port, &n)) return 1;
|
|
25 | 25 |
*value = n; |
26 |
return ret;
|
|
26 |
return 0;
|
|
27 | 27 |
} |
Also available in: Unified diff