You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

config.h 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. NeXT non-ADB Keyboard USB Converter
  3. Copyright 2013, Benjamin Gould ([email protected])
  4. Based on:
  5. TMK firmware code Copyright 2011,2012 Jun WAKO <[email protected]>
  6. Arduino code by "Ladyada" Limor Fried (http://ladyada.net/, http://adafruit.com/), released under BSD license
  7. Timing reference thanks to http://m0115.web.fc2.com/ (dead link), http://cfile7.uf.tistory.com/image/14448E464F410BF22380BB
  8. Pinouts thanks to http://www.68k.org/~degs/nextkeyboard.html
  9. Keycodes from http://ftp.netbsd.org/pub/NetBSD/NetBSD-release-6/src/sys/arch/next68k/dev/
  10. This software is licensed with a Modified BSD License.
  11. All of this is supposed to be Free Software, Open Source, DFSG-free,
  12. GPL-compatible, and OK to use in both free and proprietary applications.
  13. Additions and corrections to this file are welcome.
  14. Redistribution and use in source and binary forms, with or without
  15. modification, are permitted provided that the following conditions are met:
  16. * Redistributions of source code must retain the above copyright
  17. notice, this list of conditions and the following disclaimer.
  18. * Redistributions in binary form must reproduce the above copyright
  19. notice, this list of conditions and the following disclaimer in
  20. the documentation and/or other materials provided with the
  21. distribution.
  22. * Neither the name of the copyright holders nor the names of
  23. contributors may be used to endorse or promote products derived
  24. from this software without specific prior written permission.
  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. #define VENDOR_ID 0xFEED
  38. #define PRODUCT_ID 0xBCBC
  39. #define DEVICE_VER 0x0500
  40. #define MANUFACTURER t.m.k.
  41. #define PRODUCT NeXT Keyboard to USB converter
  42. #define DESCRIPTION USB converter for NeXT non-ADB Keyboard
  43. /* matrix size */
  44. #define MATRIX_ROWS 12 // keycode bit: 3-0
  45. #define MATRIX_COLS 8 // keycode bit: 6-4
  46. #define DEBUG_ON_INIT 1
  47. //#define TEENSY_CONFIG 1
  48. //#define PRO_MICRO_CONFIG 1
  49. #define TMK_CONFIG 1
  50. // comment out if you don't want the keyboard's LEDs to flash upon initialization or pressing shift
  51. //#define NEXT_KBD_INIT_FLASH_LEDS
  52. //#define NEXT_KBD_SHIFT_FLASH_LEDS
  53. //============= Start of Arduino Pro Micro Configuration ==============
  54. #ifdef PRO_MICRO_CONFIG
  55. // this is the debugging LED that flashes when a key is being pressed
  56. // comment out in order to disable debugging LED
  57. #define NEXT_KBD_LED1_PORT PORTD
  58. #define NEXT_KBD_LED1_PIN PIND
  59. #define NEXT_KBD_LED1_DDR DDRD
  60. #define NEXT_KBD_LED1_BIT 5
  61. #define NEXT_KBD_LED1_ON NEXT_KBD_LED1_PORT &= ~(1<<NEXT_KBD_LED1_BIT);
  62. #define NEXT_KBD_LED1_OFF NEXT_KBD_LED1_PORT |= (1<<NEXT_KBD_LED1_BIT);
  63. // reserved for future use
  64. #define NEXT_KBD_LED2_PORT PORTB
  65. #define NEXT_KBD_LED2_PIN PINB
  66. #define NEXT_KBD_LED2_DDR DDRB
  67. #define NEXT_KBD_LED2_BIT 6
  68. #define NEXT_KBD_LED2_ON NEXT_KBD_LED2_PORT &= ~(1<<NEXT_KBD_LED2_BIT);
  69. #define NEXT_KBD_LED2_OFF NEXT_KBD_LED2_PORT |= (1<<NEXT_KBD_LED2_BIT);
  70. // corresponds to the Keyboard In wire on the NeXT connector
  71. // (red wire in NeXT connector) - pin 2 on the Pro Micro
  72. #define NEXT_KBD_OUT_PORT PORTD
  73. #define NEXT_KBD_OUT_PIN PIND
  74. #define NEXT_KBD_OUT_DDR DDRD
  75. #define NEXT_KBD_OUT_BIT 1
  76. // corresponds to the Keyboard Out wire on the NeXT connector
  77. // (orange wire in NeXT connector) - pin 3 on the Pro Micro
  78. #define NEXT_KBD_IN_PORT PORTD
  79. #define NEXT_KBD_IN_PIN PIND
  80. #define NEXT_KBD_IN_DDR DDRD
  81. #define NEXT_KBD_IN_BIT 0
  82. // this pin is an input for the power key on the NeXT keyboard
  83. // as the keyboard is powered on this should be normally high;
  84. // if it is pulled low it means the power button is being preseed
  85. // (yellow wire in NeXT connector) - pin 4 on the Pro Micro
  86. #define NEXT_KBD_PWR_PORT PORTD
  87. #define NEXT_KBD_PWR_PIN PIND
  88. #define NEXT_KBD_PWR_DDR DDRD
  89. #define NEXT_KBD_PWR_BIT 4
  90. #endif
  91. //============== End of Arduino Pro Micro Configuration ===============
  92. //================ Start of Teensy 2.0 Configuration =================
  93. #ifdef TEENSY_CONFIG
  94. // this is the debugging LED that flashes when a key is being pressed
  95. // comment out in order to disable debugging LED
  96. #define NEXT_KBD_LED_PORT PORTD
  97. #define NEXT_KBD_LED_PIN PIND
  98. #define NEXT_KBD_LED_DDR DDRD
  99. #define NEXT_KBD_LED_BIT 6
  100. #define NEXT_KBD_LED_ON NEXT_KBD_LED_PORT |= (1<<NEXT_KBD_LED_BIT);
  101. #define NEXT_KBD_LED_OFF NEXT_KBD_LED_PORT &= ~(1<<NEXT_KBD_LED_BIT);
  102. // corresponds to the Keyboard In wire on the NeXT connector
  103. // (red wire in NeXT connector)
  104. #define NEXT_KBD_OUT_PORT PORTB
  105. #define NEXT_KBD_OUT_PIN PINB
  106. #define NEXT_KBD_OUT_DDR DDRB
  107. #define NEXT_KBD_OUT_BIT 1
  108. // corresponds to the Keyboard Out wire on the NeXT connector
  109. // (orange wire in NeXT connector)
  110. #define NEXT_KBD_IN_PORT PORTB
  111. #define NEXT_KBD_IN_PIN PINB
  112. #define NEXT_KBD_IN_DDR DDRB
  113. #define NEXT_KBD_IN_BIT 0
  114. #endif
  115. //================= End of Teensy 2.0 Configuration ==================
  116. //================ Start of TMK converter Configuration =================
  117. #ifdef TMK_CONFIG
  118. // this is the debugging LED that flashes when a key is being pressed
  119. // comment out in order to disable debugging LED
  120. #define NEXT_KBD_LED1_PORT PORTD
  121. #define NEXT_KBD_LED1_PIN PIND
  122. #define NEXT_KBD_LED1_DDR DDRD
  123. #define NEXT_KBD_LED1_BIT 6
  124. #define NEXT_KBD_LED1_ON NEXT_KBD_LED1_PORT |= (1<<NEXT_KBD_LED1_BIT);
  125. #define NEXT_KBD_LED1_OFF NEXT_KBD_LED1_PORT &= ~(1<<NEXT_KBD_LED1_BIT);
  126. // corresponds to the Keyboard In wire on the NeXT connector
  127. #define NEXT_KBD_OUT_PORT PORTD
  128. #define NEXT_KBD_OUT_PIN PIND
  129. #define NEXT_KBD_OUT_DDR DDRD
  130. #define NEXT_KBD_OUT_BIT 1
  131. // corresponds to the Keyboard Out wire on the NeXT connector
  132. #define NEXT_KBD_IN_PORT PORTD
  133. #define NEXT_KBD_IN_PIN PIND
  134. #define NEXT_KBD_IN_DDR DDRD
  135. #define NEXT_KBD_IN_BIT 0
  136. // this pin is an input for the power key on the NeXT keyboard
  137. // as the keyboard is powered on this should be normally high;
  138. // if it is pulled low it means the power button is being preseed
  139. #define NEXT_KBD_PWR_PORT PORTD
  140. #define NEXT_KBD_PWR_PIN PIND
  141. #define NEXT_KBD_PWR_DDR DDRD
  142. #define NEXT_KBD_PWR_BIT 4
  143. #endif
  144. //================= End of TMK converter Configuration ==================
  145. /* key combination for command */
  146. #define IS_COMMAND() ( \
  147. (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) || \
  148. (keyboard_report->mods == (MOD_BIT(KC_RALT) | MOD_BIT(KC_RALT))) || \
  149. (keyboard_report->mods == (MOD_BIT(KC_RGUI) | MOD_BIT(KC_RGUI))) \
  150. )