# | |||||
# Makefile for Teensy | |||||
# | |||||
# Target file name (without extension). | # Target file name (without extension). | ||||
TARGET = ps2_usb_lufa | TARGET = ps2_usb_lufa | ||||
F_USB = $(F_CPU) | F_USB = $(F_CPU) | ||||
# Interrupt driven control endpoint task(+60) | # Interrupt driven control endpoint task(+60) | ||||
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | |||||
#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | |||||
# Boot Section Size in *bytes* | # Boot Section Size in *bytes* | ||||
# Atmel DFU loader 4096 | # Atmel DFU loader 4096 | ||||
# LUFA bootloader 4096 | # LUFA bootloader 4096 | ||||
# USBaspLoader 2048 | # USBaspLoader 2048 | ||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096 | |||||
OPT_DEFS += -DBOOTLOADER_SIZE=512 | |||||
# Build Options | # Build Options |
# Target file name (without extension). | |||||
TARGET = ps2_usb_jis | |||||
# Directory common source filess exist | |||||
TOP_DIR = ../.. | |||||
# Directory keyboard dependent files exist | |||||
TARGET_DIR = . | |||||
# MCU name, you MUST set this to match the board you are using | |||||
# type "make clean" after changing this, so all files will be rebuilt | |||||
#MCU = at90usb162 # Teensy 1.0 | |||||
MCU = atmega32u4 # Teensy 2.0 | |||||
#MCU = at90usb646 # Teensy++ 1.0 | |||||
#MCU = at90usb1286 # Teensy++ 2.0 | |||||
# Processor frequency. | |||||
# Normally the first thing your program should do is set the clock prescaler, | |||||
# so your program will run at the correct speed. You should also set this | |||||
# variable to same clock speed. The _delay_ms() macro uses this, and many | |||||
# examples use this variable to calculate timings. Do not add a "UL" here. | |||||
F_CPU = 16000000 | |||||
# Build Options | |||||
# *Comment out* to disable the options. | |||||
# | |||||
MOUSEKEY_ENABLE = yes # Mouse keys | |||||
EXTRAKEY_ENABLE = yes # Audio control and System control | |||||
NKRO_ENABLE = yes # USB Nkey Rollover | |||||
#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened) | |||||
#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin | |||||
PS2_USE_BUSYWAIT = yes # uses primitive reference code | |||||
# keyboard dependent files | |||||
SRC = keymap_jis.c \ | |||||
matrix.c \ | |||||
led.c | |||||
ifdef PS2_USE_USART | |||||
SRC += protocol/ps2_usart.c | |||||
OPT_DEFS += -DPS2_USE_USART | |||||
endif | |||||
ifdef PS2_USE_INT | |||||
SRC += protocol/ps2.c | |||||
OPT_DEFS += -DPS2_USE_INT | |||||
endif | |||||
ifdef PS2_USE_BUSYWAIT | |||||
SRC += protocol/ps2.c | |||||
OPT_DEFS += -DPS2_USE_BUSYWAIT | |||||
endif | |||||
#CONFIG_H = config_pjrc_usart.h | |||||
CONFIG_H = config.h | |||||
#---------------- Programming Options -------------------------- | |||||
PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex | |||||
# Search Path | |||||
VPATH += $(TARGET_DIR) | |||||
VPATH += $(TOP_DIR) | |||||
include $(TOP_DIR)/protocol/pjrc.mk | |||||
include $(TOP_DIR)/protocol.mk | |||||
include $(TOP_DIR)/common.mk | |||||
include $(TOP_DIR)/rules.mk |
# | |||||
# Makefile for TMK keyboard converter rev2 | |||||
# https://github.com/tmk/keyboard_converter#pcb-rev1 | |||||
# | |||||
# Target file name (without extension). | |||||
TARGET = ps2_usb_tmk_rev1 | |||||
# Directory common source filess exist | |||||
TOP_DIR = ../.. | |||||
# Directory keyboard dependent files exist | |||||
TARGET_DIR = . | |||||
# project specific files | |||||
SRC = keymap_common.c \ | |||||
matrix.c \ | |||||
led.c | |||||
ifdef KEYMAP | |||||
SRC := keymap_$(KEYMAP).c $(SRC) | |||||
else | |||||
SRC := keymap_plain.c $(SRC) | |||||
endif | |||||
CONFIG_H = config_tmk_rev1.h | |||||
# MCU name | |||||
MCU = atmega32u4 | |||||
# Processor frequency. | |||||
# This will define a symbol, F_CPU, in all source code files equal to the | |||||
# processor frequency in Hz. You can then use this symbol in your source code to | |||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done | |||||
# automatically to create a 32-bit value in your source code. | |||||
# | |||||
# This will be an integer division of F_USB below, as it is sourced by | |||||
# F_USB after it has run through any CPU prescalers. Note that this value | |||||
# does not *change* the processor frequency - it should merely be updated to | |||||
# reflect the processor speed set externally so that the code can use accurate | |||||
# software delays. | |||||
F_CPU = 16000000 | |||||
# | |||||
# LUFA specific | |||||
# | |||||
# Target architecture (see library "Board Types" documentation). | |||||
ARCH = AVR8 | |||||
# Input clock frequency. | |||||
# This will define a symbol, F_USB, in all source code files equal to the | |||||
# input clock frequency (before any prescaling is performed) in Hz. This value may | |||||
# differ from F_CPU if prescaling is used on the latter, and is required as the | |||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed | |||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | |||||
# at the end, this will be done automatically to create a 32-bit value in your | |||||
# source code. | |||||
# | |||||
# If no clock division is performed on the input clock inside the AVR (via the | |||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | |||||
F_USB = $(F_CPU) | |||||
# Boot Section Size in *bytes* | |||||
# Teensy halfKay 512 | |||||
# Teensy++ halfKay 1024 | |||||
# Atmel DFU loader 4096 | |||||
# LUFA bootloader 4096 | |||||
# USBaspLoader 2048 | |||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096 | |||||
# Build Options | |||||
# comment out to disable the options. | |||||
# | |||||
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) | |||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | |||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | |||||
CONSOLE_ENABLE = yes # Console for debug(+400) | |||||
COMMAND_ENABLE = yes # Commands for debug and configuration | |||||
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA | |||||
# PS/2 Options | |||||
# | |||||
PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened) | |||||
#PS2_USE_BUSYWAIT = yes # uses primitive reference code | |||||
# Search Path | |||||
VPATH += $(TARGET_DIR) | |||||
VPATH += $(TOP_DIR) | |||||
include $(TOP_DIR)/protocol.mk | |||||
include $(TOP_DIR)/protocol/lufa.mk | |||||
include $(TOP_DIR)/common.mk | |||||
include $(TOP_DIR)/rules.mk |
# | |||||
# Makefile for TMK keyboard converter rev2 | |||||
# https://github.com/tmk/keyboard_converter#pcb-rev2 | |||||
# | |||||
# Target file name (without extension). | |||||
TARGET = ps2_usb_tmk_rev2 | |||||
# Directory common source filess exist | |||||
TOP_DIR = ../.. | |||||
# Directory keyboard dependent files exist | |||||
TARGET_DIR = . | |||||
# project specific files | |||||
SRC = keymap_common.c \ | |||||
matrix.c \ | |||||
led.c | |||||
ifdef KEYMAP | |||||
SRC := keymap_$(KEYMAP).c $(SRC) | |||||
else | |||||
SRC := keymap_plain.c $(SRC) | |||||
endif | |||||
CONFIG_H = config_tmk_rev2.h | |||||
# MCU name | |||||
MCU = atmega32u2 | |||||
# Processor frequency. | |||||
# This will define a symbol, F_CPU, in all source code files equal to the | |||||
# processor frequency in Hz. You can then use this symbol in your source code to | |||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done | |||||
# automatically to create a 32-bit value in your source code. | |||||
# | |||||
# This will be an integer division of F_USB below, as it is sourced by | |||||
# F_USB after it has run through any CPU prescalers. Note that this value | |||||
# does not *change* the processor frequency - it should merely be updated to | |||||
# reflect the processor speed set externally so that the code can use accurate | |||||
# software delays. | |||||
F_CPU = 16000000 | |||||
# | |||||
# LUFA specific | |||||
# | |||||
# Target architecture (see library "Board Types" documentation). | |||||
ARCH = AVR8 | |||||
# Input clock frequency. | |||||
# This will define a symbol, F_USB, in all source code files equal to the | |||||
# input clock frequency (before any prescaling is performed) in Hz. This value may | |||||
# differ from F_CPU if prescaling is used on the latter, and is required as the | |||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed | |||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | |||||
# at the end, this will be done automatically to create a 32-bit value in your | |||||
# source code. | |||||
# | |||||
# If no clock division is performed on the input clock inside the AVR (via the | |||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | |||||
F_USB = $(F_CPU) | |||||
# Boot Section Size in *bytes* | |||||
# Teensy halfKay 512 | |||||
# Teensy++ halfKay 1024 | |||||
# Atmel DFU loader 4096 | |||||
# LUFA bootloader 4096 | |||||
# USBaspLoader 2048 | |||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096 | |||||
# Build Options | |||||
# comment out to disable the options. | |||||
# | |||||
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) | |||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | |||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | |||||
CONSOLE_ENABLE = yes # Console for debug(+400) | |||||
COMMAND_ENABLE = yes # Commands for debug and configuration | |||||
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA | |||||
# PS/2 Options | |||||
# | |||||
PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin | |||||
#PS2_USE_BUSYWAIT = yes # uses primitive reference code | |||||
# Search Path | |||||
VPATH += $(TARGET_DIR) | |||||
VPATH += $(TOP_DIR) | |||||
include $(TOP_DIR)/protocol.mk | |||||
include $(TOP_DIR)/protocol/lufa.mk | |||||
include $(TOP_DIR)/common.mk | |||||
include $(TOP_DIR)/rules.mk |
PS/2 to USB keyboard converter | PS/2 to USB keyboard converter | ||||
============================== | ============================== | ||||
This firmware converts PS/2 keyboard protocol to USB and supports only Scan Code Set 2. | |||||
PS/2 signal handling implementations | |||||
------------------------------------ | |||||
Following three methods are used to implement PS/2 signal handling. | |||||
### Simple and stupid busy-wait(ps2_busywait.c) | |||||
This is expected to implemented with portable C code for reference. | |||||
### Interrupt driven(ps2_interrupt.c) | |||||
Uses pin interrupt to detect falling edge of clock line. | |||||
### USART hardware module(ps2_usart.c) | |||||
Uses AVR USART engine to receive PS/2 signal. | |||||
To select method edit Makefile. | |||||
This firmware converts PS/2 keyboard protocol to USB.(It supports Scan Code Set 2.) | |||||
Connect Wires | Connect Wires | ||||
------------- | ------------- | ||||
In case of Teensy2.0(ATMega32U4): | In case of Teensy2.0(ATMega32U4): | ||||
1. Connect Vcc and GND. | |||||
2. Connect Clock and Data line. | |||||
- Busywait: Clock is on PD5 and Data on PD2. | |||||
- Interrupt: Clock is on PD1 and Data on PD2. | |||||
- USART: Clock is on PD5 and Data on PD2. | |||||
1. Connect **Vcc** and **GND**. | |||||
2. Connect **Clock** and **Data** line. | |||||
- **Interrupt**: **Clock** is on `PD1` and **Data** on `PD0`.(Recommended. Soarer's converter compatible) | |||||
- **Busywait**: **Clock** is on `PD1` and **Data** on `PD0`. | |||||
- **USART**: **Clock** is on `PD5` and **Data** on `PD2`. | |||||
3. Optionally you need pull-up register. 1K-10K Ohm is OK. | 3. Optionally you need pull-up register. 1K-10K Ohm is OK. | ||||
To change pin configuration edit config.h. | To change pin configuration edit config.h. | ||||
Build Firmware | Build Firmware | ||||
-------------- | -------------- | ||||
Just run `make`: | |||||
For **PJRC Teensy** just run `make`: | |||||
$ make clean | |||||
$ make | $ make | ||||
To select keymap: | To select keymap: | ||||
$ make clean | |||||
$ make KEYMAP=[plain|jis|spacefn|...] | $ make KEYMAP=[plain|jis|spacefn|...] | ||||
After that you will find HEX file `ps2_usb_lufa.hex` in current directory. | |||||
- For **TMK converter Rev.1** use `make -f Makefile.tmk_rev1` instead of `make` and HEX file is `ps2_usb_tmk_rev1.hex`. | |||||
- For **TMK converter Rev.2** use `make -f Makefile.tmk_rev2` instead of `make` and HEX file is `ps2_usb_tmk_rev2.hex`. | |||||
Keymap | Keymap | ||||
------ | ------ | ||||
Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create file named `keymap_<name>.c` and see keymap document(you can find in top README.md) and existent keymap files. | |||||
Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create file named `keymap_<name>.c` and see keymap document(you can find in README.md of top directory) and existent keymap files. | |||||
PS/2 signal handling implementations | |||||
------------------------------------ | |||||
Following three methods can be used to implement PS/2 signal handling. | |||||
### Simple and stupid busy-wait(ps2_busywait.c) | |||||
This is expected to implemented with portable C code for reference. | |||||
### Interrupt driven(ps2_interrupt.c) | |||||
Uses pin interrupt to detect falling edge of clock line. | |||||
### USART hardware module(ps2_usart.c) | |||||
Uses AVR USART engine to receive PS/2 signal. | |||||
To select method edit Makefile. | |||||
V-USB Support | V-USB Support |
/* | |||||
Copyright 2012 Jun Wako <[email protected]> | |||||
This program is free software: you can redistribute it and/or modify | |||||
it under the terms of the GNU General Public License as published by | |||||
the Free Software Foundation, either version 2 of the License, or | |||||
(at your option) any later version. | |||||
This program is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with this program. If not, see <http://www.gnu.org/licenses/>. | |||||
*/ | |||||
#ifndef CONFIG_H | |||||
#define CONFIG_H | |||||
#include <avr/interrupt.h> | |||||
#define VENDOR_ID 0xFEED | |||||
#define PRODUCT_ID 0x6512 | |||||
#define DEVICE_VER 0x0001 | |||||
#define MANUFACTURER t.m.k. | |||||
#define PRODUCT PS/2 keyboard converter | |||||
#define DESCRIPTION convert PS/2 keyboard to USB | |||||
/* matrix size */ | |||||
#define MATRIX_ROWS 32 // keycode bit: 3-0 | |||||
#define MATRIX_COLS 8 // keycode bit: 6-4 | |||||
/* key combination for command */ | |||||
#define IS_COMMAND() ( \ | |||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) || \ | |||||
keyboard_report->mods == (MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RSHIFT)) \ | |||||
) | |||||
//#define NO_SUSPEND_POWER_DOWN | |||||
/* | |||||
* PS/2 Busywait | |||||
*/ | |||||
#ifdef PS2_USE_BUSYWAIT | |||||
#define PS2_CLOCK_PORT PORTD | |||||
#define PS2_CLOCK_PIN PIND | |||||
#define PS2_CLOCK_DDR DDRD | |||||
#define PS2_CLOCK_BIT 5 | |||||
#define PS2_DATA_PORT PORTD | |||||
#define PS2_DATA_PIN PIND | |||||
#define PS2_DATA_DDR DDRD | |||||
#define PS2_DATA_BIT 2 | |||||
#endif | |||||
/* | |||||
* PS/2 USART | |||||
*/ | |||||
#ifdef PS2_USE_USART | |||||
#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) | |||||
/* XCK for clock line and RXD for data line */ | |||||
#define PS2_CLOCK_PORT PORTD | |||||
#define PS2_CLOCK_PIN PIND | |||||
#define PS2_CLOCK_DDR DDRD | |||||
#define PS2_CLOCK_BIT 5 | |||||
#define PS2_DATA_PORT PORTD | |||||
#define PS2_DATA_PIN PIND | |||||
#define PS2_DATA_DDR DDRD | |||||
#define PS2_DATA_BIT 2 | |||||
/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ | |||||
/* set DDR of CLOCK as input to be slave */ | |||||
#define PS2_USART_INIT() do { \ | |||||
PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \ | |||||
PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \ | |||||
UCSR1C = ((1 << UMSEL10) | \ | |||||
(3 << UPM10) | \ | |||||
(0 << USBS1) | \ | |||||
(3 << UCSZ10) | \ | |||||
(0 << UCPOL1)); \ | |||||
UCSR1A = 0; \ | |||||
UBRR1H = 0; \ | |||||
UBRR1L = 0; \ | |||||
} while (0) | |||||
#define PS2_USART_RX_INT_ON() do { \ | |||||
UCSR1B = ((1 << RXCIE1) | \ | |||||
(1 << RXEN1)); \ | |||||
} while (0) | |||||
#define PS2_USART_RX_POLL_ON() do { \ | |||||
UCSR1B = (1 << RXEN1); \ | |||||
} while (0) | |||||
#define PS2_USART_OFF() do { \ | |||||
UCSR1C = 0; \ | |||||
UCSR1B &= ~((1 << RXEN1) | \ | |||||
(1 << TXEN1)); \ | |||||
} while (0) | |||||
#define PS2_USART_RX_READY (UCSR1A & (1<<RXC1)) | |||||
#define PS2_USART_RX_DATA UDR1 | |||||
#define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1))) | |||||
#define PS2_USART_RX_VECT USART1_RX_vect | |||||
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) | |||||
/* XCK for clock line and RXD for data line */ | |||||
#define PS2_CLOCK_PORT PORTD | |||||
#define PS2_CLOCK_PIN PIND | |||||
#define PS2_CLOCK_DDR DDRD | |||||
#define PS2_CLOCK_BIT 4 | |||||
#define PS2_DATA_PORT PORTD | |||||
#define PS2_DATA_PIN PIND | |||||
#define PS2_DATA_DDR DDRD | |||||
#define PS2_DATA_BIT 0 | |||||
/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ | |||||
/* set DDR of CLOCK as input to be slave */ | |||||
#define PS2_USART_INIT() do { \ | |||||
PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \ | |||||
PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \ | |||||
UCSR0C = ((1 << UMSEL00) | \ | |||||
(3 << UPM00) | \ | |||||
(0 << USBS0) | \ | |||||
(3 << UCSZ00) | \ | |||||
(0 << UCPOL0)); \ | |||||
UCSR0A = 0; \ | |||||
UBRR0H = 0; \ | |||||
UBRR0L = 0; \ | |||||
} while (0) | |||||
#define PS2_USART_RX_INT_ON() do { \ | |||||
UCSR0B = ((1 << RXCIE0) | \ | |||||
(1 << RXEN0)); \ | |||||
} while (0) | |||||
#define PS2_USART_RX_POLL_ON() do { \ | |||||
UCSR0B = (1 << RXEN0); \ | |||||
} while (0) | |||||
#define PS2_USART_OFF() do { \ | |||||
UCSR0C = 0; \ | |||||
UCSR0B &= ~((1 << RXEN0) | \ | |||||
(1 << TXEN0)); \ | |||||
} while (0) | |||||
#define PS2_USART_RX_READY (UCSR0A & (1<<RXC0)) | |||||
#define PS2_USART_RX_DATA UDR0 | |||||
#define PS2_USART_ERROR (UCSR0A & ((1<<FE0) | (1<<DOR0) | (1<<UPE0))) | |||||
#define PS2_USART_RX_VECT USART_RX_vect | |||||
#endif | |||||
#endif | |||||
#endif |
/* | |||||
Copyright 2012 Jun Wako <[email protected]> | |||||
This program is free software: you can redistribute it and/or modify | |||||
it under the terms of the GNU General Public License as published by | |||||
the Free Software Foundation, either version 2 of the License, or | |||||
(at your option) any later version. | |||||
This program is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with this program. If not, see <http://www.gnu.org/licenses/>. | |||||
*/ | |||||
#ifndef CONFIG_H | |||||
#define CONFIG_H | |||||
#include <avr/interrupt.h> | |||||
#define VENDOR_ID 0xFEED | |||||
#define PRODUCT_ID 0x6512 | |||||
#define DEVICE_VER 0x0001 | |||||
#define MANUFACTURER t.m.k. | |||||
#define PRODUCT PS/2 keyboard converter | |||||
#define DESCRIPTION convert PS/2 keyboard to USB | |||||
/* matrix size */ | |||||
#define MATRIX_ROWS 32 // keycode bit: 3-0 | |||||
#define MATRIX_COLS 8 // keycode bit: 6-4 | |||||
/* key combination for command */ | |||||
#define IS_COMMAND() ( \ | |||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) || \ | |||||
keyboard_report->mods == (MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RSHIFT)) \ | |||||
) | |||||
//#define NO_SUSPEND_POWER_DOWN | |||||
/* | |||||
* PS/2 Busywait | |||||
*/ | |||||
#ifdef PS2_USE_BUSYWAIT | |||||
#define PS2_CLOCK_PORT PORTD | |||||
#define PS2_CLOCK_PIN PIND | |||||
#define PS2_CLOCK_DDR DDRD | |||||
#define PS2_CLOCK_BIT 1 | |||||
#define PS2_DATA_PORT PORTD | |||||
#define PS2_DATA_PIN PIND | |||||
#define PS2_DATA_DDR DDRD | |||||
#define PS2_DATA_BIT 0 | |||||
#endif | |||||
/* | |||||
* PS/2 Pin interrupt | |||||
*/ | |||||
#ifdef PS2_USE_INT | |||||
/* uses INT1 for clock line(ATMega32U4) */ | |||||
#define PS2_CLOCK_PORT PORTD | |||||
#define PS2_CLOCK_PIN PIND | |||||
#define PS2_CLOCK_DDR DDRD | |||||
#define PS2_CLOCK_BIT 1 | |||||
#define PS2_DATA_PORT PORTD | |||||
#define PS2_DATA_PIN PIND | |||||
#define PS2_DATA_DDR DDRD | |||||
#define PS2_DATA_BIT 0 | |||||
#define PS2_INT_INIT() do { \ | |||||
EICRA |= ((1<<ISC11) | \ | |||||
(0<<ISC10)); \ | |||||
} while (0) | |||||
#define PS2_INT_ON() do { \ | |||||
EIMSK |= (1<<INT1); \ | |||||
} while (0) | |||||
#define PS2_INT_OFF() do { \ | |||||
EIMSK &= ~(1<<INT1); \ | |||||
} while (0) | |||||
#define PS2_INT_VECT INT1_vect | |||||
#endif | |||||
#endif |