tmk / tmk_keyboard

Keyboard firmwares for Atmel AVR and Cortex-M
4k stars 1.71k forks source link

How can I use ATMega32u4 module with no PB4 pinout? #466

Closed southwolf closed 7 years ago

southwolf commented 7 years ago

Thank you for the great work! I don't have a Teensy 2.0 board, but some modules like this:

https://wiki.microduino.cc/index.php/Microduino-Module_CoreUSB

This board doesn't have PB4 pinout, how can I change PB4 to another pin? Thank you!

I tried to edit this line, but I've no idea how to make it right. PORTB = (PORTB & 0xC0) | (((COL) & 0x07)<<3) | ((ROW) & 0x07); https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/hhkb_avr.h#L86

tmk commented 7 years ago

If you can't use PB4, you will have to write that part yourself and know how controller works. See this doc to know HHKB internals, especially pin configuration. https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/doc/HHKB.txt I can't tell you how to change code, it depends on your pin configuration.

This is default pinconfiguration.

Connector Cable
---------------
Two PCBs are connected by 15 lines(13 in case of Pro2).
Vcc and GND use 3(2) lines each, other lines are for keyboard signaling.

    HHKB connector lines:
    JP   Pro2   Pro     Function    Description                               TMK pin usage
    --------------------------------------------------------------------------------------------
                 1      Vcc(5V)                                               5V
     1    1      2      Vcc(5V)                                               5V
     2    2      3      Vcc(5V)                                               5V
     3    3      4      TP1684      ~KEY: Low(0) when key is pressed          PD7 input(with pullup)
     4    4      5      TP1684      HYS: High(1) when key is pressed          PB7 output
     5    5      6      HC4051      A(bit0)\                                  PB0 output
     6    6      7      HC4051      B(bit1) > select row 0-7                  PB1 output
     7    7      8      HC4051      C(bit2)/                                  PB2 output
     8    8      9      LS145       A(bit0)\                                  PB3 output
     9    9     10      LS145       B(bit1) > select column 0-7               PB4 output
    10   10     11      LS145       C(bit2)/                                  PB5 output
    11   11     12      LS145       ~D(enable) Low(0) enables selected column PB6 output
    12   12     13      GND                                                   GND
    13   13     14      GND                                                   GND
                15      GND
    14                  HC4051(Z2)  ~Enable of Z2   row0-7                    PC6
    15                  HC4051(Z3)  ~Enable of Z3   row8-15                   PC7

    NOTE: Probably HYS changes threshold for upstroke and makes hysteresis in the result.
    NOTE: HYS should be given High(1) when previous KEY state is Low(0).
    NOTE: 1KOhm didn't work as pullup resistor on KEY. AVR internal pullup or 10KOhm resistor was OK.
    NOTE: JP has two HC4051(Z2,Z3) and line 5, 6 and 7 are connected to both of them.

    (HHKB_connector.jpg)