Project

General

Profile

Statistics
| Revision:

root / lab2 / utils.c @ 25

History | View | Annotate | Download (470 Bytes)

1
#include <lcom/lcf.h>
2

    
3
#include <stdint.h>
4

    
5
int(util_get_LSB)(uint16_t val, uint8_t *lsb) {
6
    if (lsb == NULL) return 1;
7

    
8
    *lsb = (uint8_t)val;
9
    return 0;
10
}
11

    
12
int(util_get_MSB)(uint16_t val, uint8_t *msb) {
13
    if (msb == NULL) return 1;
14
    *msb = (uint8_t)(val >> 8);
15
    return 0;
16
}
17

    
18
int (util_sys_inb)(int port, uint8_t *value) {
19
    if(value == NULL) return 1;
20
    uint32_t n = 0;
21
    if(sys_inb(port, &n)) return 1;
22
    *value = (uint8_t)n;
23
    return 0;
24
}