config.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #pragma once
  15. #define VENDOR_ID 0xFEED
  16. #define PRODUCT_ID 0x3333
  17. #define DEVICE_VER 0x0100
  18. #define MANUFACTURER QMK
  19. #define PRODUCT Sun keyboard converter
  20. /* matrix size */
  21. #define MATRIX_ROWS 16
  22. #define MATRIX_COLS 8
  23. /* key combination for command */
  24. #define IS_COMMAND() ( \
  25. get_mods() == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \
  26. get_mods() == (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) || \
  27. get_mods() == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
  28. )
  29. /* Serial(USART) configuration
  30. * asynchronous, negative logic, 1200baud, no flow control
  31. * 1-start bit, 8-data bit, non parity, 1-stop bit
  32. */
  33. #define SERIAL_SOFT_BAUD 1200
  34. #define SERIAL_SOFT_PARITY_NONE
  35. #define SERIAL_SOFT_BIT_ORDER_LSB
  36. #define SERIAL_SOFT_LOGIC_NEGATIVE
  37. /* RXD Port */
  38. #define SERIAL_SOFT_RXD_ENABLE
  39. #define SERIAL_SOFT_RXD_DDR DDRD
  40. #define SERIAL_SOFT_RXD_PORT PORTD
  41. #define SERIAL_SOFT_RXD_PIN PIND
  42. #define SERIAL_SOFT_RXD_BIT 2
  43. #define SERIAL_SOFT_RXD_VECT INT2_vect
  44. /* RXD Interupt */
  45. #define SERIAL_SOFT_RXD_INIT() do { \
  46. /* pin configuration: input with pull-up */ \
  47. SERIAL_SOFT_RXD_DDR &= ~(1<<SERIAL_SOFT_RXD_BIT); \
  48. SERIAL_SOFT_RXD_PORT |= (1<<SERIAL_SOFT_RXD_BIT); \
  49. /* enable interrupt: INT2(rising edge) */ \
  50. EICRA |= ((1<<ISC21)|(1<<ISC20)); \
  51. EIMSK |= (1<<INT2); \
  52. sei(); \
  53. } while (0)
  54. #define SERIAL_SOFT_RXD_INT_ENTER()
  55. #define SERIAL_SOFT_RXD_INT_EXIT() do { \
  56. /* clear interrupt flag */ \
  57. EIFR = (1<<INTF2); \
  58. } while (0)
  59. #define SERIAL_SOFT_RXD_READ() (SERIAL_SOFT_RXD_PIN&(1<<SERIAL_SOFT_RXD_BIT))
  60. /* TXD Port */
  61. #define SERIAL_SOFT_TXD_ENABLE
  62. #define SERIAL_SOFT_TXD_DDR DDRD
  63. #define SERIAL_SOFT_TXD_PORT PORTD
  64. #define SERIAL_SOFT_TXD_PIN PIND
  65. #define SERIAL_SOFT_TXD_BIT 3
  66. #define SERIAL_SOFT_TXD_HI() do { SERIAL_SOFT_TXD_PORT |= (1<<SERIAL_SOFT_TXD_BIT); } while (0)
  67. #define SERIAL_SOFT_TXD_LO() do { SERIAL_SOFT_TXD_PORT &= ~(1<<SERIAL_SOFT_TXD_BIT); } while (0)
  68. #define SERIAL_SOFT_TXD_INIT() do { \
  69. /* pin configuration: output */ \
  70. SERIAL_SOFT_TXD_DDR |= (1<<SERIAL_SOFT_TXD_BIT); \
  71. /* idle */ \
  72. SERIAL_SOFT_TXD_ON(); \
  73. } while (0)