config.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 VENDOR_ID 0xFEED
  18. #define PRODUCT_ID 0x0001
  19. #define DEVICE_VER 0x0100
  20. #define MANUFACTURER QMK
  21. #define PRODUCT Stowaway converter
  22. #define DESCRIPTION USB converter for Stowaway keyboard
  23. // IO pins to serial
  24. // https://deskthority.net/wiki/Arduino_Pro_Micro for pin lookup
  25. #define VCC_PIN D1 // pro micro 2
  26. #define RX_PIN D0 //pro micro 3 , was 8 on cy384
  27. #define RTS_PIN C6 // 5 //[ was D4 // 4 on the cy384
  28. #define DCD_PIN E6 //7
  29. // if using the particular arduino pinout of CY384
  30. #ifdef CY384
  31. #define GND_PIN D7 //6
  32. #define PULLDOWN_PIN B1 // 15
  33. #endif
  34. #ifndef HANDSPRING
  35. // Set to 1 for Handspring or to disable RTS/DCD based handshake.
  36. #define HANDSPRING 0
  37. #endif
  38. #define MAXDROP 10 // check if keyboard is connected every X polling cycles
  39. #define SLEEP_TIMEOUT 500000 // check keyboard/reset this many millis
  40. #define MATRIX_ROWS 12
  41. #define MATRIX_COLS 8
  42. /* key combination for command */
  43. #define IS_COMMAND() ( \
  44. get_mods() == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \
  45. get_mods() == (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) || \
  46. get_mods() == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
  47. )
  48. /* Serial(USART) configuration
  49. * asynchronous, negative logic, 9600baud, no flow control
  50. * 1-start bit, 8-data bit, non parity, 1-stop bit
  51. */
  52. #define SERIAL_SOFT_BAUD 9600
  53. #define SERIAL_SOFT_PARITY_NONE
  54. #define SERIAL_SOFT_BIT_ORDER_LSB
  55. #if (HANDSPRING == 0)
  56. #define SERIAL_SOFT_LOGIC_NEGATIVE //RS232 logic
  57. #endif
  58. /* RXD Port */
  59. #define SERIAL_SOFT_RXD_ENABLE
  60. // we are using Pro micro pin 3 / D0 as serial
  61. #define SERIAL_SOFT_RXD_DDR DDRD
  62. #define SERIAL_SOFT_RXD_PORT PORTD
  63. #define SERIAL_SOFT_RXD_PIN PIND
  64. #define SERIAL_SOFT_RXD_BIT 0
  65. #define SERIAL_SOFT_RXD_VECT INT0_vect
  66. /* RXD Interupt */
  67. #define SERIAL_SOFT_RXD_INIT() do { \
  68. /* pin configuration: input with pull-up */ \
  69. SERIAL_SOFT_RXD_DDR &= ~(1<<SERIAL_SOFT_RXD_BIT); \
  70. SERIAL_SOFT_RXD_PORT |= (1<<SERIAL_SOFT_RXD_BIT); \
  71. /* enable interrupt: INT0(rising edge) */ \
  72. EICRA |= ((1<<ISC01)|(1<<ISC00)); \
  73. EIMSK |= (1<<INT0); \
  74. sei(); \
  75. } while (0)
  76. #define SERIAL_SOFT_RXD_INT_ENTER()
  77. #define SERIAL_SOFT_RXD_INT_EXIT() do { \
  78. /* clear interrupt flag */ \
  79. EIFR = (1<<INTF0); \
  80. } while (0)
  81. #define SERIAL_SOFT_RXD_READ() (SERIAL_SOFT_RXD_PIN&(1<<SERIAL_SOFT_RXD_BIT))
  82. /* TXD Port */
  83. #define SERIAL_SOFT_TXD_ENABLE
  84. #define SERIAL_SOFT_TXD_DDR DDRD
  85. #define SERIAL_SOFT_TXD_PORT PORTD
  86. #define SERIAL_SOFT_TXD_PIN PIND
  87. #define SERIAL_SOFT_TXD_BIT 3
  88. #define SERIAL_SOFT_TXD_HI() do { SERIAL_SOFT_TXD_PORT |= (1<<SERIAL_SOFT_TXD_BIT); } while (0)
  89. #define SERIAL_SOFT_TXD_LO() do { SERIAL_SOFT_TXD_PORT &= ~(1<<SERIAL_SOFT_TXD_BIT); } while (0)
  90. #define SERIAL_SOFT_TXD_INIT() do { \
  91. /* pin configuration: output */ \
  92. SERIAL_SOFT_TXD_DDR |= (1<<SERIAL_SOFT_TXD_BIT); \
  93. /* idle */ \
  94. SERIAL_SOFT_TXD_ON(); \
  95. } while (0)