logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

datahand.h (4642B)


  1. /* Copyright 2017-2019 Nikolaus Wittenstein <nikolaus.wittenstein@gmail.com>
  2. *
  3. * Permission to use, copy, modify, and/or distribute this software for any
  4. * purpose with or without fee is hereby granted, provided that the above
  5. * copyright notice and this permission notice appear in all copies.
  6. *
  7. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  8. * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  9. * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  12. * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. * PERFORMANCE OF THIS SOFTWARE.
  14. */
  15. #pragma once
  16. #include "quantum.h"
  17. /* Mode LEDs are active-low on Port B on the Teensy. */
  18. #define LED_MODE_PORT PORTB
  19. #define LED_TENKEY (1<<3)
  20. #define LED_FN (1<<4)
  21. #define LED_NORMAL (1<<5)
  22. #define LED_NAS (1<<6)
  23. /* Lock LEDs are active-low on Port F on the Teensy. */
  24. #define LED_LOCK_PORT PORTF
  25. #define LED_CAPS_LOCK (1<<4)
  26. #define LED_MOUSE_LOCK (1<<5)
  27. #define LED_NUM_LOCK (1<<6)
  28. #define LED_SCROLL_LOCK (1<<7)
  29. /* Appendix:
  30. * Table based on https://geekhack.org/index.php?topic=12212.msg2059319#msg2059319
  31. * Some pin assignments (e.g. for PS/2 I/O) have been fixed.
  32. *
  33. * Teensy Datahand 8051 pin pin 8051 Datahand Teensy
  34. * ------ -------- ---- --- --- ---- -------- ------
  35. * GND Mtrx send A P1.0 1 40 VCC VCC VCC
  36. * PB7 Mtrx send B P1.1 2 39 P0.0 LED RH NAS PB6
  37. * PD0 Mtrx send C P1.2 3 38 P0.1 LED RH NORM PB5
  38. * PD1 Mtrx send D P1.3 4 37 P0.2 LED RH FCTN PB4
  39. * PD2 RH rcv 0 P1.4 5 36 P0.3 LED RH 10K PB3
  40. * PD3 RH rcv 1 P1.5 6 35 P0.4 LED RH unused PB2
  41. * PD4 LH rcv 0 P1.6 7 34 P0.5 LED RH unused PE1
  42. * PD5 LH rcv 1 P1.7 8 33 P0.6 LED RH unused PE0
  43. * PD6 Reset button RST 9 32 P0.7 ? PE7
  44. * PD7 ? P3.0 10 31 VPP - PE6
  45. * PE0 ? P3.1 11 30 ALE - GND
  46. * PE1 kbd data P3.2 12 29 PSEN - AREF
  47. * PC0 ? P3.3 13 28 P2.7 ? PF0
  48. * PC1 kbd clk P3.4 14 27 P2.6 ? PF1
  49. * PC2 ? P3.5 15 26 P2.5 ? PF2
  50. * PC3 RAM P3.6 16 25 P2.4 ? PF3
  51. * PC4 RAM P3.7 17 24 P2.3 LED D15 LH (CAPLK) PF4
  52. * PC5 XTAL2 XTAL2 18 23 P2.2 LED D13 LH (MSELK) PF5
  53. * PC6 XTAL1 XTAL1 19 22 P2.1 LED D6 LH (NUMLK) PF6
  54. * PC7 GND GND 20 21 P2.0 LED D14 LH (SCRLK) PF7
  55. *
  56. * JP3 Pinout
  57. * 2 - keyboard data
  58. * 3 - keyboard clock
  59. *
  60. * In order to get the Teensy to work, we need to move pin 1 to a different pin. This is
  61. * because on the Teensy pin 1 is ground, but we need to write to pin 1 in order to read
  62. * the keyboard matrix. An ideal pin to move it to is VPP (pin 31), because this pin tells
  63. * the 8051 whether it should read from external or internal memory. The Teensy doesn't
  64. * care about that.
  65. *
  66. * The easiest way to reassign the pin is to use standoffs. You can check out this thread:
  67. * https://geekhack.org/index.php?topic=12212.msg235382#msg235382 for a picture of what
  68. * this looks like. Note that in the picture the pin has been reassigned to pin 12. We
  69. * don't want to do that because we're going to use that pin to send data over PS/2.
  70. *
  71. * We could if we wanted also reassign the PS/2 pins to Teensy hardware UART pins, but
  72. * that's more work. Instead we'll just bit-bang PS/2 because it's an old, slow protocol
  73. * (and because there's already a bit-banged PS/2 host implementation in QMK - we just
  74. * need to add the device side).
  75. *
  76. * So overall, we want the following inputs and outputs:
  77. * Outputs:
  78. * Matrix:
  79. * PB7
  80. * PD0
  81. * PD1
  82. * PE6 (moved from pin1, GND)
  83. * LEDs:
  84. * PB3-6
  85. * PF4-7
  86. * Inputs:
  87. * Matrix:
  88. * PD2-5
  89. * I/Os (start up as inputs):
  90. * PS/2:
  91. * PC1
  92. * PE1
  93. */