Project

General

Profile

Statistics
| Revision:

root / lab2 / utils.c @ 47

History | View | Annotate | Download (442 Bytes)

1 4 up20180655
#include <lcom/lcf.h>
2
3
#include <stdint.h>
4
5
int(util_get_LSB)(uint16_t val, uint8_t *lsb) {
6 20 up20180655
    if (lsb == NULL) return 1;
7 28 up20180642
    *lsb = val;
8 7 up20180655
    return 0;
9 4 up20180655
}
10
11
int(util_get_MSB)(uint16_t val, uint8_t *msb) {
12 20 up20180655
    if (msb == NULL) return 1;
13 28 up20180642
    *msb = (val >> 8);
14 7 up20180655
    return 0;
15 4 up20180655
}
16
17
int (util_sys_inb)(int port, uint8_t *value) {
18 8 up20180642
    if(value == NULL) return 1;
19 5 up20180642
    uint32_t n = 0;
20 9 up20180642
    if(sys_inb(port, &n)) return 1;
21 28 up20180642
    *value = n;
22 9 up20180642
    return 0;
23 4 up20180655
}