Project

General

Profile

Revision 10

Working function kbc_test_scan()

View differences:

lab3.c
1

  
1 2
#include <lcom/lcf.h>
2

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

  
5 4
#include <stdbool.h>
6 5
#include <stdint.h>
6

  
7 7
#include "keyboard.h"
8

  
9

  
8 10
int main(int argc, char *argv[]) {
9 11
  // sets the language of LCF messages (can be either EN-US or PT-PT)
10 12
  lcf_set_language("EN-US");
......
29 31
  return 0;
30 32
}
31 33

  
32
extern uint8_t scan_reg;
34
extern uint8_t scan_code;
35
extern uint32_t cnt;
33 36

  
34 37
int(kbd_test_scan)() {
35 38
  int r, ipc_status;
36
  uint8_t keyboard_irq, size, byte[2]; //size of scancode can be 2 byte long
39
  uint8_t keyboard_irq, size, bytes[2]; //size of scancode can be 2 byte long
37 40
  message msg;
38 41
  bool make=false; //to check if code is make or break
39 42

  
40
  if(kbc_subscribe_int(keyboard_irq)==1){
43
  if(kbc_subscribe_int(&keyboard_irq)==1){
41 44
    printf("Error subscribing int\n");
42 45
    return 1;
43 46
  }
44 47

  
45
  while(scan_code!=ESC_BREAK){      //looping until status_reg is the breakcode of ESC key
48
  while(scan_code!=ESC_BREAK){      //looping until scann_code is the breakcode of ESC key
46 49
    if ((r = driver_receive(ANY, &msg, &ipc_status))==1){ 
47 50
      printf("driver_receive failed with: %d",r);
48 51
      continue;
......
63 66
                    size=1;
64 67
                  }
65 68

  
66
                  if (scan_code & MAKE_CODE){	// 4 - Checks if code is make or break
69
                  if (scan_code & MAKE_CODE){	//checks if code is make or break
67 70
                      make = false;	//break code
68 71
                    }
69 72
                  else {
......
86 89
		return 1;
87 90
	}
88 91

  
92
  kbd_print_no_sysinb(cnt);
93

  
89 94
  return 0;
90 95
}
91 96

  

Also available in: Unified diff