Project

General

Profile

Revision 31

Minor changes

View differences:

lab3/Makefile
6 6

  
7 7
# additional compilation flags
8 8
# "-Wall -Wextra -Werror -I . -std=c11 -Wno-unused-parameter" are already set
9
CFLAGS += -pedantic
10
CPPFLAGS += -D LAB3
9
CFLAGS += -pedantic -DLAB3
11 10

  
12 11
# list of library dependencies (for Lab 2, only LCF library)
13 12
DPADD += ${LIBLCF}
lab3/kbc.c
16 16

  
17 17
uint8_t scancode[2];
18 18
int two_byte_scancode = 0;
19
int got_error = 0;
19 20

  
20 21
void (kbc_ih)(void) {
21 22
    uint8_t status = 0;
23
    got_error = 0;
22 24

  
23 25
    #ifdef LAB3
24 26
    sys_inb_counter(INCREMENT);
25 27
    #endif
26 28

  
27
    if (util_sys_inb(STATUS_REG, &status)) return;
29
    if (util_sys_inb(STATUS_REG, &status)) {
30
        got_error = 1;
31
        return;
32
    }
28 33

  
29
    if (status & (TIME_OUT_REC | PARITY_ERROR)) return;
34
    if (status & (TIME_OUT_REC | PARITY_ERROR)) {
35
        got_error = 1;
36
        return;
37
    }
30 38

  
31 39
    #ifdef LAB3
32 40
    sys_inb_counter(INCREMENT);
......
34 42

  
35 43
    uint8_t byte = 0;
36 44

  
37
    if (util_sys_inb(OUTPUT_BUF, &byte)) return;
45
    if (util_sys_inb(OUTPUT_BUF, &byte)) {
46
        got_error = 1;
47
        return;
48
    }
38 49

  
39 50
    if (two_byte_scancode) {
40 51
        scancode[1] = byte;
......
46 57

  
47 58
}
48 59

  
49
uint32_t sys_inb_counter(int increment) {
60
uint32_t (sys_inb_counter)(int increment) {
50 61
    static uint32_t counter = 0;
51 62
    if (increment) return ++counter;
52 63
    return counter;
lab3/kbc.h
5 5

  
6 6
#define KBC_IRQ     1 /* @brief KBC Controller IRQ Line */
7 7

  
8
/* Delay for KBC */
9
#define DELAY   20000 /* @brief KBC Response Delay */
10

  
8 11
/* I/O Ports Addresses */
9 12

  
10 13
#define KBC_CMD     0x64 /* @brief Address to send commands to KBC */
lab3/kbc_func.h
32 32
 * @param increment Whether the value should be incremented or not
33 33
 * @return The current value of the counter
34 34
 */
35
uint32_t sys_inb_counter(int get_increment);
35
uint32_t (sys_inb_counter)(int get_increment);
36 36

  
37 37
#endif
lab3/lab3.c
1 1
#include <lcom/lcf.h>
2

  
3 2
#include <lcom/lab3.h>
4 3

  
5 4
#include <stdbool.h>
......
34 33

  
35 34
extern uint8_t scancode[2];
36 35
extern int two_byte_scancode;
36
extern int got_error;
37 37

  
38 38
int(kbd_test_scan)() {
39 39

  
......
60 60

  
61 61
                        kbc_ih();
62 62

  
63
                        if (!two_byte_scancode) { /* finished processing a scancode */
63
                        if (!(two_byte_scancode || got_error)) { /* finished processing a scancode */
64 64
                            if (scancode[0] == TWO_BYTE_CODE)
65 65
                                kbd_print_scancode(!(scancode[1] & BREAK_CODE_BIT), 2, scancode);
66 66
                            else
67 67
                                kbd_print_scancode(!(scancode[0] & BREAK_CODE_BIT), 1, scancode);
68
                        } else {
69
                            break;
68 70
                        }
69 71

  
70 72
                        if (scancode[0] == ESC_BREAK_CODE)

Also available in: Unified diff