diff options
Diffstat (limited to 'ps2_vusb')
| -rw-r--r-- | ps2_vusb/Makefile | 78 | ||||
| -rw-r--r-- | ps2_vusb/README | 12 | ||||
| -rw-r--r-- | ps2_vusb/config.h | 118 | ||||
| -rw-r--r-- | ps2_vusb/keymap.c | 189 | ||||
| -rw-r--r-- | ps2_vusb/led.c | 16 | ||||
| -rw-r--r-- | ps2_vusb/main.c | 62 | ||||
| -rw-r--r-- | ps2_vusb/matrix.c | 444 | ||||
| -rw-r--r-- | ps2_vusb/ps2_usart.c | 325 | ||||
| -rw-r--r-- | ps2_vusb/sendchar_dummy.c | 8 | ||||
| -rw-r--r-- | ps2_vusb/sendchar_usart.c | 58 | ||||
| -rw-r--r-- | ps2_vusb/usbconfig.h | 378 |
11 files changed, 0 insertions, 1688 deletions
diff --git a/ps2_vusb/Makefile b/ps2_vusb/Makefile deleted file mode 100644 index 6901d1f5c..000000000 --- a/ps2_vusb/Makefile +++ /dev/null | |||
| @@ -1,78 +0,0 @@ | |||
| 1 | # Target file name (without extension). | ||
| 2 | TARGET = ps2_vusb | ||
| 3 | |||
| 4 | # Directory common source filess exist | ||
| 5 | COMMON_DIR = .. | ||
| 6 | |||
| 7 | # Directory keyboard dependent files exist | ||
| 8 | TARGET_DIR = . | ||
| 9 | |||
| 10 | # keyboard dependent files | ||
| 11 | TARGET_SRC = main.c \ | ||
| 12 | keymap.c \ | ||
| 13 | matrix.c \ | ||
| 14 | led.c \ | ||
| 15 | ps2_usart.c \ | ||
| 16 | sendchar_dummy.c | ||
| 17 | # sendchar_usart.c | ||
| 18 | |||
| 19 | OPT_DEFS = -DDEBUG_LEVEL=0 | ||
| 20 | |||
| 21 | |||
| 22 | # MCU name, you MUST set this to match the board you are using | ||
| 23 | # type "make clean" after changing this, so all files will be rebuilt | ||
| 24 | #MCU = at90usb162 # Teensy 1.0 | ||
| 25 | #MCU = atmega32u4 # Teensy 2.0 | ||
| 26 | #MCU = at90usb646 # Teensy++ 1.0 | ||
| 27 | #MCU = at90usb1286 # Teensy++ 2.0 | ||
| 28 | MCU = atmega168 | ||
| 29 | |||
| 30 | |||
| 31 | # Processor frequency. | ||
| 32 | # Normally the first thing your program should do is set the clock prescaler, | ||
| 33 | # so your program will run at the correct speed. You should also set this | ||
| 34 | # variable to same clock speed. The _delay_ms() macro uses this, and many | ||
| 35 | # examples use this variable to calculate timings. Do not add a "UL" here. | ||
| 36 | F_CPU = 20000000 | ||
| 37 | |||
| 38 | |||
| 39 | # Build Options | ||
| 40 | # comment out to disable the options. | ||
| 41 | # | ||
| 42 | MOUSEKEY_ENABLE = yes # Mouse keys | ||
| 43 | #USB_EXTRA_ENABLE = yes # Enhanced feature for Windows(Audio control and System control) | ||
| 44 | #USB_NKRO_ENABLE = yes # USB Nkey Rollover | ||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | #---------------- Programming Options (avrdude) ---------------- | ||
| 49 | # Type: avrdude -c ? to get a full listing. | ||
| 50 | AVRDUDE_PROGRAMMER = usbasp | ||
| 51 | AVRDUDE_PORT = | ||
| 52 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex | ||
| 53 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep | ||
| 54 | |||
| 55 | # Uncomment the following if you want avrdude's erase cycle counter. | ||
| 56 | # Note that this counter needs to be initialized first using -Yn, | ||
| 57 | # see avrdude manual. | ||
| 58 | #AVRDUDE_ERASE_COUNTER = -y | ||
| 59 | |||
| 60 | # Uncomment the following if you do /not/ wish a verification to be | ||
| 61 | # performed after programming the device. | ||
| 62 | #AVRDUDE_NO_VERIFY = -V | ||
| 63 | |||
| 64 | # Increase verbosity level. Please use this when submitting bug | ||
| 65 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> | ||
| 66 | # to submit bug reports. | ||
| 67 | #AVRDUDE_VERBOSE = -v -v | ||
| 68 | |||
| 69 | #AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) | ||
| 70 | AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER) | ||
| 71 | AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) | ||
| 72 | AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) | ||
| 73 | AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) | ||
| 74 | |||
| 75 | |||
| 76 | |||
| 77 | include $(COMMON_DIR)/Makefile.vusb | ||
| 78 | include $(COMMON_DIR)/Makefile.common | ||
diff --git a/ps2_vusb/README b/ps2_vusb/README deleted file mode 100644 index 7d4512a48..000000000 --- a/ps2_vusb/README +++ /dev/null | |||
| @@ -1,12 +0,0 @@ | |||
| 1 | PS/2 to USB keyboard converter with V-USB | ||
| 2 | ========================================= | ||
| 3 | 2011/02/07 | ||
| 4 | |||
| 5 | NOT COMPLETED | ||
| 6 | development was suspended. | ||
| 7 | |||
| 8 | TODO: | ||
| 9 | PS/2 library: losts data from keyboard occasionally, | ||
| 10 | should use interrupt thoroughly for communication. | ||
| 11 | |||
| 12 | Code cleaning: merge code changed here to other subprojects and common modules. | ||
diff --git a/ps2_vusb/config.h b/ps2_vusb/config.h deleted file mode 100644 index 9447dd936..000000000 --- a/ps2_vusb/config.h +++ /dev/null | |||
| @@ -1,118 +0,0 @@ | |||
| 1 | #ifndef CONFIG_H | ||
| 2 | #define CONFIG_H | ||
| 3 | |||
| 4 | |||
| 5 | #define VENDOR_ID 0xFEED | ||
| 6 | #define PRODUCT_ID 0x2233 | ||
| 7 | // TODO: share these strings with usbconfig.h | ||
| 8 | // Edit usbconfig.h to change these. | ||
| 9 | #define MANUFACTURER t.m.k. | ||
| 10 | #define PRODUCT PS/2 keyboard converter | ||
| 11 | #define DESCRIPTION convert PS/2 keyboard to USB | ||
| 12 | |||
| 13 | /* matrix size */ | ||
| 14 | #define MATRIX_ROWS 32 // keycode bit: 3-0 | ||
| 15 | #define MATRIX_COLS 8 // keycode bit: 6-4 | ||
| 16 | |||
| 17 | /* key combination for command */ | ||
| 18 | #define IS_COMMAND() ( \ | ||
| 19 | keyboard_report->mods == (BIT_LSHIFT | BIT_RSHIFT) || \ | ||
| 20 | keyboard_report->mods == (BIT_LCTRL | BIT_RSHIFT) \ | ||
| 21 | ) | ||
| 22 | |||
| 23 | |||
| 24 | /* USB NKey Rollover */ | ||
| 25 | #ifdef USB_NKRO_ENABLE | ||
| 26 | #endif | ||
| 27 | |||
| 28 | /* mouse keys */ | ||
| 29 | #ifdef MOUSEKEY_ENABLE | ||
| 30 | # define MOUSEKEY_DELAY_TIME 255 | ||
| 31 | #endif | ||
| 32 | |||
| 33 | |||
| 34 | /* PS/2 lines */ | ||
| 35 | #define PS2_CLOCK_PORT PORTD | ||
| 36 | #define PS2_CLOCK_PIN PIND | ||
| 37 | #define PS2_CLOCK_DDR DDRD | ||
| 38 | #define PS2_CLOCK_BIT 4 | ||
| 39 | #define PS2_DATA_PORT PORTD | ||
| 40 | #define PS2_DATA_PIN PIND | ||
| 41 | #define PS2_DATA_DDR DDRD | ||
| 42 | #define PS2_DATA_BIT 0 | ||
| 43 | |||
| 44 | |||
| 45 | // Synchronous USART is used to receive data from keyboard. | ||
| 46 | // Use RXD pin for PS/2 DATA line and XCK for PS/2 CLOCK. | ||
| 47 | // NOTE: This is recomended strongly if you use V-USB library. | ||
| 48 | #define PS2_USE_USART | ||
| 49 | |||
| 50 | // External or Pin Change Interrupt is used to receive data from keyboard. | ||
| 51 | // Use INT1 or PCINTxx for PS/2 CLOCK line. see below. | ||
| 52 | //#define PS2_USE_INT | ||
| 53 | |||
| 54 | |||
| 55 | #ifdef PS2_USE_USART | ||
| 56 | // synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge | ||
| 57 | // set DDR of CLOCK as input to be slave | ||
| 58 | #define PS2_USART_INIT() do { \ | ||
| 59 | PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \ | ||
| 60 | PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \ | ||
| 61 | UCSR0C = ((1 << UMSEL00) | \ | ||
| 62 | (3 << UPM00) | \ | ||
| 63 | (0 << USBS0) | \ | ||
| 64 | (3 << UCSZ00) | \ | ||
| 65 | (0 << UCPOL0)); \ | ||
| 66 | UCSR0A = 0; \ | ||
| 67 | UBRR0H = 0; \ | ||
| 68 | UBRR0L = 0; \ | ||
| 69 | } while (0) | ||
| 70 | #define PS2_USART_RX_INT_ON() do { \ | ||
| 71 | UCSR0B = ((1 << RXCIE0) | \ | ||
| 72 | (1 << RXEN0)); \ | ||
| 73 | } while (0) | ||
| 74 | #define PS2_USART_RX_POLL_ON() do { \ | ||
| 75 | UCSR0B = (1 << RXEN0); \ | ||
| 76 | } while (0) | ||
| 77 | #define PS2_USART_OFF() do { \ | ||
| 78 | UCSR0C = 0; \ | ||
| 79 | UCSR0B &= ~((1 << RXEN0) | \ | ||
| 80 | (1 << TXEN0)); \ | ||
| 81 | } while (0) | ||
| 82 | #define PS2_USART_RX_READY (UCSR0A & (1<<RXC0)) | ||
| 83 | #define PS2_USART_RX_DATA UDR0 | ||
| 84 | #define PS2_USART_ERROR (UCSR0A & ((1<<FE0) | (1<<DOR0) | (1<<UPE0))) | ||
| 85 | #define PS2_USART_RX_VECT USART_RX_vect | ||
| 86 | #endif | ||
| 87 | |||
| 88 | |||
| 89 | #ifdef PS2_USE_INT | ||
| 90 | /* INT1 | ||
| 91 | #define PS2_INT_INIT() do { \ | ||
| 92 | EICRA |= ((1<<ISC11) | \ | ||
| 93 | (0<<ISC10)); \ | ||
| 94 | } while (0) | ||
| 95 | #define PS2_INT_ON() do { \ | ||
| 96 | EIMSK |= (1<<INT1); \ | ||
| 97 | } while (0) | ||
| 98 | #define PS2_INT_OFF() do { \ | ||
| 99 | EIMSK &= ~(1<<INT1); \ | ||
| 100 | } while (0) | ||
| 101 | #define PS2_INT_VECT INT1_vect | ||
| 102 | */ | ||
| 103 | |||
| 104 | /* PCINT20 */ | ||
| 105 | #define PS2_INT_INIT() do { \ | ||
| 106 | PCICR |= (1<<PCIE2); \ | ||
| 107 | } while (0) | ||
| 108 | #define PS2_INT_ON() do { \ | ||
| 109 | PCMSK2 |= (1<<PCINT20); \ | ||
| 110 | } while (0) | ||
| 111 | #define PS2_INT_OFF() do { \ | ||
| 112 | PCMSK2 &= ~(1<<PCINT20); \ | ||
| 113 | PCICR &= ~(1<<PCIE2); \ | ||
| 114 | } while (0) | ||
| 115 | #define PS2_INT_VECT PCINT2_vect | ||
| 116 | #endif | ||
| 117 | |||
| 118 | #endif | ||
diff --git a/ps2_vusb/keymap.c b/ps2_vusb/keymap.c deleted file mode 100644 index d64e377bd..000000000 --- a/ps2_vusb/keymap.c +++ /dev/null | |||
| @@ -1,189 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Keymap for PS/2 keyboard | ||
| 3 | */ | ||
| 4 | #include <stdint.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include <avr/pgmspace.h> | ||
| 7 | #include "usb_keycodes.h" | ||
| 8 | #include "host.h" | ||
| 9 | #include "print.h" | ||
| 10 | #include "debug.h" | ||
| 11 | #include "util.h" | ||
| 12 | #include "keymap_skel.h" | ||
| 13 | |||
| 14 | |||
| 15 | #define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)])) | ||
| 16 | |||
| 17 | // Convert physical keyboard layout to matrix array. | ||
| 18 | // This is a macro to define keymap easily in keyboard layout form. | ||
| 19 | #define KEYMAP( \ | ||
| 20 | K76, K05,K06,K04,K0C, K03,K0B,K83,K0A, K01,K09,K78,K07, KFC,K7E,KFE, KB7,KBF,KDE, \ | ||
| 21 | K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ | ||
| 22 | K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \ | ||
| 23 | K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \ | ||
| 24 | K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \ | ||
| 25 | K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \ | ||
| 26 | ) { \ | ||
| 27 | { KB_NO, KB_##K01, KB_NO, KB_##K03, KB_##K04, KB_##K05, KB_##K06, KB_##K07 }, \ | ||
| 28 | { KB_NO, KB_##K09, KB_##K0A, KB_##K0B, KB_##K0C, KB_##K0D, KB_##K0E, KB_NO }, \ | ||
| 29 | { KB_NO, KB_##K11, KB_##K12, KB_NO, KB_##K14, KB_##K15, KB_##K16, KB_NO }, \ | ||
| 30 | { KB_NO, KB_NO, KB_##K1A, KB_##K1B, KB_##K1C, KB_##K1D, KB_##K1E, KB_NO }, \ | ||
| 31 | { KB_NO, KB_##K21, KB_##K22, KB_##K23, KB_##K24, KB_##K25, KB_##K26, KB_NO }, \ | ||
| 32 | { KB_NO, KB_##K29, KB_##K2A, KB_##K2B, KB_##K2C, KB_##K2D, KB_##K2E, KB_NO }, \ | ||
| 33 | { KB_NO, KB_##K31, KB_##K32, KB_##K33, KB_##K34, KB_##K35, KB_##K36, KB_NO }, \ | ||
| 34 | { KB_NO, KB_NO, KB_##K3A, KB_##K3B, KB_##K3C, KB_##K3D, KB_##K3E, KB_NO }, \ | ||
| 35 | { KB_NO, KB_##K41, KB_##K42, KB_##K43, KB_##K44, KB_##K45, KB_##K46, KB_NO }, \ | ||
| 36 | { KB_NO, KB_##K49, KB_##K4A, KB_##K4B, KB_##K4C, KB_##K4D, KB_##K4E, KB_NO }, \ | ||
| 37 | { KB_NO, KB_NO, KB_##K52, KB_NO, KB_##K54, KB_##K55, KB_NO, KB_NO }, \ | ||
| 38 | { KB_##K58, KB_##K59, KB_##K5A, KB_##K5B, KB_NO, KB_##K5D, KB_NO, KB_NO }, \ | ||
| 39 | { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_##K66, KB_NO }, \ | ||
| 40 | { KB_NO, KB_##K69, KB_NO, KB_##K6B, KB_##K6C, KB_NO, KB_NO, KB_NO }, \ | ||
| 41 | { KB_##K70, KB_##K71, KB_##K72, KB_##K73, KB_##K74, KB_##K75, KB_##K76, KB_##K77 }, \ | ||
| 42 | { KB_##K78, KB_##K79, KB_##K7A, KB_##K7B, KB_##K7C, KB_##K7D, KB_##K7E, KB_NO }, \ | ||
| 43 | { KB_NO, KB_NO, KB_NO, KB_##K83, KB_NO, KB_NO, KB_NO, KB_NO }, \ | ||
| 44 | { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO }, \ | ||
| 45 | { KB_NO, KB_##K91, KB_NO, KB_NO, KB_##K94, KB_NO, KB_NO, KB_NO }, \ | ||
| 46 | { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_##K9F }, \ | ||
| 47 | { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_##KA7 }, \ | ||
| 48 | { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_##KAF }, \ | ||
| 49 | { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_##KB7 }, \ | ||
| 50 | { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_##KBF }, \ | ||
| 51 | { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO }, \ | ||
| 52 | { KB_NO, KB_NO, KB_##KCA, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO }, \ | ||
| 53 | { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO }, \ | ||
| 54 | { KB_NO, KB_NO, KB_##KDA, KB_NO, KB_NO, KB_NO, KB_##KDE, KB_NO }, \ | ||
| 55 | { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO }, \ | ||
| 56 | { KB_NO, KB_##KE9, KB_NO, KB_##KEB, KB_##KEC, KB_NO, KB_NO, KB_NO }, \ | ||
| 57 | { KB_##KF0, KB_##KF1, KB_##KF2, KB_NO, KB_##KF4, KB_##KF5, KB_NO, KB_NO }, \ | ||
| 58 | { KB_NO, KB_NO, KB_##KFA, KB_NO, KB_##KFC, KB_##KFD, KB_##KFE, KB_NO }, \ | ||
| 59 | } | ||
| 60 | |||
| 61 | |||
| 62 | // Assign Fn key(0-7) to a layer to which switch with the Fn key pressed. | ||
| 63 | static const uint8_t PROGMEM fn_layer[] = { | ||
| 64 | 5, // Fn0 | ||
| 65 | 6, // Fn1 | ||
| 66 | 5, // Fn2 | ||
| 67 | 0, // Fn3 | ||
| 68 | 0, // Fn4 | ||
| 69 | 0, // Fn5 | ||
| 70 | 0, // Fn6 | ||
| 71 | 0 // Fn7 | ||
| 72 | }; | ||
| 73 | |||
| 74 | // Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer. | ||
| 75 | // See layer.c for details. | ||
| 76 | static const uint8_t PROGMEM fn_keycode[] = { | ||
| 77 | KB_SCLN, // Fn0 | ||
| 78 | KB_SLSH, // Fn1 | ||
| 79 | KB_A, // Fn2 | ||
| 80 | KB_NO, // Fn3 | ||
| 81 | KB_NO, // Fn4 | ||
| 82 | KB_NO, // Fn5 | ||
| 83 | KB_NO, // Fn6 | ||
| 84 | KB_NO // Fn7 | ||
| 85 | }; | ||
| 86 | |||
| 87 | static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 88 | /* keymap | ||
| 89 | * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------. | ||
| 90 | * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|Slp|Wak| | ||
| 91 | * `---' `---------------' `---------------' `---------------' `-----------' `-----------' | ||
| 92 | * ,-----------------------------------------------------------. ,-----------. ,---------------. | ||
| 93 | * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| /| *| -| | ||
| 94 | * |-----------------------------------------------------------| |-----------| |---------------| | ||
| 95 | * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| | | ||
| 96 | * |-----------------------------------------------------------| `-----------' |-----------| +| | ||
| 97 | * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| | | ||
| 98 | * |-----------------------------------------------------------| ,---. |---------------| | ||
| 99 | * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | | ||
| 100 | * |-----------------------------------------------------------| ,-----------. |-----------|Ent| | ||
| 101 | * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| | 0| .| | | ||
| 102 | * `-----------------------------------------------------------' `-----------' `---------------' | ||
| 103 | */ | ||
| 104 | /* 0: default */ | ||
| 105 | KEYMAP( | ||
| 106 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, PWR, F13, F14, | ||
| 107 | GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, | ||
| 108 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, | ||
| 109 | CAPS,FN2, S, D, F, G, H, J, K, L, FN0, QUOT, ENT, P4, P5, P6, PPLS, | ||
| 110 | LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN1, RSFT, UP, P1, P2, P3, | ||
| 111 | LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT | ||
| 112 | ), | ||
| 113 | /* 1: plain Qwerty without layer switching */ | ||
| 114 | KEYMAP( | ||
| 115 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, PWR, F13, F14, | ||
| 116 | GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, | ||
| 117 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, | ||
| 118 | CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, | ||
| 119 | LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, | ||
| 120 | LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT | ||
| 121 | ), | ||
| 122 | /* 2: Colemak http://colemak.com */ | ||
| 123 | KEYMAP( | ||
| 124 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, PWR, F13, F14, | ||
| 125 | GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, | ||
| 126 | TAB, Q, W, F, P, G, J, L, U, Y, SCLN,LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, | ||
| 127 | BSPC,A, R, S, T, D, H, N, E, I, O, QUOT, ENT, P4, P5, P6, PPLS, | ||
| 128 | LSFT,Z, X, C, V, B, K, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, | ||
| 129 | LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT | ||
| 130 | ), | ||
| 131 | /* 3: Dvorak http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard */ | ||
| 132 | KEYMAP( | ||
| 133 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, PWR, F13, F14, | ||
| 134 | GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, LBRC,RBRC,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, | ||
| 135 | TAB, QUOT,COMM,DOT, P, Y, F, G, C, R, L, SLSH,EQL, BSLS, DEL, END, PGDN, P7, P8, P9, | ||
| 136 | CAPS,A, O, E, U, I, D, H, T, N, S, MINS, ENT, P4, P5, P6, PPLS, | ||
| 137 | LSFT,SCLN,Q, J, K, X, B, M, W, V, Z, RSFT, UP, P1, P2, P3, | ||
| 138 | LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT | ||
| 139 | ), | ||
| 140 | /* 4: Workman http://viralintrospection.wordpress.com/2010/09/06/a-different-philosophy-in-designing-keyboard-layouts/ */ | ||
| 141 | KEYMAP( | ||
| 142 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, PWR, F13, F14, | ||
| 143 | GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, | ||
| 144 | TAB, Q, D, R, W, B, J, F, U, P, SCLN,LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, | ||
| 145 | BSPC,A, S, H, T, G, Y, N, E, O, I, QUOT, ENT, P4, P5, P6, PPLS, | ||
| 146 | LSFT,Z, X, M, C, V, K, L, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, | ||
| 147 | LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT | ||
| 148 | ), | ||
| 149 | /* 5: Mouse keys */ | ||
| 150 | KEYMAP( | ||
| 151 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, PWR, F13, F14, | ||
| 152 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, | ||
| 153 | TAB, WH_L,WH_D,MS_U,WH_U,WH_R,WH_L,WH_D,WH_U,WH_R,NO, NO, NO, BSLS, DEL, END, PGDN, P7, P8, P9, | ||
| 154 | CAPS,FN2, MS_L,MS_D,MS_R,NO, MS_L,MS_D,MS_U,MS_R,FN0, NO, ENT, P4, P5, P6, PPLS, | ||
| 155 | LSFT,VOLD,VOLU,MUTE,BTN2,BTN3,BTN2,BTN1,VOLD,VOLU,MUTE, RSFT, UP, P1, P2, P3, | ||
| 156 | LCTL,LGUI,LALT, BTN1, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT | ||
| 157 | ), | ||
| 158 | /* 6: Cursor keys */ | ||
| 159 | KEYMAP( | ||
| 160 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, PWR, F13, F14, | ||
| 161 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, | ||
| 162 | TAB, NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, NO, NO, NO, BSLS, DEL, END, PGDN, P7, P8, P9, | ||
| 163 | CAPS,NO, NO, NO, NO, NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, P4, P5, P6, PPLS, | ||
| 164 | LSFT,VOLD,VOLU,MUTE,NO, NO, HOME,PGDN,PGUP,END, FN1, RSFT, UP, P1, P2, P3, | ||
| 165 | LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT | ||
| 166 | ), | ||
| 167 | }; | ||
| 168 | |||
| 169 | |||
| 170 | uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) | ||
| 171 | { | ||
| 172 | return KEYCODE(layer, row, col); | ||
| 173 | } | ||
| 174 | |||
| 175 | uint8_t keymap_fn_layer(uint8_t fn_bits) | ||
| 176 | { | ||
| 177 | return pgm_read_byte(&fn_layer[biton(fn_bits)]); | ||
| 178 | } | ||
| 179 | |||
| 180 | uint8_t keymap_fn_keycode(uint8_t fn_bits) | ||
| 181 | { | ||
| 182 | return pgm_read_byte(&fn_keycode[(biton(fn_bits))]); | ||
| 183 | } | ||
| 184 | |||
| 185 | // define a condition to enter special function mode | ||
| 186 | bool keymap_is_special_mode(uint8_t fn_bits) | ||
| 187 | { | ||
| 188 | return host_get_mods() == (BIT_LSHIFT | BIT_RSHIFT) || host_get_mods() == (BIT_LCTRL | BIT_RSHIFT); | ||
| 189 | } | ||
diff --git a/ps2_vusb/led.c b/ps2_vusb/led.c deleted file mode 100644 index d69b1c675..000000000 --- a/ps2_vusb/led.c +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | #include "stdint.h" | ||
| 2 | #include "ps2.h" | ||
| 3 | #include "led.h" | ||
| 4 | |||
| 5 | |||
| 6 | void led_set(uint8_t usb_led) | ||
| 7 | { | ||
| 8 | uint8_t ps2_led = 0; | ||
| 9 | if (usb_led & (1<<USB_LED_SCROLL_LOCK)) | ||
| 10 | ps2_led |= (1<<PS2_LED_SCROLL_LOCK); | ||
| 11 | if (usb_led & (1<<USB_LED_NUM_LOCK)) | ||
| 12 | ps2_led |= (1<<PS2_LED_NUM_LOCK); | ||
| 13 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) | ||
| 14 | ps2_led |= (1<<PS2_LED_CAPS_LOCK); | ||
| 15 | ps2_host_set_led(ps2_led); | ||
| 16 | } | ||
diff --git a/ps2_vusb/main.c b/ps2_vusb/main.c deleted file mode 100644 index 1ffe5e6ec..000000000 --- a/ps2_vusb/main.c +++ /dev/null | |||
| @@ -1,62 +0,0 @@ | |||
| 1 | /* PS/2 to USB keyboard converter | ||
| 2 | * 2011/02/20 | ||
| 3 | * Copyright (c) 2011 tmk | ||
| 4 | */ | ||
| 5 | /* Name: main.c | ||
| 6 | * Project: hid-mouse, a very simple HID example | ||
| 7 | * Author: Christian Starkjohann | ||
| 8 | * Creation Date: 2008-04-07 | ||
| 9 | * Tabsize: 4 | ||
| 10 | * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH | ||
| 11 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) | ||
| 12 | * This Revision: $Id: main.c 790 2010-05-30 21:00:26Z cs $ | ||
| 13 | */ | ||
| 14 | #include <stdint.h> | ||
| 15 | #include <avr/wdt.h> | ||
| 16 | #include <avr/interrupt.h> | ||
| 17 | #include <util/delay.h> | ||
| 18 | #include "usbdrv.h" | ||
| 19 | #include "oddebug.h" | ||
| 20 | #include "host_vusb.h" | ||
| 21 | #include "keyboard.h" | ||
| 22 | |||
| 23 | |||
| 24 | #if 0 | ||
| 25 | #define DEBUGP_INIT() do { DDRC = 0xFF; } while (0) | ||
| 26 | #define DEBUGP(x) do { PORTC = x; } while (0) | ||
| 27 | #else | ||
| 28 | #define DEBUGP_INIT() | ||
| 29 | #define DEBUGP(x) | ||
| 30 | #endif | ||
| 31 | |||
| 32 | |||
| 33 | int main(void) | ||
| 34 | { | ||
| 35 | DEBUGP_INIT(); | ||
| 36 | wdt_enable(WDTO_1S); | ||
| 37 | odDebugInit(); | ||
| 38 | usbInit(); | ||
| 39 | |||
| 40 | /* enforce re-enumeration, do this while interrupts are disabled! */ | ||
| 41 | usbDeviceDisconnect(); | ||
| 42 | uint8_t i = 0; | ||
| 43 | /* fake USB disconnect for > 250 ms */ | ||
| 44 | while(--i){ | ||
| 45 | wdt_reset(); | ||
| 46 | _delay_ms(1); | ||
| 47 | } | ||
| 48 | usbDeviceConnect(); | ||
| 49 | sei(); | ||
| 50 | |||
| 51 | keyboard_init(); | ||
| 52 | |||
| 53 | while (1) { | ||
| 54 | DEBUGP(0x1); | ||
| 55 | wdt_reset(); | ||
| 56 | usbPoll(); | ||
| 57 | DEBUGP(0x2); | ||
| 58 | keyboard_proc(); | ||
| 59 | DEBUGP(0x3); | ||
| 60 | host_vusb_keyboard_send(); | ||
| 61 | } | ||
| 62 | } | ||
diff --git a/ps2_vusb/matrix.c b/ps2_vusb/matrix.c deleted file mode 100644 index ca3e0ef3e..000000000 --- a/ps2_vusb/matrix.c +++ /dev/null | |||
| @@ -1,444 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * scan matrix | ||
| 3 | */ | ||
| 4 | #include <stdint.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include <avr/io.h> | ||
| 7 | #include <util/delay.h> | ||
| 8 | #include "print.h" | ||
| 9 | #include "util.h" | ||
| 10 | #include "debug.h" | ||
| 11 | #include "ps2.h" | ||
| 12 | #include "matrix_skel.h" | ||
| 13 | |||
| 14 | |||
| 15 | #if (MATRIX_COLS > 16) | ||
| 16 | # error "MATRIX_COLS must not exceed 16" | ||
| 17 | #endif | ||
| 18 | #if (MATRIX_ROWS > 255) | ||
| 19 | # error "MATRIX_ROWS must not exceed 255" | ||
| 20 | #endif | ||
| 21 | |||
| 22 | |||
| 23 | /* | ||
| 24 | * Matrix usage: | ||
| 25 | * "PS/2 Scan Codes Set 2" is assigned to 256(32x8)cells matrix. | ||
| 26 | * Hmm, It is very sparse and not efficient :( | ||
| 27 | * | ||
| 28 | * 8bit | ||
| 29 | * --------- | ||
| 30 | * 0| | | ||
| 31 | * :| XX | 00-7F for normal codes(without E0-prefix) | ||
| 32 | * f|_________| | ||
| 33 | * 10| | | ||
| 34 | * :| E0 XX | 80-FF for E0-prefix codes(use (XX|0x80) as code) | ||
| 35 | * 1f| | | ||
| 36 | * --------- | ||
| 37 | * exceptions: | ||
| 38 | * 83: F8[0x83](normal codes but > 0x7F) | ||
| 39 | * FC: PrintScreen[E0 7C or 84] | ||
| 40 | * FE: Puause | ||
| 41 | */ | ||
| 42 | #define F8 (0x83) | ||
| 43 | #define PRINT_SCREEN (0xFC) | ||
| 44 | #define PAUSE (0xFE) | ||
| 45 | #define ROW(code) (code>>3) | ||
| 46 | #define COL(code) (code&0x07) | ||
| 47 | |||
| 48 | static bool is_modified = false; | ||
| 49 | |||
| 50 | // matrix state buffer(1:on, 0:off) | ||
| 51 | #if (MATRIX_COLS <= 8) | ||
| 52 | static uint8_t matrix[MATRIX_ROWS]; | ||
| 53 | #else | ||
| 54 | static uint16_t matrix[MATRIX_ROWS]; | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #ifdef MATRIX_HAS_GHOST | ||
| 58 | static bool matrix_has_ghost_in_row(uint8_t row); | ||
| 59 | #endif | ||
| 60 | static void matrix_make(uint8_t code); | ||
| 61 | static void matrix_break(uint8_t code); | ||
| 62 | |||
| 63 | |||
| 64 | inline | ||
| 65 | uint8_t matrix_rows(void) | ||
| 66 | { | ||
| 67 | return MATRIX_ROWS; | ||
| 68 | } | ||
| 69 | |||
| 70 | inline | ||
| 71 | uint8_t matrix_cols(void) | ||
| 72 | { | ||
| 73 | return MATRIX_COLS; | ||
| 74 | } | ||
| 75 | |||
| 76 | void matrix_init(void) | ||
| 77 | { | ||
| 78 | ps2_host_init(); | ||
| 79 | |||
| 80 | // initialize matrix state: all keys off | ||
| 81 | for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; | ||
| 82 | |||
| 83 | return; | ||
| 84 | } | ||
| 85 | |||
| 86 | /* | ||
| 87 | * PS/2 Scan Code Set 2: Exceptional Handling | ||
| 88 | * | ||
| 89 | * There are several keys to be handled exceptionally. | ||
| 90 | * The scan code for these keys are varied or prefix/postfix'd | ||
| 91 | * depending on modifier key state. | ||
| 92 | * | ||
| 93 | * References: | ||
| 94 | * http://www.microsoft.com/whdc/archive/scancode.mspx | ||
| 95 | * http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc | ||
| 96 | * | ||
| 97 | * | ||
| 98 | * Insert, Delete, Home, End, PageUp, PageDown, Up, Down, Right, Left: | ||
| 99 | * Num Lock: off | ||
| 100 | * modifiers | make | break | ||
| 101 | * ----------+---------------------------+---------------------- | ||
| 102 | * Ohter | <make> | <break> | ||
| 103 | * LShift | E0 F0 12 <make> | <break> E0 12 | ||
| 104 | * RShift | E0 F0 59 <make> | <break> E0 59 | ||
| 105 | * L+RShift | E0 F0 12 E0 F0 59 <make> | <break> E0 59 E0 12 | ||
| 106 | * | ||
| 107 | * Num Lock: on | ||
| 108 | * modifiers | make | break | ||
| 109 | * ----------+---------------------------+---------------------- | ||
| 110 | * Other | E0 12 <make> | <break> E0 F0 12 | ||
| 111 | * Shift'd | <make> | <break> | ||
| 112 | * | ||
| 113 | * Handling: ignore these prefix/postfix codes | ||
| 114 | * | ||
| 115 | * | ||
| 116 | * Keypad-/: | ||
| 117 | * modifiers | make | break | ||
| 118 | * ----------+---------------------------+---------------------- | ||
| 119 | * Ohter | <make> | <break> | ||
| 120 | * LShift | E0 F0 12 <make> | <break> E0 12 | ||
| 121 | * RShift | E0 F0 59 <make> | <break> E0 59 | ||
| 122 | * L+RShift | E0 F0 12 E0 F0 59 <make> | <break> E0 59 E0 12 | ||
| 123 | * | ||
| 124 | * Handling: ignore these prefix/postfix codes | ||
| 125 | * | ||
| 126 | * | ||
| 127 | * PrintScreen: | ||
| 128 | * With hoding down modifiers, the scan code is sent as following: | ||
| 129 | * | ||
| 130 | * modifiers | make | break | ||
| 131 | * ----------+--------------+----------------------------------- | ||
| 132 | * Other | E0 12 E0 7C | E0 F0 7C E0 F0 12 | ||
| 133 | * Shift'd | E0 7C | E0 F0 7C | ||
| 134 | * Control'd | E0 7C | E0 F0 7C | ||
| 135 | * Alt'd | 84 | F0 84 | ||
| 136 | * | ||
| 137 | * Handling: ignore prefix/postfix codes and treat both scan code | ||
| 138 | * E0 7C and 84 as PrintScreen. | ||
| 139 | * | ||
| 140 | * Pause: | ||
| 141 | * With hoding down modifiers, the scan code is sent as following: | ||
| 142 | * | ||
| 143 | * modifiers | make(no break code) | ||
| 144 | * ----------+-------------------------------------------------- | ||
| 145 | * no mods | E1 14 77 E1 F0 14 F0 77 | ||
| 146 | * Control'd | E0 7E E0 F0 7E | ||
| 147 | * | ||
| 148 | * Handling: treat these two code sequence as Pause | ||
| 149 | * | ||
| 150 | */ | ||
| 151 | uint8_t matrix_scan(void) | ||
| 152 | { | ||
| 153 | |||
| 154 | static enum { | ||
| 155 | INIT, | ||
| 156 | F0, | ||
| 157 | E0, | ||
| 158 | E0_F0, | ||
| 159 | // states for Pause/Break | ||
| 160 | E1, | ||
| 161 | E1_14, | ||
| 162 | E1_14_77, | ||
| 163 | E1_14_77_E1, | ||
| 164 | E1_14_77_E1_F0, | ||
| 165 | E1_14_77_E1_F0_14, | ||
| 166 | E1_14_77_E1_F0_14_F0, | ||
| 167 | } state = INIT; | ||
| 168 | |||
| 169 | |||
| 170 | is_modified = false; | ||
| 171 | |||
| 172 | // Pause/Break off(PS/2 has no break for this key) | ||
| 173 | if (matrix_is_on(ROW(PAUSE), COL(PAUSE))) { | ||
| 174 | matrix_break(PAUSE); | ||
| 175 | } | ||
| 176 | |||
| 177 | uint8_t code; | ||
| 178 | while ((code = ps2_host_recv())) { | ||
| 179 | switch (state) { | ||
| 180 | case INIT: | ||
| 181 | switch (code) { | ||
| 182 | case 0xE0: // 2byte make | ||
| 183 | state = E0; | ||
| 184 | break; | ||
| 185 | case 0xF0: // break code | ||
| 186 | state = F0; | ||
| 187 | break; | ||
| 188 | case 0xE1: // Pause/Break | ||
| 189 | state = E1; | ||
| 190 | break; | ||
| 191 | case 0x83: // F8 | ||
| 192 | matrix_make(F8); | ||
| 193 | state = INIT; | ||
| 194 | break; | ||
| 195 | case 0x84: // PrintScreen | ||
| 196 | matrix_make(PRINT_SCREEN); | ||
| 197 | state = INIT; | ||
| 198 | break; | ||
| 199 | default: // normal key make | ||
| 200 | if (code < 0x80) { | ||
| 201 | matrix_make(code); | ||
| 202 | } else { | ||
| 203 | debug("unexpected scan code at INIT: "); debug_hex(code); debug("\n"); | ||
| 204 | } | ||
| 205 | state = INIT; | ||
| 206 | } | ||
| 207 | break; | ||
| 208 | case E0: | ||
| 209 | switch (code) { | ||
| 210 | case 0x12: // postfix/postfix code for exceptional keys | ||
| 211 | case 0x59: // postfix/postfix code for exceptional keys | ||
| 212 | // ignore | ||
| 213 | state = INIT; | ||
| 214 | break; | ||
| 215 | case 0x7E: // former part of Control-Pause[E0 7E E0 F0 7E] | ||
| 216 | matrix_make(PAUSE); | ||
| 217 | state = INIT; | ||
| 218 | break; | ||
| 219 | case 0xF0: // E0 break | ||
| 220 | state = E0_F0; | ||
| 221 | break; | ||
| 222 | default: // E0 make | ||
| 223 | if (code < 0x80) { | ||
| 224 | matrix_make(code|0x80); | ||
| 225 | } else { | ||
| 226 | debug("unexpected scan code at E0: "); debug_hex(code); debug("\n"); | ||
| 227 | } | ||
| 228 | state = INIT; | ||
| 229 | } | ||
| 230 | break; | ||
| 231 | case F0: | ||
| 232 | switch (code) { | ||
| 233 | case 0x83: | ||
| 234 | matrix_break(F8); | ||
| 235 | state = INIT; | ||
| 236 | break; | ||
| 237 | case 0x84: | ||
| 238 | matrix_break(PRINT_SCREEN); | ||
| 239 | state = INIT; | ||
| 240 | break; | ||
| 241 | default: | ||
| 242 | if (code < 0x80) { | ||
| 243 | matrix_break(code); | ||
| 244 | } else { | ||
| 245 | debug("unexpected scan code at F0: "); debug_hex(code); debug("\n"); | ||
| 246 | } | ||
| 247 | state = INIT; | ||
| 248 | } | ||
| 249 | break; | ||
| 250 | case E0_F0: // E0 break | ||
| 251 | switch (code) { | ||
| 252 | case 0x12: // postfix/postfix code for exceptional keys | ||
| 253 | case 0x59: // postfix/postfix code for exceptional keys | ||
| 254 | case 0x7E: // latter part of Control-Pause[E0 7E E0 F0 7E] | ||
| 255 | // ignore | ||
| 256 | state = INIT; | ||
| 257 | break; | ||
| 258 | default: | ||
| 259 | if (code < 0x80) { | ||
| 260 | matrix_break(code|0x80); | ||
| 261 | } else { | ||
| 262 | debug("unexpected scan code at E0_F0: "); debug_hex(code); debug("\n"); | ||
| 263 | } | ||
| 264 | state = INIT; | ||
| 265 | } | ||
| 266 | break; | ||
| 267 | /* Pause */ | ||
| 268 | case E1: | ||
| 269 | switch (code) { | ||
| 270 | case 0x14: | ||
| 271 | state = E1_14; | ||
| 272 | break; | ||
| 273 | default: | ||
| 274 | state = INIT; | ||
| 275 | } | ||
| 276 | break; | ||
| 277 | case E1_14: | ||
| 278 | switch (code) { | ||
| 279 | case 0x77: | ||
| 280 | state = E1_14_77; | ||
| 281 | break; | ||
| 282 | default: | ||
| 283 | state = INIT; | ||
| 284 | } | ||
| 285 | break; | ||
| 286 | case E1_14_77: | ||
| 287 | switch (code) { | ||
| 288 | case 0xE1: | ||
| 289 | state = E1_14_77_E1; | ||
| 290 | break; | ||
| 291 | default: | ||
| 292 | state = INIT; | ||
| 293 | } | ||
| 294 | break; | ||
| 295 | case E1_14_77_E1: | ||
| 296 | switch (code) { | ||
| 297 | case 0xF0: | ||
| 298 | state = E1_14_77_E1_F0; | ||
| 299 | break; | ||
| 300 | default: | ||
| 301 | state = INIT; | ||
| 302 | } | ||
| 303 | break; | ||
| 304 | case E1_14_77_E1_F0: | ||
| 305 | switch (code) { | ||
| 306 | case 0x14: | ||
| 307 | state = E1_14_77_E1_F0_14; | ||
| 308 | break; | ||
| 309 | default: | ||
| 310 | state = INIT; | ||
| 311 | } | ||
| 312 | break; | ||
| 313 | case E1_14_77_E1_F0_14: | ||
| 314 | switch (code) { | ||
| 315 | case 0xF0: | ||
| 316 | state = E1_14_77_E1_F0_14_F0; | ||
| 317 | break; | ||
| 318 | default: | ||
| 319 | state = INIT; | ||
| 320 | } | ||
| 321 | break; | ||
| 322 | case E1_14_77_E1_F0_14_F0: | ||
| 323 | switch (code) { | ||
| 324 | case 0x77: | ||
| 325 | matrix_make(PAUSE); | ||
| 326 | state = INIT; | ||
| 327 | break; | ||
| 328 | default: | ||
| 329 | state = INIT; | ||
| 330 | } | ||
| 331 | break; | ||
| 332 | default: | ||
| 333 | state = INIT; | ||
| 334 | } | ||
| 335 | } | ||
| 336 | return 1; | ||
| 337 | } | ||
| 338 | |||
| 339 | bool matrix_is_modified(void) | ||
| 340 | { | ||
| 341 | return is_modified; | ||
| 342 | } | ||
| 343 | |||
| 344 | inline | ||
| 345 | bool matrix_has_ghost(void) | ||
| 346 | { | ||
| 347 | #ifdef MATRIX_HAS_GHOST | ||
| 348 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 349 | if (matrix_has_ghost_in_row(i)) | ||
| 350 | return true; | ||
| 351 | } | ||
| 352 | #endif | ||
| 353 | return false; | ||
| 354 | } | ||
| 355 | |||
| 356 | inline | ||
| 357 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 358 | { | ||
| 359 | return (matrix[row] & (1<<col)); | ||
| 360 | } | ||
| 361 | |||
| 362 | inline | ||
| 363 | #if (MATRIX_COLS <= 8) | ||
| 364 | uint8_t matrix_get_row(uint8_t row) | ||
| 365 | #else | ||
| 366 | uint16_t matrix_get_row(uint8_t row) | ||
| 367 | #endif | ||
| 368 | { | ||
| 369 | return matrix[row]; | ||
| 370 | } | ||
| 371 | |||
| 372 | void matrix_print(void) | ||
| 373 | { | ||
| 374 | #if (MATRIX_COLS <= 8) | ||
| 375 | print("\nr/c 01234567\n"); | ||
| 376 | #else | ||
| 377 | print("\nr/c 0123456789ABCDEF\n"); | ||
| 378 | #endif | ||
| 379 | for (uint8_t row = 0; row < matrix_rows(); row++) { | ||
| 380 | phex(row); print(": "); | ||
| 381 | #if (MATRIX_COLS <= 8) | ||
| 382 | pbin_reverse(matrix_get_row(row)); | ||
| 383 | #else | ||
| 384 | pbin_reverse16(matrix_get_row(row)); | ||
| 385 | #endif | ||
| 386 | #ifdef MATRIX_HAS_GHOST | ||
| 387 | if (matrix_has_ghost_in_row(row)) { | ||
| 388 | print(" <ghost"); | ||
| 389 | } | ||
| 390 | #endif | ||
| 391 | print("\n"); | ||
| 392 | } | ||
| 393 | } | ||
| 394 | |||
| 395 | uint8_t matrix_key_count(void) | ||
| 396 | { | ||
| 397 | uint8_t count = 0; | ||
| 398 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 399 | #if (MATRIX_COLS <= 8) | ||
| 400 | count += bitpop(matrix[i]); | ||
| 401 | #else | ||
| 402 | count += bitpop16(matrix[i]); | ||
| 403 | #endif | ||
| 404 | } | ||
| 405 | return count; | ||
| 406 | } | ||
| 407 | |||
| 408 | #ifdef MATRIX_HAS_GHOST | ||
| 409 | inline | ||
| 410 | static bool matrix_has_ghost_in_row(uint8_t row) | ||
| 411 | { | ||
| 412 | // no ghost exists in case less than 2 keys on | ||
| 413 | if (((matrix[row] - 1) & matrix[row]) == 0) | ||
| 414 | return false; | ||
| 415 | |||
| 416 | // ghost exists in case same state as other row | ||
| 417 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 418 | if (i != row && (matrix[i] & matrix[row]) == matrix[row]) | ||
| 419 | return true; | ||
| 420 | } | ||
| 421 | return false; | ||
| 422 | } | ||
| 423 | #endif | ||
| 424 | |||
| 425 | |||
| 426 | inline | ||
| 427 | static void matrix_make(uint8_t code) | ||
| 428 | { | ||
| 429 | if (!matrix_is_on(ROW(code), COL(code))) { | ||
| 430 | matrix[ROW(code)] |= 1<<COL(code); | ||
| 431 | is_modified = true; | ||
| 432 | //print("matrix_make: "); phex(code); print("\n"); | ||
| 433 | } | ||
| 434 | } | ||
| 435 | |||
| 436 | inline | ||
| 437 | static void matrix_break(uint8_t code) | ||
| 438 | { | ||
| 439 | if (matrix_is_on(ROW(code), COL(code))) { | ||
| 440 | matrix[ROW(code)] &= ~(1<<COL(code)); | ||
| 441 | is_modified = true; | ||
| 442 | //print("matrix_break: "); phex(code); print("\n"); | ||
| 443 | } | ||
| 444 | } | ||
diff --git a/ps2_vusb/ps2_usart.c b/ps2_vusb/ps2_usart.c deleted file mode 100644 index e45b94c93..000000000 --- a/ps2_vusb/ps2_usart.c +++ /dev/null | |||
| @@ -1,325 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright (c) 2010,2011 Jun WAKO <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This software is licensed with a Modified BSD License. | ||
| 5 | All of this is supposed to be Free Software, Open Source, DFSG-free, | ||
| 6 | GPL-compatible, and OK to use in both free and proprietary applications. | ||
| 7 | Additions and corrections to this file are welcome. | ||
| 8 | |||
| 9 | |||
| 10 | Redistribution and use in source and binary forms, with or without | ||
| 11 | modification, are permitted provided that the following conditions are met: | ||
| 12 | |||
| 13 | * Redistributions of source code must retain the above copyright | ||
| 14 | notice, this list of conditions and the following disclaimer. | ||
| 15 | |||
| 16 | * Redistributions in binary form must reproduce the above copyright | ||
| 17 | notice, this list of conditions and the following disclaimer in | ||
| 18 | the documentation and/or other materials provided with the | ||
| 19 | distribution. | ||
| 20 | |||
| 21 | * Neither the name of the copyright holders nor the names of | ||
| 22 | contributors may be used to endorse or promote products derived | ||
| 23 | from this software without specific prior written permission. | ||
| 24 | |||
| 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 28 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
| 29 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| 30 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 31 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| 32 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| 33 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 34 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 35 | POSSIBILITY OF SUCH DAMAGE. | ||
| 36 | */ | ||
| 37 | /* | ||
| 38 | Primitive PS/2 Library for AVR | ||
| 39 | ============================== | ||
| 40 | Host side is only supported now. | ||
| 41 | Synchronous USART is used to receive data by hardware process | ||
| 42 | rather than interrupt. During V-USB interrupt runs, CLOCK interrupt | ||
| 43 | cannot interpose. In the result it is prone to lost CLOCK edge. | ||
| 44 | |||
| 45 | |||
| 46 | I/O control | ||
| 47 | ----------- | ||
| 48 | High state is asserted by internal pull-up. | ||
| 49 | If you have a signaling problem, you may need to have | ||
| 50 | external pull-up resisters on CLOCK and DATA line. | ||
| 51 | |||
| 52 | |||
| 53 | PS/2 References | ||
| 54 | --------------- | ||
| 55 | http://www.computer-engineering.org/ps2protocol/ | ||
| 56 | http://www.mcamafia.de/pdf/ibm_hitrc07.pdf | ||
| 57 | */ | ||
| 58 | #include <stdbool.h> | ||
| 59 | #include <avr/io.h> | ||
| 60 | #include <avr/interrupt.h> | ||
| 61 | #include <util/delay.h> | ||
| 62 | #include "ps2.h" | ||
| 63 | #include "debug.h" | ||
| 64 | |||
| 65 | |||
| 66 | #if 0 | ||
| 67 | #define DEBUGP_INIT() do { DDRC = 0xFF; } while (0) | ||
| 68 | #define DEBUGP(x) do { PORTC = x; } while (0) | ||
| 69 | #else | ||
| 70 | #define DEBUGP_INIT() | ||
| 71 | #define DEBUGP(x) | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #define WAIT(stat, us, err) do { \ | ||
| 75 | if (!wait_##stat(us)) { \ | ||
| 76 | ps2_error = err; \ | ||
| 77 | goto ERROR; \ | ||
| 78 | } \ | ||
| 79 | } while (0) | ||
| 80 | |||
| 81 | |||
| 82 | uint8_t ps2_error = PS2_ERR_NONE; | ||
| 83 | |||
| 84 | |||
| 85 | static inline void clock_lo(void); | ||
| 86 | static inline void clock_hi(void); | ||
| 87 | static inline bool clock_in(void); | ||
| 88 | static inline void data_lo(void); | ||
| 89 | static inline void data_hi(void); | ||
| 90 | static inline bool data_in(void); | ||
| 91 | static inline uint16_t wait_clock_lo(uint16_t us); | ||
| 92 | static inline uint16_t wait_clock_hi(uint16_t us); | ||
| 93 | static inline uint16_t wait_data_lo(uint16_t us); | ||
| 94 | static inline uint16_t wait_data_hi(uint16_t us); | ||
| 95 | static inline void idle(void); | ||
| 96 | static inline void inhibit(void); | ||
| 97 | #if defined PS2_USE_INT || defined PS2_USE_USART | ||
| 98 | static inline uint8_t pbuf_dequeue(void); | ||
| 99 | static inline void pbuf_enqueue(uint8_t data); | ||
| 100 | #endif | ||
| 101 | |||
| 102 | |||
| 103 | void ps2_host_init(void) | ||
| 104 | { | ||
| 105 | DEBUGP_INIT(); | ||
| 106 | DEBUGP(0x1); | ||
| 107 | idle(); | ||
| 108 | PS2_USART_INIT(); | ||
| 109 | PS2_USART_RX_INT_ON(); | ||
| 110 | } | ||
| 111 | |||
| 112 | uint8_t ps2_host_send(uint8_t data) | ||
| 113 | { | ||
| 114 | uint8_t res = 0; | ||
| 115 | bool parity = true; | ||
| 116 | ps2_error = PS2_ERR_NONE; | ||
| 117 | |||
| 118 | DEBUGP(0x6); | ||
| 119 | PS2_USART_OFF(); | ||
| 120 | |||
| 121 | /* terminate a transmission if we have */ | ||
| 122 | inhibit(); | ||
| 123 | _delay_us(100); | ||
| 124 | |||
| 125 | /* start bit [1] */ | ||
| 126 | data_lo(); | ||
| 127 | clock_hi(); | ||
| 128 | WAIT(clock_lo, 15000, 1); | ||
| 129 | /* data [2-9] */ | ||
| 130 | for (uint8_t i = 0; i < 8; i++) { | ||
| 131 | _delay_us(15); | ||
| 132 | if (data&(1<<i)) { | ||
| 133 | parity = !parity; | ||
| 134 | data_hi(); | ||
| 135 | } else { | ||
| 136 | data_lo(); | ||
| 137 | } | ||
| 138 | WAIT(clock_hi, 50, 2); | ||
| 139 | WAIT(clock_lo, 50, 3); | ||
| 140 | } | ||
| 141 | /* parity [10] */ | ||
| 142 | _delay_us(15); | ||
| 143 | if (parity) { data_hi(); } else { data_lo(); } | ||
| 144 | WAIT(clock_hi, 50, 4); | ||
| 145 | WAIT(clock_lo, 50, 5); | ||
| 146 | /* stop bit [11] */ | ||
| 147 | _delay_us(15); | ||
| 148 | data_hi(); | ||
| 149 | /* ack [12] */ | ||
| 150 | WAIT(data_lo, 50, 6); | ||
| 151 | WAIT(clock_lo, 50, 7); | ||
| 152 | |||
| 153 | /* wait for idle state */ | ||
| 154 | WAIT(clock_hi, 50, 8); | ||
| 155 | WAIT(data_hi, 50, 9); | ||
| 156 | |||
| 157 | res = ps2_host_recv_response(); | ||
| 158 | ERROR: | ||
| 159 | idle(); | ||
| 160 | PS2_USART_INIT(); | ||
| 161 | PS2_USART_RX_INT_ON(); | ||
| 162 | return res; | ||
| 163 | } | ||
| 164 | |||
| 165 | // Do polling data from keyboard to get response to last command. | ||
| 166 | uint8_t ps2_host_recv_response(void) | ||
| 167 | { | ||
| 168 | uint8_t data = 0; | ||
| 169 | PS2_USART_INIT(); | ||
| 170 | PS2_USART_RX_POLL_ON(); | ||
| 171 | while (!PS2_USART_RX_READY) | ||
| 172 | ; | ||
| 173 | data = PS2_USART_RX_DATA; | ||
| 174 | PS2_USART_OFF(); | ||
| 175 | DEBUGP(0x9); | ||
| 176 | return data; | ||
| 177 | } | ||
| 178 | |||
| 179 | uint8_t ps2_host_recv(void) | ||
| 180 | { | ||
| 181 | return pbuf_dequeue(); | ||
| 182 | } | ||
| 183 | |||
| 184 | ISR(PS2_USART_RX_VECT) | ||
| 185 | { | ||
| 186 | DEBUGP(0x7); | ||
| 187 | uint8_t error = PS2_USART_ERROR; | ||
| 188 | uint8_t data = PS2_USART_RX_DATA; | ||
| 189 | if (error) { | ||
| 190 | DEBUGP(error>>2); | ||
| 191 | } else { | ||
| 192 | pbuf_enqueue(data); | ||
| 193 | } | ||
| 194 | DEBUGP(0x8); | ||
| 195 | } | ||
| 196 | |||
| 197 | /* send LED state to keyboard */ | ||
| 198 | void ps2_host_set_led(uint8_t led) | ||
| 199 | { | ||
| 200 | // send 0xED then keyboard keeps waiting for next LED data | ||
| 201 | // and keyboard does not send any scan codes during waiting. | ||
| 202 | // If fail to send LED data keyboard looks like being freezed. | ||
| 203 | uint8_t retry = 3; | ||
| 204 | while (retry-- && ps2_host_send(PS2_SET_LED) != PS2_ACK) | ||
| 205 | ; | ||
| 206 | retry = 3; | ||
| 207 | while (retry-- && ps2_host_send(led) != PS2_ACK) | ||
| 208 | ; | ||
| 209 | } | ||
| 210 | |||
| 211 | |||
| 212 | /*-------------------------------------------------------------------- | ||
| 213 | * static functions | ||
| 214 | *------------------------------------------------------------------*/ | ||
| 215 | static inline void clock_lo() | ||
| 216 | { | ||
| 217 | PS2_CLOCK_PORT &= ~(1<<PS2_CLOCK_BIT); | ||
| 218 | PS2_CLOCK_DDR |= (1<<PS2_CLOCK_BIT); | ||
| 219 | } | ||
| 220 | static inline void clock_hi() | ||
| 221 | { | ||
| 222 | /* input with pull up */ | ||
| 223 | PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); | ||
| 224 | PS2_CLOCK_PORT |= (1<<PS2_CLOCK_BIT); | ||
| 225 | } | ||
| 226 | static inline bool clock_in() | ||
| 227 | { | ||
| 228 | PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); | ||
| 229 | PS2_CLOCK_PORT |= (1<<PS2_CLOCK_BIT); | ||
| 230 | _delay_us(1); | ||
| 231 | return PS2_CLOCK_PIN&(1<<PS2_CLOCK_BIT); | ||
| 232 | } | ||
| 233 | static inline void data_lo() | ||
| 234 | { | ||
| 235 | PS2_DATA_PORT &= ~(1<<PS2_DATA_BIT); | ||
| 236 | PS2_DATA_DDR |= (1<<PS2_DATA_BIT); | ||
| 237 | } | ||
| 238 | static inline void data_hi() | ||
| 239 | { | ||
| 240 | /* input with pull up */ | ||
| 241 | PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); | ||
| 242 | PS2_DATA_PORT |= (1<<PS2_DATA_BIT); | ||
| 243 | } | ||
| 244 | static inline bool data_in() | ||
| 245 | { | ||
| 246 | PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); | ||
| 247 | PS2_DATA_PORT |= (1<<PS2_DATA_BIT); | ||
| 248 | _delay_us(1); | ||
| 249 | return PS2_DATA_PIN&(1<<PS2_DATA_BIT); | ||
| 250 | } | ||
| 251 | |||
| 252 | static inline uint16_t wait_clock_lo(uint16_t us) | ||
| 253 | { | ||
| 254 | while (clock_in() && us) { asm(""); _delay_us(1); us--; } | ||
| 255 | return us; | ||
| 256 | } | ||
| 257 | static inline uint16_t wait_clock_hi(uint16_t us) | ||
| 258 | { | ||
| 259 | while (!clock_in() && us) { asm(""); _delay_us(1); us--; } | ||
| 260 | return us; | ||
| 261 | } | ||
| 262 | static inline uint16_t wait_data_lo(uint16_t us) | ||
| 263 | { | ||
| 264 | while (data_in() && us) { asm(""); _delay_us(1); us--; } | ||
| 265 | return us; | ||
| 266 | } | ||
| 267 | static inline uint16_t wait_data_hi(uint16_t us) | ||
| 268 | { | ||
| 269 | while (!data_in() && us) { asm(""); _delay_us(1); us--; } | ||
| 270 | return us; | ||
| 271 | } | ||
| 272 | |||
| 273 | /* idle state that device can send */ | ||
| 274 | static inline void idle(void) | ||
| 275 | { | ||
| 276 | clock_hi(); | ||
| 277 | data_hi(); | ||
| 278 | } | ||
| 279 | |||
| 280 | /* inhibit device to send */ | ||
| 281 | static inline void inhibit(void) | ||
| 282 | { | ||
| 283 | clock_lo(); | ||
| 284 | data_hi(); | ||
| 285 | } | ||
| 286 | |||
| 287 | |||
| 288 | /*-------------------------------------------------------------------- | ||
| 289 | * Ring buffer to store scan codes from keyboard | ||
| 290 | *------------------------------------------------------------------*/ | ||
| 291 | #define PBUF_SIZE 8 | ||
| 292 | static uint8_t pbuf[PBUF_SIZE]; | ||
| 293 | static uint8_t pbuf_head = 0; | ||
| 294 | static uint8_t pbuf_tail = 0; | ||
| 295 | static inline void pbuf_enqueue(uint8_t data) | ||
| 296 | { | ||
| 297 | if (!data) | ||
| 298 | return; | ||
| 299 | |||
| 300 | uint8_t sreg = SREG; | ||
| 301 | cli(); | ||
| 302 | uint8_t next = (pbuf_head + 1) % PBUF_SIZE; | ||
| 303 | if (next != pbuf_tail) { | ||
| 304 | pbuf[pbuf_head] = data; | ||
| 305 | pbuf_head = next; | ||
| 306 | } else { | ||
| 307 | debug("pbuf: full\n"); | ||
| 308 | } | ||
| 309 | SREG = sreg; | ||
| 310 | } | ||
| 311 | |||
| 312 | static inline uint8_t pbuf_dequeue(void) | ||
| 313 | { | ||
| 314 | uint8_t val = 0; | ||
| 315 | |||
| 316 | uint8_t sreg = SREG; | ||
| 317 | cli(); | ||
| 318 | if (pbuf_head != pbuf_tail) { | ||
| 319 | val = pbuf[pbuf_tail]; | ||
| 320 | pbuf_tail = (pbuf_tail + 1) % PBUF_SIZE; | ||
| 321 | } | ||
| 322 | SREG = sreg; | ||
| 323 | |||
| 324 | return val; | ||
| 325 | } | ||
diff --git a/ps2_vusb/sendchar_dummy.c b/ps2_vusb/sendchar_dummy.c deleted file mode 100644 index 8c9e583f1..000000000 --- a/ps2_vusb/sendchar_dummy.c +++ /dev/null | |||
| @@ -1,8 +0,0 @@ | |||
| 1 | #include <stdint.h> | ||
| 2 | #include "sendchar.h" | ||
| 3 | |||
| 4 | |||
| 5 | int8_t sendchar(uint8_t c) | ||
| 6 | { | ||
| 7 | return 1; | ||
| 8 | } | ||
diff --git a/ps2_vusb/sendchar_usart.c b/ps2_vusb/sendchar_usart.c deleted file mode 100644 index fe18177a3..000000000 --- a/ps2_vusb/sendchar_usart.c +++ /dev/null | |||
| @@ -1,58 +0,0 @@ | |||
| 1 | #include <stdint.h> | ||
| 2 | #include "oddebug.h" | ||
| 3 | #include "sendchar.h" | ||
| 4 | |||
| 5 | |||
| 6 | /* from oddebug.h */ | ||
| 7 | #if defined UBRR | ||
| 8 | # define ODDBG_UBRR UBRR | ||
| 9 | #elif defined UBRRL | ||
| 10 | # define ODDBG_UBRR UBRRL | ||
| 11 | #elif defined UBRR0 | ||
| 12 | # define ODDBG_UBRR UBRR0 | ||
| 13 | #elif defined UBRR0L | ||
| 14 | # define ODDBG_UBRR UBRR0L | ||
| 15 | #endif | ||
| 16 | |||
| 17 | #if defined UCR | ||
| 18 | # define ODDBG_UCR UCR | ||
| 19 | #elif defined UCSRB | ||
| 20 | # define ODDBG_UCR UCSRB | ||
| 21 | #elif defined UCSR0B | ||
| 22 | # define ODDBG_UCR UCSR0B | ||
| 23 | #endif | ||
| 24 | |||
| 25 | #if defined TXEN | ||
| 26 | # define ODDBG_TXEN TXEN | ||
| 27 | #else | ||
| 28 | # define ODDBG_TXEN TXEN0 | ||
| 29 | #endif | ||
| 30 | |||
| 31 | #if defined USR | ||
| 32 | # define ODDBG_USR USR | ||
| 33 | #elif defined UCSRA | ||
| 34 | # define ODDBG_USR UCSRA | ||
| 35 | #elif defined UCSR0A | ||
| 36 | # define ODDBG_USR UCSR0A | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #if defined UDRE | ||
| 40 | # define ODDBG_UDRE UDRE | ||
| 41 | #else | ||
| 42 | # define ODDBG_UDRE UDRE0 | ||
| 43 | #endif | ||
| 44 | |||
| 45 | #if defined UDR | ||
| 46 | # define ODDBG_UDR UDR | ||
| 47 | #elif defined UDR0 | ||
| 48 | # define ODDBG_UDR UDR0 | ||
| 49 | #endif | ||
| 50 | |||
| 51 | |||
| 52 | /* from oddebug.c */ | ||
| 53 | int8_t sendchar(uint8_t c) | ||
| 54 | { | ||
| 55 | while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */ | ||
| 56 | ODDBG_UDR = c; | ||
| 57 | return 1; | ||
| 58 | } | ||
diff --git a/ps2_vusb/usbconfig.h b/ps2_vusb/usbconfig.h deleted file mode 100644 index 34807066f..000000000 --- a/ps2_vusb/usbconfig.h +++ /dev/null | |||
| @@ -1,378 +0,0 @@ | |||
| 1 | /* Name: usbconfig.h | ||
| 2 | * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers | ||
| 3 | * Author: Christian Starkjohann | ||
| 4 | * Creation Date: 2005-04-01 | ||
| 5 | * Tabsize: 4 | ||
| 6 | * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH | ||
| 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) | ||
| 8 | * This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $ | ||
| 9 | */ | ||
| 10 | |||
| 11 | #ifndef __usbconfig_h_included__ | ||
| 12 | #define __usbconfig_h_included__ | ||
| 13 | |||
| 14 | #include "config.h" | ||
| 15 | |||
| 16 | /* | ||
| 17 | General Description: | ||
| 18 | This file is an example configuration (with inline documentation) for the USB | ||
| 19 | driver. It configures V-USB for USB D+ connected to Port D bit 2 (which is | ||
| 20 | also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may | ||
| 21 | wire the lines to any other port, as long as D+ is also wired to INT0 (or any | ||
| 22 | other hardware interrupt, as long as it is the highest level interrupt, see | ||
| 23 | section at the end of this file). | ||
| 24 | */ | ||
| 25 | |||
| 26 | /* ---------------------------- Hardware Config ---------------------------- */ | ||
| 27 | |||
| 28 | #define USB_CFG_IOPORTNAME D | ||
| 29 | /* This is the port where the USB bus is connected. When you configure it to | ||
| 30 | * "B", the registers PORTB, PINB and DDRB will be used. | ||
| 31 | */ | ||
| 32 | #define USB_CFG_DMINUS_BIT 3 | ||
| 33 | /* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected. | ||
| 34 | * This may be any bit in the port. | ||
| 35 | */ | ||
| 36 | #define USB_CFG_DPLUS_BIT 2 | ||
| 37 | /* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected. | ||
| 38 | * This may be any bit in the port. Please note that D+ must also be connected | ||
| 39 | * to interrupt pin INT0! [You can also use other interrupts, see section | ||
| 40 | * "Optional MCU Description" below, or you can connect D- to the interrupt, as | ||
| 41 | * it is required if you use the USB_COUNT_SOF feature. If you use D- for the | ||
| 42 | * interrupt, the USB interrupt will also be triggered at Start-Of-Frame | ||
| 43 | * markers every millisecond.] | ||
| 44 | */ | ||
| 45 | #define USB_CFG_CLOCK_KHZ (F_CPU/1000) | ||
| 46 | /* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000, | ||
| 47 | * 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code | ||
| 48 | * require no crystal, they tolerate +/- 1% deviation from the nominal | ||
| 49 | * frequency. All other rates require a precision of 2000 ppm and thus a | ||
| 50 | * crystal! | ||
| 51 | * Since F_CPU should be defined to your actual clock rate anyway, you should | ||
| 52 | * not need to modify this setting. | ||
| 53 | */ | ||
| 54 | #define USB_CFG_CHECK_CRC 0 | ||
| 55 | /* Define this to 1 if you want that the driver checks integrity of incoming | ||
| 56 | * data packets (CRC checks). CRC checks cost quite a bit of code size and are | ||
| 57 | * currently only available for 18 MHz crystal clock. You must choose | ||
| 58 | * USB_CFG_CLOCK_KHZ = 18000 if you enable this option. | ||
| 59 | */ | ||
| 60 | |||
| 61 | /* ----------------------- Optional Hardware Config ------------------------ */ | ||
| 62 | |||
| 63 | /* #define USB_CFG_PULLUP_IOPORTNAME D */ | ||
| 64 | /* If you connect the 1.5k pullup resistor from D- to a port pin instead of | ||
| 65 | * V+, you can connect and disconnect the device from firmware by calling | ||
| 66 | * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h). | ||
| 67 | * This constant defines the port on which the pullup resistor is connected. | ||
| 68 | */ | ||
| 69 | /* #define USB_CFG_PULLUP_BIT 4 */ | ||
| 70 | /* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined | ||
| 71 | * above) where the 1.5k pullup resistor is connected. See description | ||
| 72 | * above for details. | ||
| 73 | */ | ||
| 74 | |||
| 75 | /* --------------------------- Functional Range ---------------------------- */ | ||
| 76 | |||
| 77 | #define USB_CFG_HAVE_INTRIN_ENDPOINT 1 | ||
| 78 | /* Define this to 1 if you want to compile a version with two endpoints: The | ||
| 79 | * default control endpoint 0 and an interrupt-in endpoint (any other endpoint | ||
| 80 | * number). | ||
| 81 | */ | ||
| 82 | #define USB_CFG_HAVE_INTRIN_ENDPOINT3 1 | ||
| 83 | /* Define this to 1 if you want to compile a version with three endpoints: The | ||
| 84 | * default control endpoint 0, an interrupt-in endpoint 3 (or the number | ||
| 85 | * configured below) and a catch-all default interrupt-in endpoint as above. | ||
| 86 | * You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature. | ||
| 87 | */ | ||
| 88 | #define USB_CFG_EP3_NUMBER 3 | ||
| 89 | /* If the so-called endpoint 3 is used, it can now be configured to any other | ||
| 90 | * endpoint number (except 0) with this macro. Default if undefined is 3. | ||
| 91 | */ | ||
| 92 | /* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */ | ||
| 93 | /* The above macro defines the startup condition for data toggling on the | ||
| 94 | * interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1. | ||
| 95 | * Since the token is toggled BEFORE sending any data, the first packet is | ||
| 96 | * sent with the oposite value of this configuration! | ||
| 97 | */ | ||
| 98 | #define USB_CFG_IMPLEMENT_HALT 0 | ||
| 99 | /* Define this to 1 if you also want to implement the ENDPOINT_HALT feature | ||
| 100 | * for endpoint 1 (interrupt endpoint). Although you may not need this feature, | ||
| 101 | * it is required by the standard. We have made it a config option because it | ||
| 102 | * bloats the code considerably. | ||
| 103 | */ | ||
| 104 | #define USB_CFG_SUPPRESS_INTR_CODE 0 | ||
| 105 | /* Define this to 1 if you want to declare interrupt-in endpoints, but don't | ||
| 106 | * want to send any data over them. If this macro is defined to 1, functions | ||
| 107 | * usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if | ||
| 108 | * you need the interrupt-in endpoints in order to comply to an interface | ||
| 109 | * (e.g. HID), but never want to send any data. This option saves a couple | ||
| 110 | * of bytes in flash memory and the transmit buffers in RAM. | ||
| 111 | */ | ||
| 112 | #define USB_CFG_INTR_POLL_INTERVAL 10 | ||
| 113 | /* If you compile a version with endpoint 1 (interrupt-in), this is the poll | ||
| 114 | * interval. The value is in milliseconds and must not be less than 10 ms for | ||
| 115 | * low speed devices. | ||
| 116 | */ | ||
| 117 | #define USB_CFG_IS_SELF_POWERED 0 | ||
| 118 | /* Define this to 1 if the device has its own power supply. Set it to 0 if the | ||
| 119 | * device is powered from the USB bus. | ||
| 120 | */ | ||
| 121 | #define USB_CFG_MAX_BUS_POWER 100 | ||
| 122 | /* Set this variable to the maximum USB bus power consumption of your device. | ||
| 123 | * The value is in milliamperes. [It will be divided by two since USB | ||
| 124 | * communicates power requirements in units of 2 mA.] | ||
| 125 | */ | ||
| 126 | #define USB_CFG_IMPLEMENT_FN_WRITE 1 | ||
| 127 | /* Set this to 1 if you want usbFunctionWrite() to be called for control-out | ||
| 128 | * transfers. Set it to 0 if you don't need it and want to save a couple of | ||
| 129 | * bytes. | ||
| 130 | */ | ||
| 131 | #define USB_CFG_IMPLEMENT_FN_READ 0 | ||
| 132 | /* Set this to 1 if you need to send control replies which are generated | ||
| 133 | * "on the fly" when usbFunctionRead() is called. If you only want to send | ||
| 134 | * data from a static buffer, set it to 0 and return the data from | ||
| 135 | * usbFunctionSetup(). This saves a couple of bytes. | ||
| 136 | */ | ||
| 137 | #define USB_CFG_IMPLEMENT_FN_WRITEOUT 0 | ||
| 138 | /* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints. | ||
| 139 | * You must implement the function usbFunctionWriteOut() which receives all | ||
| 140 | * interrupt/bulk data sent to any endpoint other than 0. The endpoint number | ||
| 141 | * can be found in 'usbRxToken'. | ||
| 142 | */ | ||
| 143 | #define USB_CFG_HAVE_FLOWCONTROL 0 | ||
| 144 | /* Define this to 1 if you want flowcontrol over USB data. See the definition | ||
| 145 | * of the macros usbDisableAllRequests() and usbEnableAllRequests() in | ||
| 146 | * usbdrv.h. | ||
| 147 | */ | ||
| 148 | #define USB_CFG_DRIVER_FLASH_PAGE 0 | ||
| 149 | /* If the device has more than 64 kBytes of flash, define this to the 64 k page | ||
| 150 | * where the driver's constants (descriptors) are located. Or in other words: | ||
| 151 | * Define this to 1 for boot loaders on the ATMega128. | ||
| 152 | */ | ||
| 153 | #define USB_CFG_LONG_TRANSFERS 0 | ||
| 154 | /* Define this to 1 if you want to send/receive blocks of more than 254 bytes | ||
| 155 | * in a single control-in or control-out transfer. Note that the capability | ||
| 156 | * for long transfers increases the driver size. | ||
| 157 | */ | ||
| 158 | /* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */ | ||
| 159 | /* This macro is a hook if you want to do unconventional things. If it is | ||
| 160 | * defined, it's inserted at the beginning of received message processing. | ||
| 161 | * If you eat the received message and don't want default processing to | ||
| 162 | * proceed, do a return after doing your things. One possible application | ||
| 163 | * (besides debugging) is to flash a status LED on each packet. | ||
| 164 | */ | ||
| 165 | /* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();} */ | ||
| 166 | /* This macro is a hook if you need to know when an USB RESET occurs. It has | ||
| 167 | * one parameter which distinguishes between the start of RESET state and its | ||
| 168 | * end. | ||
| 169 | */ | ||
| 170 | /* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */ | ||
| 171 | /* This macro (if defined) is executed when a USB SET_ADDRESS request was | ||
| 172 | * received. | ||
| 173 | */ | ||
| 174 | #define USB_COUNT_SOF 0 | ||
| 175 | /* define this macro to 1 if you need the global variable "usbSofCount" which | ||
| 176 | * counts SOF packets. This feature requires that the hardware interrupt is | ||
| 177 | * connected to D- instead of D+. | ||
| 178 | */ | ||
| 179 | /* #ifdef __ASSEMBLER__ | ||
| 180 | * macro myAssemblerMacro | ||
| 181 | * in YL, TCNT0 | ||
| 182 | * sts timer0Snapshot, YL | ||
| 183 | * endm | ||
| 184 | * #endif | ||
| 185 | * #define USB_SOF_HOOK myAssemblerMacro | ||
| 186 | * This macro (if defined) is executed in the assembler module when a | ||
| 187 | * Start Of Frame condition is detected. It is recommended to define it to | ||
| 188 | * the name of an assembler macro which is defined here as well so that more | ||
| 189 | * than one assembler instruction can be used. The macro may use the register | ||
| 190 | * YL and modify SREG. If it lasts longer than a couple of cycles, USB messages | ||
| 191 | * immediately after an SOF pulse may be lost and must be retried by the host. | ||
| 192 | * What can you do with this hook? Since the SOF signal occurs exactly every | ||
| 193 | * 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in | ||
| 194 | * designs running on the internal RC oscillator. | ||
| 195 | * Please note that Start Of Frame detection works only if D- is wired to the | ||
| 196 | * interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES! | ||
| 197 | */ | ||
| 198 | #define USB_CFG_CHECK_DATA_TOGGLING 0 | ||
| 199 | /* define this macro to 1 if you want to filter out duplicate data packets | ||
| 200 | * sent by the host. Duplicates occur only as a consequence of communication | ||
| 201 | * errors, when the host does not receive an ACK. Please note that you need to | ||
| 202 | * implement the filtering yourself in usbFunctionWriteOut() and | ||
| 203 | * usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable | ||
| 204 | * for each control- and out-endpoint to check for duplicate packets. | ||
| 205 | */ | ||
| 206 | #define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0 | ||
| 207 | /* define this macro to 1 if you want the function usbMeasureFrameLength() | ||
| 208 | * compiled in. This function can be used to calibrate the AVR's RC oscillator. | ||
| 209 | */ | ||
| 210 | #define USB_USE_FAST_CRC 0 | ||
| 211 | /* The assembler module has two implementations for the CRC algorithm. One is | ||
| 212 | * faster, the other is smaller. This CRC routine is only used for transmitted | ||
| 213 | * messages where timing is not critical. The faster routine needs 31 cycles | ||
| 214 | * per byte while the smaller one needs 61 to 69 cycles. The faster routine | ||
| 215 | * may be worth the 32 bytes bigger code size if you transmit lots of data and | ||
| 216 | * run the AVR close to its limit. | ||
| 217 | */ | ||
| 218 | |||
| 219 | /* -------------------------- Device Description --------------------------- */ | ||
| 220 | |||
| 221 | #define USB_CFG_VENDOR_ID (VENDOR_ID & 0xFF), ((VENDOR_ID >> 8) & 0xFF) | ||
| 222 | /* USB vendor ID for the device, low byte first. If you have registered your | ||
| 223 | * own Vendor ID, define it here. Otherwise you may use one of obdev's free | ||
| 224 | * shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules! | ||
| 225 | * *** IMPORTANT NOTE *** | ||
| 226 | * This template uses obdev's shared VID/PID pair for Vendor Class devices | ||
| 227 | * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand | ||
| 228 | * the implications! | ||
| 229 | */ | ||
| 230 | #define USB_CFG_DEVICE_ID (PRODUCT_ID & 0xFF), ((PRODUCT_ID >> 8) & 0xFF) | ||
| 231 | /* This is the ID of the product, low byte first. It is interpreted in the | ||
| 232 | * scope of the vendor ID. If you have registered your own VID with usb.org | ||
| 233 | * or if you have licensed a PID from somebody else, define it here. Otherwise | ||
| 234 | * you may use one of obdev's free shared VID/PID pairs. See the file | ||
| 235 | * USB-IDs-for-free.txt for details! | ||
| 236 | * *** IMPORTANT NOTE *** | ||
| 237 | * This template uses obdev's shared VID/PID pair for Vendor Class devices | ||
| 238 | * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand | ||
| 239 | * the implications! | ||
| 240 | */ | ||
| 241 | #define USB_CFG_DEVICE_VERSION 0x00, 0x01 | ||
| 242 | /* Version number of the device: Minor number first, then major number. | ||
| 243 | */ | ||
| 244 | #define USB_CFG_VENDOR_NAME 't', '.', 'm', '.', 'k', '.' | ||
| 245 | #define USB_CFG_VENDOR_NAME_LEN 6 | ||
| 246 | /* These two values define the vendor name returned by the USB device. The name | ||
| 247 | * must be given as a list of characters under single quotes. The characters | ||
| 248 | * are interpreted as Unicode (UTF-16) entities. | ||
| 249 | * If you don't want a vendor name string, undefine these macros. | ||
| 250 | * ALWAYS define a vendor name containing your Internet domain name if you use | ||
| 251 | * obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for | ||
| 252 | * details. | ||
| 253 | */ | ||
| 254 | #define USB_CFG_DEVICE_NAME 'P', 'S', '/', '2', ' ', 'k', 'e', 'y', 'b', 'o', 'a', 'r', 'd', ' ', 'c', 'o', 'n', 'v', 'e', 'r', 't', 'e', 'r' | ||
| 255 | #define USB_CFG_DEVICE_NAME_LEN 23 | ||
| 256 | /* Same as above for the device name. If you don't want a device name, undefine | ||
| 257 | * the macros. See the file USB-IDs-for-free.txt before you assign a name if | ||
| 258 | * you use a shared VID/PID. | ||
| 259 | */ | ||
| 260 | /*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */ | ||
| 261 | /*#define USB_CFG_SERIAL_NUMBER_LEN 0 */ | ||
| 262 | /* Same as above for the serial number. If you don't want a serial number, | ||
| 263 | * undefine the macros. | ||
| 264 | * It may be useful to provide the serial number through other means than at | ||
| 265 | * compile time. See the section about descriptor properties below for how | ||
| 266 | * to fine tune control over USB descriptors such as the string descriptor | ||
| 267 | * for the serial number. | ||
| 268 | */ | ||
| 269 | #define USB_CFG_DEVICE_CLASS 0 | ||
| 270 | #define USB_CFG_DEVICE_SUBCLASS 0 | ||
| 271 | /* See USB specification if you want to conform to an existing device class. | ||
| 272 | * Class 0xff is "vendor specific". | ||
| 273 | */ | ||
| 274 | #define USB_CFG_INTERFACE_CLASS 3 /* HID */ | ||
| 275 | #define USB_CFG_INTERFACE_SUBCLASS 1 /* Boot */ | ||
| 276 | #define USB_CFG_INTERFACE_PROTOCOL 1 /* Keyboard */ | ||
| 277 | /* See USB specification if you want to conform to an existing device class or | ||
| 278 | * protocol. The following classes must be set at interface level: | ||
| 279 | * HID class is 3, no subclass and protocol required (but may be useful!) | ||
| 280 | * CDC class is 2, use subclass 2 and protocol 1 for ACM | ||
| 281 | */ | ||
| 282 | #define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0 | ||
| 283 | /* Define this to the length of the HID report descriptor, if you implement | ||
| 284 | * an HID device. Otherwise don't define it or define it to 0. | ||
| 285 | * If you use this define, you must add a PROGMEM character array named | ||
| 286 | * "usbHidReportDescriptor" to your code which contains the report descriptor. | ||
| 287 | * Don't forget to keep the array and this define in sync! | ||
| 288 | */ | ||
| 289 | |||
| 290 | /* #define USB_PUBLIC static */ | ||
| 291 | /* Use the define above if you #include usbdrv.c instead of linking against it. | ||
| 292 | * This technique saves a couple of bytes in flash memory. | ||
| 293 | */ | ||
| 294 | |||
| 295 | /* ------------------- Fine Control over USB Descriptors ------------------- */ | ||
| 296 | /* If you don't want to use the driver's default USB descriptors, you can | ||
| 297 | * provide our own. These can be provided as (1) fixed length static data in | ||
| 298 | * flash memory, (2) fixed length static data in RAM or (3) dynamically at | ||
| 299 | * runtime in the function usbFunctionDescriptor(). See usbdrv.h for more | ||
| 300 | * information about this function. | ||
| 301 | * Descriptor handling is configured through the descriptor's properties. If | ||
| 302 | * no properties are defined or if they are 0, the default descriptor is used. | ||
| 303 | * Possible properties are: | ||
| 304 | * + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched | ||
| 305 | * at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is | ||
| 306 | * used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if | ||
| 307 | * you want RAM pointers. | ||
| 308 | * + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found | ||
| 309 | * in static memory is in RAM, not in flash memory. | ||
| 310 | * + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash), | ||
| 311 | * the driver must know the descriptor's length. The descriptor itself is | ||
| 312 | * found at the address of a well known identifier (see below). | ||
| 313 | * List of static descriptor names (must be declared PROGMEM if in flash): | ||
| 314 | * char usbDescriptorDevice[]; | ||
| 315 | * char usbDescriptorConfiguration[]; | ||
| 316 | * char usbDescriptorHidReport[]; | ||
| 317 | * char usbDescriptorString0[]; | ||
| 318 | * int usbDescriptorStringVendor[]; | ||
| 319 | * int usbDescriptorStringDevice[]; | ||
| 320 | * int usbDescriptorStringSerialNumber[]; | ||
| 321 | * Other descriptors can't be provided statically, they must be provided | ||
| 322 | * dynamically at runtime. | ||
| 323 | * | ||
| 324 | * Descriptor properties are or-ed or added together, e.g.: | ||
| 325 | * #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18)) | ||
| 326 | * | ||
| 327 | * The following descriptors are defined: | ||
| 328 | * USB_CFG_DESCR_PROPS_DEVICE | ||
| 329 | * USB_CFG_DESCR_PROPS_CONFIGURATION | ||
| 330 | * USB_CFG_DESCR_PROPS_STRINGS | ||
| 331 | * USB_CFG_DESCR_PROPS_STRING_0 | ||
| 332 | * USB_CFG_DESCR_PROPS_STRING_VENDOR | ||
| 333 | * USB_CFG_DESCR_PROPS_STRING_PRODUCT | ||
| 334 | * USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER | ||
| 335 | * USB_CFG_DESCR_PROPS_HID | ||
| 336 | * USB_CFG_DESCR_PROPS_HID_REPORT | ||
| 337 | * USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver) | ||
| 338 | * | ||
| 339 | * Note about string descriptors: String descriptors are not just strings, they | ||
| 340 | * are Unicode strings prefixed with a 2 byte header. Example: | ||
| 341 | * int serialNumberDescriptor[] = { | ||
| 342 | * USB_STRING_DESCRIPTOR_HEADER(6), | ||
| 343 | * 'S', 'e', 'r', 'i', 'a', 'l' | ||
| 344 | * }; | ||
| 345 | */ | ||
| 346 | |||
| 347 | #define USB_CFG_DESCR_PROPS_DEVICE 0 | ||
| 348 | #define USB_CFG_DESCR_PROPS_CONFIGURATION USB_PROP_IS_DYNAMIC | ||
| 349 | //#define USB_CFG_DESCR_PROPS_CONFIGURATION 0 | ||
| 350 | #define USB_CFG_DESCR_PROPS_STRINGS 0 | ||
| 351 | #define USB_CFG_DESCR_PROPS_STRING_0 0 | ||
| 352 | #define USB_CFG_DESCR_PROPS_STRING_VENDOR 0 | ||
| 353 | #define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0 | ||
| 354 | #define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0 | ||
| 355 | //#define USB_CFG_DESCR_PROPS_HID USB_PROP_IS_DYNAMIC | ||
| 356 | #define USB_CFG_DESCR_PROPS_HID 0 | ||
| 357 | #define USB_CFG_DESCR_PROPS_HID_REPORT USB_PROP_IS_DYNAMIC | ||
| 358 | //#define USB_CFG_DESCR_PROPS_HID_REPORT 0 | ||
| 359 | #define USB_CFG_DESCR_PROPS_UNKNOWN 0 | ||
| 360 | |||
| 361 | /* ----------------------- Optional MCU Description ------------------------ */ | ||
| 362 | |||
| 363 | /* The following configurations have working defaults in usbdrv.h. You | ||
| 364 | * usually don't need to set them explicitly. Only if you want to run | ||
| 365 | * the driver on a device which is not yet supported or with a compiler | ||
| 366 | * which is not fully supported (such as IAR C) or if you use a differnt | ||
| 367 | * interrupt than INT0, you may have to define some of these. | ||
| 368 | */ | ||
| 369 | /* #define USB_INTR_CFG MCUCR */ | ||
| 370 | /* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */ | ||
| 371 | /* #define USB_INTR_CFG_CLR 0 */ | ||
| 372 | /* #define USB_INTR_ENABLE GIMSK */ | ||
| 373 | /* #define USB_INTR_ENABLE_BIT INT0 */ | ||
| 374 | /* #define USB_INTR_PENDING GIFR */ | ||
| 375 | /* #define USB_INTR_PENDING_BIT INTF0 */ | ||
| 376 | /* #define USB_INTR_VECTOR INT0_vect */ | ||
| 377 | |||
| 378 | #endif /* __usbconfig_h_included__ */ | ||
