config.h 3.8 KB

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