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