Changeset 87ab18e in avrstuff
- Timestamp:
- Jul 31, 2014, 11:00:37 PM (10 years ago)
- Branches:
- main
- Children:
- 0010058
- Parents:
- ea32107
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kbd/xtk/code/Makefile
rea32107 r87ab18e 1 MCU=atmega48p 1 # Board settings 2 3 # K4KUSB 4 MCU=attiny2313 5 F_CPU=12000000 6 7 # Generic settings 8 BAUD=9600 9 2 10 3 11 include ../../common.mk 4 12 5 all: keyboard.hex 6 7 keyboard.bin: keyboard.o main.o 13 $(MCU).bin: $(MCU)/keyboard.o $(MCU)/main.o 8 14 $(CC) $^ -o $@ -mmcu=$(MCU) -Os 9 15 10 main.o: main.c $(LIBS)/ps2_keyboard/ps2_keyboard.h 11 $(CC) -std=c99 -c $< -mmcu=$(MCU) -Os -o $@ -Os16 $(MCU)/main.o: main.c $(LIBS)/ps2_keyboard/ps2_keyboard.h $(MCU) 17 $(CC) $(CFLAGS) -std=c99 -c $< -o $@ 12 18 13 keyboard.o: $(LIBS)/ps2_keyboard/ps2_keyboard.c $(LIBS)/ps2_keyboard/ps2_keyboard.h $(LIBS)/ps2_keyboard/keymap.h 14 $(CC) -DCALLBACK="callback();" -c $< -mmcu=$(MCU) -Os -o $@ 15 16 clean: 17 rm *.o *.bin *.hex 18 19 flash: keyboard.hex 20 $(AVRDUDE) -c usbasp -p $(MCU) -Uflash:w:$^ 19 $(MCU)/keyboard.o: $(LIBS)/ps2_keyboard/ps2_keyboard.c $(LIBS)/ps2_keyboard/ps2_keyboard.h $(LIBS)/ps2_keyboard/keymap.h $(MCU) 20 $(CC) $(CFLAGS) -DCALLBACK="callback();" -c $< -o $@ -
kbd/xtk/code/main.c
rea32107 r87ab18e 24 24 void callback() 25 25 { 26 uint8_t key_code = 0;27 key_code = read_char(); // TODO this function is blocking. Can it disturb main?28 29 key = pgm_read_byte(&(at2xt[key_code]));30 if(release)31 key |= 0x80;26 // Ignore all keys above 0x80, and importantly ignore 0xE0 from extended keys. 27 if (kbd_data < 0x80) { 28 key = pgm_read_byte(&(at2xt[kbd_data])); 29 if(release) 30 key |= 0x80; 31 } 32 32 } 33 33 … … 52 52 #endif 53 53 54 static const int delay = 25;54 static const int delay = 12; 55 55 56 56 // XT init - configure pins directions … … 58 58 DDRXT &= ~(PCLK | PDAT); // both pins as inputs (floating) 59 59 60 DDRB |= (1<<PB2); // LED61 62 60 uint8_t k; 63 61 while(1) { 64 PORTB ^= (1<<PB2); // LED65 66 62 while ((PINXT & (PDAT|PCLK)) != (PDAT|PCLK)) 67 63 ; // Wait for PC to be ready to receive data -
libs/ps2_keyboard/ps2_keyboard.c
rea32107 r87ab18e 30 30 #endif 31 31 32 static volatile uint8_t kbd_data;33 32 static volatile uint8_t char_waiting; 34 33 static uint8_t started; 35 34 static uint8_t bit_count; 36 static uint8_t caps_lock;37 35 static uint8_t extended; 38 36 39 uint8_t shift;37 volatile uint8_t kbd_data; 40 38 uint8_t release; 41 39 … … 79 77 kbd_data = 0; 80 78 return; 81 } else if (kbd_data == 0x12) { //hanlde shift key82 if(release == 0){83 shift = 1;84 } else {85 shift = 0;86 release = 0;87 }88 return;89 79 } else { //not a special character 90 if(release){ //we were in release mode - exit release mode91 release = 0;92 //ignore that character93 } else {94 char_waiting = 1;95 80 #ifdef CALLBACK 96 81 CALLBACK 97 82 #endif 83 if(release){ //we were in release mode - exit release mode 84 release = 0; 85 } else { 86 // Notify callback that there's a new char waiting 87 char_waiting = 1; 98 88 } 99 89 } -
libs/ps2_keyboard/ps2_keyboard.h
rea32107 r87ab18e 9 9 // Convert a keycode to a printable ASCII char 10 10 11 extern uint8_t shift;11 extern volatile uint8_t kbd_data; 12 12 extern uint8_t release;
Note:
See TracChangeset
for help on using the changeset viewer.