1
0
Fork 0
qmk_firmware/keyboards/handwired/symmetric70_proto/matrix_fast/readme.md
Takeshi ISHII b89abc402b
[Keyboard] Update Symmetric70 keyboard prototype (#12707)
* update handwired/symmetric70_proto/matrix.c

* make keyboards/handwired/symmetric70_proto/promicro/

* add symmetric70_proto/debug_config.h, update symmetric70_proto/local_features.mk etc.

  set MATRIX_IO_DELAY macro
    make MTEST=mdelay0  symmetric70_proto/promicro:default:flash
    make MTEST=mdelay1  symmetric70_proto/promicro:default:flash
    make MTEST=mdelay10 symmetric70_proto/promicro:default:flash
    make MTEST=mdelay30 symmetric70_proto/promicro:default:flash
  set DEBUG_MATRIX_SCAN_RATE_ENABLE yes
    make MTEST=scan symmetric70_proto/promicro:default:flash
  set MATRIX_DEBUG_DELAY and MATRIX_IO_DELAY macro
    make MTEST=matrix_debug_delay,mdelay0 symmetric70_proto/promicro:default:flash
  set MATRIX_DEBUG_SCAN
    make MTEST=matrix_debug_scan symmetric70_proto/promicro:default:flash

* add symmetric70_proto/matrix_debug/readme.md

* update symmetric70_proto/matrix_debug/readme.md

* update handwired/symmetric70_proto/readme.md

* update handwired/symmetric70_proto/readme.md

* update handwired/symmetric70_proto/*/readme.md

* add handwired/symmetric70_proto/matrix_fast/

* update handwired/symmetric70_proto/matrix_fast/readme.md

* fix typo in handwired/symmetric70_proto/matrix_fast/readme.md

* update config.h under handwired/symmetric70_proto/promicro

* add Proton C support to handwired/symmetric70_proto

* add handwired/symmetric70_proto/proton_c/readme.md

* add promicro/*/readme.md proton_c/*/readme.md

* update handwired/symmetric70_proto/proton_c/proton_c.c

support MATRIX_IO_DELAY_DEFAULT for testing.

* Added another implementation of 'adaptive_delay'.

* update symmetric70_proto/local_features.mk

* update symmetric70_proto/matrix_fast/gpio_extr.h

* add matrix_output_unselect_delay_ports()

* add MTEST=adaptive_delay_fast option

* update symmetric70_proto/matrix_debug/readme.md

* update symmetric70_proto/matrix_fast/readme.md

* update symmetric70_proto/matrix_debug/readme.md

* Erase garbage

* fix symmetric70_proto/proton_c/proton_c.c

* improve adaptive_delay_fast in symmetric70_proto/matrix_debug/matrix.c

* update symmetric70_proto/matrix_debug/readme.md

* fix symmetric70_proto/matrix_debug/readme.md

* Update keyboards/handwired/symmetric70_proto/proton_c/rules.mk

Co-authored-by: Ryan <fauxpark@gmail.com>

* Update keyboards/handwired/symmetric70_proto/proton_c/rules.mk

Co-authored-by: Ryan <fauxpark@gmail.com>

* Update keyboards/handwired/symmetric70_proto/local_features.mk

Co-authored-by: Nick Brassel <nick@tzarc.org>

* Update keyboards/handwired/symmetric70_proto/local_features.mk

Co-authored-by: Nick Brassel <nick@tzarc.org>

* Update keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c

Co-authored-by: Nick Brassel <nick@tzarc.org>

* Update keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c

Co-authored-by: Nick Brassel <nick@tzarc.org>

* Update keyboards/handwired/symmetric70_proto/local_features.mk

Co-authored-by: Nick Brassel <nick@tzarc.org>

* Update keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c

Co-authored-by: Nick Brassel <nick@tzarc.org>

* Update keyboards/handwired/symmetric70_proto/matrix_debug/readme.md

Co-authored-by: Nick Brassel <nick@tzarc.org>

* Update keyboards/handwired/symmetric70_proto/matrix_debug/readme.md

Co-authored-by: Nick Brassel <nick@tzarc.org>

* Update keyboards/handwired/symmetric70_proto/matrix_debug/readme.md

Co-authored-by: Nick Brassel <nick@tzarc.org>

* Update keyboards/handwired/symmetric70_proto/matrix_fast/matrix_config_expand.c

Co-authored-by: Nick Brassel <nick@tzarc.org>

Co-authored-by: Ryan <fauxpark@gmail.com>
Co-authored-by: Nick Brassel <nick@tzarc.org>
2021-07-13 18:14:27 +09:00

5.7 KiB

Fast and extensible matrix.c

This matrix.c is faster and more extensible than the standard quantum/matrix.c.

  • The execution speed of the matrix_scan() function is several times faster than quantum/matrix.c.
  • In addition to handling MCU GPIOs, it can be extended to handle I/O extenders.

ToDo list

  • support Pro Micro
  • support Proton-C
  • support DIRECT_PINS
  • support DIODE_DIRECTION == ROW2COL
  • support 74HC157: quadruple 2-line to 1-line data selectors / multiplexers
  • support 74HC153: dual 4-line to 1-line data selectors / multiplexers
  • support I/O expander (MCP23018)
  • support MCU & I/O expander (MCP23018) mixture like ErgoDox

Configuration

This matrix.c requires a different configuration than quantum/matrix.c.

Output pins configuration

The output pins is the Row pins if DIODE_DIRECTION == COL2ROW, and the Col pins if DIODE_DIRECTION == ROW2COL. When DIRECT_PINS is defined, the output pins do not need to be set.

Example:

// list of OUTPUT(row) ports
#define MATRIX_OUT_PORTS  \
    (Port_D, MCU_GPIO, D0), \
    (Port_C, MCU_GPIO, C0), \
    (Port_E, MCU_GPIO, E0), \
    (Port_B, MCU_GPIO, B0)
// list of OUTPUT pins
#define MATRIX_OUT_PINS  \
    (0, Port_D, 4), \
    (1, Port_C, 6), \
    (2, Port_D, 7), \
    (3, Port_E, 6), \
    (4, Port_B, 4), \
    (5, Port_B, 5)

Input pins configuration

The input pins is the Col pins if DIODE_DIRECTION == COL2ROW, and the Row pins if DIODE_DIRECTION == ROW2COL. When DIRECT_PINS is defined, the input pin settings will enumerate the connection pins of all switches.

Example:

// list of INPUT ports
#define MATRIX_IN_PORTS (Port_F, MCU_GPIO, F0), (Port_B, MCU_GPIO, B0)
// list of INPUT pins
#define MATRIX_IN_PINS \
    (0, Port_F, 4), \
    (1, Port_F, 5), \
    (2, Port_F, 6), \
    (3, Port_F, 7), \
    (4, Port_B, 1), \
    (5, Port_B, 3)

Multiplexer Extension

By defining the MATRIX_EXTENSION_74HC157 macro or MATRIX_EXTENSION_74HC153 macro, you can connect a multiplexer to the GPIO to extend the input pins.

Example:

#define MATRIX_EXTENSION_74HC157 B2 /* or #define MATRIX_EXTENSION_74HC153 B2, B6 */

// list of OUTPUT ports
#define MATRIX_OUT_PORTS (Port_D, MCU_GPIO, D0), (Port_C, MCU_GPIO, C0), (Port_E, MCU_GPIO, E0), (Port_B, MCU_GPIO, B0)
// list of OUTPUT pins
#define MATRIX_OUT_PINS  (0, Port_D, 4), (1, Port_C, 6), (2, Port_D, 7), (3, Port_E, 6), (4, Port_B, 4), (5, Port_B, 5)

// list of INPUT ports
#define MATRIX_IN_PORTS \
    (Port_Fa, MCU_GPIOa, F0), \
    (Port_Ba, MCU_GPIOa, B0), \
    (Port_Fb, MCU_GPIOb, F0), \
    (Port_Bb, MCU_GPIOb, B0)
// list of INPUT pins
#define MATRIX_IN_PINS \
    (0, Port_Fa, 4), \
    (1, Port_Fb, 5), \
    (2, Port_Fb, 6), \
    (3, Port_Fa, 7), \
    (4, Port_Ba, 1), \
    (5, Port_Bb, 3)

I/O expander Extension

I plan to provide extensions to support I/O expanders such as MCP23018 and PCA9555.

Compile

  • Measure the execution time of matrix_scan()
    • make MTEST=matrix_debug_scan[,<other options>..] handwired/symmetric70_proto/promicro/fast:default:flash
  • Measure delay time.
    • make MTEST=matrix_debug_delay[,<other options>..] handwired/symmetric70_proto/promicro/fast:default:flash

Measurement result

Pro Micro (ATmega32u4 16Mhz)

Default setting (show matrix_scan() time)

  • make MTEST=matrix_debug_scan handwired/symmetric70_proto/promicro/fast:default:flash
  • CH1: Row 0
  • CH2: Row 1
  • CH3: Row 4
  • CH4: matrix_scan()
  • Execution time of matrix_scan() 75.6us
  • Frequency of matrix scan 8.09kHz (123.6us) DS1Z_QuickPrint7

Default setting (show delay time)

  • make MTEST=matrix_debug_delay handwired/symmetric70_proto/promicro/fast:default:flash
Press R0C0 key
  • CH1: Row 0
  • CH2: Row 1
  • CH3: Row 4
  • CH4: delay time
  • Frequency of matrix scan 7.84kHz (127.6us)

DS1Z_QuickPrint9 DS1Z_QuickPrint10

Proton C

Default setting (show matrix_scan() time)

  • make MTEST=matrix_debug_scan handwired/symmetric70_proto/proton_c/fast:default:flash
  • CH1: Row 0
  • CH2: Row 1
  • CH3: Row 4
  • CH4: matrix_scan()
  • Execution time of matrix_scan() 49.8us
  • Frequency of matrix scan 15.1kHz (66.2.6us)

DS1Z_QuickPrint11

Default setting (show delay time)

  • make MTEST=matrix_debug_delay handwired/symmetric70_proto/proton_c/fast:default:flash
Press R0C0 key
  • CH1: Row 0
  • CH2: Row 1
  • CH3: Row 4
  • CH4: delay time
  • Frequency of matrix scan 13.9kHz (71.8us)

DS1Z_QuickPrint12 DS1Z_QuickPrint13

Connect a 500pF capacitor between C0 line and GND, Press R0C0, R1C0, R2C0, R3C0, R4C0 keys
  • CH1: Row 0
  • CH2: Row 1
  • CH3: Col 0
  • CH4: delay time
  • Delay time 11.6us
  • Threshold Voltage 1.9V

DS1Z_QuickPrint14

Connect a 1000pF capacitor between C0 line and GND, Press R0C0, R1C0, R2C0, R3C0, R4C0 keys
  • CH1: Row 0
  • CH2: Row 1
  • CH3: Col 0
  • CH4: delay time
  • Delay time 18.6us
  • Threshold Voltage 1.9V

DS1Z_QuickPrint15