]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/converter/palm_usb/config.h
4520725a1d658693fecba1d802dc6ed75cb4d537
[qmk_firmware.git] / keyboards / converter / palm_usb / config.h
1 /*
2 Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /* This code makes use of cy384's Arduino USB HID adapter for the Palm Portable
19  Keyboard, released under the BSD licence */
20
21
22
23
24 #pragma once
25
26 #define CUSTOM_MATRIX 2
27
28 #define VENDOR_ID       0xFEED
29 #define PRODUCT_ID      0x0001
30 #define DEVICE_VER      0x0100
31 #define MANUFACTURER    QMK
32 #define PRODUCT         Stowaway converter
33 #define DESCRIPTION     USB converter for Stowaway keyboard
34
35 // IO pins to serial
36 // https://deskthority.net/wiki/Arduino_Pro_Micro for pin lookup
37 #define VCC_PIN D1 // pro micro 2 
38 #define RX_PIN   D0 //pro micro 3 , was 8 on cy384
39 #define RTS_PIN  C6 // 5  //[ was D4 // 4 on the cy384
40 #define DCD_PIN  E6  //7 
41
42 // if using the particular arduino pinout of CY384
43 #ifdef CY384 
44     #define GND_PIN  D7 //6
45     #define PULLDOWN_PIN  B1 // 15
46 #endif
47
48 #ifndef HANDSPRING
49 // Set to 1 for Handspring or to disable RTS/DCD based handshake. 
50     #define HANDSPRING 0
51 #endif
52
53 #define MAXDROP 10 // check if keyboard is connected every X polling cycles
54 #define SLEEP_TIMEOUT 500000 // check keyboard/reset this many millis
55
56
57 #define MATRIX_ROWS 12
58 #define MATRIX_COLS 8
59
60 /* key combination for command */
61 #define IS_COMMAND() ( \
62     keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \
63     keyboard_report->mods == (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) || \
64     keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
65 )
66
67
68 /* Serial(USART) configuration
69  *     asynchronous, negative logic, 9600baud, no flow control
70  *     1-start bit, 8-data bit, non parity, 1-stop bit
71  */
72 #define SERIAL_SOFT_BAUD            9600
73 #define SERIAL_SOFT_PARITY_NONE
74 #define SERIAL_SOFT_BIT_ORDER_LSB
75 #if (HANDSPRING == 0)
76     #define SERIAL_SOFT_LOGIC_NEGATIVE  //RS232 logic
77 #endif 
78 /* RXD Port */
79 #define SERIAL_SOFT_RXD_ENABLE
80     
81 // we are using Pro micro pin 3 / D0 as serial
82 #define SERIAL_SOFT_RXD_DDR         DDRD
83 #define SERIAL_SOFT_RXD_PORT        PORTD
84 #define SERIAL_SOFT_RXD_PIN         PIND
85 #define SERIAL_SOFT_RXD_BIT         0
86 #define SERIAL_SOFT_RXD_VECT        INT0_vect
87
88 /* RXD Interupt */
89 #define SERIAL_SOFT_RXD_INIT()      do { \
90     /* pin configuration: input with pull-up */ \
91     SERIAL_SOFT_RXD_DDR &= ~(1<<SERIAL_SOFT_RXD_BIT); \
92     SERIAL_SOFT_RXD_PORT |= (1<<SERIAL_SOFT_RXD_BIT); \
93     /* enable interrupt: INT0(rising edge) */ \
94     EICRA |= ((1<<ISC01)|(1<<ISC00)); \
95     EIMSK |= (1<<INT0); \
96     sei(); \
97 } while (0)
98 #define SERIAL_SOFT_RXD_INT_ENTER()
99 #define SERIAL_SOFT_RXD_INT_EXIT()  do { \
100     /* clear interrupt  flag */ \
101     EIFR = (1<<INTF0); \
102 } while (0)
103 #define SERIAL_SOFT_RXD_READ()      (SERIAL_SOFT_RXD_PIN&(1<<SERIAL_SOFT_RXD_BIT))
104
105 /* TXD Port */
106 #define SERIAL_SOFT_TXD_ENABLE
107 #define SERIAL_SOFT_TXD_DDR         DDRD
108 #define SERIAL_SOFT_TXD_PORT        PORTD
109 #define SERIAL_SOFT_TXD_PIN         PIND
110 #define SERIAL_SOFT_TXD_BIT         3
111 #define SERIAL_SOFT_TXD_HI()        do { SERIAL_SOFT_TXD_PORT |=  (1<<SERIAL_SOFT_TXD_BIT); } while (0)
112 #define SERIAL_SOFT_TXD_LO()        do { SERIAL_SOFT_TXD_PORT &= ~(1<<SERIAL_SOFT_TXD_BIT); } while (0)
113 #define SERIAL_SOFT_TXD_INIT()      do { \
114     /* pin configuration: output */ \
115     SERIAL_SOFT_TXD_DDR |= (1<<SERIAL_SOFT_TXD_BIT); \
116     /* idle */ \
117     SERIAL_SOFT_TXD_ON(); \
118 } while (0)
119
120