/* Amiga Keyboard reading on Atmel AVR * Copyright 2010, Adrien Destugues * Distributed under the terms of the MIT Licence */ #include #include #include #include #include "amiga_keyboard.h" // #include "keymap.h" //PIN configuration #define AK_CLK PD3 /* Also INT1 */ #define AK_PORT PIND #define AK_DATA PD4 volatile uint8_t kbd_data; volatile uint8_t char_waiting; uint8_t started; uint8_t bit_count; uint8_t shift; // Notify the keyboard we got the last char right static inline void acknowledge_char() { // We have to pull down the "DATA" line // Set it as an input DDRD |= (1<>bit_count); bit_count++; } if(bit_count >= 8) { // enough bits started = 0; bit_count = 0; /* if(kbd_data == 0xF0){ //release code release = 1; kbd_data = 0; return; } else if (kbd_data == 0x12) { //hanlde shift key if(release == 0){ shift = 1; } else { shift = 0; release = 0; } return; } else { //not a special character if(release){ //we were in release mode - exit release mode release = 0; //ignore that character } else { char_waiting = 1; } }*/ kbd_data = tmp_kdata; char_waiting=1; } } /* char ak_scancode_to_ascii(uint8_t data){ char to_ret = pgm_read_byte(&(keymap[data])); //grab character from array if(shift) to_ret -= 0x20; return to_ret; } */ uint8_t ak_wait_scancode(){ while(!char_waiting); return ak_read_scancode(); } uint8_t ak_read_scancode() { while ((AK_PORT & (1<