Index: kbd/common.mk
===================================================================
--- kbd/common.mk	(revision c7cc62934aef5cee3ea572add990c741428dc3dd)
+++ kbd/common.mk	(revision ea321070a53bb5ce2cc369fb23c25f35c9658c7c)
@@ -7,8 +7,19 @@
 LIBS=../../../libs
 
+CFLAGS=-DF_CPU=$(F_CPU) -DBAUD=$(BAUD) -mmcu=$(MCU) -Os
+
+# default target
+all: $(MCU).hex
+
 # Generic rules
 %.hex: %.bin
 	$(OBJCOPY) -j .text -j .data -O ihex $^ $@
 
+$(MCU):
+	mkdir -p $(MCU)
+
+flash: $(MCU).hex
+	$(AVRDUDE) -c usbasp -p $(MCU) -Uflash:w:$^
+
 clean:
 	rm *.bin *.o *.hex
Index: kbd/ps2toserial/code/Makefile
===================================================================
--- kbd/ps2toserial/code/Makefile	(revision c7cc62934aef5cee3ea572add990c741428dc3dd)
+++ kbd/ps2toserial/code/Makefile	(revision ea321070a53bb5ce2cc369fb23c25f35c9658c7c)
@@ -1,10 +1,13 @@
+# Board settings
+
+# K4KUSB
 MCU=attiny2313
+F_CPU=12000000
 
-all: $(MCU).hex
+# Generic settings
+BAUD=9600
+
 
 include ../../common.mk
-
-$(MCU):
-	mkdir -p $(MCU)
 
 $(MCU).bin: $(MCU)/keyboard.o $(MCU)/usart.o $(MCU)/main.o
@@ -12,9 +15,9 @@
 
 $(MCU)/main.o: main.c $(LIBS)/usart/usart.h $(LIBS)/ps2_keyboard/ps2_keyboard.h $(MCU)
-	$(CC) -c $< -Os -o $@ -mmcu=$(MCU) -Os
+	$(CC) $(CFLAGS) -c $< -o $@
 
 $(MCU)/usart.o: $(LIBS)/usart/usart.c $(LIBS)/usart/usart.h $(MCU)
-	$(CC) -c $< -o $@ -mmcu=$(MCU) -Os
+	$(CC) $(CFLAGS) -c $< -o $@
 
 $(MCU)/keyboard.o: $(LIBS)/ps2_keyboard/ps2_keyboard.c $(LIBS)/ps2_keyboard/ps2_keyboard.h $(LIBS)/ps2_keyboard/keymap.h $(MCU)
-	$(CC) -c $< -mmcu=$(MCU) -Os -o $@
+	$(CC) $(CFLAGS) -c $< -o $@
Index: kbd/xtk/code/main.c
===================================================================
--- kbd/xtk/code/main.c	(revision c7cc62934aef5cee3ea572add990c741428dc3dd)
+++ kbd/xtk/code/main.c	(revision ea321070a53bb5ce2cc369fb23c25f35c9658c7c)
@@ -1,4 +1,2 @@
-#define F_CPU 16000000UL
-
 #include <avr/io.h>
 #include <avr/pgmspace.h>
@@ -39,23 +37,36 @@
 	init_keyboard(); // PS/2 KBD handler
 
-	// PCW init - configure pins directions
-	PORTB = 0;
-	DDRB = 0; // PB2 and PB1 as inputs (floating)
 
-	//debug LED - output
-	DDRD |= (1<<PD6);
-
+#ifdef __AVR_ATtiny2313__
+#define PORTXT PORTD
+#define DDRXT DDRD
+#define PINXT PIND
+	static const int PCLK = (1<<PD0);
+	static const int PDAT = (1<<PD1);
+#else
+#define PORTXT PORTB
+#define DDRXT DDRB
+#define PINXT PINB
 	static const int PCLK = (1<<PB1);
 	static const int PDAT = (1<<PB2);
+#endif
+
+	static const int delay = 25;
+
+	// XT init - configure pins directions
+	PORTXT &= ~(PCLK | PDAT);
+	DDRXT &= ~(PCLK | PDAT); // both pins as inputs (floating)
+
+	DDRB |= (1<<PB2); // LED
 
 	uint8_t k;
 	while(1) {
-		while ((PINB & (PDAT|PCLK)) != (PDAT|PCLK))
+		PORTB ^= (1<<PB2); // LED
+
+		while ((PINXT & (PDAT|PCLK)) != (PDAT|PCLK))
 			; // Wait for PC to be ready to receive data
 
 		while(key == 0xFF)
 			; // Wait for data to send
-
-		PORTD ^= (1<<PD6);
 
 		k = key; // local copy so we can receive another code from PS/2
@@ -64,28 +75,28 @@
 
 		// SEND START BIT
-		DDRB &= ~PDAT; // DAT HI
-		_delay_us(50);
-		DDRB |= PCLK; // CLK LOW
-		_delay_us(50);
-		DDRB &= ~PCLK; // CLK HI
+		DDRXT &= ~PDAT; // DAT HI
+		_delay_us(delay);
+		DDRXT |= PCLK; // CLK LOW
+		_delay_us(delay);
+		DDRXT &= ~PCLK; // CLK HI
 
 		for(int i = 0; i < 8; i++)
 		{
 			if (k & 1)
-				DDRB &= ~PDAT;
+				DDRXT &= ~PDAT;
 			else
-				DDRB |= PDAT;
+				DDRXT |= PDAT;
 
-			_delay_us(50);
-			DDRB |= PCLK; // CLK LOW
-			_delay_us(50);
-			DDRB &= ~PCLK; // CLK HI
+			_delay_us(delay);
+			DDRXT |= PCLK; // CLK LOW
+			_delay_us(delay);
+			DDRXT &= ~PCLK; // CLK HI
 
 			k >>= 1;
 		}
 
-		DDRB &= ~PDAT; // DAT HI
+		DDRXT &= ~PDAT; // DAT HI
 
-		_delay_us(100);
+		_delay_us(delay * 2);
 	}
 
Index: libs/ps2_keyboard/ps2_keyboard.c
===================================================================
--- libs/ps2_keyboard/ps2_keyboard.c	(revision c7cc62934aef5cee3ea572add990c741428dc3dd)
+++ libs/ps2_keyboard/ps2_keyboard.c	(revision ea321070a53bb5ce2cc369fb23c25f35c9658c7c)
@@ -21,5 +21,12 @@
 #define PS2_PORT PIND
 #define PS2_CLK PD3 /* Also INT1 */
+
+#ifdef __AVR_ATtiny2313__
+// K4KUSB modified board
+#define PS2_DATA PD5
+#else
+// ENSSAT IR modified board
 #define PS2_DATA PD4
+#endif
 
 static volatile uint8_t kbd_data;
@@ -107,5 +114,5 @@
 
   //make PS2_CLK input pin
-  DDRD &= ~(1<<PS2_CLK);
+  DDRD &= ~((1<<PS2_CLK) | (1<<PS2_DATA));
   //turn on pullup resistor
   PS2_PORT |= (1<<PS2_CLK);
