Revision 64
changing
utils.c | ||
---|---|---|
1 |
#include "errors.h" |
|
2 |
|
|
3 | 1 |
#include <lcom/lcf.h> |
4 | 2 |
|
5 | 3 |
#include <stdint.h> |
6 | 4 |
|
5 |
int(util_get_LSB)(uint16_t val, uint8_t *lsb) { |
|
6 |
if (lsb == NULL) return 1; |
|
7 |
*lsb = val; |
|
8 |
return 0; |
|
9 |
} |
|
10 |
|
|
11 |
int(util_get_MSB)(uint16_t val, uint8_t *msb) { |
|
12 |
if (msb == NULL) return 1; |
|
13 |
*msb = (val >> 8); |
|
14 |
return 0; |
|
15 |
} |
|
16 |
|
|
17 |
#ifdef LAB3 |
|
18 |
uint32_t sys_inb_counter = 0; |
|
19 |
#endif |
|
20 |
|
|
7 | 21 |
int (util_sys_inb)(int port, uint8_t *value) { |
8 |
if(value == NULL) return NULL_PTR;
|
|
22 |
if(value == NULL) return 1;
|
|
9 | 23 |
uint32_t n = 0; |
10 |
if(sys_inb(port, &n)) return READ_ERROR;
|
|
24 |
if(sys_inb(port, &n)) return 1;
|
|
11 | 25 |
*value = n; |
12 |
return SUCCESS; |
|
26 |
#ifdef LAB3 |
|
27 |
++sys_inb_counter; |
|
28 |
#endif |
|
29 |
return 0; |
|
13 | 30 |
} |
Also available in: Unified diff