summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jael're <drashna@live.com>2022-11-08 17:14:27 -0800
committerDrashna Jael're <drashna@live.com>2022-11-08 17:14:27 -0800
commit64f04b30c2f48fc0e7c49ca043443f03dc56df94 (patch)
treee0f374d3b92bacefd22c31e7bda8ee1c6fcb37de
parentd9f575fa86ca10b990958d4e677c6a0a387dc7c3 (diff)
parent96c48a5f4aa461ed31fd4ee61151ac206e16fb5f (diff)
Merge tag '0.18.16' into firmware22
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.md36
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.yml41
-rw-r--r--.github/ISSUE_TEMPLATE/feature_request.md24
-rw-r--r--.github/ISSUE_TEMPLATE/feature_request.yml21
-rw-r--r--.github/ISSUE_TEMPLATE/other_issues.md14
-rw-r--r--.github/ISSUE_TEMPLATE/other_issues.yml16
-rw-r--r--.github/labeler.yml41
-rw-r--r--.github/stale.yml58
-rw-r--r--.github/workflows/auto_approve.yml18
-rw-r--r--.github/workflows/develop_update.yml30
-rw-r--r--.github/workflows/feature_branch_update.yml35
-rw-r--r--.github/workflows/format.yml2
-rw-r--r--.github/workflows/format_push.yml8
-rw-r--r--.github/workflows/labeler.yml14
-rw-r--r--.github/workflows/lint.yml5
-rw-r--r--.github/workflows/unit_test.yml2
-rw-r--r--.gitignore14
-rw-r--r--.gitmodules5
-rw-r--r--Makefile9
-rw-r--r--builddefs/bootloader.mk9
-rw-r--r--builddefs/build_keyboard.mk41
-rw-r--r--builddefs/build_test.mk7
-rw-r--r--builddefs/common_features.mk167
-rw-r--r--builddefs/common_rules.mk124
-rw-r--r--builddefs/generic_features.mk2
-rw-r--r--builddefs/mcu_selection.mk72
-rw-r--r--builddefs/show_options.mk2
-rw-r--r--builddefs/testlist.mk1
-rw-r--r--data/mappings/defaults.json38
-rw-r--r--data/mappings/info_config.json21
-rw-r--r--data/mappings/info_rules.json15
-rw-r--r--data/mappings/keyboard_aliases.json17
-rw-r--r--data/schemas/api_keyboard.jsonschema1
-rw-r--r--data/schemas/definitions.jsonschema41
-rw-r--r--data/schemas/keyboard.jsonschema177
-rw-r--r--data/schemas/keymap.jsonschema7
-rw-r--r--data/templates/keyboard/readme.md2
-rw-r--r--drivers/eeprom/eeprom_i2c.h5
-rw-r--r--drivers/eeprom/eeprom_spi.c42
-rw-r--r--drivers/eeprom/eeprom_wear_leveling.c23
-rw-r--r--drivers/flash/flash_spi.c8
-rw-r--r--drivers/gpio/pca9505.c166
-rw-r--r--drivers/gpio/pca9505.h67
-rw-r--r--drivers/led/aw20216.c6
-rw-r--r--drivers/led/ckled2001-simple.c218
-rw-r--r--drivers/led/ckled2001-simple.h337
-rw-r--r--drivers/led/ckled2001.c38
-rw-r--r--drivers/led/ckled2001.h4
-rw-r--r--drivers/led/issi/is31fl3733-simple.c6
-rw-r--r--drivers/led/issi/is31fl3733.c6
-rw-r--r--drivers/led/issi/is31fl3736.c6
-rw-r--r--drivers/led/issi/is31fl3737.c6
-rw-r--r--drivers/led/issi/is31fl3741.c6
-rw-r--r--drivers/oled/oled_driver.h2
-rw-r--r--drivers/painter/gc9a01/qp_gc9a01.c9
-rw-r--r--drivers/painter/ili9xxx/qp_ili9163.c9
-rw-r--r--drivers/painter/ili9xxx/qp_ili9341.c9
-rw-r--r--drivers/painter/ili9xxx/qp_ili9488.c120
-rw-r--r--drivers/painter/ili9xxx/qp_ili9488.h37
-rw-r--r--drivers/painter/ili9xxx/qp_ili9xxx_opcodes.h1
-rw-r--r--drivers/painter/ssd1351/qp_ssd1351.c9
-rw-r--r--drivers/painter/st77xx/qp_st7735.c144
-rw-r--r--drivers/painter/st77xx/qp_st7735.h45
-rw-r--r--drivers/painter/st77xx/qp_st7735_opcodes.h31
-rw-r--r--drivers/painter/st77xx/qp_st7789.c9
-rw-r--r--drivers/painter/tft_panel/qp_tft_panel.c60
-rw-r--r--drivers/painter/tft_panel/qp_tft_panel.h16
-rw-r--r--drivers/ps2/ps2.h1
-rw-r--r--drivers/ps2/ps2_interrupt.c19
-rw-r--r--drivers/ps2/ps2_mouse.c19
-rw-r--r--drivers/sensors/adns5050.h18
-rw-r--r--drivers/sensors/adns9800.h6
-rw-r--r--drivers/sensors/cirque_pinnacle.c289
-rw-r--r--drivers/sensors/cirque_pinnacle.h111
-rw-r--r--drivers/sensors/cirque_pinnacle_gestures.c238
-rw-r--r--drivers/sensors/cirque_pinnacle_gestures.h110
-rw-r--r--drivers/sensors/cirque_pinnacle_i2c.c4
-rw-r--r--drivers/sensors/cirque_pinnacle_regdefs.h405
-rw-r--r--drivers/sensors/cirque_pinnacle_spi.c4
-rw-r--r--drivers/sensors/paw3204.c172
-rw-r--r--drivers/sensors/paw3204.h76
-rw-r--r--drivers/sensors/pimoroni_trackball.c13
-rw-r--r--drivers/sensors/pimoroni_trackball.h1
-rw-r--r--drivers/sensors/pmw3360.c567
-rw-r--r--drivers/sensors/pmw3360.h134
-rw-r--r--drivers/sensors/pmw3360_firmware.h288
-rw-r--r--drivers/sensors/pmw3389.c580
-rw-r--r--drivers/sensors/pmw3389.h135
-rw-r--r--drivers/sensors/pmw3389_firmware.h307
-rw-r--r--drivers/sensors/pmw33xx_common.c219
-rw-r--r--drivers/sensors/pmw33xx_common.h156
-rw-r--r--drivers/serial.h10
-rw-r--r--drivers/wear_leveling/wear_leveling_flash_spi.c101
-rw-r--r--drivers/wear_leveling/wear_leveling_flash_spi_config.h34
-rw-r--r--keyboards/ergodox_ez/base/info.json6
-rw-r--r--keyboards/ergodox_ez/base/rules.mk0
-rw-r--r--keyboards/ergodox_ez/config.h7
-rw-r--r--keyboards/ergodox_ez/glow/config.h35
-rw-r--r--keyboards/ergodox_ez/glow/info.json6
-rw-r--r--keyboards/ergodox_ez/info.json6
-rw-r--r--keyboards/ergodox_ez/rules.mk2
-rw-r--r--keyboards/ergodox_ez/shine/config.h26
-rw-r--r--keyboards/ergodox_ez/shine/info.json6
-rwxr-xr-xkeyboards/ergodox_ez/util/compile_keymap.py110
-rw-r--r--keyboards/moonlander/config.h9
-rw-r--r--keyboards/moonlander/info.json6
-rw-r--r--keyboards/moonlander/keymaps/oryx/rules.mk2
-rw-r--r--keyboards/moonlander/matrix.c4
-rw-r--r--keyboards/moonlander/moonlander.c2
-rw-r--r--keyboards/moonlander/moonlander.h2
-rw-r--r--keyboards/moonlander/readme.md16
-rw-r--r--keyboards/planck/config.h6
-rw-r--r--keyboards/planck/ez/base/info.json6
-rw-r--r--keyboards/planck/ez/base/rules.mk0
-rw-r--r--keyboards/planck/ez/config.h13
-rw-r--r--keyboards/planck/ez/ez.c21
-rw-r--r--keyboards/planck/ez/glow/config.h25
-rw-r--r--keyboards/planck/ez/glow/info.json6
-rw-r--r--keyboards/planck/ez/glow/keymaps/glow/keymap.c2
-rw-r--r--keyboards/planck/ez/info.json6
-rwxr-xr-xkeyboards/planck/ez/rules.mk2
-rw-r--r--keyboards/planck/info.json1
-rw-r--r--keyboards/planck/keymaps/default/keymap.c2
-rw-r--r--keyboards/planck/keymaps/oryx/keymap.c4
-rw-r--r--keyboards/planck/planck.c10
m---------lib/chibios0
m---------lib/chibios-contrib0
-rw-r--r--lib/fnv/Makefile304
-rw-r--r--lib/fnv/README158
-rw-r--r--lib/fnv/fnv.h250
-rw-r--r--lib/fnv/fnv32.c467
-rw-r--r--lib/fnv/fnv64.c591
-rw-r--r--lib/fnv/hash_32.c156
-rw-r--r--lib/fnv/hash_32a.c144
-rw-r--r--lib/fnv/hash_64.c312
-rw-r--r--lib/fnv/hash_64a.c291
-rw-r--r--lib/fnv/have_ulong64.c58
-rw-r--r--lib/fnv/longlong.h18
-rw-r--r--lib/fnv/qmk_fnv_type_validation.c14
-rw-r--r--lib/fnv/test_fnv.c2237
m---------lib/lufa0
m---------lib/pico-sdk0
m---------lib/printf0
-rw-r--r--lib/python/qmk/c_parse.py46
-rw-r--r--lib/python/qmk/cli/__init__.py42
-rwxr-xr-xlib/python/qmk/cli/compile.py5
-rw-r--r--lib/python/qmk/cli/doctor/linux.py57
-rw-r--r--lib/python/qmk/cli/doctor/macos.py2
-rwxr-xr-xlib/python/qmk/cli/doctor/main.py26
-rw-r--r--lib/python/qmk/cli/flash.py121
-rwxr-xr-xlib/python/qmk/cli/generate/api.py37
-rwxr-xr-xlib/python/qmk/cli/generate/config_h.py36
-rw-r--r--lib/python/qmk/cli/generate/dfu_header.py4
-rwxr-xr-xlib/python/qmk/cli/generate/info_json.py8
-rwxr-xr-xlib/python/qmk/cli/generate/keyboard_h.py2
-rw-r--r--lib/python/qmk/cli/import/__init__.py0
-rw-r--r--lib/python/qmk/cli/import/kbfirmware.py25
-rw-r--r--lib/python/qmk/cli/import/keyboard.py23
-rw-r--r--lib/python/qmk/cli/import/keymap.py23
-rw-r--r--lib/python/qmk/cli/lint.py124
-rwxr-xr-xlib/python/qmk/cli/multibuild.py19
-rw-r--r--lib/python/qmk/constants.py63
-rw-r--r--lib/python/qmk/flashers.py203
-rw-r--r--lib/python/qmk/git.py28
-rw-r--r--lib/python/qmk/importers.py193
-rw-r--r--lib/python/qmk/info.py271
-rw-r--r--lib/python/qmk/json_schema.py6
-rw-r--r--lib/python/qmk/keyboard.py2
-rw-r--r--lib/python/qmk/keymap.py4
-rw-r--r--lib/python/qmk/submodules.py26
-rw-r--r--lib/python/qmk/tests/test_cli_commands.py26
m---------lib/vusb0
-rw-r--r--platforms/arm_atsam/flash.mk1
-rw-r--r--platforms/arm_atsam/platform.mk3
-rw-r--r--platforms/avr/_wait.h38
-rw-r--r--platforms/avr/drivers/i2c_master.c12
-rw-r--r--platforms/avr/drivers/i2c_master.h2
-rw-r--r--platforms/avr/drivers/ps2/ps2_usart.c4
-rw-r--r--platforms/avr/drivers/serial.c4
-rw-r--r--platforms/avr/drivers/ssd1306.c329
-rw-r--r--platforms/avr/drivers/ssd1306.h87
-rw-r--r--platforms/avr/flash.mk5
-rw-r--r--platforms/avr/platform.mk3
-rw-r--r--platforms/chibios/_pin_defs.h5
-rw-r--r--platforms/chibios/_wait.h6
-rw-r--r--platforms/chibios/boards/GENERIC_PROMICRO_RP2040/board/board.mk9
-rw-r--r--platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/board.h12
-rw-r--r--platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/chconf.h13
-rw-r--r--platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/config.h62
-rw-r--r--platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/mcuconf.h98
-rw-r--r--platforms/chibios/boards/GENERIC_RP_RP2040/board/board.mk9
-rw-r--r--platforms/chibios/boards/GENERIC_RP_RP2040/configs/board.h12
-rw-r--r--platforms/chibios/boards/GENERIC_RP_RP2040/configs/chconf.h13
-rw-r--r--platforms/chibios/boards/GENERIC_RP_RP2040/configs/mcuconf.h98
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F401XC/configs/mcuconf.h4
-rw-r--r--platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/config.h2
-rw-r--r--platforms/chibios/boards/QMK_PM2040/board/board.mk9
-rw-r--r--platforms/chibios/boards/QMK_PM2040/configs/board.h12
-rw-r--r--platforms/chibios/boards/QMK_PM2040/configs/chconf.h13
-rw-r--r--platforms/chibios/boards/QMK_PM2040/configs/config.h21
-rw-r--r--platforms/chibios/boards/QMK_PM2040/configs/halconf.h9
-rw-r--r--platforms/chibios/boards/QMK_PM2040/configs/mcuconf.h98
-rw-r--r--platforms/chibios/boards/STEMCELL/board/board.mk15
-rw-r--r--platforms/chibios/boards/STEMCELL/configs/board.h8
-rw-r--r--platforms/chibios/boards/STEMCELL/configs/chconf.h9
-rw-r--r--platforms/chibios/boards/STEMCELL/configs/config.h29
-rw-r--r--platforms/chibios/boards/STEMCELL/configs/halconf.h11
-rw-r--r--platforms/chibios/boards/STEMCELL/configs/mcuconf.h252
-rw-r--r--platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.c2
-rw-r--r--platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103x6_stm32duino_bootloader.ld23
-rw-r--r--platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103x8_stm32duino_bootloader.ld1
-rw-r--r--platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103xB_stm32duino_bootloader.ld1
-rw-r--r--platforms/chibios/boards/STM32_F103_STM32DUINO/ld/stm32duino_bootloader_common.ld2
-rw-r--r--platforms/chibios/boards/common/ld/RP2040_FLASH_TIMECRIT.ld117
-rw-r--r--platforms/chibios/boards/common/ld/RP2040_rules_data_with_timecrit.ld46
-rw-r--r--platforms/chibios/bootloaders/rp2040.c56
-rw-r--r--platforms/chibios/bootloaders/stm32_dfu.c4
-rw-r--r--platforms/chibios/chibios_config.h50
-rw-r--r--platforms/chibios/converters/promicro_to_bit_c_pro/_pin_defs.h36
-rw-r--r--platforms/chibios/converters/promicro_to_bit_c_pro/converter.mk12
-rw-r--r--platforms/chibios/converters/promicro_to_blok/_pin_defs.h36
-rw-r--r--platforms/chibios/converters/promicro_to_blok/converter.mk9
-rw-r--r--platforms/chibios/converters/promicro_to_bonsai_c4/_pin_defs.h40
-rw-r--r--platforms/chibios/converters/promicro_to_bonsai_c4/converter.mk4
-rw-r--r--platforms/chibios/converters/promicro_to_kb2040/_pin_defs.h36
-rw-r--r--platforms/chibios/converters/promicro_to_kb2040/converter.mk9
-rw-r--r--platforms/chibios/converters/promicro_to_promicro_rp2040/_pin_defs.h36
-rw-r--r--platforms/chibios/converters/promicro_to_promicro_rp2040/converter.mk9
-rw-r--r--platforms/chibios/converters/promicro_to_stemcell/_pin_defs.h51
-rw-r--r--platforms/chibios/converters/promicro_to_stemcell/converter.mk18
-rw-r--r--platforms/chibios/drivers/eeprom/eeprom_stm32.c (renamed from platforms/chibios/eeprom_stm32.c)18
-rw-r--r--platforms/chibios/drivers/eeprom/eeprom_stm32.h (renamed from platforms/chibios/eeprom_stm32.h)0
-rw-r--r--platforms/chibios/drivers/eeprom/eeprom_stm32_defs.h (renamed from platforms/chibios/eeprom_stm32_defs.h)0
-rw-r--r--platforms/chibios/drivers/eeprom/eeprom_teensy.c (renamed from platforms/chibios/eeprom_teensy.c)0
-rwxr-xr-xplatforms/chibios/drivers/eeprom/eeprom_teensy.h (renamed from platforms/chibios/eeprom_teensy.h)0
-rw-r--r--platforms/chibios/drivers/flash/flash_stm32.c (renamed from platforms/chibios/flash_stm32.c)0
-rw-r--r--platforms/chibios/drivers/flash/flash_stm32.h (renamed from platforms/chibios/flash_stm32.h)0
-rw-r--r--platforms/chibios/drivers/i2c_master.c39
-rw-r--r--platforms/chibios/drivers/serial.c18
-rw-r--r--platforms/chibios/drivers/serial_protocol.c164
-rw-r--r--platforms/chibios/drivers/serial_protocol.h49
-rw-r--r--platforms/chibios/drivers/serial_usart.c322
-rw-r--r--platforms/chibios/drivers/serial_usart.h118
-rw-r--r--platforms/chibios/drivers/spi_master.c39
-rw-r--r--platforms/chibios/drivers/vendor/RP/RP2040/serial_vendor.c473
-rw-r--r--platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c189
-rw-r--r--platforms/chibios/drivers/wear_leveling/wear_leveling_efl.c143
-rw-r--r--platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h52
-rw-r--r--platforms/chibios/drivers/wear_leveling/wear_leveling_legacy.c59
-rw-r--r--platforms/chibios/drivers/wear_leveling/wear_leveling_legacy_config.h67
-rw-r--r--platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c221
-rw-r--r--platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash_config.h32
-rw-r--r--platforms/chibios/drivers/ws2812.c2
-rw-r--r--platforms/chibios/drivers/ws2812_pwm.c59
-rw-r--r--platforms/chibios/drivers/ws2812_spi.c14
-rw-r--r--platforms/chibios/drivers/wt_rgb_backlight.c9
-rw-r--r--platforms/chibios/drivers/wt_rgb_backlight.h1
-rw-r--r--platforms/chibios/flash.mk12
-rw-r--r--platforms/chibios/gd32v_compatibility.h2
-rw-r--r--platforms/chibios/platform.mk27
-rw-r--r--platforms/chibios/vendors/RP/RP2040.mk287
-rw-r--r--platforms/chibios/vendors/RP/_pin_defs.h37
-rw-r--r--platforms/chibios/vendors/RP/pico_sdk_shims.c13
-rw-r--r--platforms/chibios/vendors/RP/stage2_bootloaders.c178
-rw-r--r--platforms/eeprom.h2
-rw-r--r--platforms/synchronization_util.h34
-rw-r--r--platforms/test/platform.mk2
-rw-r--r--platforms/test/rules.mk5
-rw-r--r--quantum/action.c15
-rw-r--r--quantum/action.h1
-rw-r--r--quantum/action_code.h1
-rw-r--r--quantum/action_layer.c14
-rw-r--r--quantum/action_layer.h2
-rw-r--r--quantum/action_tapping.c12
-rw-r--r--quantum/audio/song_list.h6
-rw-r--r--quantum/command.c4
-rw-r--r--quantum/command.h2
-rw-r--r--quantum/debounce.h16
-rw-r--r--quantum/debounce/asym_eager_defer_pk.c11
-rw-r--r--quantum/debounce/none.c11
-rw-r--r--quantum/debounce/sym_defer_g.c12
-rw-r--r--quantum/debounce/sym_defer_pk.c12
-rw-r--r--quantum/debounce/sym_defer_pr.c14
-rw-r--r--quantum/debounce/sym_eager_pk.c7
-rw-r--r--quantum/debounce/sym_eager_pr.c11
-rw-r--r--quantum/debounce/tests/debounce_test_common.cpp6
-rw-r--r--quantum/dynamic_keymap.c41
-rw-r--r--quantum/encoder.c31
-rw-r--r--quantum/keyboard.c147
-rw-r--r--quantum/keyboard.h8
-rw-r--r--quantum/keycode_config.c4
-rw-r--r--quantum/keycode_config.h1
-rw-r--r--quantum/keymap.h7
-rw-r--r--quantum/keymap_common.c8
-rw-r--r--quantum/keymap_extras/keymap_bepo.h167
-rw-r--r--quantum/keymap_extras/keymap_czech.h2
-rw-r--r--quantum/keymap_extras/keymap_japanese.h4
-rw-r--r--quantum/keymap_extras/keymap_korean.h2
-rw-r--r--quantum/keymap_extras/keymap_latvian.h4
-rw-r--r--quantum/keymap_extras/keymap_lithuanian_qwerty.h50
-rw-r--r--quantum/keymap_extras/keymap_norman.h2
-rw-r--r--quantum/keymap_extras/keymap_spanish_dvorak.h4
-rw-r--r--quantum/keymap_extras/keymap_steno.h45
-rw-r--r--quantum/keymap_extras/keymap_turkish_f.h2
-rw-r--r--quantum/keymap_extras/keymap_us_extended.h2
-rw-r--r--quantum/keymap_introspection.c32
-rw-r--r--quantum/keymap_introspection.h15
-rw-r--r--quantum/led.c12
-rw-r--r--quantum/led.h3
-rw-r--r--quantum/led_matrix/led_matrix.c12
-rw-r--r--quantum/led_matrix/led_matrix.h4
-rw-r--r--quantum/led_matrix/led_matrix_drivers.c51
-rw-r--r--quantum/logging/print.c2
-rw-r--r--quantum/logging/print.h68
-rw-r--r--quantum/logging/print.mk17
-rw-r--r--quantum/matrix.c5
-rw-r--r--quantum/matrix_common.c7
-rw-r--r--quantum/mousekey.c35
-rw-r--r--quantum/mousekey.h5
-rw-r--r--quantum/painter/qp.h8
-rw-r--r--quantum/painter/qp_draw_core.c14
-rw-r--r--quantum/painter/rules.mk24
-rw-r--r--quantum/pointing_device/pointing_device.c (renamed from quantum/pointing_device.c)51
-rw-r--r--quantum/pointing_device/pointing_device.h (renamed from quantum/pointing_device.h)21
-rw-r--r--quantum/pointing_device/pointing_device_drivers.c368
-rw-r--r--quantum/pointing_device/pointing_device_gestures.c133
-rw-r--r--quantum/pointing_device/pointing_device_gestures.h58
-rw-r--r--quantum/pointing_device_drivers.c295
-rw-r--r--quantum/process_keycode/process_auto_shift.c4
-rw-r--r--quantum/process_keycode/process_auto_shift.h8
-rw-r--r--quantum/process_keycode/process_caps_word.c34
-rw-r--r--quantum/process_keycode/process_combo.c9
-rw-r--r--quantum/process_keycode/process_dynamic_macro.c3
-rw-r--r--quantum/process_keycode/process_dynamic_tapping_term.c2
-rw-r--r--quantum/process_keycode/process_joystick.c2
-rw-r--r--quantum/process_keycode/process_leader.c1
-rw-r--r--quantum/process_keycode/process_magic.c10
-rw-r--r--quantum/process_keycode/process_rgb.c4
-rw-r--r--quantum/process_keycode/process_steno.c312
-rw-r--r--quantum/process_keycode/process_steno.h24
-rw-r--r--quantum/process_keycode/process_tap_dance.c137
-rw-r--r--quantum/process_keycode/process_tap_dance.h33
-rw-r--r--quantum/process_keycode/process_terminal.c330
-rw-r--r--quantum/process_keycode/process_unicode_common.c40
-rw-r--r--quantum/process_keycode/process_unicode_common.h1
-rw-r--r--quantum/quantum.c27
-rw-r--r--quantum/quantum.h12
-rw-r--r--quantum/quantum_keycodes.h28
-rw-r--r--quantum/quantum_keycodes_legacy.h3
-rw-r--r--quantum/rgb_matrix/animations/pixel_fractal_anim.h78
-rw-r--r--quantum/rgb_matrix/animations/pixel_rain_anim.h14
-rw-r--r--quantum/rgb_matrix/animations/raindrops_anim.h15
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_anim.h3
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_cross.h3
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_nexus.h3
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_simple_anim.h3
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_wide.h3
-rw-r--r--quantum/rgb_matrix/animations/typing_heatmap_anim.h88
-rw-r--r--quantum/rgb_matrix/rgb_matrix.c15
-rw-r--r--quantum/rgb_matrix/rgb_matrix.h1
-rw-r--r--quantum/send_string.h54
-rw-r--r--quantum/send_string/send_string.c (renamed from quantum/send_string.c)126
-rw-r--r--quantum/send_string/send_string.h152
-rw-r--r--quantum/send_string/send_string_keycodes.h436
-rw-r--r--quantum/send_string_keycodes.h505
-rw-r--r--quantum/split_common/split_util.c12
-rw-r--r--quantum/split_common/transactions.c18
-rw-r--r--quantum/split_common/transport.h9
-rw-r--r--quantum/via.c33
-rw-r--r--quantum/via.h6
-rw-r--r--quantum/wear_leveling/tests/backing_mocks.cpp154
-rw-r--r--quantum/wear_leveling/tests/backing_mocks.hpp210
-rw-r--r--quantum/wear_leveling/tests/rules.mk66
-rw-r--r--quantum/wear_leveling/tests/testlist.mk6
-rw-r--r--quantum/wear_leveling/tests/wear_leveling_2byte.cpp228
-rw-r--r--quantum/wear_leveling/tests/wear_leveling_2byte_optimized_writes.cpp295
-rw-r--r--quantum/wear_leveling/tests/wear_leveling_4byte.cpp193
-rw-r--r--quantum/wear_leveling/tests/wear_leveling_8byte.cpp178
-rw-r--r--quantum/wear_leveling/tests/wear_leveling_general.cpp204
-rw-r--r--quantum/wear_leveling/wear_leveling.c768
-rw-r--r--quantum/wear_leveling/wear_leveling.h54
-rw-r--r--quantum/wear_leveling/wear_leveling_internal.h151
-rw-r--r--readme.md2
-rw-r--r--requirements.txt3
-rw-r--r--shell.nix32
-rw-r--r--tests/auto_shift/test_auto_shift.cpp1
-rw-r--r--tests/basic/test_keypress.cpp22
-rw-r--r--tests/caps_word/caps_word_autoshift/test_caps_word_autoshift.cpp64
-rw-r--r--tests/caps_word/caps_word_combo/config.h20
-rw-r--r--tests/caps_word/caps_word_combo/test.mk19
-rw-r--r--tests/caps_word/caps_word_combo/test_caps_word_combo.cpp212
-rw-r--r--tests/caps_word/test_caps_word.cpp159
-rw-r--r--tests/tap_dance/config.h (renamed from quantum/process_keycode/process_terminal_nop.h)7
-rw-r--r--tests/tap_dance/examples.c199
-rw-r--r--tests/tap_dance/examples.h (renamed from quantum/process_keycode/process_terminal.h)21
-rw-r--r--tests/tap_dance/test.mk22
-rw-r--r--tests/tap_dance/test_examples.cpp318
-rw-r--r--tests/tap_hold_configurations/default_mod_tap/test_tap_hold.cpp8
-rw-r--r--tests/tap_hold_configurations/ignore_mod_tap_interrupt/test_tap_hold.cpp24
-rw-r--r--tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp6
-rw-r--r--tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp20
-rw-r--r--tests/tap_hold_configurations/permissive_hold_ignore_mod_tap_interrupt/test_tap_hold.cpp20
-rw-r--r--tests/tap_hold_configurations/retro_tapping/test_tap_hold.cpp8
-rw-r--r--tests/tap_hold_configurations/retro_tapping/test_tapping.cpp28
-rw-r--r--tests/tap_hold_configurations/tapping_force_hold/test_action_layer.cpp4
-rw-r--r--tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp40
-rw-r--r--tests/test_common/test_fixture.cpp16
-rw-r--r--tests/test_common/test_fixture.hpp7
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix.c2
-rw-r--r--tmk_core/protocol/chibios/usb_main.c152
-rw-r--r--tmk_core/protocol/host.c5
-rw-r--r--tmk_core/protocol/midi/midi.c4
-rw-r--r--tmk_core/protocol/report.h18
-rw-r--r--tmk_core/protocol/serial.h46
-rw-r--r--tmk_core/protocol/serial_soft.c234
-rw-r--r--tmk_core/protocol/serial_uart.c133
-rw-r--r--tmk_core/protocol/usb_descriptor.c18
-rw-r--r--tmk_core/protocol/usb_descriptor.h15
-rw-r--r--tmk_core/protocol/vusb/vusb.c16
-rwxr-xr-xutil/chibios_conf_updater.sh12
-rwxr-xr-xutil/docker_build.sh2
-rwxr-xr-xutil/docker_cmd.sh2
-rwxr-xr-xutil/install/fedora.sh6
-rwxr-xr-xutil/install/msys2.sh13
-rw-r--r--util/nix/poetry.lock675
-rw-r--r--util/nix/pyproject.toml29
-rw-r--r--util/nix/sources.json6
-rwxr-xr-xutil/size_regression.sh11
-rw-r--r--util/udev/50-qmk.rules9
-rwxr-xr-xutil/uf2conv.py3
-rwxr-xr-xutil/update_chibios_mirror.sh2
431 files changed, 21317 insertions, 6386 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
deleted file mode 100644
index 81561eaba6..0000000000
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ /dev/null
@@ -1,36 +0,0 @@
----
-name: Bug report
-about: Create a report to help us improve QMK Firmware.
-title: "[Bug] "
-labels: bug, help wanted
-assignees: ''
-
----
-
-<!-- Provide a general summary of the bug in the title above. -->
-
-<!--- This template is entirely optional and can be removed, but is here to help both you and us. -->
-<!--- Anything on lines wrapped in comments like these will not show up in the final text. -->
-
-## Describe the Bug
-
-<!-- A clear and concise description of what the bug is. -->
-
-## System Information
-
-**Keyboard:**
-**Revision (if applicable):**
-**Operating system:**
-**`qmk doctor` output:**
-```
-(Paste output here)
-```
-
-**Any keyboard related software installed?**
- - [ ] AutoHotKey (Windows)
- - [ ] Karabiner (macOS)
- - [ ] Other:
-
-## Additional Context
-
-<!-- Add any other relevant information about the problem here. -->
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
new file mode 100644
index 0000000000..a5d185e1dd
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -0,0 +1,41 @@
+name: Bug report
+description: Create a report to help us improve QMK Firmware.
+title: "[Bug] "
+labels: ["bug", "help wanted"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ Provide a general summary of the bug in the title above.
+ - type: textarea
+ attributes:
+ label: Describe the Bug
+ description: A clear and concise description of what the bug is.
+ - type: input
+ attributes:
+ label: Keyboard Used
+ description: The name of the keyboard from the `make` or `qmk compile`/`qmk flash` commands, eg. `planck/rev6`.
+ - type: input
+ attributes:
+ label: Link to product page (if applicable)
+ - type: input
+ attributes:
+ label: Operating System
+ - type: textarea
+ attributes:
+ label: qmk doctor Output
+ description: Output from running the `qmk doctor` command.
+ render: text
+ - type: checkboxes
+ attributes:
+ label: Is AutoHotKey / Karabiner installed
+ options:
+ - label: AutoHotKey (Windows)
+ - label: Karabiner (macOS)
+ - type: input
+ attributes:
+ label: Other keyboard-related software installed
+ - type: textarea
+ attributes:
+ label: Additional Context
+ description: Add any other relevant information about the problem here. \ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index 1876834247..0000000000
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,24 +0,0 @@
----
-name: Feature request
-about: Suggest a new feature or changes to existing features.
-title: "[Feature Request] "
-labels: enhancement, help wanted
-assignees: ''
-
----
-
-<!--- Provide a general summary of the changes you want in the title above. -->
-
-<!--- This template is entirely optional and can be removed, but is here to help both you and us. -->
-<!--- Anything on lines wrapped in comments like these will not show up in the final text. -->
-
-## Feature Request Type
-
-- [ ] Core functionality
-- [ ] Add-on hardware support (eg. audio, RGB, OLED screen, etc.)
-- [ ] Alteration (enhancement/optimization) of existing feature(s)
-- [ ] New behavior
-
-## Description
-
-<!-- A few sentences describing what it is that you'd like to see in QMK. Additional information (such as links to spec sheets, licensing info, other related issues or PRs, etc) would be helpful. -->
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
new file mode 100644
index 0000000000..585bcf2e6f
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -0,0 +1,21 @@
+name: Feature request
+description: Suggest a new feature or changes to existing features.
+title: "[Feature Request] "
+labels: ["enhancement", "help wanted"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ Provide a general summary of the changes you want in the title above.
+ - type: checkboxes
+ attributes:
+ label: Feature Request Type
+ options:
+ - label: Core functionality
+ - label: Add-on hardware support (eg. audio, RGB, OLED screen, etc.)
+ - label: Alteration (enhancement/optimization) of existing feature(s)
+ - label: New behavior
+ - type: textarea
+ attributes:
+ label: Description
+ description: A few sentences describing what it is that you'd like to see in QMK. Additional information (such as links to spec sheets, licensing info, other related issues or PRs, etc) would be helpful. \ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/other_issues.md b/.github/ISSUE_TEMPLATE/other_issues.md
deleted file mode 100644
index befeeb165a..0000000000
--- a/.github/ISSUE_TEMPLATE/other_issues.md
+++ /dev/null
@@ -1,14 +0,0 @@
----
-name: Other issues
-about: Anything else that doesn't fall into the above categories.
-title: ''
-labels: help wanted, question
-assignees: ''
-
----
-
-<!--- Provide a general summary of the changes you want in the title above. -->
-
-<!--- Anything on lines wrapped in comments like these will not show up in the final text. -->
-
-<!-- Please check https://docs.qmk.fm/#/support for additional resources first. If that doesn't answer your question, choose the bug report template instead, as that may be more appropriate. -->
diff --git a/.github/ISSUE_TEMPLATE/other_issues.yml b/.github/ISSUE_TEMPLATE/other_issues.yml
new file mode 100644
index 0000000000..7c4fbeb23c
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/other_issues.yml
@@ -0,0 +1,16 @@
+name: Other issues
+description: Anything else that doesn't fall into the above categories.
+labels: ["help wanted", "question"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ Provide a general summary of the changes you want in the title above.
+ - type: markdown
+ attributes:
+ value: |
+ Please check [https://docs.qmk.fm/#/support](https://docs.qmk.fm/#/support) for additional resources first. If that doesn't answer your question, choose the bug report template instead, as that may be more appropriate.
+ - type: textarea
+ attributes:
+ label: Issue Description
+ description: Describe your issue in as much detail as possible. \ No newline at end of file
diff --git a/.github/labeler.yml b/.github/labeler.yml
deleted file mode 100644
index 41b2475f67..0000000000
--- a/.github/labeler.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-core:
- - quantum/**/*
- - tmk_core/**/*
- - drivers/**/*
- - tests/**/*
- - util/**/*
- - platforms/**/*
- - Makefile
- - '*.mk'
-dependencies:
- - any:
- - 'lib/**/*'
- - '!lib/python/**/*'
-keyboard:
- - any:
- - 'keyboards/**/*'
- - '!keyboards/**/keymaps/**/*'
-keymap:
- - users/**/*
- - layouts/**/*
- - keyboards/**/keymaps/**/*
-via:
- - keyboards/**/keymaps/via/*
-cli:
- - requirements.txt
- - lib/python/**/*
-python:
- - '**/*.py'
-documentation:
- - docs/**/*
-translation:
- - docs/fr-fr/**/*
- - docs/es/**/*
- - docs/ja/**/*
- - docs/he-il/**/*
- - docs/pt-br/**/*
- - docs/zh-cn/**/*
- - docs/de/**/*
- - docs/ru-ru/**/*
-CI:
- - .github/**/*
diff --git a/.github/stale.yml b/.github/stale.yml
deleted file mode 100644
index eb49888191..0000000000
--- a/.github/stale.yml
+++ /dev/null
@@ -1,58 +0,0 @@
-# Configuration for probot-stale - https://github.com/probot/stale
-
-# General configuration
-
-# Pull request specific configuration
-pulls:
- staleLabel: awaiting changes
- # Number of days of inactivity before an Issue or Pull Request becomes stale
- daysUntilStale: 45
- # Number of days of inactivity before a stale Issue or Pull Request is closed.
- # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
- daysUntilClose: 30
- # Comment to post when marking as stale. Set to `false` to disable
- markComment: >
- Thank you for your contribution!
-
- This pull request has been automatically marked as stale because it has not had
- activity in the last 45 days. It will be closed in 30 days if no further activity occurs.
- Please feel free to give a status update now, or re-open when it's ready.
-
- For maintainers: Please label with `awaiting review`, `breaking_change`, `in progress`, or `on hold` to prevent
- the issue from being re-flagged.
- # Comment to post when closing a stale Issue or Pull Request.
- closeComment: >
- Thank you for your contribution!
-
- This pull request has been automatically closed because it has not had activity in the last 30 days.
- Please feel free to give a status update now, ping for review, or re-open when it's ready.
- # Limit the number of actions per hour, from 1-30. Default is 30
- limitPerRun: 30
- exemptLabels:
- - awaiting review
- - breaking_change
- - in progress
- - on hold
-
-# Issue specific configuration
-issues:
- staleLabel: stale
- limitPerRun: 10
- daysUntilStale: 90
- daysUntilClose: 30
- markComment: >
- This issue has been automatically marked as stale because it has not had activity in the
- last 90 days. It will be closed in the next 30 days unless it is tagged properly or other activity
- occurs.
-
- For maintainers: Please label with `bug`, `in progress`, `on hold`, `discussion` or `to do` to prevent
- the issue from being re-flagged.
- closeComment: >
- This issue has been automatically closed because it has not had activity in the last 30 days.
- If this issue is still valid, re-open the issue and let us know.
- exemptLabels:
- - bug
- - in progress
- - on hold
- - discussion
- - to do
diff --git a/.github/workflows/auto_approve.yml b/.github/workflows/auto_approve.yml
deleted file mode 100644
index dea3f017dd..0000000000
--- a/.github/workflows/auto_approve.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-name: Automatic Approve
-
-on:
- schedule:
- - cron: "*/5 * * * *"
-
-jobs:
- automatic_approve:
- runs-on: ubuntu-latest
-
- if: github.repository == 'qmk/qmk_firmware'
-
- steps:
- - uses: mheap/automatic-approve-action@v1
- with:
- token: ${{ secrets.QMK_BOT_TOKEN }}
- workflows: "format.yml,lint.yml,unit_test.yml"
- dangerous_files: "lib/python/,Makefile,paths.mk,builddefs/"
diff --git a/.github/workflows/develop_update.yml b/.github/workflows/develop_update.yml
deleted file mode 100644
index 90159406a6..0000000000
--- a/.github/workflows/develop_update.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-name: Update develop after master merge
-
-on:
- push:
- branches:
- - master
-
-jobs:
- develop_update:
- runs-on: ubuntu-latest
-
- if: github.repository == 'qmk/qmk_firmware'
-
- steps:
- - uses: actions/checkout@v2
- with:
- token: ${{ secrets.QMK_BOT_TOKEN }}
- fetch-depth: 0
-
- - name: Checkout develop
- run: |
- git fetch origin master develop
- git checkout develop
-
- - name: Update develop from master
- run: |
- git config --global user.name "QMK Bot"
- git config --global user.email "hello@qmk.fm"
- git merge origin/master
- git push origin develop
diff --git a/.github/workflows/feature_branch_update.yml b/.github/workflows/feature_branch_update.yml
deleted file mode 100644
index 98d3616ad1..0000000000
--- a/.github/workflows/feature_branch_update.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-name: Update feature branches after develop merge
-
-on:
- push:
- branches:
- - develop
-
-jobs:
- feature_branch_update:
- runs-on: ubuntu-latest
-
- if: github.repository == 'qmk/qmk_firmware'
-
- strategy:
- matrix:
- branch:
- - xap
-
- steps:
- - uses: actions/checkout@v2
- with:
- token: ${{ secrets.QMK_BOT_TOKEN }}
- fetch-depth: 0
-
- - name: Checkout branch
- run: |
- git fetch origin develop ${{ matrix.branch }}
- git checkout ${{ matrix.branch }}
-
- - name: Update branch from develop
- run: |
- git config --global user.name "QMK Bot"
- git config --global user.email "hello@qmk.fm"
- git merge origin/develop
- git push origin ${{ matrix.branch }}
diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml
index ba0a86aa78..b6ce4063fe 100644
--- a/.github/workflows/format.yml
+++ b/.github/workflows/format.yml
@@ -19,7 +19,7 @@ jobs:
container: qmkfm/qmk_cli
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
fetch-depth: 0
diff --git a/.github/workflows/format_push.yml b/.github/workflows/format_push.yml
index 2f5b679499..f9c691bdd4 100644
--- a/.github/workflows/format_push.yml
+++ b/.github/workflows/format_push.yml
@@ -12,10 +12,14 @@ jobs:
container: qmkfm/qmk_cli
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
fetch-depth: 0
+ - name: Disable automatic eol conversion
+ run: |
+ echo "* -text" > .git/info/attributes
+
- name: Install dependencies
run: |
pip3 install -r requirements-dev.txt
@@ -36,7 +40,7 @@ jobs:
git config user.email 'hello@qmk.fm'
- name: Create Pull Request
- uses: peter-evans/create-pull-request@v3
+ uses: peter-evans/create-pull-request@v4
if: ${{ github.repository == 'qmk/qmk_firmware'}}
with:
token: ${{ secrets.QMK_BOT_TOKEN }}
diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml
deleted file mode 100644
index 3b99a8f43e..0000000000
--- a/.github/workflows/labeler.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-name: "Pull Request Labeler"
-
-on:
- pull_request_target:
- types: [opened, synchronize, reopened, ready_for_review, locked]
-
-jobs:
- triage:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/labeler@main
- with:
- repo-token: "${{ secrets.GITHUB_TOKEN }}"
- configuration-path: '.github/labeler.yml'
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index c7a8624ee1..5b8a45f26b 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -12,10 +12,13 @@ jobs:
container: qmkfm/qmk_cli
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
fetch-depth: 0
+ - name: Install dependencies
+ run: pip3 install -r requirements-dev.txt
+
- uses: trilom/file-changes-action@v1.2.4
id: file_changes
with:
diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml
index 60d51ce321..6f03a976ea 100644
--- a/.github/workflows/unit_test.yml
+++ b/.github/workflows/unit_test.yml
@@ -22,7 +22,7 @@ jobs:
container: qmkfm/qmk_cli
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
submodules: recursive
- name: Install dependencies
diff --git a/.gitignore b/.gitignore
index 4473e291b7..7ccdefa656 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,10 @@
.DS_Store
._*
+# Merge files
+*.orig
+*.rej
+
# Build artifacts
.clang_complete
.build/
@@ -27,7 +31,11 @@ quantum/version.h
*.uf2
# Old-style QMK Makefiles
-/keyboards/*/Makefile
+/keyboards/**/Makefile
+
+# kbfirmware....
+/keyboards/**/kb.h
+/keyboards/**/kb.c
# Eclipse/PyCharm/Other IDE Settings
*.iml
@@ -58,10 +66,12 @@ CMakeLists.txt
.vscode/temp.sql
tags
-# Ignore image files
+# Ignore image/font files
*.gif
*.jpg
*.png
+*.ttf
+*.otf
# Things Travis sees
/.vs
diff --git a/.gitmodules b/.gitmodules
index 82b3c2a79b..48c7035afa 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -11,10 +11,13 @@
url = https://github.com/qmk/googletest
[submodule "lib/lufa"]
path = lib/lufa
- url = https://github.com/zsa/lufa
+ url = https://github.com/qmk/lufa
[submodule "lib/vusb"]
path = lib/vusb
url = https://github.com/qmk/v-usb
[submodule "lib/printf"]
path = lib/printf
url = https://github.com/qmk/printf
+[submodule "lib/pico-sdk"]
+ path = lib/pico-sdk
+ url = https://github.com/qmk/pico-sdk.git
diff --git a/Makefile b/Makefile
index a9690c88f7..30081cf4e7 100644
--- a/Makefile
+++ b/Makefile
@@ -276,7 +276,7 @@ define PARSE_KEYMAP
# The rest of the rule is the target
# Remove the leading ":" from the target, as it acts as a separator
MAKE_TARGET := $$(patsubst :%,%,$$(RULE))
- # We need to generate an unique indentifer to append to the COMMANDS list
+ # We need to generate an unique identifier to append to the COMMANDS list
CURRENT_KB_UNDER := $$(subst /,_,$$(CURRENT_KB))
COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB_UNDER)_KEYMAP_$$(CURRENT_KM)
# If we are compiling a keyboard without a subproject, we want to display just the name
@@ -413,6 +413,7 @@ ifndef SKIP_GIT
if [ ! -e lib/lufa ]; then git submodule sync lib/lufa && git submodule update --depth 50 --init lib/lufa; fi
if [ ! -e lib/vusb ]; then git submodule sync lib/vusb && git submodule update --depth 50 --init lib/vusb; fi
if [ ! -e lib/printf ]; then git submodule sync lib/printf && git submodule update --depth 50 --init lib/printf; fi
+ if [ ! -e lib/pico-sdk ]; then git submodule sync lib/pico-sdk && git submodule update --depth 50 --init lib/pico-sdk; fi
git submodule status --recursive 2>/dev/null | \
while IFS= read -r x; do \
case "$$x" in \
@@ -440,9 +441,15 @@ lib/%:
.PHONY: git-submodule
git-submodule:
+ [ -e lib/ugfx ] && rm -rf lib/ugfx || true
+ [ -e lib/pico-sdk ] && rm -rf lib/pico-sdk || true
+ [ -e lib/chibios-contrib/ext/mcux-sdk ] && rm -rf lib/chibios-contrib/ext/mcux-sdk || true
git submodule sync --recursive
git submodule update --init --recursive --progress
+.PHONY: git-submodules
+git-submodules: git-submodule
+
.PHONY: list-keyboards
list-keyboards:
util/list_keyboards.sh | sort -u | tr '\n' ' '
diff --git a/builddefs/bootloader.mk b/builddefs/bootloader.mk
index eba8e280e4..9f55536423 100644
--- a/builddefs/bootloader.mk
+++ b/builddefs/bootloader.mk
@@ -105,8 +105,8 @@ ifeq ($(strip $(BOOTLOADER)), halfkay)
ifeq ($(strip $(MCU)), at90usb1286)
BOOTLOADER_SIZE = 1024
endif
- # Teensy LC, 3.x
- ifneq (,$(filter $(MCU_ORIG), MKL26Z64 MK20DX128 MK20DX256 MK66FX1M0))
+ # Teensy LC, 3.0, 3.1/2, 3.5, 3.6
+ ifneq (,$(filter $(MCU_ORIG), MKL26Z64 MK20DX128 MK20DX256 MK64FX512 MK66FX1M0))
FIRMWARE_FORMAT = hex
endif
endif
@@ -199,6 +199,11 @@ endif
ifeq ($(strip $(BOOTLOADER)), tinyuf2)
OPT_DEFS += -DBOOTLOADER_TINYUF2
BOOTLOADER_TYPE = tinyuf2
+ FIRMWARE_FORMAT = uf2
+endif
+ifeq ($(strip $(BOOTLOADER)), rp2040)
+ OPT_DEFS += -DBOOTLOADER_RP2040
+ BOOTLOADER_TYPE = rp2040
endif
ifeq ($(strip $(BOOTLOADER)), halfkay)
OPT_DEFS += -DBOOTLOADER_HALFKAY
diff --git a/builddefs/build_keyboard.mk b/builddefs/build_keyboard.mk
index dc86b232df..6841c27c0f 100644
--- a/builddefs/build_keyboard.mk
+++ b/builddefs/build_keyboard.mk
@@ -13,6 +13,14 @@ endif
include paths.mk
include $(BUILDDEFS_PATH)/message.mk
+# Helper to add defines with a 'QMK_' prefix
+define add_qmk_prefix_defs
+ ifdef $1
+ # Need to cater for 'STM32L4xx+'
+ OPT_DEFS += -DQMK_$(2)="$($1)" -DQMK_$(2)_$(shell echo $($1) | sed -e 's@+@Plus@g' -e 's@[^a-zA-Z0-9]@_@g' | tr '[:lower:]' '[:upper:]')
+ endif
+endef
+
# Set the qmk cli to use
QMK_BIN ?= qmk
@@ -228,7 +236,7 @@ endif
# that the same keymap may be used on multiple keyboards.
#
# We grab the most top-level include file that we can. That file should
-# use #ifdef statements to include all the neccesary subfolder includes,
+# use #ifdef statements to include all the necessary subfolder includes,
# as described here:
#
# https://docs.qmk.fm/#/feature_layouts?id=tips-for-making-layouts-keyboard-agnostic
@@ -390,10 +398,18 @@ ifneq ("$(KEYMAP_H)","")
CONFIG_H += $(KEYMAP_H)
endif
+OPT_DEFS += -DKEYMAP_C=\"$(KEYMAP_C)\"
+
+# If a keymap or userspace places their keymap array in another file instead, allow for it to be included
+# !!NOTE!! -- For this to work, the source file cannot be part of $(SRC), so users should not add it via `SRC += <file>`
+ifneq ($(strip $(INTROSPECTION_KEYMAP_C)),)
+OPT_DEFS += -DINTROSPECTION_KEYMAP_C=\"$(strip $(INTROSPECTION_KEYMAP_C))\"
+endif
+
# project specific files
SRC += \
$(KEYBOARD_SRC) \
- $(KEYMAP_C) \
+ $(QUANTUM_DIR)/keymap_introspection.c \
$(QUANTUM_SRC) \
$(QUANTUM_DIR)/main.c \
@@ -436,6 +452,14 @@ else
include $(TMK_PATH)/protocol/$(PLATFORM_KEY).mk
endif
+# Setup definitions based on the selected MCU
+$(eval $(call add_qmk_prefix_defs,MCU_ORIG,MCU))
+$(eval $(call add_qmk_prefix_defs,MCU_ARCH,MCU_ARCH))
+$(eval $(call add_qmk_prefix_defs,MCU_PORT_NAME,MCU_PORT_NAME))
+$(eval $(call add_qmk_prefix_defs,MCU_FAMILY,MCU_FAMILY))
+$(eval $(call add_qmk_prefix_defs,MCU_SERIES,MCU_SERIES))
+$(eval $(call add_qmk_prefix_defs,BOARD,BOARD))
+
# TODO: remove this bodge?
PROJECT_DEFS := $(OPT_DEFS)
PROJECT_INC := $(VPATH) $(EXTRAINCDIRS) $(KEYBOARD_PATHS)
@@ -469,6 +493,19 @@ check-size: build
check-md5: build
objs-size: build
+ifeq ($(strip $(TOP_SYMBOLS)),yes)
+all: top-symbols
+check-size: top-symbols
+top-symbols: build
+ echo "###########################################"
+ echo "# Highest flash usage:"
+ $(NM) -Crtd --size-sort $(BUILD_DIR)/$(TARGET).elf | grep -i ' [t] ' | head -n10 | sed -e 's#^0000000# #g' -e 's#^000000# #g' -e 's#^00000# #g' -e 's#^0000# #g' -e 's#^000# #g' -e 's#^00# #g' -e 's#^0# #g'
+ echo "###########################################"
+ echo "# Highest RAM usage:"
+ $(NM) -Crtd --size-sort $(BUILD_DIR)/$(TARGET).elf | grep -i ' [dbv] ' | head -n10 | sed -e 's#^0000000# #g' -e 's#^000000# #g' -e 's#^00000# #g' -e 's#^0000# #g' -e 's#^000# #g' -e 's#^00# #g' -e 's#^0# #g'
+ echo "###########################################"
+endif
+
include $(BUILDDEFS_PATH)/show_options.mk
include $(BUILDDEFS_PATH)/common_rules.mk
diff --git a/builddefs/build_test.mk b/builddefs/build_test.mk
index 5ad33b19c5..64db99fed9 100644
--- a/builddefs/build_test.mk
+++ b/builddefs/build_test.mk
@@ -38,11 +38,11 @@ CREATE_MAP := no
VPATH += \
$(LIB_PATH)/googletest \
$(LIB_PATH)/googlemock \
- $(LIB_PATH)/printf
+ $(COMMON_VPATH) \
+ $(TEST_PATH)
all: elf
-VPATH += $(COMMON_VPATH)
PLATFORM:=TEST
PLATFORM_KEY:=test
BOOTLOADER_TYPE:=none
@@ -63,6 +63,8 @@ include $(TMK_PATH)/protocol.mk
include $(QUANTUM_PATH)/debounce/tests/rules.mk
include $(QUANTUM_PATH)/encoder/tests/rules.mk
include $(QUANTUM_PATH)/sequencer/tests/rules.mk
+include $(QUANTUM_PATH)/wear_leveling/tests/rules.mk
+include $(QUANTUM_PATH)/logging/print.mk
include $(PLATFORM_PATH)/test/rules.mk
ifneq ($(filter $(FULL_TESTS),$(TEST)),)
include $(BUILDDEFS_PATH)/build_full_test.mk
@@ -70,7 +72,6 @@ endif
$(TEST)_SRC += \
tests/test_common/main.c \
- $(LIB_PATH)/printf/printf.c \
$(QUANTUM_PATH)/logging/print.c
$(TEST_OBJ)/$(TEST)_SRC := $($(TEST)_SRC)
diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk
index f7ad32c28e..5ec047a6e8 100644
--- a/builddefs/common_features.mk
+++ b/builddefs/common_features.mk
@@ -15,7 +15,6 @@
QUANTUM_SRC += \
$(QUANTUM_DIR)/quantum.c \
- $(QUANTUM_DIR)/send_string.c \
$(QUANTUM_DIR)/bitwise.c \
$(QUANTUM_DIR)/led.c \
$(QUANTUM_DIR)/action.c \
@@ -92,10 +91,29 @@ ifeq ($(MUSIC_ENABLE), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_music.c
endif
+VALID_STENO_PROTOCOL_TYPES := geminipr txbolt all
+STENO_PROTOCOL ?= all
ifeq ($(strip $(STENO_ENABLE)), yes)
- OPT_DEFS += -DSTENO_ENABLE
- VIRTSER_ENABLE ?= yes
- SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c
+ ifeq ($(filter $(STENO_PROTOCOL),$(VALID_STENO_PROTOCOL_TYPES)),)
+ $(call CATASTROPHIC_ERROR,Invalid STENO_PROTOCOL,STENO_PROTOCOL="$(STENO_PROTOCOL)" is not a valid stenography protocol)
+ else
+ OPT_DEFS += -DSTENO_ENABLE
+ VIRTSER_ENABLE ?= yes
+
+ ifeq ($(strip $(STENO_PROTOCOL)), geminipr)
+ OPT_DEFS += -DSTENO_ENABLE_GEMINI
+ endif
+ ifeq ($(strip $(STENO_PROTOCOL)), txbolt)
+ OPT_DEFS += -DSTENO_ENABLE_BOLT
+ endif
+ ifeq ($(strip $(STENO_PROTOCOL)), all)
+ OPT_DEFS += -DSTENO_ENABLE_ALL
+ OPT_DEFS += -DSTENO_ENABLE_GEMINI
+ OPT_DEFS += -DSTENO_ENABLE_BOLT
+ endif
+
+ SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c
+ endif
endif
ifeq ($(strip $(VIRTSER_ENABLE)), yes)
@@ -108,15 +126,16 @@ ifeq ($(strip $(MOUSEKEY_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/mousekey.c
endif
-VALID_POINTING_DEVICE_DRIVER_TYPES := adns5050 adns9800 analog_joystick cirque_pinnacle_i2c cirque_pinnacle_spi pmw3360 pmw3389 pimoroni_trackball custom
+VALID_POINTING_DEVICE_DRIVER_TYPES := adns5050 adns9800 analog_joystick cirque_pinnacle_i2c cirque_pinnacle_spi paw3204 pmw3360 pmw3389 pimoroni_trackball custom
ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
ifeq ($(filter $(POINTING_DEVICE_DRIVER),$(VALID_POINTING_DEVICE_DRIVER_TYPES)),)
$(call CATASTROPHIC_ERROR,Invalid POINTING_DEVICE_DRIVER,POINTING_DEVICE_DRIVER="$(POINTING_DEVICE_DRIVER)" is not a valid pointing device type)
else
OPT_DEFS += -DPOINTING_DEVICE_ENABLE
MOUSE_ENABLE := yes
- SRC += $(QUANTUM_DIR)/pointing_device.c
- SRC += $(QUANTUM_DIR)/pointing_device_drivers.c
+ VPATH += $(QUANTUM_DIR)/pointing_device
+ SRC += $(QUANTUM_DIR)/pointing_device/pointing_device.c
+ SRC += $(QUANTUM_DIR)/pointing_device/pointing_device_drivers.c
ifneq ($(strip $(POINTING_DEVICE_DRIVER)), custom)
SRC += drivers/sensors/$(strip $(POINTING_DEVICE_DRIVER)).c
OPT_DEFS += -DPOINTING_DEVICE_DRIVER_$(strip $(shell echo $(POINTING_DEVICE_DRIVER) | tr '[:lower:]' '[:upper:]'))
@@ -131,19 +150,21 @@ ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), cirque_pinnacle_i2c)
OPT_DEFS += -DSTM32_I2C -DHAL_USE_I2C=TRUE
SRC += drivers/sensors/cirque_pinnacle.c
+ SRC += drivers/sensors/cirque_pinnacle_gestures.c
+ SRC += $(QUANTUM_DIR)/pointing_device/pointing_device_gestures.c
QUANTUM_LIB_SRC += i2c_master.c
else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), cirque_pinnacle_spi)
OPT_DEFS += -DSTM32_SPI -DHAL_USE_SPI=TRUE
SRC += drivers/sensors/cirque_pinnacle.c
+ SRC += drivers/sensors/cirque_pinnacle_gestures.c
+ SRC += $(QUANTUM_DIR)/pointing_device/pointing_device_gestures.c
QUANTUM_LIB_SRC += spi_master.c
else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), pimoroni_trackball)
OPT_DEFS += -DSTM32_SPI -DHAL_USE_I2C=TRUE
QUANTUM_LIB_SRC += i2c_master.c
- else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), pmw3360)
- OPT_DEFS += -DSTM32_SPI -DHAL_USE_SPI=TRUE
- QUANTUM_LIB_SRC += spi_master.c
- else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), pmw3389)
+ else ifneq ($(filter $(strip $(POINTING_DEVICE_DRIVER)),pmw3360 pmw3389),)
OPT_DEFS += -DSTM32_SPI -DHAL_USE_SPI=TRUE
+ SRC += drivers/sensors/pmw33xx_common.c
QUANTUM_LIB_SRC += spi_master.c
endif
endif
@@ -154,33 +175,36 @@ ifeq ($(strip $(QUANTUM_PAINTER_ENABLE)), yes)
include $(QUANTUM_DIR)/painter/rules.mk
endif
-VALID_EEPROM_DRIVER_TYPES := vendor custom transient i2c spi
+VALID_EEPROM_DRIVER_TYPES := vendor custom transient i2c spi wear_leveling
EEPROM_DRIVER ?= vendor
ifeq ($(filter $(EEPROM_DRIVER),$(VALID_EEPROM_DRIVER_TYPES)),)
$(call CATASTROPHIC_ERROR,Invalid EEPROM_DRIVER,EEPROM_DRIVER="$(EEPROM_DRIVER)" is not a valid EEPROM driver)
else
OPT_DEFS += -DEEPROM_ENABLE
+ COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/eeprom
+ COMMON_VPATH += $(DRIVER_PATH)/eeprom
+ COMMON_VPATH += $(PLATFORM_COMMON_DIR)
ifeq ($(strip $(EEPROM_DRIVER)), custom)
# Custom EEPROM implementation -- only needs to implement init/erase/read_block/write_block
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_CUSTOM
- COMMON_VPATH += $(DRIVER_PATH)/eeprom
SRC += eeprom_driver.c
+ else ifeq ($(strip $(EEPROM_DRIVER)), wear_leveling)
+ # Wear-leveling EEPROM implementation
+ OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_WEAR_LEVELING
+ SRC += eeprom_driver.c eeprom_wear_leveling.c
else ifeq ($(strip $(EEPROM_DRIVER)), i2c)
# External I2C EEPROM implementation
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_I2C
- COMMON_VPATH += $(DRIVER_PATH)/eeprom
QUANTUM_LIB_SRC += i2c_master.c
SRC += eeprom_driver.c eeprom_i2c.c
else ifeq ($(strip $(EEPROM_DRIVER)), spi)
# External SPI EEPROM implementation
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_SPI
- COMMON_VPATH += $(DRIVER_PATH)/eeprom
QUANTUM_LIB_SRC += spi_master.c
SRC += eeprom_driver.c eeprom_spi.c
else ifeq ($(strip $(EEPROM_DRIVER)), transient)
# Transient EEPROM implementation -- no data storage but provides runtime area for it
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT
- COMMON_VPATH += $(DRIVER_PATH)/eeprom
SRC += eeprom_driver.c eeprom_transient.c
else ifeq ($(strip $(EEPROM_DRIVER)), vendor)
# Vendor-implemented EEPROM
@@ -191,17 +215,18 @@ else
ifneq ($(filter STM32F3xx_% STM32F1xx_% %_STM32F401xC %_STM32F401xE %_STM32F405xG %_STM32F411xE %_STM32F072xB %_STM32F042x6 %_GD32VF103xB %_GD32VF103x8, $(MCU_SERIES)_$(MCU_LDSCRIPT)),)
# Emulated EEPROM
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_STM32_FLASH_EMULATED
- COMMON_VPATH += $(DRIVER_PATH)/eeprom
- SRC += eeprom_driver.c
- SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
- SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
+ COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/flash
+ COMMON_VPATH += $(DRIVER_PATH)/flash
+ SRC += eeprom_driver.c eeprom_stm32.c flash_stm32.c
else ifneq ($(filter $(MCU_SERIES),STM32L0xx STM32L1xx),)
# True EEPROM on STM32L0xx, L1xx
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_STM32_L0_L1
- COMMON_VPATH += $(DRIVER_PATH)/eeprom
- COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/eeprom
- SRC += eeprom_driver.c
- SRC += eeprom_stm32_L0_L1.c
+ SRC += eeprom_driver.c eeprom_stm32_L0_L1.c
+ else ifneq ($(filter $(MCU_SERIES),RP2040),)
+ # Wear-leveling EEPROM implementation, backed by RP2040 flash
+ OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_WEAR_LEVELING
+ SRC += eeprom_driver.c eeprom_wear_leveling.c
+ WEAR_LEVELING_DRIVER = rp2040_flash
else ifneq ($(filter $(MCU_SERIES),KL2x K20x),)
# Teensy EEPROM implementations
OPT_DEFS += -DEEPROM_TEENSY
@@ -209,32 +234,64 @@ else
else
# Fall back to transient, i.e. non-persistent
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT
- COMMON_VPATH += $(DRIVER_PATH)/eeprom
SRC += eeprom_driver.c eeprom_transient.c
endif
else ifeq ($(PLATFORM),ARM_ATSAM)
# arm_atsam EEPROM
OPT_DEFS += -DEEPROM_SAMD
- SRC += $(PLATFORM_COMMON_DIR)/eeprom_samd.c
+ SRC += eeprom_samd.c
else ifeq ($(PLATFORM),TEST)
# Test harness "EEPROM"
OPT_DEFS += -DEEPROM_TEST_HARNESS
- SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
+ SRC += eeprom.c
+ endif
+ endif
+endif
+
+VALID_WEAR_LEVELING_DRIVER_TYPES := custom embedded_flash spi_flash rp2040_flash legacy
+WEAR_LEVELING_DRIVER ?= none
+ifneq ($(strip $(WEAR_LEVELING_DRIVER)),none)
+ ifeq ($(filter $(WEAR_LEVELING_DRIVER),$(VALID_WEAR_LEVELING_DRIVER_TYPES)),)
+ $(call CATASTROPHIC_ERROR,Invalid WEAR_LEVELING_DRIVER,WEAR_LEVELING_DRIVER="$(WEAR_LEVELING_DRIVER)" is not a valid wear leveling driver)
+ else
+ FNV_ENABLE := yes
+ OPT_DEFS += -DWEAR_LEVELING_ENABLE
+ OPT_DEFS += -DWEAR_LEVELING_$(strip $(shell echo $(WEAR_LEVELING_DRIVER) | tr '[:lower:]' '[:upper:]'))
+ COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/wear_leveling
+ COMMON_VPATH += $(DRIVER_PATH)/wear_leveling
+ COMMON_VPATH += $(QUANTUM_DIR)/wear_leveling
+ SRC += wear_leveling.c
+ ifeq ($(strip $(WEAR_LEVELING_DRIVER)), embedded_flash)
+ OPT_DEFS += -DHAL_USE_EFL
+ SRC += wear_leveling_efl.c
+ POST_CONFIG_H += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/wear_leveling/wear_leveling_efl_config.h
+ else ifeq ($(strip $(WEAR_LEVELING_DRIVER)), spi_flash)
+ FLASH_DRIVER := spi
+ SRC += wear_leveling_flash_spi.c
+ POST_CONFIG_H += $(DRIVER_PATH)/wear_leveling/wear_leveling_flash_spi_config.h
+ else ifeq ($(strip $(WEAR_LEVELING_DRIVER)), rp2040_flash)
+ SRC += wear_leveling_rp2040_flash.c
+ POST_CONFIG_H += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_PATH)/wear_leveling/wear_leveling_rp2040_flash_config.h
+ else ifeq ($(strip $(WEAR_LEVELING_DRIVER)), legacy)
+ COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/flash
+ SRC += flash_stm32.c wear_leveling_legacy.c
+ POST_CONFIG_H += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/wear_leveling/wear_leveling_legacy_config.h
endif
endif
endif
VALID_FLASH_DRIVER_TYPES := spi
-FLASH_DRIVER ?= no
-ifneq ($(strip $(FLASH_DRIVER)), no)
+FLASH_DRIVER ?= none
+ifneq ($(strip $(FLASH_DRIVER)), none)
ifeq ($(filter $(FLASH_DRIVER),$(VALID_FLASH_DRIVER_TYPES)),)
- $(error FLASH_DRIVER="$(FLASH_DRIVER)" is not a valid FLASH driver)
+ $(call CATASTROPHIC_ERROR,Invalid FLASH_DRIVER,FLASH_DRIVER="$(FLASH_DRIVER)" is not a valid flash driver)
else
OPT_DEFS += -DFLASH_ENABLE
- ifeq ($(strip $(FLASH_DRIVER)), spi)
+ ifeq ($(strip $(FLASH_DRIVER)),spi)
OPT_DEFS += -DFLASH_DRIVER -DFLASH_SPI
COMMON_VPATH += $(DRIVER_PATH)/flash
SRC += flash_spi.c
+ QUANTUM_LIB_SRC += spi_master.c
endif
endif
endif
@@ -275,7 +332,7 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
endif
LED_MATRIX_ENABLE ?= no
-VALID_LED_MATRIX_TYPES := IS31FL3731 IS31FL3742A IS31FL3743A IS31FL3745 IS31FL3746A custom
+VALID_LED_MATRIX_TYPES := IS31FL3731 IS31FL3742A IS31FL3743A IS31FL3745 IS31FL3746A CKLED2001 custom
# TODO: IS31FL3733 IS31FL3737 IS31FL3741
ifeq ($(strip $(LED_MATRIX_ENABLE)), yes)
@@ -331,6 +388,13 @@ endif
QUANTUM_LIB_SRC += i2c_master.c
endif
+ ifeq ($(strip $(LED_MATRIX_DRIVER)), CKLED2001)
+ OPT_DEFS += -DCKLED2001 -DSTM32_I2C -DHAL_USE_I2C=TRUE
+ COMMON_VPATH += $(DRIVER_PATH)/led
+ SRC += ckled2001-simple.c
+ QUANTUM_LIB_SRC += i2c_master.c
+ endif
+
endif
RGB_MATRIX_ENABLE ?= no
@@ -500,7 +564,7 @@ ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
endif
endif
-VALID_WS2812_DRIVER_TYPES := bitbang pwm spi i2c
+VALID_WS2812_DRIVER_TYPES := bitbang pwm spi i2c vendor
WS2812_DRIVER ?= bitbang
ifeq ($(strip $(WS2812_DRIVER_REQUIRED)), yes)
@@ -542,12 +606,6 @@ ifeq ($(strip $(LED_TABLES)), yes)
SRC += $(QUANTUM_DIR)/led_tables.c
endif
-ifeq ($(strip $(TERMINAL_ENABLE)), yes)
- SRC += $(QUANTUM_DIR)/process_keycode/process_terminal.c
- OPT_DEFS += -DTERMINAL_ENABLE
- OPT_DEFS += -DUSER_PRINT
-endif
-
ifeq ($(strip $(ORYX_ENABLE)), yes)
RAW_ENABLE := yes
SRC += $(QUANTUM_DIR)/oryx.c
@@ -601,6 +659,14 @@ ifneq ($(strip $(DEBOUNCE_TYPE)), custom)
QUANTUM_SRC += $(QUANTUM_DIR)/debounce/$(strip $(DEBOUNCE_TYPE)).c
endif
+
+VALID_SERIAL_DRIVER_TYPES := bitbang usart vendor
+
+SERIAL_DRIVER ?= bitbang
+ifeq ($(filter $(SERIAL_DRIVER),$(VALID_SERIAL_DRIVER_TYPES)),)
+ $(call CATASTROPHIC_ERROR,Invalid SERIAL_DRIVER,SERIAL_DRIVER="$(SERIAL_DRIVER)" is not a valid SERIAL driver)
+endif
+
ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
POST_CONFIG_H += $(QUANTUM_DIR)/split_common/post_config.h
OPT_DEFS += -DSPLIT_KEYBOARD
@@ -625,11 +691,11 @@ ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
endif
endif
- SERIAL_DRIVER ?= bitbang
OPT_DEFS += -DSERIAL_DRIVER_$(strip $(shell echo $(SERIAL_DRIVER) | tr '[:lower:]' '[:upper:]'))
ifeq ($(strip $(SERIAL_DRIVER)), bitbang)
QUANTUM_LIB_SRC += serial.c
else
+ QUANTUM_LIB_SRC += serial_protocol.c
QUANTUM_LIB_SRC += serial_$(strip $(SERIAL_DRIVER)).c
endif
endif
@@ -641,6 +707,12 @@ ifeq ($(strip $(CRC_ENABLE)), yes)
SRC += crc.c
endif
+ifeq ($(strip $(FNV_ENABLE)), yes)
+ OPT_DEFS += -DFNV_ENABLE
+ VPATH += $(LIB_PATH)/fnv
+ SRC += qmk_fnv_type_validation.c hash_32a.c hash_64a.c
+endif
+
ifeq ($(strip $(HAPTIC_ENABLE)),yes)
COMMON_VPATH += $(DRIVER_PATH)/haptic
@@ -717,6 +789,13 @@ ifeq ($(strip $(MAGIC_ENABLE)), yes)
OPT_DEFS += -DMAGIC_KEYCODE_ENABLE
endif
+SEND_STRING_ENABLE ?= yes
+ifeq ($(strip $(SEND_STRING_ENABLE)), yes)
+ OPT_DEFS += -DSEND_STRING_ENABLE
+ COMMON_VPATH += $(QUANTUM_DIR)/send_string
+ SRC += $(QUANTUM_DIR)/send_string/send_string.c
+endif
+
ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_auto_shift.c
OPT_DEFS += -DAUTO_SHIFT_ENABLE
@@ -827,3 +906,11 @@ ifeq ($(strip $(BLUETOOTH_ENABLE)), yes)
QUANTUM_LIB_SRC += uart.c
endif
endif
+
+ifeq ($(strip $(ENCODER_ENABLE)), yes)
+ SRC += $(QUANTUM_DIR)/encoder.c
+ OPT_DEFS += -DENCODER_ENABLE
+ ifeq ($(strip $(ENCODER_MAP_ENABLE)), yes)
+ OPT_DEFS += -DENCODER_MAP_ENABLE
+ endif
+endif
diff --git a/builddefs/common_rules.mk b/builddefs/common_rules.mk
index d3acddc87b..22746b92a3 100644
--- a/builddefs/common_rules.mk
+++ b/builddefs/common_rules.mk
@@ -1,21 +1,7 @@
# Hey Emacs, this is a -*- makefile -*-
#----------------------------------------------------------------------------
-# WinAVR Makefile Template written by Eric B. Weddington, Jg Wunsch, et al.
-#
-# Released to the Public Domain
-#
-# Additional material for this makefile was written by:
-# Peter Fleury
-# Tim Henigan
-# Colin O'Flynn
-# Reiner Patommel
-# Markus Pfaff
-# Sander Pool
-# Frederik Rouleau
-# Carlos Lamas
-#
-
-# Enable vpath seraching for source files only
+
+# Enable vpath searching for source files only
# Without this, output files, could be read from the wrong .build directories
VPATH_SRC := $(VPATH)
vpath %.c $(VPATH_SRC)
@@ -38,36 +24,15 @@ NO_LTO_OBJ := $(filter %.a,$(OBJ))
MASTER_OUTPUT := $(firstword $(OUTPUTS))
-
-
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
# Optimization level, can be [0, 1, 2, 3, s].
-# 0 = turn off optimization. s = optimize for size.
-# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT ?= s
-# Compiler flag to set the C Standard level.
-# c89 = "ANSI" C
-# gnu89 = c89 plus GCC extensions
-# c99 = ISO C99 standard (not yet fully implemented)
-# gnu99 = c99 plus GCC extensions
-CSTANDARD = -std=gnu99
-
-
-# Place -D or -U options here for C sources
-#CDEFS +=
-
-
-# Place -D or -U options here for ASM sources
-#ADEFS +=
-
-
-# Place -D or -U options here for C++ sources
-#CXXDEFS += -D__STDC_LIMIT_MACROS
-#CXXDEFS += -D__STDC_CONSTANT_MACROS
-#CXXDEFS +=
+# Compiler flag to set the C and C++ language standard level
+CSTANDARD = -std=gnu11
+CXXSTANDARD = -std=gnu++14
# Speed up recompilations by opt-in usage of ccache
USE_CCACHE ?= no
@@ -75,12 +40,8 @@ ifneq ($(USE_CCACHE),no)
CC_PREFIX ?= ccache
endif
-#---------------- Compiler Options C ----------------
-# -g*: generate debugging information
-# -O*: optimization level
-# -f...: tuning, see GCC manual and avr-libc documentation
-# -Wall...: warning level
-# -Wa,...: tell GCC to pass this to the assembler.
+#---------------- C Compiler Options ----------------
+
ifeq ($(strip $(LTO_ENABLE)), yes)
ifeq ($(PLATFORM),ARM_ATSAM)
$(info Enabling LTO on arm_atsam-targeting boards is known to have a high likelihood of failure.)
@@ -111,29 +72,20 @@ CFLAGS += -Wstrict-prototypes
ifneq ($(strip $(ALLOW_WARNINGS)), yes)
CFLAGS += -Werror
endif
-#CFLAGS += -mshort-calls
-#CFLAGS += -fno-unit-at-a-time
-#CFLAGS += -Wundef
-#CFLAGS += -Wunreachable-code
-#CFLAGS += -Wsign-compare
CFLAGS += $(CSTANDARD)
# This fixes lots of keyboards linking errors but SHOULDN'T BE A FINAL SOLUTION
# Fixing of multiple variable definitions must be made.
CFLAGS += -fcommon
-#---------------- Compiler Options C++ ----------------
-# -g*: generate debugging information
-# -O*: optimization level
-# -f...: tuning, see GCC manual and avr-libc documentation
-# -Wall...: warning level
-# -Wa,...: tell GCC to pass this to the assembler.
+#---------------- C++ Compiler Options ----------------
+
ifeq ($(strip $(DEBUG_ENABLE)),yes)
CXXFLAGS += -g$(DEBUG)
endif
CXXFLAGS += $(CXXDEFS)
CXXFLAGS += -O$(OPT)
-# to supress "warning: only initialized variables can be placed into program memory area"
+# to suppress "warning: only initialized variables can be placed into program memory area"
CXXFLAGS += -w
CXXFLAGS += -Wall
CXXFLAGS += -Wundef
@@ -141,57 +93,17 @@ CXXFLAGS += -Wundef
ifneq ($(strip $(ALLOW_WARNINGS)), yes)
CXXFLAGS += -Werror
endif
-#CXXFLAGS += -mshort-calls
-#CXXFLAGS += -fno-unit-at-a-time
-#CXXFLAGS += -Wstrict-prototypes
-#CXXFLAGS += -Wunreachable-code
-#CXXFLAGS += -Wsign-compare
-#CXXFLAGS += $(CSTANDARD)
#---------------- Assembler Options ----------------
+
ASFLAGS += $(ADEFS)
ifeq ($(VERBOSE_AS_CMD),yes)
ASFLAGS += -v
endif
-#---------------- Library Options ----------------
-# Minimalistic printf version
-PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
-
-# Floating point printf version (requires MATH_LIB = -lm below)
-PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
-
-# If this is left blank, then it will use the Standard printf version.
-PRINTF_LIB =
-#PRINTF_LIB = $(PRINTF_LIB_MIN)
-#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
-
-
-# Minimalistic scanf version
-SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
-
-# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
-SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
-
-# If this is left blank, then it will use the Standard scanf version.
-SCANF_LIB =
-#SCANF_LIB = $(SCANF_LIB_MIN)
-#SCANF_LIB = $(SCANF_LIB_FLOAT)
-
-
-MATH_LIB = -lm
-CREATE_MAP ?= yes
-
-
#---------------- Linker Options ----------------
-# -Wl,...: tell GCC to pass this to linker.
-# -Map: create map file
-# --cref: add cross reference to map file
-#
-# Comennt out "--relax" option to avoid a error such:
-# (.vectors+0x30): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_12'
-#
+CREATE_MAP ?= yes
ifeq ($(CREATE_MAP),yes)
LDFLAGS += -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref
endif
@@ -201,20 +113,11 @@ endif
#LDFLAGS += -Wl,--relax
LDFLAGS += $(EXTMEMOPTS)
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
-LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
-#LDFLAGS += -T linker_script.x
+LDFLAGS += -lm
# You can give EXTRALDFLAGS at 'make' command line.
LDFLAGS += $(EXTRALDFLAGS)
#---------------- Assembler Listings ----------------
-# -Wa,...: tell GCC to pass this to the assembler.
-# -adhlns: create listing
-# -gstabs: have the assembler create line number information; note that
-# for use in COFF files, additional information about filenames
-# and function names needs to be present in the assembler source
-# files -- see avr-libc docs [FIXME: not yet described there]
-# -listing-cont-lines: Sets the maximum number of continuation lines of hex
-# dump that will be displayed for a given single line of source input.
ADHLNS_ENABLE ?= no
ifeq ($(ADHLNS_ENABLE),yes)
@@ -468,6 +371,7 @@ show_path:
dump_vars: ERROR_IF_EMPTY=""
dump_vars: ERROR_IF_NONBOOL=""
dump_vars: ERROR_IF_UNSET=""
+dump_vars: CATASTROPHIC_ERROR=""
dump_vars:
@$(foreach V,$(sort $(.VARIABLES)),$(if $(filter-out environment% default automatic,$(origin $V)),$(info $V=$($V))))
diff --git a/builddefs/generic_features.mk b/builddefs/generic_features.mk
index c3f1ec0f72..f195e9fd75 100644
--- a/builddefs/generic_features.mk
+++ b/builddefs/generic_features.mk
@@ -25,8 +25,6 @@ GENERIC_FEATURES = \
DIP_SWITCH \
DYNAMIC_KEYMAP \
DYNAMIC_MACRO \
- ENCODER \
- ENCODER_MAP \
GRAVE_ESC \
HAPTIC \
KEY_LOCK \
diff --git a/builddefs/mcu_selection.mk b/builddefs/mcu_selection.mk
index d5fb731e08..0ea9630d59 100644
--- a/builddefs/mcu_selection.mk
+++ b/builddefs/mcu_selection.mk
@@ -87,6 +87,33 @@ ifneq ($(findstring MK20DX256, $(MCU)),)
BOARD ?= PJRC_TEENSY_3_1
endif
+ifneq ($(findstring MK64FX512, $(MCU)),)
+ # Cortex version
+ MCU = cortex-m4
+
+ # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
+ ARMV = 7
+
+ ## chip/board settings
+ # - the next two should match the directories in
+ # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
+ MCU_FAMILY = KINETIS
+ MCU_SERIES = K60x
+
+ # Linker script to use
+ # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
+ # or <keyboard_dir>/ld/
+ MCU_LDSCRIPT ?= MK64FX512
+
+ # Startup code to use
+ # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
+ MCU_STARTUP ?= k60x
+
+ # Board: it should exist either in <chibios>/os/hal/boards/,
+ # <keyboard_dir>/boards/, or drivers/boards/
+ BOARD ?= PJRC_TEENSY_3_5
+endif
+
ifneq ($(findstring MK66FX1M0, $(MCU)),)
# Cortex version
MCU = cortex-m4
@@ -116,6 +143,41 @@ ifneq ($(findstring MK66FX1M0, $(MCU)),)
BOARD ?= PJRC_TEENSY_3_6
endif
+ifneq ($(findstring RP2040, $(MCU)),)
+ # Cortex version
+ MCU = cortex-m0plus
+
+ # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
+ CHIBIOS_PORT = ARMv6-M-RP2
+
+ ## chip/board settings
+ # - the next two should match the directories in
+ # <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
+ # OR
+ # <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
+ MCU_FAMILY = RP
+ MCU_SERIES = RP2040
+
+ # Linker script to use
+ # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
+ # or <keyboard_dir>/ld/
+ STARTUPLD_CONTRIB = $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/ld
+ MCU_LDSCRIPT ?= RP2040_FLASH_TIMECRIT
+ LDFLAGS += -L $(STARTUPLD_CONTRIB)
+
+ # Startup code to use
+ # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
+ MCU_STARTUP ?= rp2040
+
+ # Board: it should exist either in <chibios>/os/hal/boards/,
+ # <keyboard_dir>/boards/, or drivers/boards/
+ BOARD ?= GENERIC_PROMICRO_RP2040
+
+ # Default UF2 Bootloader settings
+ UF2_FAMILY ?= RP2040
+ FIRMWARE_FORMAT ?= uf2
+endif
+
ifneq ($(findstring STM32F042, $(MCU)),)
# Cortex version
MCU = cortex-m0
@@ -286,7 +348,8 @@ ifneq ($(findstring STM32F401, $(MCU)),)
# or <keyboard_dir>/ld/
ifeq ($(strip $(BOOTLOADER)), tinyuf2)
MCU_LDSCRIPT ?= STM32F401xC_tinyuf2
- FIRMWARE_FORMAT ?= uf2
+ EEPROM_DRIVER ?= wear_leveling
+ WEAR_LEVELING_DRIVER ?= legacy
else
MCU_LDSCRIPT ?= STM32F401xC
endif
@@ -297,7 +360,7 @@ ifneq ($(findstring STM32F401, $(MCU)),)
# Board: it should exist either in <chibios>/os/hal/boards/,
# <keyboard_dir>/boards/, or drivers/boards/
- BOARD ?= BLACKPILL_STM32_F401
+ BOARD ?= GENERIC_STM32_F401XC
USE_FPU ?= yes
@@ -402,7 +465,8 @@ ifneq ($(findstring STM32F411, $(MCU)),)
# or <keyboard_dir>/ld/
ifeq ($(strip $(BOOTLOADER)), tinyuf2)
MCU_LDSCRIPT ?= STM32F411xE_tinyuf2
- FIRMWARE_FORMAT ?= uf2
+ EEPROM_DRIVER ?= wear_leveling
+ WEAR_LEVELING_DRIVER ?= legacy
else
MCU_LDSCRIPT ?= STM32F411xE
endif
@@ -413,7 +477,7 @@ ifneq ($(findstring STM32F411, $(MCU)),)
# Board: it should exist either in <chibios>/os/hal/boards/,
# <keyboard_dir>/boards/, or drivers/boards/
- BOARD ?= BLACKPILL_STM32_F411
+ BOARD ?= GENERIC_STM32_F411XE
USE_FPU ?= yes
diff --git a/builddefs/show_options.mk b/builddefs/show_options.mk
index f67d009191..98537e6da2 100644
--- a/builddefs/show_options.mk
+++ b/builddefs/show_options.mk
@@ -5,7 +5,6 @@ BUILD_OPTION_NAMES = \
CONSOLE_ENABLE \
COMMAND_ENABLE \
NKRO_ENABLE \
- TERMINAL_ENABLE \
CUSTOM_MATRIX \
DEBOUNCE_TYPE \
SPLIT_KEYBOARD \
@@ -46,6 +45,7 @@ OTHER_OPTION_NAMES = \
LEADER_ENABLE \
PRINTING_ENABLE \
STENO_ENABLE \
+ STENO_PROTOCOL \
TAP_DANCE_ENABLE \
VIRTSER_ENABLE \
OLED_ENABLE \
diff --git a/builddefs/testlist.mk b/builddefs/testlist.mk
index b8d22bce80..8a30a44972 100644
--- a/builddefs/testlist.mk
+++ b/builddefs/testlist.mk
@@ -4,6 +4,7 @@ FULL_TESTS := $(notdir $(TEST_LIST))
include $(QUANTUM_PATH)/debounce/tests/testlist.mk
include $(QUANTUM_PATH)/encoder/tests/testlist.mk
include $(QUANTUM_PATH)/sequencer/tests/testlist.mk
+include $(QUANTUM_PATH)/wear_leveling/tests/testlist.mk
include $(PLATFORM_PATH)/test/testlist.mk
define VALIDATE_TEST_LIST
diff --git a/data/mappings/defaults.json b/data/mappings/defaults.json
index e62ab688d6..c855e64d33 100644
--- a/data/mappings/defaults.json
+++ b/data/mappings/defaults.json
@@ -16,6 +16,30 @@
"board": "QMK_PROTON_C",
"pin_compatible": "promicro"
},
+ "kb2040": {
+ "processor": "RP2040",
+ "bootloader": "rp2040",
+ "board": "QMK_PM2040",
+ "pin_compatible": "promicro"
+ },
+ "promicro_rp2040": {
+ "processor": "RP2040",
+ "bootloader": "rp2040",
+ "board": "QMK_PM2040",
+ "pin_compatible": "promicro"
+ },
+ "blok": {
+ "processor": "RP2040",
+ "bootloader": "rp2040",
+ "board": "QMK_PM2040",
+ "pin_compatible": "promicro"
+ },
+ "bit_c_pro": {
+ "processor": "RP2040",
+ "bootloader": "rp2040",
+ "board": "QMK_PM2040",
+ "pin_compatible": "promicro"
+ },
"bluepill": {
"processor": "STM32F103",
"bootloader": "stm32duino",
@@ -30,6 +54,18 @@
"processor": "STM32F411",
"bootloader": "stm32-dfu",
"board": "BLACKPILL_STM32_F411"
+ },
+ "stemcell": {
+ "processor": "STM32F411",
+ "bootloader": "tinyuf2",
+ "board": "STEMCELL",
+ "pin_compatible": "promicro"
+ },
+ "bonsai_c4": {
+ "processor": "STM32F411",
+ "bootloader": "stm32-dfu",
+ "board": "GENERIC_STM32_F411XE",
+ "pin_compatible": "promicro"
}
}
-} \ No newline at end of file
+}
diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json
index d9f96b5892..92004dd546 100644
--- a/data/mappings/info_config.json
+++ b/data/mappings/info_config.json
@@ -7,9 +7,14 @@
# to_json: Default `true`. Set to `false` to exclude this mapping from info.json
# to_c: Default `true`. Set to `false` to exclude this mapping from config.h
# warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places
+ # deprecated: Default `false`. Set to `true` to turn on warning when a value exists
+ # invalid: Default `false`. Set to `true` to generate errors when a value exists
+ # replace_with: use with a key marked deprecated or invalid to designate a replacement
"AUDIO_VOICES": {"info_key": "audio.voices", "value_type": "bool"},
"BACKLIGHT_BREATHING": {"info_key": "backlight.breathing", "value_type": "bool"},
"BREATHING_PERIOD": {"info_key": "backlight.breathing_period", "value_type": "int"},
+ "BACKLIGHT_LEVELS": {"info_key": "backlight.levels", "value_type": "int"},
+ "BACKLIGHT_ON_STATE": {"info_key": "backlight.on_state", "value_type": "int"},
"BACKLIGHT_PIN": {"info_key": "backlight.pin"},
"BOTH_SHIFTS_TURNS_ON_CAPS_WORD": {"info_key": "caps_word.both_shifts_turns_on", "value_type": "bool"},
"CAPS_WORD_IDLE_TIMEOUT": {"info_key": "caps_word.idle_timeout", "value_type": "int"},
@@ -19,7 +24,6 @@
"DEVICE_VER": {"info_key": "usb.device_ver", "value_type": "hex"},
# TODO: Replace ^^^ with vvv
#"DEVICE_VER": {"info_key": "usb.device_version", "value_type": "bcd_version"},
- "DESCRIPTION": {"info_key": "keyboard_folder", "value_type": "str", "to_json": false},
"DIODE_DIRECTION": {"info_key": "diode_direction"},
"DOUBLE_TAP_SHIFT_TURNS_ON_CAPS_WORD": {"info_key": "caps_word.double_tap_shift_turns_on", "value_type": "bool"},
"FORCE_NKRO": {"info_key": "usb.force_nkro", "value_type": "bool"},
@@ -34,6 +38,9 @@
"LED_CAPS_LOCK_PIN": {"info_key": "indicators.caps_lock"},
"LED_NUM_LOCK_PIN": {"info_key": "indicators.num_lock"},
"LED_SCROLL_LOCK_PIN": {"info_key": "indicators.scroll_lock"},
+ "LED_COMPOSE_PIN": {"info_key": "indicators.compose"},
+ "LED_KANA_PIN": {"info_key": "indicators.kana"},
+ "LED_PIN_ON_STATE": {"info_key": "indicators.on_state", "value_type": "int"},
"MANUFACTURER": {"info_key": "manufacturer"},
"MATRIX_HAS_GHOST": {"info_key": "matrix_pins.ghost", "value_type": "bool"},
"MATRIX_IO_DELAY": {"info_key": "matrix_pins.io_delay", "value_type": "int"},
@@ -51,7 +58,6 @@
"RGB_DI_PIN": {"info_key": "rgblight.pin"},
"RGBLED_NUM": {"info_key": "rgblight.led_count", "value_type": "int"},
"RGBLED_SPLIT": {"info_key": "rgblight.split_count", "value_type": "array.int"},
- "RGBLIGHT_ANIMATIONS": {"info_key": "rgblight.animations.all", "value_type": "bool"},
"RGBLIGHT_EFFECT_ALTERNATING": {"info_key": "rgblight.animations.alternating", "value_type": "bool"},
"RGBLIGHT_EFFECT_BREATHING": {"info_key": "rgblight.animations.breathing", "value_type": "bool"},
"RGBLIGHT_EFFECT_CHRISTMAS": {"info_key": "rgblight.animations.christmas", "value_type": "bool"},
@@ -78,7 +84,6 @@
"VENDOR_ID": {"info_key": "usb.vid", "value_type": "hex"},
"QMK_ESC_OUTPUT": {"info_key": "qmk_lufa_bootloader.esc_output"},
"QMK_ESC_INPUT": {"info_key": "qmk_lufa_bootloader.esc_input"},
- "QMK_KEYS_PER_SCAN": {"info_key": "qmk.keys_per_scan", "value_type": "int"},
"QMK_LED": {"info_key": "qmk_lufa_bootloader.led"},
"QMK_SPEAKER": {"info_key": "qmk_lufa_bootloader.speaker"},
"SECURE_UNLOCK_SEQUENCE": {"info_key": "secure.unlock_sequence", "value_type": "array.array.int", "to_json": false},
@@ -102,4 +107,14 @@
"USB_MAX_POWER_CONSUMPTION": {"info_key": "usb.max_power", "value_type": "int"},
"USB_POLLING_INTERVAL_MS": {"info_key": "usb.polling_interval", "value_type": "int"},
"USB_SUSPEND_WAKEUP_DELAY": {"info_key": "usb.suspend_wakeup_delay", "value_type": "int"},
+
+ # Items we want flagged in lint
+ "NO_ACTION_MACRO": {"info_key": "_invalid.no_action_macro", "invalid": true},
+ "NO_ACTION_FUNCTION": {"info_key": "_invalid.no_action_function", "invalid": true},
+ "DESCRIPTION": {"info_key": "_invalid.usb_description", "invalid": true},
+ "DEBOUNCING_DELAY": {"info_key": "_invalid.debouncing_delay", "invalid": true, "replace_with": "DEBOUNCE"},
+ "PREVENT_STUCK_MODIFIERS": {"info_key": "_invalid.prevent_stuck_mods", "invalid": true},
+ "UNUSED_PINS": {"info_key": "_invalid.unused_pins", "deprecated": true},
+ "RGBLIGHT_ANIMATIONS": {"info_key": "rgblight.animations.all", "value_type": "bool", "deprecated": true},
+ "QMK_KEYS_PER_SCAN": {"info_key": "qmk.keys_per_scan", "value_type": "int", "deprecated": true}
}
diff --git a/data/mappings/info_rules.json b/data/mappings/info_rules.json
index a8b39afbd1..7208d6ab94 100644
--- a/data/mappings/info_rules.json
+++ b/data/mappings/info_rules.json
@@ -7,15 +7,21 @@
# to_json: Default `true`. Set to `false` to exclude this mapping from info.json
# to_c: Default `true`. Set to `false` to exclude this mapping from rules.mk
# warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places
+ # deprecated: Default `false`. Set to `true` to turn on warning when a value exists
+ # invalid: Default `false`. Set to `true` to generate errors when a value exists
+ # replace_with: use with a key marked deprecated or invalid to designate a replacement
"BOARD": {"info_key": "board"},
"BOOTLOADER": {"info_key": "bootloader", "warn_duplicate": false},
"BLUETOOTH": {"info_key": "bluetooth.driver"},
"CAPS_WORD_ENABLE": {"info_key": "caps_word.enabled", "value_type": "bool"},
+ "DEBOUNCE_TYPE": {"info_key": "build.debounce_type"},
+ "ENCODER_ENABLE": {"info_key": "encoder.enabled", "value_type": "bool"},
"FIRMWARE_FORMAT": {"info_key": "build.firmware_format"},
"KEYBOARD_SHARED_EP": {"info_key": "usb.shared_endpoint.keyboard", "value_type": "bool"},
"MOUSE_SHARED_EP": {"info_key": "usb.shared_endpoint.mouse", "value_type": "bool"},
"LAYOUTS": {"info_key": "community_layouts", "value_type": "list"},
"LED_MATRIX_DRIVER": {"info_key": "led_matrix.driver"},
+ "RGB_MATRIX_DRIVER": {"info_key": "rgb_matrix.driver"},
"LTO_ENABLE": {"info_key": "build.lto", "value_type": "bool"},
"MCU": {"info_key": "processor", "warn_duplicate": false},
"MOUSEKEY_ENABLE": {"info_key": "mouse_key.enabled", "value_type": "bool"},
@@ -24,5 +30,12 @@
"SECURE_ENABLE": {"info_key": "secure.enabled", "value_type": "bool"},
"SPLIT_KEYBOARD": {"info_key": "split.enabled", "value_type": "bool"},
"SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "to_c": false},
- "WAIT_FOR_USB": {"info_key": "usb.wait_for", "value_type": "bool"}
+ "WAIT_FOR_USB": {"info_key": "usb.wait_for", "value_type": "bool"},
+ "STENO_ENABLE": {"info_key": "stenography.enabled", "value_type": "bool"},
+ "STENO_PROTOCOL": {"info_key": "stenography.protocol"},
+
+ # Items we want flagged in lint
+ "CTPC": {"info_key": "_deprecated.ctpc", "deprecated": true, "replace_with": "CONVERT_TO=proton_c"},
+ "CONVERT_TO_PROTON_C": {"info_key": "_deprecated.ctpc", "deprecated": true, "replace_with": "CONVERT_TO=proton_c"},
+ "VIAL_ENABLE": {"info_key": "_invalid.vial", "invalid": true}
}
diff --git a/data/mappings/keyboard_aliases.json b/data/mappings/keyboard_aliases.json
index 93be17cf81..3e96451086 100644
--- a/data/mappings/keyboard_aliases.json
+++ b/data/mappings/keyboard_aliases.json
@@ -242,9 +242,6 @@
honeycomb: {
target: 'keyhive/honeycomb'
},
- id80: {
- target: 'id80/ansi'
- },
idb_60: {
target: 'idb/idb_60',
layouts: {
@@ -826,6 +823,9 @@
geminate60: {
target: 'weirdo/geminate60'
},
+ gentleman65: {
+ target: 'jkeys_design/gentleman65'
+ },
georgi: {
target: 'gboards/georgi'
},
@@ -844,6 +844,9 @@
halberd: {
target: 'kagizaraya/halberd'
},
+ handwired/hillside/0_1: {
+ target: 'handwired/hillside/48'
+ }
hecomi/alpha: {
target: 'takashiski/hecomi/alpha'
},
@@ -857,7 +860,13 @@
target: 'idobao/id67/rgb'
},
id80: {
- target: 'idobao/id80/v1'
+ target: 'idobao/id80/v2/ansi'
+ },
+ idobao/id80/v1/ansi: {
+ target: 'idobao/id80/v2/ansi'
+ },
+ idobao/id80/v1/iso: {
+ target: 'idobao/id80/v2/iso'
},
id87: {
target: 'idobao/id87/v1'
diff --git a/data/schemas/api_keyboard.jsonschema b/data/schemas/api_keyboard.jsonschema
index d638658a1d..6a30b5d990 100644
--- a/data/schemas/api_keyboard.jsonschema
+++ b/data/schemas/api_keyboard.jsonschema
@@ -9,7 +9,6 @@
"properties": {
"url": {"type": "string"}
}
-
},
"parse_errors": {"$ref": "qmk.definitions.v1#/string_array"},
"parse_warnings": {"$ref": "qmk.definitions.v1#/string_array"},
diff --git a/data/schemas/definitions.jsonschema b/data/schemas/definitions.jsonschema
index 1bdfbbeb03..8b68a58482 100644
--- a/data/schemas/definitions.jsonschema
+++ b/data/schemas/definitions.jsonschema
@@ -1,5 +1,5 @@
{
- "$schema": "http://json-schema.org/draft-07/schema#",
+ "$schema": "https://json-schema.org/draft/2020-12/schema#",
"$id": "qmk.definitions.v1",
"title": "Common definitions used across QMK's jsonschemas.",
"type": "object",
@@ -65,8 +65,7 @@
]
},
"key_unit": {
- "type": "number",
- "min": 0.25
+ "type": "number"
},
"keyboard": {
"oneOf": [
@@ -103,8 +102,11 @@
"pattern": "^LINE_PIN\\d{1,2}$"
},
{
- "type": "number",
- "multipleOf": 1
+ "type": "string",
+ "pattern": "^GP\\d{1,2}$"
+ },
+ {
+ "type": "integer"
},
{
"type": "null"
@@ -115,14 +117,12 @@
"type": "number"
},
"signed_int": {
- "type": "number",
- "multipleOf": 1
+ "type": "integer"
},
"signed_int_8": {
- "type": "number",
- "min": -127,
- "max": 127,
- "multipleOf": 1
+ "type": "integer",
+ "minimum": -127,
+ "maximum": 127
},
"string_array": {
"type": "array",
@@ -138,17 +138,20 @@
},
"unsigned_decimal": {
"type": "number",
- "min": 0
+ "minimum": 0
},
"unsigned_int": {
- "type": "number",
- "min": 0,
- "multipleOf": 1
+ "type": "integer",
+ "minimum": 0
},
"unsigned_int_8": {
- "type": "number",
- "min": 0,
- "max": 255,
- "multipleOf": 1
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 255
+ },
+ "bit": {
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 1
}
}
diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema
index dc5592220b..4c785a968a 100644
--- a/data/schemas/keyboard.jsonschema
+++ b/data/schemas/keyboard.jsonschema
@@ -1,7 +1,27 @@
{
- "$schema": "http://json-schema.org/draft-07/schema#",
+ "$schema": "https://json-schema.org/draft/2020-12/schema#",
"$id": "qmk.keyboard.v1",
"title": "Keyboard Information",
+ "definitions": {
+ "encoder_config": {
+ "type": "object",
+ "properties": {
+ "rotary": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["pin_a", "pin_b"],
+ "properties": {
+ "pin_a": {"$ref": "qmk.definitions.v1#/mcu_pin"},
+ "pin_b": {"$ref": "qmk.definitions.v1#/mcu_pin"},
+ "resolution": {"$ref": "qmk.definitions.v1#/unsigned_int"}
+ }
+ }
+ }
+ }
+ }
+ },
"type": "object",
"properties": {
"keyboard_name": {"$ref": "qmk.definitions.v1#/text_identifier"},
@@ -14,7 +34,7 @@
},
"development_board": {
"type": "string",
- "enum": ["promicro", "elite_c", "proton_c", "bluepill", "blackpill_f401", "blackpill_f411"]
+ "enum": ["promicro", "elite_c", "proton_c", "kb2040", "promicro_rp2040", "blok", "bit_c_pro", "stemcell", "bluepill", "blackpill_f401", "blackpill_f411", "bonsai_c4"]
},
"pin_compatible": {
"type": "string",
@@ -22,7 +42,7 @@
},
"processor": {
"type": "string",
- "enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "MK66FX1M0", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F405", "STM32F407", "STM32F411", "STM32F446", "STM32G431", "STM32G474", "STM32L412", "STM32L422", "STM32L432", "STM32L433", "STM32L442", "STM32L443", "GD32VF103", "WB32F3G71", "WB32FQ95", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"]
+ "enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "MK64FX512", "MK66FX1M0", "RP2040", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F405", "STM32F407", "STM32F411", "STM32F446", "STM32G431", "STM32G474", "STM32L412", "STM32L422", "STM32L432", "STM32L433", "STM32L442", "STM32L443", "GD32VF103", "WB32F3G71", "WB32FQ95", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"]
},
"audio": {
"type": "object",
@@ -40,12 +60,12 @@
"breathing": {"type": "boolean"},
"breathing_period": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
"levels": {
- "type": "number",
- "min": 1,
- "max": 31,
- "multipleOf": 1
+ "type": "integer",
+ "minimum": 1,
+ "maximum": 31
},
- "pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}
+ "pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
+ "on_state": {"$ref": "qmk.definitions.v1#/bit"}
}
},
"bluetooth": {
@@ -56,7 +76,7 @@
"type": "string",
"enum": ["BluefruitLE", "RN42"]
},
- "lto": {"type": "boolean"},
+ "lto": {"type": "boolean"}
}
},
"board": {
@@ -66,7 +86,29 @@
},
"bootloader": {
"type": "string",
- "enum": ["atmel-dfu", "bootloadhid", "bootloadHID", "custom", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "md-boot", "qmk-dfu", "qmk-hid", "stm32-dfu", "stm32duino", "gd32v-dfu", "wb32-dfu", "unknown", "usbasploader", "USBasp", "tinyuf2"],
+ "enum": [
+ "atmel-dfu",
+ "bootloadhid",
+ "bootloadHID",
+ "caterina",
+ "custom",
+ "gd32v-dfu",
+ "halfkay",
+ "kiibohd",
+ "lufa-dfu",
+ "lufa-ms",
+ "md-boot",
+ "qmk-dfu",
+ "qmk-hid",
+ "rp2040",
+ "stm32-dfu",
+ "stm32duino",
+ "tinyuf2",
+ "unknown",
+ "usbasploader",
+ "USBasp",
+ "wb32-dfu"
+ ]
},
"bootloader_instructions": {
"type": "string",
@@ -78,13 +120,13 @@
"properties": {
"debounce_type": {
"type": "string",
- "enum": ["custom", "eager_pk", "eager_pr", "sym_defer_pk", "sym_defer_pr", "sym_eager_pk"]
+ "enum": ["asym_eager_defer_pk", "custom", "sym_defer_g", "sym_defer_pk", "sym_defer_pr", "sym_eager_pk", "sym_eager_pr"]
},
"firmware_format": {
"type": "string",
"enum": ["bin", "hex", "uf2"]
},
- "lto": {"type": "boolean"},
+ "lto": {"type": "boolean"}
}
},
"diode_direction": {
@@ -99,8 +141,8 @@
"enabled": {"type": "boolean"},
"both_shifts_turns_on": {"type": "boolean"},
"double_tap_shift_turns_on": {"type": "boolean"},
- "idle_timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"},
- },
+ "idle_timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"}
+ }
},
"combo": {
"type": "object",
@@ -113,13 +155,22 @@
"type": "array",
"items": {"$ref": "qmk.definitions.v1#/filename"}
},
+ "encoder": {
+ "$ref": "#/definitions/encoder_config",
+ "properties": {
+ "enabled": {"type": "boolean"}
+ }
+ },
"features": {"$ref": "qmk.definitions.v1#/boolean_array"},
"indicators": {
"type": "object",
"properties": {
"caps_lock": {"$ref": "qmk.definitions.v1#/mcu_pin"},
"num_lock": {"$ref": "qmk.definitions.v1#/mcu_pin"},
- "scroll_lock": {"$ref": "qmk.definitions.v1#/mcu_pin"}
+ "scroll_lock": {"$ref": "qmk.definitions.v1#/mcu_pin"},
+ "compose": {"$ref": "qmk.definitions.v1#/mcu_pin"},
+ "kana": {"$ref": "qmk.definitions.v1#/mcu_pin"},
+ "on_state": {"$ref": "qmk.definitions.v1#/bit"}
}
},
"layout_aliases": {
@@ -145,18 +196,20 @@
"type": "object",
"additionalProperties": false,
"properties": {
- "label": {"type": "string"},
+ "label": {
+ "type": "string",
+ "pattern": "^[^\\n]*$"
+ },
"matrix": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
- "type": "number",
- "min": 0,
- "multipleOf": 1
+ "type": "integer",
+ "minimum": 0
}
},
- "r": {"$ref": "qmk.definitions.v1#/unsigned_decimal"},
+ "r": {"$ref": "qmk.definitions.v1#/signed_decimal"},
"rx": {"$ref": "qmk.definitions.v1#/unsigned_decimal"},
"ry": {"$ref": "qmk.definitions.v1#/unsigned_decimal"},
"h": {"$ref": "qmk.definitions.v1#/key_unit"},
@@ -190,18 +243,17 @@
"items": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}
},
"cols": {"$ref": "qmk.definitions.v1#/mcu_pin_array"},
- "rows": {"$ref": "qmk.definitions.v1#/mcu_pin_array"},
- "unused": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}
+ "rows": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}
}
},
"mouse_key": {
"type": "object",
"properties": {
"enabled": {"type": "boolean"},
- "delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
- "interval": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
- "max_speed": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
- "time_to_max": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
+ "delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
+ "interval": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
+ "max_speed": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
+ "time_to_max": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
"wheel_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
}
},
@@ -227,14 +279,13 @@
"minItems": 2,
"maxItems": 2,
"items": {
- "type": "number",
- "min": 0,
- "multipleOf": 1
+ "type": "integer",
+ "minimum": 0
}
},
"x": {"$ref": "qmk.definitions.v1#/key_unit"},
"y": {"$ref": "qmk.definitions.v1#/key_unit"},
- "flags": {"$ref": "qmk.definitions.v1#/unsigned_decimal"}
+ "flags": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
}
}
}
@@ -255,14 +306,13 @@
"minItems": 2,
"maxItems": 2,
"items": {
- "type": "number",
- "min": 0,
- "multipleOf": 1
+ "type": "integer",
+ "minimum": 0
}
},
"x": {"$ref": "qmk.definitions.v1#/key_unit"},
"y": {"$ref": "qmk.definitions.v1#/key_unit"},
- "flags": {"$ref": "qmk.definitions.v1#/unsigned_decimal"}
+ "flags": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
}
}
}
@@ -287,10 +337,9 @@
"blink": {"type": "boolean"},
"enabled": {"type": "boolean"},
"max": {
- "type": "number",
- "min": 1,
- "max": 32,
- "multipleOf": 1
+ "type": "integer",
+ "minimum": 1,
+ "maximum": 32
},
"override_rgb": {"type": "boolean"}
}
@@ -304,8 +353,8 @@
"split": {"type": "boolean"},
"split_count": {
"type": "array",
- "minLength": 2,
- "maxLength": 2,
+ "minItems": 2,
+ "maxItems": 2,
"items": {"$ref": "qmk.definitions.v1#/unsigned_int"}
}
}
@@ -319,21 +368,31 @@
"idle_timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"unlock_sequence": {
"type": "array",
- "minLength": 1,
- "maxLength": 5,
+ "minItems": 1,
+ "maxItems": 5,
"items": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
- "type": "number",
- "min": 0,
- "multipleOf": 1
+ "type": "integer",
+ "minimum": 0
}
}
}
}
},
+ "stenography": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled": {"type": "boolean"},
+ "protocol": {
+ "type": "string",
+ "enum": ["all", "geminipr", "txbolt"]
+ }
+ }
+ },
"split": {
"type": "object",
"additionalProperties": false,
@@ -362,16 +421,24 @@
}
}
},
+ "encoder": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "right": {
+ "$ref": "#/definitions/encoder_config"
+ }
+ }
+ },
"main": {
"type": "string",
"enum": ["eeprom", "left", "matrix_grid", "pin", "right"]
},
"soft_serial_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
"soft_serial_speed": {
- "type": "number",
- "min": 0,
- "max": 5,
- "multipleOf": 1
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 5
},
"transport": {
"type": "object",
@@ -413,7 +480,7 @@
"retro_per_key": {"type": "boolean"},
"term": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"term_per_key": {"type": "boolean"},
- "toggle": {"$ref": "qmk.definitions.v1#/unsigned_int"},
+ "toggle": {"$ref": "qmk.definitions.v1#/unsigned_int"}
}
},
"usb": {
@@ -425,7 +492,7 @@
"force_nkro": {"type": "boolean"},
"pid": {"$ref": "qmk.definitions.v1#/hex_number_4d"},
"vid": {"$ref": "qmk.definitions.v1#/hex_number_4d"},
- "max_power": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
+ "max_power": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"no_startup_check": {"type": "boolean"},
"polling_interval": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
"shared_endpoint": {
@@ -436,8 +503,8 @@
"mouse": {"type": "boolean"}
}
},
- "suspend_wakeup_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
- "wait_for": {"type": "boolean"},
+ "suspend_wakeup_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"},
+ "wait_for": {"type": "boolean"}
}
},
"qmk": {
@@ -445,8 +512,8 @@
"additionalProperties": false,
"properties": {
"keys_per_scan": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
- "tap_keycode_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
- "tap_capslock_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
+ "tap_keycode_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"},
+ "tap_capslock_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"}
}
},
"qmk_lufa_bootloader": {
diff --git a/data/schemas/keymap.jsonschema b/data/schemas/keymap.jsonschema
index 3803301a66..0a4fb5d453 100644
--- a/data/schemas/keymap.jsonschema
+++ b/data/schemas/keymap.jsonschema
@@ -1,5 +1,5 @@
{
- "$schema": "http://json-schema.org/draft-07/schema#",
+ "$schema": "https://json-schema.org/draft/2020-12/schema#",
"$id": "qmk.keymap.v1",
"title": "Keymap Information",
"type": "object",
@@ -31,7 +31,7 @@
"properties": {
"action": {
"type": "string",
- "enum": ['beep', 'delay', 'down', 'tap', 'up']
+ "enum": ["beep", "delay", "down", "tap", "up"]
},
"keycodes": {
"type": "array",
@@ -50,8 +50,7 @@
},
"config": {"$ref": "qmk.keyboard.v1"},
"notes": {
- "type": "string",
- "description": "asdf"
+ "type": "string"
}
},
"required": [
diff --git a/data/templates/keyboard/readme.md b/data/templates/keyboard/readme.md
index ca703c53f0..ab4f2d17ef 100644
--- a/data/templates/keyboard/readme.md
+++ b/data/templates/keyboard/readme.md
@@ -24,4 +24,4 @@ Enter the bootloader in 3 ways:
* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard
* **Physical reset button**: Briefly press the button on the back of the PCB - some may have pads you must short instead
-* **Keycode in layout**: Press the key mapped to `RESET` if it is available
+* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available
diff --git a/drivers/eeprom/eeprom_i2c.h b/drivers/eeprom/eeprom_i2c.h
index 77eea66d63..85317c9ea5 100644
--- a/drivers/eeprom/eeprom_i2c.h
+++ b/drivers/eeprom/eeprom_i2c.h
@@ -54,6 +54,11 @@
# define EXTERNAL_EEPROM_PAGE_SIZE 32
# define EXTERNAL_EEPROM_ADDRESS_SIZE 2
# define EXTERNAL_EEPROM_WRITE_TIME 5
+#elif defined(EEPROM_I2C_24LC32A)
+# define EXTERNAL_EEPROM_BYTE_COUNT 4096
+# define EXTERNAL_EEPROM_PAGE_SIZE 32
+# define EXTERNAL_EEPROM_ADDRESS_SIZE 2
+# define EXTERNAL_EEPROM_WRITE_TIME 5
#elif defined(EEPROM_I2C_MB85RC256V)
# define EXTERNAL_EEPROM_BYTE_COUNT 32768
# define EXTERNAL_EEPROM_PAGE_SIZE 128
diff --git a/drivers/eeprom/eeprom_spi.c b/drivers/eeprom/eeprom_spi.c
index 25955498c4..51ba25dece 100644
--- a/drivers/eeprom/eeprom_spi.c
+++ b/drivers/eeprom/eeprom_spi.c
@@ -58,14 +58,20 @@ static bool spi_eeprom_start(void) {
static spi_status_t spi_eeprom_wait_while_busy(int timeout) {
uint32_t deadline = timer_read32() + timeout;
- spi_status_t response;
- do {
+ spi_status_t response = SR_WIP;
+ while (response & SR_WIP) {
+ if (!spi_eeprom_start()) {
+ return SPI_STATUS_ERROR;
+ }
+
spi_write(CMD_RDSR);
response = spi_read();
+ spi_stop();
+
if (timer_read32() >= deadline) {
return SPI_STATUS_TIMEOUT;
}
- } while (response & SR_WIP);
+ }
return SPI_STATUS_SUCCESS;
}
@@ -105,27 +111,21 @@ void eeprom_driver_erase(void) {
void eeprom_read_block(void *buf, const void *addr, size_t len) {
//-------------------------------------------------
// Wait for the write-in-progress bit to be cleared
- bool res = spi_eeprom_start();
- if (!res) {
- dprint("failed to start SPI for WIP check\n");
- memset(buf, 0, len);
- return;
- }
-
spi_status_t response = spi_eeprom_wait_while_busy(EXTERNAL_EEPROM_SPI_TIMEOUT);
- spi_stop();
- if (response == SPI_STATUS_TIMEOUT) {
- dprint("SPI timeout for WIP check\n");
+ if (response != SPI_STATUS_SUCCESS) {
+ spi_stop();
memset(buf, 0, len);
+ dprint("SPI timeout for WIP check\n");
return;
}
//-------------------------------------------------
// Perform read
- res = spi_eeprom_start();
+ bool res = spi_eeprom_start();
if (!res) {
- dprint("failed to start SPI for read\n");
+ spi_stop();
memset(buf, 0, len);
+ dprint("failed to start SPI for read\n");
return;
}
@@ -158,15 +158,9 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
//-------------------------------------------------
// Wait for the write-in-progress bit to be cleared
- res = spi_eeprom_start();
- if (!res) {
- dprint("failed to start SPI for WIP check\n");
- return;
- }
-
spi_status_t response = spi_eeprom_wait_while_busy(EXTERNAL_EEPROM_SPI_TIMEOUT);
- spi_stop();
- if (response == SPI_STATUS_TIMEOUT) {
+ if (response != SPI_STATUS_SUCCESS) {
+ spi_stop();
dprint("SPI timeout for WIP check\n");
return;
}
@@ -175,6 +169,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
// Enable writes
res = spi_eeprom_start();
if (!res) {
+ spi_stop();
dprint("failed to start SPI for write-enable\n");
return;
}
@@ -186,6 +181,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
// Perform the write
res = spi_eeprom_start();
if (!res) {
+ spi_stop();
dprint("failed to start SPI for write\n");
return;
}
diff --git a/drivers/eeprom/eeprom_wear_leveling.c b/drivers/eeprom/eeprom_wear_leveling.c
new file mode 100644
index 0000000000..bd77eef35c
--- /dev/null
+++ b/drivers/eeprom/eeprom_wear_leveling.c
@@ -0,0 +1,23 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <stdint.h>
+#include <string.h>
+
+#include "eeprom_driver.h"
+#include "wear_leveling.h"
+
+void eeprom_driver_init(void) {
+ wear_leveling_init();
+}
+
+void eeprom_driver_erase(void) {
+ wear_leveling_erase();
+}
+
+void eeprom_read_block(void *buf, const void *addr, size_t len) {
+ wear_leveling_read((uint32_t)addr, buf, len);
+}
+
+void eeprom_write_block(const void *buf, void *addr, size_t len) {
+ wear_leveling_write((uint32_t)addr, buf, len);
+}
diff --git a/drivers/flash/flash_spi.c b/drivers/flash/flash_spi.c
index 684ee06d71..0c0eb8a99e 100644
--- a/drivers/flash/flash_spi.c
+++ b/drivers/flash/flash_spi.c
@@ -207,7 +207,7 @@ flash_status_t flash_erase_sector(uint32_t addr) {
/* Check that the address exceeds the limit. */
if ((addr + (EXTERNAL_FLASH_SECTOR_SIZE)) >= (EXTERNAL_FLASH_SIZE) || ((addr % (EXTERNAL_FLASH_SECTOR_SIZE)) != 0)) {
- dprintf("Flash erase sector address over limit! [addr:0x%x]\n", (uint32_t)addr);
+ dprintf("Flash erase sector address over limit! [addr:0x%lx]\n", (uint32_t)addr);
return FLASH_STATUS_ERROR;
}
@@ -247,7 +247,7 @@ flash_status_t flash_erase_block(uint32_t addr) {
/* Check that the address exceeds the limit. */
if ((addr + (EXTERNAL_FLASH_BLOCK_SIZE)) >= (EXTERNAL_FLASH_SIZE) || ((addr % (EXTERNAL_FLASH_BLOCK_SIZE)) != 0)) {
- dprintf("Flash erase block address over limit! [addr:0x%x]\n", (uint32_t)addr);
+ dprintf("Flash erase block address over limit! [addr:0x%lx]\n", (uint32_t)addr);
return FLASH_STATUS_ERROR;
}
@@ -303,7 +303,7 @@ flash_status_t flash_read_block(uint32_t addr, void *buf, size_t len) {
}
#if defined(CONSOLE_ENABLE) && defined(DEBUG_FLASH_SPI_OUTPUT)
- dprintf("[SPI FLASH R] 0x%08lX: ", addr);
+ dprintf("[SPI FLASH R] 0x%08lx: ", addr);
for (size_t i = 0; i < len; ++i) {
dprintf(" %02X", (int)(((uint8_t *)read_buf)[i]));
}
@@ -339,7 +339,7 @@ flash_status_t flash_write_block(uint32_t addr, const void *buf, size_t len) {
}
#if defined(CONSOLE_ENABLE) && defined(DEBUG_FLASH_SPI_OUTPUT)
- dprintf("[SPI FLASH W] 0x%08lX: ", addr);
+ dprintf("[SPI FLASH W] 0x%08lx: ", addr);
for (size_t i = 0; i < write_length; i++) {
dprintf(" %02X", (int)(uint8_t)(write_buf[i]));
}
diff --git a/drivers/gpio/pca9505.c b/drivers/gpio/pca9505.c
new file mode 100644
index 0000000000..5803746c96
--- /dev/null
+++ b/drivers/gpio/pca9505.c
@@ -0,0 +1,166 @@
+// Copyright 2022 nirim000
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "i2c_master.h"
+#include "pca9505.h"
+
+#include "debug.h"
+
+#define SLAVE_TO_ADDR(n) (n << 1)
+#define TIMEOUT 100
+
+enum {
+ CMD_INPUT_0 = 0,
+ CMD_INPUT_1,
+ CMD_INPUT_2,
+ CMD_INPUT_3,
+ CMD_INPUT_4,
+ CMD_OUTPUT_0 = 8,
+ CMD_OUTPUT_1,
+ CMD_OUTPUT_2,
+ CMD_OUTPUT_3,
+ CMD_OUTPUT_4,
+ CMD_INVERSION_0 = 16,
+ CMD_INVERSION_1,
+ CMD_INVERSION_2,
+ CMD_INVERSION_3,
+ CMD_INVERSION_4,
+ CMD_CONFIG_0 = 24,
+ CMD_CONFIG_1,
+ CMD_CONFIG_2,
+ CMD_CONFIG_3,
+ CMD_CONFIG_4,
+};
+
+void pca9505_init(uint8_t slave_addr) {
+ static uint8_t s_init = 0;
+ if (!s_init) {
+ i2c_init();
+
+ s_init = 1;
+ }
+
+ // TODO: could check device connected
+ // i2c_start(SLAVE_TO_ADDR(slave) | I2C_WRITE);
+ // i2c_stop();
+}
+
+bool pca9505_set_config(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) {
+ uint8_t addr = SLAVE_TO_ADDR(slave_addr);
+ uint8_t cmd = 0;
+ switch (port) {
+ case 0:
+ cmd = CMD_CONFIG_0;
+ break;
+ case 1:
+ cmd = CMD_CONFIG_1;
+ break;
+ case 2:
+ cmd = CMD_CONFIG_2;
+ break;
+ case 3:
+ cmd = CMD_CONFIG_3;
+ break;
+ case 4:
+ cmd = CMD_CONFIG_4;
+ break;
+ }
+
+ i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
+ if (ret != I2C_STATUS_SUCCESS) {
+ print("pca9505_set_config::FAILED\n");
+ return false;
+ }
+
+ return true;
+}
+
+bool pca9505_set_polarity(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) {
+ uint8_t addr = SLAVE_TO_ADDR(slave_addr);
+ uint8_t cmd = 0;
+ switch (port) {
+ case 0:
+ cmd = CMD_INVERSION_0;
+ break;
+ case 1:
+ cmd = CMD_INVERSION_1;
+ break;
+ case 2:
+ cmd = CMD_INVERSION_2;
+ break;
+ case 3:
+ cmd = CMD_INVERSION_3;
+ break;
+ case 4:
+ cmd = CMD_INVERSION_4;
+ break;
+ }
+
+ i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
+ if (ret != I2C_STATUS_SUCCESS) {
+ print("pca9505_set_polarity::FAILED\n");
+ return false;
+ }
+
+ return true;
+}
+
+bool pca9505_set_output(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) {
+ uint8_t addr = SLAVE_TO_ADDR(slave_addr);
+ uint8_t cmd = 0;
+ switch (port) {
+ case 0:
+ cmd = CMD_OUTPUT_0;
+ break;
+ case 1:
+ cmd = CMD_OUTPUT_1;
+ break;
+ case 2:
+ cmd = CMD_OUTPUT_2;
+ break;
+ case 3:
+ cmd = CMD_OUTPUT_3;
+ break;
+ case 4:
+ cmd = CMD_OUTPUT_4;
+ break;
+ }
+
+ i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
+ if (ret != I2C_STATUS_SUCCESS) {
+ print("pca9505_set_output::FAILED\n");
+ return false;
+ }
+
+ return true;
+}
+
+bool pca9505_readPins(uint8_t slave_addr, pca9505_port_t port, uint8_t* out) {
+ uint8_t addr = SLAVE_TO_ADDR(slave_addr);
+ uint8_t cmd = 0;
+ switch (port) {
+ case 0:
+ cmd = CMD_INPUT_0;
+ break;
+ case 1:
+ cmd = CMD_INPUT_1;
+ break;
+ case 2:
+ cmd = CMD_INPUT_2;
+ break;
+ case 3:
+ cmd = CMD_INPUT_3;
+ break;
+ case 4:
+ cmd = CMD_INPUT_4;
+ break;
+ }
+
+ i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
+ if (ret != I2C_STATUS_SUCCESS) {
+ print("pca9505_readPins::FAILED\n");
+ return false;
+ }
+
+ return true;
+}
diff --git a/drivers/gpio/pca9505.h b/drivers/gpio/pca9505.h
new file mode 100644
index 0000000000..732ddb88ea
--- /dev/null
+++ b/drivers/gpio/pca9505.h
@@ -0,0 +1,67 @@
+// Copyright 2022 nirim000
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+
+/**
+ * Port ID
+ */
+typedef enum {
+ PCA9505_PORT0,
+ PCA9505_PORT1,
+ PCA9505_PORT2,
+ PCA9505_PORT3,
+ PCA9505_PORT4,
+} pca9505_port_t;
+
+/**
+ * Helpers for set_config
+ */
+enum {
+ ALL_NORMAL = 0,
+ ALL_INVERTED = 0xFF,
+};
+
+/**
+ * Helpers for set_config
+ */
+enum {
+ ALL_OUTPUT = 0,
+ ALL_INPUT = 0xFF,
+};
+
+/**
+ * Helpers for set_output
+ */
+enum {
+ ALL_LOW = 0,
+ ALL_HIGH = 0xFF,
+};
+
+/**
+ * Init expander and any other dependent drivers
+ */
+void pca9505_init(uint8_t slave_addr);
+
+/**
+ * Configure input/output to a given port
+ */
+bool pca9505_set_config(uint8_t slave_addr, pca9505_port_t port, uint8_t conf);
+
+/**
+ * Configure polarity to a given port
+ */
+bool pca9505_set_polarity(uint8_t slave_addr, pca9505_port_t port, uint8_t conf);
+
+/**
+ * Write high/low to a given port
+ */
+bool pca9505_set_output(uint8_t slave_addr, pca9505_port_t port, uint8_t conf);
+
+/**
+ * Read state of a given port
+ */
+bool pca9505_readPins(uint8_t slave_addr, pca9505_port_t port, uint8_t* ret);
diff --git a/drivers/led/aw20216.c b/drivers/led/aw20216.c
index 59389cdcd6..55083936ef 100644
--- a/drivers/led/aw20216.c
+++ b/drivers/led/aw20216.c
@@ -53,6 +53,10 @@
# define AW_GLOBAL_CURRENT_MAX 150
#endif
+#ifndef AW_SPI_MODE
+# define AW_SPI_MODE 0
+#endif
+
#ifndef AW_SPI_DIVISOR
# define AW_SPI_DIVISOR 4
#endif
@@ -63,7 +67,7 @@ bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false};
bool AW20216_write(pin_t cs_pin, uint8_t page, uint8_t reg, uint8_t* data, uint8_t len) {
static uint8_t s_spi_transfer_buffer[2] = {0};
- if (!spi_start(cs_pin, false, 0, AW_SPI_DIVISOR)) {
+ if (!spi_start(cs_pin, false, AW_SPI_MODE, AW_SPI_DIVISOR)) {
spi_stop();
return false;
}
diff --git a/drivers/led/ckled2001-simple.c b/drivers/led/ckled2001-simple.c
new file mode 100644
index 0000000000..da4bf20b99
--- /dev/null
+++ b/drivers/led/ckled2001-simple.c
@@ -0,0 +1,218 @@
+/* Copyright 2021 @ Keychron (https://www.keychron.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ckled2001-simple.h"
+#include "i2c_master.h"
+#include "wait.h"
+
+#ifndef CKLED2001_TIMEOUT
+# define CKLED2001_TIMEOUT 100
+#endif
+
+#ifndef CKLED2001_PERSISTENCE
+# define CKLED2001_PERSISTENCE 0
+#endif
+
+#ifndef PHASE_CHANNEL
+# define PHASE_CHANNEL MSKPHASE_12CHANNEL
+#endif
+
+#ifndef CKLED2001_CURRENT_TUNE
+# define CKLED2001_CURRENT_TUNE \
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
+#endif
+
+// Transfer buffer for TWITransmitData()
+uint8_t g_twi_transfer_buffer[20];
+
+// These buffers match the CKLED2001 PWM registers.
+// The control buffers match the PG0 LED On/Off registers.
+// Storing them like this is optimal for I2C transfers to the registers.
+// We could optimize this and take out the unused registers from these
+// buffers and the transfers in CKLED2001_write_pwm_buffer() but it's
+// probably not worth the extra complexity.
+uint8_t g_pwm_buffer[DRIVER_COUNT][192];
+bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false};
+
+uint8_t g_led_control_registers[DRIVER_COUNT][24] = {0};
+bool g_led_control_registers_update_required[DRIVER_COUNT] = {false};
+
+bool CKLED2001_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
+ // If the transaction fails function returns false.
+ g_twi_transfer_buffer[0] = reg;
+ g_twi_transfer_buffer[1] = data;
+
+#if CKLED2001_PERSISTENCE > 0
+ for (uint8_t i = 0; i < CKLED2001_PERSISTENCE; i++) {
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, CKLED2001_TIMEOUT) != 0) {
+ return false;
+ }
+ }
+#else
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, CKLED2001_TIMEOUT) != 0) {
+ return false;
+ }
+#endif
+ return true;
+}
+
+bool CKLED2001_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
+ // Assumes PG1 is already selected.
+ // If any of the transactions fails function returns false.
+ // Transmit PWM registers in 12 transfers of 16 bytes.
+ // g_twi_transfer_buffer[] is 20 bytes
+
+ // Iterate over the pwm_buffer contents at 16 byte intervals.
+ for (int i = 0; i < 192; i += 16) {
+ g_twi_transfer_buffer[0] = i;
+ // Copy the data from i to i+15.
+ // Device will auto-increment register for data after the first byte
+ // Thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer.
+ for (int j = 0; j < 16; j++) {
+ g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
+ }
+
+#if CKLED2001_PERSISTENCE > 0
+ for (uint8_t i = 0; i < CKLED2001_PERSISTENCE; i++) {
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, CKLED2001_TIMEOUT) != 0) {
+ return false;
+ }
+ }
+#else
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, CKLED2001_TIMEOUT) != 0) {
+ return false;
+ }
+#endif
+ }
+ return true;
+}
+
+void CKLED2001_init(uint8_t addr) {
+ // Select to function page
+ CKLED2001_write_register(addr, CONFIGURE_CMD_PAGE, FUNCTION_PAGE);
+ // Setting LED driver to shutdown mode
+ CKLED2001_write_register(addr, CONFIGURATION_REG, MSKSW_SHUT_DOWN_MODE);
+ // Setting internal channel pulldown/pullup
+ CKLED2001_write_register(addr, PDU_REG, MSKSET_CA_CB_CHANNEL);
+ // Select number of scan phase
+ CKLED2001_write_register(addr, SCAN_PHASE_REG, PHASE_CHANNEL);
+ // Setting PWM Delay Phase
+ CKLED2001_write_register(addr, SLEW_RATE_CONTROL_MODE1_REG, MSKPWM_DELAY_PHASE_ENABLE);
+ // Setting Driving/Sinking Channel Slew Rate
+ CKLED2001_write_register(addr, SLEW_RATE_CONTROL_MODE2_REG, MSKDRIVING_SINKING_CHHANNEL_SLEWRATE_ENABLE);
+ // Setting Iref
+ CKLED2001_write_register(addr, SOFTWARE_SLEEP_REG, MSKSLEEP_DISABLE);
+ // Set LED CONTROL PAGE (Page 0)
+ CKLED2001_write_register(addr, CONFIGURE_CMD_PAGE, LED_CONTROL_PAGE);
+ for (int i = 0; i < LED_CONTROL_ON_OFF_LENGTH; i++) {
+ CKLED2001_write_register(addr, i, 0x00);
+ }
+
+ // Set PWM PAGE (Page 1)
+ CKLED2001_write_register(addr, CONFIGURE_CMD_PAGE, LED_PWM_PAGE);
+ for (int i = 0; i < LED_CURRENT_TUNE_LENGTH; i++) {
+ CKLED2001_write_register(addr, i, 0x00);
+ }
+
+ // Set CURRENT PAGE (Page 4)
+ uint8_t current_tuen_reg_list[LED_CURRENT_TUNE_LENGTH] = CKLED2001_CURRENT_TUNE;
+ CKLED2001_write_register(addr, CONFIGURE_CMD_PAGE, CURRENT_TUNE_PAGE);
+ for (int i = 0; i < LED_CURRENT_TUNE_LENGTH; i++) {
+ CKLED2001_write_register(addr, i, current_tuen_reg_list[i]);
+ }
+
+ // Enable LEDs ON/OFF
+ CKLED2001_write_register(addr, CONFIGURE_CMD_PAGE, LED_CONTROL_PAGE);
+ for (int i = 0; i < LED_CONTROL_ON_OFF_LENGTH; i++) {
+ CKLED2001_write_register(addr, i, 0xFF);
+ }
+
+ // Select to function page
+ CKLED2001_write_register(addr, CONFIGURE_CMD_PAGE, FUNCTION_PAGE);
+ // Setting LED driver to normal mode
+ CKLED2001_write_register(addr, CONFIGURATION_REG, MSKSW_NORMAL_MODE);
+}
+
+void CKLED2001_set_value(int index, uint8_t value) {
+ ckled2001_led led;
+ if (index >= 0 && index < DRIVER_LED_TOTAL) {
+ memcpy_P(&led, (&g_ckled2001_leds[index]), sizeof(led));
+
+ g_pwm_buffer[led.driver][led.v] = value;
+ g_pwm_buffer_update_required[led.driver] = true;
+ }
+}
+
+void CKLED2001_set_value_all(uint8_t value) {
+ for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
+ CKLED2001_set_value(i, value);
+ }
+}
+
+void CKLED2001_set_led_control_register(uint8_t index, bool value) {
+ ckled2001_led led;
+ memcpy_P(&led, (&g_ckled2001_leds[index]), sizeof(led));
+
+ uint8_t control_register = led.v / 8;
+ uint8_t bit_value = led.v % 8;
+
+ if (value) {
+ g_led_control_registers[led.driver][control_register] |= (1 << bit_value);
+ } else {
+ g_led_control_registers[led.driver][control_register] &= ~(1 << bit_value);
+ }
+
+ g_led_control_registers_update_required[led.driver] = true;
+}
+
+void CKLED2001_update_pwm_buffers(uint8_t addr, uint8_t index) {
+ if (g_pwm_buffer_update_required[index]) {
+ CKLED2001_write_register(addr, CONFIGURE_CMD_PAGE, LED_PWM_PAGE);
+
+ // If any of the transactions fail we risk writing dirty PG0,
+ // refresh page 0 just in case.
+ if (!CKLED2001_write_pwm_buffer(addr, g_pwm_buffer[index])) {
+ g_led_control_registers_update_required[index] = true;
+ }
+ }
+ g_pwm_buffer_update_required[index] = false;
+}
+
+void CKLED2001_update_led_control_registers(uint8_t addr, uint8_t index) {
+ if (g_led_control_registers_update_required[index]) {
+ CKLED2001_write_register(addr, CONFIGURE_CMD_PAGE, LED_CONTROL_PAGE);
+ for (int i = 0; i < 24; i++) {
+ CKLED2001_write_register(addr, i, g_led_control_registers[index][i]);
+ }
+ }
+ g_led_control_registers_update_required[index] = false;
+}
+
+void CKLED2001_sw_return_normal(uint8_t addr) {
+ // Select to function page
+ CKLED2001_write_register(addr, CONFIGURE_CMD_PAGE, FUNCTION_PAGE);
+ // Setting LED driver to normal mode
+ CKLED2001_write_register(addr, CONFIGURATION_REG, MSKSW_NORMAL_MODE);
+}
+
+void CKLED2001_sw_shutdown(uint8_t addr) {
+ // Select to function page
+ CKLED2001_write_register(addr, CONFIGURE_CMD_PAGE, FUNCTION_PAGE);
+ // Setting LED driver to shutdown mode
+ CKLED2001_write_register(addr, CONFIGURATION_REG, MSKSW_SHUT_DOWN_MODE);
+ // Write SW Sleep Register
+ CKLED2001_write_register(addr, SOFTWARE_SLEEP_REG, MSKSLEEP_ENABLE);
+}
diff --git a/drivers/led/ckled2001-simple.h b/drivers/led/ckled2001-simple.h
new file mode 100644
index 0000000000..731da2e1cd
--- /dev/null
+++ b/drivers/led/ckled2001-simple.h
@@ -0,0 +1,337 @@
+/* Copyright 2021 @ Keychron (https://www.keychron.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "progmem.h"
+
+typedef struct ckled2001_led {
+ uint8_t driver : 2;
+ uint8_t v;
+} __attribute__((packed)) ckled2001_led;
+
+extern const ckled2001_led PROGMEM g_ckled2001_leds[DRIVER_LED_TOTAL];
+
+void CKLED2001_init(uint8_t addr);
+bool CKLED2001_write_register(uint8_t addr, uint8_t reg, uint8_t data);
+bool CKLED2001_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
+
+void CKLED2001_set_value(int index, uint8_t value);
+void CKLED2001_set_value_all(uint8_t value);
+
+void CKLED2001_set_led_control_register(uint8_t index, bool value);
+
+// This should not be called from an interrupt
+// (eg. from a timer interrupt).
+// Call this while idle (in between matrix scans).
+// If the buffer is dirty, it will update the driver with the buffer.
+void CKLED2001_update_pwm_buffers(uint8_t addr, uint8_t index);
+void CKLED2001_update_led_control_registers(uint8_t addr, uint8_t index);
+
+void CKLED2001_sw_return_normal(uint8_t addr);
+void CKLED2001_sw_shutdown(uint8_t addr);
+
+// Registers Page Define
+#define CONFIGURE_CMD_PAGE 0xFD
+#define LED_CONTROL_PAGE 0x00
+#define LED_PWM_PAGE 0x01
+#define FUNCTION_PAGE 0x03
+#define CURRENT_TUNE_PAGE 0x04
+
+// Function Register: address 0x00
+#define CONFIGURATION_REG 0x00
+#define MSKSW_SHUT_DOWN_MODE (0x0 << 0)
+#define MSKSW_NORMAL_MODE (0x1 << 0)
+
+#define DRIVER_ID_REG 0x11
+#define CKLED2001_ID 0x8A
+
+#define PDU_REG 0x13
+#define MSKSET_CA_CB_CHANNEL 0xAA
+#define MSKCLR_CA_CB_CHANNEL 0x00
+
+#define SCAN_PHASE_REG 0x14
+#define MSKPHASE_12CHANNEL 0x00
+#define MSKPHASE_11CHANNEL 0x01
+#define MSKPHASE_10CHANNEL 0x02
+#define MSKPHASE_9CHANNEL 0x03
+#define MSKPHASE_8CHANNEL 0x04
+#define MSKPHASE_7CHANNEL 0x05
+#define MSKPHASE_6CHANNEL 0x06
+#define MSKPHASE_5CHANNEL 0x07
+#define MSKPHASE_4CHANNEL 0x08
+#define MSKPHASE_3CHANNEL 0x09
+#define MSKPHASE_2CHANNEL 0x0A
+#define MSKPHASE_1CHANNEL 0x0B
+
+#define SLEW_RATE_CONTROL_MODE1_REG 0x15
+#define MSKPWM_DELAY_PHASE_ENABLE 0x04
+#define MSKPWM_DELAY_PHASE_DISABLE 0x00
+
+#define SLEW_RATE_CONTROL_MODE2_REG 0x16
+#define MSKDRIVING_SINKING_CHHANNEL_SLEWRATE_ENABLE 0xC0
+#define MSKDRIVING_SINKING_CHHANNEL_SLEWRATE_DISABLE 0x00
+
+#define OPEN_SHORT_ENABLE_REG 0x17
+#define MSKOPEN_DETECTION_ENABLE (0x01 << 7)
+#define MSKOPEN_DETECTION_DISABLE (0x00)
+
+#define MSKSHORT_DETECTION_ENABLE (0x01 << 6)
+#define MSKSHORT_DETECTION_DISABLE (0x00)
+
+#define OPEN_SHORT_DUTY_REG 0x18
+#define OPEN_SHORT_FLAG_REG 0x19
+
+#define MSKOPEN_DETECTION_INTERRUPT_ENABLE (0x01 << 7)
+#define MSKOPEN_DETECTION_INTERRUPT_DISABLE (0x00)
+
+#define MSKSHORT_DETECTION_INTERRUPT_ENABLE (0x01 << 6)
+#define MSKSHORT_DETECTION_INTERRUPT_DISABLE (0x00)
+
+#define SOFTWARE_SLEEP_REG 0x1A
+#define MSKSLEEP_ENABLE 0x02
+#define MSKSLEEP_DISABLE 0x00
+
+// LED Control Registers
+#define LED_CONTROL_ON_OFF_FIRST_ADDR 0x0
+#define LED_CONTROL_ON_OFF_LAST_ADDR 0x17
+#define LED_CONTROL_ON_OFF_LENGTH ((LED_CONTROL_ON_OFF_LAST_ADDR - LED_CONTROL_ON_OFF_FIRST_ADDR) + 1)
+
+#define LED_CONTROL_OPEN_FIRST_ADDR 0x18
+#define LED_CONTROL_OPEN_LAST_ADDR 0x2F
+#define LED_CONTROL_OPEN_LENGTH ((LED_CONTROL_OPEN_LAST_ADDR - LED_CONTROL_OPEN_FIRST_ADDR) + 1)
+
+#define LED_CONTROL_SHORT_FIRST_ADDR 0x30
+#define LED_CONTROL_SHORT_LAST_ADDR 0x47
+#define LED_CONTROL_SHORT_LENGTH ((LED_CONTROL_SHORT_LAST_ADDR - LED_CONTROL_SHORT_FIRST_ADDR) + 1)
+
+#define LED_CONTROL_PAGE_LENGTH 0x48
+
+// LED Control Registers
+#define LED_PWM_FIRST_ADDR 0x00
+#define LED_PWM_LAST_ADDR 0xBF
+#define LED_PWM_LENGTH 0xC0
+
+// Current Tune Registers
+#define LED_CURRENT_TUNE_FIRST_ADDR 0x00
+#define LED_CURRENT_TUNE_LAST_ADDR 0x0B
+#define LED_CURRENT_TUNE_LENGTH 0x0C
+
+#define A_1 0x00
+#define A_2 0x01
+#define A_3 0x02
+#define A_4 0x03
+#define A_5 0x04
+#define A_6 0x05
+#define A_7 0x06
+#define A_8 0x07
+#define A_9 0x08
+#define A_10 0x09
+#define A_11 0x0A
+#define A_12 0x0B
+#define A_13 0x0C
+#define A_14 0x0D
+#define A_15 0x0E
+#define A_16 0x0F
+
+#define B_1 0x10
+#define B_2 0x11
+#define B_3 0x12
+#define B_4 0x13
+#define B_5 0x14
+#define B_6 0x15
+#define B_7 0x16
+#define B_8 0x17
+#define B_9 0x18
+#define B_10 0x19
+#define B_11 0x1A
+#define B_12 0x1B
+#define B_13 0x1C
+#define B_14 0x1D
+#define B_15 0x1E
+#define B_16 0x1F
+
+#define C_1 0x20
+#define C_2 0x21
+#define C_3 0x22
+#define C_4 0x23
+#define C_5 0x24
+#define C_6 0x25
+#define C_7 0x26
+#define C_8 0x27
+#define C_9 0x28
+#define C_10 0x29
+#define C_11 0x2A
+#define C_12 0x2B
+#define C_13 0x2C
+#define C_14 0x2D
+#define C_15 0x2E
+#define C_16 0x2F
+
+#define D_1 0x30
+#define D_2 0x31
+#define D_3 0x32
+#define D_4 0x33
+#define D_5 0x34
+#define D_6 0x35
+#define D_7 0x36
+#define D_8 0x37
+#define D_9 0x38
+#define D_10 0x39
+#define D_11 0x3A
+#define D_12 0x3B
+#define D_13 0x3C
+#define D_14 0x3D
+#define D_15 0x3E
+#define D_16 0x3F
+
+#define E_1 0x40
+#define E_2 0x41
+#define E_3 0x42
+#define E_4 0x43
+#define E_5 0x44
+#define E_6 0x45
+#define E_7 0x46
+#define E_8 0x47
+#define E_9 0x48
+#define E_10 0x49
+#define E_11 0x4A
+#define E_12 0x4B
+#define E_13 0x4C
+#define E_14 0x4D
+#define E_15 0x4E
+#define E_16 0x4F
+
+#define F_1 0x50
+#define F_2 0x51
+#define F_3 0x52
+#define F_4 0x53
+#define F_5 0x54
+#define F_6 0x55
+#define F_7 0x56
+#define F_8 0x57
+#define F_9 0x58
+#define F_10 0x59
+#define F_11 0x5A
+#define F_12 0x5B
+#define F_13 0x5C
+#define F_14 0x5D
+#define F_15 0x5E
+#define F_16 0x5F
+
+#define G_1 0x60
+#define G_2 0x61
+#define G_3 0x62
+#define G_4 0x63
+#define G_5 0x64
+#define G_6 0x65
+#define G_7 0x66
+#define G_8 0x67
+#define G_9 0x68
+#define G_10 0x69
+#define G_11 0x6A
+#define G_12 0x6B
+#define G_13 0x6C
+#define G_14 0x6D
+#define G_15 0x6E
+#define G_16 0x6F
+
+#define H_1 0x70
+#define H_2 0x71
+#define H_3 0x72
+#define H_4 0x73
+#define H_5 0x74
+#define H_6 0x75
+#define H_7 0x76
+#define H_8 0x77
+#define H_9 0x78
+#define H_10 0x79
+#define H_11 0x7A
+#define H_12 0x7B
+#define H_13 0x7C
+#define H_14 0x7D
+#define H_15 0x7E
+#define H_16 0x7F
+
+#define I_1 0x80
+#define I_2 0x81
+#define I_3 0x82
+#define I_4 0x83
+#define I_5 0x84
+#define I_6 0x85
+#define I_7 0x86
+#define I_8 0x87
+#define I_9 0x88
+#define I_10 0x89
+#define I_11 0x8A
+#define I_12 0x8B
+#define I_13 0x8C
+#define I_14 0x8D
+#define I_15 0x8E
+#define I_16 0x8F
+
+#define J_1 0x90
+#define J_2 0x91
+#define J_3 0x92
+#define J_4 0x93
+#define J_5 0x94
+#define J_6 0x95
+#define J_7 0x96
+#define J_8 0x97
+#define J_9 0x98
+#define J_10 0x99
+#define J_11 0x9A
+#define J_12 0x9B
+#define J_13 0x9C
+#define J_14 0x9D
+#define J_15 0x9E
+#define J_16 0x9F
+
+#define K_1 0xA0
+#define K_2 0xA1
+#define K_3 0xA2
+#define K_4 0xA3
+#define K_5 0xA4
+#define K_6 0xA5
+#define K_7 0xA6
+#define K_8 0xA7
+#define K_9 0xA8
+#define K_10 0xA9
+#define K_11 0xAA
+#define K_12 0xAB
+#define K_13 0xAC
+#define K_14 0xAD
+#define K_15 0xAE
+#define K_16 0xAF
+
+#define L_1 0xB0
+#define L_2 0xB1
+#define L_3 0xB2
+#define L_4 0xB3
+#define L_5 0xB4
+#define L_6 0xB5
+#define L_7 0xB6
+#define L_8 0xB7
+#define L_9 0xB8
+#define L_10 0xB9
+#define L_11 0xBA
+#define L_12 0xBB
+#define L_13 0xBC
+#define L_14 0xBD
+#define L_15 0xBE
+#define L_16 0xBF \ No newline at end of file
diff --git a/drivers/led/ckled2001.c b/drivers/led/ckled2001.c
index 8d71805a24..16a096780b 100644
--- a/drivers/led/ckled2001.c
+++ b/drivers/led/ckled2001.c
@@ -30,8 +30,13 @@
# define PHASE_CHANNEL MSKPHASE_12CHANNEL
#endif
+#ifndef CKLED2001_CURRENT_TUNE
+# define CKLED2001_CURRENT_TUNE \
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
+#endif
+
// Transfer buffer for TWITransmitData()
-uint8_t g_twi_transfer_buffer[20];
+uint8_t g_twi_transfer_buffer[65];
// These buffers match the CKLED2001 PWM registers.
// The control buffers match the PG0 LED On/Off registers.
@@ -67,27 +72,26 @@ bool CKLED2001_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
bool CKLED2001_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// Assumes PG1 is already selected.
// If any of the transactions fails function returns false.
- // Transmit PWM registers in 12 transfers of 16 bytes.
- // g_twi_transfer_buffer[] is 20 bytes
+ // Transmit PWM registers in 3 transfers of 64 bytes.
- // Iterate over the pwm_buffer contents at 16 byte intervals.
- for (int i = 0; i < 192; i += 16) {
+ // Iterate over the pwm_buffer contents at 64 byte intervals.
+ for (uint8_t i = 0; i < 192; i += 64) {
g_twi_transfer_buffer[0] = i;
- // Copy the data from i to i+15.
+ // Copy the data from i to i+63.
// Device will auto-increment register for data after the first byte
// Thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer.
- for (int j = 0; j < 16; j++) {
+ for (uint8_t j = 0; j < 64; j++) {
g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
}
#if CKLED2001_PERSISTENCE > 0
for (uint8_t i = 0; i < CKLED2001_PERSISTENCE; i++) {
- if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, CKLED2001_TIMEOUT) != 0) {
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 65, CKLED2001_TIMEOUT) != 0) {
return false;
}
}
#else
- if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, CKLED2001_TIMEOUT) != 0) {
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 65, CKLED2001_TIMEOUT) != 0) {
return false;
}
#endif
@@ -123,18 +127,10 @@ void CKLED2001_init(uint8_t addr) {
}
// Set CURRENT PAGE (Page 4)
+ uint8_t current_tuen_reg_list[LED_CURRENT_TUNE_LENGTH] = CKLED2001_CURRENT_TUNE;
CKLED2001_write_register(addr, CONFIGURE_CMD_PAGE, CURRENT_TUNE_PAGE);
for (int i = 0; i < LED_CURRENT_TUNE_LENGTH; i++) {
- switch (i) {
- case 2:
- case 5:
- case 8:
- case 11:
- CKLED2001_write_register(addr, i, 0xA0);
- break;
- default:
- CKLED2001_write_register(addr, i, 0xFF);
- }
+ CKLED2001_write_register(addr, i, current_tuen_reg_list[i]);
}
// Enable LEDs ON/OFF
@@ -220,14 +216,14 @@ void CKLED2001_update_led_control_registers(uint8_t addr, uint8_t index) {
g_led_control_registers_update_required[index] = false;
}
-void CKLED2001_return_normal(uint8_t addr) {
+void CKLED2001_sw_return_normal(uint8_t addr) {
// Select to function page
CKLED2001_write_register(addr, CONFIGURE_CMD_PAGE, FUNCTION_PAGE);
// Setting LED driver to normal mode
CKLED2001_write_register(addr, CONFIGURATION_REG, MSKSW_NORMAL_MODE);
}
-void CKLED2001_shutdown(uint8_t addr) {
+void CKLED2001_sw_shutdown(uint8_t addr) {
// Select to function page
CKLED2001_write_register(addr, CONFIGURE_CMD_PAGE, FUNCTION_PAGE);
// Setting LED driver to shutdown mode
diff --git a/drivers/led/ckled2001.h b/drivers/led/ckled2001.h
index 1967961d20..7d5ad34f95 100644
--- a/drivers/led/ckled2001.h
+++ b/drivers/led/ckled2001.h
@@ -45,8 +45,8 @@ void CKLED2001_set_led_control_register(uint8_t index, bool red, bool green, boo
void CKLED2001_update_pwm_buffers(uint8_t addr, uint8_t index);
void CKLED2001_update_led_control_registers(uint8_t addr, uint8_t index);
-void CKLED2001_return_normal(uint8_t addr);
-void CKLED2001_shutdown(uint8_t addr);
+void CKLED2001_sw_return_normal(uint8_t addr);
+void CKLED2001_sw_shutdown(uint8_t addr);
// Registers Page Define
#define CONFIGURE_CMD_PAGE 0xFD
diff --git a/drivers/led/issi/is31fl3733-simple.c b/drivers/led/issi/is31fl3733-simple.c
index af006f756d..2f41a7b1a9 100644
--- a/drivers/led/issi/is31fl3733-simple.c
+++ b/drivers/led/issi/is31fl3733-simple.c
@@ -70,6 +70,10 @@
# define ISSI_CSPULLUP PUR_0R
#endif
+#ifndef ISSI_GLOBALCURRENT
+# define ISSI_GLOBALCURRENT 0xFF
+#endif
+
// Transfer buffer for TWITransmitData()
uint8_t g_twi_transfer_buffer[20];
@@ -182,7 +186,7 @@ void IS31FL3733_init(uint8_t addr, uint8_t sync) {
// Set de-ghost pull-down resistors (CSx)
IS31FL3733_write_register(addr, ISSI_REG_CSPULLUP, ISSI_CSPULLUP);
// Set global current to maximum.
- IS31FL3733_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF);
+ IS31FL3733_write_register(addr, ISSI_REG_GLOBALCURRENT, ISSI_GLOBALCURRENT);
// Disable software shutdown.
IS31FL3733_write_register(addr, ISSI_REG_CONFIGURATION, ((sync & 0b11) << 6) | ((ISSI_PWM_FREQUENCY & 0b111) << 3) | 0x01);
diff --git a/drivers/led/issi/is31fl3733.c b/drivers/led/issi/is31fl3733.c
index a2fdaa90fa..add998f256 100644
--- a/drivers/led/issi/is31fl3733.c
+++ b/drivers/led/issi/is31fl3733.c
@@ -69,6 +69,10 @@
# define ISSI_CSPULLUP PUR_0R
#endif
+#ifndef ISSI_GLOBALCURRENT
+# define ISSI_GLOBALCURRENT 0xFF
+#endif
+
// Transfer buffer for TWITransmitData()
uint8_t g_twi_transfer_buffer[20];
@@ -172,7 +176,7 @@ void IS31FL3733_init(uint8_t addr, uint8_t sync) {
// Set de-ghost pull-down resistors (CSx)
IS31FL3733_write_register(addr, ISSI_REG_CSPULLUP, ISSI_CSPULLUP);
// Set global current to maximum.
- IS31FL3733_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF);
+ IS31FL3733_write_register(addr, ISSI_REG_GLOBALCURRENT, ISSI_GLOBALCURRENT);
// Disable software shutdown.
IS31FL3733_write_register(addr, ISSI_REG_CONFIGURATION, ((sync & 0b11) << 6) | ((ISSI_PWM_FREQUENCY & 0b111) << 3) | 0x01);
diff --git a/drivers/led/issi/is31fl3736.c b/drivers/led/issi/is31fl3736.c
index 7752a3f6cb..e9943614d2 100644
--- a/drivers/led/issi/is31fl3736.c
+++ b/drivers/led/issi/is31fl3736.c
@@ -63,6 +63,10 @@
# define ISSI_CSPULLUP PUR_0R
#endif
+#ifndef ISSI_GLOBALCURRENT
+# define ISSI_GLOBALCURRENT 0xFF
+#endif
+
// Transfer buffer for TWITransmitData()
uint8_t g_twi_transfer_buffer[20];
@@ -154,7 +158,7 @@ void IS31FL3736_init(uint8_t addr) {
// Set de-ghost pull-down resistors (CSx)
IS31FL3736_write_register(addr, ISSI_REG_CSPULLUP, ISSI_CSPULLUP);
// Set global current to maximum.
- IS31FL3736_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF);
+ IS31FL3736_write_register(addr, ISSI_REG_GLOBALCURRENT, ISSI_GLOBALCURRENT);
// Disable software shutdown.
IS31FL3736_write_register(addr, ISSI_REG_CONFIGURATION, 0x01);
diff --git a/drivers/led/issi/is31fl3737.c b/drivers/led/issi/is31fl3737.c
index bce0c34b2c..932530ac0a 100644
--- a/drivers/led/issi/is31fl3737.c
+++ b/drivers/led/issi/is31fl3737.c
@@ -69,6 +69,10 @@
# define ISSI_CSPULLUP PUR_0R
#endif
+#ifndef ISSI_GLOBALCURRENT
+# define ISSI_GLOBALCURRENT 0xFF
+#endif
+
// Transfer buffer for TWITransmitData()
uint8_t g_twi_transfer_buffer[20];
@@ -161,7 +165,7 @@ void IS31FL3737_init(uint8_t addr) {
// Set de-ghost pull-down resistors (CSx)
IS31FL3737_write_register(addr, ISSI_REG_CSPULLUP, ISSI_CSPULLUP);
// Set global current to maximum.
- IS31FL3737_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF);
+ IS31FL3737_write_register(addr, ISSI_REG_GLOBALCURRENT, ISSI_GLOBALCURRENT);
// Disable software shutdown.
IS31FL3737_write_register(addr, ISSI_REG_CONFIGURATION, ((ISSI_PWM_FREQUENCY & 0b111) << 3) | 0x01);
diff --git a/drivers/led/issi/is31fl3741.c b/drivers/led/issi/is31fl3741.c
index 393b0179b5..ba6b6761a3 100644
--- a/drivers/led/issi/is31fl3741.c
+++ b/drivers/led/issi/is31fl3741.c
@@ -69,6 +69,10 @@
# define ISSI_CSPULLUP PUR_32KR
#endif
+#ifndef ISSI_GLOBALCURRENT
+# define ISSI_GLOBALCURRENT 0xFF
+#endif
+
#define ISSI_MAX_LEDS 351
// Transfer buffer for TWITransmitData()
@@ -163,7 +167,7 @@ void IS31FL3741_init(uint8_t addr) {
IS31FL3741_write_register(addr, ISSI_REG_CONFIGURATION, 0x01);
// Set Golbal Current Control Register
- IS31FL3741_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF);
+ IS31FL3741_write_register(addr, ISSI_REG_GLOBALCURRENT, ISSI_GLOBALCURRENT);
// Set Pull up & Down for SWx CSy
IS31FL3741_write_register(addr, ISSI_REG_PULLDOWNUP, ((ISSI_CSPULLUP << 4) | ISSI_SWPULLUP));
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h
index 918b837f07..e9b8c5b4e8 100644
--- a/drivers/oled/oled_driver.h
+++ b/drivers/oled/oled_driver.h
@@ -260,7 +260,7 @@ void oled_write_ln_P(const char *data, bool invert);
void oled_write_raw_P(const char *data, uint16_t size);
#else
# define oled_write_P(data, invert) oled_write(data, invert)
-# define oled_write_ln_P(data, invert) oled_write(data, invert)
+# define oled_write_ln_P(data, invert) oled_write_ln(data, invert)
# define oled_write_raw_P(data, size) oled_write_raw(data, size)
#endif // defined(__AVR__)
diff --git a/drivers/painter/gc9a01/qp_gc9a01.c b/drivers/painter/gc9a01/qp_gc9a01.c
index ad76d58b07..37700a28a4 100644
--- a/drivers/painter/gc9a01/qp_gc9a01.c
+++ b/drivers/painter/gc9a01/qp_gc9a01.c
@@ -102,12 +102,11 @@ const struct tft_panel_dc_reset_painter_driver_vtable_t gc9a01_driver_vtable = {
.flush = qp_tft_panel_flush,
.pixdata = qp_tft_panel_pixdata,
.viewport = qp_tft_panel_viewport,
- .palette_convert = qp_tft_panel_palette_convert,
- .append_pixels = qp_tft_panel_append_pixels,
+ .palette_convert = qp_tft_panel_palette_convert_rgb565_swapped,
+ .append_pixels = qp_tft_panel_append_pixels_rgb565,
},
- .rgb888_to_native16bit = qp_rgb888_to_rgb565_swapped,
- .num_window_bytes = 2,
- .swap_window_coords = false,
+ .num_window_bytes = 2,
+ .swap_window_coords = false,
.opcodes =
{
.display_on = GC9A01_CMD_DISPLAY_ON,
diff --git a/drivers/painter/ili9xxx/qp_ili9163.c b/drivers/painter/ili9xxx/qp_ili9163.c
index beaac0fbb5..14363c7d04 100644
--- a/drivers/painter/ili9xxx/qp_ili9163.c
+++ b/drivers/painter/ili9xxx/qp_ili9163.c
@@ -67,12 +67,11 @@ const struct tft_panel_dc_reset_painter_driver_vtable_t ili9163_driver_vtable =
.flush = qp_tft_panel_flush,
.pixdata = qp_tft_panel_pixdata,
.viewport = qp_tft_panel_viewport,
- .palette_convert = qp_tft_panel_palette_convert,
- .append_pixels = qp_tft_panel_append_pixels,
+ .palette_convert = qp_tft_panel_palette_convert_rgb565_swapped,
+ .append_pixels = qp_tft_panel_append_pixels_rgb565,
},
- .rgb888_to_native16bit = qp_rgb888_to_rgb565_swapped,
- .num_window_bytes = 2,
- .swap_window_coords = false,
+ .num_window_bytes = 2,
+ .swap_window_coords = false,
.opcodes =
{
.display_on = ILI9XXX_CMD_DISPLAY_ON,
diff --git a/drivers/painter/ili9xxx/qp_ili9341.c b/drivers/painter/ili9xxx/qp_ili9341.c
index 1f41dcfc0b..9608f109bd 100644
--- a/drivers/painter/ili9xxx/qp_ili9341.c
+++ b/drivers/painter/ili9xxx/qp_ili9341.c
@@ -74,12 +74,11 @@ const struct tft_panel_dc_reset_painter_driver_vtable_t ili9341_driver_vtable =
.flush = qp_tft_panel_flush,
.pixdata = qp_tft_panel_pixdata,
.viewport = qp_tft_panel_viewport,
- .palette_convert = qp_tft_panel_palette_convert,
- .append_pixels = qp_tft_panel_append_pixels,
+ .palette_convert = qp_tft_panel_palette_convert_rgb565_swapped,
+ .append_pixels = qp_tft_panel_append_pixels_rgb565,
},
- .rgb888_to_native16bit = qp_rgb888_to_rgb565_swapped,
- .num_window_bytes = 2,
- .swap_window_coords = false,
+ .num_window_bytes = 2,
+ .swap_window_coords = false,
.opcodes =
{
.display_on = ILI9XXX_CMD_DISPLAY_ON,
diff --git a/drivers/painter/ili9xxx/qp_ili9488.c b/drivers/painter/ili9xxx/qp_ili9488.c
new file mode 100644
index 0000000000..55cf9f896f
--- /dev/null
+++ b/drivers/painter/ili9xxx/qp_ili9488.c
@@ -0,0 +1,120 @@
+// Copyright 2021 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "qp_internal.h"
+#include "qp_comms.h"
+#include "qp_ili9488.h"
+#include "qp_ili9xxx_opcodes.h"
+#include "qp_tft_panel.h"
+
+#ifdef QUANTUM_PAINTER_ILI9488_SPI_ENABLE
+# include <qp_comms_spi.h>
+#endif // QUANTUM_PAINTER_ILI9488_SPI_ENABLE
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Common
+
+// Driver storage
+tft_panel_dc_reset_painter_device_t ili9488_drivers[ILI9488_NUM_DEVICES] = {0};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Initialization
+
+bool qp_ili9488_init(painter_device_t device, painter_rotation_t rotation) {
+ // clang-format off
+ const uint8_t ili9488_init_sequence[] = {
+ // Command, Delay, N, Data[N]
+ ILI9XXX_CMD_RESET, 120, 0,
+ ILI9XXX_SET_PGAMMA, 0, 15, 0x00, 0x03, 0x09, 0x08, 0x16, 0x0A, 0x3F, 0x78, 0x4C, 0x09, 0x0A, 0x08, 0x16, 0x1A, 0x0F,
+ ILI9XXX_SET_NGAMMA, 0, 15, 0x00, 0x16, 0x19, 0x03, 0x0F, 0x05, 0x32, 0x45, 0x46, 0x04, 0x0E, 0x0D, 0x35, 0x37, 0x0F,
+ ILI9XXX_SET_POWER_CTL_1, 0, 2, 0x17, 0x15,
+ ILI9XXX_SET_POWER_CTL_2, 0, 1, 0x41,
+ ILI9XXX_SET_VCOM_CTL_1, 0, 3, 0x00, 0x12, 0x80,
+ ILI9XXX_SET_PIX_FMT, 0, 1, 0x66,
+ ILI9XXX_SET_RGB_IF_SIG_CTL, 0, 1, 0x80,
+ ILI9XXX_SET_FRAME_CTL_NORMAL, 0, 1, 0xA0,
+ ILI9XXX_SET_INVERSION_CTL, 0, 1, 0x02,
+ ILI9XXX_SET_FUNCTION_CTL, 0, 2, 0x02, 0x02,
+ ILI9XXX_SET_IMAGE_FUNCTION, 0, 1, 0x00,
+ ILI9XXX_SET_PUMP_RATIO_CTL, 0, 4, 0xA9, 0x51, 0x2C, 0x82,
+ ILI9XXX_CMD_SLEEP_OFF, 5, 0,
+ ILI9XXX_CMD_DISPLAY_ON, 20, 0
+ };
+ // clang-format on
+ qp_comms_bulk_command_sequence(device, ili9488_init_sequence, sizeof(ili9488_init_sequence));
+
+ // Configure the rotation (i.e. the ordering and direction of memory writes in GRAM)
+ const uint8_t madctl[] = {
+ [QP_ROTATION_0] = ILI9XXX_MADCTL_BGR | ILI9XXX_MADCTL_MY,
+ [QP_ROTATION_90] = ILI9XXX_MADCTL_BGR | ILI9XXX_MADCTL_MX | ILI9XXX_MADCTL_MV | ILI9XXX_MADCTL_MY,
+ [QP_ROTATION_180] = ILI9XXX_MADCTL_BGR | ILI9XXX_MADCTL_MX,
+ [QP_ROTATION_270] = ILI9XXX_MADCTL_BGR | ILI9XXX_MADCTL_MV,
+ };
+ qp_comms_command_databyte(device, ILI9XXX_SET_MEM_ACS_CTL, madctl[rotation]);
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Driver vtable
+
+const struct tft_panel_dc_reset_painter_driver_vtable_t ili9488_driver_vtable = {
+ .base =
+ {
+ .init = qp_ili9488_init,
+ .power = qp_tft_panel_power,
+ .clear = qp_tft_panel_clear,
+ .flush = qp_tft_panel_flush,
+ .pixdata = qp_tft_panel_pixdata,
+ .viewport = qp_tft_panel_viewport,
+ .palette_convert = qp_tft_panel_palette_convert_rgb888,
+ .append_pixels = qp_tft_panel_append_pixels_rgb888,
+ },
+ .num_window_bytes = 2,
+ .swap_window_coords = false,
+ .opcodes =
+ {
+ .display_on = ILI9XXX_CMD_DISPLAY_ON,
+ .display_off = ILI9XXX_CMD_DISPLAY_OFF,
+ .set_column_address = ILI9XXX_SET_COL_ADDR,
+ .set_row_address = ILI9XXX_SET_PAGE_ADDR,
+ .enable_writes = ILI9XXX_SET_MEM,
+ },
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// SPI
+
+#ifdef QUANTUM_PAINTER_ILI9488_SPI_ENABLE
+
+// Factory function for creating a handle to the ILI9488 device
+painter_device_t qp_ili9488_make_spi_device(uint16_t panel_width, uint16_t panel_height, pin_t chip_select_pin, pin_t dc_pin, pin_t reset_pin, uint16_t spi_divisor, int spi_mode) {
+ for (uint32_t i = 0; i < ILI9488_NUM_DEVICES; ++i) {
+ tft_panel_dc_reset_painter_device_t *driver = &ili9488_drivers[i];
+ if (!driver->base.driver_vtable) {
+ driver->base.driver_vtable = (const struct painter_driver_vtable_t *)&ili9488_driver_vtable;
+ driver->base.comms_vtable = (const struct painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
+ driver->base.native_bits_per_pixel = 24; // RGB888
+ driver->base.panel_width = panel_width;
+ driver->base.panel_height = panel_height;
+ driver->base.rotation = QP_ROTATION_0;
+ driver->base.offset_x = 0;
+ driver->base.offset_y = 0;
+
+ // SPI and other pin configuration
+ driver->base.comms_config = &driver->spi_dc_reset_config;
+ driver->spi_dc_reset_config.spi_config.chip_select_pin = chip_select_pin;
+ driver->spi_dc_reset_config.spi_config.divisor = spi_divisor;
+ driver->spi_dc_reset_config.spi_config.lsb_first = false;
+ driver->spi_dc_reset_config.spi_config.mode = spi_mode;
+ driver->spi_dc_reset_config.dc_pin = dc_pin;
+ driver->spi_dc_reset_config.reset_pin = reset_pin;
+ return (painter_device_t)driver;
+ }
+ }
+ return NULL;
+}
+
+#endif // QUANTUM_PAINTER_ILI9488_SPI_ENABLE
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/drivers/painter/ili9xxx/qp_ili9488.h b/drivers/painter/ili9xxx/qp_ili9488.h
new file mode 100644
index 0000000000..21b8f03322
--- /dev/null
+++ b/drivers/painter/ili9xxx/qp_ili9488.h
@@ -0,0 +1,37 @@
+// Copyright 2021 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "gpio.h"
+#include "qp_internal.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter ILI9488 configurables (add to your keyboard's config.h)
+
+#ifndef ILI9488_NUM_DEVICES
+/**
+ * @def This controls the maximum number of ILI9488 devices that Quantum Painter can communicate with at any one time.
+ * Increasing this number allows for multiple displays to be used.
+ */
+# define ILI9488_NUM_DEVICES 1
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter ILI9488 device factories
+
+#ifdef QUANTUM_PAINTER_ILI9488_SPI_ENABLE
+/**
+ * Factory method for an ILI9488 SPI LCD device.
+ *
+ * @param panel_width[in] the width of the display panel
+ * @param panel_height[in] the height of the display panel
+ * @param chip_select_pin[in] the GPIO pin used for SPI chip select
+ * @param dc_pin[in] the GPIO pin used for D/C control
+ * @param reset_pin[in] the GPIO pin used for RST
+ * @param spi_divisor[in] the SPI divisor to use when communicating with the display
+ * @param spi_mode[in] the SPI mode to use when communicating with the display
+ * @return the device handle used with all drawing routines in Quantum Painter
+ */
+painter_device_t qp_ili9488_make_spi_device(uint16_t panel_width, uint16_t panel_height, pin_t chip_select_pin, pin_t dc_pin, pin_t reset_pin, uint16_t spi_divisor, int spi_mode);
+#endif // QUANTUM_PAINTER_ILI9488_SPI_ENABLE
diff --git a/drivers/painter/ili9xxx/qp_ili9xxx_opcodes.h b/drivers/painter/ili9xxx/qp_ili9xxx_opcodes.h
index 1fa395cb89..47bb703648 100644
--- a/drivers/painter/ili9xxx/qp_ili9xxx_opcodes.h
+++ b/drivers/painter/ili9xxx/qp_ili9xxx_opcodes.h
@@ -85,6 +85,7 @@
#define ILI9XXX_SET_NGAMMA 0xE1 // Set negative gamma
#define ILI9XXX_SET_DGAMMA_CTL_1 0xE2 // Set digital gamma ctl 1
#define ILI9XXX_SET_DGAMMA_CTL_2 0xE3 // Set digital gamma ctl 2
+#define ILI9XXX_SET_IMAGE_FUNCTION 0xE9 // Set image function
#define ILI9XXX_ENABLE_3_GAMMA 0xF2 // Enable 3 gamma
#define ILI9XXX_SET_IF_CTL 0xF6 // Set interface control
#define ILI9XXX_SET_PUMP_RATIO_CTL 0xF7 // Set pump ratio control
diff --git a/drivers/painter/ssd1351/qp_ssd1351.c b/drivers/painter/ssd1351/qp_ssd1351.c
index 970e7e67f3..7ce76bab6d 100644
--- a/drivers/painter/ssd1351/qp_ssd1351.c
+++ b/drivers/painter/ssd1351/qp_ssd1351.c
@@ -71,12 +71,11 @@ const struct tft_panel_dc_reset_painter_driver_vtable_t ssd1351_driver_vtable =
.flush = qp_tft_panel_flush,
.pixdata = qp_tft_panel_pixdata,
.viewport = qp_tft_panel_viewport,
- .palette_convert = qp_tft_panel_palette_convert,
- .append_pixels = qp_tft_panel_append_pixels,
+ .palette_convert = qp_tft_panel_palette_convert_rgb565_swapped,
+ .append_pixels = qp_tft_panel_append_pixels_rgb565,
},
- .rgb888_to_native16bit = qp_rgb888_to_rgb565_swapped,
- .num_window_bytes = 1,
- .swap_window_coords = true,
+ .num_window_bytes = 1,
+ .swap_window_coords = true,
.opcodes =
{
.display_on = SSD1351_DISPLAYON,
diff --git a/drivers/painter/st77xx/qp_st7735.c b/drivers/painter/st77xx/qp_st7735.c
new file mode 100644
index 0000000000..e434e31b92
--- /dev/null
+++ b/drivers/painter/st77xx/qp_st7735.c
@@ -0,0 +1,144 @@
+// Copyright 2021 Paul Cotter (@gr1mr3aver)
+// Copyright 2021 Nick Brassel (@tzarc)
+// Copyright 2022 David Hoelscher (@customMK)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "qp_internal.h"
+#include "qp_comms.h"
+#include "qp_st7735.h"
+#include "qp_st77xx_opcodes.h"
+#include "qp_st7735_opcodes.h"
+#include "qp_tft_panel.h"
+
+#ifdef QUANTUM_PAINTER_ST7735_SPI_ENABLE
+# include "qp_comms_spi.h"
+#endif // QUANTUM_PAINTER_ST7735_SPI_ENABLE
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Common
+
+// Driver storage
+tft_panel_dc_reset_painter_device_t st7735_drivers[ST7735_NUM_DEVICES] = {0};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Automatic viewport offsets
+
+#ifndef ST7735_NO_AUTOMATIC_OFFSETS
+static inline void st7735_automatic_viewport_offsets(painter_device_t device, painter_rotation_t rotation) {
+ struct painter_driver_t *driver = (struct painter_driver_t *)device;
+
+ // clang-format off
+ const struct {
+ uint16_t offset_x;
+ uint16_t offset_y;
+ } rotation_offsets_80x160[] = {
+ [QP_ROTATION_0] = { .offset_x = 24, .offset_y = 0 },
+ [QP_ROTATION_90] = { .offset_x = 0, .offset_y = 24 },
+ [QP_ROTATION_180] = { .offset_x = 24, .offset_y = 0 },
+ [QP_ROTATION_270] = { .offset_x = 0, .offset_y = 24 },
+ };
+ // clang-format on
+
+ if (driver->panel_width == 80 && driver->panel_height == 160) {
+ driver->offset_x = rotation_offsets_80x160[rotation].offset_x;
+ driver->offset_y = rotation_offsets_80x160[rotation].offset_y;
+ }
+}
+#endif // ST7735_NO_AUTOMATIC_OFFSETS
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Initialization
+
+bool qp_st7735_init(painter_device_t device, painter_rotation_t rotation) {
+ // clang-format off
+ const uint8_t st7735_init_sequence[] = {
+ // Command, Delay, N, Data[N]
+ ST77XX_CMD_RESET, 120, 0,
+ ST77XX_CMD_SLEEP_OFF, 5, 0,
+ ST77XX_SET_PIX_FMT, 0, 1, 0x55,
+ ST77XX_CMD_INVERT_OFF, 0, 0,
+ ST77XX_CMD_NORMAL_ON, 0, 0,
+ ST77XX_CMD_DISPLAY_ON, 20, 0
+ };
+ // clang-format on
+ qp_comms_bulk_command_sequence(device, st7735_init_sequence, sizeof(st7735_init_sequence));
+
+ // Configure the rotation (i.e. the ordering and direction of memory writes in GRAM)
+ const uint8_t madctl[] = {
+ [QP_ROTATION_0] = ST77XX_MADCTL_BGR,
+ [QP_ROTATION_90] = ST77XX_MADCTL_BGR | ST77XX_MADCTL_MX | ST77XX_MADCTL_MV,
+ [QP_ROTATION_180] = ST77XX_MADCTL_BGR | ST77XX_MADCTL_MX | ST77XX_MADCTL_MY,
+ [QP_ROTATION_270] = ST77XX_MADCTL_BGR | ST77XX_MADCTL_MV | ST77XX_MADCTL_MY,
+ };
+ qp_comms_command_databyte(device, ST77XX_SET_MADCTL, madctl[rotation]);
+
+#ifndef ST7735_NO_AUTOMATIC_VIEWPORT_OFFSETS
+ st7735_automatic_viewport_offsets(device, rotation);
+#endif // ST7735_NO_AUTOMATIC_VIEWPORT_OFFSETS
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Driver vtable
+
+const struct tft_panel_dc_reset_painter_driver_vtable_t st7735_driver_vtable = {
+ .base =
+ {
+ .init = qp_st7735_init,
+ .power = qp_tft_panel_power,
+ .clear = qp_tft_panel_clear,
+ .flush = qp_tft_panel_flush,
+ .pixdata = qp_tft_panel_pixdata,
+ .viewport = qp_tft_panel_viewport,
+ .palette_convert = qp_tft_panel_palette_convert_rgb565_swapped,
+ .append_pixels = qp_tft_panel_append_pixels_rgb565,
+ },
+ .num_window_bytes = 2,
+ .swap_window_coords = false,
+ .opcodes =
+ {
+ .display_on = ST77XX_CMD_DISPLAY_ON,
+ .display_off = ST77XX_CMD_DISPLAY_OFF,
+ .set_column_address = ST77XX_SET_COL_ADDR,
+ .set_row_address = ST77XX_SET_ROW_ADDR,
+ .enable_writes = ST77XX_SET_MEM,
+ },
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// SPI
+
+#ifdef QUANTUM_PAINTER_ST7735_SPI_ENABLE
+
+// Factory function for creating a handle to the ST7735 device
+painter_device_t qp_st7735_make_spi_device(uint16_t panel_width, uint16_t panel_height, pin_t chip_select_pin, pin_t dc_pin, pin_t reset_pin, uint16_t spi_divisor, int spi_mode) {
+ for (uint32_t i = 0; i < ST7735_NUM_DEVICES; ++i) {
+ tft_panel_dc_reset_painter_device_t *driver = &st7735_drivers[i];
+ if (!driver->base.driver_vtable) {
+ driver->base.driver_vtable = (const struct painter_driver_vtable_t *)&st7735_driver_vtable;
+ driver->base.comms_vtable = (const struct painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
+ driver->base.panel_width = panel_width;
+ driver->base.panel_height = panel_height;
+ driver->base.rotation = QP_ROTATION_0;
+ driver->base.offset_x = 0;
+ driver->base.offset_y = 0;
+ driver->base.native_bits_per_pixel = 16; // RGB565
+
+ // SPI and other pin configuration
+ driver->base.comms_config = &driver->spi_dc_reset_config;
+ driver->spi_dc_reset_config.spi_config.chip_select_pin = chip_select_pin;
+ driver->spi_dc_reset_config.spi_config.divisor = spi_divisor;
+ driver->spi_dc_reset_config.spi_config.lsb_first = false;
+ driver->spi_dc_reset_config.spi_config.mode = spi_mode;
+ driver->spi_dc_reset_config.dc_pin = dc_pin;
+ driver->spi_dc_reset_config.reset_pin = reset_pin;
+ return (painter_device_t)driver;
+ }
+ }
+ return NULL;
+}
+
+#endif // QUANTUM_PAINTER_ST7735_SPI_ENABLE
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// \ No newline at end of file
diff --git a/drivers/painter/st77xx/qp_st7735.h b/drivers/painter/st77xx/qp_st7735.h
new file mode 100644
index 0000000000..a9ce16bef1
--- /dev/null
+++ b/drivers/painter/st77xx/qp_st7735.h
@@ -0,0 +1,45 @@
+// Copyright 2021 Paul Cotter (@gr1mr3aver)
+// Copyright 2021 Nick Brassel (@tzarc)
+// Copyright 2022 David Hoelscher (@customMK)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "gpio.h"
+#include "qp_internal.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter ST7735 configurables (add to your keyboard's config.h)
+
+#ifndef ST7735_NUM_DEVICES
+/**
+ * @def This controls the maximum number of ST7735 devices that Quantum Painter can communicate with at any one time.
+ * Increasing this number allows for multiple displays to be used.
+ */
+# define ST7735_NUM_DEVICES 1
+#endif
+
+// Additional configuration options to be copied to your keyboard's config.h (don't change here):
+
+// If you know exactly which offsets should be used on your panel with respect to selected rotation, then this config
+// option allows you to save some flash space -- you'll need to invoke qp_set_viewport_offsets() instead from your keyboard.
+// #define ST7735_NO_AUTOMATIC_VIEWPORT_OFFSETS
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter ST7735 device factories
+
+#ifdef QUANTUM_PAINTER_ST7735_SPI_ENABLE
+/**
+ * Factory method for an ST7735 SPI LCD device.
+ *
+ * @param panel_width[in] the width of the display panel
+ * @param panel_height[in] the height of the display panel
+ * @param chip_select_pin[in] the GPIO pin used for SPI chip select
+ * @param dc_pin[in] the GPIO pin used for D/C control
+ * @param reset_pin[in] the GPIO pin used for RST
+ * @param spi_divisor[in] the SPI divisor to use when communicating with the display
+ * @param spi_mode[in] the SPI mode to use when communicating with the display
+ * @return the device handle used with all drawing routines in Quantum Painter
+ */
+painter_device_t qp_st7735_make_spi_device(uint16_t panel_width, uint16_t panel_height, pin_t chip_select_pin, pin_t dc_pin, pin_t reset_pin, uint16_t spi_divisor, int spi_mode);
+#endif // QUANTUM_PAINTER_ST7735_SPI_ENABLE \ No newline at end of file
diff --git a/drivers/painter/st77xx/qp_st7735_opcodes.h b/drivers/painter/st77xx/qp_st7735_opcodes.h
new file mode 100644
index 0000000000..816e32f3d7
--- /dev/null
+++ b/drivers/painter/st77xx/qp_st7735_opcodes.h
@@ -0,0 +1,31 @@
+// Copyright 2022 David Hoelscher (@customMK)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter ST7735 additional command opcodes
+
+// Panel Function Commands
+#define ST7735_SET_FRAME_RATE_CTL_1 0xB1 // Set frame rate control 1
+#define ST7735_SET_FRAME_RATE_CTL_2 0xB2 // Set frame rate control 2
+#define ST7735_SET_FRAME_RATE_CTL_3 0xB3 // Set frame rate control 3
+#define ST7735_SET_INVERSION_CTL 0xB4 // Set inversion mode control
+#define ST7735_SET_DISPLAY_CTL 0xB6 // Set display control 5
+#define ST7735_SET_POWER_CTL_1 0xC0 // Set GVDD
+#define ST7735_SET_POWER_CTL_2 0xC1 // Set VGH and VGL
+#define ST7735_SET_POWER_CTL_3 0xC2 // Set normal mode op amp current
+#define ST7735_SET_POWER_CTL_4 0xC3 // Set idle mode op amp current
+#define ST7735_SET_POWER_CTL_5 0xC4 // Set partial mode op amp current
+#define ST7735_SET_VCOM_CTL 0xC5 // Set VCOM voltages
+#define ST7735_SET_VCOM_OFFSET_CTL 0xC7 // Set VCOM offset ctl
+#define ST7735_SET_LCD_ID 0xD1 // Set LCD module version
+#define ST7735_SET_PROJECT_ID 0xD2 // Set product project ID
+#define ST7735_SET_POWER_CTL_6 0xFC // Set partial+idle op amp current
+#define ST7735_SET_NVMEM_CTL_STATUS 0xD9 // EEPROM Control Status
+#define ST7735_SET_NVMEM_READ_CMD 0xCC // EEPROM Read Command
+#define ST7735_SET_NVMEM_WRITE_CMD 0xDF // EEPROM Write Command
+#define ST7735_SET_PGAMMA 0xE0 // Set positive gamma
+#define ST7735_SET_NGAMMA 0xE1 // Set negative gamma
+#define ST7735_SET_EXTENSION_ENABLE 0xF0 // Enable extension command
+#define ST7735_SET_VCOM_DELAY 0xFF // Set VCOM delay time
diff --git a/drivers/painter/st77xx/qp_st7789.c b/drivers/painter/st77xx/qp_st7789.c
index d005ece050..49e8436c29 100644
--- a/drivers/painter/st77xx/qp_st7789.c
+++ b/drivers/painter/st77xx/qp_st7789.c
@@ -90,12 +90,11 @@ const struct tft_panel_dc_reset_painter_driver_vtable_t st7789_driver_vtable = {
.flush = qp_tft_panel_flush,
.pixdata = qp_tft_panel_pixdata,
.viewport = qp_tft_panel_viewport,
- .palette_convert = qp_tft_panel_palette_convert,
- .append_pixels = qp_tft_panel_append_pixels,
+ .palette_convert = qp_tft_panel_palette_convert_rgb565_swapped,
+ .append_pixels = qp_tft_panel_append_pixels_rgb565,
},
- .rgb888_to_native16bit = qp_rgb888_to_rgb565_swapped,
- .num_window_bytes = 2,
- .swap_window_coords = false,
+ .num_window_bytes = 2,
+ .swap_window_coords = false,
.opcodes =
{
.display_on = ST77XX_CMD_DISPLAY_ON,
diff --git a/drivers/painter/tft_panel/qp_tft_panel.c b/drivers/painter/tft_panel/qp_tft_panel.c
index 4d636c9509..ad83b6c792 100644
--- a/drivers/painter/tft_panel/qp_tft_panel.c
+++ b/drivers/painter/tft_panel/qp_tft_panel.c
@@ -10,29 +10,6 @@
#define BYTE_SWAP(x) (((((uint16_t)(x)) >> 8) & 0x00FF) | ((((uint16_t)(x)) << 8) & 0xFF00))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Native pixel format conversion
-
-uint16_t qp_rgb888_to_rgb565(uint8_t r, uint8_t g, uint8_t b) {
- uint16_t rgb565 = (((uint16_t)r) >> 3) << 11 | (((uint16_t)g) >> 2) << 5 | (((uint16_t)b) >> 3);
- return rgb565;
-}
-
-uint16_t qp_rgb888_to_rgb565_swapped(uint8_t r, uint8_t g, uint8_t b) {
- uint16_t rgb565 = (((uint16_t)r) >> 3) << 11 | (((uint16_t)g) >> 2) << 5 | (((uint16_t)b) >> 3);
- return BYTE_SWAP(rgb565);
-}
-
-uint16_t qp_rgb888_to_bgr565(uint8_t r, uint8_t g, uint8_t b) {
- uint16_t bgr565 = (((uint16_t)b) >> 3) << 11 | (((uint16_t)g) >> 2) << 5 | (((uint16_t)r) >> 3);
- return bgr565;
-}
-
-uint16_t qp_rgb888_to_bgr565_swapped(uint8_t r, uint8_t g, uint8_t b) {
- uint16_t bgr565 = (((uint16_t)b) >> 3) << 11 | (((uint16_t)g) >> 2) << 5 | (((uint16_t)r) >> 3);
- return BYTE_SWAP(bgr565);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Quantum Painter API implementations
// Power control
@@ -105,26 +82,49 @@ bool qp_tft_panel_viewport(painter_device_t device, uint16_t left, uint16_t top,
// Stream pixel data to the current write position in GRAM
bool qp_tft_panel_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count) {
- qp_comms_send(device, pixel_data, native_pixel_count * sizeof(uint16_t));
+ struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ qp_comms_send(device, pixel_data, native_pixel_count * driver->native_bits_per_pixel / 8);
return true;
}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Convert supplied palette entries into their native equivalents
-bool qp_tft_panel_palette_convert(painter_device_t device, int16_t palette_size, qp_pixel_t *palette) {
- struct painter_driver_t * driver = (struct painter_driver_t *)device;
- struct tft_panel_dc_reset_painter_driver_vtable_t *vtable = (struct tft_panel_dc_reset_painter_driver_vtable_t *)driver->driver_vtable;
+
+bool qp_tft_panel_palette_convert_rgb565_swapped(painter_device_t device, int16_t palette_size, qp_pixel_t *palette) {
for (int16_t i = 0; i < palette_size; ++i) {
- RGB rgb = hsv_to_rgb_nocie((HSV){palette[i].hsv888.h, palette[i].hsv888.s, palette[i].hsv888.v});
- palette[i].rgb565 = vtable->rgb888_to_native16bit(rgb.r, rgb.g, rgb.b);
+ RGB rgb = hsv_to_rgb_nocie((HSV){palette[i].hsv888.h, palette[i].hsv888.s, palette[i].hsv888.v});
+ uint16_t rgb565 = (((uint16_t)rgb.r) >> 3) << 11 | (((uint16_t)rgb.g) >> 2) << 5 | (((uint16_t)rgb.b) >> 3);
+ palette[i].rgb565 = BYTE_SWAP(rgb565);
}
return true;
}
+bool qp_tft_panel_palette_convert_rgb888(painter_device_t device, int16_t palette_size, qp_pixel_t *palette) {
+ for (int16_t i = 0; i < palette_size; ++i) {
+ RGB rgb = hsv_to_rgb_nocie((HSV){palette[i].hsv888.h, palette[i].hsv888.s, palette[i].hsv888.v});
+ palette[i].rgb888.r = rgb.r;
+ palette[i].rgb888.g = rgb.g;
+ palette[i].rgb888.b = rgb.b;
+ }
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Append pixels to the target location, keyed by the pixel index
-bool qp_tft_panel_append_pixels(painter_device_t device, uint8_t *target_buffer, qp_pixel_t *palette, uint32_t pixel_offset, uint32_t pixel_count, uint8_t *palette_indices) {
+
+bool qp_tft_panel_append_pixels_rgb565(painter_device_t device, uint8_t *target_buffer, qp_pixel_t *palette, uint32_t pixel_offset, uint32_t pixel_count, uint8_t *palette_indices) {
uint16_t *buf = (uint16_t *)target_buffer;
for (uint32_t i = 0; i < pixel_count; ++i) {
buf[pixel_offset + i] = palette[palette_indices[i]].rgb565;
}
return true;
}
+
+bool qp_tft_panel_append_pixels_rgb888(painter_device_t device, uint8_t *target_buffer, qp_pixel_t *palette, uint32_t pixel_offset, uint32_t pixel_count, uint8_t *palette_indices) {
+ for (uint32_t i = 0; i < pixel_count; ++i) {
+ target_buffer[(pixel_offset + i) * 3 + 0] = palette[palette_indices[i]].rgb888.r;
+ target_buffer[(pixel_offset + i) * 3 + 1] = palette[palette_indices[i]].rgb888.g;
+ target_buffer[(pixel_offset + i) * 3 + 2] = palette[palette_indices[i]].rgb888.b;
+ }
+ return true;
+}
diff --git a/drivers/painter/tft_panel/qp_tft_panel.h b/drivers/painter/tft_panel/qp_tft_panel.h
index 6eddfc503d..3cb015891b 100644
--- a/drivers/painter/tft_panel/qp_tft_panel.h
+++ b/drivers/painter/tft_panel/qp_tft_panel.h
@@ -11,15 +11,10 @@
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Common TFT panel implementation using D/C, and RST pins.
-typedef uint16_t (*rgb888_to_native_uint16_t)(uint8_t r, uint8_t g, uint8_t b);
-
// Driver vtable with extras
struct tft_panel_dc_reset_painter_driver_vtable_t {
struct painter_driver_vtable_t base; // must be first, so it can be cast to/from the painter_driver_vtable_t* type
- // Conversion function for palette entries
- rgb888_to_native_uint16_t rgb888_to_native16bit;
-
// Number of bytes for transmitting x/y coordinates
uint8_t num_window_bytes;
@@ -58,10 +53,9 @@ bool qp_tft_panel_clear(painter_device_t device);
bool qp_tft_panel_flush(painter_device_t device);
bool qp_tft_panel_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom);
bool qp_tft_panel_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count);
-bool qp_tft_panel_palette_convert(painter_device_t device, int16_t palette_size, qp_pixel_t *palette);
-bool qp_tft_panel_append_pixels(painter_device_t device, uint8_t *target_buffer, qp_pixel_t *palette, uint32_t pixel_offset, uint32_t pixel_count, uint8_t *palette_indices);
-uint16_t qp_rgb888_to_rgb565(uint8_t r, uint8_t g, uint8_t b);
-uint16_t qp_rgb888_to_rgb565_swapped(uint8_t r, uint8_t g, uint8_t b);
-uint16_t qp_rgb888_to_bgr565(uint8_t r, uint8_t g, uint8_t b);
-uint16_t qp_rgb888_to_bgr565_swapped(uint8_t r, uint8_t g, uint8_t b);
+bool qp_tft_panel_palette_convert_rgb565_swapped(painter_device_t device, int16_t palette_size, qp_pixel_t *palette);
+bool qp_tft_panel_palette_convert_rgb888(painter_device_t device, int16_t palette_size, qp_pixel_t *palette);
+
+bool qp_tft_panel_append_pixels_rgb565(painter_device_t device, uint8_t *target_buffer, qp_pixel_t *palette, uint32_t pixel_offset, uint32_t pixel_count, uint8_t *palette_indices);
+bool qp_tft_panel_append_pixels_rgb888(painter_device_t device, uint8_t *target_buffer, qp_pixel_t *palette, uint32_t pixel_offset, uint32_t pixel_count, uint8_t *palette_indices);
diff --git a/drivers/ps2/ps2.h b/drivers/ps2/ps2.h
index f123192852..2465e16235 100644
--- a/drivers/ps2/ps2.h
+++ b/drivers/ps2/ps2.h
@@ -89,6 +89,7 @@ uint8_t ps2_host_send(uint8_t data);
uint8_t ps2_host_recv_response(void);
uint8_t ps2_host_recv(void);
void ps2_host_set_led(uint8_t usb_led);
+bool pbuf_has_data(void);
/*--------------------------------------------------------------------
* static functions
diff --git a/drivers/ps2/ps2_interrupt.c b/drivers/ps2/ps2_interrupt.c
index c49b4f8b75..2810a0f126 100644
--- a/drivers/ps2/ps2_interrupt.c
+++ b/drivers/ps2/ps2_interrupt.c
@@ -66,8 +66,8 @@ uint8_t ps2_error = PS2_ERR_NONE;
static inline uint8_t pbuf_dequeue(void);
static inline void pbuf_enqueue(uint8_t data);
-static inline bool pbuf_has_data(void);
static inline void pbuf_clear(void);
+bool pbuf_has_data(void);
#if defined(PROTOCOL_CHIBIOS)
void ps2_interrupt_service_routine(void);
@@ -76,17 +76,18 @@ void palCallback(void *arg) {
}
# define PS2_INT_INIT() \
- { palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_INPUT); } \
- while (0)
+ do { \
+ palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_INPUT); \
+ } while (0)
# define PS2_INT_ON() \
- { \
+ do { \
palEnableLineEvent(PS2_CLOCK_PIN, PAL_EVENT_MODE_FALLING_EDGE); \
palSetLineCallback(PS2_CLOCK_PIN, palCallback, NULL); \
- } \
- while (0)
+ } while (0)
# define PS2_INT_OFF() \
- { palDisableLineEvent(PS2_CLOCK_PIN); } \
- while (0)
+ do { \
+ palDisableLineEvent(PS2_CLOCK_PIN); \
+ } while (0)
#endif // PROTOCOL_CHIBIOS
void ps2_host_init(void) {
@@ -309,7 +310,7 @@ static inline uint8_t pbuf_dequeue(void) {
return val;
}
-static inline bool pbuf_has_data(void) {
+bool pbuf_has_data(void) {
#if defined(__AVR__)
uint8_t sreg = SREG;
cli();
diff --git a/drivers/ps2/ps2_mouse.c b/drivers/ps2/ps2_mouse.c
index ccb0a929ae..66b48bb3c3 100644
--- a/drivers/ps2/ps2_mouse.c
+++ b/drivers/ps2/ps2_mouse.c
@@ -53,6 +53,7 @@ void ps2_mouse_init(void) {
ps2_mouse_set_remote_mode();
#else
ps2_mouse_enable_data_reporting();
+ ps2_mouse_set_stream_mode();
#endif
#ifdef PS2_MOUSE_ENABLE_SCROLLING
@@ -75,19 +76,33 @@ void ps2_mouse_task(void) {
extern int tp_buttons;
/* receives packet from mouse */
+#ifdef PS2_MOUSE_USE_REMOTE_MODE
uint8_t rcv;
rcv = ps2_host_send(PS2_MOUSE_READ_DATA);
if (rcv == PS2_ACK) {
mouse_report.buttons = ps2_host_recv_response() | tp_buttons;
mouse_report.x = ps2_host_recv_response() * PS2_MOUSE_X_MULTIPLIER;
mouse_report.y = ps2_host_recv_response() * PS2_MOUSE_Y_MULTIPLIER;
-#ifdef PS2_MOUSE_ENABLE_SCROLLING
+# ifdef PS2_MOUSE_ENABLE_SCROLLING
mouse_report.v = -(ps2_host_recv_response() & PS2_MOUSE_SCROLL_MASK) * PS2_MOUSE_V_MULTIPLIER;
-#endif
+# endif
+ } else {
+ if (debug_mouse) print("ps2_mouse: fail to get mouse packet\n");
+ return;
+ }
+#else
+ if (pbuf_has_data()) {
+ mouse_report.buttons = ps2_host_recv_response() | tp_buttons;
+ mouse_report.x = ps2_host_recv_response() * PS2_MOUSE_X_MULTIPLIER;
+ mouse_report.y = ps2_host_recv_response() * PS2_MOUSE_Y_MULTIPLIER;
+# ifdef PS2_MOUSE_ENABLE_SCROLLING
+ mouse_report.v = -(ps2_host_recv_response() & PS2_MOUSE_SCROLL_MASK) * PS2_MOUSE_V_MULTIPLIER;
+# endif
} else {
if (debug_mouse) print("ps2_mouse: fail to get mouse packet\n");
return;
}
+#endif
/* if mouse moves or buttons state changes */
if (mouse_report.x || mouse_report.y || mouse_report.v || ((mouse_report.buttons ^ buttons_prev) & PS2_MOUSE_BTN_MASK)) {
diff --git a/drivers/sensors/adns5050.h b/drivers/sensors/adns5050.h
index e45a250196..f20c2f74bc 100644
--- a/drivers/sensors/adns5050.h
+++ b/drivers/sensors/adns5050.h
@@ -40,15 +40,27 @@
// Definitions for the ADNS serial line.
#ifndef ADNS5050_SCLK_PIN
-# error "No clock pin defined -- missing ADNS5050_SCLK_PIN"
+# ifdef POINTING_DEVICE_SCLK_PIN
+# define ADNS5050_SCLK_PIN POINTING_DEVICE_SCLK_PIN
+# else
+# error "No clock pin defined -- missing POINTING_DEVICE_SCLK_PIN or ADNS5050_SCLK_PIN"
+# endif
#endif
#ifndef ADNS5050_SDIO_PIN
-# error "No data pin defined -- missing ADNS5050_SDIO_PIN"
+# ifdef POINTING_DEVICE_SDIO_PIN
+# define ADNS5050_SDIO_PIN POINTING_DEVICE_SDIO_PIN
+# else
+# error "No data pin defined -- missing POINTING_DEVICE_SDIO_PIN or ADNS5050_SDIO_PIN"
+# endif
#endif
#ifndef ADNS5050_CS_PIN
-# error "No chip select pin defined -- missing ADNS5050_CS_PIN"
+# ifdef POINTING_DEVICE_CS_PIN
+# define ADNS5050_CS_PIN POINTING_DEVICE_CS_PIN
+# else
+# error "No chip select pin defined -- missing POINTING_DEVICE_CS_PIN or ADNS5050_CS_PIN define"
+# endif
#endif
typedef struct {
diff --git a/drivers/sensors/adns9800.h b/drivers/sensors/adns9800.h
index e75a869c03..3f1a005789 100644
--- a/drivers/sensors/adns9800.h
+++ b/drivers/sensors/adns9800.h
@@ -43,7 +43,11 @@
#endif
#ifndef ADNS9800_CS_PIN
-# error "No chip select pin defined -- missing ADNS9800_CS_PIN"
+# ifdef POINTING_DEVICE_CS_PIN
+# define ADNS9800_CS_PIN POINTING_DEVICE_CS_PIN
+# else
+# error "No chip select pin defined -- missing POINTING_DEVICE_CS_PIN or ADNS9800_CS_PIN"
+# endif
#endif
typedef struct {
diff --git a/drivers/sensors/cirque_pinnacle.c b/drivers/sensors/cirque_pinnacle.c
index 2db7f916fe..8bd4eb736e 100644
--- a/drivers/sensors/cirque_pinnacle.c
+++ b/drivers/sensors/cirque_pinnacle.c
@@ -1,52 +1,26 @@
// Copyright (c) 2018 Cirque Corp. Restrictions apply. See: www.cirque.com/sw-license
+// based on https://github.com/cirque-corp/Cirque_Pinnacle_1CA027/tree/master/Circular_Trackpad
+// with modifications and changes for QMK
+// refer to documentation: Gen2 and Gen3 (Pinnacle ASIC) at https://www.cirque.com/documentation
+
#include "cirque_pinnacle.h"
#include "print.h"
#include "debug.h"
#include "wait.h"
+#include "timer.h"
+
+#include <stdlib.h>
-// Registers for RAP
-// clang-format off
-#define FIRMWARE_ID 0x00
-#define FIRMWARE_VERSION_C 0x01
-#define STATUS_1 0x02
-#define SYSCONFIG_1 0x03
-#define FEEDCONFIG_1 0x04
-#define FEEDCONFIG_2 0x05
-#define CALIBRATION_CONFIG_1 0x07
-#define PS2_AU_CONTROL 0x08
-#define SAMPLE_RATE 0x09
-#define Z_IDLE_COUNT 0x0A
-#define Z_SCALER 0x0B
-#define SLEEP_INTERVAL 0x0C
-#define SLEEP_TIMER 0x0D
-#define PACKET_BYTE_0 0x12
-#define PACKET_BYTE_1 0x13
-#define PACKET_BYTE_2 0x14
-#define PACKET_BYTE_3 0x15
-#define PACKET_BYTE_4 0x16
-#define PACKET_BYTE_5 0x17
-
-#define ERA_VALUE 0x1B
-#define ERA_HIGH_BYTE 0x1C
-#define ERA_LOW_BYTE 0x1D
-#define ERA_CONTROL 0x1E
-
-// ADC-attenuation settings (held in BIT_7 and BIT_6)
-// 1X = most sensitive, 4X = least sensitive
-#define ADC_ATTENUATE_1X 0x00
-#define ADC_ATTENUATE_2X 0x40
-#define ADC_ATTENUATE_3X 0x80
-#define ADC_ATTENUATE_4X 0xC0
-
-// Register config values for this demo
-#define SYSCONFIG_1_VALUE 0x00
-#define FEEDCONFIG_1_VALUE 0x03 // 0x03 for absolute mode 0x01 for relative mode
-#define FEEDCONFIG_2_VALUE 0x1C // 0x1F for normal functionality 0x1E for intellimouse disabled
-#define Z_IDLE_COUNT_VALUE 0x05
-// clang-format on
+#ifndef CIRQUE_PINNACLE_ATTENUATION
+# ifdef CIRQUE_PINNACLE_CURVED_OVERLAY
+# define CIRQUE_PINNACLE_ATTENUATION EXTREG__TRACK_ADCCONFIG__ADC_ATTENUATE_2X
+# else
+# define CIRQUE_PINNACLE_ATTENUATION EXTREG__TRACK_ADCCONFIG__ADC_ATTENUATE_4X
+# endif
+#endif
bool touchpad_init;
-uint16_t scale_data = 1024;
+uint16_t scale_data = CIRQUE_PINNACLE_DEFAULT_SCALE;
void cirque_pinnacle_clear_flags(void);
void cirque_pinnacle_enable_feed(bool feedEnable);
@@ -59,6 +33,7 @@ void print_byte(uint8_t byte) {
}
#endif
+#if CIRQUE_PINNACLE_POSITION_MODE
/* Logical Scaling Functions */
// Clips raw coordinates to "reachable" window of sensor
// NOTE: values outside this window can only appear as a result of noise
@@ -74,6 +49,7 @@ void ClipCoordinates(pinnacle_data_t* coordinates) {
coordinates->yValue = CIRQUE_PINNACLE_Y_UPPER;
}
}
+#endif
uint16_t cirque_pinnacle_get_scale(void) {
return scale_data;
@@ -84,6 +60,7 @@ void cirque_pinnacle_set_scale(uint16_t scale) {
// Scales data to desired X & Y resolution
void cirque_pinnacle_scale_data(pinnacle_data_t* coordinates, uint16_t xResolution, uint16_t yResolution) {
+#if CIRQUE_PINNACLE_POSITION_MODE
uint32_t xTemp = 0;
uint32_t yTemp = 0;
@@ -99,49 +76,65 @@ void cirque_pinnacle_scale_data(pinnacle_data_t* coordinates, uint16_t xResoluti
// scale coordinates to (xResolution, yResolution) range
coordinates->xValue = (uint16_t)(xTemp * xResolution / CIRQUE_PINNACLE_X_RANGE);
coordinates->yValue = (uint16_t)(yTemp * yResolution / CIRQUE_PINNACLE_Y_RANGE);
+#else
+ int32_t xTemp = 0, yTemp = 0;
+ ldiv_t temp;
+ static int32_t xRemainder, yRemainder;
+
+ temp = ldiv(((int32_t)coordinates->xDelta) * (int32_t)xResolution + xRemainder, (int32_t)CIRQUE_PINNACLE_X_RANGE);
+ xTemp = temp.quot;
+ xRemainder = temp.rem;
+
+ temp = ldiv(((int32_t)coordinates->yDelta) * (int32_t)yResolution + yRemainder, (int32_t)CIRQUE_PINNACLE_Y_RANGE);
+ yTemp = temp.quot;
+ yRemainder = temp.rem;
+
+ coordinates->xDelta = (int16_t)xTemp;
+ coordinates->yDelta = (int16_t)yTemp;
+#endif
}
// Clears Status1 register flags (SW_CC and SW_DR)
void cirque_pinnacle_clear_flags() {
- RAP_Write(STATUS_1, 0x00);
+ RAP_Write(HOSTREG__STATUS1, HOSTREG__STATUS1_DEFVAL & ~(HOSTREG__STATUS1__COMMAND_COMPLETE | HOSTREG__STATUS1__DATA_READY));
wait_us(50);
}
// Enables/Disables the feed
void cirque_pinnacle_enable_feed(bool feedEnable) {
- uint8_t temp;
-
- RAP_ReadBytes(FEEDCONFIG_1, &temp, 1); // Store contents of FeedConfig1 register
+ uint8_t feedconfig1;
+ RAP_ReadBytes(HOSTREG__FEEDCONFIG1, &feedconfig1, 1);
if (feedEnable) {
- temp |= 0x01; // Set Feed Enable bit
- RAP_Write(0x04, temp);
+ feedconfig1 |= HOSTREG__FEEDCONFIG1__FEED_ENABLE;
} else {
- temp &= ~0x01; // Clear Feed Enable bit
- RAP_Write(0x04, temp);
+ feedconfig1 &= ~HOSTREG__FEEDCONFIG1__FEED_ENABLE;
}
+ RAP_Write(HOSTREG__FEEDCONFIG1, feedconfig1);
}
/* ERA (Extended Register Access) Functions */
// Reads <count> bytes from an extended register at <address> (16-bit address),
// stores values in <*data>
void ERA_ReadBytes(uint16_t address, uint8_t* data, uint16_t count) {
- uint8_t ERAControlValue = 0xFF;
+ uint8_t ERAControlValue = 0xFF;
+ uint16_t timeout_timer;
cirque_pinnacle_enable_feed(false); // Disable feed
- RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Send upper byte of ERA address
- RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Send lower byte of ERA address
+ RAP_Write(HOSTREG__EXT_REG_AXS_ADDR_HIGH, (uint8_t)(address >> 8)); // Send upper byte of ERA address
+ RAP_Write(HOSTREG__EXT_REG_AXS_ADDR_LOW, (uint8_t)(address & 0x00FF)); // Send lower byte of ERA address
for (uint16_t i = 0; i < count; i++) {
- RAP_Write(ERA_CONTROL, 0x05); // Signal ERA-read (auto-increment) to Pinnacle
+ RAP_Write(HOSTREG__EXT_REG_AXS_CTRL, HOSTREG__EREG_AXS__INC_ADDR_READ | HOSTREG__EREG_AXS__READ); // Signal ERA-read (auto-increment) to Pinnacle
// Wait for status register 0x1E to clear
+ timeout_timer = timer_read();
do {
- RAP_ReadBytes(ERA_CONTROL, &ERAControlValue, 1);
- } while (ERAControlValue != 0x00);
+ RAP_ReadBytes(HOSTREG__EXT_REG_AXS_CTRL, &ERAControlValue, 1);
+ } while ((ERAControlValue != 0x00) && (timer_elapsed(timeout_timer) <= CIRQUE_PINNACLE_TIMEOUT));
- RAP_ReadBytes(ERA_VALUE, data + i, 1);
+ RAP_ReadBytes(HOSTREG__EXT_REG_AXS_VALUE, data + i, 1);
cirque_pinnacle_clear_flags();
}
@@ -149,49 +142,89 @@ void ERA_ReadBytes(uint16_t address, uint8_t* data, uint16_t count) {
// Writes a byte, <data>, to an extended register at <address> (16-bit address)
void ERA_WriteByte(uint16_t address, uint8_t data) {
- uint8_t ERAControlValue = 0xFF;
+ uint8_t ERAControlValue = 0xFF;
+ uint16_t timeout_timer;
cirque_pinnacle_enable_feed(false); // Disable feed
- RAP_Write(ERA_VALUE, data); // Send data byte to be written
+ RAP_Write(HOSTREG__EXT_REG_AXS_VALUE, data); // Send data byte to be written
- RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Upper byte of ERA address
- RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Lower byte of ERA address
+ RAP_Write(HOSTREG__EXT_REG_AXS_ADDR_HIGH, (uint8_t)(address >> 8)); // Upper byte of ERA address
+ RAP_Write(HOSTREG__EXT_REG_AXS_ADDR_LOW, (uint8_t)(address & 0x00FF)); // Lower byte of ERA address
- RAP_Write(ERA_CONTROL, 0x02); // Signal an ERA-write to Pinnacle
+ RAP_Write(HOSTREG__EXT_REG_AXS_CTRL, HOSTREG__EREG_AXS__WRITE); // Signal an ERA-write to Pinnacle
// Wait for status register 0x1E to clear
+ timeout_timer = timer_read();
do {
- RAP_ReadBytes(ERA_CONTROL, &ERAControlValue, 1);
- } while (ERAControlValue != 0x00);
+ RAP_ReadBytes(HOSTREG__EXT_REG_AXS_CTRL, &ERAControlValue, 1);
+ } while ((ERAControlValue != 0x00) && (timer_elapsed(timeout_timer) <= CIRQUE_PINNACLE_TIMEOUT));
cirque_pinnacle_clear_flags();
}
-void cirque_pinnacle_set_adc_attenuation(uint8_t adcGain) {
- uint8_t temp = 0x00;
+bool cirque_pinnacle_set_adc_attenuation(uint8_t adcGain) {
+ uint8_t adcconfig = 0x00;
+
+ ERA_ReadBytes(EXTREG__TRACK_ADCCONFIG, &adcconfig, 1);
+ adcGain &= EXTREG__TRACK_ADCCONFIG__ADC_ATTENUATE_MASK;
+ if (adcGain == (adcconfig & EXTREG__TRACK_ADCCONFIG__ADC_ATTENUATE_MASK)) {
+ return false;
+ }
+ adcconfig &= ~EXTREG__TRACK_ADCCONFIG__ADC_ATTENUATE_MASK;
+ adcconfig |= adcGain;
+ ERA_WriteByte(EXTREG__TRACK_ADCCONFIG, adcconfig);
+ ERA_ReadBytes(EXTREG__TRACK_ADCCONFIG, &adcconfig, 1);
- ERA_ReadBytes(0x0187, &temp, 1);
- temp &= 0x3F; // clear top two bits
- temp |= adcGain;
- ERA_WriteByte(0x0187, temp);
- ERA_ReadBytes(0x0187, &temp, 1);
+ return true;
}
// Changes thresholds to improve detection of fingers
+// Not needed for flat overlay?
void cirque_pinnacle_tune_edge_sensitivity(void) {
- uint8_t temp = 0x00;
+ uint8_t widezmin = 0x00;
+
+ ERA_ReadBytes(EXTREG__XAXIS_WIDEZMIN, &widezmin, 1);
+ ERA_WriteByte(EXTREG__XAXIS_WIDEZMIN, 0x04); // magic number from Cirque sample code
+ ERA_ReadBytes(EXTREG__XAXIS_WIDEZMIN, &widezmin, 1);
+
+ ERA_ReadBytes(EXTREG__YAXIS_WIDEZMIN, &widezmin, 1);
+ ERA_WriteByte(EXTREG__YAXIS_WIDEZMIN, 0x03); // magic number from Cirque sample code
+ ERA_ReadBytes(EXTREG__YAXIS_WIDEZMIN, &widezmin, 1);
+}
+
+// Perform calibration
+void cirque_pinnacle_calibrate(void) {
+ uint8_t calconfig;
+ uint16_t timeout_timer;
+
+ RAP_ReadBytes(HOSTREG__CALCONFIG1, &calconfig, 1);
+ calconfig |= HOSTREG__CALCONFIG1__CALIBRATE;
+ RAP_Write(HOSTREG__CALCONFIG1, calconfig);
+
+ // Calibration takes ~100ms according to GT-AN-090624, doubling the timeout just to be safe
+ timeout_timer = timer_read();
+ do {
+ RAP_ReadBytes(HOSTREG__CALCONFIG1, &calconfig, 1);
+ } while ((calconfig & HOSTREG__CALCONFIG1__CALIBRATE) && (timer_elapsed(timeout_timer) <= 200));
+
+ cirque_pinnacle_clear_flags();
+}
- ERA_ReadBytes(0x0149, &temp, 1);
- ERA_WriteByte(0x0149, 0x04);
- ERA_ReadBytes(0x0149, &temp, 1);
+// Enable/disable cursor smoothing, smoothing is enabled by default
+void cirque_pinnacle_cursor_smoothing(bool enable) {
+ uint8_t feedconfig3;
- ERA_ReadBytes(0x0168, &temp, 1);
- ERA_WriteByte(0x0168, 0x03);
- ERA_ReadBytes(0x0168, &temp, 1);
+ RAP_ReadBytes(HOSTREG__FEEDCONFIG3, &feedconfig3, 1);
+ if (enable) {
+ feedconfig3 &= ~HOSTREG__FEEDCONFIG3__DISABLE_CROSS_RATE_SMOOTHING;
+ } else {
+ feedconfig3 |= HOSTREG__FEEDCONFIG3__DISABLE_CROSS_RATE_SMOOTHING;
+ }
+ RAP_Write(HOSTREG__FEEDCONFIG3, feedconfig3);
}
-/* Pinnacle-based TM040040 Functions */
+/* Pinnacle-based TM040040/TM035035/TM023023 Functions */
void cirque_pinnacle_init(void) {
#if defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi)
spi_init();
@@ -200,39 +233,101 @@ void cirque_pinnacle_init(void) {
#endif
touchpad_init = true;
+
+ // send a RESET command now, in case QMK had a soft-reset without a power cycle
+ RAP_Write(HOSTREG__SYSCONFIG1, HOSTREG__SYSCONFIG1__RESET);
+ wait_ms(30); // Pinnacle needs 10-15ms to boot, so wait long enough before configuring
+ RAP_Write(HOSTREG__SYSCONFIG1, HOSTREG__SYSCONFIG1_DEFVAL);
+ wait_us(50);
+
// Host clears SW_CC flag
cirque_pinnacle_clear_flags();
- // Host configures bits of registers 0x03 and 0x05
- RAP_Write(SYSCONFIG_1, SYSCONFIG_1_VALUE);
- RAP_Write(FEEDCONFIG_2, FEEDCONFIG_2_VALUE);
+#if CIRQUE_PINNACLE_POSITION_MODE
+ RAP_Write(HOSTREG__FEEDCONFIG2, HOSTREG__FEEDCONFIG2_DEFVAL);
+#else
+ // FeedConfig2 (Feature flags for Relative Mode Only)
+ uint8_t feedconfig2 = HOSTREG__FEEDCONFIG2__GLIDE_EXTEND_DISABLE | HOSTREG__FEEDCONFIG2__INTELLIMOUSE_MODE;
+# if !defined(CIRQUE_PINNACLE_TAP_ENABLE)
+ feedconfig2 |= HOSTREG__FEEDCONFIG2__ALL_TAP_DISABLE;
+# endif
+# if !defined(CIRQUE_PINNACLE_SECONDARY_TAP_ENABLE)
+ feedconfig2 |= HOSTREG__FEEDCONFIG2__SECONDARY_TAP_DISABLE;
+# elif !defined(CIRQUE_PINNACLE_TAP_ENABLE)
+# error CIRQUE_PINNACLE_TAP_ENABLE must be defined for CIRQUE_PINNACLE_SECONDARY_TAP_ENABLE to work
+# endif
+# if !defined(CIRQUE_PINNACLE_SIDE_SCROLL_ENABLE)
+ feedconfig2 |= HOSTREG__FEEDCONFIG2__SCROLL_DISABLE;
+# endif
+ RAP_Write(HOSTREG__FEEDCONFIG2, feedconfig2);
+#endif
- // Host enables preferred output mode (absolute)
- RAP_Write(FEEDCONFIG_1, FEEDCONFIG_1_VALUE);
+ // FeedConfig1 (Data Output Flags)
+ RAP_Write(HOSTREG__FEEDCONFIG1, CIRQUE_PINNACLE_POSITION_MODE ? HOSTREG__FEEDCONFIG1__DATA_TYPE__REL0_ABS1 : HOSTREG__FEEDCONFIG1_DEFVAL);
- // Host sets z-idle packet count to 5 (default is 30)
- RAP_Write(Z_IDLE_COUNT, Z_IDLE_COUNT_VALUE);
+#if CIRQUE_PINNACLE_POSITION_MODE
+ // Host sets z-idle packet count to 5 (default is 0x1E/30)
+ RAP_Write(HOSTREG__ZIDLE, 5);
+#endif
- cirque_pinnacle_set_adc_attenuation(0xFF);
+ bool calibrate = cirque_pinnacle_set_adc_attenuation(CIRQUE_PINNACLE_ATTENUATION);
+
+#ifdef CIRQUE_PINNACLE_CURVED_OVERLAY
cirque_pinnacle_tune_edge_sensitivity();
+ calibrate = true;
+#endif
+ if (calibrate) {
+ // Force a calibration after setting ADC attenuation
+ cirque_pinnacle_calibrate();
+ }
+
cirque_pinnacle_enable_feed(true);
}
-// Reads XYZ data from Pinnacle registers 0x14 through 0x17
-// Stores result in pinnacle_data_t struct with xValue, yValue, and zValue members
pinnacle_data_t cirque_pinnacle_read_data(void) {
- uint8_t data[6] = {0};
- pinnacle_data_t result = {0};
- RAP_ReadBytes(PACKET_BYTE_0, data, 6);
+ uint8_t data_ready = 0;
+ uint8_t data[6] = {0};
+ pinnacle_data_t result = {0};
+
+ // Check if there is valid data available
+ RAP_ReadBytes(HOSTREG__STATUS1, &data_ready, 1);
+ if ((data_ready & HOSTREG__STATUS1__DATA_READY) == 0) {
+ // no data available yet
+ result.valid = false; // be explicit
+ return result;
+ }
- cirque_pinnacle_clear_flags();
+ // Read all data bytes
+ RAP_ReadBytes(HOSTREG__PACKETBYTE_0, data, 6);
- result.buttonFlags = data[0] & 0x3F;
- result.xValue = data[2] | ((data[4] & 0x0F) << 8);
- result.yValue = data[3] | ((data[4] & 0xF0) << 4);
- result.zValue = data[5] & 0x3F;
+ // Get ready for the next data sample
+ cirque_pinnacle_clear_flags();
- result.touchDown = (result.xValue != 0 || result.yValue != 0);
+#if CIRQUE_PINNACLE_POSITION_MODE
+ // Decode data for absolute mode
+ // Register 0x13 is unused in this mode (palm detection area)
+ result.buttonFlags = data[0] & 0x3F; // bit0 to bit5 are switch 0-5, only hardware button presses (from input pin on the Pinnacle chip)
+ result.xValue = data[2] | ((data[4] & 0x0F) << 8); // merge high and low bits for X
+ result.yValue = data[3] | ((data[4] & 0xF0) << 4); // merge high and low bits for Y
+ result.zValue = data[5] & 0x3F; // Z is only lower 6 bits, upper 2 bits are reserved/unused
+ result.touchDown = (result.xValue != 0 || result.yValue != 0); // (0,0) is a "magic coordinate" to indicate "finger touched down"
+#else
+ // Decode data for relative mode
+ // Registers 0x16 and 0x17 are unused in this mode
+ result.buttons = data[0] & 0x07; // Only three buttons are supported
+ if ((data[0] & 0x10) && data[1] != 0) {
+ result.xDelta = -((int16_t)256 - (int16_t)(data[1]));
+ } else {
+ result.xDelta = data[1];
+ }
+ if ((data[0] & 0x20) && data[2] != 0) {
+ result.yDelta = ((int16_t)256 - (int16_t)(data[2]));
+ } else {
+ result.yDelta = -((int16_t)data[2]);
+ }
+ result.wheelCount = ((int8_t*)data)[3];
+#endif
+ result.valid = true;
return result;
}
diff --git a/drivers/sensors/cirque_pinnacle.h b/drivers/sensors/cirque_pinnacle.h
index c8cb360e03..fa06e047f2 100644
--- a/drivers/sensors/cirque_pinnacle.h
+++ b/drivers/sensors/cirque_pinnacle.h
@@ -2,53 +2,63 @@
#pragma once
+#include "cirque_pinnacle_regdefs.h"
#include <stdint.h>
#include <stdbool.h>
-// Convenient way to store and access measurements
-typedef struct {
- uint16_t xValue;
- uint16_t yValue;
- uint16_t zValue;
- uint8_t buttonFlags;
- bool touchDown;
-} pinnacle_data_t;
-
-void cirque_pinnacle_init(void);
-pinnacle_data_t cirque_pinnacle_read_data(void);
-void cirque_pinnacle_scale_data(pinnacle_data_t* coordinates, uint16_t xResolution, uint16_t yResolution);
-uint16_t cirque_pinnacle_get_scale(void);
-void cirque_pinnacle_set_scale(uint16_t scale);
-
#ifndef CIRQUE_PINNACLE_TIMEOUT
-# define CIRQUE_PINNACLE_TIMEOUT 20
+# define CIRQUE_PINNACLE_TIMEOUT 20 // I2C timeout in milliseconds
#endif
-// Coordinate scaling values
-#ifndef CIRQUE_PINNACLE_X_LOWER
-# define CIRQUE_PINNACLE_X_LOWER 127 // min "reachable" X value
-#endif
-#ifndef CIRQUE_PINNACLE_X_UPPER
-# define CIRQUE_PINNACLE_X_UPPER 1919 // max "reachable" X value
-#endif
-#ifndef CIRQUE_PINNACLE_Y_LOWER
-# define CIRQUE_PINNACLE_Y_LOWER 63 // min "reachable" Y value
+#define CIRQUE_PINNACLE_ABSOLUTE_MODE 1
+#define CIRQUE_PINNACLE_RELATIVE_MODE 0
+#ifndef CIRQUE_PINNACLE_POSITION_MODE
+# define CIRQUE_PINNACLE_POSITION_MODE CIRQUE_PINNACLE_ABSOLUTE_MODE
#endif
-#ifndef CIRQUE_PINNACLE_Y_UPPER
-# define CIRQUE_PINNACLE_Y_UPPER 1471 // max "reachable" Y value
+
+#define CIRQUE_PINNACLE_DEFAULT_SCALE 1024
+#ifndef CIRQUE_PINNACLE_DIAMETER_MM
+# define CIRQUE_PINNACLE_DIAMETER_MM 40
#endif
-#ifndef CIRQUE_PINNACLE_X_RANGE
-# define CIRQUE_PINNACLE_X_RANGE (CIRQUE_PINNACLE_X_UPPER - CIRQUE_PINNACLE_X_LOWER)
+
+#if CIRQUE_PINNACLE_POSITION_MODE
+// Coordinate scaling values
+# ifndef CIRQUE_PINNACLE_X_LOWER
+# define CIRQUE_PINNACLE_X_LOWER 127 // min "reachable" X value
+# endif
+# ifndef CIRQUE_PINNACLE_X_UPPER
+# define CIRQUE_PINNACLE_X_UPPER 1919 // max "reachable" X value
+# endif
+# ifndef CIRQUE_PINNACLE_Y_LOWER
+# define CIRQUE_PINNACLE_Y_LOWER 63 // min "reachable" Y value
+# endif
+# ifndef CIRQUE_PINNACLE_Y_UPPER
+# define CIRQUE_PINNACLE_Y_UPPER 1471 // max "reachable" Y value
+# endif
+# ifndef CIRQUE_PINNACLE_X_RANGE
+# define CIRQUE_PINNACLE_X_RANGE (CIRQUE_PINNACLE_X_UPPER - CIRQUE_PINNACLE_X_LOWER)
+# endif
+# ifndef CIRQUE_PINNACLE_Y_RANGE
+# define CIRQUE_PINNACLE_Y_RANGE (CIRQUE_PINNACLE_Y_UPPER - CIRQUE_PINNACLE_Y_LOWER)
+# endif
+# if defined(POINTING_DEVICE_GESTURES_SCROLL_ENABLE)
+# define CIRQUE_PINNACLE_CIRCULAR_SCROLL_ENABLE
+# endif
+#else
+# define CIRQUE_PINNACLE_X_RANGE 256
+# define CIRQUE_PINNACLE_Y_RANGE 256
+# if defined(POINTING_DEVICE_GESTURES_SCROLL_ENABLE)
+# define CIRQUE_PINNACLE_SIDE_SCROLL_ENABLE
+# endif
#endif
-#ifndef CIRQUE_PINNACLE_Y_RANGE
-# define CIRQUE_PINNACLE_Y_RANGE (CIRQUE_PINNACLE_Y_UPPER - CIRQUE_PINNACLE_Y_LOWER)
+#if !defined(POINTING_DEVICE_TASK_THROTTLE_MS)
+# define POINTING_DEVICE_TASK_THROTTLE_MS 10 // Cirque Pinnacle in normal operation produces data every 10ms. Advanced configuration for pen/stylus usage might require lower values.
#endif
-
#if defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_i2c)
# include "i2c_master.h"
// Cirque's 7-bit I2C Slave Address
# ifndef CIRQUE_PINNACLE_ADDR
-# define CIRQUE_PINNACLE_ADDR 0x2A
+# define CIRQUE_PINNACLE_ADDR I2C_ADDRESS_DEFAULT
# endif
#elif defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi)
# include "spi_master.h"
@@ -68,7 +78,40 @@ void cirque_pinnacle_set_scale(uint16_t scale);
# define CIRQUE_PINNACLE_SPI_DIVISOR 64
# endif
# ifndef CIRQUE_PINNACLE_SPI_CS_PIN
-# error "No Chip Select pin has been defined -- missing CIRQUE_PINNACLE_SPI_CS_PIN define"
+# ifdef POINTING_DEVICE_CS_PIN
+# define CIRQUE_PINNACLE_SPI_CS_PIN POINTING_DEVICE_CS_PIN
+# else
+# error "No Chip Select pin has been defined -- missing POINTING_DEVICE_CS_PIN or CIRQUE_PINNACLE_SPI_CS_PIN define"
+# endif
# endif
# endif
#endif
+
+#define DIVIDE_UNSIGNED_ROUND(numerator, denominator) (((numerator) + ((denominator) / 2)) / (denominator))
+#define CIRQUE_PINNACLE_INCH_TO_PX(inch) (DIVIDE_UNSIGNED_ROUND((inch) * (uint32_t)CIRQUE_PINNACLE_DIAMETER_MM * 10, 254))
+#define CIRQUE_PINNACLE_PX_TO_INCH(px) (DIVIDE_UNSIGNED_ROUND((px) * (uint32_t)254, CIRQUE_PINNACLE_DIAMETER_MM * 10))
+
+// Convenient way to store and access measurements
+typedef struct {
+ bool valid; // true if valid data was read, false if no data was ready
+#if CIRQUE_PINNACLE_POSITION_MODE
+ uint16_t xValue;
+ uint16_t yValue;
+ uint16_t zValue;
+ uint8_t buttonFlags;
+ bool touchDown;
+#else
+ int16_t xDelta;
+ int16_t yDelta;
+ int8_t wheelCount;
+ uint8_t buttons;
+#endif
+} pinnacle_data_t;
+
+void cirque_pinnacle_init(void);
+void cirque_pinnacle_calibrate(void);
+void cirque_pinnacle_cursor_smoothing(bool enable);
+pinnacle_data_t cirque_pinnacle_read_data(void);
+void cirque_pinnacle_scale_data(pinnacle_data_t* coordinates, uint16_t xResolution, uint16_t yResolution);
+uint16_t cirque_pinnacle_get_scale(void);
+void cirque_pinnacle_set_scale(uint16_t scale);
diff --git a/drivers/sensors/cirque_pinnacle_gestures.c b/drivers/sensors/cirque_pinnacle_gestures.c
new file mode 100644
index 0000000000..a73b745e59
--- /dev/null
+++ b/drivers/sensors/cirque_pinnacle_gestures.c
@@ -0,0 +1,238 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2022 Daniel Kao <daniel.m.kao@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <stdlib.h>
+#include <lib/lib8tion/lib8tion.h>
+#include "cirque_pinnacle_gestures.h"
+#include "pointing_device.h"
+#include "timer.h"
+#include "wait.h"
+#if defined(SPLIT_POINTING_ENABLE) && defined(POINTING_DEVICE_COMBINED)
+# include "keyboard.h"
+#endif
+
+#if (defined(CIRQUE_PINNACLE_TAP_ENABLE) || defined(CIRQUE_PINNACLE_CIRCULAR_SCROLL_ENABLE)) && CIRQUE_PINNACLE_POSITION_MODE
+static cirque_pinnacle_features_t features = {.tap_enable = true, .circular_scroll_enable = true};
+#endif
+
+#if defined(CIRQUE_PINNACLE_TAP_ENABLE) && CIRQUE_PINNACLE_POSITION_MODE
+static trackpad_tap_context_t tap;
+
+static report_mouse_t trackpad_tap(report_mouse_t mouse_report, pinnacle_data_t touchData) {
+ if (touchData.touchDown != tap.touchDown) {
+ tap.touchDown = touchData.touchDown;
+ if (!touchData.zValue) {
+ if (timer_elapsed(tap.timer) < CIRQUE_PINNACLE_TAPPING_TERM && tap.timer != 0) {
+ mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, true, POINTING_DEVICE_BUTTON1);
+ pointing_device_set_report(mouse_report);
+ pointing_device_send();
+# if TAP_CODE_DELAY > 0
+ wait_ms(TAP_CODE_DELAY);
+# endif
+ mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, false, POINTING_DEVICE_BUTTON1);
+ pointing_device_set_report(mouse_report);
+ pointing_device_send();
+ }
+ }
+ tap.timer = timer_read();
+ }
+ if (timer_elapsed(tap.timer) > (CIRQUE_PINNACLE_TOUCH_DEBOUNCE)) {
+ tap.timer = 0;
+ }
+
+ return mouse_report;
+}
+
+void cirque_pinnacle_enable_tap(bool enable) {
+ features.tap_enable = enable;
+}
+#endif
+
+#ifdef CIRQUE_PINNACLE_CIRCULAR_SCROLL_ENABLE
+# if !CIRQUE_PINNACLE_POSITION_MODE
+# error "Circular scroll is not supported in relative mode"
+# endif
+/* To set a trackpad exclusively as scroll wheel: outer_ring_pct = 100, trigger_px = 0, trigger_ang = 0 */
+static circular_scroll_context_t scroll = {.config = {.outer_ring_pct = 33,
+ .trigger_px = 16,
+ .trigger_ang = 9102, /* 50 degrees */
+ .wheel_clicks = 18}};
+
+static inline uint16_t atan2_16(int32_t dy, int32_t dx) {
+ if (dy == 0) {
+ if (dx >= 0) {
+ return 0;
+ } else {
+ return 32768;
+ }
+ }
+
+ int32_t abs_y = dy > 0 ? dy : -dy;
+ int16_t a;
+
+ if (dx >= 0) {
+ a = 8192 - (8192 * (dx - abs_y) / (dx + abs_y));
+ } else {
+ a = 24576 - (8192 * (dx + abs_y) / (abs_y - dx));
+ }
+
+ if (dy < 0) {
+ return -a; // negate if in quad III or IV
+ }
+ return a;
+}
+
+static circular_scroll_t circular_scroll(pinnacle_data_t touchData) {
+ circular_scroll_t report = {0, 0, false};
+ int8_t x, y, wheel_clicks;
+ uint8_t center = INT8_MAX, mag;
+ int16_t ang, dot, det, opposite_side, adjacent_side;
+ uint16_t scale = cirque_pinnacle_get_scale();
+
+ if (touchData.zValue) {
+ /*
+ * Place origin at center of trackpad, treat coordinates as vectors.
+ * Scale to +/-INT8_MAX; angles are independent of resolution.
+ */
+ if (scale) {
+ /* Rotate coordinates into a consistent orientation */
+ report_mouse_t rot = {.x = (int8_t)((int32_t)touchData.xValue * INT8_MAX * 2 / scale - center), .y = (int8_t)((int32_t)touchData.yValue * INT8_MAX * 2 / scale - center)};
+# if defined(SPLIT_POINTING_ENABLE) && defined(POINTING_DEVICE_COMBINED)
+ if (!is_keyboard_left()) {
+ rot = pointing_device_adjust_by_defines_right(rot);
+ } else
+# endif
+ {
+ rot = pointing_device_adjust_by_defines(rot);
+ }
+ x = rot.x;
+ y = rot.y;
+ } else {
+ x = 0;
+ y = 0;
+ }
+
+ /* Check if first touch */
+ if (!scroll.z) {
+ report.suppress_touch = false;
+ /* Check if touch falls within outer ring */
+ mag = sqrt16(x * x + y * y);
+ if (mag * 100 / center >= 100 - scroll.config.outer_ring_pct) {
+ scroll.state = SCROLL_DETECTING;
+ scroll.x = x;
+ scroll.y = y;
+ scroll.mag = mag;
+ /*
+ * Decide scroll axis:
+ * Vertical if started from righ half
+ * Horizontal if started from left half
+ * Flipped for left-handed
+ */
+ scroll.axis = x < 0;
+ }
+ } else if (scroll.state == SCROLL_DETECTING) {
+ report.suppress_touch = true;
+ /* Already detecting scroll, check movement from touchdown location */
+ mag = sqrt16((x - scroll.x) * (x - scroll.x) + (y - scroll.y) * (y - scroll.y));
+ if (mag >= scroll.config.trigger_px) {
+ /*
+ * Find angle of movement.
+ * 0 degrees here means movement towards center of circle
+ */
+ dot = scroll.x * x + scroll.y * y;
+ det = scroll.x * y - scroll.y * x;
+ opposite_side = abs(det); /* Based on scalar rejection */
+ adjacent_side = abs(scroll.mag * scroll.mag - abs(dot)); /* Based on scalar projection */
+ ang = (int16_t)atan2_16(opposite_side, adjacent_side);
+ if (ang < scroll.config.trigger_ang) {
+ /* Not a scroll, release coordinates */
+ report.suppress_touch = false;
+ scroll.state = NOT_SCROLL;
+ } else {
+ /* Scroll detected */
+ scroll.state = SCROLL_VALID;
+ }
+ }
+ }
+ if (scroll.state == SCROLL_VALID) {
+ report.suppress_touch = true;
+ dot = scroll.x * x + scroll.y * y;
+ det = scroll.x * y - scroll.y * x;
+ ang = (int16_t)atan2_16(det, dot);
+ wheel_clicks = ((int32_t)ang * scroll.config.wheel_clicks) / 65536;
+ if (wheel_clicks >= 1 || wheel_clicks <= -1) {
+ if (scroll.config.left_handed) {
+ if (scroll.axis == 0) {
+ report.h = -wheel_clicks;
+ } else {
+ report.v = wheel_clicks;
+ }
+ } else {
+ if (scroll.axis == 0) {
+ report.v = -wheel_clicks;
+ } else {
+ report.h = wheel_clicks;
+ }
+ }
+ scroll.x = x;
+ scroll.y = y;
+ }
+ }
+ }
+
+ scroll.z = touchData.zValue;
+ if (!scroll.z) scroll.state = SCROLL_UNINITIALIZED;
+
+ return report;
+}
+
+void cirque_pinnacle_enable_circular_scroll(bool enable) {
+ features.circular_scroll_enable = enable;
+}
+
+void cirque_pinnacle_configure_circular_scroll(uint8_t outer_ring_pct, uint8_t trigger_px, uint16_t trigger_ang, uint8_t wheel_clicks, bool left_handed) {
+ scroll.config.outer_ring_pct = outer_ring_pct;
+ scroll.config.trigger_px = trigger_px;
+ scroll.config.trigger_ang = trigger_ang;
+ scroll.config.wheel_clicks = wheel_clicks;
+ scroll.config.left_handed = left_handed;
+}
+#endif
+
+bool cirque_pinnacle_gestures(report_mouse_t* mouse_report, pinnacle_data_t touchData) {
+ bool suppress_mouse_update = false;
+
+#ifdef CIRQUE_PINNACLE_CIRCULAR_SCROLL_ENABLE
+# if !CIRQUE_PINNACLE_POSITION_MODE
+# error "Circular scroll is not supported in relative mode"
+# endif
+ circular_scroll_t scroll_report;
+ if (features.circular_scroll_enable) {
+ scroll_report = circular_scroll(touchData);
+ mouse_report->v = scroll_report.v;
+ mouse_report->h = scroll_report.h;
+ suppress_mouse_update = scroll_report.suppress_touch;
+ }
+#endif
+
+#if defined(CIRQUE_PINNACLE_TAP_ENABLE) && CIRQUE_PINNACLE_POSITION_MODE
+ if (features.tap_enable) {
+ *mouse_report = trackpad_tap(*mouse_report, touchData);
+ }
+#endif
+
+ return suppress_mouse_update;
+}
diff --git a/drivers/sensors/cirque_pinnacle_gestures.h b/drivers/sensors/cirque_pinnacle_gestures.h
new file mode 100644
index 0000000000..d2aa206b2b
--- /dev/null
+++ b/drivers/sensors/cirque_pinnacle_gestures.h
@@ -0,0 +1,110 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2022 Daniel Kao <daniel.m.kao@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include "cirque_pinnacle.h"
+#include "report.h"
+
+typedef struct {
+ bool tap_enable;
+ bool circular_scroll_enable;
+} cirque_pinnacle_features_t;
+
+#if defined(CIRQUE_PINNACLE_TAP_ENABLE) && CIRQUE_PINNACLE_POSITION_MODE
+# ifndef CIRQUE_PINNACLE_TAPPING_TERM
+# include "action.h"
+# include "action_tapping.h"
+# define CIRQUE_PINNACLE_TAPPING_TERM GET_TAPPING_TERM(KC_BTN1, &(keyrecord_t){})
+# endif
+# ifndef CIRQUE_PINNACLE_TOUCH_DEBOUNCE
+# define CIRQUE_PINNACLE_TOUCH_DEBOUNCE (CIRQUE_PINNACLE_TAPPING_TERM * 8)
+# endif
+
+typedef struct {
+ uint16_t timer;
+ bool touchDown;
+} trackpad_tap_context_t;
+
+/* Enable/disable tap gesture */
+void cirque_pinnacle_enable_tap(bool enable);
+#endif
+
+#ifdef CIRQUE_PINNACLE_CIRCULAR_SCROLL_ENABLE
+# if !CIRQUE_PINNACLE_POSITION_MODE
+# error "Circular scroll is not supported in relative mode"
+# endif
+typedef enum {
+ SCROLL_UNINITIALIZED,
+ SCROLL_DETECTING,
+ SCROLL_VALID,
+ NOT_SCROLL,
+} circular_scroll_status_t;
+
+typedef struct {
+ int8_t v;
+ int8_t h;
+ bool suppress_touch;
+} circular_scroll_t;
+
+typedef struct {
+ uint8_t outer_ring_pct; /* Width of outer ring, given as a percentage of the radius */
+ uint8_t trigger_px; /* Amount of movement before triggering scroll validation, in pixels 0~127 */
+ uint16_t trigger_ang; /* Angle required to validate scroll, in radians where pi = 32768 */
+ uint8_t wheel_clicks; /* How many clicks to report in a circle */
+ bool left_handed; /* Whether scrolling should be flipped for left handed use */
+} circular_scroll_config_t;
+
+typedef struct {
+ circular_scroll_config_t config;
+ circular_scroll_status_t state;
+ uint8_t mag;
+ int8_t x;
+ int8_t y;
+ uint16_t z;
+ bool axis;
+} circular_scroll_context_t;
+
+/* Enable/disable circular scroll gesture */
+void cirque_pinnacle_enable_circular_scroll(bool enable);
+
+/*
+ * Configure circular scroll gesture.
+ * Trackpad can be configured to act exclusively as a scroll wheel with outer_ring_pct = 0, trigger_px = 0, trigger_ang = 0.
+ * @param outer_ring_pct Width of outer ring from which to begin scroll validation, given as a percentage of the radius.
+ * @param trigger_px Amount of movement before triggering scroll validation. Expressed in pixels, trackpad coordinates are scaled to radius of 128 pixels for circular scroll.
+ * @param triger_ang Angle required to validate scroll, angle smaller than this will invalidate scroll. In radians where pi = 32768, 0 means movement towards center of trackpad, 16384 means movement perpendicular to center.
+ * @param wheel_clicks Number of scroll wheel clicks to report in a full rotation.
+ * @param left_handed Whether scrolling should be flipped for left-handed use.
+ */
+void cirque_pinnacle_configure_circular_scroll(uint8_t outer_ring_pct, uint8_t trigger_px, uint16_t trigger_ang, uint8_t wheel_clicks, bool left_handed);
+#endif
+
+#ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
+/* Implementation in pointing_device_drivers.c */
+
+/* Enable/disable inertial cursor */
+void cirque_pinnacle_enable_cursor_glide(bool enable);
+
+/*
+ * Configure inertial cursor.
+ * @param trigger_px Movement required to trigger cursor glide, set this to non-zero if you have some amount of hover.
+ */
+void cirque_pinnacle_configure_cursor_glide(float trigger_px);
+#endif
+
+/* Process available gestures */
+bool cirque_pinnacle_gestures(report_mouse_t* mouse_report, pinnacle_data_t touchData);
diff --git a/drivers/sensors/cirque_pinnacle_i2c.c b/drivers/sensors/cirque_pinnacle_i2c.c
index 8a38f1dcea..b328dd9a7a 100644
--- a/drivers/sensors/cirque_pinnacle_i2c.c
+++ b/drivers/sensors/cirque_pinnacle_i2c.c
@@ -19,7 +19,7 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) {
i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT);
if (i2c_readReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
#ifdef CONSOLE_ENABLE
- dprintf("error right touchpad\n");
+ dprintf("error cirque_pinnacle i2c_readReg\n");
#endif
touchpad_init = false;
}
@@ -34,7 +34,7 @@ void RAP_Write(uint8_t address, uint8_t data) {
if (touchpad_init) {
if (i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
#ifdef CONSOLE_ENABLE
- dprintf("error right touchpad\n");
+ dprintf("error cirque_pinnacle i2c_writeReg\n");
#endif
touchpad_init = false;
}
diff --git a/drivers/sensors/cirque_pinnacle_regdefs.h b/drivers/sensors/cirque_pinnacle_regdefs.h
new file mode 100644
index 0000000000..fb9e09af6e
--- /dev/null
+++ b/drivers/sensors/cirque_pinnacle_regdefs.h
@@ -0,0 +1,405 @@
+// Copyright (c) 2018 Cirque Corp. Restrictions apply. See: www.cirque.com/sw-license
+// based on https://github.com/cirque-corp/Cirque_Pinnacle_1CA027/tree/master/Additional_Examples
+// with modifications and changes for QMK
+// refer to documentation: Gen2 and Gen3 (Pinnacle ASIC) at https://www.cirque.com/gen2gen3-asic-details
+
+#pragma once
+
+// clang-format off
+
+#define HostReg__0 (0x00)
+#define HostReg__1 (0x01)
+#define HostReg__2 (0x02)
+#define HostReg__3 (0x03)
+#define HostReg__4 (0x04)
+#define HostReg__5 (0x05)
+#define HostReg__6 (0x06)
+#define HostReg__7 (0x07)
+#define HostReg__8 (0x08)
+#define HostReg__9 (0x09)
+#define HostReg__10 (0x0A)
+#define HostReg__11 (0x0B)
+#define HostReg__12 (0x0C)
+#define HostReg__13 (0x0D)
+#define HostReg__14 (0x0E)
+#define HostReg__15 (0x0F)
+#define HostReg__16 (0x10)
+#define HostReg__17 (0x11)
+#define HostReg__18 (0x12)
+#define HostReg__19 (0x13)
+#define HostReg__20 (0x14)
+#define HostReg__21 (0x15)
+#define HostReg__22 (0x16)
+#define HostReg__23 (0x17)
+#define HostReg__24 (0x18)
+#define HostReg__25 (0x19)
+#define HostReg__26 (0x1A)
+#define HostReg__27 (0x1B)
+#define HostReg__28 (0x1C)
+#define HostReg__29 (0x1D)
+#define HostReg__30 (0x1E)
+#define HostReg__31 (0x1F)
+
+// ---------------- Register Assignments -------------------------------------
+
+/*--------------------------------------------------------------------------*\
+ Chip ID / Version
+\*--------------------------------------------------------------------------*/
+// Chip ID Register
+#define HOSTREG__CHIPID HostReg__0
+
+// Chip Version Register
+#define HOSTREG__VERSION HostReg__1
+
+/*--------------------------------------------------------------------------*\
+ Status Register
+\*--------------------------------------------------------------------------*/
+// Status 1 Register -- MUST BE HOSTREG__2
+#define HOSTREG__STATUS1 HostReg__2
+# define HOSTREG__STATUS1__DATA_READY 0x04
+# define HOSTREG__STATUS1__COMMAND_COMPLETE 0x08
+#define HOSTREG__STATUS1_DEFVAL 0x00
+
+/*--------------------------------------------------------------------------*\
+ System Config Register
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__SYSCONFIG1 HostReg__3
+# define HOSTREG__SYSCONFIG1__RESET 0x01
+# define HOSTREG__SYSCONFIG1__STANDBY 0x02
+# define HOSTREG__SYSCONFIG1__AUTO_SLEEP 0x04
+# define HOSTREG__SYSCONFIG1__TRACK_DISABLE 0x08
+# define HOSTREG__SYSCONFIG1__ANYMEAS_ENABLE 0x10
+# define HOSTREG__SYSCONFIG1__GPIO_CTRL_ENABLE 0x20
+# define HOSTREG__SYSCONFIG1__WAKEUP_TOGGLE 0x40
+# define HOSTREG__SYSCONFIG1__FORCE_WAKEUP 0x80
+#define HOSTREG__SYSCONFIG1_DEFVAL 0x00
+
+/*--------------------------------------------------------------------------*\
+ Feed Config Registers
+\*--------------------------------------------------------------------------*/
+// Feed Config Register1
+#define HOSTREG__FEEDCONFIG1 HostReg__4
+# define HOSTREG__FEEDCONFIG1__FEED_ENABLE 0x01
+# define HOSTREG__FEEDCONFIG1__DATA_TYPE__REL0_ABS1 0x02
+# define HOSTREG__FEEDCONFIG1__FILTER_DISABLE 0x04
+# define HOSTREG__FEEDCONFIG1__X_AXIS_DISABLE 0x08
+# define HOSTREG__FEEDCONFIG1__Y_AXIS_DISABLE 0x10
+# define HOSTREG__FEEDCONFIG1__AXIS_FOR_Z__Y0_X1 0x20
+# define HOSTREG__FEEDCONFIG1__X_DATA_INVERT 0x40
+# define HOSTREG__FEEDCONFIG1__Y_DATA_INVERT 0x80
+#define HOSTREG__FEEDCONFIG1_DEFVAL 0x00
+
+// Feed Config Register2
+#define HOSTREG__FEEDCONFIG2 HostReg__5
+# define HOSTREG__FEEDCONFIG2__INTELLIMOUSE_MODE 0x01
+# define HOSTREG__FEEDCONFIG2__ALL_TAP_DISABLE 0x02
+# define HOSTREG__FEEDCONFIG2__SECONDARY_TAP_DISABLE 0x04
+# define HOSTREG__FEEDCONFIG2__SCROLL_DISABLE 0x08
+# define HOSTREG__FEEDCONFIG2__GLIDE_EXTEND_DISABLE 0x10
+# define HOSTREG__FEEDCONFIG2__PALM_BEFORE_Z_ENABLE 0x20
+# define HOSTREG__FEEDCONFIG2__BUTNS_46_SCROLL_5_MIDDLE 0x40
+# define HOSTREG__FEEDCONFIG2__SWAP_XY_RELATIVE 0x80
+#define HOSTREG__FEEDCONFIG2_DEFVAL 0x00
+
+// Feed Config Register3
+#define HOSTREG__FEEDCONFIG3 HostReg__6
+# define HOSTREG__FEEDCONFIG3__BTNS_456_TO_123_IN_REL 0x01
+# define HOSTREG__FEEDCONFIG3__DISABLE_CROSS_RATE_SMOOTHING 0x02
+# define HOSTREG__FEEDCONFIG3__DISABLE_PALM_NERD_MEAS 0x04
+# define HOSTREG__FEEDCONFIG3__DISABLE_NOISE_AVOIDANCE 0x08
+# define HOSTREG__FEEDCONFIG3__DISABLE_WRAP_LOCKOUT 0x10
+# define HOSTREG__FEEDCONFIG3__DISABLE_DYNAMIC_EMI_ADJUST 0x20
+# define HOSTREG__FEEDCONFIG3__DISABLE_HW_EMI_DETECT 0x40
+# define HOSTREG__FEEDCONFIG3__DISABLE_SW_EMI_DETECT 0x80
+#define HOSTREG__FEEDCONFIG3_DEFVAL 0x00
+
+/*--------------------------------------------------------------------------*\
+ Calibration Config
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__CALCONFIG1 HostReg__7
+# define HOSTREG__CALCONFIG1__CALIBRATE 0x01
+# define HOSTREG__CALCONFIG1__BACKGROUND_COMP_ENABLE 0x02
+# define HOSTREG__CALCONFIG1__NERD_COMP_ENABLE 0x04
+# define HOSTREG__CALCONFIG1__TRACK_ERROR_COMP_ENABLE 0x08
+# define HOSTREG__CALCONFIG1__TAP_COMP_ENABLE 0x10
+# define HOSTREG__CALCONFIG1__PALM_ERROR_COMP_ENABLE 0x20
+# define HOSTREG__CALCONFIG1__CALIBRATION_MATRIX_DISABLE 0x40
+# define HOSTREG__CALCONFIG1__FORCE_PRECALIBRATION_NOISE_CHECK 0x80
+#define HOSTREG__CALCONFIG1_DEFVAL (HOSTREG__CALCONFIG1__BACKGROUND_COMP_ENABLE | HOSTREG__CALCONFIG1__NERD_COMP_ENABLE | HOSTREG__CALCONFIG1__TRACK_ERROR_COMP_ENABLE | HOSTREG__CALCONFIG1__TAP_COMP_ENABLE | HOSTREG__CALCONFIG1__PALM_ERROR_COMP_ENABLE)
+
+/*--------------------------------------------------------------------------*\
+ PS2 Aux Control Register
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__PS2AUX_CTRL HostReg__8
+# define HOSTREG__PS2AUX_CTRL__CMD_PASSTHRU_ENABLE 0x01
+# define HOSTREG__PS2AUX_CTRL__SP_EXTENDED_MODE 0x02
+# define HOSTREG__PS2AUX_CTRL__GS_DISABLE 0x04
+# define HOSTREG__PS2AUX_CTRL__SP_DISABLE 0x08
+# define HOSTREG__PS2AUX_CTRL__GS_COORDINATE_DISABLE 0x10
+# define HOSTREG__PS2AUX_CTRL__SP_COORDINATE_DISABLE 0x20
+# define HOSTREG__PS2AUX_CTRL__DISABLE_AA00_DETECT 0x40
+# define HOSTREG__PS2AUX_CTRL__AUX_PRESENT 0x80
+#define HOSTREG__PR2AUX_CTRL_DEFVAL 0x00
+
+/*--------------------------------------------------------------------------*\
+ Sample Rate Value
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__SAMPLERATE HostReg__9
+# define HOSTREG__SAMPLERATE__10_SPS 0x0A
+# define HOSTREG__SAMPLERATE__20_SPS 0x14
+# define HOSTREG__SAMPLERATE__40_SPS 0x28
+# define HOSTREG__SAMPLERATE__60_SPS 0x3C
+# define HOSTREG__SAMPLERATE__80_SPS 0x50
+# define HOSTREG__SAMPLERATE__100_SPS 0x64
+# define HOSTREG__SAMPLERATE__200_SPS 0xC8 // 200sps not supported
+ // only for ps2 compatibility
+ // rate set to 100sps
+#define HOSTREG__SAMPLERATE_DEFVAL HOSTREG__SAMPLERATE__100_SPS
+
+/*--------------------------------------------------------------------------*\
+ Z Idle Value
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__ZIDLE HostReg__10
+#define HOSTREG__ZIDLE_DEFVAL 30 // 0x1E
+
+/*--------------------------------------------------------------------------*\
+ Z Scaler Value
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__ZSCALER HostReg__11
+#define HOSTREG__ZSCALER_DEFVAL 8 // 0x08
+
+/*--------------------------------------------------------------------------*\
+ Sleep Interval Value
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__SLEEP_INTERVAL HostReg__12
+#define HOSTREG__SLEEP_INTERVAL_DEFVAL 73 // 0x49
+
+/*--------------------------------------------------------------------------*\
+ Sleep Delay Value
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__SLEEP_DELAY HostReg__13
+#define HOSTREG__SLEEP_DELAY_DEFVAL 39 // 0x27
+
+/*--------------------------------------------------------------------------*\
+ Dynamic EMI Bad Channel Count Thresholds
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__DYNAMIC_EMI_ADJUST_THRESHOLD HostReg__14
+#define HOSTREG__DYNAMIC_EMI_ADJUST_THRESHOLD_DEFVAL 66 // 0x42
+
+/*--------------------------------------------------------------------------*\
+ Packet Registers
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__PACKETBYTE_0 HostReg__18
+#define HOSTREG__PACKETBYTE_1 HostReg__19
+#define HOSTREG__PACKETBYTE_2 HostReg__20
+#define HOSTREG__PACKETBYTE_3 HostReg__21
+#define HOSTREG__PACKETBYTE_4 HostReg__22
+#define HOSTREG__PACKETBYTE_5 HostReg__23
+
+/*--------------------------------------------------------------------------*\
+ Port A GPIO Control
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__PORTA_GPIO_CTRL HostReg__24
+#define HOSTREG__PORTA_GPIO_CTRL_DEFVAL 0xFF
+
+/*--------------------------------------------------------------------------*\
+ Port A GPIO Data
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__PORTA_GPIO_DATA HostReg__25
+#define HOSTREG__PORTA_GPIO_DATA_DEFVAL 0x00
+
+/*--------------------------------------------------------------------------*\
+ Port B GPIO Control And Data
+\*--------------------------------------------------------------------------*/
+
+#define HOSTREG__PORTB_GPIO_CTRL_DATA HostReg__26
+# define HOSTREG__PORTB_GPIO_DATA__PB0 0x01
+# define HOSTREG__PORTB_GPIO_DATA__PB1 0x02
+# define HOSTREG__PORTB_GPIO_DATA__PB2 0x04
+# define HOSTREG__PORTB_GPIO_CTRL__PB0 0x08
+# define HOSTREG__PORTB_GPIO_CTRL__PB1 0x10
+# define HOSTREG__PORTB_GPIO_CTRL__PB2 0x20
+# define HOSTREG__PORTB_GPIO_RSVD_0 0x40
+# define HOSTREG__PORTB_GPIO_READ1_WRITE0 0x80
+#define HOSTREG__PORTB_GPIO_CTRL_DATA_DEFVAL (HOSTREG__PORTB_GPIO_CTRL__PB0 | HOSTREG__PORTB_GPIO_CTRL__PB1 | HOSTREG__PORTB_GPIO_CTRL__PB2)
+
+/*--------------------------------------------------------------------------*\
+ Extended Register Access
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__EXT_REG_AXS_VALUE HostReg__27
+
+#define HOSTREG__EXT_REG_AXS_ADDR_HIGH HostReg__28
+#define HOSTREG__EXT_REG_AXS_ADDR_LOW HostReg__29
+
+#define HOSTREG__EXT_REG_AXS_CTRL HostReg__30
+# define HOSTREG__EREG_AXS__READ 0x01
+# define HOSTREG__EREG_AXS__WRITE 0x02
+# define HOSTREG__EREG_AXS__INC_ADDR_READ 0x04
+# define HOSTREG__EREG_AXS__INC_ADDR_WRITE 0x08
+# define HOSTREG__EREG_AXS__RSVD_3 0x10
+# define HOSTREG__EREG_AXS__RSVD_2 0x20
+# define HOSTREG__EREG_AXS__RSVD_1 0x40
+# define HOSTREG__EREG_AXS__RSVD_0 0x80
+
+#define HOSTREG__EXT_REG_AXS_VALUE_DEFVAL 0x00
+#define HOSTREG__EXT_REG_AXS_ADDR_HIGH_DEFVAL 0x00
+#define HOSTREG__EXT_REG_AXS_ADDR_LOW_DEFVAL 0x00
+#define HOSTREG__EXT_REG_AXS_CTRL_DEFVAL 0x00
+
+/*--------------------------------------------------------------------------*\
+ Product ID
+\*--------------------------------------------------------------------------*/
+#define HOSTREG__PRODUCT_ID HostReg__31
+
+
+
+//Some useful values
+#define I2C_ADDRESS_DEFAULT 0x2A
+#define FIRMWARE_ID 0x07
+#define FIRMWARE_VERSION 0x9D
+
+//Anymeas config options
+//First setting is HostReg 5. This sets toggle frequency (EF) and gain.
+//Gain is upper two bits (0xC0), frequency is lower 6 bits (0x3F)
+#define AnyMeas_AccumBits_ElecFreq HostReg__5
+# define ADCCNFG_ELEC_FREQ 0x3F /* Bit 4, 3, 2, 1, 0 */
+# define ADCCNFG_EF_0 0x02 // 500,000Hz
+# define ADCCNFG_EF_1 0x03 // 444,444Hz
+# define ADCCNFG_EF_2 0x04 // 400,000Hz
+# define ADCCNFG_EF_3 0x05 // 363,636Hz
+# define ADCCNFG_EF_4 0x06 // 333,333Hz
+# define ADCCNFG_EF_5 0x07 // 307,692Hz
+# define ADCCNFG_EF_6 0x09 // 267,000Hz
+# define ADCCNFG_EF_7 0x0B // 235,000Hz
+# define ADCCNFG_ACCUMBITSSELECT 0xC0 /* Bit 7, 6 */
+# define ADCCNFG_ACCBITS_17_14_0 0x00 //This is about 2x gain
+# define ADCCNFG_ACCBITS_17_15_1 0x40 //This is about 1.6x gain
+# define ADCCNFG_ACCBITS_17_2__80 0x80 //This is about 1.3x gain
+# define ADCCNFG_ACCBITS_17_2__C0 0xC0 //This is lowest gain
+//Note, all frequencies above are based on default 500ns aperture. If aperture is shorter the frequencies will be faster and if aperture is longer the frequencies will be slower.
+
+//Next is HostReg 6. This sets the sample length. There are four possible settings to bit length. All other settings are not normally used and should be a 0.
+#define AnyMeas_BitLength HostReg__6
+# define ADCCTRL_BIT_LENGTH 0x03 /* Bit 1, 0 */
+# define ADCCTRL_SAMPLES_32 0x00 //Note: this does not work.
+# define ADCCTRL_SAMPLES_128 0x01
+# define ADCCTRL_SAMPLES_256 0x02
+# define ADCCTRL_SAMPLES_512 0x03
+# define ADCCTRL_ENABLE 0x20 /* Bit 5 */
+# define ADCCTRL_INT_FLAG 0x40 /* Bit 6 */
+# define ADCCTRL_START_BUSY 0x80 /* Bit 7 */
+//The smaller the sample length the faster the measurement but the lower the SNR. For high SNR requirements 512 sample length is recommended. Alternatively, multiple 128 or 256 length measurements could be averaged.
+
+//Next is HostReg 7. This sets the sense mux. Pinnacle has 2 sense lines, Sense N and Sense P1. There is also a Sense P2 but it is not bonded out, it is only internal.
+//Signal on Sense N will be inverted from signal on Sense P1. Other than sign inversion, signal strength should be the same.
+#define AnyMeas_ADC_MuxControl HostReg__7
+# define ADCMUXCTRL_SENSEP1GATE 0x01 //Enables Sense P1. Can be combined with Sense N input or exclusivly Sense P1 alone.
+# define ADCMUXCTRL_SENSEP2GATE 0x02 //Not used.
+# define ADCMUXCTRL_SENSENGATE 0x04 //Enables Sense N. Can be combined with Sense P inputs or exclusivly Sense N alone.
+# define ADCMUXCTRL_REF0GATE 0x08 //This enables the RefCap0. This is a capacitor inside the chip that is roughly 0.25pF. It is also controlled with the toggle and polarity bits so those bits must be set properly as well in order to use it.
+# define ADCMUXCTRL_REF1GATE 0x10 //This enables the RefCap1. This is a capacitor inside the chip that is roughly 0.5pF. It is also controlled with the toggle and polarity bits so those bits must be set properly as well in order to use it.
+# define ADCMUXCTRL_OSCMEASEN 0x80 //this is a test mode for measuring the internal oscillator. It is for IC test only.
+
+//Next is HostReg 8. This contains various ADC config settings that are not likely to be used.
+#define AnyMeas_ADC_Config2 HostReg__8
+# define ADCCNFG2_ADC_CLK_SELECT 0x01 /* Bit 0 */ //If 0 use the standard 8Mhz clock. If 1 use a divide by 2, 4Mhz clock. Only used if extra slow toggle frequencies are required.
+# define ADCCNFG2_EMI_FLAG 0x02 /* Bit 1 */ //EMI flag threshold only used with internal FW. Not valid in anymeas mode.
+# define ADCCNFG2_EMI_FLAG_THRESHOLD_0 0x04 /* Bit 2 */ //EMI flag threshold only used with internal FW. Not valid in anymeas mode.
+# define ADCCNFG2_EMI_FLAG_THRESHOLD_1 0x08 /* Bit 3 */ //EMI flag threshold only used with internal FW. Not valid in anymeas mode.
+# define ADCCNFG2_DSX2_EXTEND 0x10 /* Bit 4 */ //extend one signal on the receive. Could also be helpful in situations where sensor cap is extremely high.
+# define ADCCNFG2_ETOGGLE_DELAY 0x20 /* Bit 5 */ //delay a bit before toggling electrodes. Could be helpful in situations where sensor cap is extremely high.
+
+//Next is HostReg 9. This sets the aperture length. Bottom 4 bits set the aperture width
+#define AnyMeas_ADC_AWidth HostReg__9
+# define ADCAWIDTH_AWIDTHMASK 0x0F
+# define ADCAWIDTH_APERTURE_OPEN 0x00 //does not work
+# define ADCAWIDTH_APERTURE_125NS 0x01 //does not work
+# define ADCAWIDTH_APERTURE_250NS 0x02
+# define ADCAWIDTH_APERTURE_375NS 0x03
+# define ADCAWIDTH_APERTURE_500NS 0x04
+# define ADCAWIDTH_APERTURE_625NS 0x05
+# define ADCAWIDTH_APERTURE_750NS 0x06
+# define ADCAWIDTH_APERTURE_875NS 0x07
+# define ADCAWIDTH_APERTURE_1000NS 0x08
+# define ADCAWIDTH_APERTURE_1125NS 0x09
+# define ADCAWIDTH_APERTURE_1250NS 0x0A
+# define ADCAWIDTH_APERTURE_1375NS 0x0B
+# define ADCAWIDTH_APERTURE_1500NS 0x0C
+# define ADCAWIDTH_APERTURE_1625NS 0x0D
+# define ADCAWIDTH_APERTURE_1750NS 0x0E
+# define ADCAWIDTH_APERTURE_1875NS 0x0F
+# define ADCAWIDTH_AWIDTHPLUSHALF 0x10
+# define ADCAWIDTH_AOPEN 0x20
+# define ADCAWIDTH_W2WAIT 0x40
+
+//next two registers give the high and low bytes to the 16 bit address where Pinnacle will pull the measurement data. Normally these addresses are within the base 32 registers.
+#define AnyMeas_pADCMeasInfoStart_High_Byte HostReg__10
+#define AnyMeas_pADCMeasInfoStart_Low_Byte HostReg__11
+
+//Next is the measurement index, this sets the measurement state machine to the start and should be a 0 at start.
+#define AnyMeas_MeasIndex HostReg__12
+# define ANYMEASSTATE_RESET_START 0x00
+# define ANYMEASSTATE_START_MEASUREMENT 0x01
+# define ANYMEASSTATE_WAIT_FOR_MEASUREMENT_AND_HOST 0x02
+
+//next is the state itself of the measurement, should always be 0.
+#define AnyMeas_State HostReg__13
+
+//next is the number of measurements. Use 0x80 to repeat the single measurement or repeat a number of measurements.
+//0x40 will turn the ADC off after measurements. This will result in longer startup time for a subsequent measurement, but lower idle power draw.
+#define AnyMeas_Control_NumMeas HostReg__14
+# define ANYMEAS_CONTROL__NUM_MEAS_MASK 0x3F
+# define ANYMEAS_CONTROL__ADC_POST_MEAS_PWR 0x40
+# define ANYMEAS_CONTROL__REPEAT 0x80
+
+//These are not used
+#define AnyMeas_pADCMeasInfo_High_Byte HostReg__15
+#define AnyMeas_pADCMeasInfo_Low_Byte HostReg__16
+
+//16 bit result of measurement will be found in these two registers.
+#define AnyMeas_Result_High_Byte HostReg__17
+#define AnyMeas_Result_Low_Byte HostReg__18
+
+// ---------------- Extended Register Assignments ----------------------------
+/*--------------------------------------------------------------------------*\
+ ADC Mux Control
+\*--------------------------------------------------------------------------*/
+#define EXTREG__ADCMUX_CTRL 0x00EB
+# define EXTREG__ADCMUX_CTRL__SNSP_ENABLE 0x01
+# define EXTREG__ADCMUX_CTRL__SNSN_ENABLE 0x04
+
+/*--------------------------------------------------------------------------*\
+ Timer Reload Registers
+\*--------------------------------------------------------------------------*/
+#define EXTREG__PACKET_TIMER_RELOAD 0x019F
+#define EXTREG__TRACK_TIMER_RELOAD 0x019E
+// These two registers should have matching content.
+# define EXTREG__TIMER_RELOAD__300_SPS 0x06
+# define EXTREG__TIMER_RELOAD__200_SPS 0x09
+# define EXTREG__TIMER_RELOAD__100_SPS 0x13
+
+/*--------------------------------------------------------------------------*\
+ Track ADC Config
+\*--------------------------------------------------------------------------*/
+#define EXTREG__TRACK_ADCCONFIG 0x0187
+// ADC-attenuation settings (held in BIT_7 and BIT_6)
+// 1X = most sensitive, 4X = least sensitive
+# define EXTREG__TRACK_ADCCONFIG__ADC_ATTENUATE_MASK 0xC0
+# define EXTREG__TRACK_ADCCONFIG__ADC_ATTENUATE_1X 0x00
+# define EXTREG__TRACK_ADCCONFIG__ADC_ATTENUATE_2X 0x40
+# define EXTREG__TRACK_ADCCONFIG__ADC_ATTENUATE_3X 0x80
+# define EXTREG__TRACK_ADCCONFIG__ADC_ATTENUATE_4X 0xC0
+#define EXTREG__TRACK_ADCCONFIG_DEFVAL 0x4E
+
+
+/*--------------------------------------------------------------------------*\
+ Tune Edge Sensitivity
+\*--------------------------------------------------------------------------*/
+// These registers are not detailed in any publically available documentation
+// Names inferred from debug prints in https://github.com/cirque-corp/Cirque_Pinnacle_1CA027/blob/master/Circular_Trackpad
+#define EXTREG__XAXIS_WIDEZMIN 0x0149
+#define EXTREG__YAXIS_WIDEZMIN 0x0168
+#define EXTREG__XAXIS_WIDEZMIN_DEFVAL 0x06
+#define EXTREG__YAXIS_WIDEZMIN_DEFVAL 0x05
+
+// clang-format on
diff --git a/drivers/sensors/cirque_pinnacle_spi.c b/drivers/sensors/cirque_pinnacle_spi.c
index 34c77df07b..bd980fc863 100644
--- a/drivers/sensors/cirque_pinnacle_spi.c
+++ b/drivers/sensors/cirque_pinnacle_spi.c
@@ -25,7 +25,7 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) {
}
} else {
#ifdef CONSOLE_ENABLE
- dprintf("error right touchpad\n");
+ dprintf("error cirque_pinnacle spi_start read\n");
#endif
touchpad_init = false;
}
@@ -43,7 +43,7 @@ void RAP_Write(uint8_t address, uint8_t data) {
spi_write(data);
} else {
#ifdef CONSOLE_ENABLE
- dprintf("error right touchpad\n");
+ dprintf("error cirque_pinnacle spi_start write\n");
#endif
touchpad_init = false;
}
diff --git a/drivers/sensors/paw3204.c b/drivers/sensors/paw3204.c
new file mode 100644
index 0000000000..a13753dd6f
--- /dev/null
+++ b/drivers/sensors/paw3204.c
@@ -0,0 +1,172 @@
+/* Copyright 2021 Gompa (@Gompa)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// https://github.com/shinoaliceKabocha/choco60_track/tree/master/keymaps/default
+
+#include "paw3204.h"
+#include "wait.h"
+#include "debug.h"
+#include "gpio.h"
+
+#define REG_PID1 0x00
+#define REG_PID2 0x01
+#define REG_STAT 0x02
+#define REG_X 0x03
+#define REG_Y 0x04
+
+#define REG_SETUP 0x06
+#define REG_IMGQUAL 0x07
+#define REG_IMGREC 0x0E
+#define REG_IMGTRASH 0x0D
+
+#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
+
+// CPI values
+enum cpi_values {
+ CPI400, // 0b000
+ CPI500, // 0b001
+ CPI600, // 0b010
+ CPI800, // 0b011
+ CPI1000, // 0b100
+ CPI1200, // 0b101
+ CPI1600, // 0b110
+};
+
+uint8_t paw3204_serial_read(void);
+void paw3204_serial_write(uint8_t reg_addr);
+uint8_t paw3204_read_reg(uint8_t reg_addr);
+void paw3204_write_reg(uint8_t reg_addr, uint8_t data);
+
+void paw3204_init(void) {
+ setPinOutput(PAW3204_SCLK_PIN); // setclockpin to output
+ setPinInputHigh(PAW3204_SDIO_PIN); // set datapin input high
+
+ paw3204_write_reg(REG_SETUP, 0x86); // reset sensor and set 1600cpi
+ wait_us(5);
+
+ paw3204_read_reg(0x00); // read id
+ paw3204_read_reg(0x01); // read id2
+ // PAW3204_write_reg(REG_SETUP,0x06); // dont reset sensor and set cpi 1600
+ paw3204_write_reg(REG_IMGTRASH, 0x32); // write image trashhold
+}
+
+uint8_t paw3204_serial_read(void) {
+ setPinInput(PAW3204_SDIO_PIN);
+ uint8_t byte = 0;
+
+ for (uint8_t i = 0; i < 8; ++i) {
+ writePinLow(PAW3204_SCLK_PIN);
+ wait_us(1);
+
+ byte = (byte << 1) | readPin(PAW3204_SDIO_PIN);
+
+ writePinHigh(PAW3204_SCLK_PIN);
+ wait_us(1);
+ }
+
+ return byte;
+}
+
+void paw3204_serial_write(uint8_t data) {
+ writePinLow(PAW3204_SDIO_PIN);
+ setPinOutput(PAW3204_SDIO_PIN);
+
+ for (int8_t b = 7; b >= 0; b--) {
+ writePinLow(PAW3204_SCLK_PIN);
+ if (data & (1 << b)) {
+ writePinHigh(PAW3204_SDIO_PIN);
+ } else {
+ writePinLow(PAW3204_SDIO_PIN);
+ }
+ writePinHigh(PAW3204_SCLK_PIN);
+ }
+
+ wait_us(4);
+}
+
+report_paw3204_t paw3204_read(void) {
+ report_paw3204_t data = {0};
+
+ data.isMotion = paw3204_read_reg(REG_STAT) & (1 << 7); // check for motion only (bit 7 in field)
+ data.x = (int8_t)paw3204_read_reg(REG_X);
+ data.y = (int8_t)paw3204_read_reg(REG_Y);
+
+ return data;
+}
+
+void paw3204_write_reg(uint8_t reg_addr, uint8_t data) {
+ paw3204_serial_write(0b10000000 | reg_addr);
+ paw3204_serial_write(data);
+}
+
+uint8_t paw3204_read_reg(uint8_t reg_addr) {
+ paw3204_serial_write(reg_addr);
+ wait_us(5);
+ return paw3204_serial_read();
+}
+
+void paw3204_set_cpi(uint16_t cpi) {
+ uint8_t cpival = CPI1000;
+ if (cpi <= 450) {
+ cpival = CPI400;
+ } else if (cpi <= 550) {
+ cpival = CPI500;
+ } else if (cpi <= 700) {
+ cpival = CPI600;
+ } else if (cpi <= 900) {
+ cpival = CPI800;
+ } else if (cpi <= 1100) {
+ cpival = CPI1000;
+ } else if (cpi <= 1400) {
+ cpival = CPI1200;
+ } else if (cpi > 1400) {
+ cpival = CPI1600;
+ }
+ paw3204_write_reg(REG_SETUP, cpival);
+}
+
+uint16_t paw3204_get_cpi(void) {
+ uint16_t cpival = 1000;
+
+ switch (paw3204_read_reg(REG_SETUP) & 0b111) {
+ case CPI400:
+ cpival = 400;
+ break;
+ case CPI500:
+ cpival = 500;
+ break;
+ case CPI600:
+ cpival = 600;
+ break;
+ case CPI800:
+ cpival = 800;
+ break;
+ case CPI1000:
+ cpival = 1000;
+ break;
+ case CPI1200:
+ cpival = 1200;
+ break;
+ case CPI1600:
+ cpival = 1600;
+ break;
+ }
+ return cpival;
+}
+
+uint8_t read_pid_paw3204(void) {
+ return paw3204_read_reg(REG_PID1);
+}
diff --git a/drivers/sensors/paw3204.h b/drivers/sensors/paw3204.h
new file mode 100644
index 0000000000..7f487d90dc
--- /dev/null
+++ b/drivers/sensors/paw3204.h
@@ -0,0 +1,76 @@
+/* Copyright 2021 Gompa (@Gompa)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#ifndef PAW3204_SCLK_PIN
+# ifdef POINTING_DEVICE_SCLK_PIN
+# define PAW3204_SCLK_PIN POINTING_DEVICE_SCLK_PIN
+# else
+# error "No clock pin defined -- missing POINTING_DEVICE_SCLK_PIN or PAW3204_SCLK_PIN"
+# endif
+#endif
+#ifndef PAW3204_SDIO_PIN
+# ifdef POINTING_DEVICE_SDIO_PIN
+# define PAW3204_SDIO_PIN POINTING_DEVICE_SDIO_PIN
+# else
+# error "No data pin defined -- missing POINTING_DEVICE_SDIO_PIN or PAW3204_SDIO_PIN"
+# endif
+#endif
+
+typedef struct {
+ int16_t x;
+ int16_t y;
+ bool isMotion;
+} report_paw3204_t;
+
+/**
+ * @brief Initializes the sensor so it is in a working state and ready to
+ * be polled for data.
+ *
+ * @return true Initialization was a success
+ * @return false Initialization failed, do not proceed operation
+ */
+void paw3204_init(void);
+
+/**
+ * @brief Reads and clears the current delta, and motion register values on the
+ * given sensor.
+ *
+ * @return pmw33xx_report_t Current values of the sensor, if errors occurred all
+ * fields are set to zero
+ */
+
+report_paw3204_t paw3204_read(void);
+/**
+ * @brief Sets the given CPI value the sensor. CPI is often refereed to
+ * as the sensors sensitivity. Values outside of the allowed range are
+ * constrained into legal values.
+ *
+ * @param cpi CPI value to set
+ */
+void paw3204_set_cpi(uint16_t cpi);
+
+/**
+ * @brief Gets the currently set CPI value from the sensor. CPI is often
+ * refereed to as the sensors sensitivity.
+ *
+ * @return uint16_t Current CPI value of the sensor
+ */
+uint16_t paw3204_get_cpi(void);
diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c
index 333e017a06..88a351316b 100644
--- a/drivers/sensors/pimoroni_trackball.c
+++ b/drivers/sensors/pimoroni_trackball.c
@@ -95,16 +95,3 @@ int16_t pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_di
uint16_t magnitude = (scale * offset * offset * precision) >> 7;
return isnegative ? -(int16_t)(magnitude) : (int16_t)(magnitude);
}
-
-void pimoroni_trackball_adapt_values(int8_t* mouse, int16_t* offset) {
- if (*offset > 127) {
- *mouse = 127;
- *offset -= 127;
- } else if (*offset < -127) {
- *mouse = -127;
- *offset += 127;
- } else {
- *mouse = *offset;
- *offset = 0;
- }
-}
diff --git a/drivers/sensors/pimoroni_trackball.h b/drivers/sensors/pimoroni_trackball.h
index e20ee748a7..749f381bbd 100644
--- a/drivers/sensors/pimoroni_trackball.h
+++ b/drivers/sensors/pimoroni_trackball.h
@@ -52,7 +52,6 @@ typedef struct {
void pimoroni_trackball_device_init(void);
void pimoroni_trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white);
int16_t pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_dir, uint8_t scale);
-void pimoroni_trackball_adapt_values(int8_t* mouse, int16_t* offset);
uint16_t pimoroni_trackball_get_cpi(void);
void pimoroni_trackball_set_cpi(uint16_t cpi);
i2c_status_t read_pimoroni_trackball(pimoroni_data_t* data);
diff --git a/drivers/sensors/pmw3360.c b/drivers/sensors/pmw3360.c
index 5f4d17a3f0..2c6d91d588 100644
--- a/drivers/sensors/pmw3360.c
+++ b/drivers/sensors/pmw3360.c
@@ -1,291 +1,294 @@
-/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
- * Copyright 2019 Sunjun Kim
- * Copyright 2020 Ploopy Corporation
- * Copyright 2022 Ulrich Spörlein
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "spi_master.h"
-#include "pmw3360.h"
-#include "wait.h"
-#include "debug.h"
-#include "print.h"
-#include "pmw3360_firmware.h"
-
-// Registers
-// clang-format off
-#define REG_Product_ID 0x00
-#define REG_Revision_ID 0x01
-#define REG_Motion 0x02
-#define REG_Delta_X_L 0x03
-#define REG_Delta_X_H 0x04
-#define REG_Delta_Y_L 0x05
-#define REG_Delta_Y_H 0x06
-#define REG_SQUAL 0x07
-#define REG_Raw_Data_Sum 0x08
-#define REG_Maximum_Raw_data 0x09
-#define REG_Minimum_Raw_data 0x0a
-#define REG_Shutter_Lower 0x0b
-#define REG_Shutter_Upper 0x0c
-#define REG_Control 0x0d
-#define REG_Config1 0x0f
-#define REG_Config2 0x10
-#define REG_Angle_Tune 0x11
-#define REG_Frame_Capture 0x12
-#define REG_SROM_Enable 0x13
-#define REG_Run_Downshift 0x14
-#define REG_Rest1_Rate_Lower 0x15
-#define REG_Rest1_Rate_Upper 0x16
-#define REG_Rest1_Downshift 0x17
-#define REG_Rest2_Rate_Lower 0x18
-#define REG_Rest2_Rate_Upper 0x19
-#define REG_Rest2_Downshift 0x1a
-#define REG_Rest3_Rate_Lower 0x1b
-#define REG_Rest3_Rate_Upper 0x1c
-#define REG_Observation 0x24
-#define REG_Data_Out_Lower 0x25
-#define REG_Data_Out_Upper 0x26
-#define REG_Raw_Data_Dump 0x29
-#define REG_SROM_ID 0x2a
-#define REG_Min_SQ_Run 0x2b
-#define REG_Raw_Data_Threshold 0x2c
-#define REG_Config5 0x2f
-#define REG_Power_Up_Reset 0x3a
-#define REG_Shutdown 0x3b
-#define REG_Inverse_Product_ID 0x3f
-#define REG_LiftCutoff_Tune3 0x41
-#define REG_Angle_Snap 0x42
-#define REG_LiftCutoff_Tune1 0x4a
-#define REG_Motion_Burst 0x50
-#define REG_LiftCutoff_Tune_Timeout 0x58
-#define REG_LiftCutoff_Tune_Min_Length 0x5a
-#define REG_SROM_Load_Burst 0x62
-#define REG_Lift_Config 0x63
-#define REG_Raw_Data_Burst 0x64
-#define REG_LiftCutoff_Tune2 0x65
-
-#define CPI_STEP 100
-// clang-format on
-
-// limits to 0--119, resulting in a CPI range of 100 -- 12000 (as only steps of 100 are possible).
-#ifndef MAX_CPI
-# define MAX_CPI 0x77
-#endif
-
-static const pin_t pins[] = PMW3360_CS_PINS;
-#define NUMBER_OF_SENSORS (sizeof(pins) / sizeof(pin_t))
-
-// per-sensor driver state
-static bool _inBurst[NUMBER_OF_SENSORS] = {0};
-
-#ifdef CONSOLE_ENABLE
-void print_byte(uint8_t byte) {
- dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0'));
-}
-#endif
-#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
-
-bool pmw3360_spi_start(int8_t index) {
- bool status = spi_start(pins[index], PMW3360_SPI_LSBFIRST, PMW3360_SPI_MODE, PMW3360_SPI_DIVISOR);
- // tNCS-SCLK, 120ns
- wait_us(1);
- return status;
-}
-
-spi_status_t pmw3360_write(int8_t index, uint8_t reg_addr, uint8_t data) {
- pmw3360_spi_start(index);
-
- if (reg_addr != REG_Motion_Burst) {
- _inBurst[index] = false;
- }
-
- // send address of the register, with MSBit = 1 to indicate it's a write
- spi_status_t status = spi_write(reg_addr | 0x80);
- status = spi_write(data);
-
- // tSCLK-NCS for write operation is 35us
- wait_us(35);
- spi_stop();
-
- // tSWW/tSWR (=180us) minus tSCLK-NCS. Could be shortened, but it looks like a safe lower bound
- wait_us(145);
- return status;
-}
-
-uint8_t pmw3360_read(int8_t index, uint8_t reg_addr) {
- pmw3360_spi_start(index);
- // send adress of the register, with MSBit = 0 to indicate it's a read
- spi_write(reg_addr & 0x7f);
- // tSRAD (=160us)
- wait_us(160);
- uint8_t data = spi_read();
-
- // tSCLK-NCS for read operation is 120ns
- wait_us(1);
- spi_stop();
-
- // tSRW/tSRR (=20us) minus tSCLK-NCS
- wait_us(19);
- return data;
-}
-
-bool pmw3360_check_signature(int8_t index) {
- uint8_t pid = pmw3360_read(index, REG_Product_ID);
- uint8_t iv_pid = pmw3360_read(index, REG_Inverse_Product_ID);
- uint8_t SROM_ver = pmw3360_read(index, REG_SROM_ID);
- return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04
-}
-
-void pmw3360_upload_firmware(int8_t index) {
- // Datasheet claims we need to disable REST mode first, but during startup
- // it's already disabled and we're not turning it on ...
- // pmw3360_write(index, REG_Config2, 0x00); // disable REST mode
- pmw3360_write(index, REG_SROM_Enable, 0x1d);
-
- wait_ms(10);
-
- pmw3360_write(index, REG_SROM_Enable, 0x18);
-
- pmw3360_spi_start(index);
- spi_write(REG_SROM_Load_Burst | 0x80);
- wait_us(15);
-
- for (uint16_t i = 0; i < FIRMWARE_LENGTH; i++) {
- spi_write(pgm_read_byte(firmware_data + i));
-#ifndef PMW3360_FIRMWARE_UPLOAD_FAST
- wait_us(15);
-#endif
+// Copyright 2022 Stefan Kerkmann (KarlK90)
+// Copyright 2022 Ulrich Spörlein (@uqs)
+// Copyright 2021 Alabastard (@Alabastard-64)
+// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+// Copyright 2019 Sunjun Kim
+// Copyright 2020 Ploopy Corporation
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "pmw33xx_common.h"
+#include "progmem.h"
+
+extern const size_t pmw33xx_number_of_sensors;
+
+uint16_t pmw33xx_get_cpi(uint8_t sensor) {
+ if (sensor >= pmw33xx_number_of_sensors) {
+ return 0;
}
- wait_us(200);
- pmw3360_read(index, REG_SROM_ID);
- pmw3360_write(index, REG_Config2, 0x00);
+ uint8_t cpival = pmw33xx_read(sensor, REG_Config1);
+ return (uint16_t)((cpival + 1) & 0xFF) * PMW33XX_CPI_STEP;
}
-bool pmw3360_init(int8_t index) {
- if (index >= NUMBER_OF_SENSORS) {
- return false;
+void pmw33xx_set_cpi(uint8_t sensor, uint16_t cpi) {
+ if (sensor >= pmw33xx_number_of_sensors) {
+ return;
}
- spi_init();
- // power up, need to first drive NCS high then low.
- // the datasheet does not say for how long, 40us works well in practice.
- pmw3360_spi_start(index);
- wait_us(40);
- spi_stop();
- wait_us(40);
- pmw3360_write(index, REG_Power_Up_Reset, 0x5a);
- wait_ms(50);
-
- // read registers and discard
- pmw3360_read(index, REG_Motion);
- pmw3360_read(index, REG_Delta_X_L);
- pmw3360_read(index, REG_Delta_X_H);
- pmw3360_read(index, REG_Delta_Y_L);
- pmw3360_read(index, REG_Delta_Y_H);
-
- pmw3360_upload_firmware(index);
-
- spi_stop();
-
- wait_ms(10);
- pmw3360_set_cpi(PMW3360_CPI);
-
- wait_ms(1);
-
- pmw3360_write(index, REG_Config2, 0x00);
-
- pmw3360_write(index, REG_Angle_Tune, constrain(ROTATIONAL_TRANSFORM_ANGLE, -127, 127));
-
- pmw3360_write(index, REG_Lift_Config, PMW3360_LIFTOFF_DISTANCE);
-
- bool init_success = pmw3360_check_signature(index);
-#ifdef CONSOLE_ENABLE
- if (init_success) {
- dprintf("pmw3360 signature verified");
- } else {
- dprintf("pmw3360 signature verification failed!");
- }
-#endif
-
- return init_success;
+ uint8_t cpival = CONSTRAIN((cpi / PMW33XX_CPI_STEP) - 1, 0, (PMW33XX_CPI_MAX / PMW33XX_CPI_STEP) - 1U);
+ pmw33xx_write(sensor, REG_Config1, cpival);
}
-// Only support reading the value from sensor #0, no one is using this anyway.
-uint16_t pmw3360_get_cpi(void) {
- uint8_t cpival = pmw3360_read(0, REG_Config1);
- return (uint16_t)((cpival + 1) & 0xFF) * CPI_STEP;
-}
-
-// Write same CPI to all sensors.
-void pmw3360_set_cpi(uint16_t cpi) {
- uint8_t cpival = constrain((cpi / CPI_STEP) - 1, 0, MAX_CPI);
- for (size_t i = 0; i < NUMBER_OF_SENSORS; i++) {
- pmw3360_write(i, REG_Config1, cpival);
- }
-}
+// PID, Inverse PID, SROM version
+const uint8_t pmw33xx_firmware_signature[3] PROGMEM = {0x42, 0xBD, 0x04};
-report_pmw3360_t pmw3360_read_burst(int8_t index) {
- report_pmw3360_t report = {0};
- if (index >= NUMBER_OF_SENSORS) {
- return report;
- }
-
- if (!_inBurst[index]) {
-#ifdef CONSOLE_ENABLE
- dprintf("burst on for index %d", index);
-#endif
- pmw3360_write(index, REG_Motion_Burst, 0x00);
- _inBurst[index] = true;
- }
-
- pmw3360_spi_start(index);
- spi_write(REG_Motion_Burst);
- wait_us(35); // waits for tSRAD_MOTBR
-
- report.motion = spi_read();
- spi_read(); // skip Observation
- // delta registers
- report.dx = spi_read();
- report.mdx = spi_read();
- report.dy = spi_read();
- report.mdy = spi_read();
-
- if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird.
- _inBurst[index] = false;
- }
-
- spi_stop();
-
-#ifdef CONSOLE_ENABLE
- if (debug_mouse) {
- print_byte(report.motion);
- print_byte(report.dx);
- print_byte(report.mdx);
- print_byte(report.dy);
- print_byte(report.mdy);
- dprintf("\n");
- }
-#endif
-
- report.isMotion = (report.motion & 0x80) != 0;
- report.isOnSurface = (report.motion & 0x08) == 0;
- report.dx |= (report.mdx << 8);
- report.dx = report.dx * -1;
- report.dy |= (report.mdy << 8);
- report.dy = report.dy * -1;
-
- return report;
-}
+// Firmware Blob for PMW3360
+// clang-format off
+const uint8_t pmw33xx_firmware_data[PMW33XX_FIRMWARE_LENGTH] PROGMEM = {
+ 0x01, 0x04, 0x8E, 0x96, 0x6E, 0x77, 0x3E, 0xFE, 0x7E, 0x5F, 0x1D, 0xB8, 0xF2, 0x66, 0x4E, 0xFF,
+ 0x5D, 0x19, 0xB0, 0xC2, 0x04, 0x69, 0x54, 0x2A, 0xD6, 0x2E, 0xBF, 0xDD, 0x19, 0xB0, 0xC3, 0xE5,
+ 0x29, 0xB1, 0xE0, 0x23, 0xA5, 0xA9, 0xB1, 0xC1, 0x00, 0x82, 0x67, 0x4C, 0x1A, 0x97, 0x8D, 0x79,
+ 0x51, 0x20, 0xC7, 0x06, 0x8E, 0x7C, 0x7C, 0x7A, 0x76, 0x4F, 0xFD, 0x59, 0x30, 0xE2, 0x46, 0x0E,
+ 0x9E, 0xBE, 0xDF, 0x1D, 0x99, 0x91, 0xA0, 0xA5, 0xA1, 0xA9, 0xD0, 0x22, 0xC6, 0xEF, 0x5C, 0x1B,
+ 0x95, 0x89, 0x90, 0xA2, 0xA7, 0xCC, 0xFB, 0x55, 0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, 0xC1, 0xE1, 0x40, 0x02, 0x67, 0x4C, 0x1A, 0x97, 0x8D, 0x98, 0x93, 0xA4, 0xAB, 0xD4,
+ 0x2A, 0xD6, 0x0F, 0x9C, 0x9B, 0xB4, 0xCB, 0x14, 0xAA, 0xB7, 0xCD, 0xF9, 0x51, 0x20, 0xA3, 0xC4,
+ 0xEB, 0x35, 0xC9, 0xF1, 0x60, 0x42, 0x06, 0x8E, 0x7F, 0x7C, 0x7A, 0x76, 0x6E, 0x3F, 0xFC, 0x7A,
+ 0x76, 0x6E, 0x5E, 0x3E, 0xFE, 0x7E, 0x5F, 0x3C, 0xDB, 0x15, 0x89, 0x71, 0x41, 0xE1, 0x21, 0xC0,
+ 0xE3, 0x44, 0xEB, 0x54, 0x2A, 0xB7, 0xCD, 0xF9, 0x70, 0x62, 0x27, 0xAD, 0xD8, 0x32, 0xC7, 0x0C,
+ 0x7B, 0x74, 0x4B, 0x14, 0xAA, 0xB7, 0xEC, 0x3B, 0xD5, 0x28, 0xD2, 0x07, 0x6D, 0x39, 0xD1, 0x20,
+ 0xC2, 0xE7, 0x4C, 0x1A, 0x97, 0x8D, 0x98, 0xB2, 0xC7, 0x0C, 0x59, 0x28, 0xF3, 0x9B
+};
diff --git a/drivers/sensors/pmw3360.h b/drivers/sensors/pmw3360.h
index 3aa8ed0ed8..8aa70bd427 100644
--- a/drivers/sensors/pmw3360.h
+++ b/drivers/sensors/pmw3360.h
@@ -1,79 +1,73 @@
-/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
- * Copyright 2019 Sunjun Kim
- * Copyright 2020 Ploopy Corporation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+// Copyright 2022 Stefan Kerkmann (KarlK90)
+// Copyright 2022 Ulrich Spörlein (@uqs)
+// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+// Copyright 2019 Sunjun Kim
+// Copyright 2020 Ploopy Corporation
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <stdint.h>
-#ifndef PMW3360_CPI
-# define PMW3360_CPI 1600
+#if !defined(PMW33XX_CPI)
+# define PMW33XX_CPI 1600U
#endif
-#ifndef PMW3360_CLOCK_SPEED
-# define PMW3360_CLOCK_SPEED 2000000
-#endif
-
-#ifndef PMW3360_SPI_LSBFIRST
-# define PMW3360_SPI_LSBFIRST false
-#endif
-
-#ifndef PMW3360_SPI_MODE
-# define PMW3360_SPI_MODE 3
-#endif
-
-#ifndef PMW3360_SPI_DIVISOR
-# ifdef __AVR__
-# define PMW3360_SPI_DIVISOR (F_CPU / PMW3360_CLOCK_SPEED)
-# else
-# define PMW3360_SPI_DIVISOR 64
-# endif
-#endif
-
-#ifndef PMW3360_LIFTOFF_DISTANCE
-# define PMW3360_LIFTOFF_DISTANCE 0x02
-#endif
-
-#ifndef ROTATIONAL_TRANSFORM_ANGLE
-# define ROTATIONAL_TRANSFORM_ANGLE 0x00
-#endif
-
-// Support single and plural spellings
-#ifndef PMW3360_CS_PINS
-# ifndef PMW3360_CS_PIN
-# error "No chip select pin defined -- missing PMW3360_CS_PIN or PMW3360_CS_PINS"
-# else
-# define PMW3360_CS_PINS \
- { PMW3360_CS_PIN }
-# endif
-#endif
+#define PMW33XX_CPI_STEP 100
+#define PMW33XX_CPI_MIN 100
+#define PMW33XX_CPI_MAX 12000
-typedef struct {
- int8_t motion;
- bool isMotion; // True if a motion is detected.
- bool isOnSurface; // True when a chip is on a surface
- int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value)
- int8_t mdx;
- int16_t dy; // displacement on y directions.
- int8_t mdy;
-} report_pmw3360_t;
+#define PMW33XX_FIRMWARE_LENGTH 4094
-bool pmw3360_init(int8_t index);
-uint16_t pmw3360_get_cpi(void);
-void pmw3360_set_cpi(uint16_t cpi);
-/* Reads and clears the current delta values on the sensor */
-report_pmw3360_t pmw3360_read_burst(int8_t index);
+// PMW3360 register addresses
+// clang-format off
+#define REG_Product_ID 0x00
+#define REG_Revision_ID 0x01
+#define REG_Motion 0x02
+#define REG_Delta_X_L 0x03
+#define REG_Delta_X_H 0x04
+#define REG_Delta_Y_L 0x05
+#define REG_Delta_Y_H 0x06
+#define REG_SQUAL 0x07
+#define REG_Raw_Data_Sum 0x08
+#define REG_Maximum_Raw_data 0x09
+#define REG_Minimum_Raw_data 0x0a
+#define REG_Shutter_Lower 0x0b
+#define REG_Shutter_Upper 0x0c
+#define REG_Control 0x0d
+#define REG_Config1 0x0f
+#define REG_Config2 0x10
+#define REG_Angle_Tune 0x11
+#define REG_Frame_Capture 0x12
+#define REG_SROM_Enable 0x13
+#define REG_Run_Downshift 0x14
+#define REG_Rest1_Rate_Lower 0x15
+#define REG_Rest1_Rate_Upper 0x16
+#define REG_Rest1_Downshift 0x17
+#define REG_Rest2_Rate_Lower 0x18
+#define REG_Rest2_Rate_Upper 0x19
+#define REG_Rest2_Downshift 0x1a
+#define REG_Rest3_Rate_Lower 0x1b
+#define REG_Rest3_Rate_Upper 0x1c
+#define REG_Observation 0x24
+#define REG_Data_Out_Lower 0x25
+#define REG_Data_Out_Upper 0x26
+#define REG_Raw_Data_Dump 0x29
+#define REG_SROM_ID 0x2a
+#define REG_Min_SQ_Run 0x2b
+#define REG_Raw_Data_Threshold 0x2c
+#define REG_Config5 0x2f
+#define REG_Power_Up_Reset 0x3a
+#define REG_Shutdown 0x3b
+#define REG_Inverse_Product_ID 0x3f
+#define REG_LiftCutoff_Tune3 0x41
+#define REG_Angle_Snap 0x42
+#define REG_LiftCutoff_Tune1 0x4a
+#define REG_Motion_Burst 0x50
+#define REG_LiftCutoff_Tune_Timeout 0x58
+#define REG_LiftCutoff_Tune_Min_Length 0x5a
+#define REG_SROM_Load_Burst 0x62
+#define REG_Lift_Config 0x63
+#define REG_Raw_Data_Burst 0x64
+#define REG_LiftCutoff_Tune2 0x65
+// clang-format on
diff --git a/drivers/sensors/pmw3360_firmware.h b/drivers/sensors/pmw3360_firmware.h
deleted file mode 100644
index ed9fda5a75..0000000000
--- a/drivers/sensors/pmw3360_firmware.h
+++ /dev/null
@@ -1,288 +0,0 @@
-/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
- * Copyright 2019 Sunjun Kim
- * Copyright 2020 Ploopy Corporation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include "progmem.h"
-
-// PID, Inverse PID, SROM version
-const uint8_t firmware_signature[] PROGMEM = {0x42, 0xBD, 0x04};
-
-#define FIRMWARE_LENGTH 4094
-
-// Firmware Blob foor PMW3360
-
-// clang-format off
-const uint8_t firmware_data[FIRMWARE_LENGTH] PROGMEM = {
- 0x01, 0x04, 0x8E, 0x96, 0x6E, 0x77, 0x3E, 0xFE, 0x7E, 0x5F, 0x1D, 0xB8, 0xF2, 0x66, 0x4E, 0xFF,
- 0x5D, 0x19, 0xB0, 0xC2, 0x04, 0x69, 0x54, 0x2A, 0xD6, 0x2E, 0xBF, 0xDD, 0x19, 0xB0, 0xC3, 0xE5,
- 0x29, 0xB1, 0xE0, 0x23, 0xA5, 0xA9, 0xB1, 0xC1, 0x00, 0x82, 0x67, 0x4C, 0x1A, 0x97, 0x8D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C1, 0xE1, 0x40, 0x02, 0x67, 0x4C, 0x1A, 0x97, 0x8D, 0x98, 0x93, 0xA4, 0xAB, 0xD4,
- 0x2A, 0xD6, 0x0F, 0x9C, 0x9B, 0xB4, 0xCB, 0x14, 0xAA, 0xB7, 0xCD, 0xF9, 0x51, 0x20, 0xA3, 0xC4,
- 0xEB, 0x35, 0xC9, 0xF1, 0x60, 0x42, 0x06, 0x8E, 0x7F, 0x7C, 0x7A, 0x76, 0x6E, 0x3F, 0xFC, 0x7A,
- 0x76, 0x6E, 0x5E, 0x3E, 0xFE, 0x7E, 0x5F, 0x3C, 0xDB, 0x15, 0x89, 0x71, 0x41, 0xE1, 0x21, 0xC0,
- 0xE3, 0x44, 0xEB, 0x54, 0x2A, 0xB7, 0xCD, 0xF9, 0x70, 0x62, 0x27, 0xAD, 0xD8, 0x32, 0xC7, 0x0C,
- 0x7B, 0x74, 0x4B, 0x14, 0xAA, 0xB7, 0xEC, 0x3B, 0xD5, 0x28, 0xD2, 0x07, 0x6D, 0x39, 0xD1, 0x20,
- 0xC2, 0xE7, 0x4C, 0x1A, 0x97, 0x8D, 0x98, 0xB2, 0xC7, 0x0C, 0x59, 0x28, 0xF3, 0x9B
-};
diff --git a/drivers/sensors/pmw3389.c b/drivers/sensors/pmw3389.c
index 828dafa134..cba94d6c65 100644
--- a/drivers/sensors/pmw3389.c
+++ b/drivers/sensors/pmw3389.c
@@ -1,294 +1,314 @@
-/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
- * Copyright 2019 Sunjun Kim
- * Copyright 2020 Ploopy Corporation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+// Copyright 2022 Stefan Kerkmann (KarlK90)
+// Copyright 2021 Alabastard (@Alabastard-64)
+// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+// Copyright 2019 Sunjun Kim
+// Copyright 2020 Ploopy Corporation
+// SPDX-License-Identifier: GPL-2.0-or-later
-#include "spi_master.h"
-#include "pmw3389.h"
-#include "wait.h"
-#include "debug.h"
-#include "print.h"
-#include "pmw3389_firmware.h"
+#include "pmw33xx_common.h"
+#include "progmem.h"
-// Registers
-// clang-format off
-#define REG_Product_ID 0x00
-#define REG_Revision_ID 0x01
-#define REG_Motion 0x02
-#define REG_Delta_X_L 0x03
-#define REG_Delta_X_H 0x04
-#define REG_Delta_Y_L 0x05
-#define REG_Delta_Y_H 0x06
-#define REG_SQUAL 0x07
-#define REG_RawData_Sum 0x08
-#define REG_Maximum_RawData 0x09
-#define REG_Minimum_RawData 0x0a
-#define REG_Shutter_Lower 0x0b
-#define REG_Shutter_Upper 0x0c
-#define REG_Ripple_Control 0x0d
-#define REG_Resolution_L 0x0e
-#define REG_Resolution_H 0x0f
-#define REG_Config2 0x10
-#define REG_Angle_Tune 0x11
-#define REG_Frame_Capture 0x12
-#define REG_SROM_Enable 0x13
-#define REG_Run_Downshift 0x14
-#define REG_Rest1_Rate_Lower 0x15
-#define REG_Rest1_Rate_Upper 0x16
-#define REG_Rest1_Downshift 0x17
-#define REG_Rest2_Rate_Lower 0x18
-#define REG_Rest2_Rate_Upper 0x19
-#define REG_Rest2_Downshift 0x1a
-#define REG_Rest3_Rate_Lower 0x1b
-#define REG_Rest3_Rate_Upper 0x1c
-#define REG_Observation 0x24
-#define REG_Data_Out_Lower 0x25
-#define REG_Data_Out_Upper 0x26
-#define REG_SROM_ID 0x2a
-#define REG_Min_SQ_Run 0x2b
-#define REG_RawData_Threshold 0x2c
-#define REG_Control2 0x2d
-#define REG_Config5_L 0x2e
-#define REG_Config5_H 0x2f
-#define REG_Power_Up_Reset 0X3a
-#define REG_Shutdown 0x3b
-#define REG_Inverse_Product_ID 0x3f
-#define REG_LiftCutoff_Cal3 0x41
-#define REG_Angle_Snap 0x42
-#define REG_LiftCutoff_Cal1 0x4a
-#define REG_Motion_Burst 0x50
-#define REG_SROM_Load_Burst 0x62
-#define REG_Lift_Config 0x63
-#define REG_RawData_Burst 0x64
-#define REG_LiftCutoff_Cal2 0x65
-#define REG_LiftCutoff_Cal_Timeout 0x71
-#define REG_LiftCutoff_Cal_Min_Length 0x72
-#define REG_PWM_Period_Cnt 0x73
-#define REG_PWM_Width_Cnt 0x74
-
-#define CPI_STEP 50
-// clang-format on
-
-// limits to 0--319, resulting in a CPI range of 50 -- 16000 (as only steps of 50 are possible).
-#ifndef MAX_CPI
-# define MAX_CPI 0x013f
-#endif
-
-bool _inBurst = false;
-
-#ifdef CONSOLE_ENABLE
-void print_byte(uint8_t byte) {
- dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0'));
-}
-#endif
-#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
-
-bool pmw3389_spi_start(void) {
- bool status = spi_start(PMW3389_CS_PIN, PMW3389_SPI_LSBFIRST, PMW3389_SPI_MODE, PMW3389_SPI_DIVISOR);
- // tNCS-SCLK, 120ns
- wait_us(1);
- return status;
-}
-
-spi_status_t pmw3389_write(uint8_t reg_addr, uint8_t data) {
- pmw3389_spi_start();
-
- if (reg_addr != REG_Motion_Burst) {
- _inBurst = false;
- }
-
- // send address of the register, with MSBit = 1 to indicate it's a write
- spi_status_t status = spi_write(reg_addr | 0x80);
- status = spi_write(data);
-
- // tSCLK-NCS for write operation is 35 us
- wait_us(35);
- spi_stop();
-
- // tSWW/tSWR (=180us) minus tSCLK-NCS. Could be shortened, but is looks like a safe lower bound
- wait_us(145);
- return status;
-}
-
-uint8_t pmw3389_read(uint8_t reg_addr) {
- pmw3389_spi_start();
- // send adress of the register, with MSBit = 0 to indicate it's a read
- spi_write(reg_addr & 0x7f);
- // tSRAD (=160us)
- wait_us(160);
- uint8_t data = spi_read();
-
- // tSCLK-NCS, 120ns
- wait_us(1);
- spi_stop();
-
- // tSRW/tSRR (=20us) minus tSCLK-NCS
- wait_us(19);
- return data;
-}
-
-bool pmw3389_init(void) {
- setPinOutput(PMW3389_CS_PIN);
-
- spi_init();
- _inBurst = false;
-
- spi_stop();
- pmw3389_spi_start();
- spi_stop();
-
- pmw3389_write(REG_Shutdown, 0xb6); // Shutdown first
- wait_ms(300);
-
- pmw3389_spi_start();
- wait_us(40);
- spi_stop();
- wait_us(40);
-
- // power up, need to first drive NCS high then low, see above.
- pmw3389_write(REG_Power_Up_Reset, 0x5a);
- wait_ms(50);
-
- // read registers and discard
- pmw3389_read(REG_Motion);
- pmw3389_read(REG_Delta_X_L);
- pmw3389_read(REG_Delta_X_H);
- pmw3389_read(REG_Delta_Y_L);
- pmw3389_read(REG_Delta_Y_H);
-
- pmw3389_upload_firmware();
-
- spi_stop();
+extern const size_t pmw33xx_number_of_sensors;
- wait_ms(10);
- pmw3389_set_cpi(PMW3389_CPI);
-
- wait_ms(1);
-
- pmw3389_write(REG_Config2, 0x00);
-
- pmw3389_write(REG_Angle_Tune, constrain(ROTATIONAL_TRANSFORM_ANGLE, -127, 127));
-
- pmw3389_write(REG_Lift_Config, PMW3389_LIFTOFF_DISTANCE);
-
- bool init_success = pmw3389_check_signature();
-#ifdef CONSOLE_ENABLE
- if (init_success) {
- dprintf("pmw3389 signature verified");
- } else {
- dprintf("pmw3389 signature verification failed!");
+uint16_t pmw33xx_get_cpi(uint8_t sensor) {
+ if (sensor >= pmw33xx_number_of_sensors) {
+ return 0;
}
-#endif
-
- writePinLow(PMW3389_CS_PIN);
- return init_success;
+ uint16_t cpival = (pmw33xx_read(sensor, REG_Resolution_H) << 8) | pmw33xx_read(sensor, REG_Resolution_L);
+ return (uint16_t)((cpival + 1) & 0xFFFF) * PMW33XX_CPI_STEP;
}
-void pmw3389_upload_firmware(void) {
- // Datasheet claims we need to disable REST mode first, but during startup
- // it's already disabled and we're not turning it on ...
- // pmw3389_write(REG_Config2, 0x00); // disable REST mode
- pmw3389_write(REG_SROM_Enable, 0x1d);
-
- wait_ms(10);
-
- pmw3389_write(REG_SROM_Enable, 0x18);
-
- pmw3389_spi_start();
- spi_write(REG_SROM_Load_Burst | 0x80);
- wait_us(15);
-
- for (uint16_t i = 0; i < FIRMWARE_LENGTH; i++) {
- spi_write(pgm_read_byte(firmware_data + i));
-#ifndef PMW3389_FIRMWARE_UPLOAD_FAST
- wait_us(15);
-#endif
+void pmw33xx_set_cpi(uint8_t sensor, uint16_t cpi) {
+ if (sensor >= pmw33xx_number_of_sensors) {
+ return;
}
- wait_us(200);
-
- pmw3389_read(REG_SROM_ID);
- pmw3389_write(REG_Config2, 0x00);
-}
-
-bool pmw3389_check_signature(void) {
- uint8_t pid = pmw3389_read(REG_Product_ID);
- uint8_t iv_pid = pmw3389_read(REG_Inverse_Product_ID);
- uint8_t SROM_ver = pmw3389_read(REG_SROM_ID);
- return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04
-}
-uint16_t pmw3389_get_cpi(void) {
- uint16_t cpival = (pmw3389_read(REG_Resolution_H) << 8) | pmw3389_read(REG_Resolution_L);
- return (uint16_t)((cpival + 1) & 0xffff) * CPI_STEP;
-}
-
-void pmw3389_set_cpi(uint16_t cpi) {
- uint16_t cpival = constrain((cpi / CPI_STEP) - 1, 0, MAX_CPI);
+ uint16_t cpival = CONSTRAIN((cpi / PMW33XX_CPI_STEP) - 1, 0, (PMW33XX_CPI_MAX / PMW33XX_CPI_STEP) - 1U);
// Sets upper byte first for more consistent setting of cpi
- pmw3389_write(REG_Resolution_H, (cpival >> 8) & 0xff);
- pmw3389_write(REG_Resolution_L, cpival & 0xff);
+ pmw33xx_write(sensor, REG_Resolution_H, (cpival >> 8) & 0xFF);
+ pmw33xx_write(sensor, REG_Resolution_L, cpival & 0xFF);
}
-report_pmw3389_t pmw3389_read_burst(void) {
- report_pmw3389_t report = {0};
-
- if (!_inBurst) {
-#ifdef CONSOLE_ENABLE
- dprintf("burst on");
-#endif
- pmw3389_write(REG_Motion_Burst, 0x00);
- _inBurst = true;
- }
-
- pmw3389_spi_start();
- spi_write(REG_Motion_Burst);
- wait_us(35); // waits for tSRAD_MOTBR
-
- report.motion = spi_read();
- spi_read(); // skip Observation
- // delta registers
- report.dx = spi_read();
- report.mdx = spi_read();
- report.dy = spi_read();
- report.mdy = spi_read();
-
- if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird.
- _inBurst = false;
- }
-
- spi_stop();
-
-#ifdef CONSOLE_ENABLE
- if (debug_mouse) {
- print_byte(report.motion);
- print_byte(report.dx);
- print_byte(report.mdx);
- print_byte(report.dy);
- print_byte(report.mdy);
- dprintf("\n");
- }
-#endif
+// PID, Inverse PID, SROM version
+const uint8_t pmw33xx_firmware_signature[3] PROGMEM = {0x42, 0xBD, 0x04};
- report.isMotion = (report.motion & 0x80) != 0;
- report.isOnSurface = (report.motion & 0x08) == 0;
- report.dx |= (report.mdx << 8);
- report.dx = report.dx * -1;
- report.dy |= (report.mdy << 8);
- report.dy = report.dy * -1;
+// Firmware Blob for PMW3389
+// clang-format off
+const uint8_t pmw33xx_firmware_data[PMW33XX_FIRMWARE_LENGTH] PROGMEM = {
+ 0x01, 0xe8, 0xba, 0x26, 0x0b, 0xb2, 0xbe, 0xfe, 0x7e, 0x5f, 0x3c, 0xdb, 0x15, 0xa8, 0xb3,
+ 0xe4, 0x2b, 0xb5, 0xe8, 0x53, 0x07, 0x6d, 0x3b, 0xd1, 0x20, 0xc2, 0x06, 0x6f, 0x3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4, 0xcb, 0x14, 0x8b, 0x94, 0xaa, 0xd6, 0x2e, 0xbf, 0xdd,
+ 0x19, 0xb0, 0xe2, 0x46, 0x0e, 0x7f, 0x7c, 0x5b, 0x15, 0x89, 0x90, 0x83, 0x84, 0x6b, 0x54,
+ 0x0b, 0x75, 0x68, 0x52, 0x07, 0x6d, 0x58, 0x32, 0xc7, 0xed, 0x58, 0x32, 0xc7, 0xed, 0x58,
+ 0x32, 0xe6, 0x4e, 0xff, 0x7c, 0x7a, 0x76, 0x6e, 0x3f, 0xdd, 0x38, 0xd3, 0x05, 0x88, 0x92,
+ 0xa6, 0xaf, 0xdc, 0x1b, 0xb4, 0xcb, 0xf5, 0x68, 0x52, 0x07, 0x8c, 0x7b, 0x55, 0x09, 0x90,
+ 0x83, 0x84, 0x6b, 0x54, 0x2a, 0xb7, 0xec, 0x3b, 0xd5, 0x09, 0x90, 0xa2, 0xc6, 0x0e, 0x7f,
+ 0x7c, 0x7a, 0x57, 0x0d, 0x98, 0xb2, 0xc7, 0xed, 0x58, 0x32, 0xc7, 0x0c, 0x7b, 0x74, 0x4b,
+ 0x14, 0x8b, 0x94, 0xaa, 0xb7, 0xcd, 0x18, 0x93, 0xa4, 0xca, 0x16, 0xae, 0xbf, 0xdd, 0x19,
+ 0xb0, 0xe2, 0x46, 0x0e, 0x7f, 0x5d, 0x19, 0x91, 0x81, 0x80, 0x63, 0x44, 0xeb, 0x35, 0xc9,
+ 0x10, 0x83, 0x65, 0x48, 0x12, 0xa6, 0xce, 0x1e, 0x9f, 0xbc, 0xdb, 0x15, 0x89, 0x71, 0x60,
+ 0x23, 0xc4, 0xeb, 0x54, 0x2a, 0xb7, 0xec, 0x5a, 0x36, 0xcf, 0x81, 0x10, 0xac, 0x74
+};
- return report;
-}
+// clang-format off
diff --git a/drivers/sensors/pmw3389.h b/drivers/sensors/pmw3389.h
index db4a763fe3..fafd1e2046 100644
--- a/drivers/sensors/pmw3389.h
+++ b/drivers/sensors/pmw3389.h
@@ -1,76 +1,77 @@
-/* Copyright 2021 Alabastard (@Alabastard-64)
- * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
- * Copyright 2019 Sunjun Kim
- * Copyright 2020 Ploopy Corporation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+// Copyright 2022 Stefan Kerkmann (KarlK90)
+// Copyright 2021 Alabastard (@Alabastard-64)
+// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+// Copyright 2019 Sunjun Kim
+// Copyright 2020 Ploopy Corporation
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <stdint.h>
-#ifndef PMW3389_CPI
-# define PMW3389_CPI 2000
+#if !defined(PMW33XX_CPI)
+# define PMW33XX_CPI 2000
#endif
-#ifndef PMW3389_CLOCK_SPEED
-# define PMW3389_CLOCK_SPEED 2000000
-#endif
-
-#ifndef PMW3389_SPI_LSBFIRST
-# define PMW3389_SPI_LSBFIRST false
-#endif
-
-#ifndef PMW3389_SPI_MODE
-# define PMW3389_SPI_MODE 3
-#endif
-
-#ifndef PMW3389_SPI_DIVISOR
-# ifdef __AVR__
-# define PMW3389_SPI_DIVISOR (F_CPU / PMW3389_CLOCK_SPEED)
-# else
-# define PMW3389_SPI_DIVISOR 64
-# endif
-#endif
-
-#ifndef PMW3389_LIFTOFF_DISTANCE
-# define PMW3389_LIFTOFF_DISTANCE 0x02
-#endif
-
-#ifndef ROTATIONAL_TRANSFORM_ANGLE
-# define ROTATIONAL_TRANSFORM_ANGLE 0x00
-#endif
-
-#ifndef PMW3389_CS_PIN
-# error "No chip select pin defined -- missing PMW3389_CS_PIN"
-#endif
+#define PMW33XX_CPI_STEP 50
+#define PMW33XX_CPI_MIN 50
+#define PMW33XX_CPI_MAX 16000
-typedef struct {
- int8_t motion;
- bool isMotion; // True if a motion is detected.
- bool isOnSurface; // True when a chip is on a surface
- int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value)
- int8_t mdx;
- int16_t dy; // displacement on y directions.
- int8_t mdy;
-} report_pmw3389_t;
+#define PMW33XX_FIRMWARE_LENGTH 4094
-bool pmw3389_init(void);
-void pmw3389_upload_firmware(void);
-bool pmw3389_check_signature(void);
-uint16_t pmw3389_get_cpi(void);
-void pmw3389_set_cpi(uint16_t cpi);
-/* Reads and clears the current delta values on the sensor */
-report_pmw3389_t pmw3389_read_burst(void);
+// PMW3389 register addresses
+// clang-format off
+#define REG_Product_ID 0x00
+#define REG_Revision_ID 0x01
+#define REG_Motion 0x02
+#define REG_Delta_X_L 0x03
+#define REG_Delta_X_H 0x04
+#define REG_Delta_Y_L 0x05
+#define REG_Delta_Y_H 0x06
+#define REG_SQUAL 0x07
+#define REG_RawData_Sum 0x08
+#define REG_Maximum_RawData 0x09
+#define REG_Minimum_RawData 0x0a
+#define REG_Shutter_Lower 0x0b
+#define REG_Shutter_Upper 0x0c
+#define REG_Ripple_Control 0x0d
+#define REG_Resolution_L 0x0e
+#define REG_Resolution_H 0x0f
+#define REG_Config2 0x10
+#define REG_Angle_Tune 0x11
+#define REG_Frame_Capture 0x12
+#define REG_SROM_Enable 0x13
+#define REG_Run_Downshift 0x14
+#define REG_Rest1_Rate_Lower 0x15
+#define REG_Rest1_Rate_Upper 0x16
+#define REG_Rest1_Downshift 0x17
+#define REG_Rest2_Rate_Lower 0x18
+#define REG_Rest2_Rate_Upper 0x19
+#define REG_Rest2_Downshift 0x1a
+#define REG_Rest3_Rate_Lower 0x1b
+#define REG_Rest3_Rate_Upper 0x1c
+#define REG_Observation 0x24
+#define REG_Data_Out_Lower 0x25
+#define REG_Data_Out_Upper 0x26
+#define REG_SROM_ID 0x2a
+#define REG_Min_SQ_Run 0x2b
+#define REG_RawData_Threshold 0x2c
+#define REG_Control2 0x2d
+#define REG_Config5_L 0x2e
+#define REG_Config5_H 0x2f
+#define REG_Power_Up_Reset 0X3a
+#define REG_Shutdown 0x3b
+#define REG_Inverse_Product_ID 0x3f
+#define REG_LiftCutoff_Cal3 0x41
+#define REG_Angle_Snap 0x42
+#define REG_LiftCutoff_Cal1 0x4a
+#define REG_Motion_Burst 0x50
+#define REG_SROM_Load_Burst 0x62
+#define REG_Lift_Config 0x63
+#define REG_RawData_Burst 0x64
+#define REG_LiftCutoff_Cal2 0x65
+#define REG_LiftCutoff_Cal_Timeout 0x71
+#define REG_LiftCutoff_Cal_Min_Length 0x72
+#define REG_PWM_Period_Cnt 0x73
+#define REG_PWM_Width_Cnt 0x74
+// clang-format on
diff --git a/drivers/sensors/pmw3389_firmware.h b/drivers/sensors/pmw3389_firmware.h
deleted file mode 100644
index cd9638b605..0000000000
--- a/drivers/sensors/pmw3389_firmware.h
+++ /dev/null
@@ -1,307 +0,0 @@
-/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
- * Copyright 2019 Sunjun Kim
- * Copyright 2020 Ploopy Corporation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include "progmem.h"
-
-// PID, Inverse PID, SROM version
-const uint8_t firmware_signature[] PROGMEM = {0x42, 0xBD, 0x04};
-
-#define FIRMWARE_LENGTH 4094
-
-// Firmware Blob for PMW3389
-
-//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d,
- 0x19, 0xb0, 0xe2, 0x46, 0x0e, 0x7f, 0x7c, 0x5b, 0x15, 0x89, 0x90, 0x83, 0x84, 0x6b, 0x54,
- 0x0b, 0x75, 0x68, 0x52, 0x07, 0x6d, 0x58, 0x32, 0xc7, 0xed, 0x58, 0x32, 0xc7, 0xed, 0x58,
- 0x32, 0xe6, 0x4e, 0xff, 0x7c, 0x7a, 0x76, 0x6e, 0x3f, 0xdd, 0x38, 0xd3, 0x05, 0x88, 0x92,
- 0xa6, 0xaf, 0xdc, 0x1b, 0xb4, 0xcb, 0xf5, 0x68, 0x52, 0x07, 0x8c, 0x7b, 0x55, 0x09, 0x90,
- 0x83, 0x84, 0x6b, 0x54, 0x2a, 0xb7, 0xec, 0x3b, 0xd5, 0x09, 0x90, 0xa2, 0xc6, 0x0e, 0x7f,
- 0x7c, 0x7a, 0x57, 0x0d, 0x98, 0xb2, 0xc7, 0xed, 0x58, 0x32, 0xc7, 0x0c, 0x7b, 0x74, 0x4b,
- 0x14, 0x8b, 0x94, 0xaa, 0xb7, 0xcd, 0x18, 0x93, 0xa4, 0xca, 0x16, 0xae, 0xbf, 0xdd, 0x19,
- 0xb0, 0xe2, 0x46, 0x0e, 0x7f, 0x5d, 0x19, 0x91, 0x81, 0x80, 0x63, 0x44, 0xeb, 0x35, 0xc9,
- 0x10, 0x83, 0x65, 0x48, 0x12, 0xa6, 0xce, 0x1e, 0x9f, 0xbc, 0xdb, 0x15, 0x89, 0x71, 0x60,
- 0x23, 0xc4, 0xeb, 0x54, 0x2a, 0xb7, 0xec, 0x5a, 0x36, 0xcf, 0x81, 0x10, 0xac, 0x74
-};
-
-// clang-format off
diff --git a/drivers/sensors/pmw33xx_common.c b/drivers/sensors/pmw33xx_common.c
new file mode 100644
index 0000000000..13164cb150
--- /dev/null
+++ b/drivers/sensors/pmw33xx_common.c
@@ -0,0 +1,219 @@
+// Copyright 2022 Daniel Kao (dkao)
+// Copyright 2022 Stefan Kerkmann (KarlK90)
+// Copyright 2022 Ulrich Spörlein (@uqs)
+// Copyright 2021 Alabastard (@Alabastard-64)
+// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+// Copyright 2019 Sunjun Kim
+// Copyright 2020 Ploopy Corporation
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "debug.h"
+#include "pmw33xx_common.h"
+#include "print.h"
+#include "string.h"
+#include "wait.h"
+#include "spi_master.h"
+#include "progmem.h"
+
+extern const uint8_t pmw33xx_firmware_data[PMW33XX_FIRMWARE_LENGTH] PROGMEM;
+extern const uint8_t pmw33xx_firmware_signature[3] PROGMEM;
+
+static const pin_t cs_pins[] = PMW33XX_CS_PINS;
+static bool in_burst[sizeof(cs_pins) / sizeof(pin_t)] = {0};
+
+const size_t pmw33xx_number_of_sensors = sizeof(cs_pins) / sizeof(pin_t);
+
+bool __attribute__((cold)) pmw33xx_upload_firmware(uint8_t sensor);
+bool __attribute__((cold)) pmw33xx_check_signature(uint8_t sensor);
+
+void pmw33xx_set_cpi_all_sensors(uint16_t cpi) {
+ for (uint8_t sensor = 0; sensor < pmw33xx_number_of_sensors; sensor++) {
+ pmw33xx_set_cpi(sensor, cpi);
+ }
+}
+
+bool pmw33xx_spi_start(uint8_t sensor) {
+ if (!spi_start(cs_pins[sensor], false, 3, PMW33XX_SPI_DIVISOR)) {
+ spi_stop();
+ return false;
+ }
+ // tNCS-SCLK, 10ns
+ wait_us(1);
+ return true;
+}
+
+bool pmw33xx_write(uint8_t sensor, uint8_t reg_addr, uint8_t data) {
+ if (!pmw33xx_spi_start(sensor)) {
+ return false;
+ }
+
+ if (reg_addr != REG_Motion_Burst) {
+ in_burst[sensor] = false;
+ }
+
+ // send address of the register, with MSBit = 1 to indicate it's a write
+ uint8_t command[2] = {reg_addr | 0x80, data};
+ if (spi_transmit(command, sizeof(command)) != SPI_STATUS_SUCCESS) {
+ return false;
+ }
+
+ // tSCLK-NCS for write operation is 35us
+ wait_us(35);
+ spi_stop();
+
+ // tSWW/tSWR (=18us) minus tSCLK-NCS. Could be shortened, but it looks like
+ // a safe lower bound
+ wait_us(145);
+ return true;
+}
+
+uint8_t pmw33xx_read(uint8_t sensor, uint8_t reg_addr) {
+ if (!pmw33xx_spi_start(sensor)) {
+ return 0;
+ }
+
+ // send adress of the register, with MSBit = 0 to indicate it's a read
+ spi_write(reg_addr & 0x7f);
+ // tSRAD (=160us)
+ wait_us(160);
+ uint8_t data = spi_read();
+
+ // tSCLK-NCS, 120ns
+ wait_us(1);
+ spi_stop();
+
+ // tSRW/tSRR (=20us) mins tSCLK-NCS
+ wait_us(19);
+ return data;
+}
+
+bool pmw33xx_check_signature(uint8_t sensor) {
+ uint8_t signature_dump[3] = {
+ pmw33xx_read(sensor, REG_Product_ID),
+ pmw33xx_read(sensor, REG_Inverse_Product_ID),
+ pmw33xx_read(sensor, REG_SROM_ID),
+ };
+
+ return memcmp(pmw33xx_firmware_signature, signature_dump, sizeof(signature_dump)) == 0;
+}
+
+bool pmw33xx_upload_firmware(uint8_t sensor) {
+ // Datasheet claims we need to disable REST mode first, but during startup
+ // it's already disabled and we're not turning it on ...
+ // pmw33xx_write(REG_Config2, 0x00); // disable REST mode
+ if (!pmw33xx_write(sensor, REG_SROM_Enable, 0x1d)) {
+ return false;
+ }
+ wait_ms(10);
+ pmw33xx_write(sensor, REG_SROM_Enable, 0x18);
+
+ if (!pmw33xx_spi_start(sensor)) {
+ return false;
+ }
+
+ spi_write(REG_SROM_Load_Burst | 0x80);
+ wait_us(15);
+
+ for (size_t i = 0; i < PMW33XX_FIRMWARE_LENGTH; i++) {
+ spi_write(pgm_read_byte(pmw33xx_firmware_data + i));
+ wait_us(15);
+ }
+ wait_us(200);
+
+ pmw33xx_read(sensor, REG_SROM_ID);
+ pmw33xx_write(sensor, REG_Config2, 0x00);
+
+ return true;
+}
+
+bool pmw33xx_init(uint8_t sensor) {
+ if (sensor >= pmw33xx_number_of_sensors) {
+ return false;
+ }
+ spi_init();
+
+ // power up, need to first drive NCS high then low. the datasheet does not
+ // say for how long, 40us works well in practice.
+ if (!pmw33xx_spi_start(sensor)) {
+ return false;
+ }
+ wait_us(40);
+ spi_stop();
+ wait_us(40);
+
+ if (!pmw33xx_write(sensor, REG_Power_Up_Reset, 0x5a)) {
+ return false;
+ }
+ wait_ms(50);
+
+ // read registers and discard
+ pmw33xx_read(sensor, REG_Motion);
+ pmw33xx_read(sensor, REG_Delta_X_L);
+ pmw33xx_read(sensor, REG_Delta_X_H);
+ pmw33xx_read(sensor, REG_Delta_Y_L);
+ pmw33xx_read(sensor, REG_Delta_Y_H);
+
+ if (!pmw33xx_upload_firmware(sensor)) {
+ dprintf("PMW33XX (%d): firmware upload failed!\n", sensor);
+ return false;
+ }
+
+ spi_stop();
+
+ wait_ms(10);
+ pmw33xx_set_cpi(sensor, PMW33XX_CPI);
+
+ wait_ms(1);
+
+ pmw33xx_write(sensor, REG_Config2, 0x00);
+ pmw33xx_write(sensor, REG_Angle_Tune, CONSTRAIN(ROTATIONAL_TRANSFORM_ANGLE, -127, 127));
+ pmw33xx_write(sensor, REG_Lift_Config, PMW33XX_LIFTOFF_DISTANCE);
+
+ if (!pmw33xx_check_signature(sensor)) {
+ dprintf("PMW33XX (%d): firmware signature verification failed!\n", sensor);
+ return false;
+ }
+
+ return true;
+}
+
+pmw33xx_report_t pmw33xx_read_burst(uint8_t sensor) {
+ pmw33xx_report_t report = {0};
+
+ if (sensor >= pmw33xx_number_of_sensors) {
+ return report;
+ }
+
+ if (!in_burst[sensor]) {
+ dprintf("PMW33XX (%d): burst\n", sensor);
+ if (!pmw33xx_write(sensor, REG_Motion_Burst, 0x00)) {
+ return report;
+ }
+ in_burst[sensor] = true;
+ }
+
+ if (!pmw33xx_spi_start(sensor)) {
+ return report;
+ }
+
+ spi_write(REG_Motion_Burst);
+ wait_us(35); // waits for tSRAD_MOTBR
+
+ spi_receive((uint8_t*)&report, sizeof(report));
+
+ // panic recovery, sometimes burst mode works weird.
+ if (report.motion.w & 0b111) {
+ in_burst[sensor] = false;
+ }
+
+ spi_stop();
+
+ if (debug_config.mouse) {
+ dprintf("PMW33XX (%d): motion: 0x%x dx: %i dy: %i\n", sensor, report.motion.w, report.delta_x, report.delta_y);
+ }
+
+ report.delta_x *= -1;
+ report.delta_y *= -1;
+
+ return report;
+}
diff --git a/drivers/sensors/pmw33xx_common.h b/drivers/sensors/pmw33xx_common.h
new file mode 100644
index 0000000000..c725e80f24
--- /dev/null
+++ b/drivers/sensors/pmw33xx_common.h
@@ -0,0 +1,156 @@
+// Copyright 2022 Daniel Kao (dkao)
+// Copyright 2022 Stefan Kerkmann (KarlK90)
+// Copyright 2022 Ulrich Spörlein (@uqs)
+// Copyright 2021 Alabastard (@Alabastard-64)
+// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+// Copyright 2019 Sunjun Kim
+// Copyright 2020 Ploopy Corporation
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <stdint.h>
+#include "spi_master.h"
+#include "util.h"
+
+#if defined(POINTING_DEVICE_DRIVER_pmw3360)
+# include "pmw3360.h"
+#elif defined(POINTING_DEVICE_DRIVER_pmw3389)
+# include "pmw3389.h"
+#endif
+
+typedef struct __attribute__((packed)) {
+ union {
+ struct {
+ bool capture_from_raw_data : 1; // FRAME_RData_1st
+ uint8_t operation_mode : 2; // OP_MODE
+ bool is_lifted : 1; // Lift_stat
+ bool raw_data_grab_is_raw_data : 1; // RData_1st
+ uint8_t _reserved : 2; // 1 + Reserved
+ bool is_motion : 1; // MOT
+ } b;
+ uint8_t w;
+ } motion;
+ uint8_t observation;
+ int16_t delta_x; // displacement on x directions. Unit: Count. (CPI * Count = Inch value)
+ int16_t delta_y; // displacement on y directions.
+} pmw33xx_report_t;
+
+_Static_assert(sizeof(pmw33xx_report_t) == 6, "pmw33xx_report_t must be 6 bytes in size");
+_Static_assert(sizeof((pmw33xx_report_t){0}.motion) == 1, "pmw33xx_report_t.motion must be 1 byte in size");
+
+#if !defined(PMW33XX_CLOCK_SPEED)
+# define PMW33XX_CLOCK_SPEED 2000000
+#endif
+
+#if !defined(PMW33XX_SPI_DIVISOR)
+# ifdef __AVR__
+# define PMW33XX_SPI_DIVISOR (F_CPU / PMW33XX_CLOCK_SPEED)
+# else
+# define PMW33XX_SPI_DIVISOR 64
+# endif
+#endif
+
+#if !defined(PMW33XX_LIFTOFF_DISTANCE)
+# define PMW33XX_LIFTOFF_DISTANCE 0x02
+#endif
+
+#if !defined(ROTATIONAL_TRANSFORM_ANGLE)
+# define ROTATIONAL_TRANSFORM_ANGLE 0x00
+#endif
+
+#if ROTATIONAL_TRANSFORM_ANGLE > 127 || ROTATIONAL_TRANSFORM_ANGLE < (-127)
+# error ROTATIONAL_TRANSFORM_ANGLE has to be in the range of +/- 127 for all PMW33XX sensors.
+#endif
+
+// Support single and plural spellings
+#ifndef PMW33XX_CS_PINS
+# ifndef PMW33XX_CS_PIN
+# ifdef POINTING_DEVICE_CS_PIN
+# define PMW33XX_CS_PIN POINTING_DEVICE_CS_PIN
+# define PMW33XX_CS_PINS \
+ { PMW33XX_CS_PIN }
+# else
+# error "No chip select pin defined -- missing PMW33XX_CS_PIN or PMW33XX_CS_PINS"
+# endif
+# else
+# define PMW33XX_CS_PINS \
+ { PMW33XX_CS_PIN }
+# endif
+#endif
+
+#if PMW33XX_CPI > PMW33XX_CPI_MAX || PMW33XX_CPI < PMW33XX_CPI_MIN || (PMW33XX_CPI % PMW33XX_CPI_STEP) != 0U
+# pragma message "PMW33XX_CPI has to be in the range of " STR(PMW33XX_CPI_MAX) "-" STR(PMW33XX_CPI_MIN) " in increments of " STR(PMW33XX_CPI_STEP) ". But it is " STR(PMW33XX_CPI) "."
+# error Use correct PMW33XX_CPI value.
+#endif
+
+#define CONSTRAIN(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
+
+/**
+ * @brief Initializes the given sensor so it is in a working state and ready to
+ * be polled for data.
+ *
+ * @param sensor Index of the sensors chip select pin
+ * @return true Initialization was a success
+ * @return false Initialization failed, do not proceed operation
+ */
+bool __attribute__((cold)) pmw33xx_init(uint8_t sensor);
+
+/**
+ * @brief Gets the currently set CPI value from the sensor. CPI is often
+ * refereed to as the sensors sensitivity.
+ *
+ * @param sensor Index of the sensors chip select pin
+ * @return uint16_t Current CPI value of the sensor
+ */
+uint16_t pmw33xx_get_cpi(uint8_t sensor);
+
+/**
+ * @brief Sets the given CPI value for the given PMW33XX sensor. CIP is often
+ * refereed to as the sensors sensitivity. Values outside of the allow range are
+ * constrained into legal values.
+ *
+ * @param sensor Index of the sensors chip select pin
+ * @param cpi CPI value to set, legal range depends on the PMW sensor type
+ */
+void pmw33xx_set_cpi(uint8_t sensor, uint16_t cpi);
+
+/**
+ * @brief Sets the given CPI value to all registered PMW33XX sensors. CPI is
+ * often refereed to as the sensors sensitivity. Values outside of the allow
+ * range are constrained into legal values.
+ *
+ * @param sensor Index of the sensors chip select pin
+ * @param cpi CPI value to set, legal range depends on the PMW sensor type
+ */
+void pmw33xx_set_cpi_all_sensors(uint16_t cpi);
+
+/**
+ * @brief Reads and clears the current delta, and motion register values on the
+ * given sensor.
+ *
+ * @param sensor Index of the sensors chip select pin
+ * @return pmw33xx_report_t Current values of the sensor, if errors occurred all
+ * fields are set to zero
+ */
+pmw33xx_report_t pmw33xx_read_burst(uint8_t sensor);
+
+/**
+ * @brief Read one byte of data from the given register on the sensor
+ *
+ * @param sensor Index of the sensors chip select pin
+ * @param reg_addr Register address to read from
+ * @return uint8_t
+ */
+uint8_t pmw33xx_read(uint8_t sensor, uint8_t reg_addr);
+
+/**
+ * @brief Writes one byte of data to the given register on the sensor
+ *
+ * @param sensor Index of the sensors chip select pin
+ * @param reg_addr Registers address to write to
+ * @param data Data to write to the register
+ * @return true Write was a success
+ * @return false Write failed, do not proceed operation
+ */
+bool pmw33xx_write(uint8_t sensor, uint8_t reg_addr, uint8_t data);
diff --git a/drivers/serial.h b/drivers/serial.h
index 0cfdbd9959..fb91b136e7 100644
--- a/drivers/serial.h
+++ b/drivers/serial.h
@@ -27,3 +27,13 @@ void soft_serial_initiator_init(void);
void soft_serial_target_init(void);
bool soft_serial_transaction(int sstd_index);
+
+#ifdef SERIAL_DEBUG
+# include <debug.h>
+# include <print.h>
+# define serial_dprintf(...) dprintf(__VA_ARGS__)
+#else
+# define serial_dprintf(...) \
+ do { \
+ } while (0)
+#endif
diff --git a/drivers/wear_leveling/wear_leveling_flash_spi.c b/drivers/wear_leveling/wear_leveling_flash_spi.c
new file mode 100644
index 0000000000..6191f8bf09
--- /dev/null
+++ b/drivers/wear_leveling/wear_leveling_flash_spi.c
@@ -0,0 +1,101 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <stdbool.h>
+#include <hal.h>
+#include "util.h"
+#include "timer.h"
+#include "wear_leveling.h"
+#include "wear_leveling_internal.h"
+
+#ifndef WEAR_LEVELING_EXTERNAL_FLASH_BULK_COUNT
+# define WEAR_LEVELING_EXTERNAL_FLASH_BULK_COUNT 32
+#endif // WEAR_LEVELING_EXTERNAL_FLASH_BULK_COUNT
+
+bool backing_store_init(void) {
+ bs_dprintf("Init\n");
+ flash_init();
+ return true;
+}
+
+bool backing_store_unlock(void) {
+ bs_dprintf("Unlock\n");
+ // No-op -- handled by the flash driver as it is.
+ return true;
+}
+
+bool backing_store_erase(void) {
+#ifdef WEAR_LEVELING_DEBUG_OUTPUT
+ uint32_t start = timer_read32();
+#endif
+
+ bool ret = true;
+ for (int i = 0; i < (WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_COUNT); ++i) {
+ flash_status_t status = flash_erase_block(((WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_OFFSET) + i) * (EXTERNAL_FLASH_BLOCK_SIZE));
+ if (status != FLASH_STATUS_SUCCESS) {
+ ret = false;
+ break;
+ }
+ }
+
+ bs_dprintf("Backing store erase took %ldms to complete\n", ((long)(timer_read32() - start)));
+ return ret;
+}
+
+bool backing_store_write(uint32_t address, backing_store_int_t value) {
+ return backing_store_write_bulk(address, &value, 1);
+}
+
+bool backing_store_lock(void) {
+ bs_dprintf("Lock \n");
+ // No-op -- handled by the flash driver as it is.
+ return true;
+}
+
+bool backing_store_read(uint32_t address, backing_store_int_t *value) {
+ return backing_store_read_bulk(address, value, 1);
+}
+
+bool backing_store_read_bulk(uint32_t address, backing_store_int_t *values, size_t item_count) {
+ bs_dprintf("Read ");
+ uint32_t offset = (WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_OFFSET) * (EXTERNAL_FLASH_BLOCK_SIZE) + address;
+ flash_status_t status = flash_read_block(offset, values, sizeof(backing_store_int_t) * item_count);
+ if (status == FLASH_STATUS_SUCCESS) {
+ for (size_t i = 0; i < item_count; ++i) {
+ values[i] = ~values[i];
+ }
+ wl_dump(offset, values, sizeof(backing_store_int_t) * item_count);
+ }
+ return status == FLASH_STATUS_SUCCESS;
+}
+
+bool backing_store_write_bulk(uint32_t address, backing_store_int_t *values, size_t item_count) {
+ uint32_t offset = (WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_OFFSET) * (EXTERNAL_FLASH_BLOCK_SIZE) + address;
+ size_t index = 0;
+ backing_store_int_t temp[WEAR_LEVELING_EXTERNAL_FLASH_BULK_COUNT];
+ do {
+ // Copy out the block of data we want to transmit first
+ size_t this_loop = MIN(item_count, WEAR_LEVELING_EXTERNAL_FLASH_BULK_COUNT);
+ for (size_t i = 0; i < this_loop; ++i) {
+ temp[i] = values[index + i];
+ }
+
+ bs_dprintf("Write ");
+ wl_dump(offset, temp, sizeof(backing_store_int_t) * this_loop);
+
+ // Take the complement instead
+ for (size_t i = 0; i < this_loop; ++i) {
+ temp[i] = ~temp[i];
+ }
+
+ // Write out the block
+ if (flash_write_block(offset, temp, sizeof(backing_store_int_t) * this_loop) != FLASH_STATUS_SUCCESS) {
+ return false;
+ }
+
+ offset += this_loop * sizeof(backing_store_int_t);
+ index += this_loop;
+ item_count -= this_loop;
+ } while (item_count > 0);
+
+ return true;
+}
diff --git a/drivers/wear_leveling/wear_leveling_flash_spi_config.h b/drivers/wear_leveling/wear_leveling_flash_spi_config.h
new file mode 100644
index 0000000000..394370daa3
--- /dev/null
+++ b/drivers/wear_leveling/wear_leveling_flash_spi_config.h
@@ -0,0 +1,34 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#ifndef __ASSEMBLER__
+# include <stdlib.h>
+# include <stdint.h>
+# include "flash_spi.h"
+#endif
+
+// Use 1 block -- check the config for the SPI flash to determine how big it is
+#ifndef WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_COUNT
+# define WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_COUNT 1
+#endif // WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_COUNT
+
+// Start at the first block of the external flash
+#ifndef WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_OFFSET
+# define WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_OFFSET 0
+#endif // WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_OFFSET
+
+// 8-byte writes by default
+#ifndef BACKING_STORE_WRITE_SIZE
+# define BACKING_STORE_WRITE_SIZE 8
+#endif
+
+// The space allocated by the block
+#ifndef WEAR_LEVELING_BACKING_SIZE
+# define WEAR_LEVELING_BACKING_SIZE ((EXTERNAL_FLASH_BLOCK_SIZE) * (WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_COUNT))
+#endif // WEAR_LEVELING_BACKING_SIZE
+
+// Use half of the backing size for logical EEPROM
+#ifndef WEAR_LEVELING_LOGICAL_SIZE
+# define WEAR_LEVELING_LOGICAL_SIZE ((WEAR_LEVELING_BACKING_SIZE) / 2)
+#endif // WEAR_LEVELING_LOGICAL_SIZE
diff --git a/keyboards/ergodox_ez/base/info.json b/keyboards/ergodox_ez/base/info.json
new file mode 100644
index 0000000000..be1433ccba
--- /dev/null
+++ b/keyboards/ergodox_ez/base/info.json
@@ -0,0 +1,6 @@
+{
+ "keyboard_name": "ErgoDox EZ",
+ "usb": {
+ "pid": "0x4974"
+ }
+}
diff --git a/keyboards/ergodox_ez/base/rules.mk b/keyboards/ergodox_ez/base/rules.mk
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/keyboards/ergodox_ez/base/rules.mk
diff --git a/keyboards/ergodox_ez/config.h b/keyboards/ergodox_ez/config.h
index 8208ea9728..c62b306600 100644
--- a/keyboards/ergodox_ez/config.h
+++ b/keyboards/ergodox_ez/config.h
@@ -22,13 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "config_common.h"
-/* USB Device descriptor parameter */
-#define VENDOR_ID 0x3297
-#define DEVICE_VER 0x0001
-#define MANUFACTURER ZSA Technology Labs
-#define PRODUCT_ID 0x4974
-#define PRODUCT ErgoDox EZ
-
/* key matrix size */
#define MATRIX_ROWS 14
#define MATRIX_ROWS_PER_SIDE (MATRIX_ROWS / 2)
diff --git a/keyboards/ergodox_ez/glow/config.h b/keyboards/ergodox_ez/glow/config.h
deleted file mode 100644
index 1666aa47c3..0000000000
--- a/keyboards/ergodox_ez/glow/config.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-Copyright 2012 Jun Wako <wakojun@gmail.com>
-Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
-Copyright 2015 ZSA Technology Labs Inc (@zsa)
-Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#pragma once
-
-#undef PRODUCT_ID
-#define PRODUCT_ID 0x4976
-#undef PRODUCT
-#define PRODUCT ErgoDox EZ Glow
-
-#undef ENABLE_RGB_MATRIX_PIXEL_FRACTAL
-#undef ENABLE_RGB_MATRIX_PIXEL_FLOW
-#undef ENABLE_RGB_MATRIX_PIXEL_RAIN
-
-#undef ENABLE_RGB_MATRIX_HUE_BREATHING
-#undef ENABLE_RGB_MATRIX_HUE_PENDULUM
-#undef ENABLE_RGB_MATRIX_HUE_WAVE
-
-#undef RGBLIGHT_EFFECT_CHRISTMAS
-#undef ENABLE_RGB_MATRIX_CYCLE_ALL
diff --git a/keyboards/ergodox_ez/glow/info.json b/keyboards/ergodox_ez/glow/info.json
new file mode 100644
index 0000000000..dcbb1999ca
--- /dev/null
+++ b/keyboards/ergodox_ez/glow/info.json
@@ -0,0 +1,6 @@
+{
+ "keyboard_name": "ErgoDox EZ Glow",
+ "usb": {
+ "pid": "0x4976"
+ }
+}
diff --git a/keyboards/ergodox_ez/info.json b/keyboards/ergodox_ez/info.json
index 1682f4bb45..46a0fbbacd 100644
--- a/keyboards/ergodox_ez/info.json
+++ b/keyboards/ergodox_ez/info.json
@@ -1,7 +1,11 @@
{
- "keyboard_name": "ErgoDox EZ",
+ "manufacturer": "ZSA Technology Labs",
"url": "ergodox-ez.com",
"maintainer": "ZSA via Drashna",
+ "usb": {
+ "vid": "0x3297",
+ "device_version": "0.0.1"
+ },
"layouts": {
"LAYOUT_ergodox": {
"layout": [
diff --git a/keyboards/ergodox_ez/rules.mk b/keyboards/ergodox_ez/rules.mk
index 99d1df039a..f3732107e5 100644
--- a/keyboards/ergodox_ez/rules.mk
+++ b/keyboards/ergodox_ez/rules.mk
@@ -40,3 +40,5 @@ AUDIO_SUPPORTED = no
BACKLIGHT_SUPPORTED = no
MOUSE_SHARED_EP = no
+
+DEFAULT_FOLDER = ergodox_ez/base
diff --git a/keyboards/ergodox_ez/shine/config.h b/keyboards/ergodox_ez/shine/config.h
deleted file mode 100644
index cf4f59f3b8..0000000000
--- a/keyboards/ergodox_ez/shine/config.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-Copyright 2012 Jun Wako <wakojun@gmail.com>
-Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
-Copyright 2015 ZSA Technology Labs Inc (@zsa)
-Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#pragma once
-
-#undef PRODUCT_ID
-#define PRODUCT_ID 0x4975
-#undef PRODUCT
-#define PRODUCT ErgoDox EZ Shine
diff --git a/keyboards/ergodox_ez/shine/info.json b/keyboards/ergodox_ez/shine/info.json
new file mode 100644
index 0000000000..11c3a8b209
--- /dev/null
+++ b/keyboards/ergodox_ez/shine/info.json
@@ -0,0 +1,6 @@
+{
+ "keyboard_name": "ErgoDox EZ Shine",
+ "usb": {
+ "pid": "0x4975"
+ }
+}
diff --git a/keyboards/ergodox_ez/util/compile_keymap.py b/keyboards/ergodox_ez/util/compile_keymap.py
index b447ecaf5c..310512c920 100755
--- a/keyboards/ergodox_ez/util/compile_keymap.py
+++ b/keyboards/ergodox_ez/util/compile_keymap.py
@@ -27,29 +27,34 @@ PY2 = sys.version_info.major == 2
if PY2:
chr = unichr
-
KEYBOARD_LAYOUTS = {
# These map positions in the parsed layout to
# positions in the KEYMAP MATRIX
'ergodox_ez': [
- [ 0, 1, 2, 3, 4, 5, 6], [38, 39, 40, 41, 42, 43, 44],
- [ 7, 8, 9, 10, 11, 12, 13], [45, 46, 47, 48, 49, 50, 51],
- [14, 15, 16, 17, 18, 19 ], [ 52, 53, 54, 55, 56, 57],
- [20, 21, 22, 23, 24, 25, 26], [58, 59, 60, 61, 62, 63, 64],
- [27, 28, 29, 30, 31 ], [ 65, 66, 67, 68, 69],
- [ 32, 33], [70, 71 ],
- [ 34], [72 ],
- [ 35, 36, 37], [73, 74, 75 ],
+ [0, 1, 2, 3, 4, 5, 6],
+ [38, 39, 40, 41, 42, 43, 44],
+ [7, 8, 9, 10, 11, 12, 13],
+ [45, 46, 47, 48, 49, 50, 51],
+ [14, 15, 16, 17, 18, 19],
+ [52, 53, 54, 55, 56, 57],
+ [20, 21, 22, 23, 24, 25, 26],
+ [58, 59, 60, 61, 62, 63, 64],
+ [27, 28, 29, 30, 31],
+ [65, 66, 67, 68, 69],
+ [32, 33],
+ [70, 71],
+ [34],
+ [72],
+ [35, 36, 37],
+ [73, 74, 75],
]
}
-ROW_INDENTS = {
- 'ergodox_ez': [0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 5, 0, 6, 0, 4, 0]
-}
+ROW_INDENTS = {'ergodox_ez': [0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 5, 0, 6, 0, 4, 0]}
BLANK_LAYOUTS = [
-# Compact Layout
-"""
+ # Compact Layout
+ """
.------------------------------------.------------------------------------.
| | | | | | | | | | | | | | |
!-----+----+----+----+----+----------!-----+----+----+----+----+----+-----!
@@ -70,8 +75,8 @@ BLANK_LAYOUTS = [
'-----------------' '-----------------'
""",
-# Wide Layout
-"""
+ # Wide Layout
+ """
.---------------------------------------------. .---------------------------------------------.
| | | | | | | | ! | | | | | | |
!-------+-----+-----+-----+-----+-------------! !-------+-----+-----+-----+-----+-----+-------!
@@ -93,26 +98,22 @@ BLANK_LAYOUTS = [
""",
]
-
DEFAULT_CONFIG = {
- "keymaps_includes": [
- "keymap_common.h",
- ],
+ "keymaps_includes": ["keymap_common.h",],
'filler': "-+.'!:x",
'separator': "|",
'default_key_prefix': ["KC_"],
}
-
SECTIONS = [
'layout_config',
'layers',
]
-
# Markdown Parsing
-ONELINE_COMMENT_RE = re.compile(r"""
+ONELINE_COMMENT_RE = re.compile(
+ r"""
^ # comment must be at the start of the line
\s* # arbitrary whitespace
// # start of the comment
@@ -121,22 +122,26 @@ ONELINE_COMMENT_RE = re.compile(r"""
""", re.MULTILINE | re.VERBOSE
)
-INLINE_COMMENT_RE = re.compile(r"""
+INLINE_COMMENT_RE = re.compile(
+ r"""
([\,\"\[\]\{\}\d]) # anythig that might end a expression
\s+ # comment must be preceded by whitespace
// # start of the comment
\s # and succeded by whitespace
(?:[^\"\]\}\{\[]*) # the comment (except things which might be json)
$ # until the end of line
-""", re.MULTILINE | re.VERBOSE)
+""", re.MULTILINE | re.VERBOSE
+)
-TRAILING_COMMA_RE = re.compile(r"""
+TRAILING_COMMA_RE = re.compile(
+ r"""
, # the comma
(?:\s*) # arbitrary whitespace
$ # only works if the trailing comma is followed by newline
(\s*) # arbitrary whitespace
([\]\}]) # end of an array or object
-""", re.MULTILINE | re.VERBOSE)
+""", re.MULTILINE | re.VERBOSE
+)
def loads(raw_data):
@@ -178,9 +183,7 @@ def parse_config(path):
def end_section():
if section['start_line'] >= 0:
if section['name'] == 'layout_config':
- config.update(loads("\n".join(
- section['code_lines']
- )))
+ config.update(loads("\n".join(section['code_lines'])))
elif section['sub_name'].startswith('layer'):
layer_name = section['sub_name']
config['layer_lines'][layer_name] = section['code_lines']
@@ -215,6 +218,7 @@ def parse_config(path):
assert 'layout' in config
return config
+
# header file parsing
IF0_RE = re.compile(r"""
@@ -224,7 +228,6 @@ IF0_RE = re.compile(r"""
#endif
""", re.MULTILINE | re.DOTALL | re.VERBOSE)
-
COMMENT_RE = re.compile(r"""
/\*
.*?
@@ -244,6 +247,7 @@ def regex_partial(re_str_fmt, flags):
def partial(*args, **kwargs):
re_str = re_str_fmt.format(*args, **kwargs)
return re.compile(re_str, flags)
+
return partial
@@ -256,7 +260,6 @@ KEYDEF_REP = regex_partial(r"""
) # capture group end
""", re.MULTILINE | re.DOTALL | re.VERBOSE)
-
ENUM_RE = re.compile(r"""
(
enum
@@ -268,7 +271,6 @@ ENUM_RE = re.compile(r"""
) # capture group end
""", re.MULTILINE | re.DOTALL | re.VERBOSE)
-
ENUM_KEY_REP = regex_partial(r"""
(
{} # the prefixes
@@ -309,14 +311,13 @@ def parse_valid_keys(config, out_path):
include_path = os.path.join(dirpath, include)
if os.path.exists(include_path):
header_data = read_header_file(include_path)
- valid_keycodes.update(
- parse_keydefs(config, header_data)
- )
+ valid_keycodes.update(parse_keydefs(config, header_data))
return valid_keycodes
# Keymap Parsing
+
def iter_raw_codes(layer_lines, filler, separator):
filler_re = re.compile("[" + filler + " ]")
for line in layer_lines:
@@ -346,28 +347,21 @@ LAYER_CHANGE_RE = re.compile(r"""
(DF|TG|MO)\(\d+\)
""", re.VERBOSE)
-
MACRO_RE = re.compile(r"""
M\(\w+\)
""", re.VERBOSE)
-
UNICODE_RE = re.compile(r"""
U[0-9A-F]{4}
""", re.VERBOSE)
-
NON_CODE = re.compile(r"""
^[^A-Z0-9_]$
""", re.VERBOSE)
def parse_uni_code(raw_code):
- macro_id = "UC_" + (
- unicodedata.name(raw_code)
- .replace(" ", "_")
- .replace("-", "_")
- )
+ macro_id = "UC_" + (unicodedata.name(raw_code).replace(" ", "_").replace("-", "_"))
code = "M({})".format(macro_id)
uc_hex = "{:04X}".format(ord(raw_code))
return code, macro_id, uc_hex
@@ -407,19 +401,13 @@ def parse_code(raw_code, key_prefixes, valid_keycodes):
def parse_keymap(config, key_indexes, layer_lines, valid_keycodes):
keymap = {}
- raw_codes = list(iter_raw_codes(
- layer_lines, config['filler'], config['separator']
- ))
+ raw_codes = list(iter_raw_codes(layer_lines, config['filler'], config['separator']))
indexed_codes = iter_indexed_codes(raw_codes, key_indexes)
key_prefixes = config['key_prefixes']
for raw_code, key_index, row_index in indexed_codes:
- code, macro_id, uc_hex = parse_code(
- raw_code, key_prefixes, valid_keycodes
- )
+ code, macro_id, uc_hex = parse_code(raw_code, key_prefixes, valid_keycodes)
# TODO: line numbers for invalid codes
- err_msg = "Could not parse key '{}' on row {}".format(
- raw_code, row_index
- )
+ err_msg = "Could not parse key '{}' on row {}".format(raw_code, row_index)
assert code is not None, err_msg
# print(repr(raw_code), repr(code), macro_id, uc_hex)
if macro_id:
@@ -432,17 +420,14 @@ def parse_keymap(config, key_indexes, layer_lines, valid_keycodes):
def parse_keymaps(config, valid_keycodes):
keymaps = collections.OrderedDict()
- key_indexes = config.get(
- 'key_indexes', KEYBOARD_LAYOUTS[config['layout']]
- )
+ key_indexes = config.get('key_indexes', KEYBOARD_LAYOUTS[config['layout']])
# TODO: maybe validate key_indexes
for layer_name, layer_lines, in config['layer_lines'].items():
- keymaps[layer_name] = parse_keymap(
- config, key_indexes, layer_lines, valid_keycodes
- )
+ keymaps[layer_name] = parse_keymap(config, key_indexes, layer_lines, valid_keycodes)
return keymaps
+
# keymap.c output
USERCODE = """
@@ -453,7 +438,7 @@ void matrix_init_user(void) {
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
- uint8_t layer = biton32(layer_state);
+ uint8_t layer = get_highest_layer(layer_state);
ergodox_board_led_off();
ergodox_right_led_1_off();
@@ -572,7 +557,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {{
}};
"""
-
UNICODE_MACRO_TEMPLATE = """
case {macro_id}:
unicode_action_function(0x{hi:02x}, 0x{lo:02x});
@@ -584,9 +568,7 @@ def unicode_macro_cases(config):
for macro_id, uc_hex in config['unicode_macros'].items():
hi = int(uc_hex, 16) >> 8
lo = int(uc_hex, 16) & 0xFF
- yield UNICODE_MACRO_TEMPLATE.format(
- macro_id=macro_id, hi=hi, lo=lo
- )
+ yield UNICODE_MACRO_TEMPLATE.format(macro_id=macro_id, hi=hi, lo=lo)
def iter_keymap_lines(keymap, row_indents=None):
diff --git a/keyboards/moonlander/config.h b/keyboards/moonlander/config.h
index 5951a485d3..2e5d862e37 100644
--- a/keyboards/moonlander/config.h
+++ b/keyboards/moonlander/config.h
@@ -20,17 +20,8 @@
#include "config_common.h"
-/* USB Device descriptor parameter */
-// clang-format off
-#define VENDOR_ID 0x3297
-#define PRODUCT_ID 0x1969
-#define MANUFACTURER ZSA Technology Labs
-#define PRODUCT Moonlander Mark I
-#define DEVICE_VER 0x0001
#define WEBUSB_LANDING_PAGE_URL u8"configure.ergodox-ez.com"
-// clang-format on
-
/* key matrix size */
#define MATRIX_ROWS 12
#define MATRIX_COLS 7
diff --git a/keyboards/moonlander/info.json b/keyboards/moonlander/info.json
index 60b560eeee..6322dccd5b 100644
--- a/keyboards/moonlander/info.json
+++ b/keyboards/moonlander/info.json
@@ -1,7 +1,13 @@
{
"keyboard_name": "Moonlander Mark I",
+ "manufacturer": "ZSA Technology Labs",
"url": "zsa.io/moonlander",
"maintainer": "ZSA via Drashna",
+ "usb": {
+ "vid": "0x3297",
+ "pid": "0x1969",
+ "device_version": "0.0.1"
+ },
"layouts": {
"LAYOUT_moonlander": {
"layout": [
diff --git a/keyboards/moonlander/keymaps/oryx/rules.mk b/keyboards/moonlander/keymaps/oryx/rules.mk
index d269d04c82..5026e22db5 100644
--- a/keyboards/moonlander/keymaps/oryx/rules.mk
+++ b/keyboards/moonlander/keymaps/oryx/rules.mk
@@ -1,4 +1,4 @@
-SRC += ../default/keymap.c
+INTROSPECTION_KEYMAP_C = ../default/keymap.c
-include ../default/rules.mk
ORYX_ENABLE = yes
diff --git a/keyboards/moonlander/matrix.c b/keyboards/moonlander/matrix.c
index 5f95dccc01..2ad4ccc5fd 100644
--- a/keyboards/moonlander/matrix.c
+++ b/keyboards/moonlander/matrix.c
@@ -227,3 +227,7 @@ void matrix_power_up(void) {
}
}
+
+bool is_transport_connected(void) {
+ return mcp23018_initd;
+} \ No newline at end of file
diff --git a/keyboards/moonlander/moonlander.c b/keyboards/moonlander/moonlander.c
index e849bff4e2..c217782d3f 100644
--- a/keyboards/moonlander/moonlander.c
+++ b/keyboards/moonlander/moonlander.c
@@ -320,7 +320,7 @@ bool music_mask_kb(uint16_t keycode) {
case QK_LAYER_TAP_TOGGLE ... QK_LAYER_MOD_MAX:
case QK_MOD_TAP ... QK_MOD_TAP_MAX:
case AU_ON ... MUV_DE:
- case RESET:
+ case QK_BOOT:
case EEP_RST:
return false;
default:
diff --git a/keyboards/moonlander/moonlander.h b/keyboards/moonlander/moonlander.h
index e2b4c76a11..b2e251900e 100644
--- a/keyboards/moonlander/moonlander.h
+++ b/keyboards/moonlander/moonlander.h
@@ -77,3 +77,5 @@ typedef union {
} keyboard_config_t;
extern keyboard_config_t keyboard_config;
+
+bool is_transport_connected(void); \ No newline at end of file
diff --git a/keyboards/moonlander/readme.md b/keyboards/moonlander/readme.md
index bf80f05569..733780abde 100644
--- a/keyboards/moonlander/readme.md
+++ b/keyboards/moonlander/readme.md
@@ -41,4 +41,18 @@ If you're using the Smart LED (layer indication) feature from the Oryx Configura
This changes the `RGB_TOG` keycode so that it will toggle the lights on and off, in a way that will allow the Smart LEDs to continue to work, even with the rest of the LEDs turned off.
-Additionally, a new keycode has been added to toggle the Smart LEDs. Use `TOGGLE_LAYER_COLOR`, if you aren't already.
+Additionally, a new keycode has been added to toggle the Smart LEDs. Use `TOGGLE_LAYER_COLOR`, if you aren't already.
+
+### Detecting split / Gaming mode
+
+To make it extra gaming friendly, you can configure what happens when you disconnect the right half. This is especially useful when using gaming unfriendly layers or layouts (e.g. home row mods, dvorak, colemak).
+
+Example for enabling a specific layer while right side is disconnected:
+
+```
+void housekeeping_task_user(void) {
+ if (!is_transport_connected()) {
+ // set layer
+ }
+}
+``` \ No newline at end of file
diff --git a/keyboards/planck/config.h b/keyboards/planck/config.h
index 8fb9dda32a..87221a81f8 100644
--- a/keyboards/planck/config.h
+++ b/keyboards/planck/config.h
@@ -19,11 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "config_common.h"
-/* USB Device descriptor parameter */
-#define VENDOR_ID 0x03A8
-#define MANUFACTURER OLKB
-#define PRODUCT Planck
-
/* key matrix size */
#define MATRIX_ROWS 4
#define MATRIX_COLS 12
@@ -31,7 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Planck PCB default pin-out */
#define MATRIX_ROW_PINS { D0, D5, B5, B6 }
#define MATRIX_COL_PINS { F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 }
-#define UNUSED_PINS
#define QMK_ESC_OUTPUT F1
#define QMK_ESC_INPUT D5
diff --git a/keyboards/planck/ez/base/info.json b/keyboards/planck/ez/base/info.json
new file mode 100644
index 0000000000..07167a8c2a
--- /dev/null
+++ b/keyboards/planck/ez/base/info.json
@@ -0,0 +1,6 @@
+{
+ "keyboard_name": "Planck EZ",
+ "usb": {
+ "pid": "0xC6CE"
+ }
+}
diff --git a/keyboards/planck/ez/base/rules.mk b/keyboards/planck/ez/base/rules.mk
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/keyboards/planck/ez/base/rules.mk
diff --git a/keyboards/planck/ez/config.h b/keyboards/planck/ez/config.h
index a79f49aa38..4b47e2fe2f 100644
--- a/keyboards/planck/ez/config.h
+++ b/keyboards/planck/ez/config.h
@@ -18,18 +18,6 @@
#pragma once
-
-#undef VENDOR_ID
-#define VENDOR_ID 0x3297
-#undef PRODUCT_ID
-#define PRODUCT_ID 0xC6CE
-#undef MANUFACTURER
-#define MANUFACTURER ZSA Technology Labs
-#undef PRODUCT
-#define PRODUCT Planck EZ
-#define DEVICE_VER 0x0000
-
-
#undef MATRIX_ROWS
#undef MATRIX_COLS
/* key matrix size */
@@ -181,4 +169,3 @@
#define MOUSEKEY_WHEEL_INTERVAL MOUSEKEY_INTERVAL
#define MOUSEKEY_WHEEL_MAX_SPEED MOUSEKEY_MAX_SPEED
#define MOUSEKEY_WHEEL_TIME_TO_MAX MOUSEKEY_TIME_TO_MAX
-
diff --git a/keyboards/planck/ez/ez.c b/keyboards/planck/ez/ez.c
index 5294be9ec0..93a17be293 100644
--- a/keyboards/planck/ez/ez.c
+++ b/keyboards/planck/ez/ez.c
@@ -292,7 +292,7 @@ bool music_mask_kb(uint16_t keycode) {
case QK_LAYER_TAP_TOGGLE ... QK_LAYER_MOD_MAX:
case QK_MOD_TAP ... QK_MOD_TAP_MAX:
case AU_ON ... MUV_DE:
- case RESET:
+ case QK_BOOT:
case EEP_RST:
return false;
default:
@@ -371,3 +371,22 @@ void matrix_scan_kb(void) {
#endif
matrix_scan_user();
}
+
+#ifdef SWAP_HANDS_ENABLE
+__attribute__ ((weak))
+const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
+ {{5, 4}, {4, 4}, {3, 4}, {2, 4}, {1, 4}, {0, 4}},
+ {{5, 5}, {4, 5}, {3, 5}, {2, 5}, {1, 5}, {0, 5}},
+ {{5, 6}, {4, 6}, {3, 6}, {2, 6}, {1, 6}, {0, 6}},
+ {{5, 3}, {4, 3}, {3, 3}, {2, 3}, {1, 3}, {0, 3}},
+
+ {{5, 0}, {4, 0}, {3, 0}, {2, 0}, {1, 0}, {0, 0}},
+ {{5, 1}, {4, 1}, {3, 1}, {2, 1}, {1, 1}, {0, 1}},
+ {{5, 2}, {4, 2}, {3, 2}, {2, 2}, {1, 2}, {0, 2}},
+ {{5, 7}, {4, 7}, {3, 7}, {2, 7}, {1, 7}, {0, 7}},
+};
+
+# ifdef ENCODER_MAP_ENABLE
+const uint8_t PROGMEM encoder_hand_swap_config[NUM_ENCODERS] = {0};
+# endif
+#endif
diff --git a/keyboards/planck/ez/glow/config.h b/keyboards/planck/ez/glow/config.h
deleted file mode 100644
index 55ce289010..0000000000
--- a/keyboards/planck/ez/glow/config.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright 2018 Jack Humbert <jack.humb@gmail.com>
- * Copyright 2015 ZSA Technology Labs Inc (@zsa)
- * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#undef PRODUCT_ID
-#define PRODUCT_ID 0xC6CF
-
-#undef PRODUCT
-#define PRODUCT Planck EZ Glow
diff --git a/keyboards/planck/ez/glow/info.json b/keyboards/planck/ez/glow/info.json
new file mode 100644
index 0000000000..4852258570
--- /dev/null
+++ b/keyboards/planck/ez/glow/info.json
@@ -0,0 +1,6 @@
+{
+ "keyboard_name": "Planck EZ Glow",
+ "usb": {
+ "pid": "0xC6CF"
+ }
+}
diff --git a/keyboards/planck/ez/glow/keymaps/glow/keymap.c b/keyboards/planck/ez/glow/keymaps/glow/keymap.c
index 37659fbc32..fb150a8901 100644
--- a/keyboards/planck/ez/glow/keymaps/glow/keymap.c
+++ b/keyboards/planck/ez/glow/keymaps/glow/keymap.c
@@ -163,7 +163,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `-----------------------------------------------------------------------------------'
*/
[_ADJUST] = LAYOUT_planck_grid(
- _______, RESET, DEBUG, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_DEL ,
+ _______, QK_BOOT, DEBUG, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_DEL ,
_______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______,
_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, TERM_ON, TERM_OFF, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
diff --git a/keyboards/planck/ez/info.json b/keyboards/planck/ez/info.json
index 6c9332b052..4008cb7057 100644
--- a/keyboards/planck/ez/info.json
+++ b/keyboards/planck/ez/info.json
@@ -1,7 +1,11 @@
{
- "keyboard_name": "Planck EZ",
+ "manufacturer": "ZSA Technology Labs",
"url": "https://ergodox-ez.com/pages/planck",
"maintainer": "jackhumbert",
+ "usb": {
+ "vid": "0x3297",
+ "device_version": "0.0.1"
+ },
"layouts": {
"LAYOUT_planck_1x2uC": {
"layout": [
diff --git a/keyboards/planck/ez/rules.mk b/keyboards/planck/ez/rules.mk
index d8494f1843..d493550fa8 100755
--- a/keyboards/planck/ez/rules.mk
+++ b/keyboards/planck/ez/rules.mk
@@ -30,3 +30,5 @@ RGBLIGHT_SUPPORTED = no
BAKCLIGHT_SUPPORTED = no
MOUSE_SHARED_EP = no
+
+DEFAULT_FOLDER = planck/ez/base
diff --git a/keyboards/planck/info.json b/keyboards/planck/info.json
index a4710d781f..cc57b6da60 100644
--- a/keyboards/planck/info.json
+++ b/keyboards/planck/info.json
@@ -1,5 +1,4 @@
{
- "keyboard_name": "Planck",
"url": "https://olkb.com/planck",
"maintainer": "jackhumbert",
"layouts": {
diff --git a/keyboards/planck/keymaps/default/keymap.c b/keyboards/planck/keymaps/default/keymap.c
index 3453d41746..8041e0bada 100644
--- a/keyboards/planck/keymaps/default/keymap.c
+++ b/keyboards/planck/keymaps/default/keymap.c
@@ -165,7 +165,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_ADJUST] = LAYOUT_planck_grid(
_______, QK_BOOT, DEBUG, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_DEL ,
_______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______,
- _______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, TERM_ON, TERM_OFF, _______, _______, _______,
+ _______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
)
diff --git a/keyboards/planck/keymaps/oryx/keymap.c b/keyboards/planck/keymaps/oryx/keymap.c
index d7b4bafe25..7a198f8693 100644
--- a/keyboards/planck/keymaps/oryx/keymap.c
+++ b/keyboards/planck/keymaps/oryx/keymap.c
@@ -56,7 +56,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_ADJUST] = LAYOUT_planck_grid(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
- KC_DEL, _______, AU_ON, AU_OFF, AU_TOG, _______, _______, RGB_TOG, RGB_VAI, RGB_VAD, LED_LEVEL, RESET,
+ KC_DEL, _______, AU_ON, AU_OFF, AU_TOG, _______, _______, RGB_TOG, RGB_VAI, RGB_VAD, LED_LEVEL, QK_BOOT,
_______, _______, MU_ON, MU_OFF, MU_TOG, _______, _______, RGB_MOD, RGB_HUI, RGB_HUD, TOGGLE_LAYER_COLOR, _______,
_______, _______, _______, _______, _______, _______, KC_NO, _______, _______, _______, _______, _______
),
@@ -95,7 +95,7 @@ void rgb_matrix_indicators_user(void) {
if (keyboard_config.disable_layer_led) {
return;
}
- switch (biton32(layer_state)) {
+ switch (get_highest_layer(layer_state)) {
case 1:
set_layer_color(0);
break;
diff --git a/keyboards/planck/planck.c b/keyboards/planck/planck.c
index e9bd90bdfe..20db22055c 100644
--- a/keyboards/planck/planck.c
+++ b/keyboards/planck/planck.c
@@ -1,15 +1,5 @@
#include "planck.h"
-#ifdef SWAP_HANDS_ENABLE
-__attribute__ ((weak))
-const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
- {{11, 0}, {10, 0}, {9, 0}, {8, 0}, {7, 0}, {6, 0}, {5, 0}, {4, 0}, {3, 0}, {2, 0}, {1, 0}, {0, 0}},
- {{11, 1}, {10, 1}, {9, 1}, {8, 1}, {7, 1}, {6, 1}, {5, 1}, {4, 1}, {3, 1}, {2, 1}, {1, 1}, {0, 1}},
- {{11, 2}, {10, 2}, {9, 2}, {8, 2}, {7, 2}, {6, 2}, {5, 2}, {4, 2}, {3, 2}, {2, 2}, {1, 2}, {0, 2}},
- {{11, 3}, {10, 3}, {9, 3}, {8, 3}, {7, 3}, {6, 3}, {5, 3}, {4, 3}, {3, 3}, {2, 3}, {1, 3}, {0, 3}},
-};
-#endif
-
__attribute__ ((weak))
void matrix_init_kb(void) {
// Turn status LED on, with the exception of THK
diff --git a/lib/chibios b/lib/chibios
-Subproject 257302333c31f1f710800c2b97acf3550de043e
+Subproject f836d24b06d7265696a33d1cea010bd6a931791
diff --git a/lib/chibios-contrib b/lib/chibios-contrib
-Subproject 2a6b73ff51baf89083a220b6692a04ca2cae875
+Subproject d03aa9cc2f76468e431c71421015102956dd6ad
diff --git a/lib/fnv/Makefile b/lib/fnv/Makefile
new file mode 100644
index 0000000000..c0673ded40
--- /dev/null
+++ b/lib/fnv/Makefile
@@ -0,0 +1,304 @@
+#!/bin/make
+#
+# hash - makefile for FNV hash tools
+#
+# @(#) $Revision: 5.2 $
+# @(#) $Id: Makefile,v 5.2 2012/03/21 01:42:15 chongo Exp $
+# @(#) $Source: /usr/local/src/cmd/fnv/RCS/Makefile,v $
+#
+# See:
+# http://www.isthe.com/chongo/tech/comp/fnv/index.html
+#
+# for the most up to date copy of this code and the FNV hash home page.
+#
+# Please do not copyright this code. This code is in the public domain.
+#
+# LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+# EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+#
+# By:
+# chongo <Landon Curt Noll> /\oo/\
+# http://www.isthe.com/chongo/
+#
+# Share and Enjoy! :-)
+
+# make tools
+#
+SHELL= /bin/sh
+CFLAGS= -O3 -g3
+#CFLAGS= -O2 -g3
+#CC= cc
+AR= ar
+TAR= tar
+EGREP= egrep
+GZIP_BIN= gzip
+INSTALL= install
+
+# If your system needs ranlib use:
+# RANLIB= ranlib
+# otherwise use:
+# RANLIB= :
+#
+#RANLIB= ranlib
+RANLIB= :
+
+# where to install things
+#
+DESTBIN= /usr/local/bin
+DESTLIB= /usr/local/lib
+DESTINC= /usr/local/include
+
+# what to build
+#
+SRC= hash_32.c hash_32a.c hash_64.c hash_64a.c \
+ fnv32.c fnv64.c \
+ have_ulong64.c test_fnv.c
+NO64BIT_SRC= no64bit_fnv64.c no64bit_hash_64.c \
+ no64bit_hash_64a.c no64bit_test_fnv.c
+HSRC= fnv.h \
+ longlong.h
+ALL= ${SRC} ${HSRC} \
+ README Makefile
+PROGS= fnv032 fnv064 fnv132 fnv164 fnv1a32 fnv1a64
+OBSOLETE_PROGS= fnv0_32 fnv0_64 fnv1_32 fnv1_64 fnv1a_32 fnv1a_64
+NO64BIT_PROGS= no64bit_fnv064 no64bit_fnv164 no64bit_fnv1a64
+LIBS= libfnv.a
+LIBOBJ= hash_32.o hash_64.o hash_32a.o hash_64a.o test_fnv.o
+NO64BIT_OBJ= no64bit_fnv64.o no64bit_hash_64.o \
+ no64bit_hash_64a.o no64bit_test_fnv.o
+OTHEROBJ= fnv32.o fnv64.o
+TARGETS= ${LIBOBJ} ${LIBS} ${PROGS}
+
+# default rule
+#
+all: ${TARGETS}
+
+# things to build
+#
+hash_32.o: hash_32.c longlong.h fnv.h
+ ${CC} ${CFLAGS} hash_32.c -c
+
+hash_64.o: hash_64.c longlong.h fnv.h
+ ${CC} ${CFLAGS} hash_64.c -c
+
+hash_32a.o: hash_32a.c longlong.h fnv.h
+ ${CC} ${CFLAGS} hash_32a.c -c
+
+hash_64a.o: hash_64a.c longlong.h fnv.h
+ ${CC} ${CFLAGS} hash_64a.c -c
+
+test_fnv.o: test_fnv.c longlong.h fnv.h
+ ${CC} ${CFLAGS} test_fnv.c -c
+
+fnv32.o: fnv32.c longlong.h fnv.h
+ ${CC} ${CFLAGS} fnv32.c -c
+
+fnv032: fnv32.o libfnv.a
+ ${CC} fnv32.o libfnv.a -o fnv032
+
+fnv64.o: fnv64.c longlong.h fnv.h
+ ${CC} ${CFLAGS} fnv64.c -c
+
+fnv064: fnv64.o libfnv.a
+ ${CC} fnv64.o libfnv.a -o fnv064
+
+libfnv.a: ${LIBOBJ}
+ rm -f $@
+ ${AR} rv $@ ${LIBOBJ}
+ ${RANLIB} $@
+
+fnv132: fnv032
+ -rm -f $@
+ -cp -f $? $@
+
+fnv1a32: fnv032
+ -rm -f $@
+ -cp -f $? $@
+
+fnv164: fnv064
+ -rm -f $@
+ -cp -f $? $@
+
+fnv1a64: fnv064
+ -rm -f $@
+ -cp -f $? $@
+
+longlong.h: have_ulong64.c Makefile
+ -@rm -f have_ulong64 have_ulong64.o ll_tmp longlong.h
+ @echo 'forming longlong.h'
+ @echo '/*' > longlong.h
+ @echo ' * DO NOT EDIT -- generated by the Makefile' >> longlong.h
+ @echo ' */' >> longlong.h
+ @echo '' >> longlong.h
+ @echo '#if !defined(__LONGLONG_H__)' >> longlong.h
+ @echo '#define __LONGLONG_H__' >> longlong.h
+ @echo '' >> longlong.h
+ @echo '/* do we have/want to use a long long type? */' >> longlong.h
+ -@rm -f have_ulong64.o have_ulong64
+ -@${CC} ${CFLAGS} have_ulong64.c -c 2>/dev/null; true
+ -@${CC} ${CFLAGS} have_ulong64.o -o have_ulong64 2>/dev/null; true
+ -@${SHELL} -c "./have_ulong64 > ll_tmp 2>/dev/null" \
+ >/dev/null 2>&1; true
+ -@if [ -s ll_tmp ]; then \
+ cat ll_tmp >> longlong.h; \
+ else \
+ echo '#undef HAVE_64BIT_LONG_LONG /* no */' >> longlong.h; \
+ fi
+ @echo '' >> longlong.h
+ @echo '/*' >> longlong.h
+ @echo ' * NO64BIT_LONG_LONG undef HAVE_64BIT_LONG_LONG' >> longlong.h
+ @echo ' */' >> longlong.h
+ @echo '#if defined(NO64BIT_LONG_LONG)' >> longlong.h
+ @echo '#undef HAVE_64BIT_LONG_LONG' >> longlong.h
+ @echo '#endif /* NO64BIT_LONG_LONG */' >> longlong.h
+ @echo '' >> longlong.h
+ @echo '#endif /* !__LONGLONG_H__ */' >> longlong.h
+ -@rm -f have_ulong64 have_ulong64.o ll_tmp
+ @echo 'longlong.h formed'
+
+# utilities
+#
+install: all
+ -@if [ -d "${DESTBIN}" ]; then \
+ echo " mkdir -p ${DESTBIN}"; \
+ mkdir -p ${DESTBIN}; \
+ fi
+ -@if [ -d "${DESTLIB}" ]; then \
+ echo " mkdir -p ${DESTLIB}"; \
+ mkdir -p ${DESTLIB}; \
+ fi
+ -@if [ -d "${DESTINC}" ]; then \
+ echo " mkdir -p ${DESTINC}"; \
+ mkdir -p ${DESTINC}; \
+ fi
+ ${INSTALL} -m 0755 ${PROGS} ${DESTBIN}
+ ${INSTALL} -m 0644 ${LIBS} ${DESTLIB}
+ ${RANLIB} ${DESTLIB}/libfnv.a
+ ${INSTALL} -m 0644 ${HSRC} ${DESTINC}
+ @# remove osolete programs
+ for i in ${OBSOLETE_PROGS}; do \
+ if [ -f "${DESTBIN}/$$i" ]; then \
+ echo "rm -f ${DESTBIN}/$$i"; \
+ rm -f "${DESTBIN}/$$i"; \
+ fi; \
+ done
+
+clean:
+ -rm -f have_ulong64 have_ulong64.o ll_tmp ll_tmp2 longlong.h
+ -rm -f ${LIBOBJ}
+ -rm -f ${OTHEROBJ}
+
+clobber: clean
+ -rm -f ${TARGETS}
+ -rm -f ${OBSOLETE_PROGS} lltmp lltmp2 ll_tmp
+ -rm -f ${NO64BIT_SRC}
+ -rm -f ${NO64BIT_OBJ}
+ -rm -f ${NO64BIT_PROGS}
+ -rm -f vector.c
+
+check: ${PROGS}
+ @echo -n "FNV-0 32 bit tests: "
+ @./fnv032 -t 1 -v
+ @echo -n "FNV-1 32 bit tests: "
+ @./fnv132 -t 1 -v
+ @echo -n "FNV-1a 32 bit tests: "
+ @./fnv1a32 -t 1 -v
+ @echo -n "FNV-0 64 bit tests: "
+ @./fnv064 -t 1 -v
+ @echo -n "FNV-1 64 bit tests: "
+ @./fnv164 -t 1 -v
+ @echo -n "FNV-1a 64 bit tests: "
+ @./fnv1a64 -t 1 -v
+
+###############################
+# generate test vector source #
+###############################
+
+no64bit_fnv64.c: fnv64.c
+ -rm -f $@
+ -cp -f $? $@
+
+no64bit_hash_64.c: hash_64.c
+ -rm -f $@
+ -cp -f $? $@
+
+no64bit_hash_64a.c: hash_64a.c
+ -rm -f $@
+ -cp -f $? $@
+
+no64bit_test_fnv.c: test_fnv.c
+ -rm -f $@
+ -cp -f $? $@
+
+no64bit_fnv64.o: no64bit_fnv64.c longlong.h fnv.h
+ ${CC} ${CFLAGS} -DNO64BIT_LONG_LONG no64bit_fnv64.c -c
+
+no64bit_hash_64.o: no64bit_hash_64.c longlong.h fnv.h
+ ${CC} ${CFLAGS} -DNO64BIT_LONG_LONG no64bit_hash_64.c -c
+
+no64bit_hash_64a.o: no64bit_hash_64a.c longlong.h fnv.h
+ ${CC} ${CFLAGS} -DNO64BIT_LONG_LONG no64bit_hash_64a.c -c
+
+no64bit_test_fnv.o: no64bit_test_fnv.c longlong.h fnv.h
+ ${CC} ${CFLAGS} -DNO64BIT_LONG_LONG no64bit_test_fnv.c -c
+
+no64bit_fnv064: no64bit_fnv64.o no64bit_hash_64.o \
+ no64bit_hash_64a.o no64bit_test_fnv.o
+ ${CC} ${CFLAGS} no64bit_fnv64.o no64bit_hash_64.o \
+ no64bit_hash_64a.o no64bit_test_fnv.o -o $@
+
+no64bit_fnv164: no64bit_fnv064
+ -rm -f $@
+ -cp -f $? $@
+
+no64bit_fnv1a64: no64bit_fnv064
+ -rm -f $@
+ -cp -f $? $@
+
+vector.c: ${PROGS} ${NO64BIT_PROGS}
+ -rm -f $@
+ echo '/* start of output generated by make $@ */' >> $@
+ echo '' >> $@
+ #@
+ echo '/* FNV-0 32 bit test vectors */' >> $@
+ ./fnv032 -t 0 >> $@
+ echo '' >> $@
+ #@
+ echo '/* FNV-1 32 bit test vectors */' >> $@
+ ./fnv132 -t 0 >> $@
+ echo '' >> $@
+ #@
+ echo '/* FNV-1a 32 bit test vectors */' >> $@
+ ./fnv1a32 -t 0 >> $@
+ echo '' >> $@
+ #@
+ echo '/* FNV-0 64 bit test vectors */' >> $@
+ echo '#if defined(HAVE_64BIT_LONG_LONG)' >> $@
+ ./fnv064 -t 0 >> $@
+ echo '#else /* HAVE_64BIT_LONG_LONG */' >> $@
+ ./no64bit_fnv064 -t 0 >> $@
+ echo '#endif /* HAVE_64BIT_LONG_LONG */' >> $@
+ echo '' >> $@
+ #@
+ echo '/* FNV-1 64 bit test vectors */' >> $@
+ echo '#if defined(HAVE_64BIT_LONG_LONG)' >> $@
+ ./fnv164 -t 0 >> $@
+ echo '#else /* HAVE_64BIT_LONG_LONG */' >> $@
+ ./no64bit_fnv164 -t 0 >> $@
+ echo '#endif /* HAVE_64BIT_LONG_LONG */' >> $@
+ echo '' >> $@
+ #@
+ echo '/* FNV-1a 64 bit test vectors */' >> $@
+ echo '#if defined(HAVE_64BIT_LONG_LONG)' >> $@
+ ./fnv1a64 -t 0 >> $@
+ echo '#else /* HAVE_64BIT_LONG_LONG */' >> $@
+ ./no64bit_fnv1a64 -t 0 >> $@
+ echo '#endif /* HAVE_64BIT_LONG_LONG */' >> $@
+ echo '' >> $@
+ #@
+ echo '/* end of output generated by make $@ */' >> $@
diff --git a/lib/fnv/README b/lib/fnv/README
new file mode 100644
index 0000000000..60aa9aaf61
--- /dev/null
+++ b/lib/fnv/README
@@ -0,0 +1,158 @@
+#=====================#
+# Fowler/Noll/Vo hash #
+#=====================#
+
+The basis of this hash algorithm was taken from an idea sent
+as reviewer comments to the IEEE POSIX P1003.2 committee by:
+
+ Phong Vo (http://www.research.att.com/info/kpv)
+ Glenn Fowler (http://www.research.att.com/~gsf/)
+
+In a subsequent ballot round:
+
+ Landon Curt Noll (http://www.isthe.com/chongo)
+
+improved on their algorithm. Some people tried this hash
+and found that it worked rather well. In an EMail message
+to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
+
+FNV hashes are designed to be fast while maintaining a low
+collision rate. The FNV speed allows one to quickly hash lots
+of data while maintaining a reasonable collision rate. See:
+
+ http://www.isthe.com/chongo/tech/comp/fnv/index.html
+
+for more details as well as other forms of the FNV hash.
+Comments, questions, bug fixes and suggestions welcome at
+the address given in the above URL.
+
+
+#==================#
+# FNV hash utility #
+#==================#
+
+Two hash utilities (32 bit and 64 bit) are provided:
+
+ fnv032 [-b bcnt] [-m] [-s arg] [-t code] [-v] [arg ...]
+ fnv132 [-b bcnt] [-m] [-s arg] [-t code] [-v] [arg ...]
+ fnv1a32 [-b bcnt] [-m] [-s arg] [-t code] [-v] [arg ...]
+
+ fnv064 [-b bcnt] [-m] [-s arg] [-t code] [-v] [arg ...]
+ fnv164 [-b bcnt] [-m] [-s arg] [-t code] [-v] [arg ...]
+ fnv1a64 [-b bcnt] [-m] [-s arg] [-t code] [-v] [arg ...]
+
+ -b bcnt mask off all but the lower bcnt bits (default: 32)
+ -m multiple hashes, one per line for each arg
+ -s hash arg as a string (ignoring terminating NUL bytes)
+ -t code 0 ==> generate test vectors, 1 ==> test FNV hash
+ -v verbose mode, print arg after hash (implies -m)
+ arg string (if -s was given) or filename (default stdin)
+
+The fnv032, fnv064 implement the historic FNV-0 hash.
+The fnv132, fnv164 implement the recommended FNV-1 hash.
+The fnv1a32, fnv1a64 implement the recommended FNV-1a hash.
+
+This is the original historic FNV algorithm with a 0 offset basis.
+It is recommended that FNV-1, with a non-0 offset basis be used instead.
+
+To test FNV hashes, try:
+
+ fnv032 -t 1 -v
+ fnv132 -t 1 -v
+ fnv1a32 -t 1 -v
+
+ fnv064 -t 1 -v
+ fnv164 -t 1 -v
+ fnv1a64 -t 1 -v
+
+If you are compiling, try:
+
+ make check
+
+
+#==================#
+# FNV hash library #
+#==================#
+
+The libfnv.a library implements both a 32 bit and a 64 bit FNV hash
+on collections of bytes, a NUL terminated strings or on an open file
+descriptor.
+
+Here is the 32 bit FNV 1 hash:
+
+ Fnv32_t fnv_32_buf(void *buf, int len, Fnv32_t hval); /* byte buf */
+ Fnv32_t fnv_32_str(char *string, Fnv32_t hval); /* string */
+
+Here is the 32 bit FNV 1a hash:
+
+ Fnv32_t fnv_32a_buf(void *buf, int len, Fnv32_t hval); /* byte buf */
+ Fnv32_t fnv_32a_str(char *string, Fnv32_t hval); /* string */
+
+Here is the 64 bit FNV 1 hash:
+
+ Fnv64_t fnv_64_buf(void *buf, int len, Fnv64_t hval); /* byte buf */
+ Fnv64_t fnv_64_str(char *string, Fnv64_t hval); /* string */
+
+Here is the 64 bit FNV 1a hash:
+
+ Fnv64_t fnv_64a_buf(void *buf, int len, Fnv64_t hval); /* byte buf */
+ Fnv64_t fnv_64a_str(char *string, Fnv64_t hval); /* string */
+
+On the first call to a hash function, one must supply the initial basis
+that is appropriate for the hash in question:
+
+ FNV-0: (not recommended)
+
+ FNV0_32_INIT /* 32 bit FNV-0 initial basis */
+ FNV0_64_INIT /* 64 bit FNV-0 initial basis */
+
+ FNV-1:
+
+ FNV1_32_INIT /* 32 bit FNV-1 initial basis */
+ FNV1_64_INIT /* 64 bit FNV-1 initial basis */
+
+ FNV-1a:
+
+ FNV1A_32_INIT /* 32 bit FNV-1a initial basis */
+ FNV1A_64_INIT /* 64 bit FNV-1a initial basis */
+
+For example to perform a 64 bit FNV-1 hash:
+
+ #include "fnv.h"
+
+ Fnv64_t hash_val;
+
+ hash_val = fnv_64_str("a string", FNV1_64_INIT);
+ hash_val = fnv_64_str("more string", hash_val);
+
+produces the same final hash value as:
+
+ hash_val = fnv_64_str("a stringmore string", FNV1_64_INIT);
+
+NOTE: If one used 'FNV0_64_INIT' instead of 'FNV1_64_INIT' one would get the
+ historic FNV-0 hash instead recommended FNV-1 hash.
+
+To perform a 32 bit FNV-1 hash:
+
+ #include "fnv.h"
+
+ Fnv32_t hash_val;
+
+ hash_val = fnv_32_buf(buf, length_of_buf, FNV1_32_INIT);
+ hash_val = fnv_32_str("more data", hash_val);
+
+To perform a 64 bit FNV-1a hash:
+
+ #include "fnv.h"
+
+ Fnv64_t hash_val;
+
+ hash_val = fnv_64a_buf(buf, length_of_buf, FNV1_64_INIT);
+ hash_val = fnv_64a_str("more data", hash_val);
+
+=-=
+
+chongo <Landon Curt Noll> /\oo/\
+http://www.isthe.com/chongo
+
+Share and Enjoy!
diff --git a/lib/fnv/fnv.h b/lib/fnv/fnv.h
new file mode 100644
index 0000000000..5249366731
--- /dev/null
+++ b/lib/fnv/fnv.h
@@ -0,0 +1,250 @@
+/*
+ * fnv - Fowler/Noll/Vo- hash code
+ *
+ * @(#) $Revision: 5.4 $
+ * @(#) $Id: fnv.h,v 5.4 2009/07/30 22:49:13 chongo Exp $
+ * @(#) $Source: /usr/local/src/cmd/fnv/RCS/fnv.h,v $
+ *
+ ***
+ *
+ * Fowler/Noll/Vo- hash
+ *
+ * The basis of this hash algorithm was taken from an idea sent
+ * as reviewer comments to the IEEE POSIX P1003.2 committee by:
+ *
+ * Phong Vo (http://www.research.att.com/info/kpv/)
+ * Glenn Fowler (http://www.research.att.com/~gsf/)
+ *
+ * In a subsequent ballot round:
+ *
+ * Landon Curt Noll (http://www.isthe.com/chongo/)
+ *
+ * improved on their algorithm. Some people tried this hash
+ * and found that it worked rather well. In an EMail message
+ * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
+ *
+ * FNV hashes are designed to be fast while maintaining a low
+ * collision rate. The FNV speed allows one to quickly hash lots
+ * of data while maintaining a reasonable collision rate. See:
+ *
+ * http://www.isthe.com/chongo/tech/comp/fnv/index.html
+ *
+ * for more details as well as other forms of the FNV hash.
+ *
+ ***
+ *
+ * NOTE: The FNV-0 historic hash is not recommended. One should use
+ * the FNV-1 hash instead.
+ *
+ * To use the 32 bit FNV-0 historic hash, pass FNV0_32_INIT as the
+ * Fnv32_t hashval argument to fnv_32_buf() or fnv_32_str().
+ *
+ * To use the 64 bit FNV-0 historic hash, pass FNV0_64_INIT as the
+ * Fnv64_t hashval argument to fnv_64_buf() or fnv_64_str().
+ *
+ * To use the recommended 32 bit FNV-1 hash, pass FNV1_32_INIT as the
+ * Fnv32_t hashval argument to fnv_32_buf() or fnv_32_str().
+ *
+ * To use the recommended 64 bit FNV-1 hash, pass FNV1_64_INIT as the
+ * Fnv64_t hashval argument to fnv_64_buf() or fnv_64_str().
+ *
+ * To use the recommended 32 bit FNV-1a hash, pass FNV1_32A_INIT as the
+ * Fnv32_t hashval argument to fnv_32a_buf() or fnv_32a_str().
+ *
+ * To use the recommended 64 bit FNV-1a hash, pass FNV1A_64_INIT as the
+ * Fnv64_t hashval argument to fnv_64a_buf() or fnv_64a_str().
+ *
+ ***
+ *
+ * Please do not copyright this code. This code is in the public domain.
+ *
+ * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * By:
+ * chongo <Landon Curt Noll> /\oo/\
+ * http://www.isthe.com/chongo/
+ *
+ * Share and Enjoy! :-)
+ */
+
+#if !defined(__FNV_H__)
+#define __FNV_H__
+
+#include <stdlib.h>
+#include <stdint.h>
+
+#define FNV_VERSION "5.0.2" /* @(#) FNV Version */
+
+
+/*
+ * 32 bit FNV-0 hash type
+ */
+typedef uint32_t Fnv32_t;
+
+
+/*
+ * 32 bit FNV-0 zero initial basis
+ *
+ * This historic hash is not recommended. One should use
+ * the FNV-1 hash and initial basis instead.
+ */
+#define FNV0_32_INIT ((Fnv32_t)0)
+
+
+/*
+ * 32 bit FNV-1 and FNV-1a non-zero initial basis
+ *
+ * The FNV-1 initial basis is the FNV-0 hash of the following 32 octets:
+ *
+ * chongo <Landon Curt Noll> /\../\
+ *
+ * NOTE: The \'s above are not back-slashing escape characters.
+ * They are literal ASCII backslash 0x5c characters.
+ *
+ * NOTE: The FNV-1a initial basis is the same value as FNV-1 by definition.
+ */
+#define FNV1_32_INIT ((Fnv32_t)0x811c9dc5)
+#define FNV1_32A_INIT FNV1_32_INIT
+
+
+/*
+ * determine how 64 bit unsigned values are represented
+ */
+#include "longlong.h"
+
+
+/*
+ * 64 bit FNV-0 hash
+ */
+#if defined(HAVE_64BIT_LONG_LONG)
+typedef uint64_t Fnv64_t;
+#else /* HAVE_64BIT_LONG_LONG */
+typedef struct {
+ uint32_t w32[2]; /* w32[0] is low order, w32[1] is high order word */
+} Fnv64_t;
+#endif /* HAVE_64BIT_LONG_LONG */
+
+
+/*
+ * 64 bit FNV-0 zero initial basis
+ *
+ * This historic hash is not recommended. One should use
+ * the FNV-1 hash and initial basis instead.
+ */
+#if defined(HAVE_64BIT_LONG_LONG)
+#define FNV0_64_INIT ((Fnv64_t)0)
+#else /* HAVE_64BIT_LONG_LONG */
+extern const Fnv64_t fnv0_64_init;
+#define FNV0_64_INIT (fnv0_64_init)
+#endif /* HAVE_64BIT_LONG_LONG */
+
+
+/*
+ * 64 bit FNV-1 non-zero initial basis
+ *
+ * The FNV-1 initial basis is the FNV-0 hash of the following 32 octets:
+ *
+ * chongo <Landon Curt Noll> /\../\
+ *
+ * NOTE: The \'s above are not back-slashing escape characters.
+ * They are literal ASCII backslash 0x5c characters.
+ *
+ * NOTE: The FNV-1a initial basis is the same value as FNV-1 by definition.
+ */
+#if defined(HAVE_64BIT_LONG_LONG)
+#define FNV1_64_INIT ((Fnv64_t)0xcbf29ce484222325ULL)
+#define FNV1A_64_INIT FNV1_64_INIT
+#else /* HAVE_64BIT_LONG_LONG */
+extern const fnv1_64_init;
+extern const Fnv64_t fnv1a_64_init;
+#define FNV1_64_INIT (fnv1_64_init)
+#define FNV1A_64_INIT (fnv1a_64_init)
+#endif /* HAVE_64BIT_LONG_LONG */
+
+
+/*
+ * hash types
+ */
+enum fnv_type {
+ FNV_NONE = 0, /* invalid FNV hash type */
+ FNV0_32 = 1, /* FNV-0 32 bit hash */
+ FNV1_32 = 2, /* FNV-1 32 bit hash */
+ FNV1a_32 = 3, /* FNV-1a 32 bit hash */
+ FNV0_64 = 4, /* FNV-0 64 bit hash */
+ FNV1_64 = 5, /* FNV-1 64 bit hash */
+ FNV1a_64 = 6, /* FNV-1a 64 bit hash */
+};
+
+
+/*
+ * these test vectors are used as part o the FNV test suite
+ */
+struct test_vector {
+ void *buf; /* start of test vector buffer */
+ int len; /* length of test vector */
+};
+struct fnv0_32_test_vector {
+ struct test_vector *test; /* test vector buffer to hash */
+ Fnv32_t fnv0_32; /* expected FNV-0 32 bit hash value */
+};
+struct fnv1_32_test_vector {
+ struct test_vector *test; /* test vector buffer to hash */
+ Fnv32_t fnv1_32; /* expected FNV-1 32 bit hash value */
+};
+struct fnv1a_32_test_vector {
+ struct test_vector *test; /* test vector buffer to hash */
+ Fnv32_t fnv1a_32; /* expected FNV-1a 32 bit hash value */
+};
+struct fnv0_64_test_vector {
+ struct test_vector *test; /* test vector buffer to hash */
+ Fnv64_t fnv0_64; /* expected FNV-0 64 bit hash value */
+};
+struct fnv1_64_test_vector {
+ struct test_vector *test; /* test vector buffer to hash */
+ Fnv64_t fnv1_64; /* expected FNV-1 64 bit hash value */
+};
+struct fnv1a_64_test_vector {
+ struct test_vector *test; /* test vector buffer to hash */
+ Fnv64_t fnv1a_64; /* expected FNV-1a 64 bit hash value */
+};
+
+
+/*
+ * external functions
+ */
+/* hash_32.c */
+extern Fnv32_t fnv_32_buf(void *buf, size_t len, Fnv32_t hashval);
+extern Fnv32_t fnv_32_str(char *buf, Fnv32_t hashval);
+
+/* hash_32a.c */
+extern Fnv32_t fnv_32a_buf(void *buf, size_t len, Fnv32_t hashval);
+extern Fnv32_t fnv_32a_str(char *buf, Fnv32_t hashval);
+
+/* hash_64.c */
+extern Fnv64_t fnv_64_buf(void *buf, size_t len, Fnv64_t hashval);
+extern Fnv64_t fnv_64_str(char *buf, Fnv64_t hashval);
+
+/* hash_64a.c */
+extern Fnv64_t fnv_64a_buf(void *buf, size_t len, Fnv64_t hashval);
+extern Fnv64_t fnv_64a_str(char *buf, Fnv64_t hashval);
+
+/* test_fnv.c */
+extern struct test_vector fnv_test_str[];
+extern struct fnv0_32_test_vector fnv0_32_vector[];
+extern struct fnv1_32_test_vector fnv1_32_vector[];
+extern struct fnv1a_32_test_vector fnv1a_32_vector[];
+extern struct fnv0_64_test_vector fnv0_64_vector[];
+extern struct fnv1_64_test_vector fnv1_64_vector[];
+extern struct fnv1a_64_test_vector fnv1a_64_vector[];
+extern void unknown_hash_type(char *prog, enum fnv_type type, int code);
+extern void print_fnv32(Fnv32_t hval, Fnv32_t mask, int verbose, char *arg);
+extern void print_fnv64(Fnv64_t hval, Fnv64_t mask, int verbose, char *arg);
+
+
+#endif /* __FNV_H__ */
diff --git a/lib/fnv/fnv32.c b/lib/fnv/fnv32.c
new file mode 100644
index 0000000000..58c61f03fc
--- /dev/null
+++ b/lib/fnv/fnv32.c
@@ -0,0 +1,467 @@
+/*
+ * fnv32 - 32 bit Fowler/Noll/Vo hash of a buffer or string
+ *
+ * @(#) $Revision: 5.5 $
+ * @(#) $Id: fnv32.c,v 5.5 2012/03/21 01:38:12 chongo Exp $
+ * @(#) $Source: /usr/local/src/cmd/fnv/RCS/fnv32.c,v $
+ *
+ ***
+ *
+ * Fowler/Noll/Vo hash
+ *
+ * The basis of this hash algorithm was taken from an idea sent
+ * as reviewer comments to the IEEE POSIX P1003.2 committee by:
+ *
+ * Phong Vo (http://www.research.att.com/info/kpv/)
+ * Glenn Fowler (http://www.research.att.com/~gsf/)
+ *
+ * In a subsequent ballot round:
+ *
+ * Landon Curt Noll (http://www.isthe.com/chongo/)
+ *
+ * improved on their algorithm. Some people tried this hash
+ * and found that it worked rather well. In an EMail message
+ * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
+ *
+ * FNV hashes are designed to be fast while maintaining a low
+ * collision rate. The FNV speed allows one to quickly hash lots
+ * of data while maintaining a reasonable collision rate. See:
+ *
+ * http://www.isthe.com/chongo/tech/comp/fnv/index.html
+ *
+ * for more details as well as other forms of the FNV hash.
+ *
+ ***
+ *
+ * Please do not copyright this code. This code is in the public domain.
+ *
+ * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * By:
+ * chongo <Landon Curt Noll> /\oo/\
+ * http://www.isthe.com/chongo/
+ *
+ * Share and Enjoy! :-)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include "longlong.h"
+#include "fnv.h"
+
+#define WIDTH 32 /* bit width of hash */
+
+#define BUF_SIZE (32*1024) /* number of bytes to hash at a time */
+
+static char *usage =
+"usage: %s [-b bcnt] [-m] [-s arg] [-t code] [-v] [arg ...]\n"
+"\n"
+"\t-b bcnt\tmask off all but the lower bcnt bits (default 32)\n"
+"\t-m\tmultiple hashes, one per line for each arg\n"
+"\t-s\thash arg as a string (ignoring terminating NUL bytes)\n"
+"\t-t code\t test hash code: (0 ==> generate test vectors\n"
+"\t\t\t\t 1 ==> validate against FNV test vectors)\n"
+"\t-v\tverbose mode, print arg after hash (implies -m)\n"
+"\targ\tstring (if -s was given) or filename (default stdin)\n"
+"\n"
+"\tNOTE: Programs that begin with fnv0 implement the FNV-0 hash.\n"
+"\t The FNV-0 hash is historic FNV algorithm that is now deprecated.\n"
+"\n"
+"\tSee http://www.isthe.com/chongo/tech/comp/fnv/index.html for more info.\n"
+"\n"
+"\t@(#) FNV Version: %s\n";
+static char *program; /* our name */
+
+
+/*
+ * test_fnv32 - test the FNV32 hash
+ *
+ * given:
+ * hash_type type of FNV hash to test
+ * init_hval initial hash value
+ * mask lower bit mask
+ * v_flag 1 => print test failure info on stderr
+ * code 0 ==> generate FNV test vectors
+ * 1 ==> validate against FNV test vectors
+ *
+ * returns: 0 ==> OK, else test vector failure number
+ */
+static int
+test_fnv32(enum fnv_type hash_type, Fnv32_t init_hval,
+ Fnv32_t mask, int v_flag, int code)
+{
+ struct test_vector *t; /* FNV test vestor */
+ Fnv32_t hval; /* current hash value */
+ int tstnum; /* test vector that failed, starting at 1 */
+
+ /*
+ * print preamble if generating test vectors
+ */
+ if (code == 0) {
+ switch (hash_type) {
+ case FNV0_32:
+ printf("struct fnv0_32_test_vector fnv0_32_vector[] = {\n");
+ break;
+ case FNV1_32:
+ printf("struct fnv1_32_test_vector fnv1_32_vector[] = {\n");
+ break;
+ case FNV1a_32:
+ printf("struct fnv1a_32_test_vector fnv1a_32_vector[] = {\n");
+ break;
+ default:
+ unknown_hash_type(program, hash_type, 12); /* exit(12) */
+ /*NOTREACHED*/
+ }
+ }
+
+ /*
+ * loop thru all test vectors
+ */
+ for (t = fnv_test_str, tstnum = 1; t->buf != NULL; ++t, ++tstnum) {
+
+ /*
+ * compute the FNV hash
+ */
+ hval = init_hval;
+ switch (hash_type) {
+ case FNV0_32:
+ case FNV1_32:
+ hval = fnv_32_buf(t->buf, t->len, hval);
+ break;
+ case FNV1a_32:
+ hval = fnv_32a_buf(t->buf, t->len, hval);
+ break;
+ default:
+ unknown_hash_type(program, hash_type, 13); /* exit(13) */
+ /*NOTREACHED*/
+ }
+
+ /*
+ * print the vector
+ */
+ switch (code) {
+ case 0: /* generate the test vector */
+ printf(" { &fnv_test_str[%d], (Fnv32_t) 0x%08lxUL },\n",
+ tstnum-1, hval & mask);
+ break;
+ case 1: /* validate against test vector */
+ switch (hash_type) {
+ case FNV0_32:
+ if ((hval&mask) != (fnv0_32_vector[tstnum-1].fnv0_32 & mask)) {
+ if (v_flag) {
+ fprintf(stderr, "%s: failed fnv0_32 test # %d\n",
+ program, tstnum);
+ fprintf(stderr, "%s: test # 1 is 1st test\n", program);
+ fprintf(stderr,
+ "%s: expected 0x%08lx != generated: 0x%08lx\n",
+ program, (hval&mask),
+ (fnv0_32_vector[tstnum-1].fnv0_32 & mask));
+ }
+ return tstnum;
+ }
+ break;
+ case FNV1_32:
+ if ((hval&mask) != (fnv1_32_vector[tstnum-1].fnv1_32 & mask)) {
+ if (v_flag) {
+ fprintf(stderr, "%s: failed fnv1_32 test # %d\n",
+ program, tstnum);
+ fprintf(stderr, "%s: test # 1 is 1st test\n", program);
+ fprintf(stderr,
+ "%s: expected 0x%08lx != generated: 0x%08lx\n",
+ program, (hval&mask),
+ (fnv1_32_vector[tstnum-1].fnv1_32 & mask));
+ }
+ return tstnum;
+ }
+ break;
+ case FNV1a_32:
+ if ((hval&mask) != (fnv1a_32_vector[tstnum-1].fnv1a_32 &mask)) {
+ if (v_flag) {
+ fprintf(stderr, "%s: failed fnv1a_32 test # %d\n",
+ program, tstnum);
+ fprintf(stderr, "%s: test # 1 is 1st test\n", program);
+ fprintf(stderr,
+ "%s: expected 0x%08lx != generated: 0x%08lx\n",
+ program, (hval&mask),
+ (fnv1a_32_vector[tstnum-1].fnv1a_32 & mask));
+ }
+ return tstnum;
+ }
+ break;
+ }
+ break;
+ default:
+ fprintf(stderr, "%s: -m %d not implemented yet\n", program, code);
+ exit(14);
+ }
+ }
+
+ /*
+ * print completion if generating test vectors
+ */
+ if (code == 0) {
+ printf(" { NULL, 0 }\n");
+ printf("};\n");
+ }
+
+ /*
+ * no failures, return code 0 ==> all OK
+ */
+ return 0;
+}
+
+
+/*
+ * main - the main function
+ *
+ * See the above usage for details.
+ */
+int
+main(int argc, char *argv[])
+{
+ char buf[BUF_SIZE+1]; /* read buffer */
+ int readcnt; /* number of characters written */
+ Fnv32_t hval; /* current hash value */
+ int s_flag = 0; /* 1 => -s was given, hash args as strings */
+ int m_flag = 0; /* 1 => print multiple hashes, one per arg */
+ int v_flag = 0; /* 1 => verbose hash print */
+ int b_flag = WIDTH; /* -b flag value */
+ int t_flag = -1; /* FNV test vector code (0=>print, 1=>test) */
+ enum fnv_type hash_type = FNV_NONE; /* type of FNV hash to perform */
+ Fnv32_t bmask; /* mask to apply to output */
+ extern char *optarg; /* option argument */
+ extern int optind; /* argv index of the next arg */
+ int fd; /* open file to process */
+ char *p;
+ int i;
+
+ /*
+ * parse args
+ */
+ program = argv[0];
+ while ((i = getopt(argc, argv, "b:mst:v")) != -1) {
+ switch (i) {
+ case 'b': /* bcnt bit mask count */
+ b_flag = atoi(optarg);
+ break;
+ case 'm': /* print multiple hashes, one per arg */
+ m_flag = 1;
+ break;
+ case 's': /* hash args as strings */
+ s_flag = 1;
+ break;
+ case 't': /* FNV test vector code */
+ t_flag = atoi(optarg);
+ if (t_flag < 0 || t_flag > 1) {
+ fprintf(stderr, "%s: -t code must be 0 or 1\n", program);
+ fprintf(stderr, usage, program, FNV_VERSION);
+ exit(1);
+ }
+ m_flag = 1;
+ break;
+ case 'v': /* verbose hash print */
+ m_flag = 1;
+ v_flag = 1;
+ break;
+ default:
+ fprintf(stderr, usage, program, FNV_VERSION);
+ exit(1);
+ }
+ }
+ /* -t code incompatible with -b, -m and args */
+ if (t_flag >= 0) {
+ if (b_flag != WIDTH) {
+ fprintf(stderr, "%s: -t code incompatible with -b\n", program);
+ exit(2);
+ }
+ if (s_flag != 0) {
+ fprintf(stderr, "%s: -t code incompatible with -s\n", program);
+ exit(3);
+ }
+ if (optind < argc) {
+ fprintf(stderr, "%s: -t code incompatible args\n", program);
+ exit(4);
+ }
+ }
+ /* -s requires at least 1 arg */
+ if (s_flag && optind >= argc) {
+ fprintf(stderr, usage, program, FNV_VERSION);
+ exit(5);
+ }
+ /* limit -b values */
+ if (b_flag < 0 || b_flag > WIDTH) {
+ fprintf(stderr, "%s: -b bcnt: %d must be >= 0 and < %d\n",
+ program, b_flag, WIDTH);
+ exit(6);
+ }
+ if (b_flag == WIDTH) {
+ bmask = (Fnv32_t)0xffffffff;
+ } else {
+ bmask = (Fnv32_t)((1 << b_flag) - 1);
+ }
+
+ /*
+ * start with the initial basis depending on the hash type
+ */
+ p = strrchr(program, '/');
+ if (p == NULL) {
+ p = program;
+ } else {
+ ++p;
+ }
+ if (strcmp(p, "fnv032") == 0) {
+ /* using non-recommended FNV-0 and zero initial basis */
+ hval = FNV0_32_INIT;
+ hash_type = FNV0_32;
+ } else if (strcmp(p, "fnv132") == 0) {
+ /* using FNV-1 and non-zero initial basis */
+ hval = FNV1_32_INIT;
+ hash_type = FNV1_32;
+ } else if (strcmp(p, "fnv1a32") == 0) {
+ /* start with the FNV-1a initial basis */
+ hval = FNV1_32A_INIT;
+ hash_type = FNV1a_32;
+ } else {
+ fprintf(stderr, "%s: unknown program name, unknown hash type\n",
+ program);
+ exit(7);
+ }
+
+ /*
+ * FNV test vector processing, if needed
+ */
+ if (t_flag >= 0) {
+ int code; /* test vector that failed, starting at 1 */
+
+ /*
+ * perform all tests
+ */
+ code = test_fnv32(hash_type, hval, bmask, v_flag, t_flag);
+
+ /*
+ * evaluate the tests
+ */
+ if (code == 0) {
+ if (v_flag) {
+ printf("passed\n");
+ }
+ exit(0);
+ } else {
+ printf("failed vector (1 is 1st test): %d\n", code);
+ exit(8);
+ }
+ }
+
+ /*
+ * string hashing
+ */
+ if (s_flag) {
+
+ /* hash any other strings */
+ for (i=optind; i < argc; ++i) {
+ switch (hash_type) {
+ case FNV0_32:
+ case FNV1_32:
+ hval = fnv_32_str(argv[i], hval);
+ break;
+ case FNV1a_32:
+ hval = fnv_32a_str(argv[i], hval);
+ break;
+ default:
+ unknown_hash_type(program, hash_type, 9); /* exit(9) */
+ /*NOTREACHED*/
+ }
+ if (m_flag) {
+ print_fnv32(hval, bmask, v_flag, argv[i]);
+ }
+ }
+
+
+ /*
+ * file hashing
+ */
+ } else {
+
+ /*
+ * case: process only stdin
+ */
+ if (optind >= argc) {
+
+ /* case: process only stdin */
+ while ((readcnt = read(0, buf, BUF_SIZE)) > 0) {
+ switch (hash_type) {
+ case FNV0_32:
+ case FNV1_32:
+ hval = fnv_32_buf(buf, readcnt, hval);
+ break;
+ case FNV1a_32:
+ hval = fnv_32a_buf(buf, readcnt, hval);
+ break;
+ default:
+ unknown_hash_type(program, hash_type, 10); /* exit(10) */
+ /*NOTREACHED*/
+ }
+ }
+ if (m_flag) {
+ print_fnv32(hval, bmask, v_flag, "(stdin)");
+ }
+
+ } else {
+
+ /*
+ * process any other files
+ */
+ for (i=optind; i < argc; ++i) {
+
+ /* open the file */
+ fd = open(argv[i], O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "%s: unable to open file: %s\n",
+ program, argv[i]);
+ exit(4);
+ }
+
+ /* hash the file */
+ while ((readcnt = read(fd, buf, BUF_SIZE)) > 0) {
+ switch (hash_type) {
+ case FNV0_32:
+ case FNV1_32:
+ hval = fnv_32_buf(buf, readcnt, hval);
+ break;
+ case FNV1a_32:
+ hval = fnv_32a_buf(buf, readcnt, hval);
+ break;
+ default:
+ unknown_hash_type(program, hash_type, 11);/* exit(11) */
+ /*NOTREACHED*/
+ }
+ }
+
+ /* finish processing the file */
+ if (m_flag) {
+ print_fnv32(hval, bmask, v_flag, argv[i]);
+ }
+ close(fd);
+ }
+ }
+ }
+
+ /*
+ * report hash and exit
+ */
+ if (!m_flag) {
+ print_fnv32(hval, bmask, v_flag, "");
+ }
+ return 0; /* exit(0); */
+}
diff --git a/lib/fnv/fnv64.c b/lib/fnv/fnv64.c
new file mode 100644
index 0000000000..0662d4d657
--- /dev/null
+++ b/lib/fnv/fnv64.c
@@ -0,0 +1,591 @@
+/*
+ * fnv_64 - 64 bit Fowler/Noll/Vo hash of a buffer or string
+ *
+ * @(#) $Revision: 5.5 $
+ * @(#) $Id: fnv64.c,v 5.5 2012/03/21 01:38:12 chongo Exp $
+ * @(#) $Source: /usr/local/src/cmd/fnv/RCS/fnv64.c,v $
+ *
+ ***
+ *
+ * Fowler/Noll/Vo hash
+ *
+ * The basis of this hash algorithm was taken from an idea sent
+ * as reviewer comments to the IEEE POSIX P1003.2 committee by:
+ *
+ * Phong Vo (http://www.research.att.com/info/kpv/)
+ * Glenn Fowler (http://www.research.att.com/~gsf/)
+ *
+ * In a subsequent ballot round:
+ *
+ * Landon Curt Noll (http://www.isthe.com/chongo/)
+ *
+ * improved on their algorithm. Some people tried this hash
+ * and found that it worked rather well. In an EMail message
+ * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
+ *
+ * FNV hashes are designed to be fast while maintaining a low
+ * collision rate. The FNV speed allows one to quickly hash lots
+ * of data while maintaining a reasonable collision rate. See:
+ *
+ * http://www.isthe.com/chongo/tech/comp/fnv/index.html
+ *
+ * for more details as well as other forms of the FNV hash.
+ *
+ ***
+ *
+ * Please do not copyright this code. This code is in the public domain.
+ *
+ * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * By:
+ * chongo <Landon Curt Noll> /\oo/\
+ * http://www.isthe.com/chongo/
+ *
+ * Share and Enjoy! :-)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include "longlong.h"
+#include "fnv.h"
+
+#define WIDTH 64 /* bit width of hash */
+
+#define BUF_SIZE (32*1024) /* number of bytes to hash at a time */
+
+static char *usage =
+"usage: %s [-b bcnt] [-m] [-s arg] [-t code] [-v] [arg ...]\n"
+"\n"
+"\t-b bcnt\tmask off all but the lower bcnt bits (default 64)\n"
+"\t-m\tmultiple hashes, one per line for each arg\n"
+"\t-s\thash arg as a string (ignoring terminating NUL bytes)\n"
+"\t-t code\t test hash code: (0 ==> generate test vectors\n"
+"\t\t\t\t 1 ==> validate against FNV test vectors)\n"
+"\t-v\tverbose mode, print arg after hash (implies -m)\n"
+"\targ\tstring (if -s was given) or filename (default stdin)\n"
+"\n"
+"\tNOTE: Programs that begin with fnv0 implement the FNV-0 hash.\n"
+"\t The FNV-0 hash is historic FNV algorithm that is now deprecated.\n"
+"\n"
+"\tSee http://www.isthe.com/chongo/tech/comp/fnv/index.html for more info.\n"
+"\n"
+"\t@(#) FNV Version: %s\n";
+static char *program; /* our name */
+
+
+/*
+ * test_fnv64 - test the FNV64 hash
+ *
+ * given:
+ * hash_type type of FNV hash to test
+ * init_hval initial hash value
+ * mask lower bit mask
+ * v_flag 1 => print test failure info on stderr
+ * code 0 ==> generate FNV test vectors
+ * 1 ==> validate against FNV test vectors
+ *
+ * returns: 0 ==> OK, else test vector failure number
+ */
+static int
+test_fnv64(enum fnv_type hash_type, Fnv64_t init_hval,
+ Fnv64_t mask, int v_flag, int code)
+{
+ struct test_vector *t; /* FNV test vestor */
+ Fnv64_t hval; /* current hash value */
+ int tstnum; /* test vector that failed, starting at 1 */
+
+ /*
+ * print preamble if generating test vectors
+ */
+ if (code == 0) {
+ switch (hash_type) {
+ case FNV0_64:
+ printf("struct fnv0_64_test_vector fnv0_64_vector[] = {\n");
+ break;
+ case FNV1_64:
+ printf("struct fnv1_64_test_vector fnv1_64_vector[] = {\n");
+ break;
+ case FNV1a_64:
+ printf("struct fnv1a_64_test_vector fnv1a_64_vector[] = {\n");
+ break;
+ default:
+ unknown_hash_type(program, hash_type, 12); /* exit(12) */
+ /*NOTREACHED*/
+ }
+ }
+
+ /*
+ * loop thru all test vectors
+ */
+ for (t = fnv_test_str, tstnum = 1; t->buf != NULL; ++t, ++tstnum) {
+
+ /*
+ * compute the FNV hash
+ */
+ hval = init_hval;
+ switch (hash_type) {
+ case FNV0_64:
+ case FNV1_64:
+ hval = fnv_64_buf(t->buf, t->len, hval);
+ break;
+ case FNV1a_64:
+ hval = fnv_64a_buf(t->buf, t->len, hval);
+ break;
+ default:
+ unknown_hash_type(program, hash_type, 13); /* exit(13) */
+ /*NOTREACHED*/
+ }
+
+ /*
+ * print the vector
+ */
+#if defined(HAVE_64BIT_LONG_LONG)
+ /*
+ * HAVE_64BIT_LONG_LONG testing
+ */
+ switch (code) {
+ case 0: /* generate the test vector */
+ printf(" { &fnv_test_str[%d], (Fnv64_t) 0x%016llxULL },\n",
+ tstnum-1, hval & mask);
+ break;
+
+ case 1: /* validate against test vector */
+ switch (hash_type) {
+ case FNV0_64:
+ if ((hval&mask) != (fnv0_64_vector[tstnum-1].fnv0_64 & mask)) {
+ if (v_flag) {
+ fprintf(stderr, "%s: failed fnv0_64 test # %d\n",
+ program, tstnum);
+ fprintf(stderr, "%s: test # 1 is 1st test\n", program);
+ fprintf(stderr,
+ "%s: expected 0x%016llx != generated: 0x%016llx\n",
+ program,
+ (hval&mask),
+ (fnv0_64_vector[tstnum-1].fnv0_64 & mask));
+ }
+ return tstnum;
+ }
+ break;
+ case FNV1_64:
+ if ((hval&mask) != (fnv1_64_vector[tstnum-1].fnv1_64 & mask)) {
+ if (v_flag) {
+ fprintf(stderr, "%s: failed fnv1_64 test # %d\n",
+ program, tstnum);
+ fprintf(stderr, "%s: test # 1 is 1st test\n", program);
+ fprintf(stderr,
+ "%s: expected 0x%016llx != generated: 0x%016llx\n",
+ program,
+ (hval&mask),
+ (fnv1_64_vector[tstnum-1].fnv1_64 & mask));
+ }
+ return tstnum;
+ }
+ break;
+ case FNV1a_64:
+ if ((hval&mask) != (fnv1a_64_vector[tstnum-1].fnv1a_64 &mask)) {
+ if (v_flag) {
+ fprintf(stderr, "%s: failed fnv1a_64 test # %d\n",
+ program, tstnum);
+ fprintf(stderr, "%s: test # 1 is 1st test\n", program);
+ fprintf(stderr,
+ "%s: expected 0x%016llx != generated: 0x%016llx\n",
+ program,
+ (hval&mask),
+ (fnv1a_64_vector[tstnum-1].fnv1a_64 & mask));
+ }
+ return tstnum;
+ }
+ break;
+ }
+ break;
+
+ default:
+ fprintf(stderr, "%s: -m %d not implemented yet\n", program, code);
+ exit(14);
+ }
+#else /* HAVE_64BIT_LONG_LONG */
+ /*
+ * non HAVE_64BIT_LONG_LONG testing
+ */
+ switch (code) {
+ case 0: /* generate the test vector */
+ printf(" { &fnv_test_str[%d], "
+ "(Fnv64_t) {0x%08lxUL, 0x%08lxUL} },\n",
+ tstnum-1,
+ (hval.w32[0] & mask.w32[0]),
+ (hval.w32[1] & mask.w32[1]));
+ break;
+
+ case 1: /* validate against test vector */
+ switch (hash_type) {
+ case FNV0_64:
+ if (((hval.w32[0] & mask.w32[0]) !=
+ (fnv0_64_vector[tstnum-1].fnv0_64.w32[0] &
+ mask.w32[0])) &&
+ ((hval.w32[1] & mask.w32[1]) !=
+ (fnv0_64_vector[tstnum-1].fnv0_64.w32[1] &
+ mask.w32[1]))) {
+ if (v_flag) {
+ fprintf(stderr, "%s: failed fnv0_64 test # %d\n",
+ program, tstnum);
+ fprintf(stderr, "%s: test # 1 is 1st test\n", program);
+ fprintf(stderr,
+ "%s: expected 0x%08llx%08llx != "
+ "generated: 0x%08llx%08llx\n",
+ program,
+ (hval.w32[0] & mask.w32[0]),
+ (hval.w32[1] & mask.w32[1]),
+ ((fnv0_64_vector[tstnum-1].fnv0_64.w32[0] &
+ mask.w32[0])),
+ ((fnv0_64_vector[tstnum-1].fnv0_64.w32[1] &
+ mask.w32[1])));
+ }
+ return tstnum;
+ }
+ break;
+ case FNV1_64:
+ if (((hval.w32[0] & mask.w32[0]) !=
+ (fnv1_64_vector[tstnum-1].fnv1_64.w32[0] &
+ mask.w32[0])) &&
+ ((hval.w32[1] & mask.w32[1]) !=
+ (fnv1_64_vector[tstnum-1].fnv1_64.w32[1] &
+ mask.w32[1]))) {
+ if (v_flag) {
+ fprintf(stderr, "%s: failed fnv1_64 test # %d\n",
+ program, tstnum);
+ fprintf(stderr, "%s: test # 1 is 1st test\n", program);
+ fprintf(stderr,
+ "%s: expected 0x%08llx%08llx != "
+ "generated: 0x%08llx%08llx\n",
+ program,
+ (hval.w32[0] & mask.w32[0]),
+ (hval.w32[1] & mask.w32[1]),
+ ((fnv1_64_vector[tstnum-1].fnv1_64.w32[0] &
+ mask.w32[0])),
+ ((fnv1_64_vector[tstnum-1].fnv1_64.w32[1] &
+ mask.w32[1])));
+ }
+ return tstnum;
+ }
+ break;
+ case FNV1a_64:
+ if (((hval.w32[0] & mask.w32[0]) !=
+ (fnv1a_64_vector[tstnum-1].fnv1a_64.w32[0] &
+ mask.w32[0])) &&
+ ((hval.w32[1] & mask.w32[1]) !=
+ (fnv1a_64_vector[tstnum-1].fnv1a_64.w32[1] &
+ mask.w32[1]))) {
+ if (v_flag) {
+ fprintf(stderr, "%s: failed fnv1a_64 test # %d\n",
+ program, tstnum);
+ fprintf(stderr, "%s: test # 1 is 1st test\n", program);
+ fprintf(stderr,
+ "%s: expected 0x%08llx%08llx != "
+ "generated: 0x%08llx%08llx\n",
+ program,
+ (hval.w32[0] & mask.w32[0]),
+ (hval.w32[1] & mask.w32[1]),
+ ((fnv1a_64_vector[tstnum-1].fnv1a_64.w32[0] &
+ mask.w32[0])),
+ ((fnv1a_64_vector[tstnum-1].fnv1a_64.w32[1] &
+ mask.w32[1])));
+ }
+ return tstnum;
+ }
+ break;
+ }
+ break;
+
+ default:
+ fprintf(stderr, "%s: -m %d not implemented yet\n", program, code);
+ exit(15);
+ }
+#endif /* HAVE_64BIT_LONG_LONG */
+ }
+
+ /*
+ * print completion if generating test vectors
+ */
+ if (code == 0) {
+#if defined(HAVE_64BIT_LONG_LONG)
+ printf(" { NULL, (Fnv64_t) 0 }\n");
+#else /* HAVE_64BIT_LONG_LONG */
+ printf(" { NULL, (Fnv64_t) {0,0} }\n");
+#endif /* HAVE_64BIT_LONG_LONG */
+ printf("};\n");
+ }
+
+ /*
+ * no failures, return code 0 ==> all OK
+ */
+ return 0;
+}
+
+
+/*
+ * main - the main function
+ *
+ * See the above usage for details.
+ */
+int
+main(int argc, char *argv[])
+{
+ char buf[BUF_SIZE+1]; /* read buffer */
+ int readcnt; /* number of characters written */
+ Fnv64_t hval; /* current hash value */
+ int s_flag = 0; /* 1 => -s was given, hash args as strings */
+ int m_flag = 0; /* 1 => print multiple hashes, one per arg */
+ int v_flag = 0; /* 1 => verbose hash print */
+ int b_flag = WIDTH; /* -b flag value */
+ int t_flag = -1; /* FNV test vector code (0=>print, 1=>test) */
+ enum fnv_type hash_type = FNV_NONE; /* type of FNV hash to perform */
+ Fnv64_t bmask; /* mask to apply to output */
+ extern char *optarg; /* option argument */
+ extern int optind; /* argv index of the next arg */
+ int fd; /* open file to process */
+ char *p;
+ int i;
+
+ /*
+ * parse args
+ */
+ program = argv[0];
+ while ((i = getopt(argc, argv, "b:mst:v")) != -1) {
+ switch (i) {
+ case 'b': /* bcnt bit mask count */
+ b_flag = atoi(optarg);
+ break;
+ case 'm': /* print multiple hashes, one per arg */
+ m_flag = 1;
+ break;
+ case 's': /* hash args as strings */
+ s_flag = 1;
+ break;
+ case 't': /* FNV test vector code */
+ t_flag = atoi(optarg);
+ if (t_flag < 0 || t_flag > 1) {
+ fprintf(stderr, "%s: -t code must be 0 or 1\n", program);
+ fprintf(stderr, usage, program, FNV_VERSION);
+ exit(1);
+ }
+ m_flag = 1;
+ break;
+ case 'v': /* verbose hash print */
+ m_flag = 1;
+ v_flag = 1;
+ break;
+ default:
+ fprintf(stderr, usage, program, FNV_VERSION);
+ exit(1);
+ }
+ }
+ /* -t code incompatible with -b, -m and args */
+ if (t_flag >= 0) {
+ if (b_flag != WIDTH) {
+ fprintf(stderr, "%s: -t code incompatible with -b\n", program);
+ exit(2);
+ }
+ if (s_flag != 0) {
+ fprintf(stderr, "%s: -t code incompatible with -s\n", program);
+ exit(3);
+ }
+ if (optind < argc) {
+ fprintf(stderr, "%s: -t code incompatible args\n", program);
+ exit(4);
+ }
+ }
+ /* -s requires at least 1 arg */
+ if (s_flag && optind >= argc) {
+ fprintf(stderr, usage, program, FNV_VERSION);
+ exit(5);
+ }
+ /* limit -b values */
+ if (b_flag < 0 || b_flag > WIDTH) {
+ fprintf(stderr, "%s: -b bcnt: %d must be >= 0 and < %d\n",
+ program, b_flag, WIDTH);
+ exit(6);
+ }
+#if defined(HAVE_64BIT_LONG_LONG)
+ if (b_flag == WIDTH) {
+ bmask = (Fnv64_t)0xffffffffffffffffULL;
+ } else {
+ bmask = (Fnv64_t)((1ULL << b_flag) - 1ULL);
+ }
+#else /* HAVE_64BIT_LONG_LONG */
+ if (b_flag == WIDTH) {
+ bmask.w32[0] = 0xffffffffUL;
+ bmask.w32[1] = 0xffffffffUL;
+ } else if (b_flag >= WIDTH/2) {
+ bmask.w32[0] = 0xffffffffUL;
+ bmask.w32[1] = ((1UL << (b_flag-(WIDTH/2))) - 1UL);
+ } else {
+ bmask.w32[0] = ((1UL << b_flag) - 1UL);
+ bmask.w32[1] = 0UL;
+ }
+#endif /* HAVE_64BIT_LONG_LONG */
+
+ /*
+ * start with the initial basis depending on the hash type
+ */
+ p = strrchr(program, '/');
+ if (p == NULL) {
+ p = program;
+ } else {
+ ++p;
+ }
+ if (strcmp(p, "fnv064") == 0 || strcmp(p, "no64bit_fnv064") == 0) {
+ /* using non-recommended FNV-0 and zero initial basis */
+ hval = FNV0_64_INIT;
+ hash_type = FNV0_64;
+ } else if (strcmp(p, "fnv164") == 0 || strcmp(p, "no64bit_fnv164") == 0) {
+ /* using FNV-1 and non-zero initial basis */
+ hval = FNV1_64_INIT;
+ hash_type = FNV1_64;
+ } else if (strcmp(p, "fnv1a64") == 0 || strcmp(p, "no64bit_fnv1a64") == 0) {
+ /* start with the FNV-1a initial basis */
+ hval = FNV1A_64_INIT;
+ hash_type = FNV1a_64;
+ } else {
+ fprintf(stderr, "%s: unknown program name, unknown hash type\n",
+ program);
+ exit(7);
+ }
+
+ /*
+ * FNV test vector processing, if needed
+ */
+ if (t_flag >= 0) {
+ int code; /* test vector that failed, starting at 1 */
+
+ /*
+ * perform all tests
+ */
+ code = test_fnv64(hash_type, hval, bmask, v_flag, t_flag);
+
+ /*
+ * evaluate the tests
+ */
+ if (code == 0) {
+ if (v_flag) {
+ printf("passed\n");
+ }
+ exit(0);
+ } else {
+ printf("failed vector (1 is 1st test): %d\n", code);
+ exit(8);
+ }
+ }
+
+ /*
+ * string hashing
+ */
+ if (s_flag) {
+
+ /* hash any other strings */
+ for (i=optind; i < argc; ++i) {
+ switch (hash_type) {
+ case FNV0_64:
+ case FNV1_64:
+ hval = fnv_64_str(argv[i], hval);
+ break;
+ case FNV1a_64:
+ hval = fnv_64a_str(argv[i], hval);
+ break;
+ default:
+ unknown_hash_type(program, hash_type, 9); /* exit(9) */
+ /*NOTREACHED*/
+ }
+ if (m_flag) {
+ print_fnv64(hval, bmask, v_flag, argv[i]);
+ }
+ }
+
+
+ /*
+ * file hashing
+ */
+ } else {
+
+ /*
+ * case: process only stdin
+ */
+ if (optind >= argc) {
+
+ /* case: process only stdin */
+ while ((readcnt = read(0, buf, BUF_SIZE)) > 0) {
+ switch (hash_type) {
+ case FNV0_64:
+ case FNV1_64:
+ hval = fnv_64_buf(buf, readcnt, hval);
+ break;
+ case FNV1a_64:
+ hval = fnv_64a_buf(buf, readcnt, hval);
+ break;
+ default:
+ unknown_hash_type(program, hash_type, 10); /* exit(10) */
+ /*NOTREACHED*/
+ }
+ }
+ if (m_flag) {
+ print_fnv64(hval, bmask, v_flag, "(stdin)");
+ }
+
+ } else {
+
+ /*
+ * process any other files
+ */
+ for (i=optind; i < argc; ++i) {
+
+ /* open the file */
+ fd = open(argv[i], O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "%s: unable to open file: %s\n",
+ program, argv[i]);
+ exit(4);
+ }
+
+ /* hash the file */
+ while ((readcnt = read(fd, buf, BUF_SIZE)) > 0) {
+ switch (hash_type) {
+ case FNV0_64:
+ case FNV1_64:
+ hval = fnv_64_buf(buf, readcnt, hval);
+ break;
+ case FNV1a_64:
+ hval = fnv_64a_buf(buf, readcnt, hval);
+ break;
+ default:
+ unknown_hash_type(program, hash_type, 11);/* exit(11) */
+ /*NOTREACHED*/
+ }
+ }
+
+ /* finish processing the file */
+ if (m_flag) {
+ print_fnv64(hval, bmask, v_flag, argv[i]);
+ }
+ close(fd);
+ }
+ }
+ }
+
+ /*
+ * report hash and exit
+ */
+ if (!m_flag) {
+ print_fnv64(hval, bmask, v_flag, "");
+ }
+ return 0; /* exit(0); */
+}
diff --git a/lib/fnv/hash_32.c b/lib/fnv/hash_32.c
new file mode 100644
index 0000000000..077170ff6d
--- /dev/null
+++ b/lib/fnv/hash_32.c
@@ -0,0 +1,156 @@
+/*
+ * hash_32 - 32 bit Fowler/Noll/Vo hash code
+ *
+ * @(#) $Revision: 5.1 $
+ * @(#) $Id: hash_32.c,v 5.1 2009/06/30 09:13:32 chongo Exp $
+ * @(#) $Source: /usr/local/src/cmd/fnv/RCS/hash_32.c,v $
+ *
+ ***
+ *
+ * Fowler/Noll/Vo hash
+ *
+ * The basis of this hash algorithm was taken from an idea sent
+ * as reviewer comments to the IEEE POSIX P1003.2 committee by:
+ *
+ * Phong Vo (http://www.research.att.com/info/kpv/)
+ * Glenn Fowler (http://www.research.att.com/~gsf/)
+ *
+ * In a subsequent ballot round:
+ *
+ * Landon Curt Noll (http://www.isthe.com/chongo/)
+ *
+ * improved on their algorithm. Some people tried this hash
+ * and found that it worked rather well. In an EMail message
+ * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
+ *
+ * FNV hashes are designed to be fast while maintaining a low
+ * collision rate. The FNV speed allows one to quickly hash lots
+ * of data while maintaining a reasonable collision rate. See:
+ *
+ * http://www.isthe.com/chongo/tech/comp/fnv/index.html
+ *
+ * for more details as well as other forms of the FNV hash.
+ ***
+ *
+ * NOTE: The FNV-0 historic hash is not recommended. One should use
+ * the FNV-1 hash instead.
+ *
+ * To use the 32 bit FNV-0 historic hash, pass FNV0_32_INIT as the
+ * Fnv32_t hashval argument to fnv_32_buf() or fnv_32_str().
+ *
+ * To use the recommended 32 bit FNV-1 hash, pass FNV1_32_INIT as the
+ * Fnv32_t hashval argument to fnv_32_buf() or fnv_32_str().
+ *
+ ***
+ *
+ * Please do not copyright this code. This code is in the public domain.
+ *
+ * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * By:
+ * chongo <Landon Curt Noll> /\oo/\
+ * http://www.isthe.com/chongo/
+ *
+ * Share and Enjoy! :-)
+ */
+
+#include <stdlib.h>
+#include "fnv.h"
+
+
+/*
+ * 32 bit magic FNV-0 and FNV-1 prime
+ */
+#define FNV_32_PRIME ((Fnv32_t)0x01000193)
+
+
+/*
+ * fnv_32_buf - perform a 32 bit Fowler/Noll/Vo hash on a buffer
+ *
+ * input:
+ * buf - start of buffer to hash
+ * len - length of buffer in octets
+ * hval - previous hash value or 0 if first call
+ *
+ * returns:
+ * 32 bit hash as a static hash type
+ *
+ * NOTE: To use the 32 bit FNV-0 historic hash, use FNV0_32_INIT as the hval
+ * argument on the first call to either fnv_32_buf() or fnv_32_str().
+ *
+ * NOTE: To use the recommended 32 bit FNV-1 hash, use FNV1_32_INIT as the hval
+ * argument on the first call to either fnv_32_buf() or fnv_32_str().
+ */
+Fnv32_t
+fnv_32_buf(void *buf, size_t len, Fnv32_t hval)
+{
+ unsigned char *bp = (unsigned char *)buf; /* start of buffer */
+ unsigned char *be = bp + len; /* beyond end of buffer */
+
+ /*
+ * FNV-1 hash each octet in the buffer
+ */
+ while (bp < be) {
+
+ /* multiply by the 32 bit FNV magic prime mod 2^32 */
+#if defined(NO_FNV_GCC_OPTIMIZATION)
+ hval *= FNV_32_PRIME;
+#else
+ hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
+#endif
+
+ /* xor the bottom with the current octet */
+ hval ^= (Fnv32_t)*bp++;
+ }
+
+ /* return our new hash value */
+ return hval;
+}
+
+
+/*
+ * fnv_32_str - perform a 32 bit Fowler/Noll/Vo hash on a string
+ *
+ * input:
+ * str - string to hash
+ * hval - previous hash value or 0 if first call
+ *
+ * returns:
+ * 32 bit hash as a static hash type
+ *
+ * NOTE: To use the 32 bit FNV-0 historic hash, use FNV0_32_INIT as the hval
+ * argument on the first call to either fnv_32_buf() or fnv_32_str().
+ *
+ * NOTE: To use the recommended 32 bit FNV-1 hash, use FNV1_32_INIT as the hval
+ * argument on the first call to either fnv_32_buf() or fnv_32_str().
+ */
+Fnv32_t
+fnv_32_str(char *str, Fnv32_t hval)
+{
+ unsigned char *s = (unsigned char *)str; /* unsigned string */
+
+ /*
+ * FNV-1 hash each octet in the buffer
+ */
+ while (*s) {
+
+ /* multiply by the 32 bit FNV magic prime mod 2^32 */
+#if defined(NO_FNV_GCC_OPTIMIZATION)
+ hval *= FNV_32_PRIME;
+#else
+ hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
+#endif
+
+ /* xor the bottom with the current octet */
+ hval ^= (Fnv32_t)*s++;
+ }
+
+ /* return our new hash value */
+ return hval;
+}
diff --git a/lib/fnv/hash_32a.c b/lib/fnv/hash_32a.c
new file mode 100644
index 0000000000..8b10acf3e2
--- /dev/null
+++ b/lib/fnv/hash_32a.c
@@ -0,0 +1,144 @@
+/*
+ * hash_32 - 32 bit Fowler/Noll/Vo FNV-1a hash code
+ *
+ * @(#) $Revision: 5.1 $
+ * @(#) $Id: hash_32a.c,v 5.1 2009/06/30 09:13:32 chongo Exp $
+ * @(#) $Source: /usr/local/src/cmd/fnv/RCS/hash_32a.c,v $
+ *
+ ***
+ *
+ * Fowler/Noll/Vo hash
+ *
+ * The basis of this hash algorithm was taken from an idea sent
+ * as reviewer comments to the IEEE POSIX P1003.2 committee by:
+ *
+ * Phong Vo (http://www.research.att.com/info/kpv/)
+ * Glenn Fowler (http://www.research.att.com/~gsf/)
+ *
+ * In a subsequent ballot round:
+ *
+ * Landon Curt Noll (http://www.isthe.com/chongo/)
+ *
+ * improved on their algorithm. Some people tried this hash
+ * and found that it worked rather well. In an EMail message
+ * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
+ *
+ * FNV hashes are designed to be fast while maintaining a low
+ * collision rate. The FNV speed allows one to quickly hash lots
+ * of data while maintaining a reasonable collision rate. See:
+ *
+ * http://www.isthe.com/chongo/tech/comp/fnv/index.html
+ *
+ * for more details as well as other forms of the FNV hash.
+ ***
+ *
+ * To use the recommended 32 bit FNV-1a hash, pass FNV1_32A_INIT as the
+ * Fnv32_t hashval argument to fnv_32a_buf() or fnv_32a_str().
+ *
+ ***
+ *
+ * Please do not copyright this code. This code is in the public domain.
+ *
+ * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * By:
+ * chongo <Landon Curt Noll> /\oo/\
+ * http://www.isthe.com/chongo/
+ *
+ * Share and Enjoy! :-)
+ */
+
+#include <stdlib.h>
+#include "fnv.h"
+
+
+/*
+ * 32 bit magic FNV-1a prime
+ */
+#define FNV_32_PRIME ((Fnv32_t)0x01000193)
+
+
+/*
+ * fnv_32a_buf - perform a 32 bit Fowler/Noll/Vo FNV-1a hash on a buffer
+ *
+ * input:
+ * buf - start of buffer to hash
+ * len - length of buffer in octets
+ * hval - previous hash value or 0 if first call
+ *
+ * returns:
+ * 32 bit hash as a static hash type
+ *
+ * NOTE: To use the recommended 32 bit FNV-1a hash, use FNV1_32A_INIT as the
+ * hval arg on the first call to either fnv_32a_buf() or fnv_32a_str().
+ */
+Fnv32_t
+fnv_32a_buf(void *buf, size_t len, Fnv32_t hval)
+{
+ unsigned char *bp = (unsigned char *)buf; /* start of buffer */
+ unsigned char *be = bp + len; /* beyond end of buffer */
+
+ /*
+ * FNV-1a hash each octet in the buffer
+ */
+ while (bp < be) {
+
+ /* xor the bottom with the current octet */
+ hval ^= (Fnv32_t)*bp++;
+
+ /* multiply by the 32 bit FNV magic prime mod 2^32 */
+#if defined(NO_FNV_GCC_OPTIMIZATION)
+ hval *= FNV_32_PRIME;
+#else
+ hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
+#endif
+ }
+
+ /* return our new hash value */
+ return hval;
+}
+
+
+/*
+ * fnv_32a_str - perform a 32 bit Fowler/Noll/Vo FNV-1a hash on a string
+ *
+ * input:
+ * str - string to hash
+ * hval - previous hash value or 0 if first call
+ *
+ * returns:
+ * 32 bit hash as a static hash type
+ *
+ * NOTE: To use the recommended 32 bit FNV-1a hash, use FNV1_32A_INIT as the
+ * hval arg on the first call to either fnv_32a_buf() or fnv_32a_str().
+ */
+Fnv32_t
+fnv_32a_str(char *str, Fnv32_t hval)
+{
+ unsigned char *s = (unsigned char *)str; /* unsigned string */
+
+ /*
+ * FNV-1a hash each octet in the buffer
+ */
+ while (*s) {
+
+ /* xor the bottom with the current octet */
+ hval ^= (Fnv32_t)*s++;
+
+ /* multiply by the 32 bit FNV magic prime mod 2^32 */
+#if defined(NO_FNV_GCC_OPTIMIZATION)
+ hval *= FNV_32_PRIME;
+#else
+ hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
+#endif
+ }
+
+ /* return our new hash value */
+ return hval;
+}
diff --git a/lib/fnv/hash_64.c b/lib/fnv/hash_64.c
new file mode 100644
index 0000000000..4338605dca
--- /dev/null
+++ b/lib/fnv/hash_64.c
@@ -0,0 +1,312 @@
+/*
+ * hash_64 - 64 bit Fowler/Noll/Vo-0 hash code
+ *
+ * @(#) $Revision: 5.1 $
+ * @(#) $Id: hash_64.c,v 5.1 2009/06/30 09:01:38 chongo Exp $
+ * @(#) $Source: /usr/local/src/cmd/fnv/RCS/hash_64.c,v $
+ *
+ ***
+ *
+ * Fowler/Noll/Vo hash
+ *
+ * The basis of this hash algorithm was taken from an idea sent
+ * as reviewer comments to the IEEE POSIX P1003.2 committee by:
+ *
+ * Phong Vo (http://www.research.att.com/info/kpv/)
+ * Glenn Fowler (http://www.research.att.com/~gsf/)
+ *
+ * In a subsequent ballot round:
+ *
+ * Landon Curt Noll (http://www.isthe.com/chongo/)
+ *
+ * improved on their algorithm. Some people tried this hash
+ * and found that it worked rather well. In an EMail message
+ * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
+ *
+ * FNV hashes are designed to be fast while maintaining a low
+ * collision rate. The FNV speed allows one to quickly hash lots
+ * of data while maintaining a reasonable collision rate. See:
+ *
+ * http://www.isthe.com/chongo/tech/comp/fnv/index.html
+ *
+ * for more details as well as other forms of the FNV hash.
+ *
+ ***
+ *
+ * NOTE: The FNV-0 historic hash is not recommended. One should use
+ * the FNV-1 hash instead.
+ *
+ * To use the 64 bit FNV-0 historic hash, pass FNV0_64_INIT as the
+ * Fnv64_t hashval argument to fnv_64_buf() or fnv_64_str().
+ *
+ * To use the recommended 64 bit FNV-1 hash, pass FNV1_64_INIT as the
+ * Fnv64_t hashval argument to fnv_64_buf() or fnv_64_str().
+ *
+ ***
+ *
+ * Please do not copyright this code. This code is in the public domain.
+ *
+ * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * By:
+ * chongo <Landon Curt Noll> /\oo/\
+ * http://www.isthe.com/chongo/
+ *
+ * Share and Enjoy! :-)
+ */
+
+#include <stdlib.h>
+#include "fnv.h"
+
+
+/*
+ * FNV-0 defines the initial basis to be zero
+ */
+#if !defined(HAVE_64BIT_LONG_LONG)
+const Fnv64_t fnv0_64_init = { 0UL, 0UL };
+#endif /* ! HAVE_64BIT_LONG_LONG */
+
+
+/*
+ * FNV-1 defines the initial basis to be non-zero
+ */
+#if !defined(HAVE_64BIT_LONG_LONG)
+const Fnv64_t fnv1_64_init = { 0x84222325UL, 0xcbf29ce4UL };
+#endif /* ! HAVE_64BIT_LONG_LONG */
+
+
+/*
+ * 64 bit magic FNV-0 and FNV-1 prime
+ */
+#if defined(HAVE_64BIT_LONG_LONG)
+#define FNV_64_PRIME ((Fnv64_t)0x100000001b3ULL)
+#else /* HAVE_64BIT_LONG_LONG */
+#define FNV_64_PRIME_LOW ((unsigned long)0x1b3) /* lower bits of FNV prime */
+#define FNV_64_PRIME_SHIFT (8) /* top FNV prime shift above 2^32 */
+#endif /* HAVE_64BIT_LONG_LONG */
+
+
+/*
+ * fnv_64_buf - perform a 64 bit Fowler/Noll/Vo hash on a buffer
+ *
+ * input:
+ * buf - start of buffer to hash
+ * len - length of buffer in octets
+ * hval - previous hash value or 0 if first call
+ *
+ * returns:
+ * 64 bit hash as a static hash type
+ *
+ * NOTE: To use the 64 bit FNV-0 historic hash, use FNV0_64_INIT as the hval
+ * argument on the first call to either fnv_64_buf() or fnv_64_str().
+ *
+ * NOTE: To use the recommended 64 bit FNV-1 hash, use FNV1_64_INIT as the hval
+ * argument on the first call to either fnv_64_buf() or fnv_64_str().
+ */
+Fnv64_t
+fnv_64_buf(void *buf, size_t len, Fnv64_t hval)
+{
+ unsigned char *bp = (unsigned char *)buf; /* start of buffer */
+ unsigned char *be = bp + len; /* beyond end of buffer */
+
+#if defined(HAVE_64BIT_LONG_LONG)
+
+ /*
+ * FNV-1 hash each octet of the buffer
+ */
+ while (bp < be) {
+
+ /* multiply by the 64 bit FNV magic prime mod 2^64 */
+#if defined(NO_FNV_GCC_OPTIMIZATION)
+ hval *= FNV_64_PRIME;
+#else /* NO_FNV_GCC_OPTIMIZATION */
+ hval += (hval << 1) + (hval << 4) + (hval << 5) +
+ (hval << 7) + (hval << 8) + (hval << 40);
+#endif /* NO_FNV_GCC_OPTIMIZATION */
+
+ /* xor the bottom with the current octet */
+ hval ^= (Fnv64_t)*bp++;
+ }
+
+#else /* HAVE_64BIT_LONG_LONG */
+
+ unsigned long val[4]; /* hash value in base 2^16 */
+ unsigned long tmp[4]; /* tmp 64 bit value */
+
+ /*
+ * Convert Fnv64_t hval into a base 2^16 array
+ */
+ val[0] = hval.w32[0];
+ val[1] = (val[0] >> 16);
+ val[0] &= 0xffff;
+ val[2] = hval.w32[1];
+ val[3] = (val[2] >> 16);
+ val[2] &= 0xffff;
+
+ /*
+ * FNV-1 hash each octet of the buffer
+ */
+ while (bp < be) {
+
+ /*
+ * multiply by the 64 bit FNV magic prime mod 2^64
+ *
+ * Using 0x100000001b3 we have the following digits base 2^16:
+ *
+ * 0x0 0x100 0x0 0x1b3
+ *
+ * which is the same as:
+ *
+ * 0x0 1<<FNV_64_PRIME_SHIFT 0x0 FNV_64_PRIME_LOW
+ */
+ /* multiply by the lowest order digit base 2^16 */
+ tmp[0] = val[0] * FNV_64_PRIME_LOW;
+ tmp[1] = val[1] * FNV_64_PRIME_LOW;
+ tmp[2] = val[2] * FNV_64_PRIME_LOW;
+ tmp[3] = val[3] * FNV_64_PRIME_LOW;
+ /* multiply by the other non-zero digit */
+ tmp[2] += val[0] << FNV_64_PRIME_SHIFT; /* tmp[2] += val[0] * 0x100 */
+ tmp[3] += val[1] << FNV_64_PRIME_SHIFT; /* tmp[3] += val[1] * 0x100 */
+ /* propagate carries */
+ tmp[1] += (tmp[0] >> 16);
+ val[0] = tmp[0] & 0xffff;
+ tmp[2] += (tmp[1] >> 16);
+ val[1] = tmp[1] & 0xffff;
+ val[3] = tmp[3] + (tmp[2] >> 16);
+ val[2] = tmp[2] & 0xffff;
+ /*
+ * Doing a val[3] &= 0xffff; is not really needed since it simply
+ * removes multiples of 2^64. We can discard these excess bits
+ * outside of the loop when we convert to Fnv64_t.
+ */
+
+ /* xor the bottom with the current octet */
+ val[0] ^= (unsigned long)*bp++;
+ }
+
+ /*
+ * Convert base 2^16 array back into an Fnv64_t
+ */
+ hval.w32[1] = ((val[3]<<16) | val[2]);
+ hval.w32[0] = ((val[1]<<16) | val[0]);
+
+#endif /* HAVE_64BIT_LONG_LONG */
+
+ /* return our new hash value */
+ return hval;
+}
+
+
+/*
+ * fnv_64_str - perform a 64 bit Fowler/Noll/Vo hash on a buffer
+ *
+ * input:
+ * buf - start of buffer to hash
+ * hval - previous hash value or 0 if first call
+ *
+ * returns:
+ * 64 bit hash as a static hash type
+ *
+ * NOTE: To use the 64 bit FNV-0 historic hash, use FNV0_64_INIT as the hval
+ * argument on the first call to either fnv_64_buf() or fnv_64_str().
+ *
+ * NOTE: To use the recommended 64 bit FNV-1 hash, use FNV1_64_INIT as the hval
+ * argument on the first call to either fnv_64_buf() or fnv_64_str().
+ */
+Fnv64_t
+fnv_64_str(char *str, Fnv64_t hval)
+{
+ unsigned char *s = (unsigned char *)str; /* unsigned string */
+
+#if defined(HAVE_64BIT_LONG_LONG)
+
+ /*
+ * FNV-1 hash each octet of the string
+ */
+ while (*s) {
+
+ /* multiply by the 64 bit FNV magic prime mod 2^64 */
+#if defined(NO_FNV_GCC_OPTIMIZATION)
+ hval *= FNV_64_PRIME;
+#else /* NO_FNV_GCC_OPTIMIZATION */
+ hval += (hval << 1) + (hval << 4) + (hval << 5) +
+ (hval << 7) + (hval << 8) + (hval << 40);
+#endif /* NO_FNV_GCC_OPTIMIZATION */
+
+ /* xor the bottom with the current octet */
+ hval ^= (Fnv64_t)*s++;
+ }
+
+#else /* !HAVE_64BIT_LONG_LONG */
+
+ unsigned long val[4]; /* hash value in base 2^16 */
+ unsigned long tmp[4]; /* tmp 64 bit value */
+
+ /*
+ * Convert Fnv64_t hval into a base 2^16 array
+ */
+ val[0] = hval.w32[0];
+ val[1] = (val[0] >> 16);
+ val[0] &= 0xffff;
+ val[2] = hval.w32[1];
+ val[3] = (val[2] >> 16);
+ val[2] &= 0xffff;
+
+ /*
+ * FNV-1 hash each octet of the string
+ */
+ while (*s) {
+
+ /*
+ * multiply by the 64 bit FNV magic prime mod 2^64
+ *
+ * Using 1099511628211, we have the following digits base 2^16:
+ *
+ * 0x0 0x100 0x0 0x1b3
+ *
+ * which is the same as:
+ *
+ * 0x0 1<<FNV_64_PRIME_SHIFT 0x0 FNV_64_PRIME_LOW
+ */
+ /* multiply by the lowest order digit base 2^16 */
+ tmp[0] = val[0] * FNV_64_PRIME_LOW;
+ tmp[1] = val[1] * FNV_64_PRIME_LOW;
+ tmp[2] = val[2] * FNV_64_PRIME_LOW;
+ tmp[3] = val[3] * FNV_64_PRIME_LOW;
+ /* multiply by the other non-zero digit */
+ tmp[2] += val[0] << FNV_64_PRIME_SHIFT; /* tmp[2] += val[0] * 0x100 */
+ tmp[3] += val[1] << FNV_64_PRIME_SHIFT; /* tmp[3] += val[1] * 0x100 */
+ /* propagate carries */
+ tmp[1] += (tmp[0] >> 16);
+ val[0] = tmp[0] & 0xffff;
+ tmp[2] += (tmp[1] >> 16);
+ val[1] = tmp[1] & 0xffff;
+ val[3] = tmp[3] + (tmp[2] >> 16);
+ val[2] = tmp[2] & 0xffff;
+ /*
+ * Doing a val[3] &= 0xffff; is not really needed since it simply
+ * removes multiples of 2^64. We can discard these excess bits
+ * outside of the loop when we convert to Fnv64_t.
+ */
+
+ /* xor the bottom with the current octet */
+ val[0] ^= (unsigned long)(*s++);
+ }
+
+ /*
+ * Convert base 2^16 array back into an Fnv64_t
+ */
+ hval.w32[1] = ((val[3]<<16) | val[2]);
+ hval.w32[0] = ((val[1]<<16) | val[0]);
+
+#endif /* !HAVE_64BIT_LONG_LONG */
+
+ /* return our new hash value */
+ return hval;
+}
diff --git a/lib/fnv/hash_64a.c b/lib/fnv/hash_64a.c
new file mode 100644
index 0000000000..6660f92ddf
--- /dev/null
+++ b/lib/fnv/hash_64a.c
@@ -0,0 +1,291 @@
+/*
+ * hash_64 - 64 bit Fowler/Noll/Vo-0 FNV-1a hash code
+ *
+ * @(#) $Revision: 5.1 $
+ * @(#) $Id: hash_64a.c,v 5.1 2009/06/30 09:01:38 chongo Exp $
+ * @(#) $Source: /usr/local/src/cmd/fnv/RCS/hash_64a.c,v $
+ *
+ ***
+ *
+ * Fowler/Noll/Vo hash
+ *
+ * The basis of this hash algorithm was taken from an idea sent
+ * as reviewer comments to the IEEE POSIX P1003.2 committee by:
+ *
+ * Phong Vo (http://www.research.att.com/info/kpv/)
+ * Glenn Fowler (http://www.research.att.com/~gsf/)
+ *
+ * In a subsequent ballot round:
+ *
+ * Landon Curt Noll (http://www.isthe.com/chongo/)
+ *
+ * improved on their algorithm. Some people tried this hash
+ * and found that it worked rather well. In an EMail message
+ * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
+ *
+ * FNV hashes are designed to be fast while maintaining a low
+ * collision rate. The FNV speed allows one to quickly hash lots
+ * of data while maintaining a reasonable collision rate. See:
+ *
+ * http://www.isthe.com/chongo/tech/comp/fnv/index.html
+ *
+ * for more details as well as other forms of the FNV hash.
+ *
+ ***
+ *
+ * To use the recommended 64 bit FNV-1a hash, pass FNV1A_64_INIT as the
+ * Fnv64_t hashval argument to fnv_64a_buf() or fnv_64a_str().
+ *
+ ***
+ *
+ * Please do not copyright this code. This code is in the public domain.
+ *
+ * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * By:
+ * chongo <Landon Curt Noll> /\oo/\
+ * http://www.isthe.com/chongo/
+ *
+ * Share and Enjoy! :-)
+ */
+
+#include <stdlib.h>
+#include "fnv.h"
+
+
+/*
+ * FNV-1a defines the initial basis to be non-zero
+ */
+#if !defined(HAVE_64BIT_LONG_LONG)
+const Fnv64_t fnv1a_64_init = { 0x84222325, 0xcbf29ce4 };
+#endif /* ! HAVE_64BIT_LONG_LONG */
+
+
+/*
+ * 64 bit magic FNV-1a prime
+ */
+#if defined(HAVE_64BIT_LONG_LONG)
+#define FNV_64_PRIME ((Fnv64_t)0x100000001b3ULL)
+#else /* HAVE_64BIT_LONG_LONG */
+#define FNV_64_PRIME_LOW ((unsigned long)0x1b3) /* lower bits of FNV prime */
+#define FNV_64_PRIME_SHIFT (8) /* top FNV prime shift above 2^32 */
+#endif /* HAVE_64BIT_LONG_LONG */
+
+
+/*
+ * fnv_64a_buf - perform a 64 bit Fowler/Noll/Vo FNV-1a hash on a buffer
+ *
+ * input:
+ * buf - start of buffer to hash
+ * len - length of buffer in octets
+ * hval - previous hash value or 0 if first call
+ *
+ * returns:
+ * 64 bit hash as a static hash type
+ *
+ * NOTE: To use the recommended 64 bit FNV-1a hash, use FNV1A_64_INIT as the
+ * hval arg on the first call to either fnv_64a_buf() or fnv_64a_str().
+ */
+Fnv64_t
+fnv_64a_buf(void *buf, size_t len, Fnv64_t hval)
+{
+ unsigned char *bp = (unsigned char *)buf; /* start of buffer */
+ unsigned char *be = bp + len; /* beyond end of buffer */
+
+#if defined(HAVE_64BIT_LONG_LONG)
+ /*
+ * FNV-1a hash each octet of the buffer
+ */
+ while (bp < be) {
+
+ /* xor the bottom with the current octet */
+ hval ^= (Fnv64_t)*bp++;
+
+ /* multiply by the 64 bit FNV magic prime mod 2^64 */
+#if defined(NO_FNV_GCC_OPTIMIZATION)
+ hval *= FNV_64_PRIME;
+#else /* NO_FNV_GCC_OPTIMIZATION */
+ hval += (hval << 1) + (hval << 4) + (hval << 5) +
+ (hval << 7) + (hval << 8) + (hval << 40);
+#endif /* NO_FNV_GCC_OPTIMIZATION */
+ }
+
+#else /* HAVE_64BIT_LONG_LONG */
+
+ unsigned long val[4]; /* hash value in base 2^16 */
+ unsigned long tmp[4]; /* tmp 64 bit value */
+
+ /*
+ * Convert Fnv64_t hval into a base 2^16 array
+ */
+ val[0] = hval.w32[0];
+ val[1] = (val[0] >> 16);
+ val[0] &= 0xffff;
+ val[2] = hval.w32[1];
+ val[3] = (val[2] >> 16);
+ val[2] &= 0xffff;
+
+ /*
+ * FNV-1a hash each octet of the buffer
+ */
+ while (bp < be) {
+
+ /* xor the bottom with the current octet */
+ val[0] ^= (unsigned long)*bp++;
+
+ /*
+ * multiply by the 64 bit FNV magic prime mod 2^64
+ *
+ * Using 0x100000001b3 we have the following digits base 2^16:
+ *
+ * 0x0 0x100 0x0 0x1b3
+ *
+ * which is the same as:
+ *
+ * 0x0 1<<FNV_64_PRIME_SHIFT 0x0 FNV_64_PRIME_LOW
+ */
+ /* multiply by the lowest order digit base 2^16 */
+ tmp[0] = val[0] * FNV_64_PRIME_LOW;
+ tmp[1] = val[1] * FNV_64_PRIME_LOW;
+ tmp[2] = val[2] * FNV_64_PRIME_LOW;
+ tmp[3] = val[3] * FNV_64_PRIME_LOW;
+ /* multiply by the other non-zero digit */
+ tmp[2] += val[0] << FNV_64_PRIME_SHIFT; /* tmp[2] += val[0] * 0x100 */
+ tmp[3] += val[1] << FNV_64_PRIME_SHIFT; /* tmp[3] += val[1] * 0x100 */
+ /* propagate carries */
+ tmp[1] += (tmp[0] >> 16);
+ val[0] = tmp[0] & 0xffff;
+ tmp[2] += (tmp[1] >> 16);
+ val[1] = tmp[1] & 0xffff;
+ val[3] = tmp[3] + (tmp[2] >> 16);
+ val[2] = tmp[2] & 0xffff;
+ /*
+ * Doing a val[3] &= 0xffff; is not really needed since it simply
+ * removes multiples of 2^64. We can discard these excess bits
+ * outside of the loop when we convert to Fnv64_t.
+ */
+ }
+
+ /*
+ * Convert base 2^16 array back into an Fnv64_t
+ */
+ hval.w32[1] = ((val[3]<<16) | val[2]);
+ hval.w32[0] = ((val[1]<<16) | val[0]);
+
+#endif /* HAVE_64BIT_LONG_LONG */
+
+ /* return our new hash value */
+ return hval;
+}
+
+
+/*
+ * fnv_64a_str - perform a 64 bit Fowler/Noll/Vo FNV-1a hash on a buffer
+ *
+ * input:
+ * buf - start of buffer to hash
+ * hval - previous hash value or 0 if first call
+ *
+ * returns:
+ * 64 bit hash as a static hash type
+ *
+ * NOTE: To use the recommended 64 bit FNV-1a hash, use FNV1A_64_INIT as the
+ * hval arg on the first call to either fnv_64a_buf() or fnv_64a_str().
+ */
+Fnv64_t
+fnv_64a_str(char *str, Fnv64_t hval)
+{
+ unsigned char *s = (unsigned char *)str; /* unsigned string */
+
+#if defined(HAVE_64BIT_LONG_LONG)
+
+ /*
+ * FNV-1a hash each octet of the string
+ */
+ while (*s) {
+
+ /* xor the bottom with the current octet */
+ hval ^= (Fnv64_t)*s++;
+
+ /* multiply by the 64 bit FNV magic prime mod 2^64 */
+#if defined(NO_FNV_GCC_OPTIMIZATION)
+ hval *= FNV_64_PRIME;
+#else /* NO_FNV_GCC_OPTIMIZATION */
+ hval += (hval << 1) + (hval << 4) + (hval << 5) +
+ (hval << 7) + (hval << 8) + (hval << 40);
+#endif /* NO_FNV_GCC_OPTIMIZATION */
+ }
+
+#else /* !HAVE_64BIT_LONG_LONG */
+
+ unsigned long val[4]; /* hash value in base 2^16 */
+ unsigned long tmp[4]; /* tmp 64 bit value */
+
+ /*
+ * Convert Fnv64_t hval into a base 2^16 array
+ */
+ val[0] = hval.w32[0];
+ val[1] = (val[0] >> 16);
+ val[0] &= 0xffff;
+ val[2] = hval.w32[1];
+ val[3] = (val[2] >> 16);
+ val[2] &= 0xffff;
+
+ /*
+ * FNV-1a hash each octet of the string
+ */
+ while (*s) {
+
+ /* xor the bottom with the current octet */
+
+ /*
+ * multiply by the 64 bit FNV magic prime mod 2^64
+ *
+ * Using 1099511628211, we have the following digits base 2^16:
+ *
+ * 0x0 0x100 0x0 0x1b3
+ *
+ * which is the same as:
+ *
+ * 0x0 1<<FNV_64_PRIME_SHIFT 0x0 FNV_64_PRIME_LOW
+ */
+ /* multiply by the lowest order digit base 2^16 */
+ tmp[0] = val[0] * FNV_64_PRIME_LOW;
+ tmp[1] = val[1] * FNV_64_PRIME_LOW;
+ tmp[2] = val[2] * FNV_64_PRIME_LOW;
+ tmp[3] = val[3] * FNV_64_PRIME_LOW;
+ /* multiply by the other non-zero digit */
+ tmp[2] += val[0] << FNV_64_PRIME_SHIFT; /* tmp[2] += val[0] * 0x100 */
+ tmp[3] += val[1] << FNV_64_PRIME_SHIFT; /* tmp[3] += val[1] * 0x100 */
+ /* propagate carries */
+ tmp[1] += (tmp[0] >> 16);
+ val[0] = tmp[0] & 0xffff;
+ tmp[2] += (tmp[1] >> 16);
+ val[1] = tmp[1] & 0xffff;
+ val[3] = tmp[3] + (tmp[2] >> 16);
+ val[2] = tmp[2] & 0xffff;
+ /*
+ * Doing a val[3] &= 0xffff; is not really needed since it simply
+ * removes multiples of 2^64. We can discard these excess bits
+ * outside of the loop when we convert to Fnv64_t.
+ */
+ val[0] ^= (unsigned long)(*s++);
+ }
+
+ /*
+ * Convert base 2^16 array back into an Fnv64_t
+ */
+ hval.w32[1] = ((val[3]<<16) | val[2]);
+ hval.w32[0] = ((val[1]<<16) | val[0]);
+
+#endif /* !HAVE_64BIT_LONG_LONG */
+
+ /* return our new hash value */
+ return hval;
+}
diff --git a/lib/fnv/have_ulong64.c b/lib/fnv/have_ulong64.c
new file mode 100644
index 0000000000..5c06262388
--- /dev/null
+++ b/lib/fnv/have_ulong64.c
@@ -0,0 +1,58 @@
+/*
+ * have_ulong64 - Determine if we have a 64 bit unsigned long long
+ *
+ * usage:
+ * have_ulong64 > longlong.h
+ *
+ * Not all systems have a 'long long type' so this may not compile on
+ * your system.
+ *
+ * This prog outputs the define:
+ *
+ * HAVE_64BIT_LONG_LONG
+ * defined ==> we have a 64 bit unsigned long long
+ * undefined ==> we must simulate a 64 bit unsigned long long
+ */
+/*
+ *
+ * Please do not copyright this code. This code is in the public domain.
+ *
+ * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * By:
+ * chongo <Landon Curt Noll> /\oo/\
+ * http://www.isthe.com/chongo/
+ *
+ * Share and Enjoy! :-)
+ */
+
+/*
+ * have the compiler try its hand with unsigned and signed long longs
+ */
+#if ! defined(NO64BIT_LONG_LONG)
+unsigned long long val = 1099511628211ULL;
+#endif /* NO64BIT_LONG_LONG */
+
+int
+main(void)
+{
+ /*
+ * ensure that the length of long long val is what we expect
+ */
+#if defined(NO64BIT_LONG_LONG)
+ printf("#undef HAVE_64BIT_LONG_LONG\t/* no */\n");
+#else /* NO64BIT_LONG_LONG */
+ if (val == 1099511628211ULL && sizeof(val) == 8) {
+ printf("#define HAVE_64BIT_LONG_LONG\t/* yes */\n");
+ }
+#endif /* NO64BIT_LONG_LONG */
+
+ /* exit(0); */
+ return 0;
+}
diff --git a/lib/fnv/longlong.h b/lib/fnv/longlong.h
new file mode 100644
index 0000000000..c8cfe48f29
--- /dev/null
+++ b/lib/fnv/longlong.h
@@ -0,0 +1,18 @@
+/*
+ * DO NOT EDIT -- generated by the Makefile
+ */
+
+#if !defined(__LONGLONG_H__)
+#define __LONGLONG_H__
+
+/* do we have/want to use a long long type? */
+#define HAVE_64BIT_LONG_LONG /* yes */
+
+/*
+ * NO64BIT_LONG_LONG undef HAVE_64BIT_LONG_LONG
+ */
+#if defined(NO64BIT_LONG_LONG)
+#undef HAVE_64BIT_LONG_LONG
+#endif /* NO64BIT_LONG_LONG */
+
+#endif /* !__LONGLONG_H__ */
diff --git a/lib/fnv/qmk_fnv_type_validation.c b/lib/fnv/qmk_fnv_type_validation.c
new file mode 100644
index 0000000000..e8576617ba
--- /dev/null
+++ b/lib/fnv/qmk_fnv_type_validation.c
@@ -0,0 +1,14 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include "fnv.h"
+
+// This library was originally sourced from:
+// http://www.isthe.com/chongo/tech/comp/fnv/index.html
+//
+// Version at the time of retrieval on 2022-06-26: v5.0.3
+
+_Static_assert(sizeof(long long) == 8, "long long should be 64 bits");
+_Static_assert(sizeof(unsigned long long) == 8, "unsigned long long should be 64 bits");
+
+_Static_assert(sizeof(Fnv32_t) == 4, "Fnv32_t should be 32 bits");
+_Static_assert(sizeof(Fnv64_t) == 8, "Fnv64_t should be 64 bits");
diff --git a/lib/fnv/test_fnv.c b/lib/fnv/test_fnv.c
new file mode 100644
index 0000000000..efec3dec1d
--- /dev/null
+++ b/lib/fnv/test_fnv.c
@@ -0,0 +1,2237 @@
+/*
+ * test_fnv - FNV test suite
+ *
+ * @(#) $Revision: 5.3 $
+ * @(#) $Id: test_fnv.c,v 5.3 2009/06/30 11:50:41 chongo Exp $
+ * @(#) $Source: /usr/local/src/cmd/fnv/RCS/test_fnv.c,v $
+ *
+ ***
+ *
+ * Fowler/Noll/Vo hash
+ *
+ * The basis of this hash algorithm was taken from an idea sent
+ * as reviewer comments to the IEEE POSIX P1003.2 committee by:
+ *
+ * Phong Vo (http://www.research.att.com/info/kpv/)
+ * Glenn Fowler (http://www.research.att.com/~gsf/)
+ *
+ * In a subsequent ballot round:
+ *
+ * Landon Curt Noll (http://www.isthe.com/chongo/)
+ *
+ * improved on their algorithm. Some people tried this hash
+ * and found that it worked rather well. In an EMail message
+ * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
+ *
+ * FNV hashes are designed to be fast while maintaining a low
+ * collision rate. The FNV speed allows one to quickly hash lots
+ * of data while maintaining a reasonable collision rate. See:
+ *
+ * http://www.isthe.com/chongo/tech/comp/fnv/index.html
+ *
+ * for more details as well as other forms of the FNV hash.
+ *
+ ***
+ *
+ * Please do not copyright this code. This code is in the public domain.
+ *
+ * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * By:
+ * chongo <Landon Curt Noll> /\oo/\
+ * http://www.isthe.com/chongo/
+ *
+ * Share and Enjoy! :-)
+ */
+
+#include <stdio.h>
+#include "longlong.h"
+#include "fnv.h"
+
+#define LEN(x) (sizeof(x)-1)
+/* TEST macro does not include trailing NUL byte in the test vector */
+#define TEST(x) {x, LEN(x)}
+/* TEST0 macro includes the trailing NUL byte in the test vector */
+#define TEST0(x) {x, sizeof(x)}
+/* REPEAT500 - repeat a string 500 times */
+#define R500(x) R100(x)R100(x)R100(x)R100(x)R100(x)
+#define R100(x) R10(x)R10(x)R10(x)R10(x)R10(x)R10(x)R10(x)R10(x)R10(x)R10(x)
+#define R10(x) x x x x x x x x x x
+
+/*
+ * FNV test vectors
+ *
+ * NOTE: A NULL pointer marks beyond the end of the test vectors.
+ *
+ * NOTE: The order of the fnv_test_str[] test vectors is 1-to-1 with:
+ *
+ * struct fnv0_32_test_vector fnv0_32_vector[];
+ * struct fnv1_32_test_vector fnv1_32_vector[];
+ * struct fnv1a_32_test_vector fnv1a_32_vector[];
+ * struct fnv0_64_test_vector fnv0_64_vector[];
+ * struct fnv1_64_test_vector fnv1_64_vector[];
+ * struct fnv1a_64_test_vector fnv1a_64_vector[];
+ *
+ * IMPORTANT NOTE:
+ *
+ * If you change the fnv_test_str[] array, you need
+ * to also change ALL of the above fnv*_vector arrays!!!
+ *
+ * To rebuild, try:
+ *
+ * make vector.c
+ *
+ * and then fold the results into the source file.
+ * Of course, you better make sure that the vaules
+ * produced by the above command are valid, otherwise
+ * you will be testing against invalid vectors!
+ */
+struct test_vector fnv_test_str[] = {
+ TEST(""),
+ TEST("a"),
+ TEST("b"),
+ TEST("c"),
+ TEST("d"),
+ TEST("e"),
+ TEST("f"),
+ TEST("fo"),
+ TEST("foo"),
+ TEST("foob"),
+ TEST("fooba"),
+ TEST("foobar"),
+ TEST0(""),
+ TEST0("a"),
+ TEST0("b"),
+ TEST0("c"),
+ TEST0("d"),
+ TEST0("e"),
+ TEST0("f"),
+ TEST0("fo"),
+ TEST0("foo"),
+ TEST0("foob"),
+ TEST0("fooba"),
+ TEST0("foobar"),
+ TEST("ch"),
+ TEST("cho"),
+ TEST("chon"),
+ TEST("chong"),
+ TEST("chongo"),
+ TEST("chongo "),
+ TEST("chongo w"),
+ TEST("chongo wa"),
+ TEST("chongo was"),
+ TEST("chongo was "),
+ TEST("chongo was h"),
+ TEST("chongo was he"),
+ TEST("chongo was her"),
+ TEST("chongo was here"),
+ TEST("chongo was here!"),
+ TEST("chongo was here!\n"),
+ TEST0("ch"),
+ TEST0("cho"),
+ TEST0("chon"),
+ TEST0("chong"),
+ TEST0("chongo"),
+ TEST0("chongo "),
+ TEST0("chongo w"),
+ TEST0("chongo wa"),
+ TEST0("chongo was"),
+ TEST0("chongo was "),
+ TEST0("chongo was h"),
+ TEST0("chongo was he"),
+ TEST0("chongo was her"),
+ TEST0("chongo was here"),
+ TEST0("chongo was here!"),
+ TEST0("chongo was here!\n"),
+ TEST("cu"),
+ TEST("cur"),
+ TEST("curd"),
+ TEST("curds"),
+ TEST("curds "),
+ TEST("curds a"),
+ TEST("curds an"),
+ TEST("curds and"),
+ TEST("curds and "),
+ TEST("curds and w"),
+ TEST("curds and wh"),
+ TEST("curds and whe"),
+ TEST("curds and whey"),
+ TEST("curds and whey\n"),
+ TEST0("cu"),
+ TEST0("cur"),
+ TEST0("curd"),
+ TEST0("curds"),
+ TEST0("curds "),
+ TEST0("curds a"),
+ TEST0("curds an"),
+ TEST0("curds and"),
+ TEST0("curds and "),
+ TEST0("curds and w"),
+ TEST0("curds and wh"),
+ TEST0("curds and whe"),
+ TEST0("curds and whey"),
+ TEST0("curds and whey\n"),
+ TEST("hi"), TEST0("hi"),
+ TEST("hello"), TEST0("hello"),
+ TEST("\xff\x00\x00\x01"), TEST("\x01\x00\x00\xff"),
+ TEST("\xff\x00\x00\x02"), TEST("\x02\x00\x00\xff"),
+ TEST("\xff\x00\x00\x03"), TEST("\x03\x00\x00\xff"),
+ TEST("\xff\x00\x00\x04"), TEST("\x04\x00\x00\xff"),
+ TEST("\x40\x51\x4e\x44"), TEST("\x44\x4e\x51\x40"),
+ TEST("\x40\x51\x4e\x4a"), TEST("\x4a\x4e\x51\x40"),
+ TEST("\x40\x51\x4e\x54"), TEST("\x54\x4e\x51\x40"),
+ TEST("127.0.0.1"), TEST0("127.0.0.1"),
+ TEST("127.0.0.2"), TEST0("127.0.0.2"),
+ TEST("127.0.0.3"), TEST0("127.0.0.3"),
+ TEST("64.81.78.68"), TEST0("64.81.78.68"),
+ TEST("64.81.78.74"), TEST0("64.81.78.74"),
+ TEST("64.81.78.84"), TEST0("64.81.78.84"),
+ TEST("feedface"), TEST0("feedface"),
+ TEST("feedfacedaffdeed"), TEST0("feedfacedaffdeed"),
+ TEST("feedfacedeadbeef"), TEST0("feedfacedeadbeef"),
+ TEST("line 1\nline 2\nline 3"),
+ TEST("chongo <Landon Curt Noll> /\\../\\"),
+ TEST0("chongo <Landon Curt Noll> /\\../\\"),
+ TEST("chongo (Landon Curt Noll) /\\../\\"),
+ TEST0("chongo (Landon Curt Noll) /\\../\\"),
+ TEST("http://antwrp.gsfc.nasa.gov/apod/astropix.html"),
+ TEST("http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash"),
+ TEST("http://epod.usra.edu/"),
+ TEST("http://exoplanet.eu/"),
+ TEST("http://hvo.wr.usgs.gov/cam3/"),
+ TEST("http://hvo.wr.usgs.gov/cams/HMcam/"),
+ TEST("http://hvo.wr.usgs.gov/kilauea/update/deformation.html"),
+ TEST("http://hvo.wr.usgs.gov/kilauea/update/images.html"),
+ TEST("http://hvo.wr.usgs.gov/kilauea/update/maps.html"),
+ TEST("http://hvo.wr.usgs.gov/volcanowatch/current_issue.html"),
+ TEST("http://neo.jpl.nasa.gov/risk/"),
+ TEST("http://norvig.com/21-days.html"),
+ TEST("http://primes.utm.edu/curios/home.php"),
+ TEST("http://slashdot.org/"),
+ TEST("http://tux.wr.usgs.gov/Maps/155.25-19.5.html"),
+ TEST("http://volcano.wr.usgs.gov/kilaueastatus.php"),
+ TEST("http://www.avo.alaska.edu/activity/Redoubt.php"),
+ TEST("http://www.dilbert.com/fast/"),
+ TEST("http://www.fourmilab.ch/gravitation/orbits/"),
+ TEST("http://www.fpoa.net/"),
+ TEST("http://www.ioccc.org/index.html"),
+ TEST("http://www.isthe.com/cgi-bin/number.cgi"),
+ TEST("http://www.isthe.com/chongo/bio.html"),
+ TEST("http://www.isthe.com/chongo/index.html"),
+ TEST("http://www.isthe.com/chongo/src/calc/lucas-calc"),
+ TEST("http://www.isthe.com/chongo/tech/astro/venus2004.html"),
+ TEST("http://www.isthe.com/chongo/tech/astro/vita.html"),
+ TEST("http://www.isthe.com/chongo/tech/comp/c/expert.html"),
+ TEST("http://www.isthe.com/chongo/tech/comp/calc/index.html"),
+ TEST("http://www.isthe.com/chongo/tech/comp/fnv/index.html"),
+ TEST("http://www.isthe.com/chongo/tech/math/number/howhigh.html"),
+ TEST("http://www.isthe.com/chongo/tech/math/number/number.html"),
+ TEST("http://www.isthe.com/chongo/tech/math/prime/mersenne.html"),
+ TEST("http://www.isthe.com/chongo/tech/math/prime/mersenne.html#largest"),
+ TEST("http://www.lavarnd.org/cgi-bin/corpspeak.cgi"),
+ TEST("http://www.lavarnd.org/cgi-bin/haiku.cgi"),
+ TEST("http://www.lavarnd.org/cgi-bin/rand-none.cgi"),
+ TEST("http://www.lavarnd.org/cgi-bin/randdist.cgi"),
+ TEST("http://www.lavarnd.org/index.html"),
+ TEST("http://www.lavarnd.org/what/nist-test.html"),
+ TEST("http://www.macosxhints.com/"),
+ TEST("http://www.mellis.com/"),
+ TEST("http://www.nature.nps.gov/air/webcams/parks/havoso2alert/havoalert.cfm"),
+ TEST("http://www.nature.nps.gov/air/webcams/parks/havoso2alert/timelines_24.cfm"),
+ TEST("http://www.paulnoll.com/"),
+ TEST("http://www.pepysdiary.com/"),
+ TEST("http://www.sciencenews.org/index/home/activity/view"),
+ TEST("http://www.skyandtelescope.com/"),
+ TEST("http://www.sput.nl/~rob/sirius.html"),
+ TEST("http://www.systemexperts.com/"),
+ TEST("http://www.tq-international.com/phpBB3/index.php"),
+ TEST("http://www.travelquesttours.com/index.htm"),
+ TEST("http://www.wunderground.com/global/stations/89606.html"),
+ TEST(R10("21701")),
+ TEST(R10("M21701")),
+ TEST(R10("2^21701-1")),
+ TEST(R10("\x54\xc5")),
+ TEST(R10("\xc5\x54")),
+ TEST(R10("23209")),
+ TEST(R10("M23209")),
+ TEST(R10("2^23209-1")),
+ TEST(R10("\x5a\xa9")),
+ TEST(R10("\xa9\x5a")),
+ TEST(R10("391581216093")),
+ TEST(R10("391581*2^216093-1")),
+ TEST(R10("\x05\xf9\x9d\x03\x4c\x81")),
+ TEST(R10("FEDCBA9876543210")),
+ TEST(R10("\xfe\xdc\xba\x98\x76\x54\x32\x10")),
+ TEST(R10("EFCDAB8967452301")),
+ TEST(R10("\xef\xcd\xab\x89\x67\x45\x23\x01")),
+ TEST(R10("0123456789ABCDEF")),
+ TEST(R10("\x01\x23\x45\x67\x89\xab\xcd\xef")),
+ TEST(R10("1032547698BADCFE")),
+ TEST(R10("\x10\x32\x54\x76\x98\xba\xdc\xfe")),
+ TEST(R500("\x00")),
+ TEST(R500("\x07")),
+ TEST(R500("~")),
+ TEST(R500("\x7f")),
+ {NULL, 0} /* MUST BE LAST */
+};
+
+
+/*
+ * insert the contents of vector.c below
+ *
+ * make vector.c
+ * :r vector.c
+ */
+/* start of output generated by make vector.c */
+
+/* FNV-0 32 bit test vectors */
+struct fnv0_32_test_vector fnv0_32_vector[] = {
+ { &fnv_test_str[0], (Fnv32_t) 0x00000000UL },
+ { &fnv_test_str[1], (Fnv32_t) 0x00000061UL },
+ { &fnv_test_str[2], (Fnv32_t) 0x00000062UL },
+ { &fnv_test_str[3], (Fnv32_t) 0x00000063UL },
+ { &fnv_test_str[4], (Fnv32_t) 0x00000064UL },
+ { &fnv_test_str[5], (Fnv32_t) 0x00000065UL },
+ { &fnv_test_str[6], (Fnv32_t) 0x00000066UL },
+ { &fnv_test_str[7], (Fnv32_t) 0x6600a0fdUL },
+ { &fnv_test_str[8], (Fnv32_t) 0x8ffd6e28UL },
+ { &fnv_test_str[9], (Fnv32_t) 0xd3f4689aUL },
+ { &fnv_test_str[10], (Fnv32_t) 0x43c0aa0fUL },
+ { &fnv_test_str[11], (Fnv32_t) 0xb74bb5efUL },
+ { &fnv_test_str[12], (Fnv32_t) 0x00000000UL },
+ { &fnv_test_str[13], (Fnv32_t) 0x610098b3UL },
+ { &fnv_test_str[14], (Fnv32_t) 0x62009a46UL },
+ { &fnv_test_str[15], (Fnv32_t) 0x63009bd9UL },
+ { &fnv_test_str[16], (Fnv32_t) 0x64009d6cUL },
+ { &fnv_test_str[17], (Fnv32_t) 0x65009effUL },
+ { &fnv_test_str[18], (Fnv32_t) 0x6600a092UL },
+ { &fnv_test_str[19], (Fnv32_t) 0x8ffd6e47UL },
+ { &fnv_test_str[20], (Fnv32_t) 0xd3f468f8UL },
+ { &fnv_test_str[21], (Fnv32_t) 0x43c0aa6eUL },
+ { &fnv_test_str[22], (Fnv32_t) 0xb74bb59dUL },
+ { &fnv_test_str[23], (Fnv32_t) 0x7b2f673dUL },
+ { &fnv_test_str[24], (Fnv32_t) 0x63009bb1UL },
+ { &fnv_test_str[25], (Fnv32_t) 0x8af517ccUL },
+ { &fnv_test_str[26], (Fnv32_t) 0x8bd4764aUL },
+ { &fnv_test_str[27], (Fnv32_t) 0x69763619UL },
+ { &fnv_test_str[28], (Fnv32_t) 0x1e172934UL },
+ { &fnv_test_str[29], (Fnv32_t) 0x9275dcfcUL },
+ { &fnv_test_str[30], (Fnv32_t) 0x8b8ae0c3UL },
+ { &fnv_test_str[31], (Fnv32_t) 0x6e9fd298UL },
+ { &fnv_test_str[32], (Fnv32_t) 0xbd98853bUL },
+ { &fnv_test_str[33], (Fnv32_t) 0xb219bbc1UL },
+ { &fnv_test_str[34], (Fnv32_t) 0x1f8290bbUL },
+ { &fnv_test_str[35], (Fnv32_t) 0x5589d604UL },
+ { &fnv_test_str[36], (Fnv32_t) 0xabfbe83eUL },
+ { &fnv_test_str[37], (Fnv32_t) 0xfb8e99ffUL },
+ { &fnv_test_str[38], (Fnv32_t) 0x007c6c4cUL },
+ { &fnv_test_str[39], (Fnv32_t) 0x0fde7baeUL },
+ { &fnv_test_str[40], (Fnv32_t) 0x8af517a3UL },
+ { &fnv_test_str[41], (Fnv32_t) 0x8bd47624UL },
+ { &fnv_test_str[42], (Fnv32_t) 0x6976367eUL },
+ { &fnv_test_str[43], (Fnv32_t) 0x1e17295bUL },
+ { &fnv_test_str[44], (Fnv32_t) 0x9275dcdcUL },
+ { &fnv_test_str[45], (Fnv32_t) 0x8b8ae0b4UL },
+ { &fnv_test_str[46], (Fnv32_t) 0x6e9fd2f9UL },
+ { &fnv_test_str[47], (Fnv32_t) 0xbd988548UL },
+ { &fnv_test_str[48], (Fnv32_t) 0xb219bbe1UL },
+ { &fnv_test_str[49], (Fnv32_t) 0x1f8290d3UL },
+ { &fnv_test_str[50], (Fnv32_t) 0x5589d661UL },
+ { &fnv_test_str[51], (Fnv32_t) 0xabfbe84cUL },
+ { &fnv_test_str[52], (Fnv32_t) 0xfb8e999aUL },
+ { &fnv_test_str[53], (Fnv32_t) 0x007c6c6dUL },
+ { &fnv_test_str[54], (Fnv32_t) 0x0fde7ba4UL },
+ { &fnv_test_str[55], (Fnv32_t) 0xa93cb2eaUL },
+ { &fnv_test_str[56], (Fnv32_t) 0x63009bacUL },
+ { &fnv_test_str[57], (Fnv32_t) 0x85f50fb6UL },
+ { &fnv_test_str[58], (Fnv32_t) 0x96c7bbe6UL },
+ { &fnv_test_str[59], (Fnv32_t) 0x426ccb61UL },
+ { &fnv_test_str[60], (Fnv32_t) 0xf2442993UL },
+ { &fnv_test_str[61], (Fnv32_t) 0xf44d7208UL },
+ { &fnv_test_str[62], (Fnv32_t) 0x9dea82f6UL },
+ { &fnv_test_str[63], (Fnv32_t) 0x8e2c2926UL },
+ { &fnv_test_str[64], (Fnv32_t) 0xf584c6f2UL },
+ { &fnv_test_str[65], (Fnv32_t) 0x72052e81UL },
+ { &fnv_test_str[66], (Fnv32_t) 0xff28357bUL },
+ { &fnv_test_str[67], (Fnv32_t) 0x274c30c4UL },
+ { &fnv_test_str[68], (Fnv32_t) 0xa0f0c4f5UL },
+ { &fnv_test_str[69], (Fnv32_t) 0x50060da5UL },
+ { &fnv_test_str[70], (Fnv32_t) 0x85f50fc4UL },
+ { &fnv_test_str[71], (Fnv32_t) 0x96c7bb82UL },
+ { &fnv_test_str[72], (Fnv32_t) 0x426ccb12UL },
+ { &fnv_test_str[73], (Fnv32_t) 0xf24429b3UL },
+ { &fnv_test_str[74], (Fnv32_t) 0xf44d7269UL },
+ { &fnv_test_str[75], (Fnv32_t) 0x9dea8298UL },
+ { &fnv_test_str[76], (Fnv32_t) 0x8e2c2942UL },
+ { &fnv_test_str[77], (Fnv32_t) 0xf584c6d2UL },
+ { &fnv_test_str[78], (Fnv32_t) 0x72052ef6UL },
+ { &fnv_test_str[79], (Fnv32_t) 0xff283513UL },
+ { &fnv_test_str[80], (Fnv32_t) 0x274c30a1UL },
+ { &fnv_test_str[81], (Fnv32_t) 0xa0f0c48cUL },
+ { &fnv_test_str[82], (Fnv32_t) 0x50060dafUL },
+ { &fnv_test_str[83], (Fnv32_t) 0x9e877abfUL },
+ { &fnv_test_str[84], (Fnv32_t) 0x6800a3d1UL },
+ { &fnv_test_str[85], (Fnv32_t) 0x8a01e203UL },
+ { &fnv_test_str[86], (Fnv32_t) 0xec6d6be8UL },
+ { &fnv_test_str[87], (Fnv32_t) 0x1840de38UL },
+ { &fnv_test_str[88], (Fnv32_t) 0xa7cc97b4UL },
+ { &fnv_test_str[89], (Fnv32_t) 0x3ee6b3b4UL },
+ { &fnv_test_str[90], (Fnv32_t) 0xa7cc97b7UL },
+ { &fnv_test_str[91], (Fnv32_t) 0x7dcd6669UL },
+ { &fnv_test_str[92], (Fnv32_t) 0xa7cc97b6UL },
+ { &fnv_test_str[93], (Fnv32_t) 0xbcb4191eUL },
+ { &fnv_test_str[94], (Fnv32_t) 0xa7cc97b1UL },
+ { &fnv_test_str[95], (Fnv32_t) 0xfb9acdd3UL },
+ { &fnv_test_str[96], (Fnv32_t) 0x89380433UL },
+ { &fnv_test_str[97], (Fnv32_t) 0x8acd2855UL },
+ { &fnv_test_str[98], (Fnv32_t) 0x8938043dUL },
+ { &fnv_test_str[99], (Fnv32_t) 0xcaeed493UL },
+ { &fnv_test_str[100], (Fnv32_t) 0x89380423UL },
+ { &fnv_test_str[101], (Fnv32_t) 0x59382a25UL },
+ { &fnv_test_str[102], (Fnv32_t) 0x567f75d7UL },
+ { &fnv_test_str[103], (Fnv32_t) 0x01a68175UL },
+ { &fnv_test_str[104], (Fnv32_t) 0x567f75d4UL },
+ { &fnv_test_str[105], (Fnv32_t) 0xfea67cbcUL },
+ { &fnv_test_str[106], (Fnv32_t) 0x567f75d5UL },
+ { &fnv_test_str[107], (Fnv32_t) 0xffa67e4fUL },
+ { &fnv_test_str[108], (Fnv32_t) 0xd131b668UL },
+ { &fnv_test_str[109], (Fnv32_t) 0xb94225b8UL },
+ { &fnv_test_str[110], (Fnv32_t) 0xd231b7d7UL },
+ { &fnv_test_str[111], (Fnv32_t) 0xbb446775UL },
+ { &fnv_test_str[112], (Fnv32_t) 0xdf31cc6eUL },
+ { &fnv_test_str[113], (Fnv32_t) 0xc964d12aUL },
+ { &fnv_test_str[114], (Fnv32_t) 0x23af8f9fUL },
+ { &fnv_test_str[115], (Fnv32_t) 0xcc5f174dUL },
+ { &fnv_test_str[116], (Fnv32_t) 0x96b29b8cUL },
+ { &fnv_test_str[117], (Fnv32_t) 0xc72add64UL },
+ { &fnv_test_str[118], (Fnv32_t) 0x528fb7efUL },
+ { &fnv_test_str[119], (Fnv32_t) 0xe73e8d3dUL },
+ { &fnv_test_str[120], (Fnv32_t) 0x876386feUL },
+ { &fnv_test_str[121], (Fnv32_t) 0x811c9dc5UL },
+ { &fnv_test_str[122], (Fnv32_t) 0x050c5d1fUL },
+ { &fnv_test_str[123], (Fnv32_t) 0x14bf7238UL },
+ { &fnv_test_str[124], (Fnv32_t) 0xe160ce28UL },
+ { &fnv_test_str[125], (Fnv32_t) 0x89dc5a75UL },
+ { &fnv_test_str[126], (Fnv32_t) 0xd89b69a0UL },
+ { &fnv_test_str[127], (Fnv32_t) 0x94471a88UL },
+ { &fnv_test_str[128], (Fnv32_t) 0xe78db65fUL },
+ { &fnv_test_str[129], (Fnv32_t) 0x0c3009a2UL },
+ { &fnv_test_str[130], (Fnv32_t) 0x122dff03UL },
+ { &fnv_test_str[131], (Fnv32_t) 0xb4cd8875UL },
+ { &fnv_test_str[132], (Fnv32_t) 0xf4dba725UL },
+ { &fnv_test_str[133], (Fnv32_t) 0x41a16560UL },
+ { &fnv_test_str[134], (Fnv32_t) 0x9c0f941fUL },
+ { &fnv_test_str[135], (Fnv32_t) 0x451a5348UL },
+ { &fnv_test_str[136], (Fnv32_t) 0x3f1d1d89UL },
+ { &fnv_test_str[137], (Fnv32_t) 0x1b91b57aUL },
+ { &fnv_test_str[138], (Fnv32_t) 0x3e99b577UL },
+ { &fnv_test_str[139], (Fnv32_t) 0x4c9de07aUL },
+ { &fnv_test_str[140], (Fnv32_t) 0x1ddf7572UL },
+ { &fnv_test_str[141], (Fnv32_t) 0x64e81976UL },
+ { &fnv_test_str[142], (Fnv32_t) 0x1106a888UL },
+ { &fnv_test_str[143], (Fnv32_t) 0xa498d8e5UL },
+ { &fnv_test_str[144], (Fnv32_t) 0x3c03d2e3UL },
+ { &fnv_test_str[145], (Fnv32_t) 0x26568b28UL },
+ { &fnv_test_str[146], (Fnv32_t) 0x70d7fb42UL },
+ { &fnv_test_str[147], (Fnv32_t) 0xd3ae1d22UL },
+ { &fnv_test_str[148], (Fnv32_t) 0xac8ea5f4UL },
+ { &fnv_test_str[149], (Fnv32_t) 0x4d0abd60UL },
+ { &fnv_test_str[150], (Fnv32_t) 0x48f5e086UL },
+ { &fnv_test_str[151], (Fnv32_t) 0xa8f6241bUL },
+ { &fnv_test_str[152], (Fnv32_t) 0x572f864fUL },
+ { &fnv_test_str[153], (Fnv32_t) 0xa5340803UL },
+ { &fnv_test_str[154], (Fnv32_t) 0x22881aa8UL },
+ { &fnv_test_str[155], (Fnv32_t) 0xc2e2f5a2UL },
+ { &fnv_test_str[156], (Fnv32_t) 0xebf5aec7UL },
+ { &fnv_test_str[157], (Fnv32_t) 0x3cdbfb85UL },
+ { &fnv_test_str[158], (Fnv32_t) 0xbb859704UL },
+ { &fnv_test_str[159], (Fnv32_t) 0xc956fe11UL },
+ { &fnv_test_str[160], (Fnv32_t) 0x8f11a7c9UL },
+ { &fnv_test_str[161], (Fnv32_t) 0x36c48ecfUL },
+ { &fnv_test_str[162], (Fnv32_t) 0x24bfa27eUL },
+ { &fnv_test_str[163], (Fnv32_t) 0xf2596ad1UL },
+ { &fnv_test_str[164], (Fnv32_t) 0xf14a9b45UL },
+ { &fnv_test_str[165], (Fnv32_t) 0x7d45835aUL },
+ { &fnv_test_str[166], (Fnv32_t) 0x6e49334dUL },
+ { &fnv_test_str[167], (Fnv32_t) 0x71767337UL },
+ { &fnv_test_str[168], (Fnv32_t) 0x858a1a8aUL },
+ { &fnv_test_str[169], (Fnv32_t) 0x16e75ac2UL },
+ { &fnv_test_str[170], (Fnv32_t) 0x409f99dfUL },
+ { &fnv_test_str[171], (Fnv32_t) 0x6d6652ddUL },
+ { &fnv_test_str[172], (Fnv32_t) 0x2761a9ffUL },
+ { &fnv_test_str[173], (Fnv32_t) 0x41f0d616UL },
+ { &fnv_test_str[174], (Fnv32_t) 0x0e2d0d0fUL },
+ { &fnv_test_str[175], (Fnv32_t) 0x06adc8fdUL },
+ { &fnv_test_str[176], (Fnv32_t) 0x60e0d4b9UL },
+ { &fnv_test_str[177], (Fnv32_t) 0x5ddc79d3UL },
+ { &fnv_test_str[178], (Fnv32_t) 0x1e6d0b46UL },
+ { &fnv_test_str[179], (Fnv32_t) 0x1d1514d8UL },
+ { &fnv_test_str[180], (Fnv32_t) 0xb1903a4eUL },
+ { &fnv_test_str[181], (Fnv32_t) 0x8200c318UL },
+ { &fnv_test_str[182], (Fnv32_t) 0x15e22888UL },
+ { &fnv_test_str[183], (Fnv32_t) 0x57591760UL },
+ { &fnv_test_str[184], (Fnv32_t) 0x02462efcUL },
+ { &fnv_test_str[185], (Fnv32_t) 0x7651ec44UL },
+ { &fnv_test_str[186], (Fnv32_t) 0x7c24e9d4UL },
+ { &fnv_test_str[187], (Fnv32_t) 0x1952a034UL },
+ { &fnv_test_str[188], (Fnv32_t) 0xd4c46864UL },
+ { &fnv_test_str[189], (Fnv32_t) 0xcb57cde0UL },
+ { &fnv_test_str[190], (Fnv32_t) 0x71136a70UL },
+ { &fnv_test_str[191], (Fnv32_t) 0x0618fb40UL },
+ { &fnv_test_str[192], (Fnv32_t) 0x69a24fc0UL },
+ { &fnv_test_str[193], (Fnv32_t) 0x6a9be510UL },
+ { &fnv_test_str[194], (Fnv32_t) 0xe0477040UL },
+ { &fnv_test_str[195], (Fnv32_t) 0x85aa94b0UL },
+ { &fnv_test_str[196], (Fnv32_t) 0xc6d76240UL },
+ { &fnv_test_str[197], (Fnv32_t) 0xa9f09e40UL },
+ { &fnv_test_str[198], (Fnv32_t) 0xa0291540UL },
+ { &fnv_test_str[199], (Fnv32_t) 0x00000000UL },
+ { &fnv_test_str[200], (Fnv32_t) 0x2e672aa4UL },
+ { &fnv_test_str[201], (Fnv32_t) 0x84b1aa48UL },
+ { &fnv_test_str[202], (Fnv32_t) 0xfc24ba24UL },
+ { NULL, 0 }
+};
+
+/* FNV-1 32 bit test vectors */
+struct fnv1_32_test_vector fnv1_32_vector[] = {
+ { &fnv_test_str[0], (Fnv32_t) 0x811c9dc5UL },
+ { &fnv_test_str[1], (Fnv32_t) 0x050c5d7eUL },
+ { &fnv_test_str[2], (Fnv32_t) 0x050c5d7dUL },
+ { &fnv_test_str[3], (Fnv32_t) 0x050c5d7cUL },
+ { &fnv_test_str[4], (Fnv32_t) 0x050c5d7bUL },
+ { &fnv_test_str[5], (Fnv32_t) 0x050c5d7aUL },
+ { &fnv_test_str[6], (Fnv32_t) 0x050c5d79UL },
+ { &fnv_test_str[7], (Fnv32_t) 0x6b772514UL },
+ { &fnv_test_str[8], (Fnv32_t) 0x408f5e13UL },
+ { &fnv_test_str[9], (Fnv32_t) 0xb4b1178bUL },
+ { &fnv_test_str[10], (Fnv32_t) 0xfdc80fb0UL },
+ { &fnv_test_str[11], (Fnv32_t) 0x31f0b262UL },
+ { &fnv_test_str[12], (Fnv32_t) 0x050c5d1fUL },
+ { &fnv_test_str[13], (Fnv32_t) 0x70772d5aUL },
+ { &fnv_test_str[14], (Fnv32_t) 0x6f772bc7UL },
+ { &fnv_test_str[15], (Fnv32_t) 0x6e772a34UL },
+ { &fnv_test_str[16], (Fnv32_t) 0x6d7728a1UL },
+ { &fnv_test_str[17], (Fnv32_t) 0x6c77270eUL },
+ { &fnv_test_str[18], (Fnv32_t) 0x6b77257bUL },
+ { &fnv_test_str[19], (Fnv32_t) 0x408f5e7cUL },
+ { &fnv_test_str[20], (Fnv32_t) 0xb4b117e9UL },
+ { &fnv_test_str[21], (Fnv32_t) 0xfdc80fd1UL },
+ { &fnv_test_str[22], (Fnv32_t) 0x31f0b210UL },
+ { &fnv_test_str[23], (Fnv32_t) 0xffe8d046UL },
+ { &fnv_test_str[24], (Fnv32_t) 0x6e772a5cUL },
+ { &fnv_test_str[25], (Fnv32_t) 0x4197aebbUL },
+ { &fnv_test_str[26], (Fnv32_t) 0xfcc8100fUL },
+ { &fnv_test_str[27], (Fnv32_t) 0xfdf147faUL },
+ { &fnv_test_str[28], (Fnv32_t) 0xbcd44ee1UL },
+ { &fnv_test_str[29], (Fnv32_t) 0x23382c13UL },
+ { &fnv_test_str[30], (Fnv32_t) 0x846d619eUL },
+ { &fnv_test_str[31], (Fnv32_t) 0x1630abdbUL },
+ { &fnv_test_str[32], (Fnv32_t) 0xc99e89b2UL },
+ { &fnv_test_str[33], (Fnv32_t) 0x1692c316UL },
+ { &fnv_test_str[34], (Fnv32_t) 0x9f091bcaUL },
+ { &fnv_test_str[35], (Fnv32_t) 0x2556be9bUL },
+ { &fnv_test_str[36], (Fnv32_t) 0x628e0e73UL },
+ { &fnv_test_str[37], (Fnv32_t) 0x98a0bf6cUL },
+ { &fnv_test_str[38], (Fnv32_t) 0xb10d5725UL },
+ { &fnv_test_str[39], (Fnv32_t) 0xdd002f35UL },
+ { &fnv_test_str[40], (Fnv32_t) 0x4197aed4UL },
+ { &fnv_test_str[41], (Fnv32_t) 0xfcc81061UL },
+ { &fnv_test_str[42], (Fnv32_t) 0xfdf1479dUL },
+ { &fnv_test_str[43], (Fnv32_t) 0xbcd44e8eUL },
+ { &fnv_test_str[44], (Fnv32_t) 0x23382c33UL },
+ { &fnv_test_str[45], (Fnv32_t) 0x846d61e9UL },
+ { &fnv_test_str[46], (Fnv32_t) 0x1630abbaUL },
+ { &fnv_test_str[47], (Fnv32_t) 0xc99e89c1UL },
+ { &fnv_test_str[48], (Fnv32_t) 0x1692c336UL },
+ { &fnv_test_str[49], (Fnv32_t) 0x9f091ba2UL },
+ { &fnv_test_str[50], (Fnv32_t) 0x2556befeUL },
+ { &fnv_test_str[51], (Fnv32_t) 0x628e0e01UL },
+ { &fnv_test_str[52], (Fnv32_t) 0x98a0bf09UL },
+ { &fnv_test_str[53], (Fnv32_t) 0xb10d5704UL },
+ { &fnv_test_str[54], (Fnv32_t) 0xdd002f3fUL },
+ { &fnv_test_str[55], (Fnv32_t) 0x1c4a506fUL },
+ { &fnv_test_str[56], (Fnv32_t) 0x6e772a41UL },
+ { &fnv_test_str[57], (Fnv32_t) 0x26978421UL },
+ { &fnv_test_str[58], (Fnv32_t) 0xe184ff97UL },
+ { &fnv_test_str[59], (Fnv32_t) 0x9b5e5ac6UL },
+ { &fnv_test_str[60], (Fnv32_t) 0x5b88e592UL },
+ { &fnv_test_str[61], (Fnv32_t) 0xaa8164b7UL },
+ { &fnv_test_str[62], (Fnv32_t) 0x20b18c7bUL },
+ { &fnv_test_str[63], (Fnv32_t) 0xf28025c5UL },
+ { &fnv_test_str[64], (Fnv32_t) 0x84bb753fUL },
+ { &fnv_test_str[65], (Fnv32_t) 0x3219925aUL },
+ { &fnv_test_str[66], (Fnv32_t) 0x384163c6UL },
+ { &fnv_test_str[67], (Fnv32_t) 0x54f010d7UL },
+ { &fnv_test_str[68], (Fnv32_t) 0x8cea820cUL },
+ { &fnv_test_str[69], (Fnv32_t) 0xe12ab8eeUL },
+ { &fnv_test_str[70], (Fnv32_t) 0x26978453UL },
+ { &fnv_test_str[71], (Fnv32_t) 0xe184fff3UL },
+ { &fnv_test_str[72], (Fnv32_t) 0x9b5e5ab5UL },
+ { &fnv_test_str[73], (Fnv32_t) 0x5b88e5b2UL },
+ { &fnv_test_str[74], (Fnv32_t) 0xaa8164d6UL },
+ { &fnv_test_str[75], (Fnv32_t) 0x20b18c15UL },
+ { &fnv_test_str[76], (Fnv32_t) 0xf28025a1UL },
+ { &fnv_test_str[77], (Fnv32_t) 0x84bb751fUL },
+ { &fnv_test_str[78], (Fnv32_t) 0x3219922dUL },
+ { &fnv_test_str[79], (Fnv32_t) 0x384163aeUL },
+ { &fnv_test_str[80], (Fnv32_t) 0x54f010b2UL },
+ { &fnv_test_str[81], (Fnv32_t) 0x8cea8275UL },
+ { &fnv_test_str[82], (Fnv32_t) 0xe12ab8e4UL },
+ { &fnv_test_str[83], (Fnv32_t) 0x64411eaaUL },
+ { &fnv_test_str[84], (Fnv32_t) 0x6977223cUL },
+ { &fnv_test_str[85], (Fnv32_t) 0x428ae474UL },
+ { &fnv_test_str[86], (Fnv32_t) 0xb6fa7167UL },
+ { &fnv_test_str[87], (Fnv32_t) 0x73408525UL },
+ { &fnv_test_str[88], (Fnv32_t) 0xb78320a1UL },
+ { &fnv_test_str[89], (Fnv32_t) 0x0caf4135UL },
+ { &fnv_test_str[90], (Fnv32_t) 0xb78320a2UL },
+ { &fnv_test_str[91], (Fnv32_t) 0xcdc88e80UL },
+ { &fnv_test_str[92], (Fnv32_t) 0xb78320a3UL },
+ { &fnv_test_str[93], (Fnv32_t) 0x8ee1dbcbUL },
+ { &fnv_test_str[94], (Fnv32_t) 0xb78320a4UL },
+ { &fnv_test_str[95], (Fnv32_t) 0x4ffb2716UL },
+ { &fnv_test_str[96], (Fnv32_t) 0x860632aaUL },
+ { &fnv_test_str[97], (Fnv32_t) 0xcc2c5c64UL },
+ { &fnv_test_str[98], (Fnv32_t) 0x860632a4UL },
+ { &fnv_test_str[99], (Fnv32_t) 0x2a7ec4a6UL },
+ { &fnv_test_str[100], (Fnv32_t) 0x860632baUL },
+ { &fnv_test_str[101], (Fnv32_t) 0xfefe8e14UL },
+ { &fnv_test_str[102], (Fnv32_t) 0x0a3cffd8UL },
+ { &fnv_test_str[103], (Fnv32_t) 0xf606c108UL },
+ { &fnv_test_str[104], (Fnv32_t) 0x0a3cffdbUL },
+ { &fnv_test_str[105], (Fnv32_t) 0xf906c5c1UL },
+ { &fnv_test_str[106], (Fnv32_t) 0x0a3cffdaUL },
+ { &fnv_test_str[107], (Fnv32_t) 0xf806c42eUL },
+ { &fnv_test_str[108], (Fnv32_t) 0xc07167d7UL },
+ { &fnv_test_str[109], (Fnv32_t) 0xc9867775UL },
+ { &fnv_test_str[110], (Fnv32_t) 0xbf716668UL },
+ { &fnv_test_str[111], (Fnv32_t) 0xc78435b8UL },
+ { &fnv_test_str[112], (Fnv32_t) 0xc6717155UL },
+ { &fnv_test_str[113], (Fnv32_t) 0xb99568cfUL },
+ { &fnv_test_str[114], (Fnv32_t) 0x7662e0d6UL },
+ { &fnv_test_str[115], (Fnv32_t) 0x33a7f0e2UL },
+ { &fnv_test_str[116], (Fnv32_t) 0xc2732f95UL },
+ { &fnv_test_str[117], (Fnv32_t) 0xb053e78fUL },
+ { &fnv_test_str[118], (Fnv32_t) 0x3a19c02aUL },
+ { &fnv_test_str[119], (Fnv32_t) 0xa089821eUL },
+ { &fnv_test_str[120], (Fnv32_t) 0x31ae8f83UL },
+ { &fnv_test_str[121], (Fnv32_t) 0x995fa9c4UL },
+ { &fnv_test_str[122], (Fnv32_t) 0x35983f8cUL },
+ { &fnv_test_str[123], (Fnv32_t) 0x5036a251UL },
+ { &fnv_test_str[124], (Fnv32_t) 0x97018583UL },
+ { &fnv_test_str[125], (Fnv32_t) 0xb4448d60UL },
+ { &fnv_test_str[126], (Fnv32_t) 0x025dfe59UL },
+ { &fnv_test_str[127], (Fnv32_t) 0xc5eab3afUL },
+ { &fnv_test_str[128], (Fnv32_t) 0x7d21ba1eUL },
+ { &fnv_test_str[129], (Fnv32_t) 0x7704cddbUL },
+ { &fnv_test_str[130], (Fnv32_t) 0xd0071bfeUL },
+ { &fnv_test_str[131], (Fnv32_t) 0x0ff3774cUL },
+ { &fnv_test_str[132], (Fnv32_t) 0xb0fea0eaUL },
+ { &fnv_test_str[133], (Fnv32_t) 0x58177303UL },
+ { &fnv_test_str[134], (Fnv32_t) 0x4f599cdaUL },
+ { &fnv_test_str[135], (Fnv32_t) 0x3e590a47UL },
+ { &fnv_test_str[136], (Fnv32_t) 0x965595f8UL },
+ { &fnv_test_str[137], (Fnv32_t) 0xc37f178dUL },
+ { &fnv_test_str[138], (Fnv32_t) 0x9711dd26UL },
+ { &fnv_test_str[139], (Fnv32_t) 0x23c99b7fUL },
+ { &fnv_test_str[140], (Fnv32_t) 0x6e568b17UL },
+ { &fnv_test_str[141], (Fnv32_t) 0x43f0245bUL },
+ { &fnv_test_str[142], (Fnv32_t) 0xbcb7a001UL },
+ { &fnv_test_str[143], (Fnv32_t) 0x12e6dffeUL },
+ { &fnv_test_str[144], (Fnv32_t) 0x0792f2d6UL },
+ { &fnv_test_str[145], (Fnv32_t) 0xb966936bUL },
+ { &fnv_test_str[146], (Fnv32_t) 0x46439ac5UL },
+ { &fnv_test_str[147], (Fnv32_t) 0x728d49afUL },
+ { &fnv_test_str[148], (Fnv32_t) 0xd33745c9UL },
+ { &fnv_test_str[149], (Fnv32_t) 0xbc382a57UL },
+ { &fnv_test_str[150], (Fnv32_t) 0x4bda1d31UL },
+ { &fnv_test_str[151], (Fnv32_t) 0xce35ccaeUL },
+ { &fnv_test_str[152], (Fnv32_t) 0x3b6eed94UL },
+ { &fnv_test_str[153], (Fnv32_t) 0x445c9c58UL },
+ { &fnv_test_str[154], (Fnv32_t) 0x3db8bf9dUL },
+ { &fnv_test_str[155], (Fnv32_t) 0x2dee116dUL },
+ { &fnv_test_str[156], (Fnv32_t) 0xc18738daUL },
+ { &fnv_test_str[157], (Fnv32_t) 0x5b156176UL },
+ { &fnv_test_str[158], (Fnv32_t) 0x2aa7d593UL },
+ { &fnv_test_str[159], (Fnv32_t) 0xb2409658UL },
+ { &fnv_test_str[160], (Fnv32_t) 0xe1489528UL },
+ { &fnv_test_str[161], (Fnv32_t) 0xfe1ee07eUL },
+ { &fnv_test_str[162], (Fnv32_t) 0xe8842315UL },
+ { &fnv_test_str[163], (Fnv32_t) 0x3a6a63a2UL },
+ { &fnv_test_str[164], (Fnv32_t) 0x06d2c18cUL },
+ { &fnv_test_str[165], (Fnv32_t) 0xf8ef7225UL },
+ { &fnv_test_str[166], (Fnv32_t) 0x843d3300UL },
+ { &fnv_test_str[167], (Fnv32_t) 0xbb24f7aeUL },
+ { &fnv_test_str[168], (Fnv32_t) 0x878c0ec9UL },
+ { &fnv_test_str[169], (Fnv32_t) 0xb557810fUL },
+ { &fnv_test_str[170], (Fnv32_t) 0x57423246UL },
+ { &fnv_test_str[171], (Fnv32_t) 0x87f7505eUL },
+ { &fnv_test_str[172], (Fnv32_t) 0xbb809f20UL },
+ { &fnv_test_str[173], (Fnv32_t) 0x8932abb5UL },
+ { &fnv_test_str[174], (Fnv32_t) 0x0a9b3aa0UL },
+ { &fnv_test_str[175], (Fnv32_t) 0xb8682a24UL },
+ { &fnv_test_str[176], (Fnv32_t) 0xa7ac1c56UL },
+ { &fnv_test_str[177], (Fnv32_t) 0x11409252UL },
+ { &fnv_test_str[178], (Fnv32_t) 0xa987f517UL },
+ { &fnv_test_str[179], (Fnv32_t) 0xf309e7edUL },
+ { &fnv_test_str[180], (Fnv32_t) 0xc9e8f417UL },
+ { &fnv_test_str[181], (Fnv32_t) 0x7f447bddUL },
+ { &fnv_test_str[182], (Fnv32_t) 0xb929adc5UL },
+ { &fnv_test_str[183], (Fnv32_t) 0x57022879UL },
+ { &fnv_test_str[184], (Fnv32_t) 0xdcfd2c49UL },
+ { &fnv_test_str[185], (Fnv32_t) 0x6edafff5UL },
+ { &fnv_test_str[186], (Fnv32_t) 0xf04fb1f1UL },
+ { &fnv_test_str[187], (Fnv32_t) 0xfb7de8b9UL },
+ { &fnv_test_str[188], (Fnv32_t) 0xc5f1d7e9UL },
+ { &fnv_test_str[189], (Fnv32_t) 0x32c1f439UL },
+ { &fnv_test_str[190], (Fnv32_t) 0x7fd3eb7dUL },
+ { &fnv_test_str[191], (Fnv32_t) 0x81597da5UL },
+ { &fnv_test_str[192], (Fnv32_t) 0x05eb7a25UL },
+ { &fnv_test_str[193], (Fnv32_t) 0x9c0fa1b5UL },
+ { &fnv_test_str[194], (Fnv32_t) 0x53ccb1c5UL },
+ { &fnv_test_str[195], (Fnv32_t) 0xfabece15UL },
+ { &fnv_test_str[196], (Fnv32_t) 0x4ad745a5UL },
+ { &fnv_test_str[197], (Fnv32_t) 0xe5bdc495UL },
+ { &fnv_test_str[198], (Fnv32_t) 0x23b3c0a5UL },
+ { &fnv_test_str[199], (Fnv32_t) 0xfa823dd5UL },
+ { &fnv_test_str[200], (Fnv32_t) 0x0c6c58b9UL },
+ { &fnv_test_str[201], (Fnv32_t) 0xe2dbccd5UL },
+ { &fnv_test_str[202], (Fnv32_t) 0xdb7f50f9UL },
+ { NULL, 0 }
+};
+
+/* FNV-1a 32 bit test vectors */
+struct fnv1a_32_test_vector fnv1a_32_vector[] = {
+ { &fnv_test_str[0], (Fnv32_t) 0x811c9dc5UL },
+ { &fnv_test_str[1], (Fnv32_t) 0xe40c292cUL },
+ { &fnv_test_str[2], (Fnv32_t) 0xe70c2de5UL },
+ { &fnv_test_str[3], (Fnv32_t) 0xe60c2c52UL },
+ { &fnv_test_str[4], (Fnv32_t) 0xe10c2473UL },
+ { &fnv_test_str[5], (Fnv32_t) 0xe00c22e0UL },
+ { &fnv_test_str[6], (Fnv32_t) 0xe30c2799UL },
+ { &fnv_test_str[7], (Fnv32_t) 0x6222e842UL },
+ { &fnv_test_str[8], (Fnv32_t) 0xa9f37ed7UL },
+ { &fnv_test_str[9], (Fnv32_t) 0x3f5076efUL },
+ { &fnv_test_str[10], (Fnv32_t) 0x39aaa18aUL },
+ { &fnv_test_str[11], (Fnv32_t) 0xbf9cf968UL },
+ { &fnv_test_str[12], (Fnv32_t) 0x050c5d1fUL },
+ { &fnv_test_str[13], (Fnv32_t) 0x2b24d044UL },
+ { &fnv_test_str[14], (Fnv32_t) 0x9d2c3f7fUL },
+ { &fnv_test_str[15], (Fnv32_t) 0x7729c516UL },
+ { &fnv_test_str[16], (Fnv32_t) 0xb91d6109UL },
+ { &fnv_test_str[17], (Fnv32_t) 0x931ae6a0UL },
+ { &fnv_test_str[18], (Fnv32_t) 0x052255dbUL },
+ { &fnv_test_str[19], (Fnv32_t) 0xbef39fe6UL },
+ { &fnv_test_str[20], (Fnv32_t) 0x6150ac75UL },
+ { &fnv_test_str[21], (Fnv32_t) 0x9aab3a3dUL },
+ { &fnv_test_str[22], (Fnv32_t) 0x519c4c3eUL },
+ { &fnv_test_str[23], (Fnv32_t) 0x0c1c9eb8UL },
+ { &fnv_test_str[24], (Fnv32_t) 0x5f299f4eUL },
+ { &fnv_test_str[25], (Fnv32_t) 0xef8580f3UL },
+ { &fnv_test_str[26], (Fnv32_t) 0xac297727UL },
+ { &fnv_test_str[27], (Fnv32_t) 0x4546b9c0UL },
+ { &fnv_test_str[28], (Fnv32_t) 0xbd564e7dUL },
+ { &fnv_test_str[29], (Fnv32_t) 0x6bdd5c67UL },
+ { &fnv_test_str[30], (Fnv32_t) 0xdd77ed30UL },
+ { &fnv_test_str[31], (Fnv32_t) 0xf4ca9683UL },
+ { &fnv_test_str[32], (Fnv32_t) 0x4aeb9bd0UL },
+ { &fnv_test_str[33], (Fnv32_t) 0xe0e67ad0UL },
+ { &fnv_test_str[34], (Fnv32_t) 0xc2d32fa8UL },
+ { &fnv_test_str[35], (Fnv32_t) 0x7f743fb7UL },
+ { &fnv_test_str[36], (Fnv32_t) 0x6900631fUL },
+ { &fnv_test_str[37], (Fnv32_t) 0xc59c990eUL },
+ { &fnv_test_str[38], (Fnv32_t) 0x448524fdUL },
+ { &fnv_test_str[39], (Fnv32_t) 0xd49930d5UL },
+ { &fnv_test_str[40], (Fnv32_t) 0x1c85c7caUL },
+ { &fnv_test_str[41], (Fnv32_t) 0x0229fe89UL },
+ { &fnv_test_str[42], (Fnv32_t) 0x2c469265UL },
+ { &fnv_test_str[43], (Fnv32_t) 0xce566940UL },
+ { &fnv_test_str[44], (Fnv32_t) 0x8bdd8ec7UL },
+ { &fnv_test_str[45], (Fnv32_t) 0x34787625UL },
+ { &fnv_test_str[46], (Fnv32_t) 0xd3ca6290UL },
+ { &fnv_test_str[47], (Fnv32_t) 0xddeaf039UL },
+ { &fnv_test_str[48], (Fnv32_t) 0xc0e64870UL },
+ { &fnv_test_str[49], (Fnv32_t) 0xdad35570UL },
+ { &fnv_test_str[50], (Fnv32_t) 0x5a740578UL },
+ { &fnv_test_str[51], (Fnv32_t) 0x5b004d15UL },
+ { &fnv_test_str[52], (Fnv32_t) 0x6a9c09cdUL },
+ { &fnv_test_str[53], (Fnv32_t) 0x2384f10aUL },
+ { &fnv_test_str[54], (Fnv32_t) 0xda993a47UL },
+ { &fnv_test_str[55], (Fnv32_t) 0x8227df4fUL },
+ { &fnv_test_str[56], (Fnv32_t) 0x4c298165UL },
+ { &fnv_test_str[57], (Fnv32_t) 0xfc563735UL },
+ { &fnv_test_str[58], (Fnv32_t) 0x8cb91483UL },
+ { &fnv_test_str[59], (Fnv32_t) 0x775bf5d0UL },
+ { &fnv_test_str[60], (Fnv32_t) 0xd5c428d0UL },
+ { &fnv_test_str[61], (Fnv32_t) 0x34cc0ea3UL },
+ { &fnv_test_str[62], (Fnv32_t) 0xea3b4cb7UL },
+ { &fnv_test_str[63], (Fnv32_t) 0x8e59f029UL },
+ { &fnv_test_str[64], (Fnv32_t) 0x2094de2bUL },
+ { &fnv_test_str[65], (Fnv32_t) 0xa65a0ad4UL },
+ { &fnv_test_str[66], (Fnv32_t) 0x9bbee5f4UL },
+ { &fnv_test_str[67], (Fnv32_t) 0xbe836343UL },
+ { &fnv_test_str[68], (Fnv32_t) 0x22d5344eUL },
+ { &fnv_test_str[69], (Fnv32_t) 0x19a1470cUL },
+ { &fnv_test_str[70], (Fnv32_t) 0x4a56b1ffUL },
+ { &fnv_test_str[71], (Fnv32_t) 0x70b8e86fUL },
+ { &fnv_test_str[72], (Fnv32_t) 0x0a5b4a39UL },
+ { &fnv_test_str[73], (Fnv32_t) 0xb5c3f670UL },
+ { &fnv_test_str[74], (Fnv32_t) 0x53cc3f70UL },
+ { &fnv_test_str[75], (Fnv32_t) 0xc03b0a99UL },
+ { &fnv_test_str[76], (Fnv32_t) 0x7259c415UL },
+ { &fnv_test_str[77], (Fnv32_t) 0x4095108bUL },
+ { &fnv_test_str[78], (Fnv32_t) 0x7559bdb1UL },
+ { &fnv_test_str[79], (Fnv32_t) 0xb3bf0bbcUL },
+ { &fnv_test_str[80], (Fnv32_t) 0x2183ff1cUL },
+ { &fnv_test_str[81], (Fnv32_t) 0x2bd54279UL },
+ { &fnv_test_str[82], (Fnv32_t) 0x23a156caUL },
+ { &fnv_test_str[83], (Fnv32_t) 0x64e2d7e4UL },
+ { &fnv_test_str[84], (Fnv32_t) 0x683af69aUL },
+ { &fnv_test_str[85], (Fnv32_t) 0xaed2346eUL },
+ { &fnv_test_str[86], (Fnv32_t) 0x4f9f2cabUL },
+ { &fnv_test_str[87], (Fnv32_t) 0x02935131UL },
+ { &fnv_test_str[88], (Fnv32_t) 0xc48fb86dUL },
+ { &fnv_test_str[89], (Fnv32_t) 0x2269f369UL },
+ { &fnv_test_str[90], (Fnv32_t) 0xc18fb3b4UL },
+ { &fnv_test_str[91], (Fnv32_t) 0x50ef1236UL },
+ { &fnv_test_str[92], (Fnv32_t) 0xc28fb547UL },
+ { &fnv_test_str[93], (Fnv32_t) 0x96c3bf47UL },
+ { &fnv_test_str[94], (Fnv32_t) 0xbf8fb08eUL },
+ { &fnv_test_str[95], (Fnv32_t) 0xf3e4d49cUL },
+ { &fnv_test_str[96], (Fnv32_t) 0x32179058UL },
+ { &fnv_test_str[97], (Fnv32_t) 0x280bfee6UL },
+ { &fnv_test_str[98], (Fnv32_t) 0x30178d32UL },
+ { &fnv_test_str[99], (Fnv32_t) 0x21addaf8UL },
+ { &fnv_test_str[100], (Fnv32_t) 0x4217a988UL },
+ { &fnv_test_str[101], (Fnv32_t) 0x772633d6UL },
+ { &fnv_test_str[102], (Fnv32_t) 0x08a3d11eUL },
+ { &fnv_test_str[103], (Fnv32_t) 0xb7e2323aUL },
+ { &fnv_test_str[104], (Fnv32_t) 0x07a3cf8bUL },
+ { &fnv_test_str[105], (Fnv32_t) 0x91dfb7d1UL },
+ { &fnv_test_str[106], (Fnv32_t) 0x06a3cdf8UL },
+ { &fnv_test_str[107], (Fnv32_t) 0x6bdd3d68UL },
+ { &fnv_test_str[108], (Fnv32_t) 0x1d5636a7UL },
+ { &fnv_test_str[109], (Fnv32_t) 0xd5b808e5UL },
+ { &fnv_test_str[110], (Fnv32_t) 0x1353e852UL },
+ { &fnv_test_str[111], (Fnv32_t) 0xbf16b916UL },
+ { &fnv_test_str[112], (Fnv32_t) 0xa55b89edUL },
+ { &fnv_test_str[113], (Fnv32_t) 0x3c1a2017UL },
+ { &fnv_test_str[114], (Fnv32_t) 0x0588b13cUL },
+ { &fnv_test_str[115], (Fnv32_t) 0xf22f0174UL },
+ { &fnv_test_str[116], (Fnv32_t) 0xe83641e1UL },
+ { &fnv_test_str[117], (Fnv32_t) 0x6e69b533UL },
+ { &fnv_test_str[118], (Fnv32_t) 0xf1760448UL },
+ { &fnv_test_str[119], (Fnv32_t) 0x64c8bd58UL },
+ { &fnv_test_str[120], (Fnv32_t) 0x97b4ea23UL },
+ { &fnv_test_str[121], (Fnv32_t) 0x9a4e92e6UL },
+ { &fnv_test_str[122], (Fnv32_t) 0xcfb14012UL },
+ { &fnv_test_str[123], (Fnv32_t) 0xf01b2511UL },
+ { &fnv_test_str[124], (Fnv32_t) 0x0bbb59c3UL },
+ { &fnv_test_str[125], (Fnv32_t) 0xce524afaUL },
+ { &fnv_test_str[126], (Fnv32_t) 0xdd16ef45UL },
+ { &fnv_test_str[127], (Fnv32_t) 0x60648bb3UL },
+ { &fnv_test_str[128], (Fnv32_t) 0x7fa4bcfcUL },
+ { &fnv_test_str[129], (Fnv32_t) 0x5053ae17UL },
+ { &fnv_test_str[130], (Fnv32_t) 0xc9302890UL },
+ { &fnv_test_str[131], (Fnv32_t) 0x956ded32UL },
+ { &fnv_test_str[132], (Fnv32_t) 0x9136db84UL },
+ { &fnv_test_str[133], (Fnv32_t) 0xdf9d3323UL },
+ { &fnv_test_str[134], (Fnv32_t) 0x32bb6cd0UL },
+ { &fnv_test_str[135], (Fnv32_t) 0xc8f8385bUL },
+ { &fnv_test_str[136], (Fnv32_t) 0xeb08bfbaUL },
+ { &fnv_test_str[137], (Fnv32_t) 0x62cc8e3dUL },
+ { &fnv_test_str[138], (Fnv32_t) 0xc3e20f5cUL },
+ { &fnv_test_str[139], (Fnv32_t) 0x39e97f17UL },
+ { &fnv_test_str[140], (Fnv32_t) 0x7837b203UL },
+ { &fnv_test_str[141], (Fnv32_t) 0x319e877bUL },
+ { &fnv_test_str[142], (Fnv32_t) 0xd3e63f89UL },
+ { &fnv_test_str[143], (Fnv32_t) 0x29b50b38UL },
+ { &fnv_test_str[144], (Fnv32_t) 0x5ed678b8UL },
+ { &fnv_test_str[145], (Fnv32_t) 0xb0d5b793UL },
+ { &fnv_test_str[146], (Fnv32_t) 0x52450be5UL },
+ { &fnv_test_str[147], (Fnv32_t) 0xfa72d767UL },
+ { &fnv_test_str[148], (Fnv32_t) 0x95066709UL },
+ { &fnv_test_str[149], (Fnv32_t) 0x7f52e123UL },
+ { &fnv_test_str[150], (Fnv32_t) 0x76966481UL },
+ { &fnv_test_str[151], (Fnv32_t) 0x063258b0UL },
+ { &fnv_test_str[152], (Fnv32_t) 0x2ded6e8aUL },
+ { &fnv_test_str[153], (Fnv32_t) 0xb07d7c52UL },
+ { &fnv_test_str[154], (Fnv32_t) 0xd0c71b71UL },
+ { &fnv_test_str[155], (Fnv32_t) 0xf684f1bdUL },
+ { &fnv_test_str[156], (Fnv32_t) 0x868ecfa8UL },
+ { &fnv_test_str[157], (Fnv32_t) 0xf794f684UL },
+ { &fnv_test_str[158], (Fnv32_t) 0xd19701c3UL },
+ { &fnv_test_str[159], (Fnv32_t) 0x346e171eUL },
+ { &fnv_test_str[160], (Fnv32_t) 0x91f8f676UL },
+ { &fnv_test_str[161], (Fnv32_t) 0x0bf58848UL },
+ { &fnv_test_str[162], (Fnv32_t) 0x6317b6d1UL },
+ { &fnv_test_str[163], (Fnv32_t) 0xafad4c54UL },
+ { &fnv_test_str[164], (Fnv32_t) 0x0f25681eUL },
+ { &fnv_test_str[165], (Fnv32_t) 0x91b18d49UL },
+ { &fnv_test_str[166], (Fnv32_t) 0x7d61c12eUL },
+ { &fnv_test_str[167], (Fnv32_t) 0x5147d25cUL },
+ { &fnv_test_str[168], (Fnv32_t) 0x9a8b6805UL },
+ { &fnv_test_str[169], (Fnv32_t) 0x4cd2a447UL },
+ { &fnv_test_str[170], (Fnv32_t) 0x1e549b14UL },
+ { &fnv_test_str[171], (Fnv32_t) 0x2fe1b574UL },
+ { &fnv_test_str[172], (Fnv32_t) 0xcf0cd31eUL },
+ { &fnv_test_str[173], (Fnv32_t) 0x6c471669UL },
+ { &fnv_test_str[174], (Fnv32_t) 0x0e5eef1eUL },
+ { &fnv_test_str[175], (Fnv32_t) 0x2bed3602UL },
+ { &fnv_test_str[176], (Fnv32_t) 0xb26249e0UL },
+ { &fnv_test_str[177], (Fnv32_t) 0x2c9b86a4UL },
+ { &fnv_test_str[178], (Fnv32_t) 0xe415e2bbUL },
+ { &fnv_test_str[179], (Fnv32_t) 0x18a98d1dUL },
+ { &fnv_test_str[180], (Fnv32_t) 0xb7df8b7bUL },
+ { &fnv_test_str[181], (Fnv32_t) 0x241e9075UL },
+ { &fnv_test_str[182], (Fnv32_t) 0x063f70ddUL },
+ { &fnv_test_str[183], (Fnv32_t) 0x0295aed9UL },
+ { &fnv_test_str[184], (Fnv32_t) 0x56a7f781UL },
+ { &fnv_test_str[185], (Fnv32_t) 0x253bc645UL },
+ { &fnv_test_str[186], (Fnv32_t) 0x46610921UL },
+ { &fnv_test_str[187], (Fnv32_t) 0x7c1577f9UL },
+ { &fnv_test_str[188], (Fnv32_t) 0x512b2851UL },
+ { &fnv_test_str[189], (Fnv32_t) 0x76823999UL },
+ { &fnv_test_str[190], (Fnv32_t) 0xc0586935UL },
+ { &fnv_test_str[191], (Fnv32_t) 0xf3415c85UL },
+ { &fnv_test_str[192], (Fnv32_t) 0x0ae4ff65UL },
+ { &fnv_test_str[193], (Fnv32_t) 0x58b79725UL },
+ { &fnv_test_str[194], (Fnv32_t) 0xdea43aa5UL },
+ { &fnv_test_str[195], (Fnv32_t) 0x2bb3be35UL },
+ { &fnv_test_str[196], (Fnv32_t) 0xea777a45UL },
+ { &fnv_test_str[197], (Fnv32_t) 0x8f21c305UL },
+ { &fnv_test_str[198], (Fnv32_t) 0x5c9d0865UL },
+ { &fnv_test_str[199], (Fnv32_t) 0xfa823dd5UL },
+ { &fnv_test_str[200], (Fnv32_t) 0x21a27271UL },
+ { &fnv_test_str[201], (Fnv32_t) 0x83c5c6d5UL },
+ { &fnv_test_str[202], (Fnv32_t) 0x813b0881UL },
+ { NULL, 0 }
+};
+
+/* FNV-0 64 bit test vectors */
+#if defined(HAVE_64BIT_LONG_LONG)
+struct fnv0_64_test_vector fnv0_64_vector[] = {
+ { &fnv_test_str[0], (Fnv64_t) 0x0000000000000000ULL },
+ { &fnv_test_str[1], (Fnv64_t) 0x0000000000000061ULL },
+ { &fnv_test_str[2], (Fnv64_t) 0x0000000000000062ULL },
+ { &fnv_test_str[3], (Fnv64_t) 0x0000000000000063ULL },
+ { &fnv_test_str[4], (Fnv64_t) 0x0000000000000064ULL },
+ { &fnv_test_str[5], (Fnv64_t) 0x0000000000000065ULL },
+ { &fnv_test_str[6], (Fnv64_t) 0x0000000000000066ULL },
+ { &fnv_test_str[7], (Fnv64_t) 0x000066000000ad3dULL },
+ { &fnv_test_str[8], (Fnv64_t) 0x015a8f0001265ec8ULL },
+ { &fnv_test_str[9], (Fnv64_t) 0x733fc501f4330dbaULL },
+ { &fnv_test_str[10], (Fnv64_t) 0x08697c51f2c0536fULL },
+ { &fnv_test_str[11], (Fnv64_t) 0x0b91ae3f7ccdc5efULL },
+ { &fnv_test_str[12], (Fnv64_t) 0x0000000000000000ULL },
+ { &fnv_test_str[13], (Fnv64_t) 0x000061000000a4d3ULL },
+ { &fnv_test_str[14], (Fnv64_t) 0x000062000000a686ULL },
+ { &fnv_test_str[15], (Fnv64_t) 0x000063000000a839ULL },
+ { &fnv_test_str[16], (Fnv64_t) 0x000064000000a9ecULL },
+ { &fnv_test_str[17], (Fnv64_t) 0x000065000000ab9fULL },
+ { &fnv_test_str[18], (Fnv64_t) 0x000066000000ad52ULL },
+ { &fnv_test_str[19], (Fnv64_t) 0x015a8f0001265ea7ULL },
+ { &fnv_test_str[20], (Fnv64_t) 0x733fc501f4330dd8ULL },
+ { &fnv_test_str[21], (Fnv64_t) 0x08697c51f2c0530eULL },
+ { &fnv_test_str[22], (Fnv64_t) 0x0b91ae3f7ccdc59dULL },
+ { &fnv_test_str[23], (Fnv64_t) 0x765104e111a7551dULL },
+ { &fnv_test_str[24], (Fnv64_t) 0x000063000000a851ULL },
+ { &fnv_test_str[25], (Fnv64_t) 0x01508a00011e01ccULL },
+ { &fnv_test_str[26], (Fnv64_t) 0x59dc4a01e5fd0dcaULL },
+ { &fnv_test_str[27], (Fnv64_t) 0xae5f8b39ccfe6e59ULL },
+ { &fnv_test_str[28], (Fnv64_t) 0x4ac7ec3754558154ULL },
+ { &fnv_test_str[29], (Fnv64_t) 0x6737b6044d4ac19cULL },
+ { &fnv_test_str[30], (Fnv64_t) 0xae6be54f5606fc63ULL },
+ { &fnv_test_str[31], (Fnv64_t) 0x685308cf2ddedc58ULL },
+ { &fnv_test_str[32], (Fnv64_t) 0x23f4500af1b069fbULL },
+ { &fnv_test_str[33], (Fnv64_t) 0xc88dfd98aec415a1ULL },
+ { &fnv_test_str[34], (Fnv64_t) 0x8d5b8b70f730c0fbULL },
+ { &fnv_test_str[35], (Fnv64_t) 0x634eebf407d7eae4ULL },
+ { &fnv_test_str[36], (Fnv64_t) 0x9705d3a953e4211eULL },
+ { &fnv_test_str[37], (Fnv64_t) 0x8307c6b98ca4459fULL },
+ { &fnv_test_str[38], (Fnv64_t) 0x4a7c4c49fb224d0cULL },
+ { &fnv_test_str[39], (Fnv64_t) 0xb382adb5bb48eb6eULL },
+ { &fnv_test_str[40], (Fnv64_t) 0x01508a00011e01a3ULL },
+ { &fnv_test_str[41], (Fnv64_t) 0x59dc4a01e5fd0da4ULL },
+ { &fnv_test_str[42], (Fnv64_t) 0xae5f8b39ccfe6e3eULL },
+ { &fnv_test_str[43], (Fnv64_t) 0x4ac7ec375455813bULL },
+ { &fnv_test_str[44], (Fnv64_t) 0x6737b6044d4ac1bcULL },
+ { &fnv_test_str[45], (Fnv64_t) 0xae6be54f5606fc14ULL },
+ { &fnv_test_str[46], (Fnv64_t) 0x685308cf2ddedc39ULL },
+ { &fnv_test_str[47], (Fnv64_t) 0x23f4500af1b06988ULL },
+ { &fnv_test_str[48], (Fnv64_t) 0xc88dfd98aec41581ULL },
+ { &fnv_test_str[49], (Fnv64_t) 0x8d5b8b70f730c093ULL },
+ { &fnv_test_str[50], (Fnv64_t) 0x634eebf407d7ea81ULL },
+ { &fnv_test_str[51], (Fnv64_t) 0x9705d3a953e4216cULL },
+ { &fnv_test_str[52], (Fnv64_t) 0x8307c6b98ca445faULL },
+ { &fnv_test_str[53], (Fnv64_t) 0x4a7c4c49fb224d2dULL },
+ { &fnv_test_str[54], (Fnv64_t) 0xb382adb5bb48eb64ULL },
+ { &fnv_test_str[55], (Fnv64_t) 0x4ff899cd3ce80beaULL },
+ { &fnv_test_str[56], (Fnv64_t) 0x000063000000a84cULL },
+ { &fnv_test_str[57], (Fnv64_t) 0x01508500011df956ULL },
+ { &fnv_test_str[58], (Fnv64_t) 0x59cb5501e5eead46ULL },
+ { &fnv_test_str[59], (Fnv64_t) 0x832eb839b4906d81ULL },
+ { &fnv_test_str[60], (Fnv64_t) 0x78d08b0dd16a1213ULL },
+ { &fnv_test_str[61], (Fnv64_t) 0xb46e5b7ad73cb628ULL },
+ { &fnv_test_str[62], (Fnv64_t) 0xd43b99bbbc298596ULL },
+ { &fnv_test_str[63], (Fnv64_t) 0xcacbd000ba8dfd86ULL },
+ { &fnv_test_str[64], (Fnv64_t) 0x264ff73cff45ca92ULL },
+ { &fnv_test_str[65], (Fnv64_t) 0x5fabaea5c3973661ULL },
+ { &fnv_test_str[66], (Fnv64_t) 0x27f024ab59f166bbULL },
+ { &fnv_test_str[67], (Fnv64_t) 0xce750a29d5318fa4ULL },
+ { &fnv_test_str[68], (Fnv64_t) 0x026fe915433713d5ULL },
+ { &fnv_test_str[69], (Fnv64_t) 0x5b3ce4213696b2e5ULL },
+ { &fnv_test_str[70], (Fnv64_t) 0x01508500011df924ULL },
+ { &fnv_test_str[71], (Fnv64_t) 0x59cb5501e5eead22ULL },
+ { &fnv_test_str[72], (Fnv64_t) 0x832eb839b4906df2ULL },
+ { &fnv_test_str[73], (Fnv64_t) 0x78d08b0dd16a1233ULL },
+ { &fnv_test_str[74], (Fnv64_t) 0xb46e5b7ad73cb649ULL },
+ { &fnv_test_str[75], (Fnv64_t) 0xd43b99bbbc2985f8ULL },
+ { &fnv_test_str[76], (Fnv64_t) 0xcacbd000ba8dfde2ULL },
+ { &fnv_test_str[77], (Fnv64_t) 0x264ff73cff45cab2ULL },
+ { &fnv_test_str[78], (Fnv64_t) 0x5fabaea5c3973616ULL },
+ { &fnv_test_str[79], (Fnv64_t) 0x27f024ab59f166d3ULL },
+ { &fnv_test_str[80], (Fnv64_t) 0xce750a29d5318fc1ULL },
+ { &fnv_test_str[81], (Fnv64_t) 0x026fe915433713acULL },
+ { &fnv_test_str[82], (Fnv64_t) 0x5b3ce4213696b2efULL },
+ { &fnv_test_str[83], (Fnv64_t) 0x9f2a896fc211fb1fULL },
+ { &fnv_test_str[84], (Fnv64_t) 0x000068000000b0d1ULL },
+ { &fnv_test_str[85], (Fnv64_t) 0x01618900012c7323ULL },
+ { &fnv_test_str[86], (Fnv64_t) 0x3fa86e63bc7d03c8ULL },
+ { &fnv_test_str[87], (Fnv64_t) 0xa8375b79486d6cd8ULL },
+ { &fnv_test_str[88], (Fnv64_t) 0xa0d18504e316ac54ULL },
+ { &fnv_test_str[89], (Fnv64_t) 0x08a97b0004e7fe54ULL },
+ { &fnv_test_str[90], (Fnv64_t) 0xa0d18504e316ac57ULL },
+ { &fnv_test_str[91], (Fnv64_t) 0x1152f60009cffda9ULL },
+ { &fnv_test_str[92], (Fnv64_t) 0xa0d18504e316ac56ULL },
+ { &fnv_test_str[93], (Fnv64_t) 0x19fc71000eb7fcfeULL },
+ { &fnv_test_str[94], (Fnv64_t) 0xa0d18504e316ac51ULL },
+ { &fnv_test_str[95], (Fnv64_t) 0x22a5ec00139ffa53ULL },
+ { &fnv_test_str[96], (Fnv64_t) 0x29bed00139779a33ULL },
+ { &fnv_test_str[97], (Fnv64_t) 0x4dbc81014e3c19f5ULL },
+ { &fnv_test_str[98], (Fnv64_t) 0x29bed00139779a3dULL },
+ { &fnv_test_str[99], (Fnv64_t) 0x81a72b016b9f7573ULL },
+ { &fnv_test_str[100], (Fnv64_t) 0x29bed00139779a23ULL },
+ { &fnv_test_str[101], (Fnv64_t) 0xd85411019cbbce45ULL },
+ { &fnv_test_str[102], (Fnv64_t) 0xf548616b8621d657ULL },
+ { &fnv_test_str[103], (Fnv64_t) 0xebd3e0b4eb7f35d5ULL },
+ { &fnv_test_str[104], (Fnv64_t) 0xf548616b8621d654ULL },
+ { &fnv_test_str[105], (Fnv64_t) 0xebd3ddb4eb7f30bcULL },
+ { &fnv_test_str[106], (Fnv64_t) 0xf548616b8621d655ULL },
+ { &fnv_test_str[107], (Fnv64_t) 0xebd3deb4eb7f326fULL },
+ { &fnv_test_str[108], (Fnv64_t) 0x581cb60340ab0968ULL },
+ { &fnv_test_str[109], (Fnv64_t) 0x63d2af86e2a0fbb8ULL },
+ { &fnv_test_str[110], (Fnv64_t) 0x581cb70340ab0b37ULL },
+ { &fnv_test_str[111], (Fnv64_t) 0x63d63186e2a40e75ULL },
+ { &fnv_test_str[112], (Fnv64_t) 0x581cc40340ab212eULL },
+ { &fnv_test_str[113], (Fnv64_t) 0x64023f86e2c9612aULL },
+ { &fnv_test_str[114], (Fnv64_t) 0xdbda6a26c33c909fULL },
+ { &fnv_test_str[115], (Fnv64_t) 0xd0b2feddbfe9be2dULL },
+ { &fnv_test_str[116], (Fnv64_t) 0x9c9eae3f5d037decULL },
+ { &fnv_test_str[117], (Fnv64_t) 0x252001ab0ceef804ULL },
+ { &fnv_test_str[118], (Fnv64_t) 0x4456a56f9e05cfefULL },
+ { &fnv_test_str[119], (Fnv64_t) 0x250b0ba983e0531dULL },
+ { &fnv_test_str[120], (Fnv64_t) 0x52b007213b27b33eULL },
+ { &fnv_test_str[121], (Fnv64_t) 0xcbf29ce484222325ULL },
+ { &fnv_test_str[122], (Fnv64_t) 0xaf63bd4c8601b7dfULL },
+ { &fnv_test_str[123], (Fnv64_t) 0x128599ccddae09f8ULL },
+ { &fnv_test_str[124], (Fnv64_t) 0x270e4f1caebaf068ULL },
+ { &fnv_test_str[125], (Fnv64_t) 0x01517d497446a395ULL },
+ { &fnv_test_str[126], (Fnv64_t) 0x9af5a29a89450b40ULL },
+ { &fnv_test_str[127], (Fnv64_t) 0xb502f6c063ba72e8ULL },
+ { &fnv_test_str[128], (Fnv64_t) 0xacf41561498ca7dfULL },
+ { &fnv_test_str[129], (Fnv64_t) 0x6be8c2423a351542ULL },
+ { &fnv_test_str[130], (Fnv64_t) 0xd04f1f6da96ce4a3ULL },
+ { &fnv_test_str[131], (Fnv64_t) 0x69eb9a8f282c7235ULL },
+ { &fnv_test_str[132], (Fnv64_t) 0x6a7e5a418f77cfc5ULL },
+ { &fnv_test_str[133], (Fnv64_t) 0xbcaf568ddc2ecba0ULL },
+ { &fnv_test_str[134], (Fnv64_t) 0xb03b5cc4c38f8b1fULL },
+ { &fnv_test_str[135], (Fnv64_t) 0xf89a9f51432db828ULL },
+ { &fnv_test_str[136], (Fnv64_t) 0x549e856be6103429ULL },
+ { &fnv_test_str[137], (Fnv64_t) 0x3cf50d224d29377aULL },
+ { &fnv_test_str[138], (Fnv64_t) 0xdb762df418c10c37ULL },
+ { &fnv_test_str[139], (Fnv64_t) 0xfeeb4226b0e9a6baULL },
+ { &fnv_test_str[140], (Fnv64_t) 0x7004a4cd9310c052ULL },
+ { &fnv_test_str[141], (Fnv64_t) 0xd1c727d7f5329276ULL },
+ { &fnv_test_str[142], (Fnv64_t) 0xbe313796596ce908ULL },
+ { &fnv_test_str[143], (Fnv64_t) 0x768f67ede090fcc5ULL },
+ { &fnv_test_str[144], (Fnv64_t) 0xa81563cc9db9bfc3ULL },
+ { &fnv_test_str[145], (Fnv64_t) 0x47194043c55197a8ULL },
+ { &fnv_test_str[146], (Fnv64_t) 0xc99d81864aebab02ULL },
+ { &fnv_test_str[147], (Fnv64_t) 0xcc1f161b235ea4a2ULL },
+ { &fnv_test_str[148], (Fnv64_t) 0xaadab0c420ecd434ULL },
+ { &fnv_test_str[149], (Fnv64_t) 0x6b3c034d6f44d740ULL },
+ { &fnv_test_str[150], (Fnv64_t) 0x73a45e850602cbc6ULL },
+ { &fnv_test_str[151], (Fnv64_t) 0x72360f04f0cd227bULL },
+ { &fnv_test_str[152], (Fnv64_t) 0xa9ca80be384a778fULL },
+ { &fnv_test_str[153], (Fnv64_t) 0xd4085e66906889e3ULL },
+ { &fnv_test_str[154], (Fnv64_t) 0x93aa8b2748efdbc8ULL },
+ { &fnv_test_str[155], (Fnv64_t) 0x6f8cd678407436a2ULL },
+ { &fnv_test_str[156], (Fnv64_t) 0xf39a43d4dc8be4c7ULL },
+ { &fnv_test_str[157], (Fnv64_t) 0xd7f5cec91125d245ULL },
+ { &fnv_test_str[158], (Fnv64_t) 0x691d7b73be18adc4ULL },
+ { &fnv_test_str[159], (Fnv64_t) 0xf4361e01caf6b691ULL },
+ { &fnv_test_str[160], (Fnv64_t) 0xde7d8264f64be089ULL },
+ { &fnv_test_str[161], (Fnv64_t) 0xa34ff43e5545c06fULL },
+ { &fnv_test_str[162], (Fnv64_t) 0x181f0b8e908a2bdeULL },
+ { &fnv_test_str[163], (Fnv64_t) 0x28a965b78ddbc071ULL },
+ { &fnv_test_str[164], (Fnv64_t) 0xead9cea0e3cc6ae5ULL },
+ { &fnv_test_str[165], (Fnv64_t) 0x0b6743153b43ebbaULL },
+ { &fnv_test_str[166], (Fnv64_t) 0xa7aa3f012c74528dULL },
+ { &fnv_test_str[167], (Fnv64_t) 0x2d5d8ad7f9dffeb7ULL },
+ { &fnv_test_str[168], (Fnv64_t) 0x00750fb6e19624eaULL },
+ { &fnv_test_str[169], (Fnv64_t) 0x01c125a4e6c76c82ULL },
+ { &fnv_test_str[170], (Fnv64_t) 0x3fde3afac0722f1fULL },
+ { &fnv_test_str[171], (Fnv64_t) 0xd7c3eaf4abaa379dULL },
+ { &fnv_test_str[172], (Fnv64_t) 0xd2217e1c923c9f3fULL },
+ { &fnv_test_str[173], (Fnv64_t) 0x82d0a2e3b725caf6ULL },
+ { &fnv_test_str[174], (Fnv64_t) 0x0a10bee8eeb72e4fULL },
+ { &fnv_test_str[175], (Fnv64_t) 0xc530e8723e72c6fdULL },
+ { &fnv_test_str[176], (Fnv64_t) 0xd8d34dcd2e7bad99ULL },
+ { &fnv_test_str[177], (Fnv64_t) 0xecf77466e9a2baf3ULL },
+ { &fnv_test_str[178], (Fnv64_t) 0xde3d2ddb043b9666ULL },
+ { &fnv_test_str[179], (Fnv64_t) 0xd1cc824e1a8157d8ULL },
+ { &fnv_test_str[180], (Fnv64_t) 0x7d5c68ecbc90512eULL },
+ { &fnv_test_str[181], (Fnv64_t) 0x2f7c691b1d7c76d8ULL },
+ { &fnv_test_str[182], (Fnv64_t) 0x5d88c2bad3a46bc8ULL },
+ { &fnv_test_str[183], (Fnv64_t) 0xdf107320276647a0ULL },
+ { &fnv_test_str[184], (Fnv64_t) 0x0f78f22e7e70e9bcULL },
+ { &fnv_test_str[185], (Fnv64_t) 0x8c67be5c80f67d04ULL },
+ { &fnv_test_str[186], (Fnv64_t) 0x07c1adfa4d019194ULL },
+ { &fnv_test_str[187], (Fnv64_t) 0xce1312420c5b1af4ULL },
+ { &fnv_test_str[188], (Fnv64_t) 0x043a41b2dc53ab24ULL },
+ { &fnv_test_str[189], (Fnv64_t) 0x0b038eebf7340860ULL },
+ { &fnv_test_str[190], (Fnv64_t) 0x1bcd837353fb69b0ULL },
+ { &fnv_test_str[191], (Fnv64_t) 0x46f992fc59eff180ULL },
+ { &fnv_test_str[192], (Fnv64_t) 0x497678ee29ae79c0ULL },
+ { &fnv_test_str[193], (Fnv64_t) 0xb10a62280ddd4450ULL },
+ { &fnv_test_str[194], (Fnv64_t) 0x35eb228db4d68140ULL },
+ { &fnv_test_str[195], (Fnv64_t) 0x8b350e86d9470870ULL },
+ { &fnv_test_str[196], (Fnv64_t) 0x4e1fbdb2812e9540ULL },
+ { &fnv_test_str[197], (Fnv64_t) 0x051e080df69a0600ULL },
+ { &fnv_test_str[198], (Fnv64_t) 0x45e1e8ae54dadb40ULL },
+ { &fnv_test_str[199], (Fnv64_t) 0x0000000000000000ULL },
+ { &fnv_test_str[200], (Fnv64_t) 0xcd73806290557064ULL },
+ { &fnv_test_str[201], (Fnv64_t) 0x2613a37bbe0317c8ULL },
+ { &fnv_test_str[202], (Fnv64_t) 0x1480e21fcf2ae5e4ULL },
+ { NULL, (Fnv64_t) 0 }
+};
+#else /* HAVE_64BIT_LONG_LONG */
+struct fnv0_64_test_vector fnv0_64_vector[] = {
+ { &fnv_test_str[0], (Fnv64_t) {0x00000000UL, 0x00000000UL} },
+ { &fnv_test_str[1], (Fnv64_t) {0x00000061UL, 0x00000000UL} },
+ { &fnv_test_str[2], (Fnv64_t) {0x00000062UL, 0x00000000UL} },
+ { &fnv_test_str[3], (Fnv64_t) {0x00000063UL, 0x00000000UL} },
+ { &fnv_test_str[4], (Fnv64_t) {0x00000064UL, 0x00000000UL} },
+ { &fnv_test_str[5], (Fnv64_t) {0x00000065UL, 0x00000000UL} },
+ { &fnv_test_str[6], (Fnv64_t) {0x00000066UL, 0x00000000UL} },
+ { &fnv_test_str[7], (Fnv64_t) {0x0000ad3dUL, 0x00006600UL} },
+ { &fnv_test_str[8], (Fnv64_t) {0x01265ec8UL, 0x015a8f00UL} },
+ { &fnv_test_str[9], (Fnv64_t) {0xf4330dbaUL, 0x733fc501UL} },
+ { &fnv_test_str[10], (Fnv64_t) {0xf2c0536fUL, 0x08697c51UL} },
+ { &fnv_test_str[11], (Fnv64_t) {0x7ccdc5efUL, 0x0b91ae3fUL} },
+ { &fnv_test_str[12], (Fnv64_t) {0x00000000UL, 0x00000000UL} },
+ { &fnv_test_str[13], (Fnv64_t) {0x0000a4d3UL, 0x00006100UL} },
+ { &fnv_test_str[14], (Fnv64_t) {0x0000a686UL, 0x00006200UL} },
+ { &fnv_test_str[15], (Fnv64_t) {0x0000a839UL, 0x00006300UL} },
+ { &fnv_test_str[16], (Fnv64_t) {0x0000a9ecUL, 0x00006400UL} },
+ { &fnv_test_str[17], (Fnv64_t) {0x0000ab9fUL, 0x00006500UL} },
+ { &fnv_test_str[18], (Fnv64_t) {0x0000ad52UL, 0x00006600UL} },
+ { &fnv_test_str[19], (Fnv64_t) {0x01265ea7UL, 0x015a8f00UL} },
+ { &fnv_test_str[20], (Fnv64_t) {0xf4330dd8UL, 0x733fc501UL} },
+ { &fnv_test_str[21], (Fnv64_t) {0xf2c0530eUL, 0x08697c51UL} },
+ { &fnv_test_str[22], (Fnv64_t) {0x7ccdc59dUL, 0x0b91ae3fUL} },
+ { &fnv_test_str[23], (Fnv64_t) {0x11a7551dUL, 0x765104e1UL} },
+ { &fnv_test_str[24], (Fnv64_t) {0x0000a851UL, 0x00006300UL} },
+ { &fnv_test_str[25], (Fnv64_t) {0x011e01ccUL, 0x01508a00UL} },
+ { &fnv_test_str[26], (Fnv64_t) {0xe5fd0dcaUL, 0x59dc4a01UL} },
+ { &fnv_test_str[27], (Fnv64_t) {0xccfe6e59UL, 0xae5f8b39UL} },
+ { &fnv_test_str[28], (Fnv64_t) {0x54558154UL, 0x4ac7ec37UL} },
+ { &fnv_test_str[29], (Fnv64_t) {0x4d4ac19cUL, 0x6737b604UL} },
+ { &fnv_test_str[30], (Fnv64_t) {0x5606fc63UL, 0xae6be54fUL} },
+ { &fnv_test_str[31], (Fnv64_t) {0x2ddedc58UL, 0x685308cfUL} },
+ { &fnv_test_str[32], (Fnv64_t) {0xf1b069fbUL, 0x23f4500aUL} },
+ { &fnv_test_str[33], (Fnv64_t) {0xaec415a1UL, 0xc88dfd98UL} },
+ { &fnv_test_str[34], (Fnv64_t) {0xf730c0fbUL, 0x8d5b8b70UL} },
+ { &fnv_test_str[35], (Fnv64_t) {0x07d7eae4UL, 0x634eebf4UL} },
+ { &fnv_test_str[36], (Fnv64_t) {0x53e4211eUL, 0x9705d3a9UL} },
+ { &fnv_test_str[37], (Fnv64_t) {0x8ca4459fUL, 0x8307c6b9UL} },
+ { &fnv_test_str[38], (Fnv64_t) {0xfb224d0cUL, 0x4a7c4c49UL} },
+ { &fnv_test_str[39], (Fnv64_t) {0xbb48eb6eUL, 0xb382adb5UL} },
+ { &fnv_test_str[40], (Fnv64_t) {0x011e01a3UL, 0x01508a00UL} },
+ { &fnv_test_str[41], (Fnv64_t) {0xe5fd0da4UL, 0x59dc4a01UL} },
+ { &fnv_test_str[42], (Fnv64_t) {0xccfe6e3eUL, 0xae5f8b39UL} },
+ { &fnv_test_str[43], (Fnv64_t) {0x5455813bUL, 0x4ac7ec37UL} },
+ { &fnv_test_str[44], (Fnv64_t) {0x4d4ac1bcUL, 0x6737b604UL} },
+ { &fnv_test_str[45], (Fnv64_t) {0x5606fc14UL, 0xae6be54fUL} },
+ { &fnv_test_str[46], (Fnv64_t) {0x2ddedc39UL, 0x685308cfUL} },
+ { &fnv_test_str[47], (Fnv64_t) {0xf1b06988UL, 0x23f4500aUL} },
+ { &fnv_test_str[48], (Fnv64_t) {0xaec41581UL, 0xc88dfd98UL} },
+ { &fnv_test_str[49], (Fnv64_t) {0xf730c093UL, 0x8d5b8b70UL} },
+ { &fnv_test_str[50], (Fnv64_t) {0x07d7ea81UL, 0x634eebf4UL} },
+ { &fnv_test_str[51], (Fnv64_t) {0x53e4216cUL, 0x9705d3a9UL} },
+ { &fnv_test_str[52], (Fnv64_t) {0x8ca445faUL, 0x8307c6b9UL} },
+ { &fnv_test_str[53], (Fnv64_t) {0xfb224d2dUL, 0x4a7c4c49UL} },
+ { &fnv_test_str[54], (Fnv64_t) {0xbb48eb64UL, 0xb382adb5UL} },
+ { &fnv_test_str[55], (Fnv64_t) {0x3ce80beaUL, 0x4ff899cdUL} },
+ { &fnv_test_str[56], (Fnv64_t) {0x0000a84cUL, 0x00006300UL} },
+ { &fnv_test_str[57], (Fnv64_t) {0x011df956UL, 0x01508500UL} },
+ { &fnv_test_str[58], (Fnv64_t) {0xe5eead46UL, 0x59cb5501UL} },
+ { &fnv_test_str[59], (Fnv64_t) {0xb4906d81UL, 0x832eb839UL} },
+ { &fnv_test_str[60], (Fnv64_t) {0xd16a1213UL, 0x78d08b0dUL} },
+ { &fnv_test_str[61], (Fnv64_t) {0xd73cb628UL, 0xb46e5b7aUL} },
+ { &fnv_test_str[62], (Fnv64_t) {0xbc298596UL, 0xd43b99bbUL} },
+ { &fnv_test_str[63], (Fnv64_t) {0xba8dfd86UL, 0xcacbd000UL} },
+ { &fnv_test_str[64], (Fnv64_t) {0xff45ca92UL, 0x264ff73cUL} },
+ { &fnv_test_str[65], (Fnv64_t) {0xc3973661UL, 0x5fabaea5UL} },
+ { &fnv_test_str[66], (Fnv64_t) {0x59f166bbUL, 0x27f024abUL} },
+ { &fnv_test_str[67], (Fnv64_t) {0xd5318fa4UL, 0xce750a29UL} },
+ { &fnv_test_str[68], (Fnv64_t) {0x433713d5UL, 0x026fe915UL} },
+ { &fnv_test_str[69], (Fnv64_t) {0x3696b2e5UL, 0x5b3ce421UL} },
+ { &fnv_test_str[70], (Fnv64_t) {0x011df924UL, 0x01508500UL} },
+ { &fnv_test_str[71], (Fnv64_t) {0xe5eead22UL, 0x59cb5501UL} },
+ { &fnv_test_str[72], (Fnv64_t) {0xb4906df2UL, 0x832eb839UL} },
+ { &fnv_test_str[73], (Fnv64_t) {0xd16a1233UL, 0x78d08b0dUL} },
+ { &fnv_test_str[74], (Fnv64_t) {0xd73cb649UL, 0xb46e5b7aUL} },
+ { &fnv_test_str[75], (Fnv64_t) {0xbc2985f8UL, 0xd43b99bbUL} },
+ { &fnv_test_str[76], (Fnv64_t) {0xba8dfde2UL, 0xcacbd000UL} },
+ { &fnv_test_str[77], (Fnv64_t) {0xff45cab2UL, 0x264ff73cUL} },
+ { &fnv_test_str[78], (Fnv64_t) {0xc3973616UL, 0x5fabaea5UL} },
+ { &fnv_test_str[79], (Fnv64_t) {0x59f166d3UL, 0x27f024abUL} },
+ { &fnv_test_str[80], (Fnv64_t) {0xd5318fc1UL, 0xce750a29UL} },
+ { &fnv_test_str[81], (Fnv64_t) {0x433713acUL, 0x026fe915UL} },
+ { &fnv_test_str[82], (Fnv64_t) {0x3696b2efUL, 0x5b3ce421UL} },
+ { &fnv_test_str[83], (Fnv64_t) {0xc211fb1fUL, 0x9f2a896fUL} },
+ { &fnv_test_str[84], (Fnv64_t) {0x0000b0d1UL, 0x00006800UL} },
+ { &fnv_test_str[85], (Fnv64_t) {0x012c7323UL, 0x01618900UL} },
+ { &fnv_test_str[86], (Fnv64_t) {0xbc7d03c8UL, 0x3fa86e63UL} },
+ { &fnv_test_str[87], (Fnv64_t) {0x486d6cd8UL, 0xa8375b79UL} },
+ { &fnv_test_str[88], (Fnv64_t) {0xe316ac54UL, 0xa0d18504UL} },
+ { &fnv_test_str[89], (Fnv64_t) {0x04e7fe54UL, 0x08a97b00UL} },
+ { &fnv_test_str[90], (Fnv64_t) {0xe316ac57UL, 0xa0d18504UL} },
+ { &fnv_test_str[91], (Fnv64_t) {0x09cffda9UL, 0x1152f600UL} },
+ { &fnv_test_str[92], (Fnv64_t) {0xe316ac56UL, 0xa0d18504UL} },
+ { &fnv_test_str[93], (Fnv64_t) {0x0eb7fcfeUL, 0x19fc7100UL} },
+ { &fnv_test_str[94], (Fnv64_t) {0xe316ac51UL, 0xa0d18504UL} },
+ { &fnv_test_str[95], (Fnv64_t) {0x139ffa53UL, 0x22a5ec00UL} },
+ { &fnv_test_str[96], (Fnv64_t) {0x39779a33UL, 0x29bed001UL} },
+ { &fnv_test_str[97], (Fnv64_t) {0x4e3c19f5UL, 0x4dbc8101UL} },
+ { &fnv_test_str[98], (Fnv64_t) {0x39779a3dUL, 0x29bed001UL} },
+ { &fnv_test_str[99], (Fnv64_t) {0x6b9f7573UL, 0x81a72b01UL} },
+ { &fnv_test_str[100], (Fnv64_t) {0x39779a23UL, 0x29bed001UL} },
+ { &fnv_test_str[101], (Fnv64_t) {0x9cbbce45UL, 0xd8541101UL} },
+ { &fnv_test_str[102], (Fnv64_t) {0x8621d657UL, 0xf548616bUL} },
+ { &fnv_test_str[103], (Fnv64_t) {0xeb7f35d5UL, 0xebd3e0b4UL} },
+ { &fnv_test_str[104], (Fnv64_t) {0x8621d654UL, 0xf548616bUL} },
+ { &fnv_test_str[105], (Fnv64_t) {0xeb7f30bcUL, 0xebd3ddb4UL} },
+ { &fnv_test_str[106], (Fnv64_t) {0x8621d655UL, 0xf548616bUL} },
+ { &fnv_test_str[107], (Fnv64_t) {0xeb7f326fUL, 0xebd3deb4UL} },
+ { &fnv_test_str[108], (Fnv64_t) {0x40ab0968UL, 0x581cb603UL} },
+ { &fnv_test_str[109], (Fnv64_t) {0xe2a0fbb8UL, 0x63d2af86UL} },
+ { &fnv_test_str[110], (Fnv64_t) {0x40ab0b37UL, 0x581cb703UL} },
+ { &fnv_test_str[111], (Fnv64_t) {0xe2a40e75UL, 0x63d63186UL} },
+ { &fnv_test_str[112], (Fnv64_t) {0x40ab212eUL, 0x581cc403UL} },
+ { &fnv_test_str[113], (Fnv64_t) {0xe2c9612aUL, 0x64023f86UL} },
+ { &fnv_test_str[114], (Fnv64_t) {0xc33c909fUL, 0xdbda6a26UL} },
+ { &fnv_test_str[115], (Fnv64_t) {0xbfe9be2dUL, 0xd0b2feddUL} },
+ { &fnv_test_str[116], (Fnv64_t) {0x5d037decUL, 0x9c9eae3fUL} },
+ { &fnv_test_str[117], (Fnv64_t) {0x0ceef804UL, 0x252001abUL} },
+ { &fnv_test_str[118], (Fnv64_t) {0x9e05cfefUL, 0x4456a56fUL} },
+ { &fnv_test_str[119], (Fnv64_t) {0x83e0531dUL, 0x250b0ba9UL} },
+ { &fnv_test_str[120], (Fnv64_t) {0x3b27b33eUL, 0x52b00721UL} },
+ { &fnv_test_str[121], (Fnv64_t) {0x84222325UL, 0xcbf29ce4UL} },
+ { &fnv_test_str[122], (Fnv64_t) {0x8601b7dfUL, 0xaf63bd4cUL} },
+ { &fnv_test_str[123], (Fnv64_t) {0xddae09f8UL, 0x128599ccUL} },
+ { &fnv_test_str[124], (Fnv64_t) {0xaebaf068UL, 0x270e4f1cUL} },
+ { &fnv_test_str[125], (Fnv64_t) {0x7446a395UL, 0x01517d49UL} },
+ { &fnv_test_str[126], (Fnv64_t) {0x89450b40UL, 0x9af5a29aUL} },
+ { &fnv_test_str[127], (Fnv64_t) {0x63ba72e8UL, 0xb502f6c0UL} },
+ { &fnv_test_str[128], (Fnv64_t) {0x498ca7dfUL, 0xacf41561UL} },
+ { &fnv_test_str[129], (Fnv64_t) {0x3a351542UL, 0x6be8c242UL} },
+ { &fnv_test_str[130], (Fnv64_t) {0xa96ce4a3UL, 0xd04f1f6dUL} },
+ { &fnv_test_str[131], (Fnv64_t) {0x282c7235UL, 0x69eb9a8fUL} },
+ { &fnv_test_str[132], (Fnv64_t) {0x8f77cfc5UL, 0x6a7e5a41UL} },
+ { &fnv_test_str[133], (Fnv64_t) {0xdc2ecba0UL, 0xbcaf568dUL} },
+ { &fnv_test_str[134], (Fnv64_t) {0xc38f8b1fUL, 0xb03b5cc4UL} },
+ { &fnv_test_str[135], (Fnv64_t) {0x432db828UL, 0xf89a9f51UL} },
+ { &fnv_test_str[136], (Fnv64_t) {0xe6103429UL, 0x549e856bUL} },
+ { &fnv_test_str[137], (Fnv64_t) {0x4d29377aUL, 0x3cf50d22UL} },
+ { &fnv_test_str[138], (Fnv64_t) {0x18c10c37UL, 0xdb762df4UL} },
+ { &fnv_test_str[139], (Fnv64_t) {0xb0e9a6baUL, 0xfeeb4226UL} },
+ { &fnv_test_str[140], (Fnv64_t) {0x9310c052UL, 0x7004a4cdUL} },
+ { &fnv_test_str[141], (Fnv64_t) {0xf5329276UL, 0xd1c727d7UL} },
+ { &fnv_test_str[142], (Fnv64_t) {0x596ce908UL, 0xbe313796UL} },
+ { &fnv_test_str[143], (Fnv64_t) {0xe090fcc5UL, 0x768f67edUL} },
+ { &fnv_test_str[144], (Fnv64_t) {0x9db9bfc3UL, 0xa81563ccUL} },
+ { &fnv_test_str[145], (Fnv64_t) {0xc55197a8UL, 0x47194043UL} },
+ { &fnv_test_str[146], (Fnv64_t) {0x4aebab02UL, 0xc99d8186UL} },
+ { &fnv_test_str[147], (Fnv64_t) {0x235ea4a2UL, 0xcc1f161bUL} },
+ { &fnv_test_str[148], (Fnv64_t) {0x20ecd434UL, 0xaadab0c4UL} },
+ { &fnv_test_str[149], (Fnv64_t) {0x6f44d740UL, 0x6b3c034dUL} },
+ { &fnv_test_str[150], (Fnv64_t) {0x0602cbc6UL, 0x73a45e85UL} },
+ { &fnv_test_str[151], (Fnv64_t) {0xf0cd227bUL, 0x72360f04UL} },
+ { &fnv_test_str[152], (Fnv64_t) {0x384a778fUL, 0xa9ca80beUL} },
+ { &fnv_test_str[153], (Fnv64_t) {0x906889e3UL, 0xd4085e66UL} },
+ { &fnv_test_str[154], (Fnv64_t) {0x48efdbc8UL, 0x93aa8b27UL} },
+ { &fnv_test_str[155], (Fnv64_t) {0x407436a2UL, 0x6f8cd678UL} },
+ { &fnv_test_str[156], (Fnv64_t) {0xdc8be4c7UL, 0xf39a43d4UL} },
+ { &fnv_test_str[157], (Fnv64_t) {0x1125d245UL, 0xd7f5cec9UL} },
+ { &fnv_test_str[158], (Fnv64_t) {0xbe18adc4UL, 0x691d7b73UL} },
+ { &fnv_test_str[159], (Fnv64_t) {0xcaf6b691UL, 0xf4361e01UL} },
+ { &fnv_test_str[160], (Fnv64_t) {0xf64be089UL, 0xde7d8264UL} },
+ { &fnv_test_str[161], (Fnv64_t) {0x5545c06fUL, 0xa34ff43eUL} },
+ { &fnv_test_str[162], (Fnv64_t) {0x908a2bdeUL, 0x181f0b8eUL} },
+ { &fnv_test_str[163], (Fnv64_t) {0x8ddbc071UL, 0x28a965b7UL} },
+ { &fnv_test_str[164], (Fnv64_t) {0xe3cc6ae5UL, 0xead9cea0UL} },
+ { &fnv_test_str[165], (Fnv64_t) {0x3b43ebbaUL, 0x0b674315UL} },
+ { &fnv_test_str[166], (Fnv64_t) {0x2c74528dUL, 0xa7aa3f01UL} },
+ { &fnv_test_str[167], (Fnv64_t) {0xf9dffeb7UL, 0x2d5d8ad7UL} },
+ { &fnv_test_str[168], (Fnv64_t) {0xe19624eaUL, 0x00750fb6UL} },
+ { &fnv_test_str[169], (Fnv64_t) {0xe6c76c82UL, 0x01c125a4UL} },
+ { &fnv_test_str[170], (Fnv64_t) {0xc0722f1fUL, 0x3fde3afaUL} },
+ { &fnv_test_str[171], (Fnv64_t) {0xabaa379dUL, 0xd7c3eaf4UL} },
+ { &fnv_test_str[172], (Fnv64_t) {0x923c9f3fUL, 0xd2217e1cUL} },
+ { &fnv_test_str[173], (Fnv64_t) {0xb725caf6UL, 0x82d0a2e3UL} },
+ { &fnv_test_str[174], (Fnv64_t) {0xeeb72e4fUL, 0x0a10bee8UL} },
+ { &fnv_test_str[175], (Fnv64_t) {0x3e72c6fdUL, 0xc530e872UL} },
+ { &fnv_test_str[176], (Fnv64_t) {0x2e7bad99UL, 0xd8d34dcdUL} },
+ { &fnv_test_str[177], (Fnv64_t) {0xe9a2baf3UL, 0xecf77466UL} },
+ { &fnv_test_str[178], (Fnv64_t) {0x043b9666UL, 0xde3d2ddbUL} },
+ { &fnv_test_str[179], (Fnv64_t) {0x1a8157d8UL, 0xd1cc824eUL} },
+ { &fnv_test_str[180], (Fnv64_t) {0xbc90512eUL, 0x7d5c68ecUL} },
+ { &fnv_test_str[181], (Fnv64_t) {0x1d7c76d8UL, 0x2f7c691bUL} },
+ { &fnv_test_str[182], (Fnv64_t) {0xd3a46bc8UL, 0x5d88c2baUL} },
+ { &fnv_test_str[183], (Fnv64_t) {0x276647a0UL, 0xdf107320UL} },
+ { &fnv_test_str[184], (Fnv64_t) {0x7e70e9bcUL, 0x0f78f22eUL} },
+ { &fnv_test_str[185], (Fnv64_t) {0x80f67d04UL, 0x8c67be5cUL} },
+ { &fnv_test_str[186], (Fnv64_t) {0x4d019194UL, 0x07c1adfaUL} },
+ { &fnv_test_str[187], (Fnv64_t) {0x0c5b1af4UL, 0xce131242UL} },
+ { &fnv_test_str[188], (Fnv64_t) {0xdc53ab24UL, 0x043a41b2UL} },
+ { &fnv_test_str[189], (Fnv64_t) {0xf7340860UL, 0x0b038eebUL} },
+ { &fnv_test_str[190], (Fnv64_t) {0x53fb69b0UL, 0x1bcd8373UL} },
+ { &fnv_test_str[191], (Fnv64_t) {0x59eff180UL, 0x46f992fcUL} },
+ { &fnv_test_str[192], (Fnv64_t) {0x29ae79c0UL, 0x497678eeUL} },
+ { &fnv_test_str[193], (Fnv64_t) {0x0ddd4450UL, 0xb10a6228UL} },
+ { &fnv_test_str[194], (Fnv64_t) {0xb4d68140UL, 0x35eb228dUL} },
+ { &fnv_test_str[195], (Fnv64_t) {0xd9470870UL, 0x8b350e86UL} },
+ { &fnv_test_str[196], (Fnv64_t) {0x812e9540UL, 0x4e1fbdb2UL} },
+ { &fnv_test_str[197], (Fnv64_t) {0xf69a0600UL, 0x051e080dUL} },
+ { &fnv_test_str[198], (Fnv64_t) {0x54dadb40UL, 0x45e1e8aeUL} },
+ { &fnv_test_str[199], (Fnv64_t) {0x00000000UL, 0x00000000UL} },
+ { &fnv_test_str[200], (Fnv64_t) {0x90557064UL, 0xcd738062UL} },
+ { &fnv_test_str[201], (Fnv64_t) {0xbe0317c8UL, 0x2613a37bUL} },
+ { &fnv_test_str[202], (Fnv64_t) {0xcf2ae5e4UL, 0x1480e21fUL} },
+ { NULL, (Fnv64_t) {0,0} }
+};
+#endif /* HAVE_64BIT_LONG_LONG */
+
+/* FNV-1 64 bit test vectors */
+#if defined(HAVE_64BIT_LONG_LONG)
+struct fnv1_64_test_vector fnv1_64_vector[] = {
+ { &fnv_test_str[0], (Fnv64_t) 0xcbf29ce484222325ULL },
+ { &fnv_test_str[1], (Fnv64_t) 0xaf63bd4c8601b7beULL },
+ { &fnv_test_str[2], (Fnv64_t) 0xaf63bd4c8601b7bdULL },
+ { &fnv_test_str[3], (Fnv64_t) 0xaf63bd4c8601b7bcULL },
+ { &fnv_test_str[4], (Fnv64_t) 0xaf63bd4c8601b7bbULL },
+ { &fnv_test_str[5], (Fnv64_t) 0xaf63bd4c8601b7baULL },
+ { &fnv_test_str[6], (Fnv64_t) 0xaf63bd4c8601b7b9ULL },
+ { &fnv_test_str[7], (Fnv64_t) 0x08326207b4eb2f34ULL },
+ { &fnv_test_str[8], (Fnv64_t) 0xd8cbc7186ba13533ULL },
+ { &fnv_test_str[9], (Fnv64_t) 0x0378817ee2ed65cbULL },
+ { &fnv_test_str[10], (Fnv64_t) 0xd329d59b9963f790ULL },
+ { &fnv_test_str[11], (Fnv64_t) 0x340d8765a4dda9c2ULL },
+ { &fnv_test_str[12], (Fnv64_t) 0xaf63bd4c8601b7dfULL },
+ { &fnv_test_str[13], (Fnv64_t) 0x08326707b4eb37daULL },
+ { &fnv_test_str[14], (Fnv64_t) 0x08326607b4eb3627ULL },
+ { &fnv_test_str[15], (Fnv64_t) 0x08326507b4eb3474ULL },
+ { &fnv_test_str[16], (Fnv64_t) 0x08326407b4eb32c1ULL },
+ { &fnv_test_str[17], (Fnv64_t) 0x08326307b4eb310eULL },
+ { &fnv_test_str[18], (Fnv64_t) 0x08326207b4eb2f5bULL },
+ { &fnv_test_str[19], (Fnv64_t) 0xd8cbc7186ba1355cULL },
+ { &fnv_test_str[20], (Fnv64_t) 0x0378817ee2ed65a9ULL },
+ { &fnv_test_str[21], (Fnv64_t) 0xd329d59b9963f7f1ULL },
+ { &fnv_test_str[22], (Fnv64_t) 0x340d8765a4dda9b0ULL },
+ { &fnv_test_str[23], (Fnv64_t) 0x50a6d3b724a774a6ULL },
+ { &fnv_test_str[24], (Fnv64_t) 0x08326507b4eb341cULL },
+ { &fnv_test_str[25], (Fnv64_t) 0xd8d5c8186ba98bfbULL },
+ { &fnv_test_str[26], (Fnv64_t) 0x1ccefc7ef118dbefULL },
+ { &fnv_test_str[27], (Fnv64_t) 0x0c92fab3ad3db77aULL },
+ { &fnv_test_str[28], (Fnv64_t) 0x9b77794f5fdec421ULL },
+ { &fnv_test_str[29], (Fnv64_t) 0x0ac742dfe7874433ULL },
+ { &fnv_test_str[30], (Fnv64_t) 0xd7dad5766ad8e2deULL },
+ { &fnv_test_str[31], (Fnv64_t) 0xa1bb96378e897f5bULL },
+ { &fnv_test_str[32], (Fnv64_t) 0x5b3f9b6733a367d2ULL },
+ { &fnv_test_str[33], (Fnv64_t) 0xb07ce25cbea969f6ULL },
+ { &fnv_test_str[34], (Fnv64_t) 0x8d9e9997f9df0d6aULL },
+ { &fnv_test_str[35], (Fnv64_t) 0x838c673d9603cb7bULL },
+ { &fnv_test_str[36], (Fnv64_t) 0x8b5ee8a5e872c273ULL },
+ { &fnv_test_str[37], (Fnv64_t) 0x4507c4e9fb00690cULL },
+ { &fnv_test_str[38], (Fnv64_t) 0x4c9ca59581b27f45ULL },
+ { &fnv_test_str[39], (Fnv64_t) 0xe0aca20b624e4235ULL },
+ { &fnv_test_str[40], (Fnv64_t) 0xd8d5c8186ba98b94ULL },
+ { &fnv_test_str[41], (Fnv64_t) 0x1ccefc7ef118db81ULL },
+ { &fnv_test_str[42], (Fnv64_t) 0x0c92fab3ad3db71dULL },
+ { &fnv_test_str[43], (Fnv64_t) 0x9b77794f5fdec44eULL },
+ { &fnv_test_str[44], (Fnv64_t) 0x0ac742dfe7874413ULL },
+ { &fnv_test_str[45], (Fnv64_t) 0xd7dad5766ad8e2a9ULL },
+ { &fnv_test_str[46], (Fnv64_t) 0xa1bb96378e897f3aULL },
+ { &fnv_test_str[47], (Fnv64_t) 0x5b3f9b6733a367a1ULL },
+ { &fnv_test_str[48], (Fnv64_t) 0xb07ce25cbea969d6ULL },
+ { &fnv_test_str[49], (Fnv64_t) 0x8d9e9997f9df0d02ULL },
+ { &fnv_test_str[50], (Fnv64_t) 0x838c673d9603cb1eULL },
+ { &fnv_test_str[51], (Fnv64_t) 0x8b5ee8a5e872c201ULL },
+ { &fnv_test_str[52], (Fnv64_t) 0x4507c4e9fb006969ULL },
+ { &fnv_test_str[53], (Fnv64_t) 0x4c9ca59581b27f64ULL },
+ { &fnv_test_str[54], (Fnv64_t) 0xe0aca20b624e423fULL },
+ { &fnv_test_str[55], (Fnv64_t) 0x13998e580afa800fULL },
+ { &fnv_test_str[56], (Fnv64_t) 0x08326507b4eb3401ULL },
+ { &fnv_test_str[57], (Fnv64_t) 0xd8d5ad186ba95dc1ULL },
+ { &fnv_test_str[58], (Fnv64_t) 0x1c72e17ef0ca4e97ULL },
+ { &fnv_test_str[59], (Fnv64_t) 0x2183c1b327c38ae6ULL },
+ { &fnv_test_str[60], (Fnv64_t) 0xb66d096c914504f2ULL },
+ { &fnv_test_str[61], (Fnv64_t) 0x404bf57ad8476757ULL },
+ { &fnv_test_str[62], (Fnv64_t) 0x887976bd815498bbULL },
+ { &fnv_test_str[63], (Fnv64_t) 0x3afd7f02c2bf85a5ULL },
+ { &fnv_test_str[64], (Fnv64_t) 0xfc4476b0eb70177fULL },
+ { &fnv_test_str[65], (Fnv64_t) 0x186d2da00f77ecbaULL },
+ { &fnv_test_str[66], (Fnv64_t) 0xf97140fa48c74066ULL },
+ { &fnv_test_str[67], (Fnv64_t) 0xa2b1cf49aa926d37ULL },
+ { &fnv_test_str[68], (Fnv64_t) 0x0690712cd6cf940cULL },
+ { &fnv_test_str[69], (Fnv64_t) 0xf7045b3102b8906eULL },
+ { &fnv_test_str[70], (Fnv64_t) 0xd8d5ad186ba95db3ULL },
+ { &fnv_test_str[71], (Fnv64_t) 0x1c72e17ef0ca4ef3ULL },
+ { &fnv_test_str[72], (Fnv64_t) 0x2183c1b327c38a95ULL },
+ { &fnv_test_str[73], (Fnv64_t) 0xb66d096c914504d2ULL },
+ { &fnv_test_str[74], (Fnv64_t) 0x404bf57ad8476736ULL },
+ { &fnv_test_str[75], (Fnv64_t) 0x887976bd815498d5ULL },
+ { &fnv_test_str[76], (Fnv64_t) 0x3afd7f02c2bf85c1ULL },
+ { &fnv_test_str[77], (Fnv64_t) 0xfc4476b0eb70175fULL },
+ { &fnv_test_str[78], (Fnv64_t) 0x186d2da00f77eccdULL },
+ { &fnv_test_str[79], (Fnv64_t) 0xf97140fa48c7400eULL },
+ { &fnv_test_str[80], (Fnv64_t) 0xa2b1cf49aa926d52ULL },
+ { &fnv_test_str[81], (Fnv64_t) 0x0690712cd6cf9475ULL },
+ { &fnv_test_str[82], (Fnv64_t) 0xf7045b3102b89064ULL },
+ { &fnv_test_str[83], (Fnv64_t) 0x74f762479f9d6aeaULL },
+ { &fnv_test_str[84], (Fnv64_t) 0x08326007b4eb2b9cULL },
+ { &fnv_test_str[85], (Fnv64_t) 0xd8c4c9186b9b1a14ULL },
+ { &fnv_test_str[86], (Fnv64_t) 0x7b495389bdbdd4c7ULL },
+ { &fnv_test_str[87], (Fnv64_t) 0x3b6dba0d69908e25ULL },
+ { &fnv_test_str[88], (Fnv64_t) 0xd6b2b17bf4b71261ULL },
+ { &fnv_test_str[89], (Fnv64_t) 0x447bfb7f98e615b5ULL },
+ { &fnv_test_str[90], (Fnv64_t) 0xd6b2b17bf4b71262ULL },
+ { &fnv_test_str[91], (Fnv64_t) 0x3bd2807f93fe1660ULL },
+ { &fnv_test_str[92], (Fnv64_t) 0xd6b2b17bf4b71263ULL },
+ { &fnv_test_str[93], (Fnv64_t) 0x3329057f8f16170bULL },
+ { &fnv_test_str[94], (Fnv64_t) 0xd6b2b17bf4b71264ULL },
+ { &fnv_test_str[95], (Fnv64_t) 0x2a7f8a7f8a2e19b6ULL },
+ { &fnv_test_str[96], (Fnv64_t) 0x23d3767e64b2f98aULL },
+ { &fnv_test_str[97], (Fnv64_t) 0xff768d7e4f9d86a4ULL },
+ { &fnv_test_str[98], (Fnv64_t) 0x23d3767e64b2f984ULL },
+ { &fnv_test_str[99], (Fnv64_t) 0xccd1837e334e4aa6ULL },
+ { &fnv_test_str[100], (Fnv64_t) 0x23d3767e64b2f99aULL },
+ { &fnv_test_str[101], (Fnv64_t) 0x7691fd7e028f6754ULL },
+ { &fnv_test_str[102], (Fnv64_t) 0x34ad3b1041204318ULL },
+ { &fnv_test_str[103], (Fnv64_t) 0xa29e749ea9d201c8ULL },
+ { &fnv_test_str[104], (Fnv64_t) 0x34ad3b104120431bULL },
+ { &fnv_test_str[105], (Fnv64_t) 0xa29e779ea9d206e1ULL },
+ { &fnv_test_str[106], (Fnv64_t) 0x34ad3b104120431aULL },
+ { &fnv_test_str[107], (Fnv64_t) 0xa29e769ea9d2052eULL },
+ { &fnv_test_str[108], (Fnv64_t) 0x02a17ebca4aa3497ULL },
+ { &fnv_test_str[109], (Fnv64_t) 0x229ef18bcd375c95ULL },
+ { &fnv_test_str[110], (Fnv64_t) 0x02a17dbca4aa32c8ULL },
+ { &fnv_test_str[111], (Fnv64_t) 0x229b6f8bcd3449d8ULL },
+ { &fnv_test_str[112], (Fnv64_t) 0x02a184bca4aa3ed5ULL },
+ { &fnv_test_str[113], (Fnv64_t) 0x22b3618bcd48c3efULL },
+ { &fnv_test_str[114], (Fnv64_t) 0x5c2c346706186f36ULL },
+ { &fnv_test_str[115], (Fnv64_t) 0xb78c410f5b84f8c2ULL },
+ { &fnv_test_str[116], (Fnv64_t) 0xed9478212b267395ULL },
+ { &fnv_test_str[117], (Fnv64_t) 0xd9bbb55c5256662fULL },
+ { &fnv_test_str[118], (Fnv64_t) 0x8c54f0203249438aULL },
+ { &fnv_test_str[119], (Fnv64_t) 0xbd9790b5727dc37eULL },
+ { &fnv_test_str[120], (Fnv64_t) 0xa64e5f36c9e2b0e3ULL },
+ { &fnv_test_str[121], (Fnv64_t) 0x8fd0680da3088a04ULL },
+ { &fnv_test_str[122], (Fnv64_t) 0x67aad32c078284ccULL },
+ { &fnv_test_str[123], (Fnv64_t) 0xb37d55d81c57b331ULL },
+ { &fnv_test_str[124], (Fnv64_t) 0x55ac0f3829057c43ULL },
+ { &fnv_test_str[125], (Fnv64_t) 0xcb27f4b8e1b6cc20ULL },
+ { &fnv_test_str[126], (Fnv64_t) 0x26caf88bcbef2d19ULL },
+ { &fnv_test_str[127], (Fnv64_t) 0x8e6e063b97e61b8fULL },
+ { &fnv_test_str[128], (Fnv64_t) 0xb42750f7f3b7c37eULL },
+ { &fnv_test_str[129], (Fnv64_t) 0xf3c6ba64cf7ca99bULL },
+ { &fnv_test_str[130], (Fnv64_t) 0xebfb69b427ea80feULL },
+ { &fnv_test_str[131], (Fnv64_t) 0x39b50c3ed970f46cULL },
+ { &fnv_test_str[132], (Fnv64_t) 0x5b9b177aa3eb3e8aULL },
+ { &fnv_test_str[133], (Fnv64_t) 0x6510063ecf4ec903ULL },
+ { &fnv_test_str[134], (Fnv64_t) 0x2b3bbd2c00797c7aULL },
+ { &fnv_test_str[135], (Fnv64_t) 0xf1d6204ff5cb4aa7ULL },
+ { &fnv_test_str[136], (Fnv64_t) 0x4836e27ccf099f38ULL },
+ { &fnv_test_str[137], (Fnv64_t) 0x82efbb0dd073b44dULL },
+ { &fnv_test_str[138], (Fnv64_t) 0x4a80c282ffd7d4c6ULL },
+ { &fnv_test_str[139], (Fnv64_t) 0x305d1a9c9ee43bdfULL },
+ { &fnv_test_str[140], (Fnv64_t) 0x15c366948ffc6997ULL },
+ { &fnv_test_str[141], (Fnv64_t) 0x80153ae218916e7bULL },
+ { &fnv_test_str[142], (Fnv64_t) 0xfa23e2bdf9e2a9e1ULL },
+ { &fnv_test_str[143], (Fnv64_t) 0xd47e8d8a2333c6deULL },
+ { &fnv_test_str[144], (Fnv64_t) 0x7e128095f688b056ULL },
+ { &fnv_test_str[145], (Fnv64_t) 0x2f5356890efcedabULL },
+ { &fnv_test_str[146], (Fnv64_t) 0x95c2b383014f55c5ULL },
+ { &fnv_test_str[147], (Fnv64_t) 0x4727a5339ce6070fULL },
+ { &fnv_test_str[148], (Fnv64_t) 0xb0555ecd575108e9ULL },
+ { &fnv_test_str[149], (Fnv64_t) 0x48d785770bb4af37ULL },
+ { &fnv_test_str[150], (Fnv64_t) 0x09d4701c12af02b1ULL },
+ { &fnv_test_str[151], (Fnv64_t) 0x79f031e78f3cf62eULL },
+ { &fnv_test_str[152], (Fnv64_t) 0x52a1ee85db1b5a94ULL },
+ { &fnv_test_str[153], (Fnv64_t) 0x6bd95b2eb37fa6b8ULL },
+ { &fnv_test_str[154], (Fnv64_t) 0x74971b7077aef85dULL },
+ { &fnv_test_str[155], (Fnv64_t) 0xb4e4fae2ffcc1aadULL },
+ { &fnv_test_str[156], (Fnv64_t) 0x2bd48bd898b8f63aULL },
+ { &fnv_test_str[157], (Fnv64_t) 0xe9966ac1556257f6ULL },
+ { &fnv_test_str[158], (Fnv64_t) 0x92a3d1cd078ba293ULL },
+ { &fnv_test_str[159], (Fnv64_t) 0xf81175a482e20ab8ULL },
+ { &fnv_test_str[160], (Fnv64_t) 0x5bbb3de722e73048ULL },
+ { &fnv_test_str[161], (Fnv64_t) 0x6b4f363492b9f2beULL },
+ { &fnv_test_str[162], (Fnv64_t) 0xc2d559df73d59875ULL },
+ { &fnv_test_str[163], (Fnv64_t) 0xf75f62284bc7a8c2ULL },
+ { &fnv_test_str[164], (Fnv64_t) 0xda8dd8e116a9f1ccULL },
+ { &fnv_test_str[165], (Fnv64_t) 0xbdc1e6ab76057885ULL },
+ { &fnv_test_str[166], (Fnv64_t) 0xfec6a4238a1224a0ULL },
+ { &fnv_test_str[167], (Fnv64_t) 0xc03f40f3223e290eULL },
+ { &fnv_test_str[168], (Fnv64_t) 0x1ed21673466ffda9ULL },
+ { &fnv_test_str[169], (Fnv64_t) 0xdf70f906bb0dd2afULL },
+ { &fnv_test_str[170], (Fnv64_t) 0xf3dcda369f2af666ULL },
+ { &fnv_test_str[171], (Fnv64_t) 0x9ebb11573cdcebdeULL },
+ { &fnv_test_str[172], (Fnv64_t) 0x81c72d9077fedca0ULL },
+ { &fnv_test_str[173], (Fnv64_t) 0x0ec074a31be5fb15ULL },
+ { &fnv_test_str[174], (Fnv64_t) 0x2a8b3280b6c48f20ULL },
+ { &fnv_test_str[175], (Fnv64_t) 0xfd31777513309344ULL },
+ { &fnv_test_str[176], (Fnv64_t) 0x194534a86ad006b6ULL },
+ { &fnv_test_str[177], (Fnv64_t) 0x3be6fdf46e0cfe12ULL },
+ { &fnv_test_str[178], (Fnv64_t) 0x017cc137a07eb057ULL },
+ { &fnv_test_str[179], (Fnv64_t) 0x9428fc6e7d26b54dULL },
+ { &fnv_test_str[180], (Fnv64_t) 0x9aaa2e3603ef8ad7ULL },
+ { &fnv_test_str[181], (Fnv64_t) 0x82c6d3f3a0ccdf7dULL },
+ { &fnv_test_str[182], (Fnv64_t) 0xc86eeea00cf09b65ULL },
+ { &fnv_test_str[183], (Fnv64_t) 0x705f8189dbb58299ULL },
+ { &fnv_test_str[184], (Fnv64_t) 0x415a7f554391ca69ULL },
+ { &fnv_test_str[185], (Fnv64_t) 0xcfe3d49fa2bdc555ULL },
+ { &fnv_test_str[186], (Fnv64_t) 0xf0f9c56039b25191ULL },
+ { &fnv_test_str[187], (Fnv64_t) 0x7075cb6abd1d32d9ULL },
+ { &fnv_test_str[188], (Fnv64_t) 0x43c94e2c8b277509ULL },
+ { &fnv_test_str[189], (Fnv64_t) 0x3cbfd4e4ea670359ULL },
+ { &fnv_test_str[190], (Fnv64_t) 0xc05887810f4d019dULL },
+ { &fnv_test_str[191], (Fnv64_t) 0x14468ff93ac22dc5ULL },
+ { &fnv_test_str[192], (Fnv64_t) 0xebed699589d99c05ULL },
+ { &fnv_test_str[193], (Fnv64_t) 0x6d99f6df321ca5d5ULL },
+ { &fnv_test_str[194], (Fnv64_t) 0x0cd410d08c36d625ULL },
+ { &fnv_test_str[195], (Fnv64_t) 0xef1b2a2c86831d35ULL },
+ { &fnv_test_str[196], (Fnv64_t) 0x3b349c4d69ee5f05ULL },
+ { &fnv_test_str[197], (Fnv64_t) 0x55248ce88f45f035ULL },
+ { &fnv_test_str[198], (Fnv64_t) 0xaa69ca6a18a4c885ULL },
+ { &fnv_test_str[199], (Fnv64_t) 0x1fe3fce62bd816b5ULL },
+ { &fnv_test_str[200], (Fnv64_t) 0x0289a488a8df69d9ULL },
+ { &fnv_test_str[201], (Fnv64_t) 0x15e96e1613df98b5ULL },
+ { &fnv_test_str[202], (Fnv64_t) 0xe6be57375ad89b99ULL },
+ { NULL, (Fnv64_t) 0 }
+};
+#else /* HAVE_64BIT_LONG_LONG */
+struct fnv1_64_test_vector fnv1_64_vector[] = {
+ { &fnv_test_str[0], (Fnv64_t) {0x84222325UL, 0xcbf29ce4UL} },
+ { &fnv_test_str[1], (Fnv64_t) {0x8601b7beUL, 0xaf63bd4cUL} },
+ { &fnv_test_str[2], (Fnv64_t) {0x8601b7bdUL, 0xaf63bd4cUL} },
+ { &fnv_test_str[3], (Fnv64_t) {0x8601b7bcUL, 0xaf63bd4cUL} },
+ { &fnv_test_str[4], (Fnv64_t) {0x8601b7bbUL, 0xaf63bd4cUL} },
+ { &fnv_test_str[5], (Fnv64_t) {0x8601b7baUL, 0xaf63bd4cUL} },
+ { &fnv_test_str[6], (Fnv64_t) {0x8601b7b9UL, 0xaf63bd4cUL} },
+ { &fnv_test_str[7], (Fnv64_t) {0xb4eb2f34UL, 0x08326207UL} },
+ { &fnv_test_str[8], (Fnv64_t) {0x6ba13533UL, 0xd8cbc718UL} },
+ { &fnv_test_str[9], (Fnv64_t) {0xe2ed65cbUL, 0x0378817eUL} },
+ { &fnv_test_str[10], (Fnv64_t) {0x9963f790UL, 0xd329d59bUL} },
+ { &fnv_test_str[11], (Fnv64_t) {0xa4dda9c2UL, 0x340d8765UL} },
+ { &fnv_test_str[12], (Fnv64_t) {0x8601b7dfUL, 0xaf63bd4cUL} },
+ { &fnv_test_str[13], (Fnv64_t) {0xb4eb37daUL, 0x08326707UL} },
+ { &fnv_test_str[14], (Fnv64_t) {0xb4eb3627UL, 0x08326607UL} },
+ { &fnv_test_str[15], (Fnv64_t) {0xb4eb3474UL, 0x08326507UL} },
+ { &fnv_test_str[16], (Fnv64_t) {0xb4eb32c1UL, 0x08326407UL} },
+ { &fnv_test_str[17], (Fnv64_t) {0xb4eb310eUL, 0x08326307UL} },
+ { &fnv_test_str[18], (Fnv64_t) {0xb4eb2f5bUL, 0x08326207UL} },
+ { &fnv_test_str[19], (Fnv64_t) {0x6ba1355cUL, 0xd8cbc718UL} },
+ { &fnv_test_str[20], (Fnv64_t) {0xe2ed65a9UL, 0x0378817eUL} },
+ { &fnv_test_str[21], (Fnv64_t) {0x9963f7f1UL, 0xd329d59bUL} },
+ { &fnv_test_str[22], (Fnv64_t) {0xa4dda9b0UL, 0x340d8765UL} },
+ { &fnv_test_str[23], (Fnv64_t) {0x24a774a6UL, 0x50a6d3b7UL} },
+ { &fnv_test_str[24], (Fnv64_t) {0xb4eb341cUL, 0x08326507UL} },
+ { &fnv_test_str[25], (Fnv64_t) {0x6ba98bfbUL, 0xd8d5c818UL} },
+ { &fnv_test_str[26], (Fnv64_t) {0xf118dbefUL, 0x1ccefc7eUL} },
+ { &fnv_test_str[27], (Fnv64_t) {0xad3db77aUL, 0x0c92fab3UL} },
+ { &fnv_test_str[28], (Fnv64_t) {0x5fdec421UL, 0x9b77794fUL} },
+ { &fnv_test_str[29], (Fnv64_t) {0xe7874433UL, 0x0ac742dfUL} },
+ { &fnv_test_str[30], (Fnv64_t) {0x6ad8e2deUL, 0xd7dad576UL} },
+ { &fnv_test_str[31], (Fnv64_t) {0x8e897f5bUL, 0xa1bb9637UL} },
+ { &fnv_test_str[32], (Fnv64_t) {0x33a367d2UL, 0x5b3f9b67UL} },
+ { &fnv_test_str[33], (Fnv64_t) {0xbea969f6UL, 0xb07ce25cUL} },
+ { &fnv_test_str[34], (Fnv64_t) {0xf9df0d6aUL, 0x8d9e9997UL} },
+ { &fnv_test_str[35], (Fnv64_t) {0x9603cb7bUL, 0x838c673dUL} },
+ { &fnv_test_str[36], (Fnv64_t) {0xe872c273UL, 0x8b5ee8a5UL} },
+ { &fnv_test_str[37], (Fnv64_t) {0xfb00690cUL, 0x4507c4e9UL} },
+ { &fnv_test_str[38], (Fnv64_t) {0x81b27f45UL, 0x4c9ca595UL} },
+ { &fnv_test_str[39], (Fnv64_t) {0x624e4235UL, 0xe0aca20bUL} },
+ { &fnv_test_str[40], (Fnv64_t) {0x6ba98b94UL, 0xd8d5c818UL} },
+ { &fnv_test_str[41], (Fnv64_t) {0xf118db81UL, 0x1ccefc7eUL} },
+ { &fnv_test_str[42], (Fnv64_t) {0xad3db71dUL, 0x0c92fab3UL} },
+ { &fnv_test_str[43], (Fnv64_t) {0x5fdec44eUL, 0x9b77794fUL} },
+ { &fnv_test_str[44], (Fnv64_t) {0xe7874413UL, 0x0ac742dfUL} },
+ { &fnv_test_str[45], (Fnv64_t) {0x6ad8e2a9UL, 0xd7dad576UL} },
+ { &fnv_test_str[46], (Fnv64_t) {0x8e897f3aUL, 0xa1bb9637UL} },
+ { &fnv_test_str[47], (Fnv64_t) {0x33a367a1UL, 0x5b3f9b67UL} },
+ { &fnv_test_str[48], (Fnv64_t) {0xbea969d6UL, 0xb07ce25cUL} },
+ { &fnv_test_str[49], (Fnv64_t) {0xf9df0d02UL, 0x8d9e9997UL} },
+ { &fnv_test_str[50], (Fnv64_t) {0x9603cb1eUL, 0x838c673dUL} },
+ { &fnv_test_str[51], (Fnv64_t) {0xe872c201UL, 0x8b5ee8a5UL} },
+ { &fnv_test_str[52], (Fnv64_t) {0xfb006969UL, 0x4507c4e9UL} },
+ { &fnv_test_str[53], (Fnv64_t) {0x81b27f64UL, 0x4c9ca595UL} },
+ { &fnv_test_str[54], (Fnv64_t) {0x624e423fUL, 0xe0aca20bUL} },
+ { &fnv_test_str[55], (Fnv64_t) {0x0afa800fUL, 0x13998e58UL} },
+ { &fnv_test_str[56], (Fnv64_t) {0xb4eb3401UL, 0x08326507UL} },
+ { &fnv_test_str[57], (Fnv64_t) {0x6ba95dc1UL, 0xd8d5ad18UL} },
+ { &fnv_test_str[58], (Fnv64_t) {0xf0ca4e97UL, 0x1c72e17eUL} },
+ { &fnv_test_str[59], (Fnv64_t) {0x27c38ae6UL, 0x2183c1b3UL} },
+ { &fnv_test_str[60], (Fnv64_t) {0x914504f2UL, 0xb66d096cUL} },
+ { &fnv_test_str[61], (Fnv64_t) {0xd8476757UL, 0x404bf57aUL} },
+ { &fnv_test_str[62], (Fnv64_t) {0x815498bbUL, 0x887976bdUL} },
+ { &fnv_test_str[63], (Fnv64_t) {0xc2bf85a5UL, 0x3afd7f02UL} },
+ { &fnv_test_str[64], (Fnv64_t) {0xeb70177fUL, 0xfc4476b0UL} },
+ { &fnv_test_str[65], (Fnv64_t) {0x0f77ecbaUL, 0x186d2da0UL} },
+ { &fnv_test_str[66], (Fnv64_t) {0x48c74066UL, 0xf97140faUL} },
+ { &fnv_test_str[67], (Fnv64_t) {0xaa926d37UL, 0xa2b1cf49UL} },
+ { &fnv_test_str[68], (Fnv64_t) {0xd6cf940cUL, 0x0690712cUL} },
+ { &fnv_test_str[69], (Fnv64_t) {0x02b8906eUL, 0xf7045b31UL} },
+ { &fnv_test_str[70], (Fnv64_t) {0x6ba95db3UL, 0xd8d5ad18UL} },
+ { &fnv_test_str[71], (Fnv64_t) {0xf0ca4ef3UL, 0x1c72e17eUL} },
+ { &fnv_test_str[72], (Fnv64_t) {0x27c38a95UL, 0x2183c1b3UL} },
+ { &fnv_test_str[73], (Fnv64_t) {0x914504d2UL, 0xb66d096cUL} },
+ { &fnv_test_str[74], (Fnv64_t) {0xd8476736UL, 0x404bf57aUL} },
+ { &fnv_test_str[75], (Fnv64_t) {0x815498d5UL, 0x887976bdUL} },
+ { &fnv_test_str[76], (Fnv64_t) {0xc2bf85c1UL, 0x3afd7f02UL} },
+ { &fnv_test_str[77], (Fnv64_t) {0xeb70175fUL, 0xfc4476b0UL} },
+ { &fnv_test_str[78], (Fnv64_t) {0x0f77eccdUL, 0x186d2da0UL} },
+ { &fnv_test_str[79], (Fnv64_t) {0x48c7400eUL, 0xf97140faUL} },
+ { &fnv_test_str[80], (Fnv64_t) {0xaa926d52UL, 0xa2b1cf49UL} },
+ { &fnv_test_str[81], (Fnv64_t) {0xd6cf9475UL, 0x0690712cUL} },
+ { &fnv_test_str[82], (Fnv64_t) {0x02b89064UL, 0xf7045b31UL} },
+ { &fnv_test_str[83], (Fnv64_t) {0x9f9d6aeaUL, 0x74f76247UL} },
+ { &fnv_test_str[84], (Fnv64_t) {0xb4eb2b9cUL, 0x08326007UL} },
+ { &fnv_test_str[85], (Fnv64_t) {0x6b9b1a14UL, 0xd8c4c918UL} },
+ { &fnv_test_str[86], (Fnv64_t) {0xbdbdd4c7UL, 0x7b495389UL} },
+ { &fnv_test_str[87], (Fnv64_t) {0x69908e25UL, 0x3b6dba0dUL} },
+ { &fnv_test_str[88], (Fnv64_t) {0xf4b71261UL, 0xd6b2b17bUL} },
+ { &fnv_test_str[89], (Fnv64_t) {0x98e615b5UL, 0x447bfb7fUL} },
+ { &fnv_test_str[90], (Fnv64_t) {0xf4b71262UL, 0xd6b2b17bUL} },
+ { &fnv_test_str[91], (Fnv64_t) {0x93fe1660UL, 0x3bd2807fUL} },
+ { &fnv_test_str[92], (Fnv64_t) {0xf4b71263UL, 0xd6b2b17bUL} },
+ { &fnv_test_str[93], (Fnv64_t) {0x8f16170bUL, 0x3329057fUL} },
+ { &fnv_test_str[94], (Fnv64_t) {0xf4b71264UL, 0xd6b2b17bUL} },
+ { &fnv_test_str[95], (Fnv64_t) {0x8a2e19b6UL, 0x2a7f8a7fUL} },
+ { &fnv_test_str[96], (Fnv64_t) {0x64b2f98aUL, 0x23d3767eUL} },
+ { &fnv_test_str[97], (Fnv64_t) {0x4f9d86a4UL, 0xff768d7eUL} },
+ { &fnv_test_str[98], (Fnv64_t) {0x64b2f984UL, 0x23d3767eUL} },
+ { &fnv_test_str[99], (Fnv64_t) {0x334e4aa6UL, 0xccd1837eUL} },
+ { &fnv_test_str[100], (Fnv64_t) {0x64b2f99aUL, 0x23d3767eUL} },
+ { &fnv_test_str[101], (Fnv64_t) {0x028f6754UL, 0x7691fd7eUL} },
+ { &fnv_test_str[102], (Fnv64_t) {0x41204318UL, 0x34ad3b10UL} },
+ { &fnv_test_str[103], (Fnv64_t) {0xa9d201c8UL, 0xa29e749eUL} },
+ { &fnv_test_str[104], (Fnv64_t) {0x4120431bUL, 0x34ad3b10UL} },
+ { &fnv_test_str[105], (Fnv64_t) {0xa9d206e1UL, 0xa29e779eUL} },
+ { &fnv_test_str[106], (Fnv64_t) {0x4120431aUL, 0x34ad3b10UL} },
+ { &fnv_test_str[107], (Fnv64_t) {0xa9d2052eUL, 0xa29e769eUL} },
+ { &fnv_test_str[108], (Fnv64_t) {0xa4aa3497UL, 0x02a17ebcUL} },
+ { &fnv_test_str[109], (Fnv64_t) {0xcd375c95UL, 0x229ef18bUL} },
+ { &fnv_test_str[110], (Fnv64_t) {0xa4aa32c8UL, 0x02a17dbcUL} },
+ { &fnv_test_str[111], (Fnv64_t) {0xcd3449d8UL, 0x229b6f8bUL} },
+ { &fnv_test_str[112], (Fnv64_t) {0xa4aa3ed5UL, 0x02a184bcUL} },
+ { &fnv_test_str[113], (Fnv64_t) {0xcd48c3efUL, 0x22b3618bUL} },
+ { &fnv_test_str[114], (Fnv64_t) {0x06186f36UL, 0x5c2c3467UL} },
+ { &fnv_test_str[115], (Fnv64_t) {0x5b84f8c2UL, 0xb78c410fUL} },
+ { &fnv_test_str[116], (Fnv64_t) {0x2b267395UL, 0xed947821UL} },
+ { &fnv_test_str[117], (Fnv64_t) {0x5256662fUL, 0xd9bbb55cUL} },
+ { &fnv_test_str[118], (Fnv64_t) {0x3249438aUL, 0x8c54f020UL} },
+ { &fnv_test_str[119], (Fnv64_t) {0x727dc37eUL, 0xbd9790b5UL} },
+ { &fnv_test_str[120], (Fnv64_t) {0xc9e2b0e3UL, 0xa64e5f36UL} },
+ { &fnv_test_str[121], (Fnv64_t) {0xa3088a04UL, 0x8fd0680dUL} },
+ { &fnv_test_str[122], (Fnv64_t) {0x078284ccUL, 0x67aad32cUL} },
+ { &fnv_test_str[123], (Fnv64_t) {0x1c57b331UL, 0xb37d55d8UL} },
+ { &fnv_test_str[124], (Fnv64_t) {0x29057c43UL, 0x55ac0f38UL} },
+ { &fnv_test_str[125], (Fnv64_t) {0xe1b6cc20UL, 0xcb27f4b8UL} },
+ { &fnv_test_str[126], (Fnv64_t) {0xcbef2d19UL, 0x26caf88bUL} },
+ { &fnv_test_str[127], (Fnv64_t) {0x97e61b8fUL, 0x8e6e063bUL} },
+ { &fnv_test_str[128], (Fnv64_t) {0xf3b7c37eUL, 0xb42750f7UL} },
+ { &fnv_test_str[129], (Fnv64_t) {0xcf7ca99bUL, 0xf3c6ba64UL} },
+ { &fnv_test_str[130], (Fnv64_t) {0x27ea80feUL, 0xebfb69b4UL} },
+ { &fnv_test_str[131], (Fnv64_t) {0xd970f46cUL, 0x39b50c3eUL} },
+ { &fnv_test_str[132], (Fnv64_t) {0xa3eb3e8aUL, 0x5b9b177aUL} },
+ { &fnv_test_str[133], (Fnv64_t) {0xcf4ec903UL, 0x6510063eUL} },
+ { &fnv_test_str[134], (Fnv64_t) {0x00797c7aUL, 0x2b3bbd2cUL} },
+ { &fnv_test_str[135], (Fnv64_t) {0xf5cb4aa7UL, 0xf1d6204fUL} },
+ { &fnv_test_str[136], (Fnv64_t) {0xcf099f38UL, 0x4836e27cUL} },
+ { &fnv_test_str[137], (Fnv64_t) {0xd073b44dUL, 0x82efbb0dUL} },
+ { &fnv_test_str[138], (Fnv64_t) {0xffd7d4c6UL, 0x4a80c282UL} },
+ { &fnv_test_str[139], (Fnv64_t) {0x9ee43bdfUL, 0x305d1a9cUL} },
+ { &fnv_test_str[140], (Fnv64_t) {0x8ffc6997UL, 0x15c36694UL} },
+ { &fnv_test_str[141], (Fnv64_t) {0x18916e7bUL, 0x80153ae2UL} },
+ { &fnv_test_str[142], (Fnv64_t) {0xf9e2a9e1UL, 0xfa23e2bdUL} },
+ { &fnv_test_str[143], (Fnv64_t) {0x2333c6deUL, 0xd47e8d8aUL} },
+ { &fnv_test_str[144], (Fnv64_t) {0xf688b056UL, 0x7e128095UL} },
+ { &fnv_test_str[145], (Fnv64_t) {0x0efcedabUL, 0x2f535689UL} },
+ { &fnv_test_str[146], (Fnv64_t) {0x014f55c5UL, 0x95c2b383UL} },
+ { &fnv_test_str[147], (Fnv64_t) {0x9ce6070fUL, 0x4727a533UL} },
+ { &fnv_test_str[148], (Fnv64_t) {0x575108e9UL, 0xb0555ecdUL} },
+ { &fnv_test_str[149], (Fnv64_t) {0x0bb4af37UL, 0x48d78577UL} },
+ { &fnv_test_str[150], (Fnv64_t) {0x12af02b1UL, 0x09d4701cUL} },
+ { &fnv_test_str[151], (Fnv64_t) {0x8f3cf62eUL, 0x79f031e7UL} },
+ { &fnv_test_str[152], (Fnv64_t) {0xdb1b5a94UL, 0x52a1ee85UL} },
+ { &fnv_test_str[153], (Fnv64_t) {0xb37fa6b8UL, 0x6bd95b2eUL} },
+ { &fnv_test_str[154], (Fnv64_t) {0x77aef85dUL, 0x74971b70UL} },
+ { &fnv_test_str[155], (Fnv64_t) {0xffcc1aadUL, 0xb4e4fae2UL} },
+ { &fnv_test_str[156], (Fnv64_t) {0x98b8f63aUL, 0x2bd48bd8UL} },
+ { &fnv_test_str[157], (Fnv64_t) {0x556257f6UL, 0xe9966ac1UL} },
+ { &fnv_test_str[158], (Fnv64_t) {0x078ba293UL, 0x92a3d1cdUL} },
+ { &fnv_test_str[159], (Fnv64_t) {0x82e20ab8UL, 0xf81175a4UL} },
+ { &fnv_test_str[160], (Fnv64_t) {0x22e73048UL, 0x5bbb3de7UL} },
+ { &fnv_test_str[161], (Fnv64_t) {0x92b9f2beUL, 0x6b4f3634UL} },
+ { &fnv_test_str[162], (Fnv64_t) {0x73d59875UL, 0xc2d559dfUL} },
+ { &fnv_test_str[163], (Fnv64_t) {0x4bc7a8c2UL, 0xf75f6228UL} },
+ { &fnv_test_str[164], (Fnv64_t) {0x16a9f1ccUL, 0xda8dd8e1UL} },
+ { &fnv_test_str[165], (Fnv64_t) {0x76057885UL, 0xbdc1e6abUL} },
+ { &fnv_test_str[166], (Fnv64_t) {0x8a1224a0UL, 0xfec6a423UL} },
+ { &fnv_test_str[167], (Fnv64_t) {0x223e290eUL, 0xc03f40f3UL} },
+ { &fnv_test_str[168], (Fnv64_t) {0x466ffda9UL, 0x1ed21673UL} },
+ { &fnv_test_str[169], (Fnv64_t) {0xbb0dd2afUL, 0xdf70f906UL} },
+ { &fnv_test_str[170], (Fnv64_t) {0x9f2af666UL, 0xf3dcda36UL} },
+ { &fnv_test_str[171], (Fnv64_t) {0x3cdcebdeUL, 0x9ebb1157UL} },
+ { &fnv_test_str[172], (Fnv64_t) {0x77fedca0UL, 0x81c72d90UL} },
+ { &fnv_test_str[173], (Fnv64_t) {0x1be5fb15UL, 0x0ec074a3UL} },
+ { &fnv_test_str[174], (Fnv64_t) {0xb6c48f20UL, 0x2a8b3280UL} },
+ { &fnv_test_str[175], (Fnv64_t) {0x13309344UL, 0xfd317775UL} },
+ { &fnv_test_str[176], (Fnv64_t) {0x6ad006b6UL, 0x194534a8UL} },
+ { &fnv_test_str[177], (Fnv64_t) {0x6e0cfe12UL, 0x3be6fdf4UL} },
+ { &fnv_test_str[178], (Fnv64_t) {0xa07eb057UL, 0x017cc137UL} },
+ { &fnv_test_str[179], (Fnv64_t) {0x7d26b54dUL, 0x9428fc6eUL} },
+ { &fnv_test_str[180], (Fnv64_t) {0x03ef8ad7UL, 0x9aaa2e36UL} },
+ { &fnv_test_str[181], (Fnv64_t) {0xa0ccdf7dUL, 0x82c6d3f3UL} },
+ { &fnv_test_str[182], (Fnv64_t) {0x0cf09b65UL, 0xc86eeea0UL} },
+ { &fnv_test_str[183], (Fnv64_t) {0xdbb58299UL, 0x705f8189UL} },
+ { &fnv_test_str[184], (Fnv64_t) {0x4391ca69UL, 0x415a7f55UL} },
+ { &fnv_test_str[185], (Fnv64_t) {0xa2bdc555UL, 0xcfe3d49fUL} },
+ { &fnv_test_str[186], (Fnv64_t) {0x39b25191UL, 0xf0f9c560UL} },
+ { &fnv_test_str[187], (Fnv64_t) {0xbd1d32d9UL, 0x7075cb6aUL} },
+ { &fnv_test_str[188], (Fnv64_t) {0x8b277509UL, 0x43c94e2cUL} },
+ { &fnv_test_str[189], (Fnv64_t) {0xea670359UL, 0x3cbfd4e4UL} },
+ { &fnv_test_str[190], (Fnv64_t) {0x0f4d019dUL, 0xc0588781UL} },
+ { &fnv_test_str[191], (Fnv64_t) {0x3ac22dc5UL, 0x14468ff9UL} },
+ { &fnv_test_str[192], (Fnv64_t) {0x89d99c05UL, 0xebed6995UL} },
+ { &fnv_test_str[193], (Fnv64_t) {0x321ca5d5UL, 0x6d99f6dfUL} },
+ { &fnv_test_str[194], (Fnv64_t) {0x8c36d625UL, 0x0cd410d0UL} },
+ { &fnv_test_str[195], (Fnv64_t) {0x86831d35UL, 0xef1b2a2cUL} },
+ { &fnv_test_str[196], (Fnv64_t) {0x69ee5f05UL, 0x3b349c4dUL} },
+ { &fnv_test_str[197], (Fnv64_t) {0x8f45f035UL, 0x55248ce8UL} },
+ { &fnv_test_str[198], (Fnv64_t) {0x18a4c885UL, 0xaa69ca6aUL} },
+ { &fnv_test_str[199], (Fnv64_t) {0x2bd816b5UL, 0x1fe3fce6UL} },
+ { &fnv_test_str[200], (Fnv64_t) {0xa8df69d9UL, 0x0289a488UL} },
+ { &fnv_test_str[201], (Fnv64_t) {0x13df98b5UL, 0x15e96e16UL} },
+ { &fnv_test_str[202], (Fnv64_t) {0x5ad89b99UL, 0xe6be5737UL} },
+ { NULL, (Fnv64_t) {0,0} }
+};
+#endif /* HAVE_64BIT_LONG_LONG */
+
+/* FNV-1a 64 bit test vectors */
+#if defined(HAVE_64BIT_LONG_LONG)
+struct fnv1a_64_test_vector fnv1a_64_vector[] = {
+ { &fnv_test_str[0], (Fnv64_t) 0xcbf29ce484222325ULL },
+ { &fnv_test_str[1], (Fnv64_t) 0xaf63dc4c8601ec8cULL },
+ { &fnv_test_str[2], (Fnv64_t) 0xaf63df4c8601f1a5ULL },
+ { &fnv_test_str[3], (Fnv64_t) 0xaf63de4c8601eff2ULL },
+ { &fnv_test_str[4], (Fnv64_t) 0xaf63d94c8601e773ULL },
+ { &fnv_test_str[5], (Fnv64_t) 0xaf63d84c8601e5c0ULL },
+ { &fnv_test_str[6], (Fnv64_t) 0xaf63db4c8601ead9ULL },
+ { &fnv_test_str[7], (Fnv64_t) 0x08985907b541d342ULL },
+ { &fnv_test_str[8], (Fnv64_t) 0xdcb27518fed9d577ULL },
+ { &fnv_test_str[9], (Fnv64_t) 0xdd120e790c2512afULL },
+ { &fnv_test_str[10], (Fnv64_t) 0xcac165afa2fef40aULL },
+ { &fnv_test_str[11], (Fnv64_t) 0x85944171f73967e8ULL },
+ { &fnv_test_str[12], (Fnv64_t) 0xaf63bd4c8601b7dfULL },
+ { &fnv_test_str[13], (Fnv64_t) 0x089be207b544f1e4ULL },
+ { &fnv_test_str[14], (Fnv64_t) 0x08a61407b54d9b5fULL },
+ { &fnv_test_str[15], (Fnv64_t) 0x08a2ae07b54ab836ULL },
+ { &fnv_test_str[16], (Fnv64_t) 0x0891b007b53c4869ULL },
+ { &fnv_test_str[17], (Fnv64_t) 0x088e4a07b5396540ULL },
+ { &fnv_test_str[18], (Fnv64_t) 0x08987c07b5420ebbULL },
+ { &fnv_test_str[19], (Fnv64_t) 0xdcb28a18fed9f926ULL },
+ { &fnv_test_str[20], (Fnv64_t) 0xdd1270790c25b935ULL },
+ { &fnv_test_str[21], (Fnv64_t) 0xcac146afa2febf5dULL },
+ { &fnv_test_str[22], (Fnv64_t) 0x8593d371f738acfeULL },
+ { &fnv_test_str[23], (Fnv64_t) 0x34531ca7168b8f38ULL },
+ { &fnv_test_str[24], (Fnv64_t) 0x08a25607b54a22aeULL },
+ { &fnv_test_str[25], (Fnv64_t) 0xf5faf0190cf90df3ULL },
+ { &fnv_test_str[26], (Fnv64_t) 0xf27397910b3221c7ULL },
+ { &fnv_test_str[27], (Fnv64_t) 0x2c8c2b76062f22e0ULL },
+ { &fnv_test_str[28], (Fnv64_t) 0xe150688c8217b8fdULL },
+ { &fnv_test_str[29], (Fnv64_t) 0xf35a83c10e4f1f87ULL },
+ { &fnv_test_str[30], (Fnv64_t) 0xd1edd10b507344d0ULL },
+ { &fnv_test_str[31], (Fnv64_t) 0x2a5ee739b3ddb8c3ULL },
+ { &fnv_test_str[32], (Fnv64_t) 0xdcfb970ca1c0d310ULL },
+ { &fnv_test_str[33], (Fnv64_t) 0x4054da76daa6da90ULL },
+ { &fnv_test_str[34], (Fnv64_t) 0xf70a2ff589861368ULL },
+ { &fnv_test_str[35], (Fnv64_t) 0x4c628b38aed25f17ULL },
+ { &fnv_test_str[36], (Fnv64_t) 0x9dd1f6510f78189fULL },
+ { &fnv_test_str[37], (Fnv64_t) 0xa3de85bd491270ceULL },
+ { &fnv_test_str[38], (Fnv64_t) 0x858e2fa32a55e61dULL },
+ { &fnv_test_str[39], (Fnv64_t) 0x46810940eff5f915ULL },
+ { &fnv_test_str[40], (Fnv64_t) 0xf5fadd190cf8edaaULL },
+ { &fnv_test_str[41], (Fnv64_t) 0xf273ed910b32b3e9ULL },
+ { &fnv_test_str[42], (Fnv64_t) 0x2c8c5276062f6525ULL },
+ { &fnv_test_str[43], (Fnv64_t) 0xe150b98c821842a0ULL },
+ { &fnv_test_str[44], (Fnv64_t) 0xf35aa3c10e4f55e7ULL },
+ { &fnv_test_str[45], (Fnv64_t) 0xd1ed680b50729265ULL },
+ { &fnv_test_str[46], (Fnv64_t) 0x2a5f0639b3dded70ULL },
+ { &fnv_test_str[47], (Fnv64_t) 0xdcfbaa0ca1c0f359ULL },
+ { &fnv_test_str[48], (Fnv64_t) 0x4054ba76daa6a430ULL },
+ { &fnv_test_str[49], (Fnv64_t) 0xf709c7f5898562b0ULL },
+ { &fnv_test_str[50], (Fnv64_t) 0x4c62e638aed2f9b8ULL },
+ { &fnv_test_str[51], (Fnv64_t) 0x9dd1a8510f779415ULL },
+ { &fnv_test_str[52], (Fnv64_t) 0xa3de2abd4911d62dULL },
+ { &fnv_test_str[53], (Fnv64_t) 0x858e0ea32a55ae0aULL },
+ { &fnv_test_str[54], (Fnv64_t) 0x46810f40eff60347ULL },
+ { &fnv_test_str[55], (Fnv64_t) 0xc33bce57bef63eafULL },
+ { &fnv_test_str[56], (Fnv64_t) 0x08a24307b54a0265ULL },
+ { &fnv_test_str[57], (Fnv64_t) 0xf5b9fd190cc18d15ULL },
+ { &fnv_test_str[58], (Fnv64_t) 0x4c968290ace35703ULL },
+ { &fnv_test_str[59], (Fnv64_t) 0x07174bd5c64d9350ULL },
+ { &fnv_test_str[60], (Fnv64_t) 0x5a294c3ff5d18750ULL },
+ { &fnv_test_str[61], (Fnv64_t) 0x05b3c1aeb308b843ULL },
+ { &fnv_test_str[62], (Fnv64_t) 0xb92a48da37d0f477ULL },
+ { &fnv_test_str[63], (Fnv64_t) 0x73cdddccd80ebc49ULL },
+ { &fnv_test_str[64], (Fnv64_t) 0xd58c4c13210a266bULL },
+ { &fnv_test_str[65], (Fnv64_t) 0xe78b6081243ec194ULL },
+ { &fnv_test_str[66], (Fnv64_t) 0xb096f77096a39f34ULL },
+ { &fnv_test_str[67], (Fnv64_t) 0xb425c54ff807b6a3ULL },
+ { &fnv_test_str[68], (Fnv64_t) 0x23e520e2751bb46eULL },
+ { &fnv_test_str[69], (Fnv64_t) 0x1a0b44ccfe1385ecULL },
+ { &fnv_test_str[70], (Fnv64_t) 0xf5ba4b190cc2119fULL },
+ { &fnv_test_str[71], (Fnv64_t) 0x4c962690ace2baafULL },
+ { &fnv_test_str[72], (Fnv64_t) 0x0716ded5c64cda19ULL },
+ { &fnv_test_str[73], (Fnv64_t) 0x5a292c3ff5d150f0ULL },
+ { &fnv_test_str[74], (Fnv64_t) 0x05b3e0aeb308ecf0ULL },
+ { &fnv_test_str[75], (Fnv64_t) 0xb92a5eda37d119d9ULL },
+ { &fnv_test_str[76], (Fnv64_t) 0x73ce41ccd80f6635ULL },
+ { &fnv_test_str[77], (Fnv64_t) 0xd58c2c132109f00bULL },
+ { &fnv_test_str[78], (Fnv64_t) 0xe78baf81243f47d1ULL },
+ { &fnv_test_str[79], (Fnv64_t) 0xb0968f7096a2ee7cULL },
+ { &fnv_test_str[80], (Fnv64_t) 0xb425a84ff807855cULL },
+ { &fnv_test_str[81], (Fnv64_t) 0x23e4e9e2751b56f9ULL },
+ { &fnv_test_str[82], (Fnv64_t) 0x1a0b4eccfe1396eaULL },
+ { &fnv_test_str[83], (Fnv64_t) 0x54abd453bb2c9004ULL },
+ { &fnv_test_str[84], (Fnv64_t) 0x08ba5f07b55ec3daULL },
+ { &fnv_test_str[85], (Fnv64_t) 0x337354193006cb6eULL },
+ { &fnv_test_str[86], (Fnv64_t) 0xa430d84680aabd0bULL },
+ { &fnv_test_str[87], (Fnv64_t) 0xa9bc8acca21f39b1ULL },
+ { &fnv_test_str[88], (Fnv64_t) 0x6961196491cc682dULL },
+ { &fnv_test_str[89], (Fnv64_t) 0xad2bb1774799dfe9ULL },
+ { &fnv_test_str[90], (Fnv64_t) 0x6961166491cc6314ULL },
+ { &fnv_test_str[91], (Fnv64_t) 0x8d1bb3904a3b1236ULL },
+ { &fnv_test_str[92], (Fnv64_t) 0x6961176491cc64c7ULL },
+ { &fnv_test_str[93], (Fnv64_t) 0xed205d87f40434c7ULL },
+ { &fnv_test_str[94], (Fnv64_t) 0x6961146491cc5faeULL },
+ { &fnv_test_str[95], (Fnv64_t) 0xcd3baf5e44f8ad9cULL },
+ { &fnv_test_str[96], (Fnv64_t) 0xe3b36596127cd6d8ULL },
+ { &fnv_test_str[97], (Fnv64_t) 0xf77f1072c8e8a646ULL },
+ { &fnv_test_str[98], (Fnv64_t) 0xe3b36396127cd372ULL },
+ { &fnv_test_str[99], (Fnv64_t) 0x6067dce9932ad458ULL },
+ { &fnv_test_str[100], (Fnv64_t) 0xe3b37596127cf208ULL },
+ { &fnv_test_str[101], (Fnv64_t) 0x4b7b10fa9fe83936ULL },
+ { &fnv_test_str[102], (Fnv64_t) 0xaabafe7104d914beULL },
+ { &fnv_test_str[103], (Fnv64_t) 0xf4d3180b3cde3edaULL },
+ { &fnv_test_str[104], (Fnv64_t) 0xaabafd7104d9130bULL },
+ { &fnv_test_str[105], (Fnv64_t) 0xf4cfb20b3cdb5bb1ULL },
+ { &fnv_test_str[106], (Fnv64_t) 0xaabafc7104d91158ULL },
+ { &fnv_test_str[107], (Fnv64_t) 0xf4cc4c0b3cd87888ULL },
+ { &fnv_test_str[108], (Fnv64_t) 0xe729bac5d2a8d3a7ULL },
+ { &fnv_test_str[109], (Fnv64_t) 0x74bc0524f4dfa4c5ULL },
+ { &fnv_test_str[110], (Fnv64_t) 0xe72630c5d2a5b352ULL },
+ { &fnv_test_str[111], (Fnv64_t) 0x6b983224ef8fb456ULL },
+ { &fnv_test_str[112], (Fnv64_t) 0xe73042c5d2ae266dULL },
+ { &fnv_test_str[113], (Fnv64_t) 0x8527e324fdeb4b37ULL },
+ { &fnv_test_str[114], (Fnv64_t) 0x0a83c86fee952abcULL },
+ { &fnv_test_str[115], (Fnv64_t) 0x7318523267779d74ULL },
+ { &fnv_test_str[116], (Fnv64_t) 0x3e66d3d56b8caca1ULL },
+ { &fnv_test_str[117], (Fnv64_t) 0x956694a5c0095593ULL },
+ { &fnv_test_str[118], (Fnv64_t) 0xcac54572bb1a6fc8ULL },
+ { &fnv_test_str[119], (Fnv64_t) 0xa7a4c9f3edebf0d8ULL },
+ { &fnv_test_str[120], (Fnv64_t) 0x7829851fac17b143ULL },
+ { &fnv_test_str[121], (Fnv64_t) 0x2c8f4c9af81bcf06ULL },
+ { &fnv_test_str[122], (Fnv64_t) 0xd34e31539740c732ULL },
+ { &fnv_test_str[123], (Fnv64_t) 0x3605a2ac253d2db1ULL },
+ { &fnv_test_str[124], (Fnv64_t) 0x08c11b8346f4a3c3ULL },
+ { &fnv_test_str[125], (Fnv64_t) 0x6be396289ce8a6daULL },
+ { &fnv_test_str[126], (Fnv64_t) 0xd9b957fb7fe794c5ULL },
+ { &fnv_test_str[127], (Fnv64_t) 0x05be33da04560a93ULL },
+ { &fnv_test_str[128], (Fnv64_t) 0x0957f1577ba9747cULL },
+ { &fnv_test_str[129], (Fnv64_t) 0xda2cc3acc24fba57ULL },
+ { &fnv_test_str[130], (Fnv64_t) 0x74136f185b29e7f0ULL },
+ { &fnv_test_str[131], (Fnv64_t) 0xb2f2b4590edb93b2ULL },
+ { &fnv_test_str[132], (Fnv64_t) 0xb3608fce8b86ae04ULL },
+ { &fnv_test_str[133], (Fnv64_t) 0x4a3a865079359063ULL },
+ { &fnv_test_str[134], (Fnv64_t) 0x5b3a7ef496880a50ULL },
+ { &fnv_test_str[135], (Fnv64_t) 0x48fae3163854c23bULL },
+ { &fnv_test_str[136], (Fnv64_t) 0x07aaa640476e0b9aULL },
+ { &fnv_test_str[137], (Fnv64_t) 0x2f653656383a687dULL },
+ { &fnv_test_str[138], (Fnv64_t) 0xa1031f8e7599d79cULL },
+ { &fnv_test_str[139], (Fnv64_t) 0xa31908178ff92477ULL },
+ { &fnv_test_str[140], (Fnv64_t) 0x097edf3c14c3fb83ULL },
+ { &fnv_test_str[141], (Fnv64_t) 0xb51ca83feaa0971bULL },
+ { &fnv_test_str[142], (Fnv64_t) 0xdd3c0d96d784f2e9ULL },
+ { &fnv_test_str[143], (Fnv64_t) 0x86cd26a9ea767d78ULL },
+ { &fnv_test_str[144], (Fnv64_t) 0xe6b215ff54a30c18ULL },
+ { &fnv_test_str[145], (Fnv64_t) 0xec5b06a1c5531093ULL },
+ { &fnv_test_str[146], (Fnv64_t) 0x45665a929f9ec5e5ULL },
+ { &fnv_test_str[147], (Fnv64_t) 0x8c7609b4a9f10907ULL },
+ { &fnv_test_str[148], (Fnv64_t) 0x89aac3a491f0d729ULL },
+ { &fnv_test_str[149], (Fnv64_t) 0x32ce6b26e0f4a403ULL },
+ { &fnv_test_str[150], (Fnv64_t) 0x614ab44e02b53e01ULL },
+ { &fnv_test_str[151], (Fnv64_t) 0xfa6472eb6eef3290ULL },
+ { &fnv_test_str[152], (Fnv64_t) 0x9e5d75eb1948eb6aULL },
+ { &fnv_test_str[153], (Fnv64_t) 0xb6d12ad4a8671852ULL },
+ { &fnv_test_str[154], (Fnv64_t) 0x88826f56eba07af1ULL },
+ { &fnv_test_str[155], (Fnv64_t) 0x44535bf2645bc0fdULL },
+ { &fnv_test_str[156], (Fnv64_t) 0x169388ffc21e3728ULL },
+ { &fnv_test_str[157], (Fnv64_t) 0xf68aac9e396d8224ULL },
+ { &fnv_test_str[158], (Fnv64_t) 0x8e87d7e7472b3883ULL },
+ { &fnv_test_str[159], (Fnv64_t) 0x295c26caa8b423deULL },
+ { &fnv_test_str[160], (Fnv64_t) 0x322c814292e72176ULL },
+ { &fnv_test_str[161], (Fnv64_t) 0x8a06550eb8af7268ULL },
+ { &fnv_test_str[162], (Fnv64_t) 0xef86d60e661bcf71ULL },
+ { &fnv_test_str[163], (Fnv64_t) 0x9e5426c87f30ee54ULL },
+ { &fnv_test_str[164], (Fnv64_t) 0xf1ea8aa826fd047eULL },
+ { &fnv_test_str[165], (Fnv64_t) 0x0babaf9a642cb769ULL },
+ { &fnv_test_str[166], (Fnv64_t) 0x4b3341d4068d012eULL },
+ { &fnv_test_str[167], (Fnv64_t) 0xd15605cbc30a335cULL },
+ { &fnv_test_str[168], (Fnv64_t) 0x5b21060aed8412e5ULL },
+ { &fnv_test_str[169], (Fnv64_t) 0x45e2cda1ce6f4227ULL },
+ { &fnv_test_str[170], (Fnv64_t) 0x50ae3745033ad7d4ULL },
+ { &fnv_test_str[171], (Fnv64_t) 0xaa4588ced46bf414ULL },
+ { &fnv_test_str[172], (Fnv64_t) 0xc1b0056c4a95467eULL },
+ { &fnv_test_str[173], (Fnv64_t) 0x56576a71de8b4089ULL },
+ { &fnv_test_str[174], (Fnv64_t) 0xbf20965fa6dc927eULL },
+ { &fnv_test_str[175], (Fnv64_t) 0x569f8383c2040882ULL },
+ { &fnv_test_str[176], (Fnv64_t) 0xe1e772fba08feca0ULL },
+ { &fnv_test_str[177], (Fnv64_t) 0x4ced94af97138ac4ULL },
+ { &fnv_test_str[178], (Fnv64_t) 0xc4112ffb337a82fbULL },
+ { &fnv_test_str[179], (Fnv64_t) 0xd64a4fd41de38b7dULL },
+ { &fnv_test_str[180], (Fnv64_t) 0x4cfc32329edebcbbULL },
+ { &fnv_test_str[181], (Fnv64_t) 0x0803564445050395ULL },
+ { &fnv_test_str[182], (Fnv64_t) 0xaa1574ecf4642ffdULL },
+ { &fnv_test_str[183], (Fnv64_t) 0x694bc4e54cc315f9ULL },
+ { &fnv_test_str[184], (Fnv64_t) 0xa3d7cb273b011721ULL },
+ { &fnv_test_str[185], (Fnv64_t) 0x577c2f8b6115bfa5ULL },
+ { &fnv_test_str[186], (Fnv64_t) 0xb7ec8c1a769fb4c1ULL },
+ { &fnv_test_str[187], (Fnv64_t) 0x5d5cfce63359ab19ULL },
+ { &fnv_test_str[188], (Fnv64_t) 0x33b96c3cd65b5f71ULL },
+ { &fnv_test_str[189], (Fnv64_t) 0xd845097780602bb9ULL },
+ { &fnv_test_str[190], (Fnv64_t) 0x84d47645d02da3d5ULL },
+ { &fnv_test_str[191], (Fnv64_t) 0x83544f33b58773a5ULL },
+ { &fnv_test_str[192], (Fnv64_t) 0x9175cbb2160836c5ULL },
+ { &fnv_test_str[193], (Fnv64_t) 0xc71b3bc175e72bc5ULL },
+ { &fnv_test_str[194], (Fnv64_t) 0x636806ac222ec985ULL },
+ { &fnv_test_str[195], (Fnv64_t) 0xb6ef0e6950f52ed5ULL },
+ { &fnv_test_str[196], (Fnv64_t) 0xead3d8a0f3dfdaa5ULL },
+ { &fnv_test_str[197], (Fnv64_t) 0x922908fe9a861ba5ULL },
+ { &fnv_test_str[198], (Fnv64_t) 0x6d4821de275fd5c5ULL },
+ { &fnv_test_str[199], (Fnv64_t) 0x1fe3fce62bd816b5ULL },
+ { &fnv_test_str[200], (Fnv64_t) 0xc23e9fccd6f70591ULL },
+ { &fnv_test_str[201], (Fnv64_t) 0xc1af12bdfe16b5b5ULL },
+ { &fnv_test_str[202], (Fnv64_t) 0x39e9f18f2f85e221ULL },
+ { NULL, (Fnv64_t) 0 }
+};
+#else /* HAVE_64BIT_LONG_LONG */
+struct fnv1a_64_test_vector fnv1a_64_vector[] = {
+ { &fnv_test_str[0], (Fnv64_t) {0x84222325UL, 0xcbf29ce4UL} },
+ { &fnv_test_str[1], (Fnv64_t) {0x8601ec8cUL, 0xaf63dc4cUL} },
+ { &fnv_test_str[2], (Fnv64_t) {0x8601f1a5UL, 0xaf63df4cUL} },
+ { &fnv_test_str[3], (Fnv64_t) {0x8601eff2UL, 0xaf63de4cUL} },
+ { &fnv_test_str[4], (Fnv64_t) {0x8601e773UL, 0xaf63d94cUL} },
+ { &fnv_test_str[5], (Fnv64_t) {0x8601e5c0UL, 0xaf63d84cUL} },
+ { &fnv_test_str[6], (Fnv64_t) {0x8601ead9UL, 0xaf63db4cUL} },
+ { &fnv_test_str[7], (Fnv64_t) {0xb541d342UL, 0x08985907UL} },
+ { &fnv_test_str[8], (Fnv64_t) {0xfed9d577UL, 0xdcb27518UL} },
+ { &fnv_test_str[9], (Fnv64_t) {0x0c2512afUL, 0xdd120e79UL} },
+ { &fnv_test_str[10], (Fnv64_t) {0xa2fef40aUL, 0xcac165afUL} },
+ { &fnv_test_str[11], (Fnv64_t) {0xf73967e8UL, 0x85944171UL} },
+ { &fnv_test_str[12], (Fnv64_t) {0x8601b7dfUL, 0xaf63bd4cUL} },
+ { &fnv_test_str[13], (Fnv64_t) {0xb544f1e4UL, 0x089be207UL} },
+ { &fnv_test_str[14], (Fnv64_t) {0xb54d9b5fUL, 0x08a61407UL} },
+ { &fnv_test_str[15], (Fnv64_t) {0xb54ab836UL, 0x08a2ae07UL} },
+ { &fnv_test_str[16], (Fnv64_t) {0xb53c4869UL, 0x0891b007UL} },
+ { &fnv_test_str[17], (Fnv64_t) {0xb5396540UL, 0x088e4a07UL} },
+ { &fnv_test_str[18], (Fnv64_t) {0xb5420ebbUL, 0x08987c07UL} },
+ { &fnv_test_str[19], (Fnv64_t) {0xfed9f926UL, 0xdcb28a18UL} },
+ { &fnv_test_str[20], (Fnv64_t) {0x0c25b935UL, 0xdd127079UL} },
+ { &fnv_test_str[21], (Fnv64_t) {0xa2febf5dUL, 0xcac146afUL} },
+ { &fnv_test_str[22], (Fnv64_t) {0xf738acfeUL, 0x8593d371UL} },
+ { &fnv_test_str[23], (Fnv64_t) {0x168b8f38UL, 0x34531ca7UL} },
+ { &fnv_test_str[24], (Fnv64_t) {0xb54a22aeUL, 0x08a25607UL} },
+ { &fnv_test_str[25], (Fnv64_t) {0x0cf90df3UL, 0xf5faf019UL} },
+ { &fnv_test_str[26], (Fnv64_t) {0x0b3221c7UL, 0xf2739791UL} },
+ { &fnv_test_str[27], (Fnv64_t) {0x062f22e0UL, 0x2c8c2b76UL} },
+ { &fnv_test_str[28], (Fnv64_t) {0x8217b8fdUL, 0xe150688cUL} },
+ { &fnv_test_str[29], (Fnv64_t) {0x0e4f1f87UL, 0xf35a83c1UL} },
+ { &fnv_test_str[30], (Fnv64_t) {0x507344d0UL, 0xd1edd10bUL} },
+ { &fnv_test_str[31], (Fnv64_t) {0xb3ddb8c3UL, 0x2a5ee739UL} },
+ { &fnv_test_str[32], (Fnv64_t) {0xa1c0d310UL, 0xdcfb970cUL} },
+ { &fnv_test_str[33], (Fnv64_t) {0xdaa6da90UL, 0x4054da76UL} },
+ { &fnv_test_str[34], (Fnv64_t) {0x89861368UL, 0xf70a2ff5UL} },
+ { &fnv_test_str[35], (Fnv64_t) {0xaed25f17UL, 0x4c628b38UL} },
+ { &fnv_test_str[36], (Fnv64_t) {0x0f78189fUL, 0x9dd1f651UL} },
+ { &fnv_test_str[37], (Fnv64_t) {0x491270ceUL, 0xa3de85bdUL} },
+ { &fnv_test_str[38], (Fnv64_t) {0x2a55e61dUL, 0x858e2fa3UL} },
+ { &fnv_test_str[39], (Fnv64_t) {0xeff5f915UL, 0x46810940UL} },
+ { &fnv_test_str[40], (Fnv64_t) {0x0cf8edaaUL, 0xf5fadd19UL} },
+ { &fnv_test_str[41], (Fnv64_t) {0x0b32b3e9UL, 0xf273ed91UL} },
+ { &fnv_test_str[42], (Fnv64_t) {0x062f6525UL, 0x2c8c5276UL} },
+ { &fnv_test_str[43], (Fnv64_t) {0x821842a0UL, 0xe150b98cUL} },
+ { &fnv_test_str[44], (Fnv64_t) {0x0e4f55e7UL, 0xf35aa3c1UL} },
+ { &fnv_test_str[45], (Fnv64_t) {0x50729265UL, 0xd1ed680bUL} },
+ { &fnv_test_str[46], (Fnv64_t) {0xb3dded70UL, 0x2a5f0639UL} },
+ { &fnv_test_str[47], (Fnv64_t) {0xa1c0f359UL, 0xdcfbaa0cUL} },
+ { &fnv_test_str[48], (Fnv64_t) {0xdaa6a430UL, 0x4054ba76UL} },
+ { &fnv_test_str[49], (Fnv64_t) {0x898562b0UL, 0xf709c7f5UL} },
+ { &fnv_test_str[50], (Fnv64_t) {0xaed2f9b8UL, 0x4c62e638UL} },
+ { &fnv_test_str[51], (Fnv64_t) {0x0f779415UL, 0x9dd1a851UL} },
+ { &fnv_test_str[52], (Fnv64_t) {0x4911d62dUL, 0xa3de2abdUL} },
+ { &fnv_test_str[53], (Fnv64_t) {0x2a55ae0aUL, 0x858e0ea3UL} },
+ { &fnv_test_str[54], (Fnv64_t) {0xeff60347UL, 0x46810f40UL} },
+ { &fnv_test_str[55], (Fnv64_t) {0xbef63eafUL, 0xc33bce57UL} },
+ { &fnv_test_str[56], (Fnv64_t) {0xb54a0265UL, 0x08a24307UL} },
+ { &fnv_test_str[57], (Fnv64_t) {0x0cc18d15UL, 0xf5b9fd19UL} },
+ { &fnv_test_str[58], (Fnv64_t) {0xace35703UL, 0x4c968290UL} },
+ { &fnv_test_str[59], (Fnv64_t) {0xc64d9350UL, 0x07174bd5UL} },
+ { &fnv_test_str[60], (Fnv64_t) {0xf5d18750UL, 0x5a294c3fUL} },
+ { &fnv_test_str[61], (Fnv64_t) {0xb308b843UL, 0x05b3c1aeUL} },
+ { &fnv_test_str[62], (Fnv64_t) {0x37d0f477UL, 0xb92a48daUL} },
+ { &fnv_test_str[63], (Fnv64_t) {0xd80ebc49UL, 0x73cdddccUL} },
+ { &fnv_test_str[64], (Fnv64_t) {0x210a266bUL, 0xd58c4c13UL} },
+ { &fnv_test_str[65], (Fnv64_t) {0x243ec194UL, 0xe78b6081UL} },
+ { &fnv_test_str[66], (Fnv64_t) {0x96a39f34UL, 0xb096f770UL} },
+ { &fnv_test_str[67], (Fnv64_t) {0xf807b6a3UL, 0xb425c54fUL} },
+ { &fnv_test_str[68], (Fnv64_t) {0x751bb46eUL, 0x23e520e2UL} },
+ { &fnv_test_str[69], (Fnv64_t) {0xfe1385ecUL, 0x1a0b44ccUL} },
+ { &fnv_test_str[70], (Fnv64_t) {0x0cc2119fUL, 0xf5ba4b19UL} },
+ { &fnv_test_str[71], (Fnv64_t) {0xace2baafUL, 0x4c962690UL} },
+ { &fnv_test_str[72], (Fnv64_t) {0xc64cda19UL, 0x0716ded5UL} },
+ { &fnv_test_str[73], (Fnv64_t) {0xf5d150f0UL, 0x5a292c3fUL} },
+ { &fnv_test_str[74], (Fnv64_t) {0xb308ecf0UL, 0x05b3e0aeUL} },
+ { &fnv_test_str[75], (Fnv64_t) {0x37d119d9UL, 0xb92a5edaUL} },
+ { &fnv_test_str[76], (Fnv64_t) {0xd80f6635UL, 0x73ce41ccUL} },
+ { &fnv_test_str[77], (Fnv64_t) {0x2109f00bUL, 0xd58c2c13UL} },
+ { &fnv_test_str[78], (Fnv64_t) {0x243f47d1UL, 0xe78baf81UL} },
+ { &fnv_test_str[79], (Fnv64_t) {0x96a2ee7cUL, 0xb0968f70UL} },
+ { &fnv_test_str[80], (Fnv64_t) {0xf807855cUL, 0xb425a84fUL} },
+ { &fnv_test_str[81], (Fnv64_t) {0x751b56f9UL, 0x23e4e9e2UL} },
+ { &fnv_test_str[82], (Fnv64_t) {0xfe1396eaUL, 0x1a0b4eccUL} },
+ { &fnv_test_str[83], (Fnv64_t) {0xbb2c9004UL, 0x54abd453UL} },
+ { &fnv_test_str[84], (Fnv64_t) {0xb55ec3daUL, 0x08ba5f07UL} },
+ { &fnv_test_str[85], (Fnv64_t) {0x3006cb6eUL, 0x33735419UL} },
+ { &fnv_test_str[86], (Fnv64_t) {0x80aabd0bUL, 0xa430d846UL} },
+ { &fnv_test_str[87], (Fnv64_t) {0xa21f39b1UL, 0xa9bc8accUL} },
+ { &fnv_test_str[88], (Fnv64_t) {0x91cc682dUL, 0x69611964UL} },
+ { &fnv_test_str[89], (Fnv64_t) {0x4799dfe9UL, 0xad2bb177UL} },
+ { &fnv_test_str[90], (Fnv64_t) {0x91cc6314UL, 0x69611664UL} },
+ { &fnv_test_str[91], (Fnv64_t) {0x4a3b1236UL, 0x8d1bb390UL} },
+ { &fnv_test_str[92], (Fnv64_t) {0x91cc64c7UL, 0x69611764UL} },
+ { &fnv_test_str[93], (Fnv64_t) {0xf40434c7UL, 0xed205d87UL} },
+ { &fnv_test_str[94], (Fnv64_t) {0x91cc5faeUL, 0x69611464UL} },
+ { &fnv_test_str[95], (Fnv64_t) {0x44f8ad9cUL, 0xcd3baf5eUL} },
+ { &fnv_test_str[96], (Fnv64_t) {0x127cd6d8UL, 0xe3b36596UL} },
+ { &fnv_test_str[97], (Fnv64_t) {0xc8e8a646UL, 0xf77f1072UL} },
+ { &fnv_test_str[98], (Fnv64_t) {0x127cd372UL, 0xe3b36396UL} },
+ { &fnv_test_str[99], (Fnv64_t) {0x932ad458UL, 0x6067dce9UL} },
+ { &fnv_test_str[100], (Fnv64_t) {0x127cf208UL, 0xe3b37596UL} },
+ { &fnv_test_str[101], (Fnv64_t) {0x9fe83936UL, 0x4b7b10faUL} },
+ { &fnv_test_str[102], (Fnv64_t) {0x04d914beUL, 0xaabafe71UL} },
+ { &fnv_test_str[103], (Fnv64_t) {0x3cde3edaUL, 0xf4d3180bUL} },
+ { &fnv_test_str[104], (Fnv64_t) {0x04d9130bUL, 0xaabafd71UL} },
+ { &fnv_test_str[105], (Fnv64_t) {0x3cdb5bb1UL, 0xf4cfb20bUL} },
+ { &fnv_test_str[106], (Fnv64_t) {0x04d91158UL, 0xaabafc71UL} },
+ { &fnv_test_str[107], (Fnv64_t) {0x3cd87888UL, 0xf4cc4c0bUL} },
+ { &fnv_test_str[108], (Fnv64_t) {0xd2a8d3a7UL, 0xe729bac5UL} },
+ { &fnv_test_str[109], (Fnv64_t) {0xf4dfa4c5UL, 0x74bc0524UL} },
+ { &fnv_test_str[110], (Fnv64_t) {0xd2a5b352UL, 0xe72630c5UL} },
+ { &fnv_test_str[111], (Fnv64_t) {0xef8fb456UL, 0x6b983224UL} },
+ { &fnv_test_str[112], (Fnv64_t) {0xd2ae266dUL, 0xe73042c5UL} },
+ { &fnv_test_str[113], (Fnv64_t) {0xfdeb4b37UL, 0x8527e324UL} },
+ { &fnv_test_str[114], (Fnv64_t) {0xee952abcUL, 0x0a83c86fUL} },
+ { &fnv_test_str[115], (Fnv64_t) {0x67779d74UL, 0x73185232UL} },
+ { &fnv_test_str[116], (Fnv64_t) {0x6b8caca1UL, 0x3e66d3d5UL} },
+ { &fnv_test_str[117], (Fnv64_t) {0xc0095593UL, 0x956694a5UL} },
+ { &fnv_test_str[118], (Fnv64_t) {0xbb1a6fc8UL, 0xcac54572UL} },
+ { &fnv_test_str[119], (Fnv64_t) {0xedebf0d8UL, 0xa7a4c9f3UL} },
+ { &fnv_test_str[120], (Fnv64_t) {0xac17b143UL, 0x7829851fUL} },
+ { &fnv_test_str[121], (Fnv64_t) {0xf81bcf06UL, 0x2c8f4c9aUL} },
+ { &fnv_test_str[122], (Fnv64_t) {0x9740c732UL, 0xd34e3153UL} },
+ { &fnv_test_str[123], (Fnv64_t) {0x253d2db1UL, 0x3605a2acUL} },
+ { &fnv_test_str[124], (Fnv64_t) {0x46f4a3c3UL, 0x08c11b83UL} },
+ { &fnv_test_str[125], (Fnv64_t) {0x9ce8a6daUL, 0x6be39628UL} },
+ { &fnv_test_str[126], (Fnv64_t) {0x7fe794c5UL, 0xd9b957fbUL} },
+ { &fnv_test_str[127], (Fnv64_t) {0x04560a93UL, 0x05be33daUL} },
+ { &fnv_test_str[128], (Fnv64_t) {0x7ba9747cUL, 0x0957f157UL} },
+ { &fnv_test_str[129], (Fnv64_t) {0xc24fba57UL, 0xda2cc3acUL} },
+ { &fnv_test_str[130], (Fnv64_t) {0x5b29e7f0UL, 0x74136f18UL} },
+ { &fnv_test_str[131], (Fnv64_t) {0x0edb93b2UL, 0xb2f2b459UL} },
+ { &fnv_test_str[132], (Fnv64_t) {0x8b86ae04UL, 0xb3608fceUL} },
+ { &fnv_test_str[133], (Fnv64_t) {0x79359063UL, 0x4a3a8650UL} },
+ { &fnv_test_str[134], (Fnv64_t) {0x96880a50UL, 0x5b3a7ef4UL} },
+ { &fnv_test_str[135], (Fnv64_t) {0x3854c23bUL, 0x48fae316UL} },
+ { &fnv_test_str[136], (Fnv64_t) {0x476e0b9aUL, 0x07aaa640UL} },
+ { &fnv_test_str[137], (Fnv64_t) {0x383a687dUL, 0x2f653656UL} },
+ { &fnv_test_str[138], (Fnv64_t) {0x7599d79cUL, 0xa1031f8eUL} },
+ { &fnv_test_str[139], (Fnv64_t) {0x8ff92477UL, 0xa3190817UL} },
+ { &fnv_test_str[140], (Fnv64_t) {0x14c3fb83UL, 0x097edf3cUL} },
+ { &fnv_test_str[141], (Fnv64_t) {0xeaa0971bUL, 0xb51ca83fUL} },
+ { &fnv_test_str[142], (Fnv64_t) {0xd784f2e9UL, 0xdd3c0d96UL} },
+ { &fnv_test_str[143], (Fnv64_t) {0xea767d78UL, 0x86cd26a9UL} },
+ { &fnv_test_str[144], (Fnv64_t) {0x54a30c18UL, 0xe6b215ffUL} },
+ { &fnv_test_str[145], (Fnv64_t) {0xc5531093UL, 0xec5b06a1UL} },
+ { &fnv_test_str[146], (Fnv64_t) {0x9f9ec5e5UL, 0x45665a92UL} },
+ { &fnv_test_str[147], (Fnv64_t) {0xa9f10907UL, 0x8c7609b4UL} },
+ { &fnv_test_str[148], (Fnv64_t) {0x91f0d729UL, 0x89aac3a4UL} },
+ { &fnv_test_str[149], (Fnv64_t) {0xe0f4a403UL, 0x32ce6b26UL} },
+ { &fnv_test_str[150], (Fnv64_t) {0x02b53e01UL, 0x614ab44eUL} },
+ { &fnv_test_str[151], (Fnv64_t) {0x6eef3290UL, 0xfa6472ebUL} },
+ { &fnv_test_str[152], (Fnv64_t) {0x1948eb6aUL, 0x9e5d75ebUL} },
+ { &fnv_test_str[153], (Fnv64_t) {0xa8671852UL, 0xb6d12ad4UL} },
+ { &fnv_test_str[154], (Fnv64_t) {0xeba07af1UL, 0x88826f56UL} },
+ { &fnv_test_str[155], (Fnv64_t) {0x645bc0fdUL, 0x44535bf2UL} },
+ { &fnv_test_str[156], (Fnv64_t) {0xc21e3728UL, 0x169388ffUL} },
+ { &fnv_test_str[157], (Fnv64_t) {0x396d8224UL, 0xf68aac9eUL} },
+ { &fnv_test_str[158], (Fnv64_t) {0x472b3883UL, 0x8e87d7e7UL} },
+ { &fnv_test_str[159], (Fnv64_t) {0xa8b423deUL, 0x295c26caUL} },
+ { &fnv_test_str[160], (Fnv64_t) {0x92e72176UL, 0x322c8142UL} },
+ { &fnv_test_str[161], (Fnv64_t) {0xb8af7268UL, 0x8a06550eUL} },
+ { &fnv_test_str[162], (Fnv64_t) {0x661bcf71UL, 0xef86d60eUL} },
+ { &fnv_test_str[163], (Fnv64_t) {0x7f30ee54UL, 0x9e5426c8UL} },
+ { &fnv_test_str[164], (Fnv64_t) {0x26fd047eUL, 0xf1ea8aa8UL} },
+ { &fnv_test_str[165], (Fnv64_t) {0x642cb769UL, 0x0babaf9aUL} },
+ { &fnv_test_str[166], (Fnv64_t) {0x068d012eUL, 0x4b3341d4UL} },
+ { &fnv_test_str[167], (Fnv64_t) {0xc30a335cUL, 0xd15605cbUL} },
+ { &fnv_test_str[168], (Fnv64_t) {0xed8412e5UL, 0x5b21060aUL} },
+ { &fnv_test_str[169], (Fnv64_t) {0xce6f4227UL, 0x45e2cda1UL} },
+ { &fnv_test_str[170], (Fnv64_t) {0x033ad7d4UL, 0x50ae3745UL} },
+ { &fnv_test_str[171], (Fnv64_t) {0xd46bf414UL, 0xaa4588ceUL} },
+ { &fnv_test_str[172], (Fnv64_t) {0x4a95467eUL, 0xc1b0056cUL} },
+ { &fnv_test_str[173], (Fnv64_t) {0xde8b4089UL, 0x56576a71UL} },
+ { &fnv_test_str[174], (Fnv64_t) {0xa6dc927eUL, 0xbf20965fUL} },
+ { &fnv_test_str[175], (Fnv64_t) {0xc2040882UL, 0x569f8383UL} },
+ { &fnv_test_str[176], (Fnv64_t) {0xa08feca0UL, 0xe1e772fbUL} },
+ { &fnv_test_str[177], (Fnv64_t) {0x97138ac4UL, 0x4ced94afUL} },
+ { &fnv_test_str[178], (Fnv64_t) {0x337a82fbUL, 0xc4112ffbUL} },
+ { &fnv_test_str[179], (Fnv64_t) {0x1de38b7dUL, 0xd64a4fd4UL} },
+ { &fnv_test_str[180], (Fnv64_t) {0x9edebcbbUL, 0x4cfc3232UL} },
+ { &fnv_test_str[181], (Fnv64_t) {0x45050395UL, 0x08035644UL} },
+ { &fnv_test_str[182], (Fnv64_t) {0xf4642ffdUL, 0xaa1574ecUL} },
+ { &fnv_test_str[183], (Fnv64_t) {0x4cc315f9UL, 0x694bc4e5UL} },
+ { &fnv_test_str[184], (Fnv64_t) {0x3b011721UL, 0xa3d7cb27UL} },
+ { &fnv_test_str[185], (Fnv64_t) {0x6115bfa5UL, 0x577c2f8bUL} },
+ { &fnv_test_str[186], (Fnv64_t) {0x769fb4c1UL, 0xb7ec8c1aUL} },
+ { &fnv_test_str[187], (Fnv64_t) {0x3359ab19UL, 0x5d5cfce6UL} },
+ { &fnv_test_str[188], (Fnv64_t) {0xd65b5f71UL, 0x33b96c3cUL} },
+ { &fnv_test_str[189], (Fnv64_t) {0x80602bb9UL, 0xd8450977UL} },
+ { &fnv_test_str[190], (Fnv64_t) {0xd02da3d5UL, 0x84d47645UL} },
+ { &fnv_test_str[191], (Fnv64_t) {0xb58773a5UL, 0x83544f33UL} },
+ { &fnv_test_str[192], (Fnv64_t) {0x160836c5UL, 0x9175cbb2UL} },
+ { &fnv_test_str[193], (Fnv64_t) {0x75e72bc5UL, 0xc71b3bc1UL} },
+ { &fnv_test_str[194], (Fnv64_t) {0x222ec985UL, 0x636806acUL} },
+ { &fnv_test_str[195], (Fnv64_t) {0x50f52ed5UL, 0xb6ef0e69UL} },
+ { &fnv_test_str[196], (Fnv64_t) {0xf3dfdaa5UL, 0xead3d8a0UL} },
+ { &fnv_test_str[197], (Fnv64_t) {0x9a861ba5UL, 0x922908feUL} },
+ { &fnv_test_str[198], (Fnv64_t) {0x275fd5c5UL, 0x6d4821deUL} },
+ { &fnv_test_str[199], (Fnv64_t) {0x2bd816b5UL, 0x1fe3fce6UL} },
+ { &fnv_test_str[200], (Fnv64_t) {0xd6f70591UL, 0xc23e9fccUL} },
+ { &fnv_test_str[201], (Fnv64_t) {0xfe16b5b5UL, 0xc1af12bdUL} },
+ { &fnv_test_str[202], (Fnv64_t) {0x2f85e221UL, 0x39e9f18fUL} },
+ { NULL, (Fnv64_t) {0,0} }
+};
+#endif /* HAVE_64BIT_LONG_LONG */
+
+/* end of output generated by make vector.c */
+/*
+ * insert the contents of vector.c above
+ */
+
+
+/*
+ * unknown_hash_type - report an unknown hash type error
+ *
+ * NOTE: Does not return.
+ */
+void
+unknown_hash_type(char *prog, enum fnv_type type, int code)
+{
+ fprintf(stderr, "%s: unknown or unexpexted hash type: %d\n", prog, type);
+ exit(code);
+}
+
+
+/*
+ * print_fnv32 - print an FNV hash
+ *
+ * given:
+ * hval the hash value to print
+ * mask lower bit mask
+ * verbose 1 => print arg with hash
+ * arg string or filename arg
+ */
+void
+print_fnv32(Fnv32_t hval, Fnv32_t mask, int verbose, char *arg)
+{
+ if (verbose) {
+ printf("0x%08lx %s\n", hval & mask, arg);
+ } else {
+ printf("0x%08lx\n", hval & mask);
+ }
+}
+
+
+/*
+ * print_fnv64 - print an FNV hash
+ *
+ * given:
+ * hval the hash value to print
+ * mask lower bit mask
+ * verbose 1 => print arg with hash
+ * arg string or filename arg
+ */
+void
+print_fnv64(Fnv64_t hval, Fnv64_t mask, int verbose, char *arg)
+{
+#if defined(HAVE_64BIT_LONG_LONG)
+ if (verbose) {
+ printf("0x%016llx %s\n", hval & mask, arg);
+ } else {
+ printf("0x%016llx\n", hval & mask);
+ }
+#else
+ if (verbose) {
+ printf("0x%08lx%08lx %s\n",
+ hval.w32[1] & mask.w32[1],
+ hval.w32[0] & mask.w32[0],
+ arg);
+ } else {
+ printf("0x%08lx%08lx\n",
+ hval.w32[1] & mask.w32[1],
+ hval.w32[0] & mask.w32[0]);
+ }
+#endif
+}
diff --git a/lib/lufa b/lib/lufa
-Subproject 913c56a6d422685f540b49afa7c61458fb9272a
+Subproject 549b97320d515bfca2f95c145a67bd13be968fa
diff --git a/lib/pico-sdk b/lib/pico-sdk
new file mode 160000
+Subproject 07edde8e49890d2172bbc272aacc119f999df06
diff --git a/lib/printf b/lib/printf
-Subproject d3b984684bb8a8bdc48cc7a1abecb93ce59bbe3
+Subproject c2e3b4e10d281e7f0f694d3ecbd9f320977288c
diff --git a/lib/python/qmk/c_parse.py b/lib/python/qmk/c_parse.py
index 359aaccbbc..c14eb490fa 100644
--- a/lib/python/qmk/c_parse.py
+++ b/lib/python/qmk/c_parse.py
@@ -24,6 +24,14 @@ def _get_chunks(it, size):
return iter(lambda: tuple(islice(it, size)), ())
+def _preprocess_c_file(file):
+ """Load file and strip comments
+ """
+ file_contents = file.read_text(encoding='utf-8')
+ file_contents = comment_remover(file_contents)
+ return file_contents.replace('\\\n', '')
+
+
def strip_line_comment(string):
"""Removes comments from a single line string.
"""
@@ -58,9 +66,7 @@ def find_layouts(file):
parsed_layouts = {}
# Search the file for LAYOUT macros and aliases
- file_contents = file.read_text(encoding='utf-8')
- file_contents = comment_remover(file_contents)
- file_contents = file_contents.replace('\\\n', '')
+ file_contents = _preprocess_c_file(file)
for line in file_contents.split('\n'):
if layout_macro_define_regex.match(line.lstrip()) and '(' in line and 'LAYOUT' in line:
@@ -205,13 +211,23 @@ def _coerce_led_token(_type, value):
return value_map[value]
+def _validate_led_config(matrix, matrix_rows, matrix_indexes, position, position_raw, flags):
+ # TODO: Improve crude parsing/validation
+ if len(matrix) != matrix_rows and len(matrix) != (matrix_rows / 2):
+ raise ValueError("Unable to parse g_led_config matrix data")
+ if len(position) != len(flags):
+ raise ValueError("Unable to parse g_led_config position data")
+ if len(matrix_indexes) and (max(matrix_indexes) >= len(flags)):
+ raise ValueError("OOB within g_led_config matrix data")
+ if not all(isinstance(n, int) for n in matrix_indexes):
+ raise ValueError("matrix indexes are not all ints")
+ if (len(position_raw) % 2) != 0:
+ raise ValueError("Malformed g_led_config position data")
+
+
def _parse_led_config(file, matrix_cols, matrix_rows):
"""Return any 'raw' led/rgb matrix config
"""
- file_contents = file.read_text(encoding='utf-8')
- file_contents = comment_remover(file_contents)
- file_contents = file_contents.replace('\\\n', '')
-
matrix_raw = []
position_raw = []
flags = []
@@ -219,7 +235,7 @@ def _parse_led_config(file, matrix_cols, matrix_rows):
found_led_config = False
bracket_count = 0
section = 0
- for _type, value in lex(file_contents, CLexer()):
+ for _type, value in lex(_preprocess_c_file(file), CLexer()):
# Assume g_led_config..stuff..;
if value == 'g_led_config':
found_led_config = True
@@ -242,23 +258,21 @@ def _parse_led_config(file, matrix_cols, matrix_rows):
position_raw.append(_coerce_led_token(_type, value))
if section == 3 and bracket_count == 2:
flags.append(_coerce_led_token(_type, value))
+ elif _type in [Token.Comment.Preproc]:
+ # TODO: Promote to error
+ return None
# Slightly better intrim format
matrix = list(_get_chunks(matrix_raw, matrix_cols))
position = list(_get_chunks(position_raw, 2))
matrix_indexes = list(filter(lambda x: x is not None, matrix_raw))
- # If we have not found anything - bail
+ # If we have not found anything - bail with no error
if not section:
return None
- # TODO: Improve crude parsing/validation
- if len(matrix) != matrix_rows and len(matrix) != (matrix_rows / 2):
- raise ValueError("Unable to parse g_led_config matrix data")
- if len(position) != len(flags):
- raise ValueError("Unable to parse g_led_config position data")
- if len(matrix_indexes) and (max(matrix_indexes) >= len(flags)):
- raise ValueError("OOB within g_led_config matrix data")
+ # Throw any validation errors
+ _validate_led_config(matrix, matrix_rows, matrix_indexes, position, position_raw, flags)
return (matrix, position, flags)
diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py
index d7192631a3..98e212c47b 100644
--- a/lib/python/qmk/cli/__init__.py
+++ b/lib/python/qmk/cli/__init__.py
@@ -15,6 +15,7 @@ from milc.questions import yesno
import_names = {
# A mapping of package name to importable name
'pep8-naming': 'pep8ext_naming',
+ 'pyserial': 'serial',
'pyusb': 'usb.core',
'qmk-dotty-dict': 'dotty_dict',
'pillow': 'PIL'
@@ -59,6 +60,9 @@ subcommands = [
'qmk.cli.generate.rules_mk',
'qmk.cli.generate.version_h',
'qmk.cli.hello',
+ 'qmk.cli.import.kbfirmware',
+ 'qmk.cli.import.keyboard',
+ 'qmk.cli.import.keymap',
'qmk.cli.info',
'qmk.cli.json2c',
'qmk.cli.lint',
@@ -91,7 +95,7 @@ def _install_deps(requirements):
elif not os.access(sys.prefix, os.W_OK):
# We can't write to sys.prefix, attempt to install locally
- command.append('--local')
+ command.append('--user')
return _run_cmd(*command, '-r', requirements)
@@ -156,6 +160,18 @@ def _broken_module_imports(requirements):
return False
+def _yesno(*args):
+ """Wrapper to only prompt if interactive
+ """
+ return sys.stdout.isatty() and yesno(*args)
+
+
+def _eprint(errmsg):
+ """Wrapper to print to stderr
+ """
+ print(errmsg, file=sys.stderr)
+
+
# Make sure our python is new enough
#
# Supported version information
@@ -177,7 +193,7 @@ def _broken_module_imports(requirements):
# void: 3.9
if sys.version_info[0] != 3 or sys.version_info[1] < 7:
- print('Error: Your Python is too old! Please upgrade to Python 3.7 or later.')
+ _eprint('Error: Your Python is too old! Please upgrade to Python 3.7 or later.')
exit(127)
milc_version = __VERSION__.split('.')
@@ -185,7 +201,7 @@ milc_version = __VERSION__.split('.')
if int(milc_version[0]) < 2 and int(milc_version[1]) < 4:
requirements = Path('requirements.txt').resolve()
- print(f'Your MILC library is too old! Please upgrade: python3 -m pip install -U -r {str(requirements)}')
+ _eprint(f'Your MILC library is too old! Please upgrade: python3 -m pip install -U -r {str(requirements)}')
exit(127)
# Make sure we can run binaries in the same directory as our Python interpreter
@@ -195,7 +211,7 @@ if python_dir not in os.environ['PATH'].split(':'):
os.environ['PATH'] = ":".join((python_dir, os.environ['PATH']))
# Check to make sure we have all our dependencies
-msg_install = f'Please run `{sys.executable} -m pip install -r %s` to install required python dependencies.'
+msg_install = f'\nPlease run `{sys.executable} -m pip install -r %s` to install required python dependencies.'
args = sys.argv[1:]
while args and args[0][0] == '-':
del args[0]
@@ -204,24 +220,20 @@ safe_command = args and args[0] in safe_commands
if not safe_command:
if _broken_module_imports('requirements.txt'):
- if yesno('Would you like to install the required Python modules?'):
+ if _yesno('Would you like to install the required Python modules?'):
_install_deps('requirements.txt')
else:
- print()
- print(msg_install % (str(Path('requirements.txt').resolve()),))
- print()
+ _eprint(msg_install % (str(Path('requirements.txt').resolve()),))
exit(1)
if cli.config.user.developer and _broken_module_imports('requirements-dev.txt'):
- if yesno('Would you like to install the required developer Python modules?'):
+ if _yesno('Would you like to install the required developer Python modules?'):
_install_deps('requirements-dev.txt')
- elif yesno('Would you like to disable developer mode?'):
+ elif _yesno('Would you like to disable developer mode?'):
_run_cmd(sys.argv[0], 'config', 'user.developer=None')
else:
- print()
- print(msg_install % (str(Path('requirements-dev.txt').resolve()),))
- print('You can also turn off developer mode: qmk config user.developer=None')
- print()
+ _eprint(msg_install % (str(Path('requirements-dev.txt').resolve()),))
+ _eprint('You can also turn off developer mode: qmk config user.developer=None')
exit(1)
# Import our subcommands
@@ -231,6 +243,6 @@ for subcommand in subcommands:
except (ImportError, ModuleNotFoundError) as e:
if safe_command:
- print(f'Warning: Could not import {subcommand}: {e.__class__.__name__}, {e}')
+ _eprint(f'Warning: Could not import {subcommand}: {e.__class__.__name__}, {e}')
else:
raise
diff --git a/lib/python/qmk/cli/compile.py b/lib/python/qmk/cli/compile.py
index acbd778649..95118e6687 100755
--- a/lib/python/qmk/cli/compile.py
+++ b/lib/python/qmk/cli/compile.py
@@ -32,8 +32,9 @@ def compile(cli):
If a keyboard and keymap are provided this command will build a firmware based on that.
"""
if cli.args.clean and not cli.args.filename and not cli.args.dry_run:
- command = create_make_command(cli.config.compile.keyboard, cli.config.compile.keymap, 'clean')
- cli.run(command, capture_output=False, stdin=DEVNULL)
+ if cli.config.compile.keyboard and cli.config.compile.keymap:
+ command = create_make_command(cli.config.compile.keyboard, cli.config.compile.keymap, 'clean')
+ cli.run(command, capture_output=False, stdin=DEVNULL)
# Build the environment vars
envs = {}
diff --git a/lib/python/qmk/cli/doctor/linux.py b/lib/python/qmk/cli/doctor/linux.py
index 94683d3307..a803305c0d 100644
--- a/lib/python/qmk/cli/doctor/linux.py
+++ b/lib/python/qmk/cli/doctor/linux.py
@@ -6,7 +6,7 @@ from pathlib import Path
from milc import cli
-from qmk.constants import QMK_FIRMWARE
+from qmk.constants import QMK_FIRMWARE, BOOTLOADER_VIDS_PIDS
from .check import CheckStatus
@@ -26,6 +26,18 @@ def _udev_rule(vid, pid=None, *args):
return rule
+def _generate_desired_rules(bootloader_vids_pids):
+ rules = dict()
+ for bl in bootloader_vids_pids.keys():
+ rules[bl] = set()
+ for vid_pid in bootloader_vids_pids[bl]:
+ if bl == 'caterina' or bl == 'md-boot':
+ rules[bl].add(_udev_rule(vid_pid[0], vid_pid[1], 'ENV{ID_MM_DEVICE_IGNORE}="1"'))
+ else:
+ rules[bl].add(_udev_rule(vid_pid[0], vid_pid[1]))
+ return rules
+
+
def _deprecated_udev_rule(vid, pid=None):
""" Helper function that return udev rules
@@ -47,47 +59,8 @@ def check_udev_rules():
Path("/run/udev/rules.d/"),
Path("/etc/udev/rules.d/"),
]
- desired_rules = {
- 'atmel-dfu': {
- _udev_rule("03eb", "2fef"), # ATmega16U2
- _udev_rule("03eb", "2ff0"), # ATmega32U2
- _udev_rule("03eb", "2ff3"), # ATmega16U4
- _udev_rule("03eb", "2ff4"), # ATmega32U4
- _udev_rule("03eb", "2ff9"), # AT90USB64
- _udev_rule("03eb", "2ffa"), # AT90USB162
- _udev_rule("03eb", "2ffb") # AT90USB128
- },
- 'kiibohd': {_udev_rule("1c11", "b007")},
- 'stm32': {
- _udev_rule("1eaf", "0003"), # STM32duino
- _udev_rule("0483", "df11") # STM32 DFU
- },
- 'bootloadhid': {_udev_rule("16c0", "05df")},
- 'usbasploader': {_udev_rule("16c0", "05dc")},
- 'massdrop': {_udev_rule("03eb", "6124", 'ENV{ID_MM_DEVICE_IGNORE}="1"')},
- 'caterina': {
- # Spark Fun Electronics
- _udev_rule("1b4f", "9203", 'ENV{ID_MM_DEVICE_IGNORE}="1"'), # Pro Micro 3V3/8MHz
- _udev_rule("1b4f", "9205", 'ENV{ID_MM_DEVICE_IGNORE}="1"'), # Pro Micro 5V/16MHz
- _udev_rule("1b4f", "9207", 'ENV{ID_MM_DEVICE_IGNORE}="1"'), # LilyPad 3V3/8MHz (and some Pro Micro clones)
- # Pololu Electronics
- _udev_rule("1ffb", "0101", 'ENV{ID_MM_DEVICE_IGNORE}="1"'), # A-Star 32U4
- # Arduino SA
- _udev_rule("2341", "0036", 'ENV{ID_MM_DEVICE_IGNORE}="1"'), # Leonardo
- _udev_rule("2341", "0037", 'ENV{ID_MM_DEVICE_IGNORE}="1"'), # Micro
- # Adafruit Industries LLC
- _udev_rule("239a", "000c", 'ENV{ID_MM_DEVICE_IGNORE}="1"'), # Feather 32U4
- _udev_rule("239a", "000d", 'ENV{ID_MM_DEVICE_IGNORE}="1"'), # ItsyBitsy 32U4 3V3/8MHz
- _udev_rule("239a", "000e", 'ENV{ID_MM_DEVICE_IGNORE}="1"'), # ItsyBitsy 32U4 5V/16MHz
- # dog hunter AG
- _udev_rule("2a03", "0036", 'ENV{ID_MM_DEVICE_IGNORE}="1"'), # Leonardo
- _udev_rule("2a03", "0037", 'ENV{ID_MM_DEVICE_IGNORE}="1"') # Micro
- },
- 'hid-bootloader': {
- _udev_rule("03eb", "2067"), # QMK HID
- _udev_rule("16c0", "0478") # PJRC halfkay
- }
- }
+
+ desired_rules = _generate_desired_rules(BOOTLOADER_VIDS_PIDS)
# These rules are no longer recommended, only use them to check for their presence.
deprecated_rules = {
diff --git a/lib/python/qmk/cli/doctor/macos.py b/lib/python/qmk/cli/doctor/macos.py
index 00fb272858..5d088c9492 100644
--- a/lib/python/qmk/cli/doctor/macos.py
+++ b/lib/python/qmk/cli/doctor/macos.py
@@ -8,6 +8,6 @@ from .check import CheckStatus
def os_test_macos():
"""Run the Mac specific tests.
"""
- cli.log.info("Detected {fg_cyan}macOS %s{fg_reset}.", platform.mac_ver()[0])
+ cli.log.info("Detected {fg_cyan}macOS %s (%s){fg_reset}.", platform.mac_ver()[0], 'Apple Silicon' if platform.processor() == 'arm' else 'Intel')
return CheckStatus.OK
diff --git a/lib/python/qmk/cli/doctor/main.py b/lib/python/qmk/cli/doctor/main.py
index 2898a9894c..1600ab8dd4 100755
--- a/lib/python/qmk/cli/doctor/main.py
+++ b/lib/python/qmk/cli/doctor/main.py
@@ -11,7 +11,7 @@ from milc.questions import yesno
from qmk import submodules
from qmk.constants import QMK_FIRMWARE, QMK_FIRMWARE_UPSTREAM
from .check import CheckStatus, check_binaries, check_binary_versions, check_submodules
-from qmk.git import git_check_repo, git_get_branch, git_get_tag, git_is_dirty, git_get_remotes, git_check_deviation
+from qmk.git import git_check_repo, git_get_branch, git_get_tag, git_get_last_log_entry, git_get_common_ancestor, git_is_dirty, git_get_remotes, git_check_deviation
from qmk.commands import in_virtualenv
@@ -66,10 +66,32 @@ def git_tests():
if git_branch in ['master', 'develop'] and git_deviation:
cli.log.warning('{fg_yellow}The local "%s" branch contains commits not found in the upstream branch.', git_branch)
status = CheckStatus.WARNING
+ for branch in [git_branch, 'upstream/master', 'upstream/develop']:
+ cli.log.info('- Latest %s: %s', branch, git_get_last_log_entry(branch))
+ for branch in ['upstream/master', 'upstream/develop']:
+ cli.log.info('- Common ancestor with %s: %s', branch, git_get_common_ancestor(branch, 'HEAD'))
return status
+def output_submodule_status():
+ """Prints out information related to the submodule status.
+ """
+ cli.log.info('Submodule status:')
+ sub_status = submodules.status()
+ for s in sub_status.keys():
+ sub_info = sub_status[s]
+ if 'name' in sub_info:
+ sub_name = sub_info['name']
+ sub_shorthash = sub_info['shorthash'] if 'shorthash' in sub_info else ''
+ sub_describe = sub_info['describe'] if 'describe' in sub_info else ''
+ sub_last_log_timestamp = sub_info['last_log_timestamp'] if 'last_log_timestamp' in sub_info else ''
+ if sub_last_log_timestamp != '':
+ cli.log.info(f'- {sub_name}: {sub_last_log_timestamp} -- {sub_describe} ({sub_shorthash})')
+ else:
+ cli.log.error(f'- {sub_name}: <<< missing or unknown >>>')
+
+
@cli.argument('-y', '--yes', action='store_true', arg_only=True, help='Answer yes to all questions.')
@cli.argument('-n', '--no', action='store_true', arg_only=True, help='Answer no to all questions.')
@cli.subcommand('Basic QMK environment checks')
@@ -129,6 +151,8 @@ def doctor(cli):
elif sub_ok == CheckStatus.WARNING and status == CheckStatus.OK:
status = CheckStatus.WARNING
+ output_submodule_status()
+
# Report a summary of our findings to the user
if status == CheckStatus.OK:
cli.log.info('{fg_green}QMK is ready to go')
diff --git a/lib/python/qmk/cli/flash.py b/lib/python/qmk/cli/flash.py
index 28e48a4101..c39f4b36d4 100644
--- a/lib/python/qmk/cli/flash.py
+++ b/lib/python/qmk/cli/flash.py
@@ -4,6 +4,7 @@ You can compile a keymap already in the repo or using a QMK Configurator export.
A bootloader must be specified.
"""
from subprocess import DEVNULL
+import sys
from argcomplete.completers import FilesCompleter
from milc import cli
@@ -12,6 +13,7 @@ import qmk.path
from qmk.decorators import automagic_keyboard, automagic_keymap
from qmk.commands import compile_configurator_json, create_make_command, parse_configurator_json
from qmk.keyboard import keyboard_completer, keyboard_folder
+from qmk.flashers import flasher
def print_bootloader_help():
@@ -33,12 +35,15 @@ def print_bootloader_help():
cli.echo('\tdfu-split-right')
cli.echo('\tdfu-util-split-left')
cli.echo('\tdfu-util-split-right')
+ cli.echo('\tuf2-split-left')
+ cli.echo('\tuf2-split-right')
cli.echo('For more info, visit https://docs.qmk.fm/#/flashing')
-@cli.argument('filename', nargs='?', arg_only=True, type=qmk.path.FileType('r'), completer=FilesCompleter('.json'), help='The configurator export JSON to compile.')
+@cli.argument('filename', nargs='?', arg_only=True, type=qmk.path.FileType('r'), completer=FilesCompleter('.json'), help='A configurator export JSON to be compiled and flashed or a pre-compiled binary firmware file (bin/hex) to be flashed.')
@cli.argument('-b', '--bootloaders', action='store_true', help='List the available bootloaders.')
@cli.argument('-bl', '--bootloader', default='flash', help='The flash command, corresponding to qmk\'s make options of bootloaders.')
+@cli.argument('-m', '--mcu', help='The MCU name. Required for HalfKay, HID, USBAspLoader and ISP flashing.')
@cli.argument('-km', '--keymap', help='The keymap to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.')
@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='The keyboard to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.')
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the make command to be run.")
@@ -51,6 +56,8 @@ def print_bootloader_help():
def flash(cli):
"""Compile and or flash QMK Firmware or keyboard/layout
+ If a binary firmware is supplied, try to flash that.
+
If a Configurator JSON export is supplied this command will create a new keymap. Keymap and Keyboard arguments
will be ignored.
@@ -58,55 +65,69 @@ def flash(cli):
If bootloader is omitted the make system will use the configured bootloader for that keyboard.
"""
- if cli.args.clean and not cli.args.filename and not cli.args.dry_run:
- command = create_make_command(cli.config.flash.keyboard, cli.config.flash.keymap, 'clean')
- cli.run(command, capture_output=False, stdin=DEVNULL)
-
- # Build the environment vars
- envs = {}
- for env in cli.args.env:
- if '=' in env:
- key, value = env.split('=', 1)
- envs[key] = value
- else:
- cli.log.warning('Invalid environment variable: %s', env)
-
- # Determine the compile command
- command = ''
-
- if cli.args.bootloaders:
- # Provide usage and list bootloaders
- cli.echo('usage: qmk flash [-h] [-b] [-n] [-kb KEYBOARD] [-km KEYMAP] [-bl BOOTLOADER] [filename]')
- print_bootloader_help()
- return False
-
- if cli.args.filename:
- # Handle compiling a configurator JSON
- user_keymap = parse_configurator_json(cli.args.filename)
- keymap_path = qmk.path.keymap(user_keymap['keyboard'])
- command = compile_configurator_json(user_keymap, cli.args.bootloader, parallel=cli.config.flash.parallel, **envs)
-
- cli.log.info('Wrote keymap to {fg_cyan}%s/%s/keymap.c', keymap_path, user_keymap['keymap'])
+ if cli.args.filename and cli.args.filename.suffix in ['.bin', '.hex']:
+ # Try to flash binary firmware
+ cli.echo('Flashing binary firmware...\nPlease reset your keyboard into bootloader mode now!\nPress Ctrl-C to exit.\n')
+ try:
+ err, msg = flasher(cli.args.mcu, cli.args.filename)
+ if err:
+ cli.log.error(msg)
+ return False
+ except KeyboardInterrupt:
+ cli.log.info('Ctrl-C was pressed, exiting...')
+ sys.exit(0)
else:
- if cli.config.flash.keyboard and cli.config.flash.keymap:
- # Generate the make command for a specific keyboard/keymap.
- command = create_make_command(cli.config.flash.keyboard, cli.config.flash.keymap, cli.args.bootloader, parallel=cli.config.flash.parallel, **envs)
-
- elif not cli.config.flash.keyboard:
- cli.log.error('Could not determine keyboard!')
- elif not cli.config.flash.keymap:
- cli.log.error('Could not determine keymap!')
-
- # Compile the firmware, if we're able to
- if command:
- cli.log.info('Compiling keymap with {fg_cyan}%s', ' '.join(command))
- if not cli.args.dry_run:
- cli.echo('\n')
- compile = cli.run(command, capture_output=False, stdin=DEVNULL)
- return compile.returncode
+ if cli.args.clean and not cli.args.filename and not cli.args.dry_run:
+ if cli.config.flash.keyboard and cli.config.flash.keymap:
+ command = create_make_command(cli.config.flash.keyboard, cli.config.flash.keymap, 'clean')
+ cli.run(command, capture_output=False, stdin=DEVNULL)
+
+ # Build the environment vars
+ envs = {}
+ for env in cli.args.env:
+ if '=' in env:
+ key, value = env.split('=', 1)
+ envs[key] = value
+ else:
+ cli.log.warning('Invalid environment variable: %s', env)
+
+ # Determine the compile command
+ command = ''
+
+ if cli.args.bootloaders:
+ # Provide usage and list bootloaders
+ cli.echo('usage: qmk flash [-h] [-b] [-n] [-kb KEYBOARD] [-km KEYMAP] [-bl BOOTLOADER] [filename]')
+ print_bootloader_help()
+ return False
+
+ if cli.args.filename:
+ # Handle compiling a configurator JSON
+ user_keymap = parse_configurator_json(cli.args.filename)
+ keymap_path = qmk.path.keymap(user_keymap['keyboard'])
+ command = compile_configurator_json(user_keymap, cli.args.bootloader, parallel=cli.config.flash.parallel, **envs)
+
+ cli.log.info('Wrote keymap to {fg_cyan}%s/%s/keymap.c', keymap_path, user_keymap['keymap'])
- else:
- cli.log.error('You must supply a configurator export, both `--keyboard` and `--keymap`, or be in a directory for a keyboard or keymap.')
- cli.echo('usage: qmk flash [-h] [-b] [-n] [-kb KEYBOARD] [-km KEYMAP] [-bl BOOTLOADER] [filename]')
- return False
+ else:
+ if cli.config.flash.keyboard and cli.config.flash.keymap:
+ # Generate the make command for a specific keyboard/keymap.
+ command = create_make_command(cli.config.flash.keyboard, cli.config.flash.keymap, cli.args.bootloader, parallel=cli.config.flash.parallel, **envs)
+
+ elif not cli.config.flash.keyboard:
+ cli.log.error('Could not determine keyboard!')
+ elif not cli.config.flash.keymap:
+ cli.log.error('Could not determine keymap!')
+
+ # Compile the firmware, if we're able to
+ if command:
+ cli.log.info('Compiling keymap with {fg_cyan}%s', ' '.join(command))
+ if not cli.args.dry_run:
+ cli.echo('\n')
+ compile = cli.run(command, capture_output=False, stdin=DEVNULL)
+ return compile.returncode
+
+ else:
+ cli.log.error('You must supply a configurator export, both `--keyboard` and `--keymap`, or be in a directory for a keyboard or keymap.')
+ cli.echo('usage: qmk flash [-h] [-b] [-n] [-kb KEYBOARD] [-km KEYMAP] [-bl BOOTLOADER] [filename]')
+ return False
diff --git a/lib/python/qmk/cli/generate/api.py b/lib/python/qmk/cli/generate/api.py
index 0596b3f22b..8d8ca3cd41 100755
--- a/lib/python/qmk/cli/generate/api.py
+++ b/lib/python/qmk/cli/generate/api.py
@@ -12,21 +12,30 @@ from qmk.json_encoders import InfoJSONEncoder
from qmk.json_schema import json_load
from qmk.keyboard import find_readme, list_keyboards
-TEMPLATE_PATH = Path('data/templates/api/')
+DATA_PATH = Path('data')
+TEMPLATE_PATH = DATA_PATH / 'templates/api/'
BUILD_API_PATH = Path('.build/api_data/')
+def _filtered_keyboard_list():
+ """Perform basic filtering of list_keyboards
+ """
+ keyboard_list = list_keyboards()
+ if cli.args.filter:
+ kb_list = []
+ for keyboard_name in keyboard_list:
+ if any(i in keyboard_name for i in cli.args.filter):
+ kb_list.append(keyboard_name)
+ keyboard_list = kb_list
+ return keyboard_list
+
+
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't write the data to disk.")
@cli.argument('-f', '--filter', arg_only=True, action='append', default=[], help="Filter the list of keyboards based on partial name matches the supplied value. May be passed multiple times.")
-@cli.subcommand('Creates a new keymap for the keyboard of your choosing', hidden=False if cli.config.user.developer else True)
+@cli.subcommand('Generate QMK API data', hidden=False if cli.config.user.developer else True)
def generate_api(cli):
"""Generates the QMK API data.
"""
- if BUILD_API_PATH.exists():
- shutil.rmtree(BUILD_API_PATH)
-
- shutil.copytree(TEMPLATE_PATH, BUILD_API_PATH)
-
v1_dir = BUILD_API_PATH / 'v1'
keyboard_all_file = v1_dir / 'keyboards.json' # A massive JSON containing everything
keyboard_list_file = v1_dir / 'keyboard_list.json' # A simple list of keyboard targets
@@ -34,14 +43,14 @@ def generate_api(cli):
keyboard_metadata_file = v1_dir / 'keyboard_metadata.json' # All the data configurator/via needs for initialization
usb_file = v1_dir / 'usb.json' # A mapping of USB VID/PID -> keyboard target
+ if BUILD_API_PATH.exists():
+ shutil.rmtree(BUILD_API_PATH)
+
+ shutil.copytree(TEMPLATE_PATH, BUILD_API_PATH)
+ shutil.copytree(DATA_PATH, v1_dir)
+
# Filter down when required
- keyboard_list = list_keyboards()
- if cli.args.filter:
- kb_list = []
- for keyboard_name in keyboard_list:
- if any(i in keyboard_name for i in cli.args.filter):
- kb_list.append(keyboard_name)
- keyboard_list = kb_list
+ keyboard_list = _filtered_keyboard_list()
kb_all = {}
usb_list = {}
diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py
index 893892c479..a26dcdf7d7 100755
--- a/lib/python/qmk/cli/generate/config_h.py
+++ b/lib/python/qmk/cli/generate/config_h.py
@@ -134,6 +134,36 @@ def generate_config_items(kb_info_json, config_h_lines):
config_h_lines.append(f'#endif // {config_key}')
+def generate_encoder_config(encoder_json, config_h_lines, postfix=''):
+ """Generate the config.h lines for encoders."""
+ a_pads = []
+ b_pads = []
+ resolutions = []
+ for encoder in encoder_json.get("rotary", []):
+ a_pads.append(encoder["pin_a"])
+ b_pads.append(encoder["pin_b"])
+ resolutions.append(encoder.get("resolution", None))
+
+ config_h_lines.append(f'#ifndef ENCODERS_PAD_A{postfix}')
+ config_h_lines.append(f'# define ENCODERS_PAD_A{postfix} {{ { ", ".join(a_pads) } }}')
+ config_h_lines.append(f'#endif // ENCODERS_PAD_A{postfix}')
+
+ config_h_lines.append(f'#ifndef ENCODERS_PAD_B{postfix}')
+ config_h_lines.append(f'# define ENCODERS_PAD_B{postfix} {{ { ", ".join(b_pads) } }}')
+ config_h_lines.append(f'#endif // ENCODERS_PAD_B{postfix}')
+
+ if None in resolutions:
+ cli.log.debug("Unable to generate ENCODER_RESOLUTION configuration")
+ elif len(set(resolutions)) == 1:
+ config_h_lines.append(f'#ifndef ENCODER_RESOLUTION{postfix}')
+ config_h_lines.append(f'# define ENCODER_RESOLUTION{postfix} { resolutions[0] }')
+ config_h_lines.append(f'#endif // ENCODER_RESOLUTION{postfix}')
+ else:
+ config_h_lines.append(f'#ifndef ENCODER_RESOLUTIONS{postfix}')
+ config_h_lines.append(f'# define ENCODER_RESOLUTIONS{postfix} {{ { ", ".join(map(str,resolutions)) } }}')
+ config_h_lines.append(f'#endif // ENCODER_RESOLUTIONS{postfix}')
+
+
def generate_split_config(kb_info_json, config_h_lines):
"""Generate the config.h lines for split boards."""
if 'primary' in kb_info_json['split']:
@@ -173,6 +203,9 @@ def generate_split_config(kb_info_json, config_h_lines):
if 'right' in kb_info_json['split'].get('matrix_pins', {}):
config_h_lines.append(matrix_pins(kb_info_json['split']['matrix_pins']['right'], '_RIGHT'))
+ if 'right' in kb_info_json['split'].get('encoder', {}):
+ generate_encoder_config(kb_info_json['split']['encoder']['right'], config_h_lines, '_RIGHT')
+
@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
@@ -198,6 +231,9 @@ def generate_config_h(cli):
if 'matrix_pins' in kb_info_json:
config_h_lines.append(matrix_pins(kb_info_json['matrix_pins']))
+ if 'encoder' in kb_info_json:
+ generate_encoder_config(kb_info_json['encoder'], config_h_lines)
+
if 'split' in kb_info_json:
generate_split_config(kb_info_json, config_h_lines)
diff --git a/lib/python/qmk/cli/generate/dfu_header.py b/lib/python/qmk/cli/generate/dfu_header.py
index e873117387..aa0252ca86 100644
--- a/lib/python/qmk/cli/generate/dfu_header.py
+++ b/lib/python/qmk/cli/generate/dfu_header.py
@@ -33,8 +33,8 @@ def generate_dfu_header(cli):
kb_info_json = dotty(info_json(cli.config.generate_dfu_header.keyboard))
keyboard_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '#pragma once']
- keyboard_h_lines.append(f'#define MANUFACTURER {kb_info_json["manufacturer"]}')
- keyboard_h_lines.append(f'#define PRODUCT {kb_info_json["keyboard_name"]} Bootloader')
+ keyboard_h_lines.append(f'#define MANUFACTURER "{kb_info_json["manufacturer"]}"')
+ keyboard_h_lines.append(f'#define PRODUCT "{kb_info_json["keyboard_name"]} Bootloader"')
# Optional
if 'qmk_lufa_bootloader.esc_output' in kb_info_json:
diff --git a/lib/python/qmk/cli/generate/info_json.py b/lib/python/qmk/cli/generate/info_json.py
index 284d1a8510..0dc80f10cc 100755
--- a/lib/python/qmk/cli/generate/info_json.py
+++ b/lib/python/qmk/cli/generate/info_json.py
@@ -5,7 +5,7 @@ Compile an info.json for a particular keyboard and pretty-print it.
import json
from argcomplete.completers import FilesCompleter
-from jsonschema import Draft7Validator, RefResolver, validators
+from jsonschema import Draft202012Validator, RefResolver, validators
from milc import cli
from pathlib import Path
@@ -18,7 +18,7 @@ from qmk.path import is_keyboard, normpath
def pruning_validator(validator_class):
- """Extends Draft7Validator to remove properties that aren't specified in the schema.
+ """Extends Draft202012Validator to remove properties that aren't specified in the schema.
"""
validate_properties = validator_class.VALIDATORS["properties"]
@@ -37,10 +37,10 @@ def strip_info_json(kb_info_json):
"""Remove the API-only properties from the info.json.
"""
schema_store = compile_schema_store()
- pruning_draft_7_validator = pruning_validator(Draft7Validator)
+ pruning_draft_validator = pruning_validator(Draft202012Validator)
schema = schema_store['qmk.keyboard.v1']
resolver = RefResolver.from_schema(schema_store['qmk.keyboard.v1'], store=schema_store)
- validator = pruning_draft_7_validator(schema, resolver=resolver).validate
+ validator = pruning_draft_validator(schema, resolver=resolver).validate
return validator(kb_info_json)
diff --git a/lib/python/qmk/cli/generate/keyboard_h.py b/lib/python/qmk/cli/generate/keyboard_h.py
index 2058865cbf..54ddb4cffd 100755
--- a/lib/python/qmk/cli/generate/keyboard_h.py
+++ b/lib/python/qmk/cli/generate/keyboard_h.py
@@ -41,7 +41,7 @@ def generate_keyboard_h(cli):
keyboard_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '#pragma once', '#include "quantum.h"']
if not has_layout_h:
- keyboard_h_lines.append('#pragma error("<keyboard>.h is only optional for data driven keyboards - kb.h == bad times")')
+ keyboard_h_lines.append('#error("<keyboard>.h is only optional for data driven keyboards - kb.h == bad times")')
# Show the results
dump_lines(cli.args.output, keyboard_h_lines, cli.args.quiet)
diff --git a/lib/python/qmk/cli/import/__init__.py b/lib/python/qmk/cli/import/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/lib/python/qmk/cli/import/__init__.py
diff --git a/lib/python/qmk/cli/import/kbfirmware.py b/lib/python/qmk/cli/import/kbfirmware.py
new file mode 100644
index 0000000000..9c03737378
--- /dev/null
+++ b/lib/python/qmk/cli/import/kbfirmware.py
@@ -0,0 +1,25 @@
+from milc import cli
+
+from qmk.importers import import_kbfirmware as _import_kbfirmware
+from qmk.path import FileType
+from qmk.json_schema import json_load
+
+
+@cli.argument('filename', type=FileType('r'), nargs='+', arg_only=True, help='file')
+@cli.subcommand('Import kbfirmware json export')
+def import_kbfirmware(cli):
+ filename = cli.args.filename[0]
+
+ data = json_load(filename)
+
+ cli.log.info(f'{{style_bright}}Importing {filename.name}.{{style_normal}}')
+ cli.echo('')
+
+ cli.log.warn("Support here is basic - Consider using 'qmk new-keyboard' instead")
+
+ kb_name = _import_kbfirmware(data)
+
+ cli.log.info(f'{{fg_green}}Imported a new keyboard named {{fg_cyan}}{kb_name}{{fg_green}}.{{fg_reset}}')
+ cli.log.info(f'To start working on things, `cd` into {{fg_cyan}}keyboards/{kb_name}{{fg_reset}},')
+ cli.log.info('or open the directory in your preferred text editor.')
+ cli.log.info(f"And build with {{fg_yellow}}qmk compile -kb {kb_name} -km default{{fg_reset}}.")
diff --git a/lib/python/qmk/cli/import/keyboard.py b/lib/python/qmk/cli/import/keyboard.py
new file mode 100644
index 0000000000..3a5ed37dee
--- /dev/null
+++ b/lib/python/qmk/cli/import/keyboard.py
@@ -0,0 +1,23 @@
+from milc import cli
+
+from qmk.importers import import_keyboard as _import_keyboard
+from qmk.path import FileType
+from qmk.json_schema import json_load
+
+
+@cli.argument('filename', type=FileType('r'), nargs='+', arg_only=True, help='file')
+@cli.subcommand('Import data-driven keyboard')
+def import_keyboard(cli):
+ filename = cli.args.filename[0]
+
+ data = json_load(filename)
+
+ cli.log.info(f'{{style_bright}}Importing {filename.name}.{{style_normal}}')
+ cli.echo('')
+
+ kb_name = _import_keyboard(data)
+
+ cli.log.info(f'{{fg_green}}Imported a new keyboard named {{fg_cyan}}{kb_name}{{fg_green}}.{{fg_reset}}')
+ cli.log.info(f'To start working on things, `cd` into {{fg_cyan}}keyboards/{kb_name}{{fg_reset}},')
+ cli.log.info('or open the directory in your preferred text editor.')
+ cli.log.info(f"And build with {{fg_yellow}}qmk compile -kb {kb_name} -km default{{fg_reset}}.")
diff --git a/lib/python/qmk/cli/import/keymap.py b/lib/python/qmk/cli/import/keymap.py
new file mode 100644
index 0000000000..a499c93480
--- /dev/null
+++ b/lib/python/qmk/cli/import/keymap.py
@@ -0,0 +1,23 @@
+from milc import cli
+
+from qmk.importers import import_keymap as _import_keymap
+from qmk.path import FileType
+from qmk.json_schema import json_load
+
+
+@cli.argument('filename', type=FileType('r'), nargs='+', arg_only=True, help='file')
+@cli.subcommand('Import data-driven keymap')
+def import_keymap(cli):
+ filename = cli.args.filename[0]
+
+ data = json_load(filename)
+
+ cli.log.info(f'{{style_bright}}Importing {filename.name}.{{style_normal}}')
+ cli.echo('')
+
+ kb_name, km_name = _import_keymap(data)
+
+ cli.log.info(f'{{fg_green}}Imported a new keymap named {{fg_cyan}}{km_name}{{fg_green}}.{{fg_reset}}')
+ cli.log.info(f'To start working on things, `cd` into {{fg_cyan}}keyboards/{kb_name}/keymaps/{km_name}{{fg_reset}},')
+ cli.log.info('or open the directory in your preferred text editor.')
+ cli.log.info(f"And build with {{fg_yellow}}qmk compile -kb {kb_name} -km {km_name}{{fg_reset}}.")
diff --git a/lib/python/qmk/cli/lint.py b/lib/python/qmk/cli/lint.py
index af057b4110..6b077c250f 100644
--- a/lib/python/qmk/cli/lint.py
+++ b/lib/python/qmk/cli/lint.py
@@ -7,26 +7,43 @@ from milc import cli
from qmk.decorators import automagic_keyboard, automagic_keymap
from qmk.info import info_json
from qmk.keyboard import keyboard_completer, list_keyboards
-from qmk.keymap import locate_keymap
+from qmk.keymap import locate_keymap, list_keymaps
from qmk.path import is_keyboard, keyboard
+from qmk.git import git_get_ignored_files
-def keymap_check(kb, km):
- """Perform the keymap level checks.
+def _list_defaultish_keymaps(kb):
+ """Return default like keymaps for a given keyboard
"""
- ok = True
- keymap_path = locate_keymap(kb, km)
+ defaultish = ['ansi', 'iso', 'via']
- if not keymap_path:
+ keymaps = set()
+ for x in list_keymaps(kb):
+ if x in defaultish or x.startswith('default'):
+ keymaps.add(x)
+
+ return keymaps
+
+
+def _handle_json_errors(kb, info):
+ """Convert any json errors into lint errors
+ """
+ ok = True
+ # Check for errors in the json
+ if info['parse_errors']:
ok = False
- cli.log.error("%s: Can't find %s keymap.", kb, km)
+ cli.log.error(f'{kb}: Errors found when generating info.json.')
+ if cli.config.lint.strict and info['parse_warnings']:
+ ok = False
+ cli.log.error(f'{kb}: Warnings found when generating info.json (Strict mode enabled.)')
return ok
-def rules_mk_assignment_only(keyboard_path):
+def _rules_mk_assignment_only(kb):
"""Check the keyboard-level rules.mk to ensure it only has assignments.
"""
+ keyboard_path = keyboard(kb)
current_path = Path()
errors = []
@@ -58,10 +75,58 @@ def rules_mk_assignment_only(keyboard_path):
return errors
+def keymap_check(kb, km):
+ """Perform the keymap level checks.
+ """
+ ok = True
+ keymap_path = locate_keymap(kb, km)
+
+ if not keymap_path:
+ ok = False
+ cli.log.error("%s: Can't find %s keymap.", kb, km)
+ return ok
+
+ # Additional checks
+ invalid_files = git_get_ignored_files(keymap_path.parent.as_posix())
+ for file in invalid_files:
+ cli.log.error(f'{kb}/{km}: The file "{file}" should not exist!')
+ ok = False
+
+ return ok
+
+
+def keyboard_check(kb):
+ """Perform the keyboard level checks.
+ """
+ ok = True
+ kb_info = info_json(kb)
+
+ if not _handle_json_errors(kb, kb_info):
+ ok = False
+
+ # Additional checks
+ rules_mk_assignment_errors = _rules_mk_assignment_only(kb)
+ if rules_mk_assignment_errors:
+ ok = False
+ cli.log.error('%s: Non-assignment code found in rules.mk. Move it to post_rules.mk instead.', kb)
+ for assignment_error in rules_mk_assignment_errors:
+ cli.log.error(assignment_error)
+
+ invalid_files = git_get_ignored_files(f'keyboards/{kb}/')
+ for file in invalid_files:
+ if 'keymap' in file:
+ continue
+ cli.log.error(f'{kb}: The file "{file}" should not exist!')
+ ok = False
+
+ return ok
+
+
@cli.argument('--strict', action='store_true', help='Treat warnings as errors')
@cli.argument('-kb', '--keyboard', completer=keyboard_completer, help='Comma separated list of keyboards to check')
@cli.argument('-km', '--keymap', help='The keymap to check')
@cli.argument('--all-kb', action='store_true', arg_only=True, help='Check all keyboards')
+@cli.argument('--all-km', action='store_true', arg_only=True, help='Check all keymaps')
@cli.subcommand('Check keyboard and keymap for common mistakes.')
@automagic_keyboard
@automagic_keymap
@@ -73,7 +138,7 @@ def lint(cli):
# Determine our keyboard list
if cli.args.all_kb:
if cli.args.keyboard:
- cli.log.warning('Both --all-kb and --keyboard passed, --all-kb takes presidence.')
+ cli.log.warning('Both --all-kb and --keyboard passed, --all-kb takes precedence.')
keyboard_list = list_keyboards()
elif not cli.config.lint.keyboard:
@@ -89,38 +154,25 @@ def lint(cli):
cli.log.error('No such keyboard: %s', kb)
continue
- # Gather data about the keyboard.
- ok = True
- keyboard_path = keyboard(kb)
- keyboard_info = info_json(kb)
+ # Determine keymaps to also check
+ if cli.args.all_km:
+ keymaps = list_keymaps(kb)
+ elif cli.config.lint.keymap:
+ keymaps = {cli.config.lint.keymap}
+ else:
+ keymaps = _list_defaultish_keymaps(kb)
+ # Ensure that at least a 'default' keymap always exists
+ keymaps.add('default')
- # Check for errors in the info.json
- if keyboard_info['parse_errors']:
- ok = False
- cli.log.error('%s: Errors found when generating info.json.', kb)
-
- if cli.config.lint.strict and keyboard_info['parse_warnings']:
- ok = False
- cli.log.error('%s: Warnings found when generating info.json (Strict mode enabled.)', kb)
+ ok = True
- # Check the rules.mk file(s)
- rules_mk_assignment_errors = rules_mk_assignment_only(keyboard_path)
- if rules_mk_assignment_errors:
+ # keyboard level checks
+ if not keyboard_check(kb):
ok = False
- cli.log.error('%s: Non-assignment code found in rules.mk. Move it to post_rules.mk instead.', kb)
- for assignment_error in rules_mk_assignment_errors:
- cli.log.error(assignment_error)
# Keymap specific checks
- if cli.config.lint.keymap:
- if not keymap_check(kb, cli.config.lint.keymap):
- ok = False
-
- # Check if all non-data driven macros exist in <keyboard.h>
- for layout, data in keyboard_info['layouts'].items():
- # Matrix data should be a list with exactly two integers: [0, 1]
- if not data['c_macro'] and not all('matrix' in key_data.keys() or len(key_data) == 2 or all(isinstance(n, int) for n in key_data) for key_data in data['layout']):
- cli.log.error(f'{kb}: "{layout}" has no "matrix" definition in either "info.json" or "<keyboard>.h"!')
+ for keymap in keymaps:
+ if not keymap_check(kb, keymap):
ok = False
# Report status
diff --git a/lib/python/qmk/cli/multibuild.py b/lib/python/qmk/cli/multibuild.py
index dff8c88422..5e0f0b5188 100755
--- a/lib/python/qmk/cli/multibuild.py
+++ b/lib/python/qmk/cli/multibuild.py
@@ -28,6 +28,7 @@ def _is_split(keyboard_name):
return True if 'SPLIT_KEYBOARD' in rules_mk and rules_mk['SPLIT_KEYBOARD'].lower() == 'yes' else False
+@cli.argument('-t', '--no-temp', arg_only=True, action='store_true', help="Remove temporary files during build.")
@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.")
@cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.")
@cli.argument('-f', '--filter', arg_only=True, action='append', default=[], help="Filter the list of keyboards based on the supplied value in rules.mk. Supported format is 'SPLIT_KEYBOARD=yes'. May be passed multiple times.")
@@ -69,6 +70,7 @@ def multibuild(cli):
all: {keyboard_safe}_binary
{keyboard_safe}_binary:
@rm -f "{QMK_FIRMWARE}/.build/failed.log.{keyboard_safe}" || true
+ @echo "Compiling QMK Firmware for target: '{keyboard_name}:{cli.args.keymap}'..." >>"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}"
+@$(MAKE) -C "{QMK_FIRMWARE}" -f "{QMK_FIRMWARE}/builddefs/build_keyboard.mk" KEYBOARD="{keyboard_name}" KEYMAP="{cli.args.keymap}" REQUIRE_PLATFORM_KEY= COLOR=true SILENT=false {' '.join(cli.args.env)} \\
>>"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" 2>&1 \\
|| cp "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" "{QMK_FIRMWARE}/.build/failed.log.{os.getpid()}.{keyboard_safe}"
@@ -76,11 +78,26 @@ all: {keyboard_safe}_binary
|| {{ grep '\[WARNINGS\]' "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" >/dev/null 2>&1 && printf "Build %-64s \e[1;33m[WARNINGS]\e[0m\\n" "{keyboard_name}:{cli.args.keymap}" ; }} \\
|| printf "Build %-64s \e[1;32m[OK]\e[0m\\n" "{keyboard_name}:{cli.args.keymap}"
@rm -f "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" || true
-
"""# noqa
)
# yapf: enable
+ if cli.args.no_temp:
+ # yapf: disable
+ f.write(
+ f"""\
+ @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.elf" 2>/dev/null || true
+ @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.map" 2>/dev/null || true
+ @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.hex" 2>/dev/null || true
+ @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.bin" 2>/dev/null || true
+ @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.uf2" 2>/dev/null || true
+ @rm -rf "{QMK_FIRMWARE}/.build/obj_{keyboard_safe}" || true
+ @rm -rf "{QMK_FIRMWARE}/.build/obj_{keyboard_safe}_{cli.args.keymap}" || true
+"""# noqa
+ )
+ # yapf: enable
+ f.write('\n')
+
cli.run([make_cmd, *get_make_parallel_args(cli.args.parallel), '-f', makefile.as_posix(), 'all'], capture_output=False, stdin=DEVNULL)
# Check for failures
diff --git a/lib/python/qmk/constants.py b/lib/python/qmk/constants.py
index a54d9058bc..8a13029a8a 100644
--- a/lib/python/qmk/constants.py
+++ b/lib/python/qmk/constants.py
@@ -14,12 +14,13 @@ QMK_FIRMWARE_UPSTREAM = 'qmk/qmk_firmware'
MAX_KEYBOARD_SUBFOLDERS = 5
# Supported processor types
-CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK66FX1M0', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F405', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G431', 'STM32G474', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95'
+CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK64FX512', 'MK66FX1M0', 'RP2040', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F405', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G431', 'STM32G474', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95'
LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None
VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85'
# Bootloaders of the supported processors
MCU2BOOTLOADER = {
+ "RP2040": "rp2040",
"MKL26Z64": "halfkay",
"MK20DX128": "halfkay",
"MK20DX256": "halfkay",
@@ -58,6 +59,59 @@ MCU2BOOTLOADER = {
"atmega328": "usbasploader",
}
+# Map of legacy keycodes that can be automatically updated
+LEGACY_KEYCODES = { # Comment here is to force multiline formatting
+ 'RESET': 'QK_BOOT'
+}
+
+# Map VID:PID values to bootloaders
+BOOTLOADER_VIDS_PIDS = {
+ 'atmel-dfu': {
+ ("03eb", "2fef"), # ATmega16U2
+ ("03eb", "2ff0"), # ATmega32U2
+ ("03eb", "2ff3"), # ATmega16U4
+ ("03eb", "2ff4"), # ATmega32U4
+ ("03eb", "2ff9"), # AT90USB64
+ ("03eb", "2ffa"), # AT90USB162
+ ("03eb", "2ffb") # AT90USB128
+ },
+ 'kiibohd': {("1c11", "b007")},
+ 'stm32-dfu': {
+ ("1eaf", "0003"), # STM32duino
+ ("0483", "df11") # STM32 DFU
+ },
+ 'apm32-dfu': {("314b", "0106")},
+ 'gd32v-dfu': {("28e9", "0189")},
+ 'bootloadhid': {("16c0", "05df")},
+ 'usbasploader': {("16c0", "05dc")},
+ 'usbtinyisp': {("1782", "0c9f")},
+ 'md-boot': {("03eb", "6124")},
+ 'caterina': {
+ # pid.codes shared PID
+ ("1209", "2302"), # Keyboardio Atreus 2 Bootloader
+ # Spark Fun Electronics
+ ("1b4f", "9203"), # Pro Micro 3V3/8MHz
+ ("1b4f", "9205"), # Pro Micro 5V/16MHz
+ ("1b4f", "9207"), # LilyPad 3V3/8MHz (and some Pro Micro clones)
+ # Pololu Electronics
+ ("1ffb", "0101"), # A-Star 32U4
+ # Arduino SA
+ ("2341", "0036"), # Leonardo
+ ("2341", "0037"), # Micro
+ # Adafruit Industries LLC
+ ("239a", "000c"), # Feather 32U4
+ ("239a", "000d"), # ItsyBitsy 32U4 3V3/8MHz
+ ("239a", "000e"), # ItsyBitsy 32U4 5V/16MHz
+ # dog hunter AG
+ ("2a03", "0036"), # Leonardo
+ ("2a03", "0037") # Micro
+ },
+ 'hid-bootloader': {
+ ("03eb", "2067"), # QMK HID
+ ("16c0", "0478") # PJRC halfkay
+ }
+}
+
# Common format strings
DATE_FORMAT = '%Y-%m-%d'
DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S %Z'
@@ -67,13 +121,6 @@ TIME_FORMAT = '%H:%M:%S'
COL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijilmnopqrstuvwxyz'
ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop'
-# Mapping between info.json and config.h keys
-LED_INDICATORS = {
- 'caps_lock': 'LED_CAPS_LOCK_PIN',
- 'num_lock': 'LED_NUM_LOCK_PIN',
- 'scroll_lock': 'LED_SCROLL_LOCK_PIN',
-}
-
# Constants that should match their counterparts in make
BUILD_DIR = environ.get('BUILD_DIR', '.build')
KEYBOARD_OUTPUT_PREFIX = f'{BUILD_DIR}/obj_'
diff --git a/lib/python/qmk/flashers.py b/lib/python/qmk/flashers.py
new file mode 100644
index 0000000000..a9cf726b44
--- /dev/null
+++ b/lib/python/qmk/flashers.py
@@ -0,0 +1,203 @@
+import shutil
+import time
+import os
+import signal
+
+import usb.core
+
+from qmk.constants import BOOTLOADER_VIDS_PIDS
+from milc import cli
+
+# yapf: disable
+_PID_TO_MCU = {
+ '2fef': 'atmega16u2',
+ '2ff0': 'atmega32u2',
+ '2ff3': 'atmega16u4',
+ '2ff4': 'atmega32u4',
+ '2ff9': 'at90usb64',
+ '2ffa': 'at90usb162',
+ '2ffb': 'at90usb128'
+}
+
+AVRDUDE_MCU = {
+ 'atmega32a': 'm32',
+ 'atmega328p': 'm328p',
+ 'atmega328': 'm328',
+}
+# yapf: enable
+
+
+class DelayedKeyboardInterrupt:
+ # Custom interrupt handler to delay the processing of Ctrl-C
+ # https://stackoverflow.com/a/21919644
+ def __enter__(self):
+ self.signal_received = False
+ self.old_handler = signal.signal(signal.SIGINT, self.handler)
+
+ def handler(self, sig, frame):
+ self.signal_received = (sig, frame)
+
+ def __exit__(self, type, value, traceback):
+ signal.signal(signal.SIGINT, self.old_handler)
+ if self.signal_received:
+ self.old_handler(*self.signal_received)
+
+
+# TODO: Make this more generic, so cli/doctor/check.py and flashers.py can share the code
+def _check_dfu_programmer_version():
+ # Return True if version is higher than 0.7.0: supports '--force'
+ check = cli.run(['dfu-programmer', '--version'], combined_output=True, timeout=5)
+ first_line = check.stdout.split('\n')[0]
+ version_number = first_line.split()[1]
+ maj, min_, bug = version_number.split('.')
+ if int(maj) >= 0 and int(min_) >= 7:
+ return True
+ else:
+ return False
+
+
+def _find_bootloader():
+ # To avoid running forever in the background, only look for bootloaders for 10min
+ start_time = time.time()
+ while time.time() - start_time < 600:
+ for bl in BOOTLOADER_VIDS_PIDS:
+ for vid, pid in BOOTLOADER_VIDS_PIDS[bl]:
+ vid_hex = int(f'0x{vid}', 0)
+ pid_hex = int(f'0x{pid}', 0)
+ with DelayedKeyboardInterrupt():
+ # PyUSB does not like to be interrupted by Ctrl-C
+ # therefore we catch the interrupt with a custom handler
+ # and only process it once pyusb finished
+ dev = usb.core.find(idVendor=vid_hex, idProduct=pid_hex)
+ if dev:
+ if bl == 'atmel-dfu':
+ details = _PID_TO_MCU[pid]
+ elif bl == 'caterina':
+ details = (vid_hex, pid_hex)
+ elif bl == 'hid-bootloader':
+ if vid == '16c0' and pid == '0478':
+ details = 'halfkay'
+ else:
+ details = 'qmk-hid'
+ elif bl == 'stm32-dfu' or bl == 'apm32-dfu' or bl == 'gd32v-dfu' or bl == 'kiibohd':
+ details = (vid, pid)
+ else:
+ details = None
+ return (bl, details)
+ time.sleep(0.1)
+ return (None, None)
+
+
+def _find_serial_port(vid, pid):
+ if 'windows' in cli.platform.lower():
+ from serial.tools.list_ports_windows import comports
+ platform = 'windows'
+ else:
+ from serial.tools.list_ports_posix import comports
+ platform = 'posix'
+
+ start_time = time.time()
+ # Caterina times out after 8 seconds
+ while time.time() - start_time < 8:
+ for port in comports():
+ port, desc, hwid = port
+ if f'{vid:04x}:{pid:04x}' in hwid.casefold():
+ if platform == 'windows':
+ time.sleep(1)
+ return port
+ else:
+ start_time = time.time()
+ # Wait until the port becomes writable before returning
+ while time.time() - start_time < 8:
+ if os.access(port, os.W_OK):
+ return port
+ else:
+ time.sleep(0.5)
+ return None
+ return None
+
+
+def _flash_caterina(details, file):
+ port = _find_serial_port(details[0], details[1])
+ if port:
+ cli.run(['avrdude', '-p', 'atmega32u4', '-c', 'avr109', '-U', f'flash:w:{file}:i', '-P', port], capture_output=False)
+ return False
+ else:
+ return True
+
+
+def _flash_atmel_dfu(mcu, file):
+ force = '--force' if _check_dfu_programmer_version() else ''
+ cli.run(['dfu-programmer', mcu, 'erase', force], capture_output=False)
+ cli.run(['dfu-programmer', mcu, 'flash', force, file], capture_output=False)
+ cli.run(['dfu-programmer', mcu, 'reset'], capture_output=False)
+
+
+def _flash_hid_bootloader(mcu, details, file):
+ if details == 'halfkay':
+ if shutil.which('teensy-loader-cli'):
+ cmd = 'teensy-loader-cli'
+ elif shutil.which('teensy_loader_cli'):
+ cmd = 'teensy_loader_cli'
+
+ # Use 'hid_bootloader_cli' for QMK HID and as a fallback for HalfKay
+ if not cmd:
+ if shutil.which('hid_bootloader_cli'):
+ cmd = 'hid_bootloader_cli'
+ else:
+ return True
+
+ cli.run([cmd, f'-mmcu={mcu}', '-w', '-v', file], capture_output=False)
+
+
+def _flash_dfu_util(details, file):
+ # STM32duino
+ if details[0] == '1eaf' and details[1] == '0003':
+ cli.run(['dfu-util', '-a', '2', '-d', f'{details[0]}:{details[1]}', '-R', '-D', file], capture_output=False)
+ # kiibohd
+ elif details[0] == '1c11' and details[1] == 'b007':
+ cli.run(['dfu-util', '-a', '0', '-d', f'{details[0]}:{details[1]}', '-D', file], capture_output=False)
+ # STM32, APM32, or GD32V DFU
+ else:
+ cli.run(['dfu-util', '-a', '0', '-d', f'{details[0]}:{details[1]}', '-s', '0x08000000:leave', '-D', file], capture_output=False)
+
+
+def _flash_isp(mcu, programmer, file):
+ programmer = 'usbasp' if programmer == 'usbasploader' else 'usbtiny'
+ # Check if the provide mcu has an avrdude-specific name, otherwise pass on what the user provided
+ mcu = AVRDUDE_MCU.get(mcu, mcu)
+ cli.run(['avrdude', '-p', mcu, '-c', programmer, '-U', f'flash:w:{file}:i'], capture_output=False)
+
+
+def _flash_mdloader(file):
+ cli.run(['mdloader', '--first', '--download', file, '--restart'], capture_output=False)
+
+
+def flasher(mcu, file):
+ bl, details = _find_bootloader()
+ # Add a small sleep to avoid race conditions
+ time.sleep(1)
+ if bl == 'atmel-dfu':
+ _flash_atmel_dfu(details, file.name)
+ elif bl == 'caterina':
+ if _flash_caterina(details, file.name):
+ return (True, "The Caterina bootloader was found but is not writable. Check 'qmk doctor' output for advice.")
+ elif bl == 'hid-bootloader':
+ if mcu:
+ if _flash_hid_bootloader(mcu, details, file.name):
+ return (True, "Please make sure 'teensy_loader_cli' or 'hid_bootloader_cli' is available on your system.")
+ else:
+ return (True, "Specifying the MCU with '-m' is necessary for HalfKay/HID bootloaders!")
+ elif bl == 'stm32-dfu' or bl == 'apm32-dfu' or bl == 'gd32v-dfu' or bl == 'kiibohd':
+ _flash_dfu_util(details, file.name)
+ elif bl == 'usbasploader' or bl == 'usbtinyisp':
+ if mcu:
+ _flash_isp(mcu, bl, file.name)
+ else:
+ return (True, "Specifying the MCU with '-m' is necessary for ISP flashing!")
+ elif bl == 'md-boot':
+ _flash_mdloader(file.name)
+ else:
+ return (True, "Known bootloader found but flashing not currently supported!")
+
+ return (False, None)
diff --git a/lib/python/qmk/git.py b/lib/python/qmk/git.py
index beeb689144..7fa0306f5c 100644
--- a/lib/python/qmk/git.py
+++ b/lib/python/qmk/git.py
@@ -62,6 +62,25 @@ def git_get_tag():
return git_tag.stdout.strip()
+def git_get_last_log_entry(branch_name):
+ """Retrieves the last log entry for the branch being worked on.
+ """
+ git_lastlog = cli.run(['git', '--no-pager', 'log', '--pretty=format:%ad (%h) -- %s', '--date=iso', '-n1', branch_name])
+
+ if git_lastlog.returncode == 0 and git_lastlog.stdout:
+ return git_lastlog.stdout.strip()
+
+
+def git_get_common_ancestor(branch_a, branch_b):
+ """Retrieves the common ancestor between for the two supplied branches.
+ """
+ git_merge_base = cli.run(['git', 'merge-base', branch_a, branch_b])
+ git_branchpoint_log = cli.run(['git', '--no-pager', 'log', '--pretty=format:%ad (%h) -- %s', '--date=iso', '-n1', git_merge_base.stdout.strip()])
+
+ if git_branchpoint_log.returncode == 0 and git_branchpoint_log.stdout:
+ return git_branchpoint_log.stdout.strip()
+
+
def git_get_remotes():
"""Returns the current remotes for a repo.
"""
@@ -108,3 +127,12 @@ def git_check_deviation(active_branch):
cli.run(['git', 'fetch', 'upstream', active_branch])
deviations = cli.run(['git', '--no-pager', 'log', f'upstream/{active_branch}...{active_branch}'])
return bool(deviations.returncode)
+
+
+def git_get_ignored_files(check_dir='.'):
+ """Return a list of files that would be captured by the current .gitignore
+ """
+ invalid = cli.run(['git', 'ls-files', '-c', '-o', '-i', '--exclude-from=.gitignore', check_dir])
+ if invalid.returncode != 0:
+ return []
+ return invalid.stdout.strip().splitlines()
diff --git a/lib/python/qmk/importers.py b/lib/python/qmk/importers.py
new file mode 100644
index 0000000000..307c66ee3c
--- /dev/null
+++ b/lib/python/qmk/importers.py
@@ -0,0 +1,193 @@
+from dotty_dict import dotty
+from datetime import date
+from pathlib import Path
+import json
+
+from qmk.git import git_get_username
+from qmk.json_schema import validate
+from qmk.path import keyboard, keymap
+from qmk.constants import MCU2BOOTLOADER, LEGACY_KEYCODES
+from qmk.json_encoders import InfoJSONEncoder, KeymapJSONEncoder
+from qmk.json_schema import deep_update, json_load
+
+TEMPLATE = Path('data/templates/keyboard/')
+
+
+def replace_placeholders(src, dest, tokens):
+ """Replaces the given placeholders in each template file.
+ """
+ content = src.read_text()
+ for key, value in tokens.items():
+ content = content.replace(f'%{key}%', value)
+
+ dest.write_text(content)
+
+
+def _gen_dummy_keymap(name, info_data):
+ # Pick the first layout macro and just dump in KC_NOs or something?
+ (layout_name, layout_data), *_ = info_data["layouts"].items()
+ layout_length = len(layout_data["layout"])
+
+ keymap_data = {
+ "keyboard": name,
+ "layout": layout_name,
+ "layers": [["KC_NO" for _ in range(0, layout_length)]],
+ }
+
+ return keymap_data
+
+
+def _extract_kbfirmware_layout(kbf_data):
+ layout = []
+ for key in kbf_data['keyboard.keys']:
+ item = {
+ 'matrix': [key['row'], key['col']],
+ 'x': key['state']['x'],
+ 'y': key['state']['y'],
+ }
+ if key['state']['w'] != 1:
+ item['w'] = key['state']['w']
+ if key['state']['h'] != 1:
+ item['h'] = key['state']['h']
+ layout.append(item)
+
+ return layout
+
+
+def _extract_kbfirmware_keymap(kbf_data):
+ keymap_data = {
+ 'keyboard': kbf_data['keyboard.settings.name'].lower(),
+ 'layout': 'LAYOUT',
+ 'layers': [],
+ }
+
+ for i in range(15):
+ layer = []
+ for key in kbf_data['keyboard.keys']:
+ keycode = key['keycodes'][i]['id']
+ keycode = LEGACY_KEYCODES.get(keycode, keycode)
+ if '()' in keycode:
+ fields = key['keycodes'][i]['fields']
+ keycode = f'{keycode.split(")")[0]}{",".join(map(str, fields))})'
+ layer.append(keycode)
+ if set(layer) == {'KC_TRNS'}:
+ break
+ keymap_data['layers'].append(layer)
+
+ return keymap_data
+
+
+def import_keymap(keymap_data):
+ # Validate to ensure we don't have to deal with bad data - handles stdin/file
+ validate(keymap_data, 'qmk.keymap.v1')
+
+ kb_name = keymap_data['keyboard']
+ km_name = keymap_data['keymap']
+
+ km_folder = keymap(kb_name) / km_name
+ keyboard_keymap = km_folder / 'keymap.json'
+
+ # This is the deepest folder in the expected tree
+ keyboard_keymap.parent.mkdir(parents=True, exist_ok=True)
+
+ # Dump out all those lovely files
+ keyboard_keymap.write_text(json.dumps(keymap_data, cls=KeymapJSONEncoder))
+
+ return (kb_name, km_name)
+
+
+def import_keyboard(info_data, keymap_data=None):
+ # Validate to ensure we don't have to deal with bad data - handles stdin/file
+ validate(info_data, 'qmk.api.keyboard.v1')
+
+ # And validate some more as everything is optional
+ if not all(key in info_data for key in ['keyboard_name', 'layouts']):
+ raise ValueError('invalid info.json')
+
+ kb_name = info_data['keyboard_name']
+
+ # bail
+ kb_folder = keyboard(kb_name)
+ if kb_folder.exists():
+ raise ValueError(f'Keyboard {{fg_cyan}}{kb_name}{{fg_reset}} already exists! Please choose a different name.')
+
+ if not keymap_data:
+ # TODO: if supports community then grab that instead
+ keymap_data = _gen_dummy_keymap(kb_name, info_data)
+
+ keyboard_info = kb_folder / 'info.json'
+ keyboard_keymap = kb_folder / 'keymaps' / 'default' / 'keymap.json'
+
+ # begin with making the deepest folder in the tree
+ keyboard_keymap.parent.mkdir(parents=True, exist_ok=True)
+
+ user_name = git_get_username()
+ if not user_name:
+ user_name = 'TODO'
+
+ tokens = { # Comment here is to force multiline formatting
+ 'YEAR': str(date.today().year),
+ 'KEYBOARD': kb_name,
+ 'USER_NAME': user_name,
+ 'REAL_NAME': user_name,
+ }
+
+ # Dump out all those lovely files
+ for file in list(TEMPLATE.iterdir()):
+ replace_placeholders(file, kb_folder / file.name, tokens)
+
+ temp = json_load(keyboard_info)
+ deep_update(temp, info_data)
+
+ keyboard_info.write_text(json.dumps(temp, cls=InfoJSONEncoder))
+ keyboard_keymap.write_text(json.dumps(keymap_data, cls=KeymapJSONEncoder))
+
+ return kb_name
+
+
+def import_kbfirmware(kbfirmware_data):
+ kbf_data = dotty(kbfirmware_data)
+
+ diode_direction = ["COL2ROW", "ROW2COL"][kbf_data['keyboard.settings.diodeDirection']]
+ mcu = ["atmega32u2", "atmega32u4", "at90usb1286"][kbf_data['keyboard.controller']]
+ bootloader = MCU2BOOTLOADER.get(mcu, "custom")
+
+ layout = _extract_kbfirmware_layout(kbf_data)
+ keymap_data = _extract_kbfirmware_keymap(kbf_data)
+
+ # convert to d/d info.json
+ info_data = dotty({
+ "keyboard_name": kbf_data['keyboard.settings.name'].lower(),
+ "processor": mcu,
+ "bootloader": bootloader,
+ "diode_direction": diode_direction,
+ "matrix_pins": {
+ "cols": kbf_data['keyboard.pins.col'],
+ "rows": kbf_data['keyboard.pins.row'],
+ },
+ "layouts": {
+ "LAYOUT": {
+ "layout": layout,
+ }
+ }
+ })
+
+ if kbf_data['keyboard.pins.num'] or kbf_data['keyboard.pins.caps'] or kbf_data['keyboard.pins.scroll']:
+ if kbf_data['keyboard.pins.num']:
+ info_data['indicators.num_lock'] = kbf_data['keyboard.pins.num']
+ if kbf_data['keyboard.pins.caps']:
+ info_data['indicators.caps_lock'] = kbf_data['keyboard.pins.caps']
+ if kbf_data['keyboard.pins.scroll']:
+ info_data['indicators.scroll_lock'] = kbf_data['keyboard.pins.scroll']
+
+ if kbf_data['keyboard.pins.rgb']:
+ info_data['rgblight.animations.all'] = True
+ info_data['rgblight.led_count'] = kbf_data['keyboard.settings.rgbNum']
+ info_data['rgblight.pin'] = kbf_data['keyboard.pins.rgb']
+
+ if kbf_data['keyboard.pins.led']:
+ info_data['backlight.levels'] = kbf_data['keyboard.settings.backlightLevels']
+ info_data['backlight.pin'] = kbf_data['keyboard.pins.led']
+
+ # delegate as if it were a regular keyboard import
+ return import_keyboard(info_data.to_dict(), keymap_data)
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py
index 0763433b3d..7460d84ad3 100644
--- a/lib/python/qmk/info.py
+++ b/lib/python/qmk/info.py
@@ -26,13 +26,6 @@ def _valid_community_layout(layout):
return (Path('layouts/default') / layout).exists()
-def _remove_newlines_from_labels(layouts):
- for layout_name, layout_json in layouts.items():
- for key in layout_json['layout']:
- if '\n' in key['label']:
- key['label'] = key['label'].split('\n')[0]
-
-
def info_json(keyboard):
"""Generate the info.json data for a specific keyboard.
"""
@@ -111,23 +104,13 @@ def info_json(keyboard):
# Check that the reported matrix size is consistent with the actual matrix size
_check_matrix(info_data)
- # Remove newline characters from layout labels
- _remove_newlines_from_labels(layouts)
-
return info_data
def _extract_features(info_data, rules):
"""Find all the features enabled in rules.mk.
"""
- # Special handling for bootmagic which also supports a "lite" mode.
- if rules.get('BOOTMAGIC_ENABLE') == 'lite':
- rules['BOOTMAGIC_LITE_ENABLE'] = 'on'
- del rules['BOOTMAGIC_ENABLE']
- if rules.get('BOOTMAGIC_ENABLE') == 'full':
- rules['BOOTMAGIC_ENABLE'] = 'on'
-
- # Process the rest of the rules as booleans
+ # Process booleans rules
for key, value in rules.items():
if key.endswith('_ENABLE'):
key = '_'.join(key.split('_')[:-1]).lower()
@@ -228,6 +211,66 @@ def _extract_audio(info_data, config_c):
info_data['audio'] = {'pins': audio_pins}
+def _extract_encoders_values(config_c, postfix=''):
+ """Common encoder extraction logic
+ """
+ a_pad = config_c.get(f'ENCODERS_PAD_A{postfix}', '').replace(' ', '')[1:-1]
+ b_pad = config_c.get(f'ENCODERS_PAD_B{postfix}', '').replace(' ', '')[1:-1]
+ resolutions = config_c.get(f'ENCODER_RESOLUTIONS{postfix}', '').replace(' ', '')[1:-1]
+
+ default_resolution = config_c.get('ENCODER_RESOLUTION', None)
+
+ if a_pad and b_pad:
+ a_pad = list(filter(None, a_pad.split(',')))
+ b_pad = list(filter(None, b_pad.split(',')))
+ resolutions = list(filter(None, resolutions.split(',')))
+ if default_resolution:
+ resolutions += [default_resolution] * (len(a_pad) - len(resolutions))
+
+ encoders = []
+ for index in range(len(a_pad)):
+ encoder = {'pin_a': a_pad[index], 'pin_b': b_pad[index]}
+ if index < len(resolutions):
+ encoder['resolution'] = int(resolutions[index])
+ encoders.append(encoder)
+
+ return encoders
+
+
+def _extract_encoders(info_data, config_c):
+ """Populate data about encoder pins
+ """
+ encoders = _extract_encoders_values(config_c)
+ if encoders:
+ if 'encoder' not in info_data:
+ info_data['encoder'] = {}
+
+ if 'rotary' in info_data['encoder']:
+ _log_warning(info_data, 'Encoder config is specified in both config.h and info.json (encoder.rotary) (Value: %s), the config.h value wins.' % info_data['encoder']['rotary'])
+
+ info_data['encoder']['rotary'] = encoders
+
+
+def _extract_split_encoders(info_data, config_c):
+ """Populate data about split encoder pins
+ """
+ encoders = _extract_encoders_values(config_c, '_RIGHT')
+ if encoders:
+ if 'split' not in info_data:
+ info_data['split'] = {}
+
+ if 'encoder' not in info_data['split']:
+ info_data['split']['encoder'] = {}
+
+ if 'right' not in info_data['split']['encoder']:
+ info_data['split']['encoder']['right'] = {}
+
+ if 'rotary' in info_data['split']['encoder']['right']:
+ _log_warning(info_data, 'Encoder config is specified in both config.h and info.json (encoder.rotary) (Value: %s), the config.h value wins.' % info_data['split']['encoder']['right']['rotary'])
+
+ info_data['split']['encoder']['right']['rotary'] = encoders
+
+
def _extract_secure_unlock(info_data, config_c):
"""Populate data about the secure unlock sequence
"""
@@ -324,12 +367,10 @@ def _extract_split_right_pins(info_data, config_c):
# Figure out the right half matrix pins
row_pins = config_c.get('MATRIX_ROW_PINS_RIGHT', '').replace('{', '').replace('}', '').strip()
col_pins = config_c.get('MATRIX_COL_PINS_RIGHT', '').replace('{', '').replace('}', '').strip()
- unused_pin_text = config_c.get('UNUSED_PINS_RIGHT')
- unused_pins = unused_pin_text.replace('{', '').replace('}', '').strip() if isinstance(unused_pin_text, str) else None
direct_pins = config_c.get('DIRECT_PINS_RIGHT', '').replace(' ', '')[1:-1]
- if row_pins and col_pins:
- if info_data.get('split', {}).get('matrix_pins', {}).get('right') in info_data:
+ if row_pins or col_pins or direct_pins:
+ if info_data.get('split', {}).get('matrix_pins', {}).get('right', None):
_log_warning(info_data, 'Right hand matrix data is specified in both info.json and config.h, the config.h values win.')
if 'split' not in info_data:
@@ -341,37 +382,14 @@ def _extract_split_right_pins(info_data, config_c):
if 'right' not in info_data['split']['matrix_pins']:
info_data['split']['matrix_pins']['right'] = {}
- info_data['split']['matrix_pins']['right'] = {
- 'cols': _extract_pins(col_pins),
- 'rows': _extract_pins(row_pins),
- }
+ if col_pins:
+ info_data['split']['matrix_pins']['right']['cols'] = _extract_pins(col_pins)
- if direct_pins:
- if info_data.get('split', {}).get('matrix_pins', {}).get('right', {}):
- _log_warning(info_data, 'Right hand matrix data is specified in both info.json and config.h, the config.h values win.')
+ if row_pins:
+ info_data['split']['matrix_pins']['right']['rows'] = _extract_pins(row_pins)
- if 'split' not in info_data:
- info_data['split'] = {}
-
- if 'matrix_pins' not in info_data['split']:
- info_data['split']['matrix_pins'] = {}
-
- if 'right' not in info_data['split']['matrix_pins']:
- info_data['split']['matrix_pins']['right'] = {}
-
- info_data['split']['matrix_pins']['right']['direct'] = _extract_direct_matrix(direct_pins)
-
- if unused_pins:
- if 'split' not in info_data:
- info_data['split'] = {}
-
- if 'matrix_pins' not in info_data['split']:
- info_data['split']['matrix_pins'] = {}
-
- if 'right' not in info_data['split']['matrix_pins']:
- info_data['split']['matrix_pins']['right'] = {}
-
- info_data['split']['matrix_pins']['right']['unused'] = _extract_pins(unused_pins)
+ if direct_pins:
+ info_data['split']['matrix_pins']['right']['direct'] = _extract_direct_matrix(direct_pins)
def _extract_matrix_info(info_data, config_c):
@@ -379,8 +397,6 @@ def _extract_matrix_info(info_data, config_c):
"""
row_pins = config_c.get('MATRIX_ROW_PINS', '').replace('{', '').replace('}', '').strip()
col_pins = config_c.get('MATRIX_COL_PINS', '').replace('{', '').replace('}', '').strip()
- unused_pin_text = config_c.get('UNUSED_PINS')
- unused_pins = unused_pin_text.replace('{', '').replace('}', '').strip() if isinstance(unused_pin_text, str) else None
direct_pins = config_c.get('DIRECT_PINS', '').replace(' ', '')[1:-1]
info_snippet = {}
@@ -406,12 +422,6 @@ def _extract_matrix_info(info_data, config_c):
info_snippet['direct'] = _extract_direct_matrix(direct_pins)
- if unused_pins:
- if 'matrix_pins' not in info_data:
- info_data['matrix_pins'] = {}
-
- info_snippet['unused'] = _extract_pins(unused_pins)
-
if config_c.get('CUSTOM_MATRIX', 'no') != 'no':
if 'matrix_pins' in info_data and 'custom' in info_data['matrix_pins']:
_log_warning(info_data, 'Custom Matrix is specified in both info.json and config.h, the config.h values win.')
@@ -440,6 +450,47 @@ def _extract_device_version(info_data):
info_data['usb']['device_version'] = f'{major}.{minor}.{revision}'
+def _config_to_json(key_type, config_value):
+ """Convert config value using spec
+ """
+ if key_type.startswith('array'):
+ if '.' in key_type:
+ key_type, array_type = key_type.split('.', 1)
+ else:
+ array_type = None
+
+ config_value = config_value.replace('{', '').replace('}', '').strip()
+
+ if array_type == 'int':
+ return list(map(int, config_value.split(',')))
+ else:
+ return config_value.split(',')
+
+ elif key_type == 'bool':
+ return config_value in true_values
+
+ elif key_type == 'hex':
+ return '0x' + config_value[2:].upper()
+
+ elif key_type == 'list':
+ return config_value.split()
+
+ elif key_type == 'int':
+ return int(config_value)
+
+ elif key_type == 'str':
+ return config_value.strip('"')
+
+ elif key_type == 'bcd_version':
+ major = int(config_value[2:4])
+ minor = int(config_value[4])
+ revision = int(config_value[5])
+
+ return f'{major}.{minor}.{revision}'
+
+ return config_value
+
+
def _extract_config_h(info_data, config_c):
"""Pull some keyboard information from existing config.h files
"""
@@ -452,47 +503,23 @@ def _extract_config_h(info_data, config_c):
key_type = info_dict.get('value_type', 'raw')
try:
+ replace_with = info_dict.get('replace_with')
+ if config_key in config_c and info_dict.get('invalid', False):
+ if replace_with:
+ _log_error(info_data, '%s in config.h is no longer a valid option and should be replaced with %s' % (config_key, replace_with))
+ else:
+ _log_error(info_data, '%s in config.h is no longer a valid option and should be removed' % config_key)
+ elif config_key in config_c and info_dict.get('deprecated', False):
+ if replace_with:
+ _log_warning(info_data, '%s in config.h is deprecated in favor of %s and will be removed at a later date' % (config_key, replace_with))
+ else:
+ _log_warning(info_data, '%s in config.h is deprecated and will be removed at a later date' % config_key)
+
if config_key in config_c and info_dict.get('to_json', True):
if dotty_info.get(info_key) and info_dict.get('warn_duplicate', True):
_log_warning(info_data, '%s in config.h is overwriting %s in info.json' % (config_key, info_key))
- if key_type.startswith('array'):
- if '.' in key_type:
- key_type, array_type = key_type.split('.', 1)
- else:
- array_type = None
-
- config_value = config_c[config_key].replace('{', '').replace('}', '').strip()
-
- if array_type == 'int':
- dotty_info[info_key] = list(map(int, config_value.split(',')))
- else:
- dotty_info[info_key] = config_value.split(',')
-
- elif key_type == 'bool':
- dotty_info[info_key] = config_c[config_key] in true_values
-
- elif key_type == 'hex':
- dotty_info[info_key] = '0x' + config_c[config_key][2:].upper()
-
- elif key_type == 'list':
- dotty_info[info_key] = config_c[config_key].split()
-
- elif key_type == 'int':
- dotty_info[info_key] = int(config_c[config_key])
-
- elif key_type == 'str':
- dotty_info[info_key] = config_c[config_key].strip('"')
-
- elif key_type == 'bcd_version':
- major = int(config_c[config_key][2:4])
- minor = int(config_c[config_key][4])
- revision = int(config_c[config_key][5])
-
- dotty_info[info_key] = f'{major}.{minor}.{revision}'
-
- else:
- dotty_info[info_key] = config_c[config_key]
+ dotty_info[info_key] = _config_to_json(key_type, config_c[config_key])
except Exception as e:
_log_warning(info_data, f'{config_key}->{info_key}: {e}')
@@ -506,6 +533,8 @@ def _extract_config_h(info_data, config_c):
_extract_split_main(info_data, config_c)
_extract_split_transport(info_data, config_c)
_extract_split_right_pins(info_data, config_c)
+ _extract_encoders(info_data, config_c)
+ _extract_split_encoders(info_data, config_c)
_extract_device_version(info_data)
return info_data
@@ -547,40 +576,23 @@ def _extract_rules_mk(info_data, rules):
key_type = info_dict.get('value_type', 'raw')
try:
+ replace_with = info_dict.get('replace_with')
+ if rules_key in rules and info_dict.get('invalid', False):
+ if replace_with:
+ _log_error(info_data, '%s in rules.mk is no longer a valid option and should be replaced with %s' % (rules_key, replace_with))
+ else:
+ _log_error(info_data, '%s in rules.mk is no longer a valid option and should be removed' % rules_key)
+ elif rules_key in rules and info_dict.get('deprecated', False):
+ if replace_with:
+ _log_warning(info_data, '%s in rules.mk is deprecated in favor of %s and will be removed at a later date' % (rules_key, replace_with))
+ else:
+ _log_warning(info_data, '%s in rules.mk is deprecated and will be removed at a later date' % rules_key)
+
if rules_key in rules and info_dict.get('to_json', True):
if dotty_info.get(info_key) and info_dict.get('warn_duplicate', True):
_log_warning(info_data, '%s in rules.mk is overwriting %s in info.json' % (rules_key, info_key))
- if key_type.startswith('array'):
- if '.' in key_type:
- key_type, array_type = key_type.split('.', 1)
- else:
- array_type = None
-
- rules_value = rules[rules_key].replace('{', '').replace('}', '').strip()
-
- if array_type == 'int':
- dotty_info[info_key] = list(map(int, rules_value.split(',')))
- else:
- dotty_info[info_key] = rules_value.split(',')
-
- elif key_type == 'list':
- dotty_info[info_key] = rules[rules_key].split()
-
- elif key_type == 'bool':
- dotty_info[info_key] = rules[rules_key] in true_values
-
- elif key_type == 'hex':
- dotty_info[info_key] = '0x' + rules[rules_key][2:].upper()
-
- elif key_type == 'int':
- dotty_info[info_key] = int(rules[rules_key])
-
- elif key_type == 'str':
- dotty_info[info_key] = rules[rules_key].strip('"')
-
- else:
- dotty_info[info_key] = rules[rules_key]
+ dotty_info[info_key] = _config_to_json(key_type, rules[rules_key])
except Exception as e:
_log_warning(info_data, f'{rules_key}->{info_key}: {e}')
@@ -821,8 +833,11 @@ def merge_info_jsons(keyboard, info_data):
for new_key, existing_key in zip(layout['layout'], info_data['layouts'][layout_name]['layout']):
existing_key.update(new_key)
else:
- layout['c_macro'] = False
- info_data['layouts'][layout_name] = layout
+ if not all('matrix' in key_data.keys() for key_data in layout['layout']):
+ _log_error(info_data, f'Layout "{layout_name}" has no "matrix" definition in either "info.json" or "<keyboard>.h"!')
+ else:
+ layout['c_macro'] = False
+ info_data['layouts'][layout_name] = layout
# Update info_data with the new data
if 'layouts' in new_info_data:
diff --git a/lib/python/qmk/json_schema.py b/lib/python/qmk/json_schema.py
index 682346113e..01175146b5 100644
--- a/lib/python/qmk/json_schema.py
+++ b/lib/python/qmk/json_schema.py
@@ -68,11 +68,7 @@ def create_validator(schema):
schema_store = compile_schema_store()
resolver = jsonschema.RefResolver.from_schema(schema_store[schema], store=schema_store)
- # TODO: Remove this after the jsonschema>=4 requirement had time to reach users
- try:
- return jsonschema.Draft202012Validator(schema_store[schema], resolver=resolver).validate
- except AttributeError:
- return jsonschema.Draft7Validator(schema_store[schema], resolver=resolver).validate
+ return jsonschema.Draft202012Validator(schema_store[schema], resolver=resolver).validate
def validate(data, schema):
diff --git a/lib/python/qmk/keyboard.py b/lib/python/qmk/keyboard.py
index e69f63aebe..686d4fc403 100644
--- a/lib/python/qmk/keyboard.py
+++ b/lib/python/qmk/keyboard.py
@@ -103,7 +103,7 @@ def list_keyboards():
"""
# We avoid pathlib here because this is performance critical code.
kb_wildcard = os.path.join(base_path, "**", "rules.mk")
- paths = [path for path in glob(kb_wildcard, recursive=True) if 'keymaps' not in path]
+ paths = [path for path in glob(kb_wildcard, recursive=True) if os.path.sep + 'keymaps' + os.path.sep not in path]
return sorted(set(map(resolve_keyboard, map(_find_name, paths))))
diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py
index ca5be0959b..f317f4d11e 100644
--- a/lib/python/qmk/keymap.py
+++ b/lib/python/qmk/keymap.py
@@ -12,7 +12,7 @@ from pygments.token import Token
from pygments import lex
import qmk.path
-from qmk.keyboard import find_keyboard_from_dir, rules_mk
+from qmk.keyboard import find_keyboard_from_dir, rules_mk, keyboard_folder
from qmk.errors import CppError
# The `keymap.c` template to use when a keyboard doesn't have its own
@@ -357,7 +357,7 @@ def locate_keymap(keyboard, keymap):
checked_dirs = ''
keymap_path = ''
- for dir in keyboard.split('/'):
+ for dir in keyboard_folder(keyboard).split('/'):
if checked_dirs:
checked_dirs = '/'.join((checked_dirs, dir))
else:
diff --git a/lib/python/qmk/submodules.py b/lib/python/qmk/submodules.py
index 6a272dae50..52efa602a0 100644
--- a/lib/python/qmk/submodules.py
+++ b/lib/python/qmk/submodules.py
@@ -11,7 +11,11 @@ def status():
{
'name': 'submodule_name',
'status': None/False/True,
- 'githash': '<sha-1 hash for the submodule>
+ 'githash': '<sha-1 hash for the submodule>'
+ 'shorthash': '<short hash for the submodule>'
+ 'describe': '<output of `git describe --tags`>'
+ 'last_log_message': 'log message'
+ 'last_log_timestamp': 'timestamp'
}
status is None when the submodule doesn't exist, False when it's out of date, and True when it's current
@@ -36,6 +40,26 @@ def status():
else:
raise ValueError('Unknown `git submodule status` sha-1 prefix character: "%s"' % status)
+ submodule_logs = cli.run(['git', 'submodule', '-q', 'foreach', 'git --no-pager log --pretty=format:"$sm_path%x01%h%x01%ad%x01%s%x0A" --date=iso -n1'])
+ for log_line in submodule_logs.stdout.split('\n'):
+ if not log_line:
+ continue
+
+ r = log_line.split('\x01')
+ submodule = r[0]
+ submodules[submodule]['shorthash'] = r[1] if len(r) > 1 else ''
+ submodules[submodule]['last_log_timestamp'] = r[2] if len(r) > 2 else ''
+ submodules[submodule]['last_log_message'] = r[3] if len(r) > 3 else ''
+
+ submodule_tags = cli.run(['git', 'submodule', '-q', 'foreach', '\'echo $sm_path `git describe --tags`\''])
+ for log_line in submodule_tags.stdout.split('\n'):
+ if not log_line:
+ continue
+
+ r = log_line.split()
+ submodule = r[0]
+ submodules[submodule]['describe'] = r[1] if len(r) > 1 else ''
+
return submodules
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py
index 71830ce194..2f3d09723f 100644
--- a/lib/python/qmk/tests/test_cli_commands.py
+++ b/lib/python/qmk/tests/test_cli_commands.py
@@ -97,13 +97,15 @@ def test_list_keyboards():
def test_list_keymaps():
result = check_subcommand('list-keymaps', '-kb', 'handwired/pytest/basic')
check_returncode(result)
- assert 'default' and 'default_json' in result.stdout
+ assert 'default' in result.stdout
+ assert 'default_json' in result.stdout
def test_list_keymaps_long():
result = check_subcommand('list-keymaps', '--keyboard', 'handwired/pytest/basic')
check_returncode(result)
- assert 'default' and 'default_json' in result.stdout
+ assert 'default' in result.stdout
+ assert 'default_json' in result.stdout
def test_list_keymaps_community():
@@ -113,25 +115,24 @@ def test_list_keymaps_community():
def test_list_keymaps_kb_only():
-<<<<<<< HEAD
result = check_subcommand('list-keymaps', '-kb', 'moonlander')
-=======
- result = check_subcommand('list-keymaps', '-kb', 'contra')
->>>>>>> qmk/master
check_returncode(result)
- assert 'default' and 'oyrx' and 'webusb' in result.stdout
+ assert 'default' in result.stdout
+ assert 'oryx' in result.stdout
def test_list_keymaps_vendor_kb():
result = check_subcommand('list-keymaps', '-kb', 'planck/ez')
check_returncode(result)
- assert 'default' and 'oryx' and 'webusb' in result.stdout
+ assert 'default' in result.stdout
+ assert 'oryx' in result.stdout
-# def test_list_keymaps_vendor_kb_rev():
-# result = check_subcommand('list-keymaps', '-kb', 'kbdfans/kbd67/mkiirgb/v2')
-# check_returncode(result)
-# assert 'default' and 'via' in result.stdout
+def test_list_keymaps_vendor_kb_rev():
+ result = check_subcommand('list-keymaps', '-kb', 'kbdfans/kbd67/mkiirgb/v2')
+ check_returncode(result)
+ assert 'default' in result.stdout
+ assert 'oryx' in result.stdout
def test_list_keymaps_no_keyboard_found():
@@ -263,7 +264,6 @@ def test_generate_config_h():
result = check_subcommand('generate-config-h', '-kb', 'handwired/pytest/basic')
check_returncode(result)
assert '# define DEVICE_VER 0x0001' in result.stdout
- assert '# define DESCRIPTION "handwired/pytest/basic"' in result.stdout
assert '# define DIODE_DIRECTION COL2ROW' in result.stdout
assert '# define MANUFACTURER none' in result.stdout
assert '# define PRODUCT pytest' in result.stdout
diff --git a/lib/vusb b/lib/vusb
-Subproject bdb53e4c043d089279d9891b68bea77614cb97e
+Subproject 819dbc1e5d5926b17e27e00ca6d3d2988adae04
diff --git a/platforms/arm_atsam/flash.mk b/platforms/arm_atsam/flash.mk
index 8152610ceb..8068c08d57 100644
--- a/platforms/arm_atsam/flash.mk
+++ b/platforms/arm_atsam/flash.mk
@@ -13,6 +13,7 @@ mdloader: bin
$(call EXEC_MDLOADER)
flash: bin
+ $(SILENT) || printf "Flashing for bootloader: $(BLUE)$(BOOTLOADER)$(NO_COLOR)\n"
ifneq ($(strip $(PROGRAM_CMD)),)
$(UNSYNC_OUTPUT_CMD) && $(PROGRAM_CMD)
else ifeq ($(strip $(ARM_ATSAM)),SAMD51J18A)
diff --git a/platforms/arm_atsam/platform.mk b/platforms/arm_atsam/platform.mk
index b49bf764d7..9462f517ae 100644
--- a/platforms/arm_atsam/platform.mk
+++ b/platforms/arm_atsam/platform.mk
@@ -24,13 +24,14 @@ COMPILEFLAGS += -fno-strict-aliasing
COMPILEFLAGS += -mfloat-abi=hard
COMPILEFLAGS += -mfpu=fpv4-sp-d16
COMPILEFLAGS += -mthumb
+COMPILEFLAGS += -fno-builtin-printf
#ALLOW_WARNINGS = yes
CFLAGS += $(COMPILEFLAGS)
CXXFLAGS += $(COMPILEFLAGS)
-CXXFLAGS += -fno-exceptions -std=c++11
+CXXFLAGS += -fno-exceptions $(CXXSTANDARD)
LDFLAGS +=-Wl,--gc-sections
LDFLAGS += -Wl,-Map="%OUT%%PROJ_NAME%.map"
diff --git a/platforms/avr/_wait.h b/platforms/avr/_wait.h
index 683db6ae57..c1a598a428 100644
--- a/platforms/avr/_wait.h
+++ b/platforms/avr/_wait.h
@@ -17,6 +17,26 @@
#include <util/delay.h>
+// http://ww1.microchip.com/downloads/en/devicedoc/atmel-0856-avr-instruction-set-manual.pdf
+// page 22: Table 4-2. Arithmetic and Logic Instructions
+/*
+ for (uint16_t i = times; i > 0; i--) {
+ __builtin_avr_delay_cycles(1);
+ }
+
+ .L3: sbiw r24,0 // loop step 1
+ brne .L4 // loop step 2
+ ret
+ .L4: nop // __builtin_avr_delay_cycles(1);
+ sbiw r24,1 // loop step 3
+ rjmp .L3 // loop step 4
+*/
+
+#define AVR_sbiw_clocks 2
+#define AVR_rjmp_clocks 2
+#define AVR_brne_clocks 2
+#define AVR_WAIT_LOOP_OVERHEAD (AVR_sbiw_clocks + AVR_brne_clocks + AVR_sbiw_clocks + AVR_rjmp_clocks)
+
#define wait_ms(ms) \
do { \
if (__builtin_constant_p(ms)) { \
@@ -27,15 +47,15 @@
} \
} \
} while (0)
-#define wait_us(us) \
- do { \
- if (__builtin_constant_p(us)) { \
- _delay_us(us); \
- } else { \
- for (uint16_t i = us; i > 0; i--) { \
- _delay_us(1); \
- } \
- } \
+#define wait_us(us) \
+ do { \
+ if (__builtin_constant_p(us)) { \
+ _delay_us(us); \
+ } else { \
+ for (uint16_t i = us; i > 0; i--) { \
+ __builtin_avr_delay_cycles((F_CPU / 1000000) - AVR_WAIT_LOOP_OVERHEAD); \
+ } \
+ } \
} while (0)
#define wait_cpuclock(n) __builtin_avr_delay_cycles(n)
#define CPU_CLOCK F_CPU
diff --git a/platforms/avr/drivers/i2c_master.c b/platforms/avr/drivers/i2c_master.c
index c1a7b5f72d..524494c99d 100644
--- a/platforms/avr/drivers/i2c_master.c
+++ b/platforms/avr/drivers/i2c_master.c
@@ -64,7 +64,7 @@ static i2c_status_t i2c_start_impl(uint8_t address, uint16_t timeout) {
uint16_t timeout_timer = timer_read();
while (!(TWCR & (1 << TWINT))) {
- if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
+ if ((timeout != I2C_TIMEOUT_INFINITE) && (timer_elapsed(timeout_timer) > timeout)) {
return I2C_STATUS_TIMEOUT;
}
}
@@ -81,7 +81,7 @@ static i2c_status_t i2c_start_impl(uint8_t address, uint16_t timeout) {
timeout_timer = timer_read();
while (!(TWCR & (1 << TWINT))) {
- if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
+ if ((timeout != I2C_TIMEOUT_INFINITE) && (timer_elapsed(timeout_timer) > timeout)) {
return I2C_STATUS_TIMEOUT;
}
}
@@ -102,7 +102,7 @@ i2c_status_t i2c_start(uint8_t address, uint16_t timeout) {
i2c_status_t status;
do {
status = i2c_start_impl(address, time_slice);
- } while ((status < 0) && ((timeout == I2C_TIMEOUT_INFINITE) || (timer_elapsed(timeout_timer) < timeout)));
+ } while ((status < 0) && ((timeout == I2C_TIMEOUT_INFINITE) || (timer_elapsed(timeout_timer) <= timeout)));
return status;
}
@@ -114,7 +114,7 @@ i2c_status_t i2c_write(uint8_t data, uint16_t timeout) {
uint16_t timeout_timer = timer_read();
while (!(TWCR & (1 << TWINT))) {
- if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
+ if ((timeout != I2C_TIMEOUT_INFINITE) && (timer_elapsed(timeout_timer) > timeout)) {
return I2C_STATUS_TIMEOUT;
}
}
@@ -132,7 +132,7 @@ int16_t i2c_read_ack(uint16_t timeout) {
uint16_t timeout_timer = timer_read();
while (!(TWCR & (1 << TWINT))) {
- if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
+ if ((timeout != I2C_TIMEOUT_INFINITE) && (timer_elapsed(timeout_timer) > timeout)) {
return I2C_STATUS_TIMEOUT;
}
}
@@ -147,7 +147,7 @@ int16_t i2c_read_nack(uint16_t timeout) {
uint16_t timeout_timer = timer_read();
while (!(TWCR & (1 << TWINT))) {
- if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
+ if ((timeout != I2C_TIMEOUT_INFINITE) && (timer_elapsed(timeout_timer) > timeout)) {
return I2C_STATUS_TIMEOUT;
}
}
diff --git a/platforms/avr/drivers/i2c_master.h b/platforms/avr/drivers/i2c_master.h
index 2d95846db5..04ef126c80 100644
--- a/platforms/avr/drivers/i2c_master.h
+++ b/platforms/avr/drivers/i2c_master.h
@@ -19,6 +19,8 @@
#pragma once
+#include <stdint.h>
+
#define I2C_READ 0x01
#define I2C_WRITE 0x00
diff --git a/platforms/avr/drivers/ps2/ps2_usart.c b/platforms/avr/drivers/ps2/ps2_usart.c
index 39ec930d4a..581badac64 100644
--- a/platforms/avr/drivers/ps2/ps2_usart.c
+++ b/platforms/avr/drivers/ps2/ps2_usart.c
@@ -72,8 +72,8 @@ uint8_t ps2_error = PS2_ERR_NONE;
static inline uint8_t pbuf_dequeue(void);
static inline void pbuf_enqueue(uint8_t data);
-static inline bool pbuf_has_data(void);
static inline void pbuf_clear(void);
+bool pbuf_has_data(void);
void ps2_host_init(void) {
idle(); // without this many USART errors occur when cable is disconnected
@@ -212,7 +212,7 @@ static inline uint8_t pbuf_dequeue(void) {
return val;
}
-static inline bool pbuf_has_data(void) {
+bool pbuf_has_data(void) {
uint8_t sreg = SREG;
cli();
bool has_data = (pbuf_head != pbuf_tail);
diff --git a/platforms/avr/drivers/serial.c b/platforms/avr/drivers/serial.c
index 31eab7b7c0..7487f8d5e2 100644
--- a/platforms/avr/drivers/serial.c
+++ b/platforms/avr/drivers/serial.c
@@ -503,6 +503,10 @@ bool soft_serial_transaction(int sstd_index) {
sei();
return true;
}
+#else
+# ifndef USE_I2C
+# error SOFT_SERIAL_PIN or USE_I2C is required but has not been defined.
+# endif
#endif
// Helix serial.c history
diff --git a/platforms/avr/drivers/ssd1306.c b/platforms/avr/drivers/ssd1306.c
deleted file mode 100644
index 7afbc09f00..0000000000
--- a/platforms/avr/drivers/ssd1306.c
+++ /dev/null
@@ -1,329 +0,0 @@
-#ifdef SSD1306OLED
-
-# include "ssd1306.h"
-# include "i2c.h"
-# include <string.h>
-# include "print.h"
-# include "glcdfont.c"
-# ifdef PROTOCOL_LUFA
-# include "lufa.h"
-# endif
-# include "sendchar.h"
-# include "timer.h"
-
-struct CharacterMatrix display;
-
-// Set this to 1 to help diagnose early startup problems
-// when testing power-on with ble. Turn it off otherwise,
-// as the latency of printing most of the debug info messes
-// with the matrix scan, causing keys to drop.
-# define DEBUG_TO_SCREEN 0
-
-// static uint16_t last_battery_update;
-// static uint32_t vbat;
-//#define BatteryUpdateInterval 10000 /* milliseconds */
-# define ScreenOffInterval 300000 /* milliseconds */
-# if DEBUG_TO_SCREEN
-static uint8_t displaying;
-# endif
-static uint16_t last_flush;
-
-// Write command sequence.
-// Returns true on success.
-static inline bool _send_cmd1(uint8_t cmd) {
- bool res = false;
-
- if (i2c_start_write(SSD1306_ADDRESS)) {
- xprintf("failed to start write to %d\n", SSD1306_ADDRESS);
- goto done;
- }
-
- if (i2c_master_write(0x0 /* command byte follows */)) {
- print("failed to write control byte\n");
-
- goto done;
- }
-
- if (i2c_master_write(cmd)) {
- xprintf("failed to write command %d\n", cmd);
- goto done;
- }
- res = true;
-done:
- i2c_master_stop();
- return res;
-}
-
-// Write 2-byte command sequence.
-// Returns true on success
-static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) {
- if (!_send_cmd1(cmd)) {
- return false;
- }
- return _send_cmd1(opr);
-}
-
-// Write 3-byte command sequence.
-// Returns true on success
-static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) {
- if (!_send_cmd1(cmd)) {
- return false;
- }
- if (!_send_cmd1(opr1)) {
- return false;
- }
- return _send_cmd1(opr2);
-}
-
-# define send_cmd1(c) \
- if (!_send_cmd1(c)) { \
- goto done; \
- }
-# define send_cmd2(c, o) \
- if (!_send_cmd2(c, o)) { \
- goto done; \
- }
-# define send_cmd3(c, o1, o2) \
- if (!_send_cmd3(c, o1, o2)) { \
- goto done; \
- }
-
-static void clear_display(void) {
- matrix_clear(&display);
-
- // Clear all of the display bits (there can be random noise
- // in the RAM on startup)
- send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1);
- send_cmd3(ColumnAddr, 0, DisplayWidth - 1);
-
- if (i2c_start_write(SSD1306_ADDRESS)) {
- goto done;
- }
- if (i2c_master_write(0x40)) {
- // Data mode
- goto done;
- }
- for (uint8_t row = 0; row < MatrixRows; ++row) {
- for (uint8_t col = 0; col < DisplayWidth; ++col) {
- i2c_master_write(0);
- }
- }
-
- display.dirty = false;
-
-done:
- i2c_master_stop();
-}
-
-# if DEBUG_TO_SCREEN
-# undef sendchar
-static int8_t capture_sendchar(uint8_t c) {
- sendchar(c);
- iota_gfx_write_char(c);
-
- if (!displaying) {
- iota_gfx_flush();
- }
- return 0;
-}
-# endif
-
-bool iota_gfx_init(void) {
- bool success = false;
-
- send_cmd1(DisplayOff);
- send_cmd2(SetDisplayClockDiv, 0x80);
- send_cmd2(SetMultiPlex, DisplayHeight - 1);
-
- send_cmd2(SetDisplayOffset, 0);
-
- send_cmd1(SetStartLine | 0x0);
- send_cmd2(SetChargePump, 0x14 /* Enable */);
- send_cmd2(SetMemoryMode, 0 /* horizontal addressing */);
-
-# ifdef OLED_ROTATE180
- // the following Flip the display orientation 180 degrees
- send_cmd1(SegRemap);
- send_cmd1(ComScanInc);
-# endif
-# ifndef OLED_ROTATE180
- // Flips the display orientation 0 degrees
- send_cmd1(SegRemap | 0x1);
- send_cmd1(ComScanDec);
-# endif
-
- send_cmd2(SetComPins, 0x2);
- send_cmd2(SetContrast, 0x8f);
- send_cmd2(SetPreCharge, 0xf1);
- send_cmd2(SetVComDetect, 0x40);
- send_cmd1(DisplayAllOnResume);
- send_cmd1(NormalDisplay);
- send_cmd1(DeActivateScroll);
- send_cmd1(DisplayOn);
-
- send_cmd2(SetContrast, 0); // Dim
-
- clear_display();
-
- success = true;
-
- iota_gfx_flush();
-
-# if DEBUG_TO_SCREEN
- print_set_sendchar(capture_sendchar);
-# endif
-
-done:
- return success;
-}
-
-bool iota_gfx_off(void) {
- bool success = false;
-
- send_cmd1(DisplayOff);
- success = true;
-
-done:
- return success;
-}
-
-bool iota_gfx_on(void) {
- bool success = false;
-
- send_cmd1(DisplayOn);
- success = true;
-
-done:
- return success;
-}
-
-void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) {
- *matrix->cursor = c;
- ++matrix->cursor;
-
- if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) {
- // We went off the end; scroll the display upwards by one line
- memmove(&matrix->display[0], &matrix->display[1], MatrixCols * (MatrixRows - 1));
- matrix->cursor = &matrix->display[MatrixRows - 1][0];
- memset(matrix->cursor, ' ', MatrixCols);
- }
-}
-
-void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) {
- matrix->dirty = true;
-
- if (c == '\n') {
- // Clear to end of line from the cursor and then move to the
- // start of the next line
- uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols;
-
- while (cursor_col++ < MatrixCols) {
- matrix_write_char_inner(matrix, ' ');
- }
- return;
- }
-
- matrix_write_char_inner(matrix, c);
-}
-
-void iota_gfx_write_char(uint8_t c) {
- matrix_write_char(&display, c);
-}
-
-void matrix_write(struct CharacterMatrix *matrix, const char *data) {
- const char *end = data + strlen(data);
- while (data < end) {
- matrix_write_char(matrix, *data);
- ++data;
- }
-}
-
-void iota_gfx_write(const char *data) {
- matrix_write(&display, data);
-}
-
-void matrix_write_P(struct CharacterMatrix *matrix, const char *data) {
- while (true) {
- uint8_t c = pgm_read_byte(data);
- if (c == 0) {
- return;
- }
- matrix_write_char(matrix, c);
- ++data;
- }
-}
-
-void iota_gfx_write_P(const char *data) {
- matrix_write_P(&display, data);
-}
-
-void matrix_clear(struct CharacterMatrix *matrix) {
- memset(matrix->display, ' ', sizeof(matrix->display));
- matrix->cursor = &matrix->display[0][0];
- matrix->dirty = true;
-}
-
-void iota_gfx_clear_screen(void) {
- matrix_clear(&display);
-}
-
-void matrix_render(struct CharacterMatrix *matrix) {
- last_flush = timer_read();
- iota_gfx_on();
-# if DEBUG_TO_SCREEN
- ++displaying;
-# endif
-
- // Move to the home position
- send_cmd3(PageAddr, 0, MatrixRows - 1);
- send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1);
-
- if (i2c_start_write(SSD1306_ADDRESS)) {
- goto done;
- }
- if (i2c_master_write(0x40)) {
- // Data mode
- goto done;
- }
-
- for (uint8_t row = 0; row < MatrixRows; ++row) {
- for (uint8_t col = 0; col < MatrixCols; ++col) {
- const uint8_t *glyph = font + (matrix->display[row][col] * (FontWidth - 1));
-
- for (uint8_t glyphCol = 0; glyphCol < FontWidth - 1; ++glyphCol) {
- uint8_t colBits = pgm_read_byte(glyph + glyphCol);
- i2c_master_write(colBits);
- }
-
- // 1 column of space between chars (it's not included in the glyph)
- i2c_master_write(0);
- }
- }
-
- matrix->dirty = false;
-
-done:
- i2c_master_stop();
-# if DEBUG_TO_SCREEN
- --displaying;
-# endif
-}
-
-void iota_gfx_flush(void) {
- matrix_render(&display);
-}
-
-__attribute__((weak)) void iota_gfx_task_user(void) {}
-
-void iota_gfx_task(void) {
- iota_gfx_task_user();
-
- if (display.dirty) {
- iota_gfx_flush();
- }
-
- if (timer_elapsed(last_flush) > ScreenOffInterval) {
- iota_gfx_off();
- }
-}
-#endif
diff --git a/platforms/avr/drivers/ssd1306.h b/platforms/avr/drivers/ssd1306.h
deleted file mode 100644
index 6eecdcfaa4..0000000000
--- a/platforms/avr/drivers/ssd1306.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#pragma once
-
-#include <stdbool.h>
-#include <stdio.h>
-#include "config.h"
-
-enum ssd1306_cmds {
- DisplayOff = 0xAE,
- DisplayOn = 0xAF,
-
- SetContrast = 0x81,
- DisplayAllOnResume = 0xA4,
-
- DisplayAllOn = 0xA5,
- NormalDisplay = 0xA6,
- InvertDisplay = 0xA7,
- SetDisplayOffset = 0xD3,
- SetComPins = 0xda,
- SetVComDetect = 0xdb,
- SetDisplayClockDiv = 0xD5,
- SetPreCharge = 0xd9,
- SetMultiPlex = 0xa8,
- SetLowColumn = 0x00,
- SetHighColumn = 0x10,
- SetStartLine = 0x40,
-
- SetMemoryMode = 0x20,
- ColumnAddr = 0x21,
- PageAddr = 0x22,
-
- ComScanInc = 0xc0,
- ComScanDec = 0xc8,
- SegRemap = 0xa0,
- SetChargePump = 0x8d,
- ExternalVcc = 0x01,
- SwitchCapVcc = 0x02,
-
- ActivateScroll = 0x2f,
- DeActivateScroll = 0x2e,
- SetVerticalScrollArea = 0xa3,
- RightHorizontalScroll = 0x26,
- LeftHorizontalScroll = 0x27,
- VerticalAndRightHorizontalScroll = 0x29,
- VerticalAndLeftHorizontalScroll = 0x2a,
-};
-
-// Controls the SSD1306 128x32 OLED display via i2c
-
-#ifndef SSD1306_ADDRESS
-# define SSD1306_ADDRESS 0x3C
-#endif
-
-#define DisplayHeight 32
-#define DisplayWidth 128
-
-#define FontHeight 8
-#define FontWidth 6
-
-#define MatrixRows (DisplayHeight / FontHeight)
-#define MatrixCols (DisplayWidth / FontWidth)
-
-struct CharacterMatrix {
- uint8_t display[MatrixRows][MatrixCols];
- uint8_t *cursor;
- bool dirty;
-};
-
-extern struct CharacterMatrix display;
-
-bool iota_gfx_init(void);
-void iota_gfx_task(void);
-bool iota_gfx_off(void);
-bool iota_gfx_on(void);
-void iota_gfx_flush(void);
-void iota_gfx_write_char(uint8_t c);
-void iota_gfx_write(const char *data);
-void iota_gfx_write_P(const char *data);
-void iota_gfx_clear_screen(void);
-
-void iota_gfx_task_user(void);
-
-void matrix_clear(struct CharacterMatrix *matrix);
-void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c);
-void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c);
-void matrix_write(struct CharacterMatrix *matrix, const char *data);
-void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
-void matrix_render(struct CharacterMatrix *matrix);
diff --git a/platforms/avr/flash.mk b/platforms/avr/flash.mk
index 6d50e72534..e058e8d296 100644
--- a/platforms/avr/flash.mk
+++ b/platforms/avr/flash.mk
@@ -78,7 +78,7 @@ AVRDUDE_PROGRAMMER ?= avrdude
define EXEC_AVRDUDE
list_devices() { \
if $(GREP) -q -s icrosoft /proc/version; then \
- wmic.exe path Win32_SerialPort get DeviceID 2>/dev/null | LANG=C perl -pne 's/COM(\d+)/COM.($$1-1)/e' | sed 's!COM!/dev/ttyS!' | xargs echo -n | sort; \
+ powershell.exe 'Get-CimInstance -Class Win32_SerialPort | Select -ExpandProperty "DeviceID"' 2>/dev/null | sed -e "s/\r//g" | LANG=C perl -pne 's/COM(\d+)/COM.($$1-1)/e' | sed 's!COM!/dev/ttyS!' | sort; \
elif [ "`uname`" = "FreeBSD" ]; then \
ls /dev/tty* | grep -v '\.lock$$' | grep -v '\.init$$'; \
else \
@@ -168,7 +168,8 @@ endef
hid_bootloader: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
$(call EXEC_HID_LUFA)
-flash: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
+flash: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
+ $(SILENT) || printf "Flashing for bootloader: $(BLUE)$(BOOTLOADER)$(NO_COLOR)\n"
ifneq ($(strip $(PROGRAM_CMD)),)
$(UNSYNC_OUTPUT_CMD) && $(PROGRAM_CMD)
else ifeq ($(strip $(BOOTLOADER)), caterina)
diff --git a/platforms/avr/platform.mk b/platforms/avr/platform.mk
index 978199b385..39a11b28e4 100644
--- a/platforms/avr/platform.mk
+++ b/platforms/avr/platform.mk
@@ -24,6 +24,7 @@ COMPILEFLAGS += -fdata-sections
COMPILEFLAGS += -fpack-struct
COMPILEFLAGS += -fshort-enums
COMPILEFLAGS += -mcall-prologues
+COMPILEFLAGS += -fno-builtin-printf
# Linker relaxation is only possible if
# link time optimizations are not enabled.
@@ -38,7 +39,7 @@ CFLAGS += -fno-inline-small-functions
CFLAGS += -fno-strict-aliasing
CXXFLAGS += $(COMPILEFLAGS)
-CXXFLAGS += -fno-exceptions -std=c++11
+CXXFLAGS += -fno-exceptions $(CXXSTANDARD)
LDFLAGS += -Wl,--gc-sections
diff --git a/platforms/chibios/_pin_defs.h b/platforms/chibios/_pin_defs.h
index 0d96e2fc3b..414c9e3d11 100644
--- a/platforms/chibios/_pin_defs.h
+++ b/platforms/chibios/_pin_defs.h
@@ -21,6 +21,11 @@
# include <hal.h>
#endif
+/* Include the vendor specific pin defs */
+#if __has_include_next("_pin_defs.h")
+# include_next "_pin_defs.h"
+#endif
+
#define A0 PAL_LINE(GPIOA, 0)
#define A1 PAL_LINE(GPIOA, 1)
#define A2 PAL_LINE(GPIOA, 2)
diff --git a/platforms/chibios/_wait.h b/platforms/chibios/_wait.h
index 2f36c64a2e..c0ccbc5569 100644
--- a/platforms/chibios/_wait.h
+++ b/platforms/chibios/_wait.h
@@ -17,6 +17,7 @@
#include <ch.h>
#include <hal.h>
+#include "chibios_config.h"
/* chThdSleepX of zero maps to infinite - so we map to a tiny delay to still yield */
#define wait_ms(ms) \
@@ -30,6 +31,11 @@
#ifdef WAIT_US_TIMER
void wait_us(uint16_t duration);
+#elif PORT_SUPPORTS_RT == TRUE
+# define wait_us(us) \
+ do { \
+ chSysPolledDelayX(US2RTC(REALTIME_COUNTER_CLOCK, us)); \
+ } while (0)
#else
# define wait_us(us) \
do { \
diff --git a/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/board/board.mk b/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/board/board.mk
new file mode 100644
index 0000000000..911cc5a058
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/board/board.mk
@@ -0,0 +1,9 @@
+# List of all the board related files.
+BOARDSRC = $(CHIBIOS)/os/hal/boards/RP_PICO_RP2040/board.c
+
+# Required include directories
+BOARDINC = $(CHIBIOS)/os/hal/boards/RP_PICO_RP2040
+
+# Shared variables
+ALLCSRC += $(BOARDSRC)
+ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/board.h b/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/board.h
new file mode 100644
index 0000000000..b4363595d0
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/board.h
@@ -0,0 +1,12 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include_next "board.h"
+
+#undef BOARD_RP_PICO_RP2040
+#define BOARD_GENERIC_PROMICRO_RP2040
+
+#undef BOARD_NAME
+#define BOARD_NAME "Pro Micro RP2040"
diff --git a/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/chconf.h b/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/chconf.h
new file mode 100644
index 0000000000..d53f57edd9
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/chconf.h
@@ -0,0 +1,13 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#define CH_CFG_SMP_MODE TRUE
+#define CH_CFG_ST_RESOLUTION 32
+#define CH_CFG_ST_FREQUENCY 1000000
+#define CH_CFG_INTERVALS_SIZE 32
+#define CH_CFG_TIME_TYPES_SIZE 32
+#define CH_CFG_ST_TIMEDELTA 20
+
+#include_next <chconf.h>
diff --git a/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/config.h b/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/config.h
new file mode 100644
index 0000000000..7fe9b654e1
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/config.h
@@ -0,0 +1,62 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+/**======================
+ ** I2C Driver
+ *========================**/
+
+#if !defined(I2C_DRIVER)
+# define I2C_DRIVER I2CD2
+#endif
+
+#if !defined(I2C1_SDA_PIN)
+# define I2C1_SDA_PIN GP2
+#endif
+
+#if !defined(I2C1_SCL_PIN)
+# define I2C1_SCL_PIN GP3
+#endif
+
+/**======================
+ ** SPI Driver
+ *========================**/
+
+#if !defined(SPI_DRIVER)
+# define SPI_DRIVER SPID0
+#endif
+
+#if !defined(SPI_SCK_PIN)
+# define SPI_SCK_PIN GP18
+#endif
+
+#if !defined(SPI_MISO_PIN)
+# define SPI_MISO_PIN GP20
+#endif
+
+#if !defined(SPI_MOSI_PIN)
+# define SPI_MOSI_PIN GP19
+#endif
+
+/**======================
+ ** SERIAL Driver
+ *========================**/
+
+#if !defined(SERIAL_USART_DRIVER)
+# define SERIAL_USART_DRIVER SIOD0
+#endif
+
+#if !defined(SERIAL_USART_TX_PIN) && !defined(SOFT_SERIAL_PIN)
+# define SERIAL_USART_TX_PIN GP0
+#endif
+
+#if !defined(SERIAL_USART_RX_PIN)
+# define SERIAL_USART_RX_PIN GP1
+#endif
+
+/**======================
+ ** Double-tap
+ *========================**/
+
+#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET
diff --git a/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/mcuconf.h
new file mode 100644
index 0000000000..8348e5312f
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/mcuconf.h
@@ -0,0 +1,98 @@
+/*
+ ChibiOS - Copyright (C) 2006..2021 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#ifndef MCUCONF_H
+#define MCUCONF_H
+
+/*
+ * RP2040_MCUCONF drivers configuration.
+ *
+ * IRQ priorities:
+ * 3...0 Lowest...Highest.
+ *
+ * DMA priorities:
+ * 0...1 Lowest...Highest.
+ */
+
+#define RP2040_MCUCONF
+
+/*
+ * HAL driver system settings.
+ */
+#define RP_NO_INIT FALSE
+#define RP_CORE1_START FALSE
+#define RP_CORE1_VECTORS_TABLE _vectors
+#define RP_CORE1_ENTRY_POINT _crt0_c1_entry
+#define RP_CORE1_STACK_END __c1_main_stack_end__
+
+/*
+ * IRQ system settings.
+ */
+#define RP_IRQ_SYSTICK_PRIORITY 2
+#define RP_IRQ_TIMER_ALARM0_PRIORITY 2
+#define RP_IRQ_TIMER_ALARM1_PRIORITY 2
+#define RP_IRQ_TIMER_ALARM2_PRIORITY 2
+#define RP_IRQ_TIMER_ALARM3_PRIORITY 2
+#define RP_IRQ_UART0_PRIORITY 3
+#define RP_IRQ_UART1_PRIORITY 3
+#define RP_IRQ_SPI0_PRIORITY 2
+#define RP_IRQ_SPI1_PRIORITY 2
+#define RP_IRQ_USB0_PRIORITY 3
+#define RP_IRQ_I2C0_PRIORITY 2
+#define RP_IRQ_I2C1_PRIORITY 2
+
+/*
+ * ADC driver system settings.
+ */
+#define RP_ADC_USE_ADC1 FALSE
+
+/*
+ * SIO driver system settings.
+ */
+#define RP_SIO_USE_UART0 TRUE
+#define RP_SIO_USE_UART1 FALSE
+
+/*
+ * SPI driver system settings.
+ */
+#define RP_SPI_USE_SPI0 TRUE
+#define RP_SPI_USE_SPI1 FALSE
+#define RP_SPI_SPI0_RX_DMA_CHANNEL RP_DMA_CHANNEL_ID_ANY
+#define RP_SPI_SPI0_TX_DMA_CHANNEL RP_DMA_CHANNEL_ID_ANY
+#define RP_SPI_SPI1_RX_DMA_CHANNEL RP_DMA_CHANNEL_ID_ANY
+#define RP_SPI_SPI1_TX_DMA_CHANNEL RP_DMA_CHANNEL_ID_ANY
+#define RP_SPI_SPI0_DMA_PRIORITY 1
+#define RP_SPI_SPI1_DMA_PRIORITY 1
+#define RP_SPI_DMA_ERROR_HOOK(spip)
+
+/*
+ * I2C driver system settings.
+ */
+#define RP_I2C_USE_I2C0 FALSE
+#define RP_I2C_USE_I2C1 TRUE
+#define RP_I2C_BUSY_TIMEOUT 50
+#define RP_I2C_ADDRESS_MODE_10BIT FALSE
+
+/*
+ * USB driver system settings.
+ */
+#define RP_USB_USE_USBD0 TRUE
+#define RP_USB_FORCE_VBUS_DETECT TRUE
+#define RP_USE_EXTERNAL_VBUS_DETECT FALSE
+#define RP_USB_USE_SOF_INTR TRUE
+#define RP_USB_USE_ERROR_DATA_SEQ_INTR FALSE
+
+#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/GENERIC_RP_RP2040/board/board.mk b/platforms/chibios/boards/GENERIC_RP_RP2040/board/board.mk
new file mode 100644
index 0000000000..911cc5a058
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_RP_RP2040/board/board.mk
@@ -0,0 +1,9 @@
+# List of all the board related files.
+BOARDSRC = $(CHIBIOS)/os/hal/boards/RP_PICO_RP2040/board.c
+
+# Required include directories
+BOARDINC = $(CHIBIOS)/os/hal/boards/RP_PICO_RP2040
+
+# Shared variables
+ALLCSRC += $(BOARDSRC)
+ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/GENERIC_RP_RP2040/configs/board.h b/platforms/chibios/boards/GENERIC_RP_RP2040/configs/board.h
new file mode 100644
index 0000000000..052050c944
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_RP_RP2040/configs/board.h
@@ -0,0 +1,12 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include_next "board.h"
+
+#undef BOARD_RP_PICO_RP2040
+#define BOARD_GENERIC_RP2040
+
+#undef BOARD_NAME
+#define BOARD_NAME "Generic Raspberry Pi RP2040"
diff --git a/platforms/chibios/boards/GENERIC_RP_RP2040/configs/chconf.h b/platforms/chibios/boards/GENERIC_RP_RP2040/configs/chconf.h
new file mode 100644
index 0000000000..d53f57edd9
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_RP_RP2040/configs/chconf.h
@@ -0,0 +1,13 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#define CH_CFG_SMP_MODE TRUE
+#define CH_CFG_ST_RESOLUTION 32
+#define CH_CFG_ST_FREQUENCY 1000000
+#define CH_CFG_INTERVALS_SIZE 32
+#define CH_CFG_TIME_TYPES_SIZE 32
+#define CH_CFG_ST_TIMEDELTA 20
+
+#include_next <chconf.h>
diff --git a/platforms/chibios/boards/GENERIC_RP_RP2040/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_RP_RP2040/configs/mcuconf.h
new file mode 100644
index 0000000000..9d8dc61aac
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_RP_RP2040/configs/mcuconf.h
@@ -0,0 +1,98 @@
+/*
+ ChibiOS - Copyright (C) 2006..2021 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#ifndef MCUCONF_H
+#define MCUCONF_H
+
+/*
+ * RP2040_MCUCONF drivers configuration.
+ *
+ * IRQ priorities:
+ * 3...0 Lowest...Highest.
+ *
+ * DMA priorities:
+ * 0...1 Lowest...Highest.
+ */
+
+#define RP2040_MCUCONF
+
+/*
+ * HAL driver system settings.
+ */
+#define RP_NO_INIT FALSE
+#define RP_CORE1_START FALSE
+#define RP_CORE1_VECTORS_TABLE _vectors
+#define RP_CORE1_ENTRY_POINT _crt0_c1_entry
+#define RP_CORE1_STACK_END __c1_main_stack_end__
+
+/*
+ * IRQ system settings.
+ */
+#define RP_IRQ_SYSTICK_PRIORITY 2
+#define RP_IRQ_TIMER_ALARM0_PRIORITY 2
+#define RP_IRQ_TIMER_ALARM1_PRIORITY 2
+#define RP_IRQ_TIMER_ALARM2_PRIORITY 2
+#define RP_IRQ_TIMER_ALARM3_PRIORITY 2
+#define RP_IRQ_UART0_PRIORITY 3
+#define RP_IRQ_UART1_PRIORITY 3
+#define RP_IRQ_SPI0_PRIORITY 2
+#define RP_IRQ_SPI1_PRIORITY 2
+#define RP_IRQ_USB0_PRIORITY 3
+#define RP_IRQ_I2C0_PRIORITY 2
+#define RP_IRQ_I2C1_PRIORITY 2
+
+/*
+ * ADC driver system settings.
+ */
+#define RP_ADC_USE_ADC1 FALSE
+
+/*
+ * SIO driver system settings.
+ */
+#define RP_SIO_USE_UART0 FALSE
+#define RP_SIO_USE_UART1 FALSE
+
+/*
+ * SPI driver system settings.
+ */
+#define RP_SPI_USE_SPI0 FALSE
+#define RP_SPI_USE_SPI1 FALSE
+#define RP_SPI_SPI0_RX_DMA_CHANNEL RP_DMA_CHANNEL_ID_ANY
+#define RP_SPI_SPI0_TX_DMA_CHANNEL RP_DMA_CHANNEL_ID_ANY
+#define RP_SPI_SPI1_RX_DMA_CHANNEL RP_DMA_CHANNEL_ID_ANY
+#define RP_SPI_SPI1_TX_DMA_CHANNEL RP_DMA_CHANNEL_ID_ANY
+#define RP_SPI_SPI0_DMA_PRIORITY 1
+#define RP_SPI_SPI1_DMA_PRIORITY 1
+#define RP_SPI_DMA_ERROR_HOOK(spip)
+
+/*
+ * I2C driver system settings.
+ */
+#define RP_I2C_USE_I2C0 FALSE
+#define RP_I2C_USE_I2C1 FALSE
+#define RP_I2C_BUSY_TIMEOUT 50
+#define RP_I2C_ADDRESS_MODE_10BIT FALSE
+
+/*
+ * USB driver system settings.
+ */
+#define RP_USB_USE_USBD0 TRUE
+#define RP_USB_FORCE_VBUS_DETECT TRUE
+#define RP_USE_EXTERNAL_VBUS_DETECT FALSE
+#define RP_USB_USE_SOF_INTR TRUE
+#define RP_USB_USE_ERROR_DATA_SEQ_INTR FALSE
+
+#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/GENERIC_STM32_F401XC/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_STM32_F401XC/configs/mcuconf.h
index 24cec7137d..1208563aa1 100644
--- a/platforms/chibios/boards/GENERIC_STM32_F401XC/configs/mcuconf.h
+++ b/platforms/chibios/boards/GENERIC_STM32_F401XC/configs/mcuconf.h
@@ -53,8 +53,8 @@
#define STM32_PLLP_VALUE 4
#define STM32_PLLQ_VALUE 7
#define STM32_HPRE STM32_HPRE_DIV1
-#define STM32_PPRE1 STM32_PPRE1_DIV2
-#define STM32_PPRE2 STM32_PPRE2_DIV1
+#define STM32_PPRE1 STM32_PPRE1_DIV2
+#define STM32_PPRE2 STM32_PPRE2_DIV1
#define STM32_RTCSEL STM32_RTCSEL_LSI
#define STM32_RTCPRE_VALUE 8
#define STM32_MCO1SEL STM32_MCO1SEL_HSI
diff --git a/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/config.h b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/config.h
index 9fdc825669..437a8e4df2 100644
--- a/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/config.h
+++ b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/config.h
@@ -18,3 +18,5 @@
#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
#endif
+
+#define USB_ENDPOINTS_ARE_REORDERABLE
diff --git a/platforms/chibios/boards/QMK_PM2040/board/board.mk b/platforms/chibios/boards/QMK_PM2040/board/board.mk
new file mode 100644
index 0000000000..911cc5a058
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PM2040/board/board.mk
@@ -0,0 +1,9 @@
+# List of all the board related files.
+BOARDSRC = $(CHIBIOS)/os/hal/boards/RP_PICO_RP2040/board.c
+
+# Required include directories
+BOARDINC = $(CHIBIOS)/os/hal/boards/RP_PICO_RP2040
+
+# Shared variables
+ALLCSRC += $(BOARDSRC)
+ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/QMK_PM2040/configs/board.h b/platforms/chibios/boards/QMK_PM2040/configs/board.h
new file mode 100644
index 0000000000..433e1c527f
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PM2040/configs/board.h
@@ -0,0 +1,12 @@
+// Copyright 2022 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include_next "board.h"
+
+#undef BOARD_RP_PICO_RP2040
+#define BOARD_PM2040
+
+#undef BOARD_NAME
+#define BOARD_NAME "Pro Micro RP2040"
diff --git a/platforms/chibios/boards/QMK_PM2040/configs/chconf.h b/platforms/chibios/boards/QMK_PM2040/configs/chconf.h
new file mode 100644
index 0000000000..d53f57edd9
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PM2040/configs/chconf.h
@@ -0,0 +1,13 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#define CH_CFG_SMP_MODE TRUE
+#define CH_CFG_ST_RESOLUTION 32
+#define CH_CFG_ST_FREQUENCY 1000000
+#define CH_CFG_INTERVALS_SIZE 32
+#define CH_CFG_TIME_TYPES_SIZE 32
+#define CH_CFG_ST_TIMEDELTA 20
+
+#include_next <chconf.h>
diff --git a/platforms/chibios/boards/QMK_PM2040/configs/config.h b/platforms/chibios/boards/QMK_PM2040/configs/config.h
new file mode 100644
index 0000000000..8c773f8b19
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PM2040/configs/config.h
@@ -0,0 +1,21 @@
+// Copyright 2022 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#ifndef I2C_DRIVER
+# define I2C_DRIVER I2CD2
+#endif
+#ifndef I2C1_SDA_PIN
+# define I2C1_SDA_PIN D1
+#endif
+#ifndef I2C1_SCL_PIN
+# define I2C1_SCL_PIN D0
+#endif
+
+#ifndef RP2040_BOOTLOADER_DOUBLE_TAP_RESET
+# define RP2040_BOOTLOADER_DOUBLE_TAP_RESET
+#endif
+#ifndef RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT
+# define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 500U
+#endif
diff --git a/platforms/chibios/boards/QMK_PM2040/configs/halconf.h b/platforms/chibios/boards/QMK_PM2040/configs/halconf.h
new file mode 100644
index 0000000000..d7a58f0ea6
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PM2040/configs/halconf.h
@@ -0,0 +1,9 @@
+// Copyright 2022 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#define HAL_USE_I2C TRUE
+#define HAL_USE_SPI TRUE
+
+#include_next <halconf.h>
diff --git a/platforms/chibios/boards/QMK_PM2040/configs/mcuconf.h b/platforms/chibios/boards/QMK_PM2040/configs/mcuconf.h
new file mode 100644
index 0000000000..a737b36c1c
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PM2040/configs/mcuconf.h
@@ -0,0 +1,98 @@
+/*
+ ChibiOS - Copyright (C) 2006..2021 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#ifndef MCUCONF_H
+#define MCUCONF_H
+
+/*
+ * RP2040_MCUCONF drivers configuration.
+ *
+ * IRQ priorities:
+ * 3...0 Lowest...Highest.
+ *
+ * DMA priorities:
+ * 0...1 Lowest...Highest.
+ */
+
+#define RP2040_MCUCONF
+
+/*
+ * HAL driver system settings.
+ */
+#define RP_NO_INIT FALSE
+#define RP_CORE1_START FALSE
+#define RP_CORE1_VECTORS_TABLE _vectors
+#define RP_CORE1_ENTRY_POINT _crt0_c1_entry
+#define RP_CORE1_STACK_END __c1_main_stack_end__
+
+/*
+ * IRQ system settings.
+ */
+#define RP_IRQ_SYSTICK_PRIORITY 2
+#define RP_IRQ_TIMER_ALARM0_PRIORITY 2
+#define RP_IRQ_TIMER_ALARM1_PRIORITY 2
+#define RP_IRQ_TIMER_ALARM2_PRIORITY 2
+#define RP_IRQ_TIMER_ALARM3_PRIORITY 2
+#define RP_IRQ_UART0_PRIORITY 3
+#define RP_IRQ_UART1_PRIORITY 3
+#define RP_IRQ_SPI0_PRIORITY 2
+#define RP_IRQ_SPI1_PRIORITY 2
+#define RP_IRQ_USB0_PRIORITY 3
+#define RP_IRQ_I2C0_PRIORITY 2
+#define RP_IRQ_I2C1_PRIORITY 2
+
+/*
+ * ADC driver system settings.
+ */
+#define RP_ADC_USE_ADC1 FALSE
+
+/*
+ * SIO driver system settings.
+ */
+#define RP_SIO_USE_UART0 FALSE
+#define RP_SIO_USE_UART1 FALSE
+
+/*
+ * SPI driver system settings.
+ */
+#define RP_SPI_USE_SPI0 TRUE
+#define RP_SPI_USE_SPI1 FALSE
+#define RP_SPI_SPI0_RX_DMA_CHANNEL RP_DMA_CHANNEL_ID_ANY
+#define RP_SPI_SPI0_TX_DMA_CHANNEL RP_DMA_CHANNEL_ID_ANY
+#define RP_SPI_SPI1_RX_DMA_CHANNEL RP_DMA_CHANNEL_ID_ANY
+#define RP_SPI_SPI1_TX_DMA_CHANNEL RP_DMA_CHANNEL_ID_ANY
+#define RP_SPI_SPI0_DMA_PRIORITY 1
+#define RP_SPI_SPI1_DMA_PRIORITY 1
+#define RP_SPI_DMA_ERROR_HOOK(spip)
+
+/*
+ * I2C driver system settings.
+ */
+#define RP_I2C_USE_I2C0 FALSE
+#define RP_I2C_USE_I2C1 TRUE
+#define RP_I2C_BUSY_TIMEOUT 50
+#define RP_I2C_ADDRESS_MODE_10BIT FALSE
+
+/*
+ * USB driver system settings.
+ */
+#define RP_USB_USE_USBD0 TRUE
+#define RP_USB_FORCE_VBUS_DETECT TRUE
+#define RP_USE_EXTERNAL_VBUS_DETECT FALSE
+#define RP_USB_USE_SOF_INTR TRUE
+#define RP_USB_USE_ERROR_DATA_SEQ_INTR FALSE
+
+#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/STEMCELL/board/board.mk b/platforms/chibios/boards/STEMCELL/board/board.mk
new file mode 100644
index 0000000000..b0d1c3c404
--- /dev/null
+++ b/platforms/chibios/boards/STEMCELL/board/board.mk
@@ -0,0 +1,15 @@
+# Copyright 2022 Mega Mind (@megamind4089)
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# Default pin config of nucleo64_411re has most pins in input pull up mode
+
+# List of all the board related files.
+BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F411RE/board.c
+
+# Required include directories
+BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F411RE
+
+
+# Shared variables
+ALLCSRC += $(BOARDSRC)
+ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/STEMCELL/configs/board.h b/platforms/chibios/boards/STEMCELL/configs/board.h
new file mode 100644
index 0000000000..39cf79ab09
--- /dev/null
+++ b/platforms/chibios/boards/STEMCELL/configs/board.h
@@ -0,0 +1,8 @@
+// Copyright 2022 Mega Mind (@megamind4089)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include_next "board.h"
+
+#undef STM32_HSE_BYPASS
diff --git a/platforms/chibios/boards/STEMCELL/configs/chconf.h b/platforms/chibios/boards/STEMCELL/configs/chconf.h
new file mode 100644
index 0000000000..d25bea0d17
--- /dev/null
+++ b/platforms/chibios/boards/STEMCELL/configs/chconf.h
@@ -0,0 +1,9 @@
+// Copyright 2022 Mega Mind (@megamind4089)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#define CH_CFG_ST_RESOLUTION 16
+#define CH_CFG_ST_FREQUENCY 10000
+
+#include_next <chconf.h>
diff --git a/platforms/chibios/boards/STEMCELL/configs/config.h b/platforms/chibios/boards/STEMCELL/configs/config.h
new file mode 100644
index 0000000000..82f6c63636
--- /dev/null
+++ b/platforms/chibios/boards/STEMCELL/configs/config.h
@@ -0,0 +1,29 @@
+// Copyright 2022 Mega Mind(@megamind4089)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
+# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
+#endif
+
+/**======================
+ ** I2C Driver
+ *========================**/
+
+#if !defined(I2C1_SDA_PIN)
+# define I2C1_SDA_PIN D0
+#endif
+
+#if !defined(I2C1_SCL_PIN)
+# define I2C1_SCL_PIN D1
+#endif
+
+/**======================
+ ** SERIAL Driver
+ *========================**/
+
+#if !defined(SERIAL_USART_DRIVER)
+# define SERIAL_USART_DRIVER SD2
+#endif
+
diff --git a/platforms/chibios/boards/STEMCELL/configs/halconf.h b/platforms/chibios/boards/STEMCELL/configs/halconf.h
new file mode 100644
index 0000000000..f38949e626
--- /dev/null
+++ b/platforms/chibios/boards/STEMCELL/configs/halconf.h
@@ -0,0 +1,11 @@
+// Copyright 2022 Mega Mind (@megamind4089)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#define PAL_USE_WAIT TRUE
+#define PAL_USE_CALLBACKS TRUE
+#define HAL_USE_I2C TRUE
+#define HAL_USE_SERIAL TRUE
+
+#include_next <halconf.h>
diff --git a/platforms/chibios/boards/STEMCELL/configs/mcuconf.h b/platforms/chibios/boards/STEMCELL/configs/mcuconf.h
new file mode 100644
index 0000000000..db239854aa
--- /dev/null
+++ b/platforms/chibios/boards/STEMCELL/configs/mcuconf.h
@@ -0,0 +1,252 @@
+/*
+ ChibiOS - Copyright (C) 2006..2020 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#ifndef MCUCONF_H
+#define MCUCONF_H
+
+/*
+ * STM32F4xx drivers configuration.
+ * The following settings override the default settings present in
+ * the various device driver implementation headers.
+ * Note that the settings for each driver only have effect if the whole
+ * driver is enabled in halconf.h.
+ *
+ * IRQ priorities:
+ * 15...0 Lowest...Highest.
+ *
+ * DMA priorities:
+ * 0...3 Lowest...Highest.
+ */
+
+#define STM32F4xx_MCUCONF
+#define STM32F411_MCUCONF
+
+/*
+ * HAL driver system settings.
+ */
+#define STM32_NO_INIT FALSE
+#define STM32_PVD_ENABLE FALSE
+#define STM32_PLS STM32_PLS_LEV0
+#define STM32_BKPRAM_ENABLE FALSE
+#define STM32_HSI_ENABLED TRUE
+#define STM32_LSI_ENABLED TRUE
+#define STM32_HSE_ENABLED TRUE
+#define STM32_LSE_ENABLED FALSE
+#define STM32_CLOCK48_REQUIRED TRUE
+#define STM32_SW STM32_SW_PLL
+#define STM32_PLLSRC STM32_PLLSRC_HSE
+#define STM32_PLLM_VALUE 8
+#define STM32_PLLN_VALUE 336
+#define STM32_PLLP_VALUE 4
+#define STM32_PLLQ_VALUE 7
+#define STM32_HPRE STM32_HPRE_DIV1
+#define STM32_PPRE1 STM32_PPRE1_DIV2
+#define STM32_PPRE2 STM32_PPRE2_DIV1
+#define STM32_RTCSEL STM32_RTCSEL_LSI
+#define STM32_RTCPRE_VALUE 8
+#define STM32_MCO1SEL STM32_MCO1SEL_HSI
+#define STM32_MCO1PRE STM32_MCO1PRE_DIV1
+#define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK
+#define STM32_MCO2PRE STM32_MCO2PRE_DIV5
+#define STM32_I2SSRC STM32_I2SSRC_CKIN
+#define STM32_PLLI2SN_VALUE 192
+#define STM32_PLLI2SR_VALUE 5
+
+/*
+ * IRQ system settings.
+ */
+#define STM32_IRQ_EXTI0_PRIORITY 6
+#define STM32_IRQ_EXTI1_PRIORITY 6
+#define STM32_IRQ_EXTI2_PRIORITY 6
+#define STM32_IRQ_EXTI3_PRIORITY 6
+#define STM32_IRQ_EXTI4_PRIORITY 6
+#define STM32_IRQ_EXTI5_9_PRIORITY 6
+#define STM32_IRQ_EXTI10_15_PRIORITY 6
+#define STM32_IRQ_EXTI16_PRIORITY 6
+#define STM32_IRQ_EXTI17_PRIORITY 15
+#define STM32_IRQ_EXTI18_PRIORITY 6
+#define STM32_IRQ_EXTI19_PRIORITY 6
+#define STM32_IRQ_EXTI20_PRIORITY 6
+#define STM32_IRQ_EXTI21_PRIORITY 15
+#define STM32_IRQ_EXTI22_PRIORITY 15
+
+#define STM32_IRQ_TIM1_BRK_TIM9_PRIORITY 7
+#define STM32_IRQ_TIM1_UP_TIM10_PRIORITY 7
+#define STM32_IRQ_TIM1_TRGCO_TIM11_PRIORITY 7
+#define STM32_IRQ_TIM1_CC_PRIORITY 7
+#define STM32_IRQ_TIM2_PRIORITY 7
+#define STM32_IRQ_TIM3_PRIORITY 7
+#define STM32_IRQ_TIM4_PRIORITY 7
+#define STM32_IRQ_TIM5_PRIORITY 7
+
+#define STM32_IRQ_USART1_PRIORITY 12
+#define STM32_IRQ_USART2_PRIORITY 12
+#define STM32_IRQ_USART6_PRIORITY 12
+
+/*
+ * ADC driver system settings.
+ */
+#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4
+#define STM32_ADC_USE_ADC1 FALSE
+#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
+#define STM32_ADC_ADC1_DMA_PRIORITY 2
+#define STM32_ADC_IRQ_PRIORITY 6
+#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 6
+
+/*
+ * GPT driver system settings.
+ */
+#define STM32_GPT_USE_TIM1 FALSE
+#define STM32_GPT_USE_TIM2 FALSE
+#define STM32_GPT_USE_TIM3 FALSE
+#define STM32_GPT_USE_TIM4 FALSE
+#define STM32_GPT_USE_TIM5 FALSE
+#define STM32_GPT_USE_TIM9 FALSE
+#define STM32_GPT_USE_TIM10 FALSE
+#define STM32_GPT_USE_TIM11 FALSE
+
+/*
+ * I2C driver system settings.
+ */
+#define STM32_I2C_USE_I2C1 TRUE
+#define STM32_I2C_USE_I2C2 FALSE
+#define STM32_I2C_USE_I2C3 FALSE
+#define STM32_I2C_BUSY_TIMEOUT 50
+#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
+#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
+#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
+#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
+#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
+#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
+#define STM32_I2C_I2C1_IRQ_PRIORITY 5
+#define STM32_I2C_I2C2_IRQ_PRIORITY 5
+#define STM32_I2C_I2C3_IRQ_PRIORITY 5
+#define STM32_I2C_I2C1_DMA_PRIORITY 3
+#define STM32_I2C_I2C2_DMA_PRIORITY 3
+#define STM32_I2C_I2C3_DMA_PRIORITY 3
+#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
+
+/*
+ * I2S driver system settings.
+ */
+#define STM32_I2S_USE_SPI2 FALSE
+#define STM32_I2S_USE_SPI3 FALSE
+#define STM32_I2S_SPI2_IRQ_PRIORITY 10
+#define STM32_I2S_SPI3_IRQ_PRIORITY 10
+#define STM32_I2S_SPI2_DMA_PRIORITY 1
+#define STM32_I2S_SPI3_DMA_PRIORITY 1
+#define STM32_I2S_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
+#define STM32_I2S_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
+#define STM32_I2S_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
+#define STM32_I2S_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
+#define STM32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure")
+
+/*
+ * ICU driver system settings.
+ */
+#define STM32_ICU_USE_TIM1 FALSE
+#define STM32_ICU_USE_TIM2 FALSE
+#define STM32_ICU_USE_TIM3 FALSE
+#define STM32_ICU_USE_TIM4 FALSE
+#define STM32_ICU_USE_TIM5 FALSE
+#define STM32_ICU_USE_TIM9 FALSE
+#define STM32_ICU_USE_TIM10 FALSE
+#define STM32_ICU_USE_TIM11 FALSE
+
+/*
+ * PWM driver system settings.
+ */
+#define STM32_PWM_USE_TIM1 FALSE
+#define STM32_PWM_USE_TIM2 FALSE
+#define STM32_PWM_USE_TIM3 FALSE
+#define STM32_PWM_USE_TIM4 FALSE
+#define STM32_PWM_USE_TIM5 FALSE
+#define STM32_PWM_USE_TIM9 FALSE
+#define STM32_PWM_USE_TIM10 FALSE
+#define STM32_PWM_USE_TIM11 FALSE
+
+/*
+ * RTC driver system settings.
+ */
+#define STM32_RTC_PRESA_VALUE 32
+#define STM32_RTC_PRESS_VALUE 1024
+#define STM32_RTC_CR_INIT 0
+#define STM32_RTC_TAMPCR_INIT 0
+
+/*
+ * SERIAL driver system settings.
+ */
+#define STM32_SERIAL_USE_USART1 TRUE
+#define STM32_SERIAL_USE_USART2 TRUE
+#define STM32_SERIAL_USE_USART6 FALSE
+
+/*
+ * SPI driver system settings.
+ */
+#define STM32_SPI_USE_SPI1 FALSE
+#define STM32_SPI_USE_SPI2 FALSE
+#define STM32_SPI_USE_SPI3 FALSE
+#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0)
+#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
+#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
+#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
+#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
+#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
+#define STM32_SPI_SPI1_DMA_PRIORITY 1
+#define STM32_SPI_SPI2_DMA_PRIORITY 1
+#define STM32_SPI_SPI3_DMA_PRIORITY 1
+#define STM32_SPI_SPI1_IRQ_PRIORITY 10
+#define STM32_SPI_SPI2_IRQ_PRIORITY 10
+#define STM32_SPI_SPI3_IRQ_PRIORITY 10
+#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
+
+/*
+ * ST driver system settings.
+ */
+#define STM32_ST_IRQ_PRIORITY 8
+#define STM32_ST_USE_TIMER 2
+
+/*
+ * UART driver system settings.
+ */
+#define STM32_UART_USE_USART1 FALSE
+#define STM32_UART_USE_USART2 FALSE
+#define STM32_UART_USE_USART6 FALSE
+#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
+#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
+#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
+#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
+#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
+#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
+#define STM32_UART_USART1_DMA_PRIORITY 0
+#define STM32_UART_USART2_DMA_PRIORITY 0
+#define STM32_UART_USART6_DMA_PRIORITY 0
+#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
+
+/*
+ * USB driver system settings.
+ */
+#define STM32_USB_USE_OTG1 TRUE
+#define STM32_USB_OTG1_IRQ_PRIORITY 14
+#define STM32_USB_OTG1_RX_FIFO_SIZE 512
+#define STM32_USB_HOST_WAKEUP_DURATION 2
+
+/*
+ * WDG driver system settings.
+ */
+#define STM32_WDG_USE_IWDG FALSE
+
+#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.c b/platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.c
index cba977da77..e82e1d37ce 100644
--- a/platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.c
+++ b/platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.c
@@ -28,7 +28,9 @@ const PALConfig pal_default_config =
{VAL_GPIOBODR, VAL_GPIOBCRL, VAL_GPIOBCRH},
{VAL_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH},
{VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH},
+# if STM32_HAS_GPIOE
{VAL_GPIOEODR, VAL_GPIOECRL, VAL_GPIOECRH},
+# endif
};
#endif
diff --git a/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103x6_stm32duino_bootloader.ld b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103x6_stm32duino_bootloader.ld
new file mode 100644
index 0000000000..18aaff2a23
--- /dev/null
+++ b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103x6_stm32duino_bootloader.ld
@@ -0,0 +1,23 @@
+/*
+ ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/*
+ * STM32F103x6 memory setup for use with the STM32Duino bootloader.
+ */
+f103_flash_size = 32k;
+f103_ram_size = 10k;
+
+INCLUDE stm32duino_bootloader_common.ld
diff --git a/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103x8_stm32duino_bootloader.ld b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103x8_stm32duino_bootloader.ld
index a4bd566b59..465af12cab 100644
--- a/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103x8_stm32duino_bootloader.ld
+++ b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103x8_stm32duino_bootloader.ld
@@ -18,5 +18,6 @@
* STM32F103x8 memory setup for use with the STM32Duino bootloader.
*/
f103_flash_size = 64k;
+f103_ram_size = 20k;
INCLUDE stm32duino_bootloader_common.ld
diff --git a/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103xB_stm32duino_bootloader.ld b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103xB_stm32duino_bootloader.ld
index dc47400dc5..3a47a33156 100644
--- a/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103xB_stm32duino_bootloader.ld
+++ b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103xB_stm32duino_bootloader.ld
@@ -18,5 +18,6 @@
* STM32F103xB memory setup for use with the STM32Duino bootloader.
*/
f103_flash_size = 128k;
+f103_ram_size = 20k;
INCLUDE stm32duino_bootloader_common.ld
diff --git a/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/stm32duino_bootloader_common.ld b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/stm32duino_bootloader_common.ld
index 76cd3153be..1466ae7ed2 100644
--- a/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/stm32duino_bootloader_common.ld
+++ b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/stm32duino_bootloader_common.ld
@@ -27,7 +27,7 @@ MEMORY
flash5 : org = 0x00000000, len = 0
flash6 : org = 0x00000000, len = 0
flash7 : org = 0x00000000, len = 0
- ram0 : org = 0x20000000, len = 20k
+ ram0 : org = 0x20000000, len = f103_ram_size
ram1 : org = 0x00000000, len = 0
ram2 : org = 0x00000000, len = 0
ram3 : org = 0x00000000, len = 0
diff --git a/platforms/chibios/boards/common/ld/RP2040_FLASH_TIMECRIT.ld b/platforms/chibios/boards/common/ld/RP2040_FLASH_TIMECRIT.ld
new file mode 100644
index 0000000000..66ed4ce086
--- /dev/null
+++ b/platforms/chibios/boards/common/ld/RP2040_FLASH_TIMECRIT.ld
@@ -0,0 +1,117 @@
+/*
+ ChibiOS - Copyright (C) 2006..2021 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/*
+ * RP2040 memory setup.
+ */
+MEMORY
+{
+ flash0 (rx) : org = 0x00000000, len = 16k /* ROM */
+ flash1 (rx) : org = 0x10000000, len = DEFINED(FLASH_LEN) ? FLASH_LEN : 2048k /* XIP */
+ flash2 (rx) : org = 0x00000000, len = 0
+ flash3 (rx) : org = 0x00000000, len = 0
+ flash4 (rx) : org = 0x00000000, len = 0
+ flash5 (rx) : org = 0x00000000, len = 0
+ flash6 (rx) : org = 0x00000000, len = 0
+ flash7 (rx) : org = 0x00000000, len = 0
+ ram0 (wx) : org = 0x20000000, len = 256k /* SRAM0 striped */
+ ram1 (wx) : org = 0x00000000, len = 256k /* SRAM0 non striped */
+ ram2 (wx) : org = 0x00000000, len = 0
+ ram3 (wx) : org = 0x00000000, len = 0
+ ram4 (wx) : org = 0x20040000, len = 4k /* SRAM4 */
+ ram5 (wx) : org = 0x20041000, len = 4k /* SRAM5 */
+ ram6 (wx) : org = 0x00000000, len = 0
+ ram7 (wx) : org = 0x20041f00, len = 256 /* SRAM5 boot */
+}
+
+/* For each data/text section two region are defined, a virtual region
+ and a load region (_LMA suffix).*/
+
+/* Flash region to be used for exception vectors.*/
+REGION_ALIAS("VECTORS_FLASH", flash1);
+REGION_ALIAS("VECTORS_FLASH_LMA", flash1);
+
+/* Flash region to be used for constructors and destructors.*/
+REGION_ALIAS("XTORS_FLASH", flash1);
+REGION_ALIAS("XTORS_FLASH_LMA", flash1);
+
+/* Flash region to be used for code text.*/
+REGION_ALIAS("TEXT_FLASH", flash1);
+REGION_ALIAS("TEXT_FLASH_LMA", flash1);
+
+/* Flash region to be used for read only data.*/
+REGION_ALIAS("RODATA_FLASH", flash1);
+REGION_ALIAS("RODATA_FLASH_LMA", flash1);
+
+/* Flash region to be used for various.*/
+REGION_ALIAS("VARIOUS_FLASH", flash1);
+REGION_ALIAS("VARIOUS_FLASH_LMA", flash1);
+
+/* Flash region to be used for RAM(n) initialization data.*/
+REGION_ALIAS("RAM_INIT_FLASH_LMA", flash1);
+
+/* RAM region to be used for Main stack. This stack accommodates the processing
+ of all exceptions and interrupts.*/
+REGION_ALIAS("MAIN_STACK_RAM", ram4);
+
+/* RAM region to be used for the process stack. This is the stack used by
+ the main() function.*/
+REGION_ALIAS("PROCESS_STACK_RAM", ram4);
+
+/* RAM region to be used for Main stack. This stack accommodates the processing
+ of all exceptions and interrupts.*/
+REGION_ALIAS("C1_MAIN_STACK_RAM", ram5);
+
+/* RAM region to be used for the process stack. This is the stack used by
+ the main() function.*/
+REGION_ALIAS("C1_PROCESS_STACK_RAM", ram5);
+
+/* RAM region to be used for data segment.*/
+REGION_ALIAS("DATA_RAM", ram0);
+REGION_ALIAS("DATA_RAM_LMA", flash1);
+
+/* RAM region to be used for BSS segment.*/
+REGION_ALIAS("BSS_RAM", ram0);
+
+/* RAM region to be used for the default heap.*/
+REGION_ALIAS("HEAP_RAM", ram0);
+
+SECTIONS
+{
+ .flash_begin : {
+ __flash_binary_start = .;
+ } > flash1
+
+ .boot2 : {
+ __boot2_start__ = .;
+ KEEP (*(.boot2))
+ __boot2_end__ = .;
+ } > flash1
+}
+
+/* Generic rules inclusion.*/
+INCLUDE rules_stacks.ld
+INCLUDE rules_stacks_c1.ld
+INCLUDE RP2040_rules_code_with_boot2.ld
+INCLUDE RP2040_rules_data_with_timecrit.ld
+INCLUDE rules_memory.ld
+
+SECTIONS
+{
+ .flash_end : {
+ __flash_binary_end = .;
+ } > flash1
+}
diff --git a/platforms/chibios/boards/common/ld/RP2040_rules_data_with_timecrit.ld b/platforms/chibios/boards/common/ld/RP2040_rules_data_with_timecrit.ld
new file mode 100644
index 0000000000..a9a47be983
--- /dev/null
+++ b/platforms/chibios/boards/common/ld/RP2040_rules_data_with_timecrit.ld
@@ -0,0 +1,46 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+SECTIONS
+{
+ .data : ALIGN(4)
+ {
+ PROVIDE(_textdata = LOADADDR(.data));
+ PROVIDE(_data = .);
+ __textdata_base__ = LOADADDR(.data);
+ __data_base__ = .;
+ *(vtable)
+ *(.time_critical*)
+ . = ALIGN(4);
+ *(.data)
+ *(.data.*)
+ *(.ramtext)
+ . = ALIGN(4);
+ PROVIDE(_edata = .);
+ __data_end__ = .;
+ } > DATA_RAM AT > DATA_RAM_LMA
+
+ .bss (NOLOAD) : ALIGN(4)
+ {
+ __bss_base__ = .;
+ *(.bss)
+ *(.bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ PROVIDE(end = .);
+ } > BSS_RAM
+}
diff --git a/platforms/chibios/bootloaders/rp2040.c b/platforms/chibios/bootloaders/rp2040.c
new file mode 100644
index 0000000000..bedc00f32e
--- /dev/null
+++ b/platforms/chibios/bootloaders/rp2040.c
@@ -0,0 +1,56 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "quantum.h"
+#include "hal.h"
+#include "bootloader.h"
+#include "pico/bootrom.h"
+
+#if !defined(RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED)
+# define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED_MASK 0U
+#else
+# define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED_MASK (1U << RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED)
+#endif
+
+__attribute__((weak)) void mcu_reset(void) {
+ NVIC_SystemReset();
+}
+void bootloader_jump(void) {
+ reset_usb_boot(RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED_MASK, 0U);
+}
+
+void enter_bootloader_mode_if_requested(void) {}
+
+#if defined(RP2040_BOOTLOADER_DOUBLE_TAP_RESET)
+# if !defined(RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT)
+# define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 200U
+# endif
+
+// Needs to be located in a RAM section that is never initialized on boot to
+// preserve its value on reset
+static volatile uint32_t __attribute__((section(".ram0.bootloader_magic"))) magic_location;
+const uint32_t magic_token = 0xCAFEB0BA;
+
+// We can not use the __early_init / enter_bootloader_mode_if_requested hook as
+// we depend on an already initialized system with usable memory regions and
+// populated function pointer tables to the optimized math functions in the
+// bootrom. This function is called just prior to main.
+void __late_init(void) {
+ // All clocks have to be enabled before jumping to the bootloader function,
+ // otherwise the bootrom will be stuck infinitely.
+ clocks_init();
+
+ if (magic_location != magic_token) {
+ magic_location = magic_token;
+ // ChibiOS is not initialized at this point, so sleeping is only
+ // possible via busy waiting.
+ wait_us(RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT * 1000U);
+ magic_location = 0;
+ return;
+ }
+
+ magic_location = 0;
+ reset_usb_boot(RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED_MASK, 0U);
+}
+
+#endif
diff --git a/platforms/chibios/bootloaders/stm32_dfu.c b/platforms/chibios/bootloaders/stm32_dfu.c
index ff866bd2bc..7b4ab86033 100644
--- a/platforms/chibios/bootloaders/stm32_dfu.c
+++ b/platforms/chibios/bootloaders/stm32_dfu.c
@@ -38,7 +38,7 @@ extern uint32_t __ram0_end__;
# endif
# ifndef STM32_BOOTLOADER_DUAL_BANK_DELAY
-# define STM32_BOOTLOADER_DUAL_BANK_DELAY 100000
+# define STM32_BOOTLOADER_DUAL_BANK_DELAY 100
# endif
__attribute__((weak)) void bootloader_jump(void) {
@@ -55,7 +55,7 @@ __attribute__((weak)) void bootloader_jump(void) {
# endif
// Wait for a while for the capacitor to charge
- wait_ms(100);
+ wait_ms(STM32_BOOTLOADER_DUAL_BANK_DELAY);
// Issue a system reset to get the ROM bootloader to execute, with BOOT0 high
NVIC_SystemReset();
diff --git a/platforms/chibios/chibios_config.h b/platforms/chibios/chibios_config.h
index a7098f2713..8dcc23727f 100644
--- a/platforms/chibios/chibios_config.h
+++ b/platforms/chibios/chibios_config.h
@@ -19,6 +19,30 @@
# define SPLIT_USB_DETECT // Force this on when dedicated pin is not used
#endif
+#if defined(MCU_RP)
+# define CPU_CLOCK RP_CORE_CLK
+// ChibiOS uses the RP2040 timer peripheral as its real time counter, this timer
+// is monotonic and running at 1MHz.
+# define REALTIME_COUNTER_CLOCK 1000000
+
+# define USE_GPIOV1
+# define PAL_OUTPUT_TYPE_OPENDRAIN _Static_assert(0, "RP2040 has no Open Drain GPIO configuration, setting this is not possible");
+
+# define usb_lld_endpoint_fields
+
+# define I2C1_SCL_PAL_MODE (PAL_MODE_ALTERNATE_I2C | PAL_RP_PAD_SLEWFAST | PAL_RP_PAD_PUE | PAL_RP_PAD_DRIVE4)
+# define I2C1_SDA_PAL_MODE I2C1_SCL_PAL_MODE
+
+# define USE_I2CV1_CONTRIB
+# if !defined(I2C1_CLOCK_SPEED)
+# define I2C1_CLOCK_SPEED 400000
+# endif
+
+# define SPI_SCK_PAL_MODE (PAL_MODE_ALTERNATE_SPI | PAL_RP_PAD_SLEWFAST | PAL_RP_PAD_DRIVE4)
+# define SPI_MOSI_PAL_MODE SPI_SCK_PAL_MODE
+# define SPI_MISO_PAL_MODE SPI_SCK_PAL_MODE
+#endif
+
// STM32 compatibility
#if defined(MCU_STM32)
# define CPU_CLOCK STM32_SYSCLK
@@ -60,6 +84,8 @@
# define PAL_OUTPUT_TYPE_PUSHPULL PAL_WB32_OTYPE_PUSHPULL
# define PAL_OUTPUT_SPEED_HIGHEST PAL_WB32_OSPEED_HIGH
# define PAL_PUPDR_FLOATING PAL_WB32_PUPDR_FLOATING
+
+# define SPI_SCK_FLAGS PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST | PAL_WB32_CURRENT_LEVEL3
# endif
#endif
@@ -74,13 +100,18 @@
#if defined(MCU_KINETIS)
# define CPU_CLOCK KINETIS_SYSCLK_FREQUENCY
-# if defined(K20x) || defined(KL2x)
+# if defined(K20x) || defined(K60x) || defined(KL2x)
# define USE_I2CV1
# define USE_I2CV1_CONTRIB // for some reason a bunch of ChibiOS-Contrib boards only have clock_speed
# define USE_GPIOV1
# endif
#endif
+#if defined(MCU_MIMXRT1062)
+# include "clock_config.h"
+# define CPU_CLOCK BOARD_BOOTCLOCKRUN_CORE_CLOCK
+#endif
+
#if defined(HT32)
# define CPU_CLOCK HT32_CK_SYS_FREQUENCY
# define PAL_MODE_ALTERNATE PAL_HT32_MODE_AF
@@ -88,3 +119,20 @@
# define PAL_OUTPUT_TYPE_PUSHPULL PAL_HT32_MODE_DIR
# define PAL_OUTPUT_SPEED_HIGHEST 0
#endif
+
+#if !defined(REALTIME_COUNTER_CLOCK)
+# define REALTIME_COUNTER_CLOCK CPU_CLOCK
+#endif
+
+// SPI Fallbacks
+#ifndef SPI_SCK_FLAGS
+# define SPI_SCK_FLAGS PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST
+#endif
+
+#ifndef SPI_MOSI_FLAGS
+# define SPI_MOSI_FLAGS PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST
+#endif
+
+#ifndef SPI_MISO_FLAGS
+# define SPI_MISO_FLAGS PAL_MODE_ALTERNATE(SPI_MISO_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST
+#endif
diff --git a/platforms/chibios/converters/promicro_to_bit_c_pro/_pin_defs.h b/platforms/chibios/converters/promicro_to_bit_c_pro/_pin_defs.h
new file mode 100644
index 0000000000..a693e33011
--- /dev/null
+++ b/platforms/chibios/converters/promicro_to_bit_c_pro/_pin_defs.h
@@ -0,0 +1,36 @@
+// Copyright 2022 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+// Left side (front)
+#define D3 0U
+#define D2 1U
+// GND
+// GND
+#define D1 2U
+#define D0 3U
+#define D4 4U
+#define C6 5U
+#define D7 6U
+#define E6 7U
+#define B4 8U
+#define B5 9U
+
+// Right side (front)
+// RAW
+// GND
+// RESET
+// VCC
+#define F4 29U
+#define F5 28U
+#define F6 27U
+#define F7 26U
+#define B1 22U
+#define B3 20U
+#define B2 23U
+#define B6 21U
+
+// LEDs (Mapped to R and G channel of the Bit-C PRO's RGB led)
+#define D5 16U
+#define B0 17U
diff --git a/platforms/chibios/converters/promicro_to_bit_c_pro/converter.mk b/platforms/chibios/converters/promicro_to_bit_c_pro/converter.mk
new file mode 100644
index 0000000000..c0eaee8593
--- /dev/null
+++ b/platforms/chibios/converters/promicro_to_bit_c_pro/converter.mk
@@ -0,0 +1,12 @@
+# nullbits Bit-C PRO MCU settings for converting AVR projects
+MCU := RP2040
+BOARD := QMK_PM2040
+BOOTLOADER := rp2040
+
+# These are defaults based on what has been implemented for RP2040 boards
+SERIAL_DRIVER ?= vendor
+WS2812_DRIVER ?= vendor
+BACKLIGHT_DRIVER ?= software
+
+# Tell QMK to use the correct 2nd stage bootloader
+OPT_DEFS += -DRP2040_FLASH_W25X10CL
diff --git a/platforms/chibios/converters/promicro_to_blok/_pin_defs.h b/platforms/chibios/converters/promicro_to_blok/_pin_defs.h
new file mode 100644
index 0000000000..957b84e1a6
--- /dev/null
+++ b/platforms/chibios/converters/promicro_to_blok/_pin_defs.h
@@ -0,0 +1,36 @@
+// Copyright 2022 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+// Left side (front)
+#define D3 0U
+#define D2 1U
+// GND
+// GND
+#define D1 16U
+#define D0 17U
+#define D4 4U
+#define C6 5U
+#define D7 6U
+#define E6 7U
+#define B4 8U
+#define B5 9U
+
+// Right side (front)
+// RAW
+// GND
+// RESET
+// VCC
+#define F4 29U
+#define F5 28U
+#define F6 27U
+#define F7 26U
+#define B1 22U
+#define B3 20U
+#define B2 23U
+#define B6 21U
+
+// LEDs (Mapped to unused pins to avoid collisions)
+#define D5 12U
+#define B0 13U
diff --git a/platforms/chibios/converters/promicro_to_blok/converter.mk b/platforms/chibios/converters/promicro_to_blok/converter.mk
new file mode 100644
index 0000000000..5106e411f4
--- /dev/null
+++ b/platforms/chibios/converters/promicro_to_blok/converter.mk
@@ -0,0 +1,9 @@
+# Boardsource Blok MCU settings for converting AVR projects
+MCU := RP2040
+BOARD := QMK_PM2040
+BOOTLOADER := rp2040
+
+# These are defaults based on what has been implemented for RP2040 boards
+SERIAL_DRIVER ?= vendor
+WS2812_DRIVER ?= vendor
+BACKLIGHT_DRIVER ?= software
diff --git a/platforms/chibios/converters/promicro_to_bonsai_c4/_pin_defs.h b/platforms/chibios/converters/promicro_to_bonsai_c4/_pin_defs.h
new file mode 100644
index 0000000000..7e6b8ddaf2
--- /dev/null
+++ b/platforms/chibios/converters/promicro_to_bonsai_c4/_pin_defs.h
@@ -0,0 +1,40 @@
+// Copyright 2022 customMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+// Left side (front)
+#define D3 PAL_LINE(GPIOB, 7)
+#define D2 PAL_LINE(GPIOA, 15)
+// GND
+// GND
+#define D1 PAL_LINE(GPIOB, 9)
+#define D0 PAL_LINE(GPIOB, 6)
+#define D4 PAL_LINE(GPIOA, 4)
+#define C6 PAL_LINE(GPIOB, 8)
+#define D7 PAL_LINE(GPIOA, 3)
+#define E6 PAL_LINE(GPIOB, 10)
+#define B4 PAL_LINE(GPIOA, 8)
+#define B5 PAL_LINE(GPIOB, 0)
+
+// Right side (front)
+// RAW
+// GND
+// RESET
+// VCC
+#define F4 PAL_LINE(GPIOA, 7)
+#define F5 PAL_LINE(GPIOA, 6)
+#define F6 PAL_LINE(GPIOA, 5)
+#define F7 PAL_LINE(GPIOA, 1)
+#define B1 PAL_LINE(GPIOB, 13)
+#define B3 PAL_LINE(GPIOB, 14)
+#define B2 PAL_LINE(GPIOB, 15)
+#define B6 PAL_LINE(GPIOB, 1)
+
+// LEDs (only D5/B2 uses an actual LED)
+// Setting both RX and TX LEDs to the same pin as there
+// is only one LED availble
+// If this is undesirable, either B0 or B5 can be redefined by
+// using #undef and #define to change its assignment
+#define B0 PAL_LINE(GPIOB, 2)
+#define D5 PAL_LINE(GPIOB, 2) \ No newline at end of file
diff --git a/platforms/chibios/converters/promicro_to_bonsai_c4/converter.mk b/platforms/chibios/converters/promicro_to_bonsai_c4/converter.mk
new file mode 100644
index 0000000000..7410209b67
--- /dev/null
+++ b/platforms/chibios/converters/promicro_to_bonsai_c4/converter.mk
@@ -0,0 +1,4 @@
+# Proton C MCU settings for converting AVR projects
+MCU := STM32F411
+BOARD := GENERIC_STM32_F411XE
+BOOTLOADER := stm32-dfu \ No newline at end of file
diff --git a/platforms/chibios/converters/promicro_to_kb2040/_pin_defs.h b/platforms/chibios/converters/promicro_to_kb2040/_pin_defs.h
new file mode 100644
index 0000000000..0a3110890b
--- /dev/null
+++ b/platforms/chibios/converters/promicro_to_kb2040/_pin_defs.h
@@ -0,0 +1,36 @@
+// Copyright 2022 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+// Left side (front)
+#define D3 0U
+#define D2 1U
+// GND
+// GND
+#define D1 2U
+#define D0 3U
+#define D4 4U
+#define C6 5U
+#define D7 6U
+#define E6 7U
+#define B4 8U
+#define B5 9U
+
+// Right side (front)
+// RAW
+// GND
+// RESET
+// VCC
+#define F4 29U
+#define F5 28U
+#define F6 27U
+#define F7 26U
+#define B1 18U
+#define B3 20U
+#define B2 19U
+#define B6 10U
+
+// LEDs (Mapped to QT connector to avoid collisions with button/neopixel)
+#define D5 12U
+#define B0 13U
diff --git a/platforms/chibios/converters/promicro_to_kb2040/converter.mk b/platforms/chibios/converters/promicro_to_kb2040/converter.mk
new file mode 100644
index 0000000000..6ffee357b3
--- /dev/null
+++ b/platforms/chibios/converters/promicro_to_kb2040/converter.mk
@@ -0,0 +1,9 @@
+# Adafruit KB2040 MCU settings for converting AVR projects
+MCU := RP2040
+BOARD := QMK_PM2040
+BOOTLOADER := rp2040
+
+# These are defaults based on what has been implemented for RP2040 boards
+SERIAL_DRIVER ?= vendor
+WS2812_DRIVER ?= vendor
+BACKLIGHT_DRIVER ?= software
diff --git a/platforms/chibios/converters/promicro_to_promicro_rp2040/_pin_defs.h b/platforms/chibios/converters/promicro_to_promicro_rp2040/_pin_defs.h
new file mode 100644
index 0000000000..0a1f4112a3
--- /dev/null
+++ b/platforms/chibios/converters/promicro_to_promicro_rp2040/_pin_defs.h
@@ -0,0 +1,36 @@
+// Copyright 2022 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+// Left side (front)
+#define D3 0U
+#define D2 1U
+// GND
+// GND
+#define D1 2U
+#define D0 3U
+#define D4 4U
+#define C6 5U
+#define D7 6U
+#define E6 7U
+#define B4 8U
+#define B5 9U
+
+// Right side (front)
+// RAW
+// GND
+// RESET
+// VCC
+#define F4 29U
+#define F5 28U
+#define F6 27U
+#define F7 26U
+#define B1 22U
+#define B3 20U
+#define B2 23U
+#define B6 21U
+
+// LEDs (Mapped to QT connector to avoid collisions with button/neopixel)
+#define D5 17U
+#define B0 16U
diff --git a/platforms/chibios/converters/promicro_to_promicro_rp2040/converter.mk b/platforms/chibios/converters/promicro_to_promicro_rp2040/converter.mk
new file mode 100644
index 0000000000..03863eeb02
--- /dev/null
+++ b/platforms/chibios/converters/promicro_to_promicro_rp2040/converter.mk
@@ -0,0 +1,9 @@
+# Sparkfun Pro Micro RP2040 MCU settings for converting AVR projects
+MCU := RP2040
+BOARD := QMK_PM2040
+BOOTLOADER := rp2040
+
+# These are defaults based on what has been implemented for RP2040 boards
+SERIAL_DRIVER ?= vendor
+WS2812_DRIVER ?= vendor
+BACKLIGHT_DRIVER ?= software
diff --git a/platforms/chibios/converters/promicro_to_stemcell/_pin_defs.h b/platforms/chibios/converters/promicro_to_stemcell/_pin_defs.h
new file mode 100644
index 0000000000..a7b709f837
--- /dev/null
+++ b/platforms/chibios/converters/promicro_to_stemcell/_pin_defs.h
@@ -0,0 +1,51 @@
+// Copyright 2022 Mega Mind (@megamind4089)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+// Pindefs for v2.0.0
+// https://megamind4089.github.io/STeMCell/pinout/
+
+// Left side (front)
+#ifdef STEMCELL_UART_SWAP
+# define D3 PAL_LINE(GPIOA, 3)
+# define D2 PAL_LINE(GPIOA, 2)
+#else
+# define D3 PAL_LINE(GPIOA, 2)
+# define D2 PAL_LINE(GPIOA, 3)
+#endif
+// GND
+// GND
+#ifdef STEMCELL_I2C_SWAP
+# define D1 PAL_LINE(GPIOB, 6)
+# define D0 PAL_LINE(GPIOB, 7)
+#else
+# define D1 PAL_LINE(GPIOB, 7)
+# define D0 PAL_LINE(GPIOB, 6)
+#endif
+
+#define D4 PAL_LINE(GPIOA, 15)
+#define C6 PAL_LINE(GPIOB, 3)
+#define D7 PAL_LINE(GPIOB, 4)
+#define E6 PAL_LINE(GPIOB, 5)
+#define B4 PAL_LINE(GPIOB, 8)
+#define B5 PAL_LINE(GPIOB, 9)
+
+// Right side (front)
+// RAW
+// GND
+// RESET
+// VCC
+#define F4 PAL_LINE(GPIOB, 10)
+#define F5 PAL_LINE(GPIOB, 2)
+#define F6 PAL_LINE(GPIOB, 1)
+#define F7 PAL_LINE(GPIOB, 0)
+
+#define B1 PAL_LINE(GPIOA, 5)
+#define B3 PAL_LINE(GPIOA, 6)
+#define B2 PAL_LINE(GPIOA, 7)
+#define B6 PAL_LINE(GPIOA, 4)
+
+// LEDs
+#define D5 PAL_LINE(GPIOA, 8) // User LED
+#define B0 PAL_LINE(GPIOA, 9) // unconnected pin
diff --git a/platforms/chibios/converters/promicro_to_stemcell/converter.mk b/platforms/chibios/converters/promicro_to_stemcell/converter.mk
new file mode 100644
index 0000000000..1bbe9bf09e
--- /dev/null
+++ b/platforms/chibios/converters/promicro_to_stemcell/converter.mk
@@ -0,0 +1,18 @@
+# Copyright 2022 Mega Mind (@megamind4089)
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+MCU := STM32F411
+BOARD := STEMCELL
+BOOTLOADER := tinyuf2
+
+SERIAL_DRIVER ?= usart
+WS2812_DRIVER ?= bitbang
+
+ifeq ($(strip $(STMC_US)), yes)
+ OPT_DEFS += -DSTEMCELL_UART_SWAP
+endif
+
+ifeq ($(strip $(STMC_IS)), yes)
+ OPT_DEFS += -DSTEMCELL_I2C_SWAP
+endif
+
diff --git a/platforms/chibios/eeprom_stm32.c b/platforms/chibios/drivers/eeprom/eeprom_stm32.c
index a15bfe09ed..1a354dc213 100644
--- a/platforms/chibios/eeprom_stm32.c
+++ b/platforms/chibios/drivers/eeprom/eeprom_stm32.c
@@ -250,7 +250,7 @@ uint16_t EEPROM_Init(void) {
}
wvalue = ~*log_addr;
if (!wvalue) {
- eeprom_printf("Incomplete write at log_addr: 0x%04x;\n", (uint32_t)log_addr);
+ eeprom_printf("Incomplete write at log_addr: 0x%04lx;\n", (uint32_t)log_addr);
/* Possibly incomplete write. Ignore and continue */
continue;
}
@@ -261,7 +261,7 @@ uint16_t EEPROM_Init(void) {
} else {
/* Reserved for future use */
if (address & FEE_VALUE_RESERVED) {
- eeprom_printf("Reserved encoded value at log_addr: 0x%04x;\n", (uint32_t)log_addr);
+ eeprom_printf("Reserved encoded value at log_addr: 0x%04lx;\n", (uint32_t)log_addr);
continue;
}
/* Optimization for 0 or 1 values. */
@@ -293,14 +293,14 @@ static void eeprom_clear(void) {
FLASH_Unlock();
for (uint16_t page_num = 0; page_num < FEE_PAGE_COUNT; ++page_num) {
- eeprom_printf("FLASH_ErasePage(0x%04x)\n", (uint32_t)(FEE_PAGE_BASE_ADDRESS + (page_num * FEE_PAGE_SIZE)));
+ eeprom_printf("FLASH_ErasePage(0x%04lx)\n", (uint32_t)(FEE_PAGE_BASE_ADDRESS + (page_num * FEE_PAGE_SIZE)));
FLASH_ErasePage(FEE_PAGE_BASE_ADDRESS + (page_num * FEE_PAGE_SIZE));
}
FLASH_Lock();
empty_slot = (uint16_t *)FEE_WRITE_LOG_BASE_ADDRESS;
- eeprom_printf("eeprom_clear empty_slot: 0x%08x\n", (uint32_t)empty_slot);
+ eeprom_printf("eeprom_clear empty_slot: 0x%08lx\n", (uint32_t)empty_slot);
}
/* Erase emulated eeprom */
@@ -328,7 +328,7 @@ static uint8_t eeprom_compact(void) {
for (; dest < FEE_COMPACTED_LAST_ADDRESS; ++src, dest += 2) {
value = *src;
if (value) {
- eeprom_printf("FLASH_ProgramHalfWord(0x%04x, 0x%04x)\n", (uint32_t)dest, ~value);
+ eeprom_printf("FLASH_ProgramHalfWord(0x%04lx, 0x%04x)\n", (uint32_t)dest, ~value);
FLASH_Status status = FLASH_ProgramHalfWord(dest, ~value);
if (status != FLASH_COMPLETE) final_status = status;
}
@@ -355,7 +355,7 @@ static uint8_t eeprom_write_direct_entry(uint16_t Address) {
FLASH_Unlock();
- eeprom_printf("FLASH_ProgramHalfWord(0x%08x, 0x%04x) [DIRECT]\n", (uint32_t)directAddress, value);
+ eeprom_printf("FLASH_ProgramHalfWord(0x%08lx, 0x%04x) [DIRECT]\n", (uint32_t)directAddress, value);
FLASH_Status status = FLASH_ProgramHalfWord(directAddress, value);
FLASH_Lock();
@@ -397,12 +397,12 @@ static uint8_t eeprom_write_log_word_entry(uint16_t Address) {
FLASH_Unlock();
/* address */
- eeprom_printf("FLASH_ProgramHalfWord(0x%08x, 0x%04x)\n", (uint32_t)empty_slot, Address);
+ eeprom_printf("FLASH_ProgramHalfWord(0x%08lx, 0x%04x)\n", (uint32_t)empty_slot, Address);
final_status = FLASH_ProgramHalfWord((uintptr_t)empty_slot++, Address);
/* value */
if (encoding == (FEE_WORD_ENCODING | FEE_VALUE_NEXT)) {
- eeprom_printf("FLASH_ProgramHalfWord(0x%08x, 0x%04x)\n", (uint32_t)empty_slot, ~value);
+ eeprom_printf("FLASH_ProgramHalfWord(0x%08lx, 0x%04x)\n", (uint32_t)empty_slot, ~value);
FLASH_Status status = FLASH_ProgramHalfWord((uintptr_t)empty_slot++, ~value);
if (status != FLASH_COMPLETE) final_status = status;
}
@@ -428,7 +428,7 @@ static uint8_t eeprom_write_log_byte_entry(uint16_t Address) {
uint16_t value = (Address << 8) | DataBuf[Address];
/* write to flash */
- eeprom_printf("FLASH_ProgramHalfWord(0x%08x, 0x%04x)\n", (uint32_t)empty_slot, value);
+ eeprom_printf("FLASH_ProgramHalfWord(0x%08lx, 0x%04x)\n", (uint32_t)empty_slot, value);
FLASH_Status status = FLASH_ProgramHalfWord((uintptr_t)empty_slot++, value);
FLASH_Lock();
diff --git a/platforms/chibios/eeprom_stm32.h b/platforms/chibios/drivers/eeprom/eeprom_stm32.h
index 8fcfb556b8..8fcfb556b8 100644
--- a/platforms/chibios/eeprom_stm32.h
+++ b/platforms/chibios/drivers/eeprom/eeprom_stm32.h
diff --git a/platforms/chibios/eeprom_stm32_defs.h b/platforms/chibios/drivers/eeprom/eeprom_stm32_defs.h
index 57d0440330..57d0440330 100644
--- a/platforms/chibios/eeprom_stm32_defs.h
+++ b/platforms/chibios/drivers/eeprom/eeprom_stm32_defs.h
diff --git a/platforms/chibios/eeprom_teensy.c b/platforms/chibios/drivers/eeprom/eeprom_teensy.c
index c8777febde..c8777febde 100644
--- a/platforms/chibios/eeprom_teensy.c
+++ b/platforms/chibios/drivers/eeprom/eeprom_teensy.c
diff --git a/platforms/chibios/eeprom_teensy.h b/platforms/chibios/drivers/eeprom/eeprom_teensy.h
index 9a14a1fa79..9a14a1fa79 100755
--- a/platforms/chibios/eeprom_teensy.h
+++ b/platforms/chibios/drivers/eeprom/eeprom_teensy.h
diff --git a/platforms/chibios/flash_stm32.c b/platforms/chibios/drivers/flash/flash_stm32.c
index 72c41b8b78..72c41b8b78 100644
--- a/platforms/chibios/flash_stm32.c
+++ b/platforms/chibios/drivers/flash/flash_stm32.c
diff --git a/platforms/chibios/flash_stm32.h b/platforms/chibios/drivers/flash/flash_stm32.h
index 6c66642ec5..6c66642ec5 100644
--- a/platforms/chibios/flash_stm32.h
+++ b/platforms/chibios/drivers/flash/flash_stm32.h
diff --git a/platforms/chibios/drivers/i2c_master.c b/platforms/chibios/drivers/i2c_master.c
index 21e064b1dc..4c7a5daa17 100644
--- a/platforms/chibios/drivers/i2c_master.c
+++ b/platforms/chibios/drivers/i2c_master.c
@@ -107,16 +107,25 @@ static const I2CConfig i2cconfig = {
#endif
};
-static i2c_status_t chibios_to_qmk(const msg_t* status) {
- switch (*status) {
- case I2C_NO_ERROR:
- return I2C_STATUS_SUCCESS;
- case I2C_TIMEOUT:
- return I2C_STATUS_TIMEOUT;
- // I2C_BUS_ERROR, I2C_ARBITRATION_LOST, I2C_ACK_FAILURE, I2C_OVERRUN, I2C_PEC_ERROR, I2C_SMB_ALERT
- default:
- return I2C_STATUS_ERROR;
+/**
+ * @brief Handles any I2C error condition by stopping the I2C peripheral and
+ * aborting any ongoing transactions. Furthermore ChibiOS status codes are
+ * converted into QMK codes.
+ *
+ * @param status ChibiOS specific I2C status code
+ * @return i2c_status_t QMK specific I2C status code
+ */
+static i2c_status_t i2c_epilogue(const msg_t status) {
+ if (status == MSG_OK) {
+ return I2C_STATUS_SUCCESS;
}
+
+ // From ChibiOS HAL: "After a timeout the driver must be stopped and
+ // restarted because the bus is in an uncertain state." We also issue that
+ // hard stop in case of any error.
+ i2c_stop();
+
+ return status == MSG_TIMEOUT ? I2C_STATUS_TIMEOUT : I2C_STATUS_ERROR;
}
__attribute__((weak)) void i2c_init(void) {
@@ -149,14 +158,14 @@ i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length,
i2c_address = address;
i2cStart(&I2C_DRIVER, &i2cconfig);
msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, TIME_MS2I(timeout));
- return chibios_to_qmk(&status);
+ return i2c_epilogue(status);
}
i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) {
i2c_address = address;
i2cStart(&I2C_DRIVER, &i2cconfig);
msg_t status = i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, TIME_MS2I(timeout));
- return chibios_to_qmk(&status);
+ return i2c_epilogue(status);
}
i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) {
@@ -170,7 +179,7 @@ i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data,
complete_packet[0] = regaddr;
msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 1, 0, 0, TIME_MS2I(timeout));
- return chibios_to_qmk(&status);
+ return i2c_epilogue(status);
}
i2c_status_t i2c_writeReg16(uint8_t devaddr, uint16_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) {
@@ -185,14 +194,14 @@ i2c_status_t i2c_writeReg16(uint8_t devaddr, uint16_t regaddr, const uint8_t* da
complete_packet[1] = regaddr & 0xFF;
msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 2, 0, 0, TIME_MS2I(timeout));
- return chibios_to_qmk(&status);
+ return i2c_epilogue(status);
}
i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) {
i2c_address = devaddr;
i2cStart(&I2C_DRIVER, &i2cconfig);
msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), &regaddr, 1, data, length, TIME_MS2I(timeout));
- return chibios_to_qmk(&status);
+ return i2c_epilogue(status);
}
i2c_status_t i2c_readReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) {
@@ -200,7 +209,7 @@ i2c_status_t i2c_readReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uin
i2cStart(&I2C_DRIVER, &i2cconfig);
uint8_t register_packet[2] = {regaddr >> 8, regaddr & 0xFF};
msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), register_packet, 2, data, length, TIME_MS2I(timeout));
- return chibios_to_qmk(&status);
+ return i2c_epilogue(status);
}
void i2c_stop(void) {
diff --git a/platforms/chibios/drivers/serial.c b/platforms/chibios/drivers/serial.c
index 0cff057d1d..0dd8e71ae8 100644
--- a/platforms/chibios/drivers/serial.c
+++ b/platforms/chibios/drivers/serial.c
@@ -20,7 +20,8 @@
# error "chSysPolledDelayX method not supported on this platform"
#else
# undef wait_us
-# define wait_us(x) chSysPolledDelayX(US2RTC(CPU_CLOCK, x))
+// Force usage of polled waiting - in case WAIT_US_TIMER is activated
+# define wait_us(us) chSysPolledDelayX(US2RTC(REALTIME_COUNTER_CLOCK, us))
#endif
#ifndef SELECT_SOFT_SERIAL_SPEED
@@ -87,10 +88,7 @@ static THD_FUNCTION(Thread1, arg) {
chRegSetThreadName("blinker");
while (true) {
palWaitLineTimeout(SOFT_SERIAL_PIN, TIME_INFINITE);
-
- split_shared_memory_lock();
interrupt_handler(NULL);
- split_shared_memory_unlock();
}
}
@@ -155,6 +153,7 @@ static void __attribute__((noinline)) serial_write_byte(uint8_t data) {
// interrupt handle to be used by the slave device
void interrupt_handler(void *arg) {
+ split_shared_memory_lock_autounlock();
chSysLockFromISR();
sync_send();
@@ -212,6 +211,8 @@ void interrupt_handler(void *arg) {
static inline bool initiate_transaction(uint8_t sstd_index) {
if (sstd_index > NUM_TOTAL_TRANSACTIONS) return false;
+ split_shared_memory_lock_autounlock();
+
split_transaction_desc_t *trans = &split_transaction_table[sstd_index];
// TODO: remove extra delay between transactions
@@ -233,7 +234,7 @@ static inline bool initiate_transaction(uint8_t sstd_index) {
// check if the slave is present
if (serial_read_pin()) {
// slave failed to pull the line low, assume not present
- dprintf("serial::NO_RESPONSE\n");
+ serial_dprintf("serial::NO_RESPONSE\n");
chSysUnlock();
return false;
}
@@ -269,7 +270,7 @@ static inline bool initiate_transaction(uint8_t sstd_index) {
serial_delay();
if ((checksum_computed) != (checksum_received)) {
- dprintf("serial::FAIL[%u,%u,%u]\n", checksum_computed, checksum_received, sstd_index);
+ serial_dprintf("serial::FAIL[%u,%u,%u]\n", checksum_computed, checksum_received, sstd_index);
serial_output();
serial_high();
@@ -292,8 +293,5 @@ static inline bool initiate_transaction(uint8_t sstd_index) {
//
// this code is very time dependent, so we need to disable interrupts
bool soft_serial_transaction(int sstd_index) {
- split_shared_memory_lock();
- bool result = initiate_transaction((uint8_t)sstd_index);
- split_shared_memory_unlock();
- return result;
+ return initiate_transaction((uint8_t)sstd_index);
}
diff --git a/platforms/chibios/drivers/serial_protocol.c b/platforms/chibios/drivers/serial_protocol.c
new file mode 100644
index 0000000000..c95aed9885
--- /dev/null
+++ b/platforms/chibios/drivers/serial_protocol.c
@@ -0,0 +1,164 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <ch.h>
+
+#include "quantum.h"
+#include "serial.h"
+#include "serial_protocol.h"
+#include "printf.h"
+#include "synchronization_util.h"
+
+static inline bool initiate_transaction(uint8_t transaction_id);
+static inline bool react_to_transaction(void);
+
+/**
+ * @brief This thread runs on the slave and responds to transactions initiated
+ * by the master.
+ */
+static THD_WORKING_AREA(waSlaveThread, 1024);
+static THD_FUNCTION(SlaveThread, arg) {
+ (void)arg;
+ chRegSetThreadName("split_protocol_tx_rx");
+
+ while (true) {
+ if (unlikely(!react_to_transaction())) {
+ /* Clear the receive queue, to start with a clean slate.
+ * Parts of failed transactions or spurious bytes could still be in it. */
+ serial_transport_driver_clear();
+ }
+ }
+}
+
+/**
+ * @brief Slave specific initializations.
+ */
+void soft_serial_target_init(void) {
+ serial_transport_driver_slave_init();
+
+ /* Start transport thread. */
+ chThdCreateStatic(waSlaveThread, sizeof(waSlaveThread), HIGHPRIO, SlaveThread, NULL);
+}
+
+/**
+ * @brief Master specific initializations.
+ */
+void soft_serial_initiator_init(void) {
+ serial_transport_driver_master_init();
+}
+
+/**
+ * @brief React to transactions started by the master.
+ */
+static inline bool react_to_transaction(void) {
+ uint8_t transaction_id = 0;
+ /* Wait until there is a transaction for us. */
+ if (unlikely(!serial_transport_receive_blocking(&transaction_id, sizeof(transaction_id)))) {
+ return false;
+ }
+
+ /* Sanity check that we are actually responding to a valid transaction. */
+ if (unlikely(transaction_id >= NUM_TOTAL_TRANSACTIONS)) {
+ return false;
+ }
+
+ split_shared_memory_lock_autounlock();
+
+ split_transaction_desc_t* transaction = &split_transaction_table[transaction_id];
+
+ /* Send back the handshake which is XORed as a simple checksum,
+ to signal that the slave is ready to receive possible transaction buffers */
+ transaction_id ^= NUM_TOTAL_TRANSACTIONS;
+ if (unlikely(!serial_transport_send(&transaction_id, sizeof(transaction_id)))) {
+ return false;
+ }
+
+ /* Receive transaction buffer from the master. If this transaction requires it.*/
+ if (transaction->initiator2target_buffer_size) {
+ if (unlikely(!serial_transport_receive(split_trans_initiator2target_buffer(transaction), transaction->initiator2target_buffer_size))) {
+ return false;
+ }
+ }
+
+ /* Allow any slave processing to occur. */
+ if (transaction->slave_callback) {
+ transaction->slave_callback(transaction->initiator2target_buffer_size, split_trans_initiator2target_buffer(transaction), transaction->initiator2target_buffer_size, split_trans_target2initiator_buffer(transaction));
+ }
+
+ /* Send transaction buffer to the master. If this transaction requires it. */
+ if (transaction->target2initiator_buffer_size) {
+ if (unlikely(!serial_transport_send(split_trans_target2initiator_buffer(transaction), transaction->target2initiator_buffer_size))) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/**
+ * @brief Start transaction from the master half to the slave half.
+ *
+ * @param index Transaction Table index of the transaction to start.
+ * @return bool Indicates success of transaction.
+ */
+bool soft_serial_transaction(int index) {
+ bool result = initiate_transaction((uint8_t)index);
+
+ if (unlikely(!result)) {
+ /* Clear the receive queue, to start with a clean slate.
+ * Parts of failed transactions or spurious bytes could still be in it. */
+ serial_transport_driver_clear();
+ }
+
+ return result;
+}
+
+/**
+ * @brief Initiate transaction to slave half.
+ */
+static inline bool initiate_transaction(uint8_t transaction_id) {
+ /* Sanity check that we are actually starting a valid transaction. */
+ if (unlikely(transaction_id >= NUM_TOTAL_TRANSACTIONS)) {
+ serial_dprintf("SPLIT: illegal transaction id\n");
+ return false;
+ }
+
+ split_shared_memory_lock_autounlock();
+
+ split_transaction_desc_t* transaction = &split_transaction_table[transaction_id];
+
+ /* Send transaction table index to the slave, which doubles as basic handshake token. */
+ if (unlikely(!serial_transport_send(&transaction_id, sizeof(transaction_id)))) {
+ serial_dprintf("SPLIT: sending handshake failed\n");
+ return false;
+ }
+
+ uint8_t transaction_id_shake = 0xFF;
+
+ /* Which we always read back first so that we can error out correctly.
+ * - due to the half duplex limitations on return codes, we always have to read *something*.
+ * - without the read, write only transactions *always* succeed, even during the boot process where the slave is not ready.
+ */
+ if (unlikely(!serial_transport_receive(&transaction_id_shake, sizeof(transaction_id_shake)) || (transaction_id_shake != (transaction_id ^ NUM_TOTAL_TRANSACTIONS)))) {
+ serial_dprintf("SPLIT: receiving handshake failed\n");
+ return false;
+ }
+
+ /* Send transaction buffer to the slave. If this transaction requires it. */
+ if (transaction->initiator2target_buffer_size) {
+ if (unlikely(!serial_transport_send(split_trans_initiator2target_buffer(transaction), transaction->initiator2target_buffer_size))) {
+ serial_dprintf("SPLIT: sending buffer failed\n");
+ return false;
+ }
+ }
+
+ /* Receive transaction buffer from the slave. If this transaction requires it. */
+ if (transaction->target2initiator_buffer_size) {
+ if (unlikely(!serial_transport_receive(split_trans_target2initiator_buffer(transaction), transaction->target2initiator_buffer_size))) {
+ serial_dprintf("SPLIT: receiving buffer failed\n");
+ return false;
+ }
+ }
+
+ return true;
+}
diff --git a/platforms/chibios/drivers/serial_protocol.h b/platforms/chibios/drivers/serial_protocol.h
new file mode 100644
index 0000000000..4275a7f8d8
--- /dev/null
+++ b/platforms/chibios/drivers/serial_protocol.h
@@ -0,0 +1,49 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#pragma once
+
+/**
+ * @brief Clears any intermediate sending or receiving state of the driver to a known good
+ * state. This happens after errors in the middle of transactions, to start with
+ * a clean slate.
+ */
+void serial_transport_driver_clear(void);
+
+/**
+ * @brief Driver specific initialization on the slave half.
+ */
+void serial_transport_driver_slave_init(void);
+
+/**
+ * @brief Driver specific specific initialization on the master half.
+ */
+void serial_transport_driver_master_init(void);
+
+/**
+ * @brief Blocking receive of size * bytes.
+ *
+ * @return true Receive success.
+ * @return false Receive failed, e.g. by bit errors.
+ */
+bool __attribute__((nonnull, hot)) serial_transport_receive(uint8_t* destination, const size_t size);
+
+/**
+ * @brief Blocking receive of size * bytes with an implicitly defined timeout.
+ *
+ * @return true Receive success.
+ * @return false Receive failed, e.g. by timeout or bit errors.
+ */
+bool __attribute__((nonnull, hot)) serial_transport_receive_blocking(uint8_t* destination, const size_t size);
+
+/**
+ * @brief Blocking send of buffer with timeout.
+ *
+ * @return true Send success.
+ * @return false Send failed, e.g. by timeout or bit errors.
+ */
+bool __attribute__((nonnull, hot)) serial_transport_send(const uint8_t* source, const size_t size);
diff --git a/platforms/chibios/drivers/serial_usart.c b/platforms/chibios/drivers/serial_usart.c
index e9fa4af7a3..6581a5b6e9 100644
--- a/platforms/chibios/drivers/serial_usart.c
+++ b/platforms/chibios/drivers/serial_usart.c
@@ -1,49 +1,55 @@
-/* Copyright 2021 QMK
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+// Copyright 2021 QMK
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
#include "serial_usart.h"
+#include "serial_protocol.h"
#include "synchronization_util.h"
#if defined(SERIAL_USART_CONFIG)
-static SerialConfig serial_config = SERIAL_USART_CONFIG;
-#else
-static SerialConfig serial_config = {
- .speed = (SERIAL_USART_SPEED), /* speed - mandatory */
+static QMKSerialConfig serial_config = SERIAL_USART_CONFIG;
+#elif defined(MCU_STM32) /* STM32 MCUs */
+static QMKSerialConfig serial_config = {
+# if HAL_USE_SERIAL
+ .speed = (SERIAL_USART_SPEED),
+# else
+ .baud = (SERIAL_USART_SPEED),
+# endif
.cr1 = (SERIAL_USART_CR1),
.cr2 = (SERIAL_USART_CR2),
# if !defined(SERIAL_USART_FULL_DUPLEX)
.cr3 = ((SERIAL_USART_CR3) | USART_CR3_HDSEL) /* activate half-duplex mode */
# else
- .cr3 = (SERIAL_USART_CR3)
+ .cr3 = (SERIAL_USART_CR3)
# endif
};
+#elif defined(MCU_RP) /* Raspberry Pi MCUs */
+/* USART in 8E2 config with RX and TX FIFOs enabled. */
+// clang-format off
+static QMKSerialConfig serial_config = {
+ .baud = (SERIAL_USART_SPEED),
+ .UARTLCR_H = UART_UARTLCR_H_WLEN_8BITS | UART_UARTLCR_H_PEN | UART_UARTLCR_H_STP2 | UART_UARTLCR_H_FEN,
+ .UARTCR = 0U,
+ .UARTIFLS = UART_UARTIFLS_RXIFLSEL_1_8F | UART_UARTIFLS_TXIFLSEL_1_8E,
+ .UARTDMACR = 0U
+};
+// clang-format on
+#else
+# error MCU Familiy not supported by default, supply your own serial_config by defining SERIAL_USART_CONFIG in your keyboard files.
#endif
-static SerialDriver* serial_driver = &SERIAL_USART_DRIVER;
+static QMKSerialDriver* serial_driver = (QMKSerialDriver*)&SERIAL_USART_DRIVER;
-static inline bool react_to_transactions(void);
-static inline bool __attribute__((nonnull)) receive(uint8_t* destination, const size_t size);
-static inline bool __attribute__((nonnull)) send(const uint8_t* source, const size_t size);
-static inline bool initiate_transaction(uint8_t sstd_index);
-static inline void usart_clear(void);
+#if HAL_USE_SERIAL
/**
- * @brief Clear the receive input queue.
+ * @brief SERIAL Driver startup routine.
*/
-static inline void usart_clear(void) {
+static inline void usart_driver_start(void) {
+ sdStart(serial_driver, &serial_config);
+}
+
+inline void serial_transport_driver_clear(void) {
osalSysLock();
bool volatile queue_not_empty = !iqIsEmptyI(&serial_driver->iqueue);
osalSysUnlock();
@@ -64,36 +70,96 @@ static inline void usart_clear(void) {
}
}
+#elif HAL_USE_SIO
+
+void clear_rx_evt_cb(SIODriver* siop) {
+ osalSysLockFromISR();
+ /* If errors occured during transactions this callback is invoked. We just
+ * clear the error sources and move on. We rely on the fact that we check
+ * for the success of the transaction by comparing the received/send bytes
+ * with the actual received/send bytes in the send/receive functions. */
+ sioGetAndClearEventsI(serial_driver);
+ osalSysUnlockFromISR();
+}
+
+static const SIOOperation serial_usart_operation = {.rx_cb = NULL, .rx_idle_cb = NULL, .tx_cb = NULL, .tx_end_cb = NULL, .rx_evt_cb = &clear_rx_evt_cb};
+
/**
- * @brief Blocking send of buffer with timeout.
- *
- * @return true Send success.
- * @return false Send failed.
+ * @brief SIO Driver startup routine.
*/
-static inline bool send(const uint8_t* source, const size_t size) {
- bool success = (size_t)sdWriteTimeout(serial_driver, source, size, TIME_MS2I(SERIAL_USART_TIMEOUT)) == size;
+static inline void usart_driver_start(void) {
+ sioStart(serial_driver, &serial_config);
+ sioStartOperation(serial_driver, &serial_usart_operation);
+}
+
+inline void serial_transport_driver_clear(void) {
+ osalSysLock();
+ while (!sioIsRXEmptyX(serial_driver)) {
+ (void)sioGetX(serial_driver);
+ }
+ osalSysUnlock();
+}
+
+#else
+
+# error Either the SERIAL or SIO driver has to be activated to use the usart driver for split keyboards.
+
+#endif
+
+inline bool serial_transport_send(const uint8_t* source, const size_t size) {
+ bool success = (size_t)chnWriteTimeout(serial_driver, source, size, TIME_MS2I(SERIAL_USART_TIMEOUT)) == size;
#if !defined(SERIAL_USART_FULL_DUPLEX)
- if (success) {
- /* Half duplex fills the input queue with the data we wrote - just throw it away.
- Under the right circumstances (e.g. bad cables paired with high baud rates)
- less bytes can be present in the input queue, therefore a timeout is needed. */
- uint8_t dump[size];
- return receive(dump, size);
+ /* Half duplex fills the input queue with the data we wrote - just throw it away. */
+ if (likely(success)) {
+ size_t bytes_left = size;
+# if HAL_USE_SERIAL
+ /* The SERIAL driver uses large soft FIFOs that are filled from an IRQ
+ * context, so there is a delay between receiving the data and it
+ * becoming actually available, therefore we have to apply a timeout
+ * mechanism. Under the right circumstances (e.g. bad cables paired with
+ * high baud rates) less bytes can be present in the input queue as
+ * well. */
+ uint8_t dump[64];
+
+ while (unlikely(bytes_left >= 64)) {
+ if (unlikely(!serial_transport_receive(dump, 64))) {
+ return false;
+ }
+ bytes_left -= 64;
+ }
+
+ return serial_transport_receive(dump, bytes_left);
+# else
+ /* The SIO driver directly accesses the hardware FIFOs of the USART
+ * peripheral. As these are limited in depth, the RX FIFO might have been
+ * overflowed by a large that we just send. Therefore we attempt to read
+ * back all the data we send or until the FIFO runs empty in case it
+ * overflowed and data was truncated. */
+ if (unlikely(sioSynchronizeTXEnd(serial_driver, TIME_MS2I(SERIAL_USART_TIMEOUT)) < MSG_OK)) {
+ return false;
+ }
+
+ osalSysLock();
+ while (bytes_left > 0 && !sioIsRXEmptyX(serial_driver)) {
+ (void)sioGetX(serial_driver);
+ bytes_left--;
+ }
+ osalSysUnlock();
+# endif
}
#endif
return success;
}
-/**
- * @brief Blocking receive of size * bytes with timeout.
- *
- * @return true Receive success.
- * @return false Receive failed.
- */
-static inline bool receive(uint8_t* destination, const size_t size) {
- bool success = (size_t)sdReadTimeout(serial_driver, destination, size, TIME_MS2I(SERIAL_USART_TIMEOUT)) == size;
+inline bool serial_transport_receive(uint8_t* destination, const size_t size) {
+ bool success = (size_t)chnReadTimeout(serial_driver, destination, size, TIME_MS2I(SERIAL_USART_TIMEOUT)) == size;
+ return success;
+}
+
+inline bool serial_transport_receive_blocking(uint8_t* destination, const size_t size) {
+ bool success = (size_t)chnRead(serial_driver, destination, size) == size;
return success;
}
@@ -103,7 +169,7 @@ static inline bool receive(uint8_t* destination, const size_t size) {
* @brief Initiate pins for USART peripheral. Half-duplex configuration.
*/
__attribute__((weak)) void usart_init(void) {
-# if defined(MCU_STM32)
+# if defined(MCU_STM32) /* STM32 MCUs */
# if defined(USE_GPIOV1)
palSetLineMode(SERIAL_USART_TX_PIN, PAL_MODE_ALTERNATE_OPENDRAIN);
# else
@@ -113,6 +179,8 @@ __attribute__((weak)) void usart_init(void) {
# if defined(USART_REMAP)
USART_REMAP;
# endif
+# elif defined(MCU_RP) /* Raspberry Pi MCUs */
+# error Half-duplex with the SIO driver is not supported due to hardware limitations on the RP2040, switch to the PIO driver which has half-duplex support.
# else
# pragma message "usart_init: MCU Familiy not supported by default, please supply your own init code by implementing usart_init() in your keyboard files."
# endif
@@ -124,7 +192,7 @@ __attribute__((weak)) void usart_init(void) {
* @brief Initiate pins for USART peripheral. Full-duplex configuration.
*/
__attribute__((weak)) void usart_init(void) {
-# if defined(MCU_STM32)
+# if defined(MCU_STM32) /* STM32 MCUs */
# if defined(USE_GPIOV1)
palSetLineMode(SERIAL_USART_TX_PIN, PAL_MODE_ALTERNATE_PUSHPULL);
palSetLineMode(SERIAL_USART_RX_PIN, PAL_MODE_INPUT);
@@ -136,6 +204,9 @@ __attribute__((weak)) void usart_init(void) {
# if defined(USART_REMAP)
USART_REMAP;
# endif
+# elif defined(MCU_RP) /* Raspberry Pi MCUs */
+ palSetLineMode(SERIAL_USART_TX_PIN, PAL_MODE_ALTERNATE_UART);
+ palSetLineMode(SERIAL_USART_RX_PIN, PAL_MODE_ALTERNATE_UART);
# else
# pragma message "usart_init: MCU Familiy not supported by default, please supply your own init code by implementing usart_init() in your keyboard files."
# endif
@@ -146,7 +217,7 @@ __attribute__((weak)) void usart_init(void) {
/**
* @brief Overridable master specific initializations.
*/
-__attribute__((weak, nonnull)) void usart_master_init(SerialDriver** driver) {
+__attribute__((weak, nonnull)) void usart_master_init(QMKSerialDriver** driver) {
(void)driver;
usart_init();
}
@@ -154,161 +225,22 @@ __attribute__((weak, nonnull)) void usart_master_init(SerialDriver** driver) {
/**
* @brief Overridable slave specific initializations.
*/
-__attribute__((weak, nonnull)) void usart_slave_init(SerialDriver** driver) {
+__attribute__((weak, nonnull)) void usart_slave_init(QMKSerialDriver** driver) {
(void)driver;
usart_init();
}
-/**
- * @brief This thread runs on the slave and responds to transactions initiated
- * by the master.
- */
-static THD_WORKING_AREA(waSlaveThread, 1024);
-static THD_FUNCTION(SlaveThread, arg) {
- (void)arg;
- chRegSetThreadName("usart_tx_rx");
-
- while (true) {
- if (!react_to_transactions()) {
- /* Clear the receive queue, to start with a clean slate.
- * Parts of failed transactions or spurious bytes could still be in it. */
- usart_clear();
- }
- split_shared_memory_unlock();
- }
-}
-
-/**
- * @brief Slave specific initializations.
- */
-void soft_serial_target_init(void) {
+void serial_transport_driver_slave_init(void) {
usart_slave_init(&serial_driver);
-
- sdStart(serial_driver, &serial_config);
-
- /* Start transport thread. */
- chThdCreateStatic(waSlaveThread, sizeof(waSlaveThread), HIGHPRIO, SlaveThread, NULL);
+ usart_driver_start();
}
-/**
- * @brief React to transactions started by the master.
- */
-static inline bool react_to_transactions(void) {
- /* Wait until there is a transaction for us. */
- uint8_t sstd_index = (uint8_t)sdGet(serial_driver);
-
- /* Sanity check that we are actually responding to a valid transaction. */
- if (sstd_index >= NUM_TOTAL_TRANSACTIONS) {
- return false;
- }
-
- split_shared_memory_lock();
- split_transaction_desc_t* trans = &split_transaction_table[sstd_index];
-
- /* Send back the handshake which is XORed as a simple checksum,
- to signal that the slave is ready to receive possible transaction buffers */
- sstd_index ^= HANDSHAKE_MAGIC;
- if (!send(&sstd_index, sizeof(sstd_index))) {
- return false;
- }
-
- /* Receive transaction buffer from the master. If this transaction requires it.*/
- if (trans->initiator2target_buffer_size) {
- if (!receive(split_trans_initiator2target_buffer(trans), trans->initiator2target_buffer_size)) {
- return false;
- }
- }
-
- /* Allow any slave processing to occur. */
- if (trans->slave_callback) {
- trans->slave_callback(trans->initiator2target_buffer_size, split_trans_initiator2target_buffer(trans), trans->initiator2target_buffer_size, split_trans_target2initiator_buffer(trans));
- }
-
- /* Send transaction buffer to the master. If this transaction requires it. */
- if (trans->target2initiator_buffer_size) {
- if (!send(split_trans_target2initiator_buffer(trans), trans->target2initiator_buffer_size)) {
- return false;
- }
- }
-
- return true;
-}
-
-/**
- * @brief Master specific initializations.
- */
-void soft_serial_initiator_init(void) {
+void serial_transport_driver_master_init(void) {
usart_master_init(&serial_driver);
#if defined(MCU_STM32) && defined(SERIAL_USART_PIN_SWAP)
serial_config.cr2 |= USART_CR2_SWAP; // master has swapped TX/RX pins
#endif
- sdStart(serial_driver, &serial_config);
-}
-
-/**
- * @brief Start transaction from the master half to the slave half.
- *
- * @param index Transaction Table index of the transaction to start.
- * @return bool Indicates success of transaction.
- */
-bool soft_serial_transaction(int index) {
- /* Clear the receive queue, to start with a clean slate.
- * Parts of failed transactions or spurious bytes could still be in it. */
- usart_clear();
-
- split_shared_memory_lock();
- bool result = initiate_transaction((uint8_t)index);
- split_shared_memory_unlock();
-
- return result;
-}
-
-/**
- * @brief Initiate transaction to slave half.
- */
-static inline bool initiate_transaction(uint8_t sstd_index) {
- /* Sanity check that we are actually starting a valid transaction. */
- if (sstd_index >= NUM_TOTAL_TRANSACTIONS) {
- dprintln("USART: Illegal transaction Id.");
- return false;
- }
-
- split_transaction_desc_t* trans = &split_transaction_table[sstd_index];
-
- /* Send transaction table index to the slave, which doubles as basic handshake token. */
- if (!send(&sstd_index, sizeof(sstd_index))) {
- dprintln("USART: Send Handshake failed.");
- return false;
- }
-
- uint8_t sstd_index_shake = 0xFF;
-
- /* Which we always read back first so that we can error out correctly.
- * - due to the half duplex limitations on return codes, we always have to read *something*.
- * - without the read, write only transactions *always* succeed, even during the boot process where the slave is not ready.
- */
- if (!receive(&sstd_index_shake, sizeof(sstd_index_shake)) || (sstd_index_shake != (sstd_index ^ HANDSHAKE_MAGIC))) {
- dprintln("USART: Handshake failed.");
- return false;
- }
-
- /* Send transaction buffer to the slave. If this transaction requires it. */
- if (trans->initiator2target_buffer_size) {
- if (!send(split_trans_initiator2target_buffer(trans), trans->initiator2target_buffer_size)) {
- dprintln("USART: Send failed.");
- return false;
- }
- }
-
- /* Receive transaction buffer from the slave. If this transaction requires it. */
- if (trans->target2initiator_buffer_size) {
- if (!receive(split_trans_target2initiator_buffer(trans), trans->target2initiator_buffer_size)) {
- dprintln("USART: Receive failed.");
- return false;
- }
- }
-
- return true;
+ usart_driver_start();
}
diff --git a/platforms/chibios/drivers/serial_usart.h b/platforms/chibios/drivers/serial_usart.h
index 81fe9e0113..fa062cd736 100644
--- a/platforms/chibios/drivers/serial_usart.h
+++ b/platforms/chibios/drivers/serial_usart.h
@@ -1,42 +1,12 @@
-/* Copyright 2021 QMK
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+// Copyright 2021 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "quantum.h"
#include "serial.h"
-#include "printf.h"
-
-#include <ch.h>
#include <hal.h>
-#if !defined(SERIAL_USART_DRIVER)
-# define SERIAL_USART_DRIVER SD1
-#endif
-
-#if !defined(USE_GPIOV1)
-/* The default PAL alternate modes are used to signal that the pins are used for USART. */
-# if !defined(SERIAL_USART_TX_PAL_MODE)
-# define SERIAL_USART_TX_PAL_MODE 7
-# endif
-# if !defined(SERIAL_USART_RX_PAL_MODE)
-# define SERIAL_USART_RX_PAL_MODE 7
-# endif
-#endif
-
#if defined(SOFT_SERIAL_PIN)
# define SERIAL_USART_TX_PIN SOFT_SERIAL_PIN
#endif
@@ -49,6 +19,62 @@
# define SERIAL_USART_RX_PIN A10
#endif
+#if !defined(SELECT_SOFT_SERIAL_SPEED)
+# define SELECT_SOFT_SERIAL_SPEED 1
+#endif
+
+#if defined(SERIAL_USART_SPEED)
+// Allow advanced users to directly set SERIAL_USART_SPEED
+#elif SELECT_SOFT_SERIAL_SPEED == 0
+# define SERIAL_USART_SPEED 460800
+#elif SELECT_SOFT_SERIAL_SPEED == 1
+# define SERIAL_USART_SPEED 230400
+#elif SELECT_SOFT_SERIAL_SPEED == 2
+# define SERIAL_USART_SPEED 115200
+#elif SELECT_SOFT_SERIAL_SPEED == 3
+# define SERIAL_USART_SPEED 57600
+#elif SELECT_SOFT_SERIAL_SPEED == 4
+# define SERIAL_USART_SPEED 38400
+#elif SELECT_SOFT_SERIAL_SPEED == 5
+# define SERIAL_USART_SPEED 19200
+#else
+# error invalid SELECT_SOFT_SERIAL_SPEED value
+#endif
+
+#if !defined(SERIAL_USART_TIMEOUT)
+# define SERIAL_USART_TIMEOUT 20
+#endif
+
+#if HAL_USE_SERIAL
+
+typedef SerialDriver QMKSerialDriver;
+typedef SerialConfig QMKSerialConfig;
+
+# if !defined(SERIAL_USART_DRIVER)
+# define SERIAL_USART_DRIVER SD1
+# endif
+
+#elif HAL_USE_SIO
+
+typedef SIODriver QMKSerialDriver;
+typedef SIOConfig QMKSerialConfig;
+
+# if !defined(SERIAL_USART_DRIVER)
+# define SERIAL_USART_DRIVER SIOD1
+# endif
+
+#endif
+
+#if !defined(USE_GPIOV1)
+/* The default PAL alternate modes are used to signal that the pins are used for USART. */
+# if !defined(SERIAL_USART_TX_PAL_MODE)
+# define SERIAL_USART_TX_PAL_MODE 7
+# endif
+# if !defined(SERIAL_USART_RX_PAL_MODE)
+# define SERIAL_USART_RX_PAL_MODE 7
+# endif
+#endif
+
#if !defined(USART_CR1_M0)
# define USART_CR1_M0 USART_CR1_M // some platforms (f1xx) dont have this so
#endif
@@ -86,31 +112,3 @@
(AFIO->MAPR |= AFIO_MAPR_USART3_REMAP_FULLREMAP); \
} while (0)
#endif
-
-#if !defined(SELECT_SOFT_SERIAL_SPEED)
-# define SELECT_SOFT_SERIAL_SPEED 1
-#endif
-
-#if defined(SERIAL_USART_SPEED)
-// Allow advanced users to directly set SERIAL_USART_SPEED
-#elif SELECT_SOFT_SERIAL_SPEED == 0
-# define SERIAL_USART_SPEED 460800
-#elif SELECT_SOFT_SERIAL_SPEED == 1
-# define SERIAL_USART_SPEED 230400
-#elif SELECT_SOFT_SERIAL_SPEED == 2
-# define SERIAL_USART_SPEED 115200
-#elif SELECT_SOFT_SERIAL_SPEED == 3
-# define SERIAL_USART_SPEED 57600
-#elif SELECT_SOFT_SERIAL_SPEED == 4
-# define SERIAL_USART_SPEED 38400
-#elif SELECT_SOFT_SERIAL_SPEED == 5
-# define SERIAL_USART_SPEED 19200
-#else
-# error invalid SELECT_SOFT_SERIAL_SPEED value
-#endif
-
-#if !defined(SERIAL_USART_TIMEOUT)
-# define SERIAL_USART_TIMEOUT 20
-#endif
-
-#define HANDSHAKE_MAGIC 7
diff --git a/platforms/chibios/drivers/spi_master.c b/platforms/chibios/drivers/spi_master.c
index ce69e7f0ac..c3ab0623f0 100644
--- a/platforms/chibios/drivers/spi_master.c
+++ b/platforms/chibios/drivers/spi_master.c
@@ -20,7 +20,7 @@
static pin_t currentSlavePin = NO_PIN;
-#if defined(K20x) || defined(KL2x)
+#if defined(K20x) || defined(KL2x) || defined(RP2040)
static SPIConfig spiConfig = {NULL, 0, 0, 0};
#else
static SPIConfig spiConfig = {false, NULL, 0, 0, 0, 0};
@@ -42,10 +42,12 @@ __attribute__((weak)) void spi_init(void) {
palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), SPI_MOSI_PAL_MODE);
palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), SPI_MISO_PAL_MODE);
#else
- palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST);
- palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST);
- palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_MODE_ALTERNATE(SPI_MISO_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST);
+ palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), SPI_SCK_FLAGS);
+ palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), SPI_MOSI_FLAGS);
+ palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), SPI_MISO_FLAGS);
#endif
+ spiStop(&SPI_DRIVER);
+ currentSlavePin = NO_PIN;
}
}
@@ -167,7 +169,36 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) {
spiConfig.SPI_CPOL = SPI_CPOL_High;
break;
}
+#elif defined(MCU_RP)
+ if (lsbFirst) {
+ osalDbgAssert(lsbFirst == false, "RP2040s PrimeCell SPI implementation does not support sending LSB first.");
+ }
+
+ // Motorola frame format and 8bit transfer data size.
+ spiConfig.SSPCR0 = SPI_SSPCR0_FRF_MOTOROLA | SPI_SSPCR0_DSS_8BIT;
+ // Serial output clock = (ck_sys or ck_peri) / (SSPCPSR->CPSDVSR * (1 +
+ // SSPCR0->SCR)). SCR is always set to zero, as QMK SPI API expects the
+ // passed divisor to be the only value to divide the input clock by.
+ spiConfig.SSPCPSR = roundedDivisor; // Even number from 2 to 254
+ switch (mode) {
+ case 0:
+ spiConfig.SSPCR0 &= ~SPI_SSPCR0_SPO; // Clock polarity: low
+ spiConfig.SSPCR0 &= ~SPI_SSPCR0_SPH; // Clock phase: sample on first edge
+ break;
+ case 1:
+ spiConfig.SSPCR0 &= ~SPI_SSPCR0_SPO; // Clock polarity: low
+ spiConfig.SSPCR0 |= SPI_SSPCR0_SPH; // Clock phase: sample on second edge transition
+ break;
+ case 2:
+ spiConfig.SSPCR0 |= SPI_SSPCR0_SPO; // Clock polarity: high
+ spiConfig.SSPCR0 &= ~SPI_SSPCR0_SPH; // Clock phase: sample on first edge
+ break;
+ case 3:
+ spiConfig.SSPCR0 |= SPI_SSPCR0_SPO; // Clock polarity: high
+ spiConfig.SSPCR0 |= SPI_SSPCR0_SPH; // Clock phase: sample on second edge transition
+ break;
+ }
#else
spiConfig.cr1 = 0;
diff --git a/platforms/chibios/drivers/vendor/RP/RP2040/serial_vendor.c b/platforms/chibios/drivers/vendor/RP/RP2040/serial_vendor.c
new file mode 100644
index 0000000000..764764b3f9
--- /dev/null
+++ b/platforms/chibios/drivers/vendor/RP/RP2040/serial_vendor.c
@@ -0,0 +1,473 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "quantum.h"
+#include "serial_usart.h"
+#include "serial_protocol.h"
+#include "hardware/pio.h"
+#include "hardware/clocks.h"
+
+#if !defined(MCU_RP)
+# error PIO Driver is only available for Raspberry Pi 2040 MCUs!
+#endif
+
+static inline bool receive_impl(uint8_t* destination, const size_t size, sysinterval_t timeout);
+static inline bool send_impl(const uint8_t* source, const size_t size);
+static inline void pio_serve_interrupt(void);
+
+#define MSG_PIO_ERROR ((msg_t)(-3))
+
+#if defined(SERIAL_PIO_USE_PIO1)
+static const PIO pio = pio1;
+
+OSAL_IRQ_HANDLER(RP_PIO1_IRQ_0_HANDLER) {
+ OSAL_IRQ_PROLOGUE();
+ pio_serve_interrupt();
+ OSAL_IRQ_EPILOGUE();
+}
+#else
+static const PIO pio = pio0;
+
+OSAL_IRQ_HANDLER(RP_PIO0_IRQ_0_HANDLER) {
+ OSAL_IRQ_PROLOGUE();
+ pio_serve_interrupt();
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+#define UART_TX_WRAP_TARGET 0
+#define UART_TX_WRAP 3
+
+// clang-format off
+#if defined(SERIAL_USART_FULL_DUPLEX)
+static const uint16_t uart_tx_program_instructions[] = {
+ // .wrap_target
+ 0x9fa0, // 0: pull block side 1 [7]
+ 0xf727, // 1: set x, 7 side 0 [7]
+ 0x6001, // 2: out pins, 1
+ 0x0642, // 3: jmp x--, 2 [6]
+ // .wrap
+};
+#else
+static const uint16_t uart_tx_program_instructions[] = {
+ // .wrap_target
+ 0x9fa0, // 0: pull block side 1 [7]
+ 0xf727, // 1: set x, 7 side 0 [7]
+ 0x6081, // 2: out pindirs, 1
+ 0x0642, // 3: jmp x--, 2 [6]
+ // .wrap
+};
+#endif
+// clang-format on
+
+static const pio_program_t uart_tx_program = {
+ .instructions = uart_tx_program_instructions,
+ .length = 4,
+ .origin = -1,
+};
+
+#define UART_RX_WRAP_TARGET 0
+#define UART_RX_WRAP 8
+
+// clang-format off
+static const uint16_t uart_rx_program_instructions[] = {
+ // .wrap_target
+ 0x2020, // 0: wait 0 pin, 0
+ 0xea27, // 1: set x, 7 [10]
+ 0x4001, // 2: in pins, 1
+ 0x0642, // 3: jmp x--, 2 [6]
+ 0x00c8, // 4: jmp pin, 8
+ 0xc020, // 5: irq wait 0
+ 0x20a0, // 6: wait 1 pin, 0
+ 0x0000, // 7: jmp 0
+ 0x8020, // 8: push block
+ // .wrap
+};
+// clang-format on
+
+static const pio_program_t uart_rx_program = {
+ .instructions = uart_rx_program_instructions,
+ .length = 9,
+ .origin = -1,
+};
+
+thread_reference_t rx_thread = NULL;
+static int rx_state_machine = -1;
+
+thread_reference_t tx_thread = NULL;
+static int tx_state_machine = -1;
+
+void pio_serve_interrupt(void) {
+ uint32_t irqs = pio->ints0;
+
+ // The RX FIFO is not empty any more, therefore wake any sleeping rx thread
+ if (irqs & (PIO_IRQ0_INTF_SM0_RXNEMPTY_BITS << rx_state_machine)) {
+ // Disable rx not empty interrupt
+ pio_set_irq0_source_enabled(pio, pis_sm0_rx_fifo_not_empty + rx_state_machine, false);
+
+ osalSysLockFromISR();
+ osalThreadResumeI(&rx_thread, MSG_OK);
+ osalSysUnlockFromISR();
+ }
+
+ // The TX FIFO is not full any more, therefore wake any sleeping tx thread
+ if (irqs & (PIO_IRQ0_INTF_SM0_TXNFULL_BITS << tx_state_machine)) {
+ // Disable tx not full interrupt
+ pio_set_irq0_source_enabled(pio, pis_sm0_tx_fifo_not_full + tx_state_machine, false);
+ osalSysLockFromISR();
+ osalThreadResumeI(&tx_thread, MSG_OK);
+ osalSysUnlockFromISR();
+ }
+
+ // IRQ 0 is set on framing or break errors by the rx state machine
+ if (pio_interrupt_get(pio, 0UL)) {
+ pio_interrupt_clear(pio, 0UL);
+
+ osalSysLockFromISR();
+ osalThreadResumeI(&rx_thread, MSG_PIO_ERROR);
+ osalSysUnlockFromISR();
+ }
+}
+
+#if !defined(SERIAL_USART_FULL_DUPLEX)
+// The internal pull-ups of the RP2040 are rather weakish with a range of 50k to
+// 80k, which in turn do not provide enough current to guarantee fast signal rise
+// times with a parasitic capacitance of greater than 100pf. In real world
+// applications, like split keyboards which might have vias in the signal path
+// or long PCB traces, this prevents a successful communication. The solution
+// is to temporarily augment the weak pull ups from the receiving side by
+// driving the tx pin high. On the receiving side the lowest possible drive
+// strength is chosen because the transmitting side must still be able to drive
+// the signal low. With this configuration the rise times are fast enough and
+// the generated low level with 360mV will generate a logical zero.
+static inline void enter_rx_state(void) {
+ osalSysLock();
+ nvicEnableVector(RP_USBCTRL_IRQ_NUMBER, RP_IRQ_USB0_PRIORITY);
+ // Wait for the transmitting state machines FIFO to run empty. At this point
+ // the last byte has been pulled from the transmitting state machines FIFO
+ // into the output shift register. We have to wait a tiny bit more until
+ // this byte is transmitted, before we can turn on the receiving state
+ // machine again.
+ while (!pio_sm_is_tx_fifo_empty(pio, tx_state_machine)) {
+ }
+ // Wait for ~11 bits, 1 start bit + 8 data bits + 1 stop bit + 1 bit
+ // headroom.
+ wait_us(1000000U * 11U / SERIAL_USART_SPEED);
+ // Disable tx state machine to not interfere with our tx pin manipulation
+ pio_sm_set_enabled(pio, tx_state_machine, false);
+ gpio_set_drive_strength(SERIAL_USART_TX_PIN, GPIO_DRIVE_STRENGTH_2MA);
+ pio_sm_set_pins_with_mask(pio, tx_state_machine, 1U << SERIAL_USART_TX_PIN, 1U << SERIAL_USART_TX_PIN);
+ pio_sm_set_consecutive_pindirs(pio, tx_state_machine, SERIAL_USART_TX_PIN, 1U, false);
+ pio_sm_set_enabled(pio, rx_state_machine, true);
+ osalSysUnlock();
+}
+
+static inline void leave_rx_state(void) {
+ osalSysLock();
+ // We don't want to be interrupted by frequent (1KHz) USB interrupts while
+ // doing our timing critical sending operation.
+ nvicDisableVector(RP_USBCTRL_IRQ_NUMBER);
+ // In Half-duplex operation the tx pin dual-functions as sender and
+ // receiver. To not receive the data we will send, we disable the receiving
+ // state machine.
+ pio_sm_set_enabled(pio, rx_state_machine, false);
+ pio_sm_set_consecutive_pindirs(pio, tx_state_machine, SERIAL_USART_TX_PIN, 1U, true);
+ pio_sm_set_pins_with_mask(pio, tx_state_machine, 0U, 1U << SERIAL_USART_TX_PIN);
+ gpio_set_drive_strength(SERIAL_USART_TX_PIN, GPIO_DRIVE_STRENGTH_12MA);
+ pio_sm_restart(pio, tx_state_machine);
+ pio_sm_set_enabled(pio, tx_state_machine, true);
+ osalSysUnlock();
+}
+#else
+// All this trickery is gladly not necessary for full-duplex.
+static inline void enter_rx_state(void) {}
+static inline void leave_rx_state(void) {}
+#endif
+
+/**
+ * @brief Clear the RX and TX hardware FIFOs of the state machines.
+ */
+inline void serial_transport_driver_clear(void) {
+ osalSysLock();
+ pio_sm_clear_fifos(pio, rx_state_machine);
+ pio_sm_clear_fifos(pio, tx_state_machine);
+ osalSysUnlock();
+}
+
+static inline msg_t sync_tx(sysinterval_t timeout) {
+ msg_t msg = MSG_OK;
+ osalSysLock();
+ while (pio_sm_is_tx_fifo_full(pio, tx_state_machine)) {
+#if !defined(SERIAL_USART_FULL_DUPLEX)
+ // Enable USB interrupts again, because we might sleep for a long time
+ // here and don't want to be disconnected from the host.
+ nvicEnableVector(RP_USBCTRL_IRQ_NUMBER, RP_IRQ_USB0_PRIORITY);
+#endif
+ pio_set_irq0_source_enabled(pio, pis_sm0_tx_fifo_not_full + tx_state_machine, true);
+ msg = osalThreadSuspendTimeoutS(&tx_thread, timeout);
+ if (msg < MSG_OK) {
+ pio_set_irq0_source_enabled(pio, pis_sm0_tx_fifo_not_full + tx_state_machine, false);
+ break;
+ }
+ }
+#if !defined(SERIAL_USART_FULL_DUPLEX)
+ // Entering timing critical territory again.
+ nvicDisableVector(RP_USBCTRL_IRQ_NUMBER);
+#endif
+ osalSysUnlock();
+ return msg;
+}
+
+static inline bool send_impl(const uint8_t* source, const size_t size) {
+ size_t send = 0;
+ msg_t msg;
+ while (send < size) {
+ msg = sync_tx(TIME_MS2I(SERIAL_USART_TIMEOUT));
+ if (msg < MSG_OK) {
+ return false;
+ }
+
+ osalSysLock();
+ while (send < size) {
+ if (pio_sm_is_tx_fifo_full(pio, tx_state_machine)) {
+ break;
+ }
+ if (send >= size) {
+ break;
+ }
+ pio_sm_put(pio, tx_state_machine, (uint32_t)(*source));
+ source++;
+ send++;
+ }
+ osalSysUnlock();
+ }
+
+ return send == size;
+}
+
+/**
+ * @brief Blocking send of buffer with timeout.
+ *
+ * @return true Send success.
+ * @return false Send failed.
+ */
+inline bool serial_transport_send(const uint8_t* source, const size_t size) {
+ leave_rx_state();
+ bool result = send_impl(source, size);
+ enter_rx_state();
+
+ return result;
+}
+
+static inline msg_t sync_rx(sysinterval_t timeout) {
+ msg_t msg = MSG_OK;
+ osalSysLock();
+ while (pio_sm_is_rx_fifo_empty(pio, rx_state_machine)) {
+ pio_set_irq0_source_enabled(pio, pis_sm0_rx_fifo_not_empty + rx_state_machine, true);
+ msg = osalThreadSuspendTimeoutS(&rx_thread, timeout);
+ if (msg < MSG_OK) {
+ pio_set_irq0_source_enabled(pio, pis_sm0_rx_fifo_not_empty + rx_state_machine, false);
+ break;
+ }
+ }
+ osalSysUnlock();
+ return msg;
+}
+
+static inline bool receive_impl(uint8_t* destination, const size_t size, sysinterval_t timeout) {
+ size_t read = 0U;
+
+ while (read < size) {
+ msg_t msg = sync_rx(timeout);
+ if (msg < MSG_OK) {
+ return false;
+ }
+ osalSysLock();
+ while (true) {
+ if (pio_sm_is_rx_fifo_empty(pio, rx_state_machine)) {
+ break;
+ }
+ if (read >= size) {
+ break;
+ }
+ *destination++ = *((uint8_t*)&pio->rxf[rx_state_machine] + 3U);
+ read++;
+ }
+ osalSysUnlock();
+ }
+
+ return read == size;
+}
+
+/**
+ * @brief Blocking receive of size * bytes with timeout.
+ *
+ * @return true Receive success.
+ * @return false Receive failed, e.g. by timeout.
+ */
+inline bool serial_transport_receive(uint8_t* destination, const size_t size) {
+ return receive_impl(destination, size, TIME_MS2I(SERIAL_USART_TIMEOUT));
+}
+
+/**
+ * @brief Blocking receive of size * bytes.
+ *
+ * @return true Receive success.
+ * @return false Receive failed.
+ */
+inline bool serial_transport_receive_blocking(uint8_t* destination, const size_t size) {
+ return receive_impl(destination, size, TIME_INFINITE);
+}
+
+static inline void pio_tx_init(pin_t tx_pin) {
+ uint pio_idx = pio_get_index(pio);
+ uint offset = pio_add_program(pio, &uart_tx_program);
+
+#if defined(SERIAL_USART_FULL_DUPLEX)
+ // clang-format off
+ iomode_t tx_pin_mode = PAL_RP_GPIO_OE |
+ PAL_RP_PAD_SLEWFAST |
+ PAL_RP_PAD_DRIVE4 |
+ (pio_idx == 0 ? PAL_MODE_ALTERNATE_PIO0 : PAL_MODE_ALTERNATE_PIO1);
+ // clang-format on
+ pio_sm_set_pins_with_mask(pio, tx_state_machine, 1U << tx_pin, 1U << tx_pin);
+ pio_sm_set_consecutive_pindirs(pio, tx_state_machine, tx_pin, 1U, true);
+#else
+ // clang-format off
+ iomode_t tx_pin_mode = PAL_RP_PAD_IE |
+ PAL_RP_GPIO_OE |
+ PAL_RP_PAD_SCHMITT |
+ PAL_RP_PAD_PUE |
+ PAL_RP_PAD_SLEWFAST |
+ PAL_RP_PAD_DRIVE12 |
+ PAL_RP_IOCTRL_OEOVER_DRVINVPERI |
+ (pio_idx == 0 ? PAL_MODE_ALTERNATE_PIO0 : PAL_MODE_ALTERNATE_PIO1);
+ // clang-format on
+ pio_sm_set_pins_with_mask(pio, tx_state_machine, 0U << tx_pin, 1U << tx_pin);
+ pio_sm_set_consecutive_pindirs(pio, tx_state_machine, tx_pin, 1U, true);
+#endif
+
+ palSetLineMode(tx_pin, tx_pin_mode);
+
+ pio_sm_config config = pio_get_default_sm_config();
+ sm_config_set_wrap(&config, offset + UART_TX_WRAP_TARGET, offset + UART_TX_WRAP);
+#if defined(SERIAL_USART_FULL_DUPLEX)
+ sm_config_set_sideset(&config, 2, true, false);
+#else
+ sm_config_set_sideset(&config, 2, true, true);
+#endif
+ // OUT shifts to right, no autopull
+ sm_config_set_out_shift(&config, true, false, 32);
+ // We are mapping both OUT and side-set to the same pin, because sometimes
+ // we need to assert user data onto the pin (with OUT) and sometimes
+ // assert constant values (start/stop bit)
+ sm_config_set_out_pins(&config, tx_pin, 1);
+ sm_config_set_sideset_pins(&config, tx_pin);
+ // We only need TX, so get an 8-deep FIFO!
+ sm_config_set_fifo_join(&config, PIO_FIFO_JOIN_TX);
+ // SM transmits 1 bit per 8 execution cycles.
+ float div = (float)clock_get_hz(clk_sys) / (8 * SERIAL_USART_SPEED);
+ sm_config_set_clkdiv(&config, div);
+ pio_sm_init(pio, tx_state_machine, offset, &config);
+ pio_sm_set_enabled(pio, tx_state_machine, true);
+}
+
+static inline void pio_rx_init(pin_t rx_pin) {
+ uint offset = pio_add_program(pio, &uart_rx_program);
+
+#if defined(SERIAL_USART_FULL_DUPLEX)
+ uint pio_idx = pio_get_index(pio);
+ pio_sm_set_consecutive_pindirs(pio, rx_state_machine, rx_pin, 1, false);
+ // clang-format off
+ iomode_t rx_pin_mode = PAL_RP_PAD_IE |
+ PAL_RP_PAD_SCHMITT |
+ PAL_RP_PAD_PUE |
+ (pio_idx == 0 ? PAL_MODE_ALTERNATE_PIO0 : PAL_MODE_ALTERNATE_PIO1);
+ // clang-format on
+ palSetLineMode(rx_pin, rx_pin_mode);
+#endif
+
+ pio_sm_config config = pio_get_default_sm_config();
+ sm_config_set_wrap(&config, offset + UART_RX_WRAP_TARGET, offset + UART_RX_WRAP);
+ sm_config_set_in_pins(&config, rx_pin); // for WAIT, IN
+ sm_config_set_jmp_pin(&config, rx_pin); // for JMP
+ // Shift to right, autopush disabled
+ sm_config_set_in_shift(&config, true, false, 32);
+ // Deeper FIFO as we're not doing any TX
+ sm_config_set_fifo_join(&config, PIO_FIFO_JOIN_RX);
+ // SM transmits 1 bit per 8 execution cycles.
+ float div = (float)clock_get_hz(clk_sys) / (8 * SERIAL_USART_SPEED);
+ sm_config_set_clkdiv(&config, div);
+ pio_sm_init(pio, rx_state_machine, offset, &config);
+ pio_sm_set_enabled(pio, rx_state_machine, true);
+}
+
+static inline void pio_init(pin_t tx_pin, pin_t rx_pin) {
+ uint pio_idx = pio_get_index(pio);
+
+ /* Get PIOx peripheral out of reset state. */
+ hal_lld_peripheral_unreset(pio_idx == 0 ? RESETS_ALLREG_PIO0 : RESETS_ALLREG_PIO1);
+
+ tx_state_machine = pio_claim_unused_sm(pio, true);
+ if (tx_state_machine < 0) {
+ dprintln("ERROR: Failed to acquire state machine for serial transmission!");
+ return;
+ }
+ pio_tx_init(tx_pin);
+
+ rx_state_machine = pio_claim_unused_sm(pio, true);
+ if (rx_state_machine < 0) {
+ dprintln("ERROR: Failed to acquire state machine for serial reception!");
+ return;
+ }
+ pio_rx_init(rx_pin);
+
+ // Enable error flag IRQ source for rx state machine
+ pio_set_irq0_source_enabled(pio, pis_sm0_rx_fifo_not_empty + rx_state_machine, true);
+ pio_set_irq0_source_enabled(pio, pis_sm0_tx_fifo_not_full + tx_state_machine, true);
+ pio_set_irq0_source_enabled(pio, pis_interrupt0, true);
+
+ // Enable PIO specific interrupt vector, as the pio implementation is timing
+ // critical we use the highest possible priority.
+#if defined(SERIAL_PIO_USE_PIO1)
+ nvicEnableVector(RP_PIO1_IRQ_0_NUMBER, CORTEX_MAX_KERNEL_PRIORITY);
+#else
+ nvicEnableVector(RP_PIO0_IRQ_0_NUMBER, CORTEX_MAX_KERNEL_PRIORITY);
+#endif
+
+ enter_rx_state();
+}
+
+/**
+ * @brief PIO driver specific initialization function for the master side.
+ */
+void serial_transport_driver_master_init(void) {
+#if defined(SERIAL_USART_FULL_DUPLEX)
+ pin_t tx_pin = SERIAL_USART_TX_PIN;
+ pin_t rx_pin = SERIAL_USART_RX_PIN;
+#else
+ pin_t tx_pin = SERIAL_USART_TX_PIN;
+ pin_t rx_pin = SERIAL_USART_TX_PIN;
+#endif
+
+#if defined(SERIAL_USART_PIN_SWAP)
+ pio_init(rx_pin, tx_pin);
+#else
+ pio_init(tx_pin, rx_pin);
+#endif
+}
+
+/**
+ * @brief PIO driver specific initialization function for the slave side.
+ */
+void serial_transport_driver_slave_init(void) {
+#if defined(SERIAL_USART_FULL_DUPLEX)
+ pin_t tx_pin = SERIAL_USART_TX_PIN;
+ pin_t rx_pin = SERIAL_USART_RX_PIN;
+#else
+ pin_t tx_pin = SERIAL_USART_TX_PIN;
+ pin_t rx_pin = SERIAL_USART_TX_PIN;
+#endif
+
+ pio_init(tx_pin, rx_pin);
+}
diff --git a/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c b/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c
new file mode 100644
index 0000000000..bc34eded14
--- /dev/null
+++ b/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c
@@ -0,0 +1,189 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "quantum.h"
+#include "ws2812.h"
+#include "hardware/pio.h"
+#include "hardware/clocks.h"
+
+#if !defined(MCU_RP)
+# error PIO Driver is only available for Raspberry Pi 2040 MCUs!
+#endif
+
+#if defined(WS2812_PIO_USE_PIO1)
+static const PIO pio = pio1;
+#else
+static const PIO pio = pio0;
+#endif
+
+#if !defined(RP_DMA_PRIORITY_WS2812)
+# define RP_DMA_PRIORITY_WS2812 12
+#endif
+
+static int state_machine = -1;
+
+#define WS2812_WRAP_TARGET 0
+#define WS2812_WRAP 3
+
+#define WS2812_T1 2
+#define WS2812_T2 5
+#define WS2812_T3 3
+
+#if defined(WS2812_EXTERNAL_PULLUP)
+
+# pragma message "The GPIOs of the RP2040 are NOT 5V tolerant! Make sure to NOT apply any voltage over 3.3V to the RGB data pin."
+
+// clang-format off
+static const uint16_t ws2812_program_instructions[] = {
+ // .wrap_target
+ 0x7221, // 0: out x, 1 side 1 [2]
+ 0x0123, // 1: jmp !x, 3 side 0 [1]
+ 0x0400, // 2: jmp 0 side 0 [4]
+ 0xb442, // 3: nop side 1 [4]
+ // .wrap
+};
+
+#else
+
+static const uint16_t ws2812_program_instructions[] = {
+ // .wrap_target
+ 0x6221, // 0: out x, 1 side 0 [2]
+ 0x1123, // 1: jmp !x, 3 side 1 [1]
+ 0x1400, // 2: jmp 0 side 1 [4]
+ 0xa442, // 3: nop side 0 [4]
+ // .wrap
+};
+// clang-format on
+#endif
+
+static const pio_program_t ws2812_program = {
+ .instructions = ws2812_program_instructions,
+ .length = 4,
+ .origin = -1,
+};
+
+static uint32_t WS2812_BUFFER[RGBLED_NUM];
+static const rp_dma_channel_t* WS2812_DMA_CHANNEL;
+
+bool ws2812_init(void) {
+ uint pio_idx = pio_get_index(pio);
+ /* Get PIOx peripheral out of reset state. */
+ hal_lld_peripheral_unreset(pio_idx == 0 ? RESETS_ALLREG_PIO0 : RESETS_ALLREG_PIO1);
+
+ // clang-format off
+ iomode_t rgb_pin_mode = PAL_RP_PAD_SLEWFAST |
+ PAL_RP_GPIO_OE |
+ (pio_idx == 0 ? PAL_MODE_ALTERNATE_PIO0 : PAL_MODE_ALTERNATE_PIO1);
+ // clang-format on
+
+ palSetLineMode(RGB_DI_PIN, rgb_pin_mode);
+
+ state_machine = pio_claim_unused_sm(pio, true);
+ if (state_machine < 0) {
+ dprintln("ERROR: Failed to acquire state machine for WS2812 output!");
+ return false;
+ }
+
+ uint offset = pio_add_program(pio, &ws2812_program);
+
+ pio_sm_set_consecutive_pindirs(pio, state_machine, RGB_DI_PIN, 1, true);
+
+ pio_sm_config config = pio_get_default_sm_config();
+ sm_config_set_wrap(&config, offset + WS2812_WRAP_TARGET, offset + WS2812_WRAP);
+ sm_config_set_sideset_pins(&config, RGB_DI_PIN);
+ sm_config_set_fifo_join(&config, PIO_FIFO_JOIN_TX);
+
+#if defined(WS2812_EXTERNAL_PULLUP)
+ /* Instruct side-set to change the pin-directions instead of outputting
+ * a logic level. We generate our levels the following way:
+ *
+ * 1: Set RGB data pin to high impedance input and let the pull-up drive the
+ * signal high.
+ *
+ * 0: Set RGB data pin to low impedance output and drive the pin low.
+ */
+ sm_config_set_sideset(&config, 1, false, true);
+#else
+ sm_config_set_sideset(&config, 1, false, false);
+#endif
+
+#if defined(RGBW)
+ sm_config_set_out_shift(&config, false, true, 32);
+#else
+ sm_config_set_out_shift(&config, false, true, 24);
+#endif
+
+ int cycles_per_bit = WS2812_T1 + WS2812_T2 + WS2812_T3;
+ float div = clock_get_hz(clk_sys) / (800.0f * KHZ * cycles_per_bit);
+ sm_config_set_clkdiv(&config, div);
+
+ pio_sm_init(pio, state_machine, offset, &config);
+ pio_sm_set_enabled(pio, state_machine, true);
+
+ WS2812_DMA_CHANNEL = dmaChannelAlloc(RP_DMA_CHANNEL_ID_ANY, RP_DMA_PRIORITY_WS2812, NULL, NULL);
+
+ // clang-format off
+ uint32_t mode = DMA_CTRL_TRIG_INCR_READ |
+ DMA_CTRL_TRIG_DATA_SIZE_WORD |
+ DMA_CTRL_TRIG_IRQ_QUIET |
+ DMA_CTRL_TRIG_TREQ_SEL(pio_idx == 0 ? state_machine : state_machine + 8);
+ // clang-format on
+
+ dmaChannelSetModeX(WS2812_DMA_CHANNEL, mode);
+ dmaChannelSetDestinationX(WS2812_DMA_CHANNEL, (uint32_t)&pio->txf[state_machine]);
+ return true;
+}
+
+/**
+ * @brief Convert RGBW value into WS2812 compatible 32-bit data word.
+ */
+__always_inline static uint32_t rgbw8888_to_u32(uint8_t red, uint8_t green, uint8_t blue, uint8_t white) {
+#if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB)
+ return ((uint32_t)green << 24) | ((uint32_t)red << 16) | ((uint32_t)blue << 8) | ((uint32_t)white);
+#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_RGB)
+ return ((uint32_t)red << 24) | ((uint32_t)green << 16) | ((uint32_t)blue << 8) | ((uint32_t)white);
+#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_BGR)
+ return ((uint32_t)blue << 24) | ((uint32_t)green << 16) | ((uint32_t)red << 8) | ((uint32_t)white);
+#endif
+}
+
+static inline void sync_ws2812_transfer(void) {
+ if (unlikely(dmaChannelIsBusyX(WS2812_DMA_CHANNEL) || !pio_sm_is_tx_fifo_empty(pio, state_machine))) {
+ fast_timer_t start = timer_read_fast();
+ do {
+ // Abort the synchronization if we have to wait longer than the total
+ // count of LEDs in millisecounds. This is safely much longer than it
+ // would take to push all the data out.
+ if (unlikely(timer_elapsed_fast(start) > RGBLED_NUM)) {
+ dprintln("ERROR: WS2812 DMA transfer has stalled, aborting!");
+ dmaChannelDisableX(WS2812_DMA_CHANNEL);
+ return;
+ }
+
+ } while (dmaChannelIsBusyX(WS2812_DMA_CHANNEL) || !pio_sm_is_tx_fifo_empty(pio, state_machine));
+ // We wait for the WS2812 chain to reset after all data has been pushed
+ // out.
+ wait_us(WS2812_TRST_US);
+ }
+}
+
+void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) {
+ static bool is_initialized = false;
+ if (unlikely(!is_initialized)) {
+ is_initialized = ws2812_init();
+ }
+
+ sync_ws2812_transfer();
+
+ for (int i = 0; i < leds; i++) {
+#if defined(RGBW)
+ WS2812_BUFFER[i] = rgbw8888_to_u32(ledarray[i].r, ledarray[i].g, ledarray[i].b, ledarray[i].w);
+#else
+ WS2812_BUFFER[i] = rgbw8888_to_u32(ledarray[i].r, ledarray[i].g, ledarray[i].b, 0);
+#endif
+ }
+
+ dmaChannelSetSourceX(WS2812_DMA_CHANNEL, (uint32_t)WS2812_BUFFER);
+ dmaChannelSetCounterX(WS2812_DMA_CHANNEL, leds);
+ dmaChannelEnableX(WS2812_DMA_CHANNEL);
+}
diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_efl.c b/platforms/chibios/drivers/wear_leveling/wear_leveling_efl.c
new file mode 100644
index 0000000000..cdd1e26a7d
--- /dev/null
+++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_efl.c
@@ -0,0 +1,143 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <stdbool.h>
+#include <hal.h>
+#include "timer.h"
+#include "wear_leveling.h"
+#include "wear_leveling_internal.h"
+
+static flash_offset_t base_offset = UINT32_MAX;
+
+#if defined(WEAR_LEVELING_EFL_FIRST_SECTOR)
+static flash_sector_t first_sector = WEAR_LEVELING_EFL_FIRST_SECTOR;
+#else // defined(WEAR_LEVELING_EFL_FIRST_SECTOR)
+static flash_sector_t first_sector = UINT16_MAX;
+#endif // defined(WEAR_LEVELING_EFL_FIRST_SECTOR)
+
+static flash_sector_t sector_count = UINT16_MAX;
+static BaseFlash * flash;
+
+#ifndef WEAR_LEVELING_EFL_FIRST_SECTOR
+// "Automatic" detection of the flash size -- ideally ChibiOS would have this already, but alas, it doesn't.
+static inline uint32_t detect_flash_size(void) {
+# if defined(WEAR_LEVELING_EFL_FLASH_SIZE)
+ return WEAR_LEVELING_EFL_FLASH_SIZE;
+# elif defined(FLASH_BANK_SIZE)
+ return FLASH_BANK_SIZE;
+# elif defined(FLASH_SIZE)
+ return FLASH_SIZE;
+# elif defined(FLASHSIZE_BASE)
+# if defined(QMK_MCU_SERIES_STM32F0XX) || defined(QMK_MCU_SERIES_STM32F1XX) || defined(QMK_MCU_SERIES_STM32F3XX) || defined(QMK_MCU_SERIES_STM32F4XX) || defined(QMK_MCU_SERIES_STM32G4XX) || defined(QMK_MCU_SERIES_STM32L0XX) || defined(QMK_MCU_SERIES_STM32L4XX) || defined(QMK_MCU_SERIES_GD32VF103)
+ return ((*(uint32_t *)FLASHSIZE_BASE) & 0xFFFFU) << 10U; // this register has the flash size in kB, so we convert it to bytes
+# elif defined(QMK_MCU_SERIES_STM32L1XX)
+# error This MCU family has an uncommon flash size register definition and has not been implemented. Perhaps try using the true EEPROM on the MCU instead?
+# endif
+# else
+# error Unknown flash size definition.
+ return 0;
+# endif
+}
+#endif // WEAR_LEVELING_EFL_FIRST_SECTOR
+
+bool backing_store_init(void) {
+ bs_dprintf("Init\n");
+ flash = (BaseFlash *)&EFLD1;
+
+ // Need to re-lock the EFL, as if we've just had the bootloader executing it'll already be unlocked.
+ backing_store_lock();
+
+ const flash_descriptor_t *desc = flashGetDescriptor(flash);
+ uint32_t counter = 0;
+
+#if defined(WEAR_LEVELING_EFL_FIRST_SECTOR)
+
+ // Work out how many sectors we want to use, working forwards from the first sector specified
+ for (flash_sector_t i = 0; i < desc->sectors_count - first_sector; ++i) {
+ counter += flashGetSectorSize(flash, first_sector + i);
+ if (counter >= (WEAR_LEVELING_BACKING_SIZE)) {
+ sector_count = i + 1;
+ base_offset = flashGetSectorOffset(flash, first_sector);
+ break;
+ }
+ }
+ if (sector_count == UINT16_MAX || base_offset >= flash_size) {
+ // We didn't get the required number of sectors. Can't do anything here. Fault.
+ chSysHalt("Invalid sector count intended to be used with wear_leveling");
+ }
+
+#else // defined(WEAR_LEVELING_EFL_FIRST_SECTOR)
+
+ // Work out how many sectors we want to use, working backwards from the end of the flash
+ uint32_t flash_size = detect_flash_size();
+ flash_sector_t last_sector = desc->sectors_count;
+ for (flash_sector_t i = 0; i < desc->sectors_count; ++i) {
+ first_sector = desc->sectors_count - i - 1;
+ if (flashGetSectorOffset(flash, first_sector) >= flash_size) {
+ last_sector = first_sector;
+ continue;
+ }
+ counter += flashGetSectorSize(flash, first_sector);
+ if (counter >= (WEAR_LEVELING_BACKING_SIZE)) {
+ sector_count = last_sector - first_sector;
+ base_offset = flashGetSectorOffset(flash, first_sector);
+ break;
+ }
+ }
+
+#endif // defined(WEAR_LEVELING_EFL_FIRST_SECTOR)
+
+ return true;
+}
+
+bool backing_store_unlock(void) {
+ bs_dprintf("Unlock\n");
+ return eflStart(&EFLD1, NULL) == HAL_RET_SUCCESS;
+}
+
+bool backing_store_erase(void) {
+#ifdef WEAR_LEVELING_DEBUG_OUTPUT
+ uint32_t start = timer_read32();
+#endif
+
+ bool ret = true;
+ flash_error_t status;
+ for (int i = 0; i < sector_count; ++i) {
+ // Kick off the sector erase
+ status = flashStartEraseSector(flash, first_sector + i);
+ if (status != FLASH_NO_ERROR && status != FLASH_BUSY_ERASING) {
+ ret = false;
+ }
+
+ // Wait for the erase to complete
+ status = flashWaitErase(flash);
+ if (status != FLASH_NO_ERROR && status != FLASH_BUSY_ERASING) {
+ ret = false;
+ }
+ }
+
+ bs_dprintf("Backing store erase took %ldms to complete\n", ((long)(timer_read32() - start)));
+ return ret;
+}
+
+bool backing_store_write(uint32_t address, backing_store_int_t value) {
+ uint32_t offset = (base_offset + address);
+ bs_dprintf("Write ");
+ wl_dump(offset, &value, sizeof(value));
+ value = ~value;
+ return flashProgram(flash, offset, sizeof(value), (const uint8_t *)&value) == FLASH_NO_ERROR;
+}
+
+bool backing_store_lock(void) {
+ bs_dprintf("Lock \n");
+ eflStop(&EFLD1);
+ return true;
+}
+
+bool backing_store_read(uint32_t address, backing_store_int_t *value) {
+ uint32_t offset = (base_offset + address);
+ backing_store_int_t *loc = (backing_store_int_t *)flashGetOffsetAddress(flash, offset);
+ *value = ~(*loc);
+ bs_dprintf("Read ");
+ wl_dump(offset, value, sizeof(backing_store_int_t));
+ return true;
+}
diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h b/platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h
new file mode 100644
index 0000000000..244c87cb7f
--- /dev/null
+++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h
@@ -0,0 +1,52 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#ifndef __ASSEMBLER__
+# include <hal.h>
+#endif
+
+// Work out how many bytes per write to internal flash
+#ifndef BACKING_STORE_WRITE_SIZE
+// These need to match EFL's XXXXXX_FLASH_LINE_SIZE, see associated code in `lib/chibios/os/hal/ports/**/hal_efl_lld.c`,
+// or associated `stm32_registry.h` for the MCU in question (or equivalent for the family).
+# if defined(QMK_MCU_SERIES_GD32VF103)
+# define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c
+# elif defined(QMK_MCU_FAMILY_NUC123)
+# define BACKING_STORE_WRITE_SIZE 4 // from hal_efl_lld.c
+# elif defined(QMK_MCU_FAMILY_WB32)
+# define BACKING_STORE_WRITE_SIZE 8 // from hal_efl_lld.c
+# elif defined(QMK_MCU_FAMILY_STM32)
+# if defined(STM32_FLASH_LINE_SIZE) // from some family's stm32_registry.h file
+# define BACKING_STORE_WRITE_SIZE (STM32_FLASH_LINE_SIZE)
+# else
+# if defined(QMK_MCU_SERIES_STM32F1XX)
+# define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c
+# elif defined(QMK_MCU_SERIES_STM32F3XX)
+# define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c
+# elif defined(QMK_MCU_SERIES_STM32F4XX)
+# define BACKING_STORE_WRITE_SIZE (1 << STM32_FLASH_PSIZE) // from hal_efl_lld.c
+# elif defined(QMK_MCU_SERIES_STM32L4XX)
+# define BACKING_STORE_WRITE_SIZE 8 // from hal_efl_lld.c
+# elif defined(QMK_MCU_SERIES_STM32G0XX)
+# define BACKING_STORE_WRITE_SIZE 8 // from hal_efl_lld.c
+# elif defined(QMK_MCU_SERIES_STM32G4XX)
+# define BACKING_STORE_WRITE_SIZE 8 // from hal_efl_lld.c
+# else
+# error "ChibiOS hasn't defined STM32_FLASH_LINE_SIZE, and could not automatically determine BACKING_STORE_WRITE_SIZE" // normally defined in stm32_registry.h, should be set by STM32_FLASH_LINE_SIZE
+# endif
+# endif
+# else
+# error "Could not automatically determine BACKING_STORE_WRITE_SIZE"
+# endif
+#endif
+
+// 2kB backing space allocated
+#ifndef WEAR_LEVELING_BACKING_SIZE
+# define WEAR_LEVELING_BACKING_SIZE 2048
+#endif // WEAR_LEVELING_BACKING_SIZE
+
+// 1kB logical EEPROM
+#ifndef WEAR_LEVELING_LOGICAL_SIZE
+# define WEAR_LEVELING_LOGICAL_SIZE 1024
+#endif // WEAR_LEVELING_LOGICAL_SIZE
diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy.c b/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy.c
new file mode 100644
index 0000000000..87126c4467
--- /dev/null
+++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy.c
@@ -0,0 +1,59 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <stdbool.h>
+#include <hal.h>
+#include "timer.h"
+#include "wear_leveling.h"
+#include "wear_leveling_internal.h"
+#include "flash_stm32.h"
+
+bool backing_store_init(void) {
+ bs_dprintf("Init\n");
+ return true;
+}
+
+bool backing_store_unlock(void) {
+ bs_dprintf("Unlock\n");
+ FLASH_Unlock();
+ return true;
+}
+
+bool backing_store_erase(void) {
+#ifdef WEAR_LEVELING_DEBUG_OUTPUT
+ uint32_t start = timer_read32();
+#endif
+
+ bool ret = true;
+ FLASH_Status status;
+ for (int i = 0; i < (WEAR_LEVELING_LEGACY_EMULATION_PAGE_COUNT); ++i) {
+ status = FLASH_ErasePage(WEAR_LEVELING_LEGACY_EMULATION_BASE_PAGE_ADDRESS + (i * (WEAR_LEVELING_LEGACY_EMULATION_PAGE_SIZE)));
+ if (status != FLASH_COMPLETE) {
+ ret = false;
+ }
+ }
+
+ bs_dprintf("Backing store erase took %ldms to complete\n", ((long)(timer_read32() - start)));
+ return ret;
+}
+
+bool backing_store_write(uint32_t address, backing_store_int_t value) {
+ uint32_t offset = ((WEAR_LEVELING_LEGACY_EMULATION_BASE_PAGE_ADDRESS) + address);
+ bs_dprintf("Write ");
+ wl_dump(offset, &value, sizeof(backing_store_int_t));
+ return FLASH_ProgramHalfWord(offset, ~value) == FLASH_COMPLETE;
+}
+
+bool backing_store_lock(void) {
+ bs_dprintf("Lock \n");
+ FLASH_Lock();
+ return true;
+}
+
+bool backing_store_read(uint32_t address, backing_store_int_t* value) {
+ uint32_t offset = ((WEAR_LEVELING_LEGACY_EMULATION_BASE_PAGE_ADDRESS) + address);
+ backing_store_int_t* loc = (backing_store_int_t*)offset;
+ *value = ~(*loc);
+ bs_dprintf("Read ");
+ wl_dump(offset, loc, sizeof(backing_store_int_t));
+ return true;
+}
diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy_config.h b/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy_config.h
new file mode 100644
index 0000000000..e64cab87d1
--- /dev/null
+++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy_config.h
@@ -0,0 +1,67 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+// Work out the page size to use
+#ifndef WEAR_LEVELING_LEGACY_EMULATION_PAGE_SIZE
+# if defined(QMK_MCU_STM32F042)
+# define WEAR_LEVELING_LEGACY_EMULATION_PAGE_SIZE 1024
+# elif defined(QMK_MCU_STM32F070) || defined(QMK_MCU_STM32F072)
+# define WEAR_LEVELING_LEGACY_EMULATION_PAGE_SIZE 2048
+# elif defined(QMK_MCU_STM32F401) || defined(QMK_MCU_STM32F411)
+# define WEAR_LEVELING_LEGACY_EMULATION_PAGE_SIZE 16384
+# endif
+#endif
+
+// Work out how much flash space we have
+#ifndef WEAR_LEVELING_LEGACY_EMULATION_FLASH_SIZE
+# define WEAR_LEVELING_LEGACY_EMULATION_FLASH_SIZE ((*(uint32_t *)FLASHSIZE_BASE) & 0xFFFFU) // in kB
+#endif
+
+// The base location of program memory
+#ifndef WEAR_LEVELING_LEGACY_EMULATION_FLASH_BASE
+# define WEAR_LEVELING_LEGACY_EMULATION_FLASH_BASE 0x08000000
+#endif
+
+// The number of pages to use
+#ifndef WEAR_LEVELING_LEGACY_EMULATION_PAGE_COUNT
+# if defined(QMK_MCU_STM32F042)
+# define WEAR_LEVELING_LEGACY_EMULATION_PAGE_COUNT 2
+# elif defined(QMK_MCU_STM32F070) || defined(QMK_MCU_STM32F072)
+# define WEAR_LEVELING_LEGACY_EMULATION_PAGE_COUNT 1
+# elif defined(QMK_MCU_STM32F401) || defined(QMK_MCU_STM32F411)
+# define WEAR_LEVELING_LEGACY_EMULATION_PAGE_COUNT 1
+# endif
+#endif
+
+// The origin of the emulated eeprom
+#ifndef WEAR_LEVELING_LEGACY_EMULATION_BASE_PAGE_ADDRESS
+# if defined(QMK_MCU_STM32F042) || defined(QMK_MCU_STM32F070) || defined(QMK_MCU_STM32F072)
+# define WEAR_LEVELING_LEGACY_EMULATION_BASE_PAGE_ADDRESS ((uintptr_t)(WEAR_LEVELING_LEGACY_EMULATION_FLASH_BASE) + WEAR_LEVELING_LEGACY_EMULATION_FLASH_SIZE * 1024 - (WEAR_LEVELING_LEGACY_EMULATION_PAGE_COUNT * WEAR_LEVELING_LEGACY_EMULATION_PAGE_SIZE))
+# elif defined(QMK_MCU_STM32F401) || defined(QMK_MCU_STM32F411)
+# if defined(BOOTLOADER_STM32_DFU)
+# define WEAR_LEVELING_LEGACY_EMULATION_BASE_PAGE_ADDRESS (WEAR_LEVELING_LEGACY_EMULATION_FLASH_BASE + (1 * (WEAR_LEVELING_LEGACY_EMULATION_PAGE_SIZE))) // +16k
+# elif defined(BOOTLOADER_TINYUF2)
+# define WEAR_LEVELING_LEGACY_EMULATION_BASE_PAGE_ADDRESS (WEAR_LEVELING_LEGACY_EMULATION_FLASH_BASE + (3 * (WEAR_LEVELING_LEGACY_EMULATION_PAGE_SIZE))) // +48k
+# endif
+# endif
+#endif
+
+// 2-byte writes
+#ifndef BACKING_STORE_WRITE_SIZE
+# define BACKING_STORE_WRITE_SIZE 2
+#endif
+
+// The amount of space to use for the entire set of emulation
+#ifndef WEAR_LEVELING_BACKING_SIZE
+# if defined(QMK_MCU_STM32F042) || defined(QMK_MCU_STM32F070) || defined(QMK_MCU_STM32F072)
+# define WEAR_LEVELING_BACKING_SIZE 2048
+# elif defined(QMK_MCU_STM32F401) || defined(QMK_MCU_STM32F411)
+# define WEAR_LEVELING_BACKING_SIZE 16384
+# endif
+#endif
+
+// The logical amount of eeprom available
+#ifndef WEAR_LEVELING_LOGICAL_SIZE
+# define WEAR_LEVELING_LOGICAL_SIZE 1024
+#endif
diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c b/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c
new file mode 100644
index 0000000000..640628e1e9
--- /dev/null
+++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c
@@ -0,0 +1,221 @@
+/**
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ * Copyright (c) 2022 Nick Brassel (@tzarc)
+ * Copyright (c) 2022 Stefan Kerkmann (@KarlK90)
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "pico/bootrom.h"
+#include "hardware/flash.h"
+#include "hardware/sync.h"
+#include "hardware/structs/ssi.h"
+#include "hardware/structs/ioqspi.h"
+
+#include <stdbool.h>
+#include "timer.h"
+#include "wear_leveling.h"
+#include "wear_leveling_internal.h"
+
+#ifndef WEAR_LEVELING_RP2040_FLASH_BULK_COUNT
+# define WEAR_LEVELING_RP2040_FLASH_BULK_COUNT 64
+#endif // WEAR_LEVELING_RP2040_FLASH_BULK_COUNT
+
+#define FLASHCMD_PAGE_PROGRAM 0x02
+#define FLASHCMD_READ_STATUS 0x05
+#define FLASHCMD_WRITE_ENABLE 0x06
+
+extern uint8_t BOOT2_ROM[256];
+static uint32_t BOOT2_ROM_RAM[64];
+
+static ssi_hw_t *const ssi = (ssi_hw_t *)XIP_SSI_BASE;
+
+// Sanity check
+check_hw_layout(ssi_hw_t, ssienr, SSI_SSIENR_OFFSET);
+check_hw_layout(ssi_hw_t, spi_ctrlr0, SSI_SPI_CTRLR0_OFFSET);
+
+static void __no_inline_not_in_flash_func(flash_enable_xip_via_boot2)(void) {
+ ((void (*)(void))BOOT2_ROM_RAM + 1)();
+}
+
+// Bitbanging the chip select using IO overrides, in case RAM-resident IRQs
+// are still running, and the FIFO bottoms out. (the bootrom does the same)
+static void __no_inline_not_in_flash_func(flash_cs_force)(bool high) {
+ uint32_t field_val = high ? IO_QSPI_GPIO_QSPI_SS_CTRL_OUTOVER_VALUE_HIGH : IO_QSPI_GPIO_QSPI_SS_CTRL_OUTOVER_VALUE_LOW;
+ hw_write_masked(&ioqspi_hw->io[1].ctrl, field_val << IO_QSPI_GPIO_QSPI_SS_CTRL_OUTOVER_LSB, IO_QSPI_GPIO_QSPI_SS_CTRL_OUTOVER_BITS);
+}
+
+// Also allow any unbounded loops to check whether the above abort condition
+// was asserted, and terminate early
+static int __no_inline_not_in_flash_func(flash_was_aborted)(void) {
+ return *(io_rw_32 *)(IO_QSPI_BASE + IO_QSPI_GPIO_QSPI_SD1_CTRL_OFFSET) & IO_QSPI_GPIO_QSPI_SD1_CTRL_INOVER_BITS;
+}
+
+// Put bytes from one buffer, and get bytes into another buffer.
+// These can be the same buffer.
+// If tx is NULL then send zeroes.
+// If rx is NULL then all read data will be dropped.
+//
+// If rx_skip is nonzero, this many bytes will first be consumed from the FIFO,
+// before reading a further count bytes into *rx.
+// E.g. if you have written a command+address just before calling this function.
+static void __no_inline_not_in_flash_func(flash_put_get)(const uint8_t *tx, uint8_t *rx, size_t count, size_t rx_skip) {
+ // Make sure there is never more data in flight than the depth of the RX
+ // FIFO. Otherwise, when we are interrupted for long periods, hardware
+ // will overflow the RX FIFO.
+ const uint max_in_flight = 16 - 2; // account for data internal to SSI
+ size_t tx_count = count;
+ size_t rx_count = count;
+ while (tx_count || rx_skip || rx_count) {
+ // NB order of reads, for pessimism rather than optimism
+ uint32_t tx_level = ssi_hw->txflr;
+ uint32_t rx_level = ssi_hw->rxflr;
+ bool did_something = false; // Expect this to be folded into control flow, not register
+ if (tx_count && tx_level + rx_level < max_in_flight) {
+ ssi->dr0 = (uint32_t)(tx ? *tx++ : 0);
+ --tx_count;
+ did_something = true;
+ }
+ if (rx_level) {
+ uint8_t rxbyte = ssi->dr0;
+ did_something = true;
+ if (rx_skip) {
+ --rx_skip;
+ } else {
+ if (rx) *rx++ = rxbyte;
+ --rx_count;
+ }
+ }
+ // APB load costs 4 cycles, so only do it on idle loops (our budget is
+ // 48 cyc/byte)
+ if (!did_something && __builtin_expect(flash_was_aborted(), 0)) break;
+ }
+ flash_cs_force(1);
+}
+
+// Convenience wrapper for above
+// (And it's hard for the debug host to get the tight timing between
+// cmd DR0 write and the remaining data)
+static void __no_inline_not_in_flash_func(_flash_do_cmd)(uint8_t cmd, const uint8_t *tx, uint8_t *rx, size_t count) {
+ flash_cs_force(0);
+ ssi->dr0 = cmd;
+ flash_put_get(tx, rx, count, 1);
+}
+
+// Timing of this one is critical, so do not expose the symbol to debugger etc
+static void __no_inline_not_in_flash_func(flash_put_cmd_addr)(uint8_t cmd, uint32_t addr) {
+ flash_cs_force(0);
+ addr |= cmd << 24;
+ for (int i = 0; i < 4; ++i) {
+ ssi->dr0 = addr >> 24;
+ addr <<= 8;
+ }
+}
+
+// Poll the flash status register until the busy bit (LSB) clears
+static void __no_inline_not_in_flash_func(flash_wait_ready)(void) {
+ uint8_t stat;
+ do {
+ _flash_do_cmd(FLASHCMD_READ_STATUS, NULL, &stat, 1);
+ } while (stat & 0x1 && !flash_was_aborted());
+}
+
+// Set the WEL bit (needed before any program/erase operation)
+static void __no_inline_not_in_flash_func(flash_enable_write)(void) {
+ _flash_do_cmd(FLASHCMD_WRITE_ENABLE, NULL, NULL, 0);
+}
+
+static void __no_inline_not_in_flash_func(pico_program_bulk)(uint32_t flash_address, backing_store_int_t *values, size_t item_count) {
+ rom_connect_internal_flash_fn connect_internal_flash = (rom_connect_internal_flash_fn)rom_func_lookup_inline(ROM_FUNC_CONNECT_INTERNAL_FLASH);
+ rom_flash_exit_xip_fn flash_exit_xip = (rom_flash_exit_xip_fn)rom_func_lookup_inline(ROM_FUNC_FLASH_EXIT_XIP);
+ rom_flash_flush_cache_fn flash_flush_cache = (rom_flash_flush_cache_fn)rom_func_lookup_inline(ROM_FUNC_FLASH_FLUSH_CACHE);
+ assert(connect_internal_flash && flash_exit_xip && flash_flush_cache);
+
+ static backing_store_int_t bulk_write_buffer[WEAR_LEVELING_RP2040_FLASH_BULK_COUNT];
+
+ while (item_count) {
+ size_t batch_size = MIN(item_count, WEAR_LEVELING_RP2040_FLASH_BULK_COUNT);
+ for (size_t i = 0; i < batch_size; i++, values++, item_count--) {
+ bulk_write_buffer[i] = ~(*values);
+ }
+ __compiler_memory_barrier();
+
+ connect_internal_flash();
+ flash_exit_xip();
+ flash_enable_write();
+
+ flash_put_cmd_addr(FLASHCMD_PAGE_PROGRAM, flash_address);
+ flash_put_get((uint8_t *)bulk_write_buffer, NULL, batch_size * sizeof(backing_store_int_t), 4);
+ flash_wait_ready();
+ flash_address += batch_size * sizeof(backing_store_int_t);
+
+ flash_flush_cache();
+ flash_enable_xip_via_boot2();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// QMK Wear-Leveling Backing Store implementation
+
+static int interrupts;
+
+bool backing_store_init(void) {
+ bs_dprintf("Init\n");
+ memcpy(BOOT2_ROM_RAM, BOOT2_ROM, sizeof(BOOT2_ROM));
+ __compiler_memory_barrier();
+ return true;
+}
+
+bool backing_store_unlock(void) {
+ bs_dprintf("Unlock\n");
+ return true;
+}
+
+bool backing_store_erase(void) {
+#ifdef WEAR_LEVELING_DEBUG_OUTPUT
+ uint32_t start = timer_read32();
+#endif
+
+ // Ensure the backing size can be cleanly subtracted from the flash size without alignment issues.
+ _Static_assert((WEAR_LEVELING_BACKING_SIZE) % (FLASH_SECTOR_SIZE) == 0, "Backing size must be a multiple of FLASH_SECTOR_SIZE");
+
+ interrupts = save_and_disable_interrupts();
+ flash_range_erase((WEAR_LEVELING_RP2040_FLASH_BASE), (WEAR_LEVELING_BACKING_SIZE));
+ restore_interrupts(interrupts);
+
+ bs_dprintf("Backing store erase took %ldms to complete\n", ((long)(timer_read32() - start)));
+ return true;
+}
+
+bool backing_store_write(uint32_t address, backing_store_int_t value) {
+ return backing_store_write_bulk(address, &value, 1);
+}
+
+bool backing_store_write_bulk(uint32_t address, backing_store_int_t *values, size_t item_count) {
+ uint32_t offset = (WEAR_LEVELING_RP2040_FLASH_BASE) + address;
+ bs_dprintf("Write ");
+ wl_dump(offset, values, sizeof(backing_store_int_t) * item_count);
+ interrupts = save_and_disable_interrupts();
+ pico_program_bulk(offset, values, item_count);
+ restore_interrupts(interrupts);
+ return true;
+}
+
+bool backing_store_lock(void) {
+ return true;
+}
+
+bool backing_store_read(uint32_t address, backing_store_int_t *value) {
+ return backing_store_read_bulk(address, value, 1);
+}
+
+bool backing_store_read_bulk(uint32_t address, backing_store_int_t *values, size_t item_count) {
+ uint32_t offset = (WEAR_LEVELING_RP2040_FLASH_BASE) + address;
+ backing_store_int_t *loc = (backing_store_int_t *)((XIP_BASE) + offset);
+ for (size_t i = 0; i < item_count; ++i) {
+ values[i] = ~loc[i];
+ }
+ bs_dprintf("Read ");
+ wl_dump(offset, values, item_count * sizeof(backing_store_int_t));
+ return true;
+}
diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash_config.h b/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash_config.h
new file mode 100644
index 0000000000..93a9aa0372
--- /dev/null
+++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash_config.h
@@ -0,0 +1,32 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#ifndef __ASSEMBLER__
+# include "hardware/flash.h"
+#endif
+
+// 2-byte writes
+#ifndef BACKING_STORE_WRITE_SIZE
+# define BACKING_STORE_WRITE_SIZE 2
+#endif
+
+// 64kB backing space allocated
+#ifndef WEAR_LEVELING_BACKING_SIZE
+# define WEAR_LEVELING_BACKING_SIZE 8192
+#endif // WEAR_LEVELING_BACKING_SIZE
+
+// 32kB logical EEPROM
+#ifndef WEAR_LEVELING_LOGICAL_SIZE
+# define WEAR_LEVELING_LOGICAL_SIZE 4096
+#endif // WEAR_LEVELING_LOGICAL_SIZE
+
+// Define how much flash space we have (defaults to lib/pico-sdk/src/boards/include/boards/***)
+#ifndef WEAR_LEVELING_RP2040_FLASH_SIZE
+# define WEAR_LEVELING_RP2040_FLASH_SIZE (PICO_FLASH_SIZE_BYTES)
+#endif
+
+// Define the location of emulated EEPROM
+#ifndef WEAR_LEVELING_RP2040_FLASH_BASE
+# define WEAR_LEVELING_RP2040_FLASH_BASE ((WEAR_LEVELING_RP2040_FLASH_SIZE) - (WEAR_LEVELING_BACKING_SIZE))
+#endif
diff --git a/platforms/chibios/drivers/ws2812.c b/platforms/chibios/drivers/ws2812.c
index 1b3bb59842..55ac333b1e 100644
--- a/platforms/chibios/drivers/ws2812.c
+++ b/platforms/chibios/drivers/ws2812.c
@@ -6,7 +6,7 @@
/* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */
#ifndef NOP_FUDGE
-# if defined(STM32F0XX) || defined(STM32F1XX) || defined(GD32VF103) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX)
+# if defined(STM32F0XX) || defined(STM32F1XX) || defined(GD32VF103) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) || defined(WB32F3G71xx) || defined(WB32FQ95xx)
# define NOP_FUDGE 0.4
# else
# error("NOP_FUDGE configuration required")
diff --git a/platforms/chibios/drivers/ws2812_pwm.c b/platforms/chibios/drivers/ws2812_pwm.c
index 57187676d7..792de85ce9 100644
--- a/platforms/chibios/drivers/ws2812_pwm.c
+++ b/platforms/chibios/drivers/ws2812_pwm.c
@@ -29,6 +29,22 @@
# error "please consult your MCU's datasheet and specify in your config.h: #define WS2812_DMAMUX_ID STM32_DMAMUX1_TIM?_UP"
#endif
+/* Summarize https://www.st.com/resource/en/application_note/an4013-stm32-crossseries-timer-overview-stmicroelectronics.pdf to
+ * figure out if we are using a 32bit timer. This is needed to setup the DMA controller correctly.
+ * Ignore STM32H7XX and STM32U5XX as they are not supported by ChibiOS.
+ */
+#if !defined(STM32F1XX) && !defined(STM32L0XX) && !defined(STM32L1XX)
+# define WS2812_PWM_TIMER_32BIT_PWMD2 1
+#endif
+#if !defined(STM32F1XX)
+# define WS2812_PWM_TIMER_32BIT_PWMD5 1
+#endif
+#define WS2812_CONCAT1(a, b) a##b
+#define WS2812_CONCAT(a, b) WS2812_CONCAT1(a, b)
+#if WS2812_CONCAT(WS2812_PWM_TIMER_32BIT_, WS2812_PWM_DRIVER)
+# define WS2812_PWM_TIMER_32BIT
+#endif
+
#ifndef WS2812_PWM_COMPLEMENTARY_OUTPUT
# define WS2812_PWM_OUTPUT_MODE PWM_OUTPUT_ACTIVE_HIGH
#else
@@ -89,6 +105,9 @@
* The duty cycle is calculated for a high period of 350 nS.
*/
#define WS2812_DUTYCYCLE_0 (WS2812_PWM_FREQUENCY / (1000000000 / 350))
+#if (WS2812_DUTYCYCLE_0 > 255)
+# error WS2812 PWM driver: High period for a 0 is more than a byte
+#endif
/**
* @brief High period for a one, in ticks
@@ -105,6 +124,9 @@
* This is in the middle of the specifications of the WS2812 and WS2812B.
*/
#define WS2812_DUTYCYCLE_1 (WS2812_PWM_FREQUENCY / (1000000000 / 800))
+#if (WS2812_DUTYCYCLE_1 > 255)
+# error WS2812 PWM driver: High period for a 1 is more than a byte
+#endif
/* --- PRIVATE MACROS ------------------------------------------------------- */
@@ -247,13 +269,35 @@
/* --- PRIVATE VARIABLES ---------------------------------------------------- */
-static uint32_t ws2812_frame_buffer[WS2812_BIT_N + 1]; /**< Buffer for a frame */
+// STM32F2XX, STM32F4XX and STM32F7XX do NOT zero pad DMA transfers of unequal data width. Buffer width must match TIMx CCR.
+// For all other STM32 DMA transfer will automatically zero pad. We only need to set the right peripheral width.
+#if defined(STM32F2XX) || defined(STM32F4XX) || defined(STM32F7XX)
+# if defined(WS2812_PWM_TIMER_32BIT)
+# define WS2812_DMA_MEMORY_WIDTH STM32_DMA_CR_MSIZE_WORD
+# define WS2812_DMA_PERIPHERAL_WIDTH STM32_DMA_CR_PSIZE_WORD
+typedef uint32_t ws2812_buffer_t;
+# else
+# define WS2812_DMA_MEMORY_WIDTH STM32_DMA_CR_MSIZE_HWORD
+# define WS2812_DMA_PERIPHERAL_WIDTH STM32_DMA_CR_PSIZE_HWORD
+typedef uint16_t ws2812_buffer_t;
+# endif
+#else
+# define WS2812_DMA_MEMORY_WIDTH STM32_DMA_CR_MSIZE_BYTE
+# if defined(WS2812_PWM_TIMER_32BIT)
+# define WS2812_DMA_PERIPHERAL_WIDTH STM32_DMA_CR_PSIZE_WORD
+# else
+# define WS2812_DMA_PERIPHERAL_WIDTH STM32_DMA_CR_PSIZE_HWORD
+# endif
+typedef uint8_t ws2812_buffer_t;
+#endif
+
+static ws2812_buffer_t ws2812_frame_buffer[WS2812_BIT_N + 1]; /**< Buffer for a frame */
/* --- PUBLIC FUNCTIONS ----------------------------------------------------- */
/*
* Gedanke: Double-buffer type transactions: double buffer transfers using two memory pointers for
-the memory (while the DMA is reading/writing from/to a buffer, the application can
-write/read to/from the other buffer).
+ * the memory (while the DMA is reading/writing from/to a buffer, the application can
+ * write/read to/from the other buffer).
*/
void ws2812_init(void) {
@@ -284,11 +328,18 @@ void ws2812_init(void) {
// Configure DMA
// dmaInit(); // Joe added this
+#if defined(WB32F3G71xx) || defined(WB32FQ95xx)
+ dmaStreamAlloc(WS2812_DMA_STREAM - WB32_DMA_STREAM(0), 10, NULL, NULL);
+ dmaStreamSetSource(WS2812_DMA_STREAM, ws2812_frame_buffer);
+ dmaStreamSetDestination(WS2812_DMA_STREAM, &(WS2812_PWM_DRIVER.tim->CCR[WS2812_PWM_CHANNEL - 1])); // Ziel ist der An-Zeit im Cap-Comp-Register
+ dmaStreamSetMode(WS2812_DMA_STREAM, WB32_DMA_CHCFG_HWHIF(WS2812_DMA_CHANNEL) | WB32_DMA_CHCFG_DIR_M2P | WB32_DMA_CHCFG_PSIZE_WORD | WB32_DMA_CHCFG_MSIZE_WORD | WB32_DMA_CHCFG_MINC | WB32_DMA_CHCFG_CIRC | WB32_DMA_CHCFG_TCIE | WB32_DMA_CHCFG_PL(3));
+#else
dmaStreamAlloc(WS2812_DMA_STREAM - STM32_DMA_STREAM(0), 10, NULL, NULL);
dmaStreamSetPeripheral(WS2812_DMA_STREAM, &(WS2812_PWM_DRIVER.tim->CCR[WS2812_PWM_CHANNEL - 1])); // Ziel ist der An-Zeit im Cap-Comp-Register
dmaStreamSetMemory0(WS2812_DMA_STREAM, ws2812_frame_buffer);
+ dmaStreamSetMode(WS2812_DMA_STREAM, STM32_DMA_CR_CHSEL(WS2812_DMA_CHANNEL) | STM32_DMA_CR_DIR_M2P | WS2812_DMA_PERIPHERAL_WIDTH | WS2812_DMA_MEMORY_WIDTH | STM32_DMA_CR_MINC | STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(3));
+#endif
dmaStreamSetTransactionSize(WS2812_DMA_STREAM, WS2812_BIT_N);
- dmaStreamSetMode(WS2812_DMA_STREAM, STM32_DMA_CR_CHSEL(WS2812_DMA_CHANNEL) | STM32_DMA_CR_DIR_M2P | STM32_DMA_CR_PSIZE_WORD | STM32_DMA_CR_MSIZE_WORD | STM32_DMA_CR_MINC | STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(3));
// M2P: Memory 2 Periph; PL: Priority Level
#if (STM32_DMA_SUPPORTS_DMAMUX == TRUE)
diff --git a/platforms/chibios/drivers/ws2812_spi.c b/platforms/chibios/drivers/ws2812_spi.c
index 01d8148875..a73eb69720 100644
--- a/platforms/chibios/drivers/ws2812_spi.c
+++ b/platforms/chibios/drivers/ws2812_spi.c
@@ -16,6 +16,10 @@
# define WS2812_SPI_SCK_PAL_MODE 5
#endif
+#ifndef WS2812_SPI_DIVISOR
+# define WS2812_SPI_DIVISOR 16
+#endif
+
// Push Pull or Open Drain Configuration
// Default Push Pull
#ifndef WS2812_EXTERNAL_PULLUP
@@ -42,7 +46,7 @@
# define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_0)
#elif WS2812_SPI_DIVISOR == 8
# define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_1)
-#elif WS2812_SPI_DIVISOR == 16 // same as default
+#elif WS2812_SPI_DIVISOR == 16 // default
# define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_1 | SPI_CR1_BR_0)
#elif WS2812_SPI_DIVISOR == 32
# define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_2)
@@ -53,7 +57,7 @@
#elif WS2812_SPI_DIVISOR == 256
# define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0)
#else
-# define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_1 | SPI_CR1_BR_0) // default
+# error "Configured WS2812_SPI_DIVISOR value is not supported at this time."
#endif
// Use SPI circular buffer
@@ -148,8 +152,14 @@ void ws2812_init(void) {
NULL, // end_cb
PAL_PORT(RGB_DI_PIN),
PAL_PAD(RGB_DI_PIN),
+# if defined(WB32F3G71xx) || defined(WB32FQ95xx)
+ 0,
+ 0,
+ WS2812_SPI_DIVISOR
+# else
WS2812_SPI_DIVISOR_CR1_BR_X,
0
+# endif
#else
// HAL_SPI_V2
# if SPI_SUPPORTS_CIRCULAR == TRUE
diff --git a/platforms/chibios/drivers/wt_rgb_backlight.c b/platforms/chibios/drivers/wt_rgb_backlight.c
index a696fe7ed4..af4b84c5cf 100644
--- a/platforms/chibios/drivers/wt_rgb_backlight.c
+++ b/platforms/chibios/drivers/wt_rgb_backlight.c
@@ -144,7 +144,6 @@ backlight_config g_config = {
};
bool g_suspend_state = false;
-uint8_t g_indicator_state = 0;
// Global tick at 20 Hz
uint32_t g_tick = 0;
@@ -1982,11 +1981,6 @@ void backlight_set_suspend_state(bool state)
g_suspend_state = state;
}
-void backlight_set_indicator_state(uint8_t state)
-{
- g_indicator_state = state;
-}
-
void backlight_effect_rgb_test(void)
{
// Mask out bits 4 and 5
@@ -2425,8 +2419,7 @@ void backlight_effect_indicators_set_colors( uint8_t index, HS color )
// colors already set
void backlight_effect_indicators(void)
{
- if ( g_config.caps_lock_indicator.index != 255 &&
- ( g_indicator_state & (1<<USB_LED_CAPS_LOCK) ) )
+ if ( g_config.caps_lock_indicator.index != 255 && host_keyboard_led_state().caps_lock )
{
backlight_effect_indicators_set_colors( g_config.caps_lock_indicator.index, g_config.caps_lock_indicator.color );
}
diff --git a/platforms/chibios/drivers/wt_rgb_backlight.h b/platforms/chibios/drivers/wt_rgb_backlight.h
index 529f84636a..2114789213 100644
--- a/platforms/chibios/drivers/wt_rgb_backlight.h
+++ b/platforms/chibios/drivers/wt_rgb_backlight.h
@@ -81,7 +81,6 @@ void backlight_timer_enable(void);
void backlight_timer_disable(void);
void backlight_set_suspend_state(bool state);
-void backlight_set_indicator_state(uint8_t state);
// This should not be called from an interrupt
// (eg. from a timer interrupt).
diff --git a/platforms/chibios/flash.mk b/platforms/chibios/flash.mk
index a91ef2cf35..023da34bb5 100644
--- a/platforms/chibios/flash.mk
+++ b/platforms/chibios/flash.mk
@@ -54,11 +54,11 @@ endef
# TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS
# within the emulated eeprom via dfu-util or another tool
-ifneq (,$(filter $(MAKECMDGOALS),dfu-util-split-left))
+ifneq (,$(filter $(MAKECMDGOALS), dfu-util-split-left uf2-split-left))
OPT_DEFS += -DINIT_EE_HANDS_LEFT
endif
-ifneq (,$(filter $(MAKECMDGOALS),dfu-util-split-right))
+ifneq (,$(filter $(MAKECMDGOALS), dfu-util-split-right uf2-split-right))
OPT_DEFS += -DINIT_EE_HANDS_RIGHT
endif
@@ -66,6 +66,10 @@ dfu-util-split-left: dfu-util
dfu-util-split-right: dfu-util
+uf2-split-left: flash
+
+uf2-split-right: flash
+
ST_LINK_CLI ?= st-link_cli
ST_LINK_ARGS ?=
@@ -96,14 +100,16 @@ endef
teensy: $(BUILD_DIR)/$(TARGET).hex cpfirmware sizeafter
$(call EXEC_TEENSY)
-
flash: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
+ $(SILENT) || printf "Flashing for bootloader: $(BLUE)$(BOOTLOADER)$(NO_COLOR)\n"
ifneq ($(strip $(PROGRAM_CMD)),)
$(UNSYNC_OUTPUT_CMD) && $(PROGRAM_CMD)
else ifeq ($(strip $(BOOTLOADER)),kiibohd)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL)
else ifeq ($(strip $(BOOTLOADER)),tinyuf2)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_UF2_UTIL_DEPLOY)
+else ifeq ($(strip $(BOOTLOADER)),rp2040)
+ $(UNSYNC_OUTPUT_CMD) && $(call EXEC_UF2_UTIL_DEPLOY)
else ifeq ($(strip $(MCU_FAMILY)),KINETIS)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_TEENSY)
else ifeq ($(strip $(MCU_FAMILY)),MIMXRT1062)
diff --git a/platforms/chibios/gd32v_compatibility.h b/platforms/chibios/gd32v_compatibility.h
index a3148fb6d2..d01c3d00a2 100644
--- a/platforms/chibios/gd32v_compatibility.h
+++ b/platforms/chibios/gd32v_compatibility.h
@@ -35,7 +35,9 @@
#define STM32_DMA_STREAM_ID(peripheral, channel) GD32_DMA_STREAM_ID(peripheral - 1, channel - 1)
#define STM32_DMA_CR_DIR_M2P GD32_DMA_CTL_DIR_M2P
#define STM32_DMA_CR_PSIZE_WORD GD32_DMA_CTL_PWIDTH_WORD
+#define STM32_DMA_CR_PSIZE_HWORD GD32_DMA_CTL_PWIDTH_HWORD
#define STM32_DMA_CR_MSIZE_WORD GD32_DMA_CTL_MWIDTH_WORD
+#define STM32_DMA_CR_MSIZE_BYTE GD32_DMA_CTL_MWIDTH_BYTE
#define STM32_DMA_CR_MINC GD32_DMA_CTL_MNAGA
#define STM32_DMA_CR_CIRC GD32_DMA_CTL_CMEN
#define STM32_DMA_CR_PL GD32_DMA_CTL_PRIO
diff --git a/platforms/chibios/platform.mk b/platforms/chibios/platform.mk
index 21751f23fd..b2a8ec89e1 100644
--- a/platforms/chibios/platform.mk
+++ b/platforms/chibios/platform.mk
@@ -36,6 +36,7 @@ ifeq ($(strip $(MCU)), risc-v)
# RISC-V Support
# As of 7.4.2021 there is only one supported RISC-V platform in Chibios-Contrib,
# therefore all required settings are hard-coded
+ USE_CHIBIOS_CONTRIB = yes
STARTUP_MK = $(CHIBIOS_CONTRIB)/os/common/startup/RISCV-ECLIC/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
PORT_V = $(CHIBIOS_CONTRIB)/os/common/ports/RISCV-ECLIC/compilers/GCC/mk/port.mk
RULESPATH = $(CHIBIOS_CONTRIB)/os/common/startup/RISCV-ECLIC/compilers/GCC
@@ -87,12 +88,17 @@ ifeq ("$(MCU_PORT_NAME)","")
endif
ifeq ("$(wildcard $(PLATFORM_MK))","")
- PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)/$(PLATFORM_NAME).mk
+ PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)/$(PLATFORM_NAME).mk
ifeq ("$(wildcard $(PLATFORM_MK))","")
- PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)/$(PLATFORM_NAME).mk
+ PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)/$(PLATFORM_NAME).mk
endif
endif
+# If no MCU architecture specified, use the MCU instead (allows for mcu_selection.mk to swap to cortex-m0 etc.)
+ifeq ("$(MCU_ARCH)","")
+ MCU_ARCH = $(MCU)
+endif
+
include $(STARTUP_MK)
include $(PORT_V)
include $(PLATFORM_MK)
@@ -282,6 +288,17 @@ EXTRAINCDIRS += $(CHIBIOS)/os/license $(CHIBIOS)/os/oslib/include \
$(STREAMSINC) $(CHIBIOS)/os/various $(COMMON_VPATH)
#
+# QMK specific MCU family support selection.
+##############################################################################
+ifneq ("$(wildcard $(PLATFORM_PATH)/$(PLATFORM_KEY)/vendors/$(MCU_FAMILY)/$(MCU_SERIES).mk)","")
+ # Either by MCU series e.g. STM32/STM32F1xx.mk or...
+ include $(PLATFORM_PATH)/$(PLATFORM_KEY)/vendors/$(MCU_FAMILY)/$(MCU_SERIES).mk
+else ifneq ("$(wildcard $(PLATFORM_PATH)/$(PLATFORM_KEY)/vendors/$(MCU_FAMILY)/$(MCU_FAMILY).mk)","")
+ # By MCU family e.g. STM32/STM32.mk
+ include $(PLATFORM_PATH)/$(PLATFORM_KEY)/vendors/$(MCU_FAMILY)/$(MCU_FAMILY).mk
+endif
+
+#
# ChibiOS-Contrib
##############################################################################
@@ -332,10 +349,14 @@ SHARED_CFLAGS = -fomit-frame-pointer \
-ffunction-sections \
-fdata-sections \
-fno-common \
- -fshort-wchar
+ -fshort-wchar \
+ -fno-builtin-printf
+
+LDSCRIPT_PATH := $(shell dirname "$(LDSCRIPT)")
# Shared Linker flags for all toolchains
SHARED_LDFLAGS = -T $(LDSCRIPT) \
+ -L $(LDSCRIPT_PATH) \
-Wl,--gc-sections \
-nostartfiles
diff --git a/platforms/chibios/vendors/RP/RP2040.mk b/platforms/chibios/vendors/RP/RP2040.mk
new file mode 100644
index 0000000000..de426c9c40
--- /dev/null
+++ b/platforms/chibios/vendors/RP/RP2040.mk
@@ -0,0 +1,287 @@
+#
+# Raspberry Pi RP2040 specific drivers
+##############################################################################
+COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/vendor/$(MCU_FAMILY)/$(MCU_SERIES)
+
+ifeq ($(strip $(WS2812_DRIVER)), vendor)
+ OPT_DEFS += -DRP_DMA_REQUIRED=TRUE
+endif
+
+#
+# Raspberry Pi Pico SDK Support
+##############################################################################
+ADEFS += -DCRT0_VTOR_INIT=1 \
+ -DCRT0_EXTRA_CORES_NUMBER=0
+
+CFLAGS += -DPICO_NO_FPGA_CHECK \
+ -DNDEBUG
+
+#
+# Pico SDK source and header files needed by QMK and ChibiOS
+##############################################################################
+PICOSDKROOT := $(TOP_DIR)/lib/pico-sdk
+
+PICOSDKSRC = $(PICOSDKROOT)/src/rp2_common/hardware_clocks/clocks.c \
+ $(PICOSDKROOT)/src/rp2_common/hardware_pll/pll.c \
+ $(PICOSDKROOT)/src/rp2_common/hardware_pio/pio.c \
+ $(PICOSDKROOT)/src/rp2_common/hardware_flash/flash.c \
+ $(PICOSDKROOT)/src/rp2_common/hardware_gpio/gpio.c \
+ $(PICOSDKROOT)/src/rp2_common/hardware_claim/claim.c \
+ $(PICOSDKROOT)/src/rp2_common/hardware_watchdog/watchdog.c \
+ $(PICOSDKROOT)/src/rp2_common/hardware_xosc/xosc.c \
+ $(PICOSDKROOT)/src/rp2_common/pico_bootrom/bootrom.c
+
+PICOSDKINC = $(CHIBIOS)//os/various/pico_bindings/dumb/include \
+ $(PICOSDKROOT)/src/common/pico_base/include \
+ $(PICOSDKROOT)/src/rp2_common/pico_platform/include \
+ $(PICOSDKROOT)/src/rp2_common/hardware_base/include \
+ $(PICOSDKROOT)/src/rp2_common/hardware_clocks/include \
+ $(PICOSDKROOT)/src/rp2_common/hardware_claim/include \
+ $(PICOSDKROOT)/src/rp2_common/hardware_flash/include \
+ $(PICOSDKROOT)/src/rp2_common/hardware_gpio/include \
+ $(PICOSDKROOT)/src/rp2_common/hardware_irq/include \
+ $(PICOSDKROOT)/src/rp2_common/hardware_pll/include \
+ $(PICOSDKROOT)/src/rp2_common/hardware_pio/include \
+ $(PICOSDKROOT)/src/rp2_common/hardware_sync/include \
+ $(PICOSDKROOT)/src/rp2_common/hardware_resets/include \
+ $(PICOSDKROOT)/src/rp2_common/hardware_watchdog/include \
+ $(PICOSDKROOT)/src/rp2_common/hardware_xosc/include \
+ $(PICOSDKROOT)/src/rp2040/hardware_regs/include \
+ $(PICOSDKROOT)/src/rp2040/hardware_structs/include \
+ $(PICOSDKROOT)/src/boards/include \
+ $(PICOSDKROOT)/src/rp2_common/pico_bootrom/include
+
+PLATFORM_SRC += $(PICOSDKSRC)
+EXTRAINCDIRS += $(PICOSDKINC)
+
+PLATFORM_RP2040_PATH := $(PLATFORM_PATH)/$(PLATFORM_KEY)/vendors/$(MCU_FAMILY)
+
+PLATFORM_SRC += $(PLATFORM_RP2040_PATH)/stage2_bootloaders.c \
+ $(PLATFORM_RP2040_PATH)/pico_sdk_shims.c
+
+EXTRAINCDIRS += $(PLATFORM_RP2040_PATH)
+
+#
+# RP2040 optimized compiler intrinsics
+##############################################################################
+
+# Enables optimized Compiler intrinsics which are located in the RP2040
+# bootrom. This needs startup code and linker script support from ChibiOS,
+# which is WIP. Therefore disabled by default for now.
+RP2040_INTRINSICS_ENABLED ?= no
+ifeq ($(strip $(RP2040_INTRINSICS_ENABLED)), yes)
+ PICOSDKINTRINSICSSRC = $(PICOSDKROOT)/src/rp2_common/pico_float/float_aeabi.S \
+ $(PICOSDKROOT)/src/rp2_common/pico_float/float_math.c \
+ $(PICOSDKROOT)/src/rp2_common/pico_float/float_init_rom.c \
+ $(PICOSDKROOT)/src/rp2_common/pico_float/float_v1_rom_shim.S \
+ $(PICOSDKROOT)/src/rp2_common/pico_double/double_aeabi.S \
+ $(PICOSDKROOT)/src/rp2_common/pico_double/double_math.c \
+ $(PICOSDKROOT)/src/rp2_common/pico_double/double_init_rom.c \
+ $(PICOSDKROOT)/src/rp2_common/pico_double/double_v1_rom_shim.S \
+ $(PICOSDKROOT)/src/rp2_common/pico_divider/divider.S \
+ $(PICOSDKROOT)/src/rp2_common/pico_int64_ops/pico_int64_ops_aeabi.S \
+ $(PICOSDKROOT)/src/rp2_common/pico_mem_ops/mem_ops_aeabi.S \
+ $(PICOSDKROOT)/src/rp2_common/pico_malloc/pico_malloc.c \
+ $(PICOSDKROOT)/src/rp2_common/pico_bit_ops/bit_ops_aeabi.S
+
+ PICOSDKINTRINSICSINC = $(PICOSDKROOT)/src/common/pico_base/include \
+ $(PICOSDKROOT)/src/rp2_common/pico_platfrom/include \
+ $(PICOSDKROOT)/src/rp2_common/pico_bootrom/include \
+ $(PICOSDKROOT)/src/rp2_common/hardware_divider/include \
+ $(PICOSDKROOT)/src/rp2_common/pico_float/include \
+ $(PICOSDKROOT)/src/rp2_common/pico_double/include \
+ $(PICOSDKROOT)/src/rp2_common/pico_malloc/include
+
+ OPT_DEFS += -DPICO_FLOAT_SUPPORT_ROM_V1=0 -DPICO_DOUBLE_SUPPORT_ROM_V1=0
+
+ CFLAGS += -Wl,--defsym=__StackLimit=__heap_end__
+ CFLAGS += -Wl,--defsym=__unhandled_user_irq=_unhandled_exception
+ CFLAGS += -Wl,--build-id=none
+
+ # single precision floating point intrinsics
+ OPT_DEFS += -DPICO_FLOAT_IN_RAM=1
+ OPT_DEFS += -DPICO_FLOAT_PROPAGATE_NANS=0
+
+ CFLAGS += -Wl,--wrap=__aeabi_fdiv
+ CFLAGS += -Wl,--wrap=__aeabi_fmul
+ CFLAGS += -Wl,--wrap=__aeabi_frsub
+ CFLAGS += -Wl,--wrap=__aeabi_fsub
+ CFLAGS += -Wl,--wrap=__aeabi_cfcmpeq
+ CFLAGS += -Wl,--wrap=__aeabi_cfrcmple
+ CFLAGS += -Wl,--wrap=__aeabi_cfcmple
+ CFLAGS += -Wl,--wrap=__aeabi_fcmpeq
+ CFLAGS += -Wl,--wrap=__aeabi_fcmplt
+ CFLAGS += -Wl,--wrap=__aeabi_fcmple
+ CFLAGS += -Wl,--wrap=__aeabi_fcmpge
+ CFLAGS += -Wl,--wrap=__aeabi_fcmpgt
+ CFLAGS += -Wl,--wrap=__aeabi_fcmpun
+ CFLAGS += -Wl,--wrap=__aeabi_i2f
+ CFLAGS += -Wl,--wrap=__aeabi_l2f
+ CFLAGS += -Wl,--wrap=__aeabi_ui2f
+ CFLAGS += -Wl,--wrap=__aeabi_ul2f
+ CFLAGS += -Wl,--wrap=__aeabi_i2f
+ CFLAGS += -Wl,--wrap=__aeabi_f2iz
+ CFLAGS += -Wl,--wrap=__aeabi_f2lz
+ CFLAGS += -Wl,--wrap=__aeabi_f2uiz
+ CFLAGS += -Wl,--wrap=__aeabi_f2ulz
+ CFLAGS += -Wl,--wrap=__aeabi_f2d
+ CFLAGS += -Wl,--wrap=sqrtf
+ CFLAGS += -Wl,--wrap=cosf
+ CFLAGS += -Wl,--wrap=sinf
+ CFLAGS += -Wl,--wrap=tanf
+ CFLAGS += -Wl,--wrap=atan2f
+ CFLAGS += -Wl,--wrap=expf
+ CFLAGS += -Wl,--wrap=logf
+ CFLAGS += -Wl,--wrap=ldexpf
+ CFLAGS += -Wl,--wrap=copysignf
+ CFLAGS += -Wl,--wrap=truncf
+ CFLAGS += -Wl,--wrap=floorf
+ CFLAGS += -Wl,--wrap=ceilf
+ CFLAGS += -Wl,--wrap=roundf
+ CFLAGS += -Wl,--wrap=sincosf
+ CFLAGS += -Wl,--wrap=asinf
+ CFLAGS += -Wl,--wrap=acosf
+ CFLAGS += -Wl,--wrap=atanf
+ CFLAGS += -Wl,--wrap=sinhf
+ CFLAGS += -Wl,--wrap=coshf
+ CFLAGS += -Wl,--wrap=tanhf
+ CFLAGS += -Wl,--wrap=asinhf
+ CFLAGS += -Wl,--wrap=acoshf
+ CFLAGS += -Wl,--wrap=atanhf
+ CFLAGS += -Wl,--wrap=exp2f
+ CFLAGS += -Wl,--wrap=log2f
+ CFLAGS += -Wl,--wrap=exp10f
+ CFLAGS += -Wl,--wrap=log10f
+ CFLAGS += -Wl,--wrap=powf
+ CFLAGS += -Wl,--wrap=powintf
+ CFLAGS += -Wl,--wrap=hypotf
+ CFLAGS += -Wl,--wrap=cbrtf
+ CFLAGS += -Wl,--wrap=fmodf
+ CFLAGS += -Wl,--wrap=dremf
+ CFLAGS += -Wl,--wrap=remainderf
+ CFLAGS += -Wl,--wrap=remquof
+ CFLAGS += -Wl,--wrap=expm1f
+ CFLAGS += -Wl,--wrap=log1pf
+ CFLAGS += -Wl,--wrap=fmaf
+
+ # double precision floating point intrinsics
+ OPT_DEFS += -DPICO_DOUBLE_IN_RAM=1
+ OPT_DEFS += -DPICO_DOUBLE_PROPAGATE_NANS=0
+
+ CFLAGS += -Wl,--wrap=__aeabi_dadd
+ CFLAGS += -Wl,--wrap=__aeabi_ddiv
+ CFLAGS += -Wl,--wrap=__aeabi_dmul
+ CFLAGS += -Wl,--wrap=__aeabi_drsub
+ CFLAGS += -Wl,--wrap=__aeabi_dsub
+ CFLAGS += -Wl,--wrap=__aeabi_cdcmpeq
+ CFLAGS += -Wl,--wrap=__aeabi_cdrcmple
+ CFLAGS += -Wl,--wrap=__aeabi_cdcmple
+ CFLAGS += -Wl,--wrap=__aeabi_dcmpeq
+ CFLAGS += -Wl,--wrap=__aeabi_dcmplt
+ CFLAGS += -Wl,--wrap=__aeabi_dcmple
+ CFLAGS += -Wl,--wrap=__aeabi_dcmpge
+ CFLAGS += -Wl,--wrap=__aeabi_dcmpgt
+ CFLAGS += -Wl,--wrap=__aeabi_dcmpun
+ CFLAGS += -Wl,--wrap=__aeabi_i2d
+ CFLAGS += -Wl,--wrap=__aeabi_l2d
+ CFLAGS += -Wl,--wrap=__aeabi_ui2d
+ CFLAGS += -Wl,--wrap=__aeabi_ul2d
+ CFLAGS += -Wl,--wrap=__aeabi_d2iz
+ CFLAGS += -Wl,--wrap=__aeabi_d2lz
+ CFLAGS += -Wl,--wrap=__aeabi_d2uiz
+ CFLAGS += -Wl,--wrap=__aeabi_d2ulz
+ CFLAGS += -Wl,--wrap=__aeabi_d2f
+ CFLAGS += -Wl,--wrap=sqrt
+ CFLAGS += -Wl,--wrap=cos
+ CFLAGS += -Wl,--wrap=sin
+ CFLAGS += -Wl,--wrap=tan
+ CFLAGS += -Wl,--wrap=atan2
+ CFLAGS += -Wl,--wrap=exp
+ CFLAGS += -Wl,--wrap=log
+ CFLAGS += -Wl,--wrap=ldexp
+ CFLAGS += -Wl,--wrap=copysign
+ CFLAGS += -Wl,--wrap=trunc
+ CFLAGS += -Wl,--wrap=floor
+ CFLAGS += -Wl,--wrap=ceil
+ CFLAGS += -Wl,--wrap=round
+ CFLAGS += -Wl,--wrap=sincos
+ CFLAGS += -Wl,--wrap=asin
+ CFLAGS += -Wl,--wrap=acos
+ CFLAGS += -Wl,--wrap=atan
+ CFLAGS += -Wl,--wrap=sinh
+ CFLAGS += -Wl,--wrap=cosh
+ CFLAGS += -Wl,--wrap=tanh
+ CFLAGS += -Wl,--wrap=asinh
+ CFLAGS += -Wl,--wrap=acosh
+ CFLAGS += -Wl,--wrap=atanh
+ CFLAGS += -Wl,--wrap=exp2
+ CFLAGS += -Wl,--wrap=log2
+ CFLAGS += -Wl,--wrap=exp10
+ CFLAGS += -Wl,--wrap=log10
+ CFLAGS += -Wl,--wrap=pow
+ CFLAGS += -Wl,--wrap=powint
+ CFLAGS += -Wl,--wrap=hypot
+ CFLAGS += -Wl,--wrap=cbrt
+ CFLAGS += -Wl,--wrap=fmod
+ CFLAGS += -Wl,--wrap=drem
+ CFLAGS += -Wl,--wrap=remainder
+ CFLAGS += -Wl,--wrap=remquo
+ CFLAGS += -Wl,--wrap=expm1
+ CFLAGS += -Wl,--wrap=log1p
+ CFLAGS += -Wl,--wrap=fma
+
+ # bit operation intrinsics
+ OPT_DEFS += -DPICO_BITS_IN_RAM=1
+
+ CFLAGS += -Wl,--wrap=__clzsi2
+ CFLAGS += -Wl,--wrap=__clzsi2
+ CFLAGS += -Wl,--wrap=__clzdi2
+ CFLAGS += -Wl,--wrap=__ctzsi2
+ CFLAGS += -Wl,--wrap=__ctzdi2
+ CFLAGS += -Wl,--wrap=__popcountsi2
+ CFLAGS += -Wl,--wrap=__popcountdi2
+ CFLAGS += -Wl,--wrap=__clz
+ CFLAGS += -Wl,--wrap=__clzl
+ CFLAGS += -Wl,--wrap=__clzsi2
+ CFLAGS += -Wl,--wrap=__clzll
+
+ # integer division intrinsics
+ OPT_DEFS += -DPICO_DIVIDER_IN_RAM=1
+ OPT_DEFS += -DPICO_DIVIDER_DISABLE_INTERRUPTS=1
+
+ CFLAGS += -Wl,--wrap=__aeabi_idiv
+ CFLAGS += -Wl,--wrap=__aeabi_idivmod
+ CFLAGS += -Wl,--wrap=__aeabi_ldivmod
+ CFLAGS += -Wl,--wrap=__aeabi_uidiv
+ CFLAGS += -Wl,--wrap=__aeabi_uidivmod
+ CFLAGS += -Wl,--wrap=__aeabi_uldivmod
+
+ # 64bit integer intrinsics
+ OPT_DEFS += -DPICO_INT64_OPS_IN_RAM=1
+
+ CFLAGS += -Wl,--wrap=__aeabi_lmul
+
+ # malloc and friends functions
+ OPT_DEFS += -DPICO_USE_MALLOC_MUTEX=0
+ OPT_DEFS += -DPICO_DEBUG_MALLOC=0
+ OPT_DEFS ?= -DPICO_MALLOC_PANIC=0
+
+ CFLAGS += -Wl,--wrap=malloc
+ CFLAGS += -Wl,--wrap=calloc
+ CFLAGS += -Wl,--wrap=free
+
+ # memory operation intrinsics
+ OPT_DEFS += -DPICO_MEM_IN_RAM=1
+
+ CFLAGS += -Wl,--wrap=memcpy
+ CFLAGS += -Wl,--wrap=memset
+ CFLAGS += -Wl,--wrap=__aeabi_memcpy
+ CFLAGS += -Wl,--wrap=__aeabi_memset
+ CFLAGS += -Wl,--wrap=__aeabi_memcpy4
+ CFLAGS += -Wl,--wrap=__aeabi_memset4
+ CFLAGS += -Wl,--wrap=__aeabi_memcpy8
+ CFLAGS += -Wl,--wrap=__aeabi_memset8
+
+ PLATFORM_SRC += $(PICOSDKINTRINSICSSRC)
+ EXTRAINCDIRS += $(PICOSDKINTRINSICSINC)
+endif
diff --git a/platforms/chibios/vendors/RP/_pin_defs.h b/platforms/chibios/vendors/RP/_pin_defs.h
new file mode 100644
index 0000000000..4241845369
--- /dev/null
+++ b/platforms/chibios/vendors/RP/_pin_defs.h
@@ -0,0 +1,37 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+/* RP2040 GPIO Numbering */
+#define GP0 0U
+#define GP1 1U
+#define GP2 2U
+#define GP3 3U
+#define GP4 4U
+#define GP5 5U
+#define GP6 6U
+#define GP7 7U
+#define GP8 8U
+#define GP9 9U
+#define GP10 10U
+#define GP11 11U
+#define GP12 12U
+#define GP13 13U
+#define GP14 14U
+#define GP15 15U
+#define GP16 16U
+#define GP17 17U
+#define GP18 18U
+#define GP19 19U
+#define GP20 20U
+#define GP21 21U
+#define GP22 22U
+#define GP23 23U
+#define GP24 24U
+#define GP25 25U
+#define GP26 26U
+#define GP27 27U
+#define GP28 28U
+#define GP29 29U
+#define GP30 30U
diff --git a/platforms/chibios/vendors/RP/pico_sdk_shims.c b/platforms/chibios/vendors/RP/pico_sdk_shims.c
new file mode 100644
index 0000000000..239155c086
--- /dev/null
+++ b/platforms/chibios/vendors/RP/pico_sdk_shims.c
@@ -0,0 +1,13 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <stdbool.h>
+#include <ch.h>
+
+void panic(const char *fmt, ...) {
+ chSysHalt(fmt);
+}
+
+void hard_assertion_failure(void) {
+ panic("hard assert");
+}
diff --git a/platforms/chibios/vendors/RP/stage2_bootloaders.c b/platforms/chibios/vendors/RP/stage2_bootloaders.c
new file mode 100644
index 0000000000..e65b0a5802
--- /dev/null
+++ b/platforms/chibios/vendors/RP/stage2_bootloaders.c
@@ -0,0 +1,178 @@
+// ----------------------------------------------------------------------------
+// Pre-compiled second stage boot code for RP2040.
+//
+// Copyright (c) 2019-2021 Raspberry Pi (Trading) Ltd.
+// SPDX-License-Identifier: BSD-3-Clause
+// ----------------------------------------------------------------------------
+
+#include <stdint.h>
+
+#define BOOTLOADER_SECTION __attribute__((used, section(".boot2")))
+
+// clang-format off
+
+#if defined(RP2040_FLASH_AT25SF128A)
+
+uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {
+ 0x00, 0xb5, 0x31, 0x4b, 0x21, 0x20, 0x58, 0x60, 0x98, 0x68, 0x02, 0x21,
+ 0x88, 0x43, 0x98, 0x60, 0xd8, 0x60, 0x18, 0x61, 0x58, 0x61, 0x2d, 0x4b,
+ 0x00, 0x21, 0x99, 0x60, 0x04, 0x21, 0x59, 0x61, 0x01, 0x21, 0xf0, 0x22,
+ 0x99, 0x50, 0x2a, 0x49, 0x19, 0x60, 0x01, 0x21, 0x99, 0x60, 0x35, 0x20,
+ 0x00, 0xf0, 0x42, 0xf8, 0x02, 0x22, 0x90, 0x42, 0x12, 0xd0, 0x06, 0x21,
+ 0x19, 0x66, 0x00, 0xf0, 0x32, 0xf8, 0x19, 0x6e, 0x31, 0x21, 0x19, 0x66,
+ 0x1a, 0x66, 0x00, 0xf0, 0x2c, 0xf8, 0x19, 0x6e, 0x19, 0x6e, 0x19, 0x6e,
+ 0x05, 0x20, 0x00, 0xf0, 0x2f, 0xf8, 0x01, 0x21, 0x08, 0x42, 0xf9, 0xd1,
+ 0x00, 0x21, 0x99, 0x60, 0x1b, 0x49, 0x19, 0x60, 0x00, 0x21, 0x59, 0x60,
+ 0x1a, 0x49, 0x1b, 0x48, 0x01, 0x60, 0x01, 0x21, 0x99, 0x60, 0xeb, 0x21,
+ 0x19, 0x66, 0x20, 0x21, 0x19, 0x66, 0x00, 0xf0, 0x12, 0xf8, 0x00, 0x21,
+ 0x99, 0x60, 0x16, 0x49, 0x14, 0x48, 0x01, 0x60, 0x01, 0x21, 0x99, 0x60,
+ 0x01, 0xbc, 0x00, 0x28, 0x00, 0xd0, 0x00, 0x47, 0x12, 0x48, 0x13, 0x49,
+ 0x08, 0x60, 0x03, 0xc8, 0x80, 0xf3, 0x08, 0x88, 0x08, 0x47, 0x03, 0xb5,
+ 0x99, 0x6a, 0x04, 0x20, 0x01, 0x42, 0xfb, 0xd0, 0x01, 0x20, 0x01, 0x42,
+ 0xf8, 0xd1, 0x03, 0xbd, 0x02, 0xb5, 0x18, 0x66, 0x18, 0x66, 0xff, 0xf7,
+ 0xf2, 0xff, 0x18, 0x6e, 0x18, 0x6e, 0x02, 0xbd, 0x00, 0x00, 0x02, 0x40,
+ 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x07, 0x00, 0x00, 0x03, 0x5f, 0x00,
+ 0x21, 0x22, 0x00, 0x00, 0xf4, 0x00, 0x00, 0x18, 0x22, 0x20, 0x00, 0x20,
+ 0x00, 0x01, 0x00, 0x10, 0x08, 0xed, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0xdd, 0xc0, 0xb5
+};
+
+#elif defined(RP2040_FLASH_GD25Q64CS)
+
+uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {
+ 0x00, 0xb5, 0x31, 0x4b, 0x21, 0x20, 0x58, 0x60, 0x98, 0x68, 0x02, 0x21,
+ 0x88, 0x43, 0x98, 0x60, 0xd8, 0x60, 0x18, 0x61, 0x58, 0x61, 0x2d, 0x4b,
+ 0x00, 0x21, 0x99, 0x60, 0x04, 0x21, 0x59, 0x61, 0x01, 0x21, 0xf0, 0x22,
+ 0x99, 0x50, 0x2a, 0x49, 0x19, 0x60, 0x01, 0x21, 0x99, 0x60, 0x35, 0x20,
+ 0x00, 0xf0, 0x42, 0xf8, 0x02, 0x22, 0x90, 0x42, 0x12, 0xd0, 0x06, 0x21,
+ 0x19, 0x66, 0x00, 0xf0, 0x32, 0xf8, 0x19, 0x6e, 0x31, 0x21, 0x19, 0x66,
+ 0x1a, 0x66, 0x00, 0xf0, 0x2c, 0xf8, 0x19, 0x6e, 0x19, 0x6e, 0x19, 0x6e,
+ 0x05, 0x20, 0x00, 0xf0, 0x2f, 0xf8, 0x01, 0x21, 0x08, 0x42, 0xf9, 0xd1,
+ 0x00, 0x21, 0x99, 0x60, 0x1b, 0x49, 0x19, 0x60, 0x00, 0x21, 0x59, 0x60,
+ 0x1a, 0x49, 0x1b, 0x48, 0x01, 0x60, 0x01, 0x21, 0x99, 0x60, 0xe7, 0x21,
+ 0x19, 0x66, 0xa0, 0x21, 0x19, 0x66, 0x00, 0xf0, 0x12, 0xf8, 0x00, 0x21,
+ 0x99, 0x60, 0x16, 0x49, 0x14, 0x48, 0x01, 0x60, 0x01, 0x21, 0x99, 0x60,
+ 0x01, 0xbc, 0x00, 0x28, 0x00, 0xd0, 0x00, 0x47, 0x12, 0x48, 0x13, 0x49,
+ 0x08, 0x60, 0x03, 0xc8, 0x80, 0xf3, 0x08, 0x88, 0x08, 0x47, 0x03, 0xb5,
+ 0x99, 0x6a, 0x04, 0x20, 0x01, 0x42, 0xfb, 0xd0, 0x01, 0x20, 0x01, 0x42,
+ 0xf8, 0xd1, 0x03, 0xbd, 0x02, 0xb5, 0x18, 0x66, 0x18, 0x66, 0xff, 0xf7,
+ 0xf2, 0xff, 0x18, 0x6e, 0x18, 0x6e, 0x02, 0xbd, 0x00, 0x00, 0x02, 0x40,
+ 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x07, 0x00, 0x00, 0x03, 0x5f, 0x00,
+ 0x21, 0x12, 0x00, 0x00, 0xf4, 0x00, 0x00, 0x18, 0x22, 0x10, 0x00, 0xa0,
+ 0x00, 0x01, 0x00, 0x10, 0x08, 0xed, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xe2, 0xd9, 0xa2, 0xb5
+};
+
+#elif defined(RP2040_FLASH_W25X10CL)
+
+uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {
+ 0x00, 0xb5, 0x14, 0x4b, 0x00, 0x21, 0x99, 0x60, 0x04, 0x21, 0x59, 0x61,
+ 0x12, 0x49, 0x19, 0x60, 0x00, 0x21, 0x59, 0x60, 0x11, 0x49, 0x12, 0x48,
+ 0x01, 0x60, 0x01, 0x21, 0x99, 0x60, 0xbb, 0x21, 0x19, 0x66, 0x02, 0x21,
+ 0x19, 0x66, 0x08, 0x21, 0x98, 0x6a, 0x08, 0x42, 0xfc, 0xd0, 0x00, 0x21,
+ 0x99, 0x60, 0x0c, 0x49, 0x0a, 0x48, 0x01, 0x60, 0x01, 0x21, 0x99, 0x60,
+ 0x01, 0xbc, 0x00, 0x28, 0x00, 0xd0, 0x00, 0x47, 0x08, 0x48, 0x09, 0x49,
+ 0x08, 0x60, 0x03, 0xc8, 0x80, 0xf3, 0x08, 0x88, 0x08, 0x47, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x00, 0x03, 0x3f, 0x00, 0x1d, 0x12, 0x00, 0x00,
+ 0xf4, 0x00, 0x00, 0x18, 0x1e, 0x10, 0x00, 0x20, 0x00, 0x01, 0x00, 0x10,
+ 0x08, 0xed, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x7c, 0x81, 0x53, 0x9a
+};
+
+#elif defined(RP2040_FLASH_IS25LP080)
+
+uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {
+ 0x00, 0xb5, 0x2b, 0x4b, 0x00, 0x21, 0x99, 0x60, 0x04, 0x21, 0x59, 0x61,
+ 0x29, 0x49, 0x19, 0x60, 0x01, 0x21, 0x99, 0x60, 0x28, 0x48, 0x00, 0xf0,
+ 0x42, 0xf8, 0x28, 0x4a, 0x90, 0x42, 0x12, 0xd0, 0x06, 0x21, 0x19, 0x66,
+ 0x00, 0xf0, 0x32, 0xf8, 0x19, 0x6e, 0x01, 0x21, 0x19, 0x66, 0x00, 0x20,
+ 0x1a, 0x66, 0x00, 0xf0, 0x2b, 0xf8, 0x19, 0x6e, 0x19, 0x6e, 0x1f, 0x48,
+ 0x00, 0xf0, 0x2f, 0xf8, 0x01, 0x21, 0x08, 0x42, 0xf9, 0xd1, 0x00, 0x21,
+ 0x99, 0x60, 0x1d, 0x49, 0x19, 0x60, 0x00, 0x21, 0x59, 0x60, 0x1c, 0x49,
+ 0x1c, 0x48, 0x01, 0x60, 0x01, 0x21, 0x99, 0x60, 0xeb, 0x21, 0x19, 0x66,
+ 0xa0, 0x21, 0x19, 0x66, 0x00, 0xf0, 0x12, 0xf8, 0x00, 0x21, 0x99, 0x60,
+ 0x17, 0x49, 0x16, 0x48, 0x01, 0x60, 0x01, 0x21, 0x99, 0x60, 0x01, 0xbc,
+ 0x00, 0x28, 0x00, 0xd0, 0x00, 0x47, 0x14, 0x48, 0x14, 0x49, 0x08, 0x60,
+ 0x03, 0xc8, 0x80, 0xf3, 0x08, 0x88, 0x08, 0x47, 0x03, 0xb5, 0x99, 0x6a,
+ 0x04, 0x20, 0x01, 0x42, 0xfb, 0xd0, 0x01, 0x20, 0x01, 0x42, 0xf8, 0xd1,
+ 0x03, 0xbd, 0x02, 0xb5, 0x18, 0x66, 0x18, 0x66, 0xff, 0xf7, 0xf2, 0xff,
+ 0x18, 0x6e, 0x18, 0x6e, 0x02, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
+ 0x00, 0x00, 0x07, 0x00, 0x05, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0x03, 0x5f, 0x00, 0x21, 0x22, 0x00, 0x00, 0xf4, 0x00, 0x00, 0x18,
+ 0x22, 0x20, 0x00, 0xa0, 0x00, 0x01, 0x00, 0x10, 0x08, 0xed, 0x00, 0xe0,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x28, 0x33, 0x43, 0xb2
+};
+
+#elif defined(RP2040_FLASH_GENERIC_03H)
+
+uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {
+ 0x00, 0xb5, 0x0c, 0x4b, 0x00, 0x21, 0x99, 0x60, 0x04, 0x21, 0x59, 0x61,
+ 0x0a, 0x49, 0x19, 0x60, 0x0a, 0x49, 0x0b, 0x48, 0x01, 0x60, 0x00, 0x21,
+ 0x59, 0x60, 0x01, 0x21, 0x99, 0x60, 0x01, 0xbc, 0x00, 0x28, 0x00, 0xd0,
+ 0x00, 0x47, 0x07, 0x48, 0x07, 0x49, 0x08, 0x60, 0x03, 0xc8, 0x80, 0xf3,
+ 0x08, 0x88, 0x08, 0x47, 0x00, 0x00, 0x00, 0x18, 0x00, 0x03, 0x1f, 0x00,
+ 0x18, 0x02, 0x00, 0x03, 0xf4, 0x00, 0x00, 0x18, 0x00, 0x01, 0x00, 0x10,
+ 0x08, 0xed, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2c, 0xec, 0x21, 0x0d
+};
+
+#else
+
+uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {
+ 0x00, 0xb5, 0x32, 0x4b, 0x21, 0x20, 0x58, 0x60, 0x98, 0x68, 0x02, 0x21,
+ 0x88, 0x43, 0x98, 0x60, 0xd8, 0x60, 0x18, 0x61, 0x58, 0x61, 0x2e, 0x4b,
+ 0x00, 0x21, 0x99, 0x60, 0x04, 0x21, 0x59, 0x61, 0x01, 0x21, 0xf0, 0x22,
+ 0x99, 0x50, 0x2b, 0x49, 0x19, 0x60, 0x01, 0x21, 0x99, 0x60, 0x35, 0x20,
+ 0x00, 0xf0, 0x44, 0xf8, 0x02, 0x22, 0x90, 0x42, 0x14, 0xd0, 0x06, 0x21,
+ 0x19, 0x66, 0x00, 0xf0, 0x34, 0xf8, 0x19, 0x6e, 0x01, 0x21, 0x19, 0x66,
+ 0x00, 0x20, 0x18, 0x66, 0x1a, 0x66, 0x00, 0xf0, 0x2c, 0xf8, 0x19, 0x6e,
+ 0x19, 0x6e, 0x19, 0x6e, 0x05, 0x20, 0x00, 0xf0, 0x2f, 0xf8, 0x01, 0x21,
+ 0x08, 0x42, 0xf9, 0xd1, 0x00, 0x21, 0x99, 0x60, 0x1b, 0x49, 0x19, 0x60,
+ 0x00, 0x21, 0x59, 0x60, 0x1a, 0x49, 0x1b, 0x48, 0x01, 0x60, 0x01, 0x21,
+ 0x99, 0x60, 0xeb, 0x21, 0x19, 0x66, 0xa0, 0x21, 0x19, 0x66, 0x00, 0xf0,
+ 0x12, 0xf8, 0x00, 0x21, 0x99, 0x60, 0x16, 0x49, 0x14, 0x48, 0x01, 0x60,
+ 0x01, 0x21, 0x99, 0x60, 0x01, 0xbc, 0x00, 0x28, 0x00, 0xd0, 0x00, 0x47,
+ 0x12, 0x48, 0x13, 0x49, 0x08, 0x60, 0x03, 0xc8, 0x80, 0xf3, 0x08, 0x88,
+ 0x08, 0x47, 0x03, 0xb5, 0x99, 0x6a, 0x04, 0x20, 0x01, 0x42, 0xfb, 0xd0,
+ 0x01, 0x20, 0x01, 0x42, 0xf8, 0xd1, 0x03, 0xbd, 0x02, 0xb5, 0x18, 0x66,
+ 0x18, 0x66, 0xff, 0xf7, 0xf2, 0xff, 0x18, 0x6e, 0x18, 0x6e, 0x02, 0xbd,
+ 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x07, 0x00,
+ 0x00, 0x03, 0x5f, 0x00, 0x21, 0x22, 0x00, 0x00, 0xf4, 0x00, 0x00, 0x18,
+ 0x22, 0x20, 0x00, 0xa0, 0x00, 0x01, 0x00, 0x10, 0x08, 0xed, 0x00, 0xe0,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x07, 0x0b, 0x8f, 0xd5
+};
+
+#endif
+
+// clang-format on
diff --git a/platforms/eeprom.h b/platforms/eeprom.h
index 091e6e4400..8cb7e342dc 100644
--- a/platforms/eeprom.h
+++ b/platforms/eeprom.h
@@ -27,6 +27,8 @@ void eeprom_update_block(const void *__src, void *__dst, size_t __n);
# error EEPROM_SIZE has not been defined for custom driver.
# endif
# define TOTAL_EEPROM_BYTE_COUNT (EEPROM_SIZE)
+#elif defined(EEPROM_WEAR_LEVELING)
+# define TOTAL_EEPROM_BYTE_COUNT (WEAR_LEVELING_LOGICAL_SIZE)
#elif defined(EEPROM_TRANSIENT)
# include "eeprom_transient.h"
# define TOTAL_EEPROM_BYTE_COUNT (TRANSIENT_EEPROM_SIZE)
diff --git a/platforms/synchronization_util.h b/platforms/synchronization_util.h
index 3730f271db..59933945c3 100644
--- a/platforms/synchronization_util.h
+++ b/platforms/synchronization_util.h
@@ -9,6 +9,40 @@ void split_shared_memory_lock(void);
void split_shared_memory_unlock(void);
# endif
#else
+# if defined(SPLIT_KEYBOARD)
inline void split_shared_memory_lock(void){};
inline void split_shared_memory_unlock(void){};
+# endif
+#endif
+
+/* GCCs cleanup attribute expects a function with one parameter, which is a
+ * pointer to a type compatible with the variable. As we don't want to expose
+ * the platforms internal mutex type this workaround with auto generated adapter
+ * function is defined */
+#define QMK_DECLARE_AUTOUNLOCK_HELPERS(prefix) \
+ inline unsigned prefix##_autounlock_lock_helper(void) { \
+ prefix##_lock(); \
+ return 0; \
+ } \
+ \
+ inline void prefix##_autounlock_unlock_helper(unsigned* unused_guard) { \
+ prefix##_unlock(); \
+ }
+
+/* Convinience macro the automatically generate the correct RAII-style
+ * lock_autounlock function macro */
+#define QMK_DECLARE_AUTOUNLOCK_CALL(prefix) unsigned prefix##_guard __attribute__((unused, cleanup(prefix##_autounlock_unlock_helper))) = prefix##_autounlock_lock_helper
+
+#if defined(SPLIT_KEYBOARD)
+QMK_DECLARE_AUTOUNLOCK_HELPERS(split_shared_memory)
+
+/**
+ * @brief Acquire exclusive access to the split keyboard shared memory, by
+ * calling the platforms `split_shared_memory_lock()` function. The lock is
+ * automatically released by calling the platforms `split_shared_memory_unlock()`
+ * function. This happens when the block where
+ * `split_shared_memory_lock_autounlock()` is called in goes out of scope i.e.
+ * when the enclosing function returns.
+ */
+# define split_shared_memory_lock_autounlock QMK_DECLARE_AUTOUNLOCK_CALL(split_shared_memory)
#endif
diff --git a/platforms/test/platform.mk b/platforms/test/platform.mk
index eb2424ec5c..f07c863e69 100644
--- a/platforms/test/platform.mk
+++ b/platforms/test/platform.mk
@@ -31,4 +31,4 @@ CFLAGS += -fno-strict-aliasing
CXXFLAGS += $(COMPILEFLAGS)
CXXFLAGS += -fno-exceptions
-CXXFLAGS += -std=gnu++11
+CXXFLAGS += $(CXXSTANDARD)
diff --git a/platforms/test/rules.mk b/platforms/test/rules.mk
index 55512c7392..a2baa283d0 100644
--- a/platforms/test/rules.mk
+++ b/platforms/test/rules.mk
@@ -11,7 +11,8 @@ eeprom_stm32_large_DEFS := $(eeprom_stm32_DEFS) \
-DFEE_PAGE_COUNT=16
eeprom_stm32_INC := \
- $(PLATFORM_PATH)/chibios/
+ $(PLATFORM_PATH)/chibios/drivers/eeprom/ \
+ $(PLATFORM_PATH)/chibios/drivers/flash/
eeprom_stm32_tiny_INC := $(eeprom_stm32_INC)
eeprom_stm32_large_INC := $(eeprom_stm32_INC)
@@ -19,6 +20,6 @@ eeprom_stm32_SRC := \
$(TOP_DIR)/drivers/eeprom/eeprom_driver.c \
$(PLATFORM_PATH)/$(PLATFORM_KEY)/eeprom_stm32_tests.cpp \
$(PLATFORM_PATH)/$(PLATFORM_KEY)/flash_stm32_mock.c \
- $(PLATFORM_PATH)/chibios/eeprom_stm32.c
+ $(PLATFORM_PATH)/chibios/drivers/eeprom/eeprom_stm32.c
eeprom_stm32_tiny_SRC := $(eeprom_stm32_SRC)
eeprom_stm32_large_SRC := $(eeprom_stm32_SRC)
diff --git a/quantum/action.c b/quantum/action.c
index 16fefa9e43..2cea6caae1 100644
--- a/quantum/action.c
+++ b/quantum/action.c
@@ -844,7 +844,7 @@ __attribute__((weak)) void register_code(uint8_t code) {
# endif
add_key(KC_CAPS_LOCK);
send_keyboard_report();
- wait_ms(100);
+ wait_ms(TAP_HOLD_CAPS_DELAY);
del_key(KC_CAPS_LOCK);
send_keyboard_report();
}
@@ -1090,16 +1090,11 @@ void clear_keyboard_but_mods_and_keys() {
*
* FIXME: Needs documentation.
*/
-bool is_tap_key(keypos_t key) {
- action_t action = layer_switch_get_action(key);
- return is_tap_action(action);
-}
-
-/** \brief Utilities for actions. (FIXME: Needs better description)
- *
- * FIXME: Needs documentation.
- */
bool is_tap_record(keyrecord_t *record) {
+ if (IS_NOEVENT(record->event)) {
+ return false;
+ }
+
#ifdef COMBO_ENABLE
action_t action;
if (record->keycode) {
diff --git a/quantum/action.h b/quantum/action.h
index 08e1f6ac29..2bc46429b2 100644
--- a/quantum/action.h
+++ b/quantum/action.h
@@ -105,7 +105,6 @@ void clear_keyboard(void);
void clear_keyboard_but_mods(void);
void clear_keyboard_but_mods_and_keys(void);
void layer_switch(uint8_t new_layer);
-bool is_tap_key(keypos_t key);
bool is_tap_record(keyrecord_t *record);
bool is_tap_action(action_t action);
diff --git a/quantum/action_code.h b/quantum/action_code.h
index 20b3e459d2..e107f0a740 100644
--- a/quantum/action_code.h
+++ b/quantum/action_code.h
@@ -234,6 +234,7 @@ enum layer_param_tap_op {
#define ACTION_LAYER_INVERT(layer, on) ACTION_LAYER_BIT_XOR((layer) / 4, 1 << ((layer) % 4), (on))
#define ACTION_LAYER_ON(layer, on) ACTION_LAYER_BIT_OR((layer) / 4, 1 << ((layer) % 4), (on))
#define ACTION_LAYER_OFF(layer, on) ACTION_LAYER_BIT_AND((layer) / 4, ~(1 << ((layer) % 4)), (on))
+#define ACTION_LAYER_GOTO(layer) ACTION_LAYER_SET(layer, ON_PRESS)
#define ACTION_LAYER_SET(layer, on) ACTION_LAYER_BIT_SET((layer) / 4, 1 << ((layer) % 4), (on))
#define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF)
#define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON)
diff --git a/quantum/action_layer.c b/quantum/action_layer.c
index e39f71a9e2..5cc1ac9b34 100644
--- a/quantum/action_layer.c
+++ b/quantum/action_layer.c
@@ -73,21 +73,21 @@ void default_layer_set(layer_state_t state) {
#ifndef NO_ACTION_LAYER
/** \brief Default Layer Or
*
- * Turns on the default layer based on matching bits between specifed layer and existing layer state
+ * Turns on the default layer based on matching bits between specified layer and existing layer state
*/
void default_layer_or(layer_state_t state) {
default_layer_state_set(default_layer_state | state);
}
/** \brief Default Layer And
*
- * Turns on default layer based on matching enabled bits between specifed layer and existing layer state
+ * Turns on default layer based on matching enabled bits between specified layer and existing layer state
*/
void default_layer_and(layer_state_t state) {
default_layer_state_set(default_layer_state & state);
}
/** \brief Default Layer Xor
*
- * Turns on default layer based on non-matching bits between specifed layer and existing layer state
+ * Turns on default layer based on non-matching bits between specified layer and existing layer state
*/
void default_layer_xor(layer_state_t state) {
default_layer_state_set(default_layer_state ^ state);
@@ -117,7 +117,7 @@ __attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) {
/** \brief Layer state set
*
- * Sets the layer to match the specifed state (a bitmask)
+ * Sets the layer to match the specified state (a bitmask)
*/
void layer_state_set(layer_state_t state) {
state = layer_state_set_kb(state);
@@ -198,21 +198,21 @@ void layer_invert(uint8_t layer) {
/** \brief Layer or
*
- * Turns on layers based on matching bits between specifed layer and existing layer state
+ * Turns on layers based on matching bits between specified layer and existing layer state
*/
void layer_or(layer_state_t state) {
layer_state_set(layer_state | state);
}
/** \brief Layer and
*
- * Turns on layers based on matching enabled bits between specifed layer and existing layer state
+ * Turns on layers based on matching enabled bits between specified layer and existing layer state
*/
void layer_and(layer_state_t state) {
layer_state_set(layer_state & state);
}
/** \brief Layer xor
*
- * Turns on layers based on non-matching bits between specifed layer and existing layer state
+ * Turns on layers based on non-matching bits between specified layer and existing layer state
*/
void layer_xor(layer_state_t state) {
layer_state_set(layer_state ^ state);
diff --git a/quantum/action_layer.h b/quantum/action_layer.h
index b87d096eed..bd1085a70f 100644
--- a/quantum/action_layer.h
+++ b/quantum/action_layer.h
@@ -41,7 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif
#if !defined(LAYER_STATE_8BIT) && !defined(LAYER_STATE_16BIT) && !defined(LAYER_STATE_32BIT)
-# define LAYER_STATE_32BIT
+# define LAYER_STATE_16BIT
#endif
#if defined(LAYER_STATE_8BIT)
diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c
index 3c8b5678b7..df3317ac05 100644
--- a/quantum/action_tapping.c
+++ b/quantum/action_tapping.c
@@ -125,7 +125,7 @@ void action_tapping_process(keyrecord_t record) {
/* return true when key event is processed or consumed. */
bool process_tapping(keyrecord_t *keyp) {
keyevent_t event = keyp->event;
-# if (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) || defined(TAPPING_TERM_PER_KEY) || defined(PERMISSIVE_HOLD_PER_KEY) || defined(TAPPING_FORCE_HOLD_PER_KEY) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
+# if (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) || defined(PERMISSIVE_HOLD_PER_KEY) || defined(TAPPING_FORCE_HOLD_PER_KEY) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
uint16_t tapping_keycode = get_record_keycode(&tapping_key, false);
# endif
@@ -164,17 +164,15 @@ bool process_tapping(keyrecord_t *keyp) {
* useful for long TAPPING_TERM but may prevent fast typing.
*/
// clang-format off
-# if defined(TAPPING_TERM_PER_KEY) || (TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
+# if defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
else if (
(
- (
- GET_TAPPING_TERM(tapping_keycode, &tapping_key) >= 500
+ IS_RELEASED(event) && waiting_buffer_typed(event)
# ifdef PERMISSIVE_HOLD_PER_KEY
- || get_permissive_hold(tapping_keycode, &tapping_key)
+ && get_permissive_hold(tapping_keycode, &tapping_key)
# elif defined(PERMISSIVE_HOLD)
- || true
+ && true
# endif
- ) && IS_RELEASED(event) && waiting_buffer_typed(event)
)
// Causes nested taps to not wait past TAPPING_TERM/RETRO_SHIFT
// unnecessarily and fixes them for Layer Taps.
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h
index 3e425abb47..ff22e6fe95 100644
--- a/quantum/audio/song_list.h
+++ b/quantum/audio/song_list.h
@@ -144,6 +144,12 @@
*/
#define USSR_ANTHEM B__NOTE(_G6), B__NOTE(_C7), W__NOTE(_G6), H__NOTE(_A6), B__NOTE(_B6), W__NOTE(_E6), W__NOTE(_E6), B__NOTE(_A6), W__NOTE(_G6), H__NOTE(_F6), B__NOTE(_G6), W__NOTE(_C6), W__NOTE(_C6), B__NOTE(_D6), W__NOTE(_D6), W__NOTE(_E6), B__NOTE(_D6), W__NOTE(_D6), W__NOTE(_G6), B__NOTE(_F6), W__NOTE(_G6), W__NOTE(_A6), B__NOTE(_B6),
+/* Title: Hymn Risen
+ * Author/Composer: Terrance Andrew Davis
+ * License: Public Domain
+ */
+#define TOS_HYMN_RISEN H__NOTE(_D5), H__NOTE(_E5), HD_NOTE(_F5), HD_NOTE(_F5), H__NOTE(_F5), HD_NOTE(_D5), E__NOTE(_E5), E__NOTE(_E5), H__NOTE(_C5), Q__NOTE(_D5), Q__NOTE(_D5), H__NOTE(_E5), H__NOTE(_C5), Q__NOTE(_G5), Q__NOTE(_F5), H__NOTE(_D5), H__NOTE(_E5), HD_NOTE(_F5), HD_NOTE(_F5), H__NOTE(_F5), HD_NOTE(_D5), E__NOTE(_E5), E__NOTE(_E5), H__NOTE(_C5), Q__NOTE(_D5), Q__NOTE(_D5), H__NOTE(_E5), H__NOTE(_C5), Q__NOTE(_G5), Q__NOTE(_F5), H__NOTE(_D5), H__NOTE(_C5), W__NOTE(_D5), W__NOTE(_E5), Q__NOTE(_A4), H__NOTE(_A4), Q__NOTE(_E5), Q__NOTE(_E5), Q__NOTE(_F5), Q__NOTE(_E5), Q__NOTE(_D5), Q__NOTE(_G5), Q__NOTE(_B4), Q__NOTE(_D5), Q__NOTE(_C5), M__NOTE(_F5, 80), H__NOTE(_D5), H__NOTE(_C5), W__NOTE(_D5), W__NOTE(_E5), Q__NOTE(_A4), H__NOTE(_A4), Q__NOTE(_E5), Q__NOTE(_E5), Q__NOTE(_F5), Q__NOTE(_E5), Q__NOTE(_D5), Q__NOTE(_G5), Q__NOTE(_B4), Q__NOTE(_D5), Q__NOTE(_C5), M__NOTE(_F5, 80)
+
/* Removed sounds
+ This list is here solely for compatibility, so that removed songs don't just break things
* If you think that any of these songs were wrongfully removed, let us know and provide
diff --git a/quantum/command.c b/quantum/command.c
index f90d73207c..84757b9b01 100644
--- a/quantum/command.c
+++ b/quantum/command.c
@@ -161,7 +161,7 @@ static void command_common_help(void) {
}
static void print_version(void) {
- print(/* clang-format off */
+ xprintf("%s", /* clang-format off */
"\n\t- Version -\n"
"VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") "
"PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") "
@@ -282,6 +282,7 @@ static void print_eeconfig(void) {
".swap_grave_esc: %u\n"
".swap_backslash_backspace: %u\n"
".nkro: %u\n"
+ ".swap_escape_capslock: %u\n"
, kc.raw
, kc.swap_control_capslock
@@ -294,6 +295,7 @@ static void print_eeconfig(void) {
, kc.swap_grave_esc
, kc.swap_backslash_backspace
, kc.nkro
+ , kc.swap_escape_capslock
); /* clang-format on */
# ifdef BACKLIGHT_ENABLE
diff --git a/quantum/command.h b/quantum/command.h
index 676507d3bd..a63f9ec7a7 100644
--- a/quantum/command.h
+++ b/quantum/command.h
@@ -146,7 +146,7 @@ bool command_proc(uint8_t code);
#endif
#ifndef MAGIC_KEY_EEPROM_CLEAR
-# define MAGIC_KEY_EEPROM_CLEAR BSPACE
+# define MAGIC_KEY_EEPROM_CLEAR BACKSPACE
#endif
#ifndef MAGIC_KEY_NKRO
diff --git a/quantum/debounce.h b/quantum/debounce.h
index 3532d9cd7b..a8629654c2 100644
--- a/quantum/debounce.h
+++ b/quantum/debounce.h
@@ -1,10 +1,16 @@
#pragma once
-// raw is the current key state
-// on entry cooked is the previous debounced state
-// on exit cooked is the current debounced state
-// changed is true if raw has changed since the last call
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed);
+/**
+ * @brief Debounce raw matrix events according to the choosen debounce algorithm.
+ *
+ * @param raw The current key state
+ * @param cooked The debounced key state
+ * @param num_rows Number of rows to debounce
+ * @param changed True if raw has changed since the last call
+ * @return true Cooked has new keychanges after debouncing
+ * @return false Cooked is the same as before
+ */
+bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed);
void debounce_init(uint8_t num_rows);
diff --git a/quantum/debounce/asym_eager_defer_pk.c b/quantum/debounce/asym_eager_defer_pk.c
index b1eb4a2b7b..4745c6f465 100644
--- a/quantum/debounce/asym_eager_defer_pk.c
+++ b/quantum/debounce/asym_eager_defer_pk.c
@@ -55,6 +55,7 @@ static debounce_counter_t *debounce_counters;
static fast_timer_t last_time;
static bool counters_need_update;
static bool matrix_need_update;
+static bool cooked_changed;
# define DEBOUNCE_ELAPSED 0
@@ -77,8 +78,9 @@ void debounce_free(void) {
debounce_counters = NULL;
}
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
bool updated_last = false;
+ cooked_changed = false;
if (counters_need_update) {
fast_timer_t now = timer_read_fast();
@@ -102,6 +104,8 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
transfer_matrix_values(raw, cooked, num_rows);
}
+
+ return cooked_changed;
}
static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time) {
@@ -123,7 +127,9 @@ static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[],
matrix_need_update = true;
} else {
// key-up: defer
- cooked[row] = (cooked[row] & ~col_mask) | (raw[row] & col_mask);
+ matrix_row_t cooked_next = (cooked[row] & ~col_mask) | (raw[row] & col_mask);
+ cooked_changed |= cooked_next ^ cooked[row];
+ cooked[row] = cooked_next;
}
} else {
debounce_pointer->time -= elapsed_time;
@@ -152,6 +158,7 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui
if (debounce_pointer->pressed) {
// key-down: eager
cooked[row] ^= col_mask;
+ cooked_changed = true;
}
}
} else if (debounce_pointer->time != DEBOUNCE_ELAPSED) {
diff --git a/quantum/debounce/none.c b/quantum/debounce/none.c
index 8a85cc04a8..4cff5e05e2 100644
--- a/quantum/debounce/none.c
+++ b/quantum/debounce/none.c
@@ -17,13 +17,16 @@
#include "matrix.h"
#include "quantum.h"
#include <stdlib.h>
+#include <string.h>
void debounce_init(uint8_t num_rows) {}
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
- for (int i = 0; i < num_rows; i++) {
- cooked[i] = raw[i];
- }
+bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+ bool cooked_changed = memcmp(raw, cooked, sizeof(matrix_row_t) * num_rows) != 0;
+
+ memcpy(cooked, raw, sizeof(matrix_row_t) * num_rows);
+
+ return cooked_changed;
}
void debounce_free(void) {}
diff --git a/quantum/debounce/sym_defer_g.c b/quantum/debounce/sym_defer_g.c
index 47450992a4..d04310a761 100644
--- a/quantum/debounce/sym_defer_g.c
+++ b/quantum/debounce/sym_defer_g.c
@@ -20,6 +20,7 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state.
#include "matrix.h"
#include "timer.h"
#include "quantum.h"
+#include <string.h>
#ifndef DEBOUNCE
# define DEBOUNCE 5
#endif
@@ -30,18 +31,23 @@ static fast_timer_t debouncing_time;
void debounce_init(uint8_t num_rows) {}
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+ bool cooked_changed = false;
+
if (changed) {
debouncing = true;
debouncing_time = timer_read_fast();
}
if (debouncing && timer_elapsed_fast(debouncing_time) >= DEBOUNCE) {
- for (int i = 0; i < num_rows; i++) {
- cooked[i] = raw[i];
+ if (memcmp(cooked, raw, sizeof(matrix_row_t) * num_rows) != 0) {
+ memcpy(cooked, raw, sizeof(matrix_row_t) * num_rows);
+ cooked_changed = true;
}
debouncing = false;
}
+
+ return cooked_changed;
}
void debounce_free(void) {}
diff --git a/quantum/debounce/sym_defer_pk.c b/quantum/debounce/sym_defer_pk.c
index 9dee29e28e..7b59b5e100 100644
--- a/quantum/debounce/sym_defer_pk.c
+++ b/quantum/debounce/sym_defer_pk.c
@@ -48,6 +48,7 @@ typedef uint8_t debounce_counter_t;
static debounce_counter_t *debounce_counters;
static fast_timer_t last_time;
static bool counters_need_update;
+static bool cooked_changed;
# define DEBOUNCE_ELAPSED 0
@@ -70,8 +71,9 @@ void debounce_free(void) {
debounce_counters = NULL;
}
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
bool updated_last = false;
+ cooked_changed = false;
if (counters_need_update) {
fast_timer_t now = timer_read_fast();
@@ -95,6 +97,8 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
start_debounce_counters(raw, cooked, num_rows);
}
+
+ return cooked_changed;
}
static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time) {
@@ -104,8 +108,10 @@ static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[],
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
if (*debounce_pointer != DEBOUNCE_ELAPSED) {
if (*debounce_pointer <= elapsed_time) {
- *debounce_pointer = DEBOUNCE_ELAPSED;
- cooked[row] = (cooked[row] & ~(ROW_SHIFTER << col)) | (raw[row] & (ROW_SHIFTER << col));
+ *debounce_pointer = DEBOUNCE_ELAPSED;
+ matrix_row_t cooked_next = (cooked[row] & ~(ROW_SHIFTER << col)) | (raw[row] & (ROW_SHIFTER << col));
+ cooked_changed |= cooked[row] ^ cooked_next;
+ cooked[row] = cooked_next;
} else {
*debounce_pointer -= elapsed_time;
counters_need_update = true;
diff --git a/quantum/debounce/sym_defer_pr.c b/quantum/debounce/sym_defer_pr.c
index ce24f0922f..452c4599d0 100644
--- a/quantum/debounce/sym_defer_pr.c
+++ b/quantum/debounce/sym_defer_pr.c
@@ -46,11 +46,12 @@ void debounce_free(void) {
last_raw = NULL;
}
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
- uint16_t now = timer_read();
- uint16_t elapsed16 = TIMER_DIFF_16(now, last_time);
- last_time = now;
- uint8_t elapsed = (elapsed16 > 255) ? 255 : elapsed16;
+bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+ uint16_t now = timer_read();
+ uint16_t elapsed16 = TIMER_DIFF_16(now, last_time);
+ last_time = now;
+ uint8_t elapsed = (elapsed16 > 255) ? 255 : elapsed16;
+ bool cooked_changed = false;
uint8_t* countdown = countdowns;
@@ -63,10 +64,13 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
} else if (*countdown > elapsed) {
*countdown -= elapsed;
} else if (*countdown) {
+ cooked_changed |= cooked[row] ^ raw_row;
cooked[row] = raw_row;
*countdown = 0;
}
}
+
+ return cooked_changed;
}
bool debounce_active(void) {
diff --git a/quantum/debounce/sym_eager_pk.c b/quantum/debounce/sym_eager_pk.c
index fe3e88bb06..f736d1645c 100644
--- a/quantum/debounce/sym_eager_pk.c
+++ b/quantum/debounce/sym_eager_pk.c
@@ -49,6 +49,7 @@ static debounce_counter_t *debounce_counters;
static fast_timer_t last_time;
static bool counters_need_update;
static bool matrix_need_update;
+static bool cooked_changed;
# define DEBOUNCE_ELAPSED 0
@@ -71,8 +72,9 @@ void debounce_free(void) {
debounce_counters = NULL;
}
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
bool updated_last = false;
+ cooked_changed = false;
if (counters_need_update) {
fast_timer_t now = timer_read_fast();
@@ -96,6 +98,8 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
transfer_matrix_values(raw, cooked, num_rows);
}
+
+ return cooked_changed;
}
// If the current time is > debounce counter, set the counter to enable input.
@@ -132,6 +136,7 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui
*debounce_pointer = DEBOUNCE;
counters_need_update = true;
existing_row ^= col_mask; // flip the bit.
+ cooked_changed = true;
}
}
debounce_pointer++;
diff --git a/quantum/debounce/sym_eager_pr.c b/quantum/debounce/sym_eager_pr.c
index 29b0cabefb..aad5ca351b 100644
--- a/quantum/debounce/sym_eager_pr.c
+++ b/quantum/debounce/sym_eager_pr.c
@@ -48,6 +48,7 @@ static bool matrix_need_update;
static debounce_counter_t *debounce_counters;
static fast_timer_t last_time;
static bool counters_need_update;
+static bool cooked_changed;
# define DEBOUNCE_ELAPSED 0
@@ -67,8 +68,9 @@ void debounce_free(void) {
debounce_counters = NULL;
}
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
bool updated_last = false;
+ cooked_changed = false;
if (counters_need_update) {
fast_timer_t now = timer_read_fast();
@@ -92,6 +94,8 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
transfer_matrix_values(raw, cooked, num_rows);
}
+
+ return cooked_changed;
}
// If the current time is > debounce counter, set the counter to enable input.
@@ -123,8 +127,9 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui
// determine new value basd on debounce pointer + raw value
if (existing_row != raw_row) {
if (*debounce_pointer == DEBOUNCE_ELAPSED) {
- *debounce_pointer = DEBOUNCE;
- cooked[row] = raw_row;
+ *debounce_pointer = DEBOUNCE;
+ cooked[row] = raw_row;
+ cooked_changed |= cooked[row] ^ raw[row];
counters_need_update = true;
}
}
diff --git a/quantum/debounce/tests/debounce_test_common.cpp b/quantum/debounce/tests/debounce_test_common.cpp
index 0d5a7bb766..bd98e32955 100644
--- a/quantum/debounce/tests/debounce_test_common.cpp
+++ b/quantum/debounce/tests/debounce_test_common.cpp
@@ -125,11 +125,15 @@ void DebounceTest::runDebounce(bool changed) {
std::copy(std::begin(input_matrix_), std::end(input_matrix_), std::begin(raw_matrix_));
std::copy(std::begin(output_matrix_), std::end(output_matrix_), std::begin(cooked_matrix_));
- debounce(raw_matrix_, cooked_matrix_, MATRIX_ROWS, changed);
+ bool cooked_changed = debounce(raw_matrix_, cooked_matrix_, MATRIX_ROWS, changed);
if (!std::equal(std::begin(input_matrix_), std::end(input_matrix_), std::begin(raw_matrix_))) {
FAIL() << "Fatal error: debounce() modified raw matrix at " << strTime() << "\ninput_matrix: changed=" << changed << "\n" << strMatrix(input_matrix_) << "\nraw_matrix:\n" << strMatrix(raw_matrix_);
}
+
+ if (std::equal(std::begin(output_matrix_), std::end(output_matrix_), std::begin(cooked_matrix_)) && cooked_changed) {
+ FAIL() << "Fatal error: debounce() did detect a wrong cooked matrix change at " << strTime() << "\noutput_matrix: cooked_changed=" << cooked_changed << "\n" << strMatrix(output_matrix_) << "\ncooked_matrix:\n" << strMatrix(cooked_matrix_);
+ }
}
void DebounceTest::checkCookedMatrix(bool changed, const std::string &error_message) {
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
index 9570882771..6a33d14374 100644
--- a/quantum/dynamic_keymap.c
+++ b/quantum/dynamic_keymap.c
@@ -21,6 +21,13 @@
#include "eeconfig.h"
#include "dynamic_keymap.h"
+#ifdef VIA_ENABLE
+# include "via.h" // for VIA_EEPROM_CONFIG_END
+# define DYNAMIC_KEYMAP_EEPROM_START (VIA_EEPROM_CONFIG_END)
+#else
+# define DYNAMIC_KEYMAP_EEPROM_START (EECONFIG_SIZE)
+#endif
+
#ifdef ENCODER_ENABLE
# include "encoder.h"
#else
@@ -55,17 +62,8 @@
#endif
// If DYNAMIC_KEYMAP_EEPROM_ADDR not explicitly defined in config.h,
-// default it start after VIA_EEPROM_CUSTOM_ADDR+VIA_EEPROM_CUSTOM_SIZE
#ifndef DYNAMIC_KEYMAP_EEPROM_ADDR
-# ifdef VIA_ENABLE
-# ifdef VIA_EEPROM_CUSTOM_CONFIG_ADDR
-# define DYNAMIC_KEYMAP_EEPROM_ADDR (VIA_EEPROM_CUSTOM_CONFIG_ADDR + VIA_EEPROM_CUSTOM_CONFIG_SIZE)
-# else
-# error DYNAMIC_KEYMAP_EEPROM_ADDR not defined
-# endif
-# else
-# define DYNAMIC_KEYMAP_EEPROM_ADDR EECONFIG_SIZE
-# endif
+# define DYNAMIC_KEYMAP_EEPROM_ADDR DYNAMIC_KEYMAP_EEPROM_START
#endif
// Dynamic encoders starts after dynamic keymaps
@@ -97,6 +95,10 @@ _Static_assert((DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) - (DYNAMIC_KEYMAP_MACRO_EEPROM_A
# define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + 1)
#endif
+#ifndef DYNAMIC_KEYMAP_MACRO_DELAY
+# define DYNAMIC_KEYMAP_MACRO_DELAY TAP_CODE_DELAY
+#endif
+
uint8_t dynamic_keymap_get_layer_count(void) {
return DYNAMIC_KEYMAP_LAYER_COUNT;
}
@@ -148,18 +150,25 @@ void dynamic_keymap_set_encoder(uint8_t layer, uint8_t encoder_id, bool clockwis
void dynamic_keymap_reset(void) {
// Reset the keymaps in EEPROM to what is in flash.
- // All keyboards using dynamic keymaps should define a layout
- // for the same number of layers as DYNAMIC_KEYMAP_LAYER_COUNT.
for (int layer = 0; layer < DYNAMIC_KEYMAP_LAYER_COUNT; layer++) {
for (int row = 0; row < MATRIX_ROWS; row++) {
for (int column = 0; column < MATRIX_COLS; column++) {
- dynamic_keymap_set_keycode(layer, row, column, pgm_read_word(&keymaps[layer][row][column]));
+ if (layer < keymap_layer_count()) {
+ dynamic_keymap_set_keycode(layer, row, column, pgm_read_word(&keymaps[layer][row][column]));
+ } else {
+ dynamic_keymap_set_keycode(layer, row, column, KC_TRANSPARENT);
+ }
}
}
#ifdef ENCODER_MAP_ENABLE
for (int encoder = 0; encoder < NUM_ENCODERS; encoder++) {
- dynamic_keymap_set_encoder(layer, encoder, true, pgm_read_word(&encoder_map[layer][encoder][0]));
- dynamic_keymap_set_encoder(layer, encoder, false, pgm_read_word(&encoder_map[layer][encoder][1]));
+ if (layer < encodermap_layer_count()) {
+ dynamic_keymap_set_encoder(layer, encoder, true, pgm_read_word(&encoder_map[layer][encoder][0]));
+ dynamic_keymap_set_encoder(layer, encoder, false, pgm_read_word(&encoder_map[layer][encoder][1]));
+ } else {
+ dynamic_keymap_set_encoder(layer, encoder, true, KC_TRANSPARENT);
+ dynamic_keymap_set_encoder(layer, encoder, false, KC_TRANSPARENT);
+ }
}
#endif // ENCODER_MAP_ENABLE
}
@@ -304,6 +313,6 @@ void dynamic_keymap_macro_send(uint8_t id) {
break;
}
}
- send_string(data);
+ send_string_with_delay(data, DYNAMIC_KEYMAP_MACRO_DELAY);
}
}
diff --git a/quantum/encoder.c b/quantum/encoder.c
index 105bed0147..5f8a7ce080 100644
--- a/quantum/encoder.c
+++ b/quantum/encoder.c
@@ -163,27 +163,38 @@ static bool encoder_update(uint8_t index, uint8_t state) {
index += thisHand;
#endif
encoder_pulses[i] += encoder_LUT[state & 0xF];
+
+#ifdef ENCODER_DEFAULT_POS
+ if ((encoder_pulses[i] >= resolution) || (encoder_pulses[i] <= -resolution) || ((state & 0x3) == ENCODER_DEFAULT_POS)) {
+ if (encoder_pulses[i] >= 1) {
+#else
if (encoder_pulses[i] >= resolution) {
- encoder_value[index]++;
- changed = true;
+#endif
+
+ encoder_value[index]++;
+ changed = true;
#ifdef ENCODER_MAP_ENABLE
- encoder_exec_mapping(index, ENCODER_COUNTER_CLOCKWISE);
+ encoder_exec_mapping(index, ENCODER_COUNTER_CLOCKWISE);
#else // ENCODER_MAP_ENABLE
encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE);
#endif // ENCODER_MAP_ENABLE
- }
+ }
+
+#ifdef ENCODER_DEFAULT_POS
+ if (encoder_pulses[i] <= -1) {
+#else
if (encoder_pulses[i] <= -resolution) { // direction is arbitrary here, but this clockwise
- encoder_value[index]--;
- changed = true;
+#endif
+ encoder_value[index]--;
+ changed = true;
#ifdef ENCODER_MAP_ENABLE
- encoder_exec_mapping(index, ENCODER_CLOCKWISE);
+ encoder_exec_mapping(index, ENCODER_CLOCKWISE);
#else // ENCODER_MAP_ENABLE
encoder_update_kb(index, ENCODER_CLOCKWISE);
#endif // ENCODER_MAP_ENABLE
- }
- encoder_pulses[i] %= resolution;
+ }
+ encoder_pulses[i] %= resolution;
#ifdef ENCODER_DEFAULT_POS
- if ((state & 0x3) == ENCODER_DEFAULT_POS) {
encoder_pulses[i] = 0;
}
#endif
diff --git a/quantum/keyboard.c b/quantum/keyboard.c
index a65f9d6d18..1c62a43d9d 100644
--- a/quantum/keyboard.c
+++ b/quantum/keyboard.c
@@ -212,6 +212,12 @@ static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata) {
return false;
}
+#else
+
+static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata) {
+ return false;
+}
+
#endif
/** \brief matrix_setup
@@ -381,12 +387,9 @@ void keyboard_init(void) {
#ifdef ENCODER_ENABLE
encoder_init();
#endif
-#ifdef STENO_ENABLE
+#ifdef STENO_ENABLE_ALL
steno_init();
#endif
-#ifdef POINTING_DEVICE_ENABLE
- pointing_device_init();
-#endif
#if defined(NKRO_ENABLE) && defined(FORCE_NKRO)
keymap_config.nkro = 1;
eeconfig_update_keymap(keymap_config.raw);
@@ -403,6 +406,10 @@ void keyboard_init(void) {
#ifdef SPLIT_KEYBOARD
split_post_init();
#endif
+#ifdef POINTING_DEVICE_ENABLE
+ // init after split init
+ pointing_device_init();
+#endif
#if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE)
debug_enable = true;
@@ -425,64 +432,74 @@ void switch_events(uint8_t row, uint8_t col, bool pressed) {
#endif
}
-/** \brief Perform scan of keyboard matrix
+/**
+ * @brief Generates a tick event at a maximum rate of 1KHz that drives the
+ * internal QMK state machine.
+ */
+static inline void generate_tick_event(void) {
+ static uint16_t last_tick = 0;
+ const uint16_t now = timer_read();
+ if (TIMER_DIFF_16(now, last_tick) != 0) {
+ action_exec(TICK_EVENT);
+ last_tick = now;
+ }
+}
+
+/**
+ * @brief This task scans the keyboards matrix and processes any key presses
+ * that occur.
*
- * Any detected changes in state are sent out as part of the processing
+ * @return true Matrix did change
+ * @return false Matrix didn't change
*/
-bool matrix_scan_task(void) {
- static matrix_row_t matrix_prev[MATRIX_ROWS];
- matrix_row_t matrix_row = 0;
- matrix_row_t matrix_change = 0;
-#ifdef QMK_KEYS_PER_SCAN
- uint8_t keys_processed = 0;
-#endif
+static bool matrix_task(void) {
+ static matrix_row_t matrix_previous[MATRIX_ROWS];
- uint8_t matrix_changed = matrix_scan();
- if (matrix_changed) last_matrix_activity_trigger();
+ matrix_scan();
- for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
- matrix_row = matrix_get_row(r);
- matrix_change = matrix_row ^ matrix_prev[r];
- if (matrix_change) {
-#ifdef MATRIX_HAS_GHOST
- if (has_ghost_in_row(r, matrix_row)) {
- continue;
- }
-#endif
- if (debug_matrix) matrix_print();
- matrix_row_t col_mask = 1;
- for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) {
- if (matrix_change & col_mask) {
- if (should_process_keypress()) {
- action_exec((keyevent_t){
- .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & col_mask), .time = (timer_read() | 1) /* time should not be 0 */
- });
- }
- // record a processed key
- matrix_prev[r] ^= col_mask;
-
- switch_events(r, c, (matrix_row & col_mask));
-
-#ifdef QMK_KEYS_PER_SCAN
- // only jump out if we have processed "enough" keys.
- if (++keys_processed >= QMK_KEYS_PER_SCAN)
-#endif
- // process a key per task call
- goto MATRIX_LOOP_END;
+ bool matrix_changed = false;
+ for (uint8_t row = 0; row < MATRIX_ROWS && !matrix_changed; row++) {
+ matrix_changed |= matrix_previous[row] ^ matrix_get_row(row);
+ }
+
+ matrix_scan_perf_task();
+
+ // Short-circuit the complete matrix processing if it is not necessary
+ if (!matrix_changed) {
+ generate_tick_event();
+ return matrix_changed;
+ }
+
+ if (debug_config.matrix) {
+ matrix_print();
+ }
+
+ const bool process_keypress = should_process_keypress();
+
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ const matrix_row_t current_row = matrix_get_row(row);
+ const matrix_row_t row_changes = current_row ^ matrix_previous[row];
+
+ if (!row_changes || has_ghost_in_row(row, current_row)) {
+ continue;
+ }
+
+ matrix_row_t col_mask = 1;
+ for (uint8_t col = 0; col < MATRIX_COLS; col++, col_mask <<= 1) {
+ if (row_changes & col_mask) {
+ const bool key_pressed = current_row & col_mask;
+
+ if (process_keypress) {
+ action_exec(MAKE_KEYEVENT(row, col, key_pressed));
}
+
+ switch_events(row, col, key_pressed);
}
}
- }
- // call with pseudo tick event when no real key event.
-#ifdef QMK_KEYS_PER_SCAN
- // we can get here with some keys processed now.
- if (!keys_processed)
-#endif
- action_exec(TICK_EVENT);
-MATRIX_LOOP_END:
+ matrix_previous[row] = current_row;
+ }
- matrix_scan_perf_task();
return matrix_changed;
}
@@ -561,20 +578,12 @@ void quantum_task(void) {
#endif
}
-/** \brief Keyboard task: Do keyboard routine jobs
- *
- * Do routine keyboard jobs:
- *
- * * scan matrix
- * * handle mouse movements
- * * handle midi commands
- * * light LEDs
- *
- * This is repeatedly called as fast as possible.
- */
+/** \brief Main task that is repeatedly called as fast as possible. */
void keyboard_task(void) {
- bool matrix_changed = matrix_scan_task();
- (void)matrix_changed;
+ const bool matrix_changed = matrix_task();
+ if (matrix_changed) {
+ last_matrix_activity_trigger();
+ }
quantum_task();
@@ -596,8 +605,10 @@ void keyboard_task(void) {
#endif
#ifdef ENCODER_ENABLE
- bool encoders_changed = encoder_read();
- if (encoders_changed) last_encoder_activity_trigger();
+ const bool encoders_changed = encoder_read();
+ if (encoders_changed) {
+ last_encoder_activity_trigger();
+ }
#endif
#ifdef OLED_ENABLE
diff --git a/quantum/keyboard.h b/quantum/keyboard.h
index fe0736a515..86ce65aac1 100644
--- a/quantum/keyboard.h
+++ b/quantum/keyboard.h
@@ -71,9 +71,15 @@ static inline bool IS_RELEASED(keyevent_t event) {
/* Common keyevent object factory */
#define MAKE_KEYPOS(row_num, col_num) ((keypos_t){.row = (row_num), .col = (col_num)})
+
+/**
+ * @brief Constructs a key event for a pressed or released key.
+ */
#define MAKE_KEYEVENT(row_num, col_num, press) ((keyevent_t){.key = MAKE_KEYPOS((row_num), (col_num)), .pressed = (press), .time = (timer_read() | 1)})
-/* Tick event */
+/**
+ * @brief Constructs a internal tick event that is used to drive the internal QMK state machine.
+ */
#define TICK_EVENT MAKE_KEYEVENT(KEYLOC_TICK, KEYLOC_TICK, false)
#ifdef ENCODER_MAP_ENABLE
diff --git a/quantum/keycode_config.c b/quantum/keycode_config.c
index dd2a17e242..5b5cc5d28e 100644
--- a/quantum/keycode_config.c
+++ b/quantum/keycode_config.c
@@ -29,6 +29,8 @@ uint16_t keycode_config(uint16_t keycode) {
case KC_LOCKING_CAPS_LOCK:
if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) {
return KC_LEFT_CTRL;
+ } else if (keymap_config.swap_escape_capslock) {
+ return KC_ESCAPE;
}
return keycode;
case KC_LEFT_CTRL:
@@ -96,6 +98,8 @@ uint16_t keycode_config(uint16_t keycode) {
case KC_ESCAPE:
if (keymap_config.swap_grave_esc) {
return KC_GRAVE;
+ } else if (keymap_config.swap_escape_capslock) {
+ return KC_CAPS_LOCK;
}
return KC_ESCAPE;
case KC_BACKSLASH:
diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h
index a2cb025ed2..81a8e61471 100644
--- a/quantum/keycode_config.h
+++ b/quantum/keycode_config.h
@@ -38,6 +38,7 @@ typedef union {
bool swap_lctl_lgui : 1;
bool swap_rctl_rgui : 1;
bool oneshot_enable : 1;
+ bool swap_escape_capslock : 1;
};
} keymap_config_t;
diff --git a/quantum/keymap.h b/quantum/keymap.h
index d64b271efb..edff484129 100644
--- a/quantum/keymap.h
+++ b/quantum/keymap.h
@@ -46,6 +46,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "quantum_keycodes.h"
+// Gross hack, remove me and change RESET keycode to QK_BOOT
+#if defined(MCU_RP)
+# undef RESET
+#endif
+
// translates key to keycode
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
@@ -55,3 +60,5 @@ extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
// Ensure we have a forward declaration for the encoder map
# include "encoder.h"
#endif
+
+#include "keymap_introspection.h"
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index c1940f0fd3..8d7a8bda9a 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -47,10 +47,9 @@ action_t action_for_keycode(uint16_t keycode) {
keycode = keycode_config(keycode);
action_t action = {};
- uint8_t action_layer, when, mod;
+ uint8_t action_layer, mod;
(void)action_layer;
- (void)when;
(void)mod;
switch (keycode) {
@@ -85,9 +84,8 @@ action_t action_for_keycode(uint16_t keycode) {
break;
case QK_TO ... QK_TO_MAX:;
// Layer set "GOTO"
- when = (keycode >> 0x4) & 0x3;
- action_layer = keycode & 0xF;
- action.code = ACTION_LAYER_SET(action_layer, when);
+ action_layer = keycode & 0xFF;
+ action.code = ACTION_LAYER_GOTO(action_layer);
break;
case QK_MOMENTARY ... QK_MOMENTARY_MAX:;
// Momentary action_layer
diff --git a/quantum/keymap_extras/keymap_bepo.h b/quantum/keymap_extras/keymap_bepo.h
index ea04aed3c1..dc3bcda5a2 100644
--- a/quantum/keymap_extras/keymap_bepo.h
+++ b/quantum/keymap_extras/keymap_bepo.h
@@ -237,169 +237,4 @@
#define BP_DDAG S(ALGR(BP_H)) // ‡
#define BP_FORD S(ALGR(BP_F)) // ª
// Row 5
-#define BP_NNBS S(ALGR(BP_)) // (narrow non-breaking space)
-
-// DEPRECATED
-#define BP_DOLLAR BP_DLR
-#define BP_DOUBLE_QUOTE BP_DQUO
-#define BP_DQOT BP_DQUO
-#define BP_LEFT_GUILLEMET BP_LDAQ
-#define BP_LGIL BP_LDAQ
-#define BP_RIGHT_GUILLEMET BP_RDAQ
-#define BP_RGIL BP_RDAQ
-#define BP_LEFT_PAREN BP_LPRN
-#define BP_RIGHT_PAREN BP_RPRN
-#define BP_MINUS BP_MINS
-#define BP_SLASH BP_SLSH
-#define BP_ASTERISK BP_ASTR
-#define BP_EQUAL BP_EQL
-#define BP_PERCENT BP_PERC
-#define BP_E_ACUTE BP_EACU
-#define BP_ECUT BP_EACU
-#define BP_E_GRAVE BP_EGRV
-#define BP_DEAD_CIRCUMFLEX BP_DCIR
-#define BP_DCRC BP_DCIR
-#define BP_COMMA BP_COMM
-#define BP_C_CEDILLA BP_CCED
-#define BP_E_CIRCUMFLEX BP_ECIR
-#define BP_ECRC BP_ECIR
-#define BP_A_GRAVE BP_AGRV
-#define BP_APOSTROPHE BP_QUOT
-#define BP_APOS BP_QUOT
-#define BP_DEGREE BP_DEG
-#define BP_DEGR BP_DEG
-#define BP_GRAVE BP_GRV
-#define BP_EXCLAIM BP_EXLM
-#define BP_SCOLON BP_SCLN
-#define BP_COLON BP_COLN
-#define BP_QUESTION BP_QUES
-#define BP_QEST BP_QUES
-#define BP_NON_BREAKING_SPACE BP_NBSP
-#define BP_EN_DASH BP_NDSH
-#define BP_EM_DASH BP_MDSH
-#define BP_LESS BP_LABK
-#define BP_GREATER BP_RABK
-#define BP_GRTR BP_RABK
-#define BP_LBRACKET BP_LBRC
-#define BP_RBRACKET BP_RBRC
-#define BP_CIRCUMFLEX CIRC
-#define BP_PLUS_MINUS BP_PLMN
-#define BP_PSMS BP_PLMN
-#define BP_MATH_MINUS BP_MMNS
-#define BP_OBELUS BP_DIV
-#define BP_OBEL BP_DIV
-#define BP_DIVISION_SIGN BP_DIV
-#define BP_DVSN BP_DIV
-#define BP_TIMES BP_MUL
-#define BP_TIMS BP_MUL
-#define BP_DIFFERENT BP_NEQL
-#define BP_DIFF BP_NEQL
-#define BP_PERMILLE BP_PERM
-#define BP_PMIL BP_PERM
-#define BP_DEAD_ACUTE BP_ACUT
-#define BP_DACT BP_ACUT
-#define BP_AMPERSAND BP_AMPR
-#define BP_OE_LIGATURE BP_OE
-#define BP_DEAD_GRAVE BP_DGRV
-#define BP_INVERTED_EXCLAIM BP_IEXL
-#define BP_IXLM BP_IEXL
-#define BP_DEAD_CARON BP_CARN
-#define BP_DCAR BP_CARN
-#define BP_DEAD_SLASH BP_DSLS
-#define BP_DSLH BP_DSLS
-#define BP_IJ_LIGATURE BP_IJ
-#define BP_SCHWA BP_SCHW
-#define BP_SCWA BP_SCHW
-#define BP_DEAD_BREVE BP_BREV
-#define BP_DBRV BP_BREV
-#define BP_AE_LIGATURE BP_AE
-#define BP_U_GRAVE BP_UGRV
-#define BP_DEAD_TREMA BP_DIAE
-#define BP_DTRM BP_DIAE
-#define BP_TYPOGRAPHICAL_APOSTROPHE BP_COMM
-#define BP_TAPO BP_COMM
-#define BP_COPYRIGHT BP_COPY
-#define BP_CPRT BP_COPY
-#define BP_THORN BP_THRN
-#define BP_SHARP_S BP_SS
-#define BP_SRPS BP_SS
-#define BP_REGISTERED_TRADEMARK BP_REGD
-#define BP_RTM BP_REGD
-#define BP_DEAD_TILDE BP_DTIL
-#define BP_DTLD BP_DTIL
-#define BP_DEAD_MACRON BP_MACR
-#define BP_DMCR BP_MACR
-#define BP_DEAD_CEDILLA BP_CEDL
-#define BP_DCED BP_CEDL
-#define BP_NONUS_SLASH BP_SLSH
-#define BP_NUSL BP_SLSH
-#define BP_BACKSLASH BP_BSLS
-#define BP_LEFT_CURLY_BRACE BP_LCBR
-#define BP_RIGHT_CURLY_BRACE BP_RCBR
-#define BP_ELLIPSIS BP_ELLP
-#define BP_ELPS BP_ELLP
-#define BP_TILDE BP_TILD
-#define BP_INVERTED_QUESTION BP_IQUE
-#define BP_IQST BP_IQUE
-#define BP_DEAD_RING BP_RNGA
-#define BP_DRNG BP_RNGA
-#define BP_DEAD_GREEK BP_DGRK
-#define BP_DAGGER BP_DAGG
-#define BP_DAGR BP_DAGG
-#define BP_DEAD_OGONEK BP_OGON
-#define BP_DOGO BP_OGON
-#define BP_UNDERSCORE BP_UNDS
-#define BP_PARAGRAPH BP_PARA
-#define BP_PARG BP_PARA
-#define BP_LOW_DOUBLE_QUOTE BP_DLQU
-#define BP_LWQT BP_DLQU
-#define BP_LEFT_DOUBLE_QUOTE BP_RDQU
-#define BP_RIGHT_DOUBLE_QUOTE BP_RDQU
-#define BP_LESS_OR_EQUAL BP_LEQL
-#define BP_GREATER_OR_EQUAL BP_GEQL
-#define BP_NEGATION BP_NOT
-#define BP_NEGT BP_NOT
-#define BP_ONE_QUARTER BP_QRTR
-#define BP_1QRT BP_QRTR
-#define BP_ONE_HALF BP_HALF
-#define BP_1HLF BP_HALF
-#define BP_THREE_QUARTERS TQTR
-#define BP_3QRT BP_TQTR
-#define BP_MINUTES BP_PRIM
-#define BP_MNUT BP_PRIM
-#define BP_SECONDS BP_DPRM
-#define BP_SCND BP_DPRM
-#define BP_BROKEN_PIPE BP_BRKP
-#define BP_BPIP BP_BRKP
-#define BP_DEAD_DOUBLE_ACUTE BP_DACU
-#define BP_DDCT BP_DACU
-#define BP_SECTION BP_SECT
-#define BP_GRAVE_BIS BP_GRV
-#define BP_GRVB BP_GRV
-#define BP_DEAD_DOT_ABOVE BP_DOTA
-#define BP_DDTA BP_DOTA
-#define BP_DEAD_CURRENCY BP_CURR
-#define BP_DCUR BP_CURR
-#define BP_DEAD_HORN BP_HORN
-#define BP_DHRN BP_HORN
-#define BP_LONG_S BP_LNGS
-#define BP_TRADEMARK BP_TM
-#define BP_ORDINAL_INDICATOR_O MORD
-#define BP_ORDO BP_MORD
-#define BP_DEAD_COMMA BP_DCMM
-#define BP_DCOM BP_DCMM
-#define BP_LEFT_QUOTE BP_LSQU
-#define BP_LQOT BP_LSQU
-#define BP_RIGHT_QUOTE BP_RSQU
-#define BP_RQOT BP_RSQU
-#define BP_INTERPUNCT BP_MDDT
-#define BP_IPCT BP_MDDT
-#define BP_DEAD_HOOK_ABOVE BP_HOKA
-#define BP_DHKA BP_HOKA
-#define BP_DEAD_UNDERDOT BP_DOTB
-#define BP_DUDT BP_DOTB
-#define BP_DOUBLE_DAGGER BP_DDAG
-#define BP_DDGR BP_DDAG
-#define BP_ORDINAL_INDICATOR_A BP_FORD
-#define BP_ORDA BP_FORD
-#define BP_NARROW_NON_BREAKING_SPACE BP_NNBS
+#define BP_NNBS S(ALGR(KC_SPC)) //   (narrow non-breaking space)
diff --git a/quantum/keymap_extras/keymap_czech.h b/quantum/keymap_extras/keymap_czech.h
index 43ba2a14ff..21ebf79686 100644
--- a/quantum/keymap_extras/keymap_czech.h
+++ b/quantum/keymap_extras/keymap_czech.h
@@ -111,7 +111,7 @@
#define CZ_8 S(CZ_AACU) // 8
#define CZ_9 S(CZ_IACU) // 9
#define CZ_0 S(CZ_EACU) // 0
-#define CZ_PERC S(CZ_PLUS) // %
+#define CZ_PERC S(CZ_EQL) // %
#define CZ_CARN S(CZ_ACUT) // ˇ (dead)
// Row 2
#define CZ_SLSH S(CZ_UACU) // /
diff --git a/quantum/keymap_extras/keymap_japanese.h b/quantum/keymap_extras/keymap_japanese.h
index a3907a0372..6ad2c4da47 100644
--- a/quantum/keymap_extras/keymap_japanese.h
+++ b/quantum/keymap_extras/keymap_japanese.h
@@ -28,7 +28,7 @@
/*
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
- * │Z↔︎H│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ ^ │ ¥ │ │
+ * │Z↔H│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ ^ │ ¥ │ │
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┤
* │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ @ │ [ │ │
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
@@ -40,7 +40,7 @@
* └─────┴───┴─────┴─────┴─────────┴─────┴───┴───┴───┴───┴─────┘
*/
// Row 1
-#define JP_ZKHK KC_GRV // Zenkaku ↔︎ Hankaku ↔ Kanji (半角 ↔ 全角 ↔ 漢字)
+#define JP_ZKHK KC_GRV // Zenkaku ↔ Hankaku ↔ Kanji (半角 ↔ 全角 ↔ 漢字)
#define JP_1 KC_1 // 1
#define JP_2 KC_2 // 2
#define JP_3 KC_3 // 3
diff --git a/quantum/keymap_extras/keymap_korean.h b/quantum/keymap_extras/keymap_korean.h
index da914767b8..edfa356e89 100644
--- a/quantum/keymap_extras/keymap_korean.h
+++ b/quantum/keymap_extras/keymap_korean.h
@@ -121,7 +121,7 @@
#define KR_PIPE S(KR_WON) // |
// Row 3
#define KR_COLN S(KR_SCLN) // :
-#define KR_DQUO S(KR_COLN) // "
+#define KR_DQUO S(KR_QUOT) // "
// Row 4
#define KR_LABK S(KR_COMM) // <
#define KR_RABK S(KR_DOT) // >
diff --git a/quantum/keymap_extras/keymap_latvian.h b/quantum/keymap_extras/keymap_latvian.h
index 452e9167bc..025adf4fe0 100644
--- a/quantum/keymap_extras/keymap_latvian.h
+++ b/quantum/keymap_extras/keymap_latvian.h
@@ -161,8 +161,8 @@
#define LV_ACUT ALGR(LV_QUOT) // ´ (dead)
// Row 4
#define LV_ZCAR ALGR(LV_Z) // Ž
-#define LV_CCAR ALGR(LV_Z) // Č
-#define LV_NCED ALGR(LV_Z) // Ņ
+#define LV_CCAR ALGR(LV_C) // Č
+#define LV_NCED ALGR(LV_N) // Ņ
/* Shift+AltGr symbols
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
diff --git a/quantum/keymap_extras/keymap_lithuanian_qwerty.h b/quantum/keymap_extras/keymap_lithuanian_qwerty.h
index 0f92562a13..cbd56f1a67 100644
--- a/quantum/keymap_extras/keymap_lithuanian_qwerty.h
+++ b/quantum/keymap_extras/keymap_lithuanian_qwerty.h
@@ -24,11 +24,11 @@
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
* │ ` │ Ą │ Č │ Ę │ Ė │ Į │ Š │ Ų │ Ū │ 9 │ 0 │ - │ Ž │       │
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │     │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │     │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
- * │      │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ \ │    │
- * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │        │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │          │
+ * │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │ \ │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │ │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │ │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │ │
* ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
* │    │    │    │                        │    │    │    │    │
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
@@ -72,7 +72,7 @@
#define LT_L KC_L // L
#define LT_SCLN KC_SCLN // ;
#define LT_QUOT KC_QUOT // '
-#define LT_BSLS KC_NUHS // (backslash)
+#define LT_BSLS KC_BSLS // (backslash)
// Row 4
#define LT_Z KC_Z // Z
#define LT_X KC_X // X
@@ -89,11 +89,11 @@
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
* │ ~ │   │   │   │   │   │   │   │   │ ( │ ) │ _ │   │       │
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │     │   │   │   │   │   │   │   │   │   │   │ { │ } │     │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
- * │      │   │   │   │   │   │   │   │   │   │ : │ " │ | │    │
- * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │        │   │   │   │   │   │   │   │ < │ > │ ? │          │
+ * │ │ │ │ │ │ │ │ │ │ │ │ { │ } │ | │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │ │ │ │ │ │ │ │ │ │ │ : │ " │ │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │ │ │ │ │ │ │ │ │ < │ > │ ? │ │
* ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
* │    │    │    │                        │    │    │    │    │
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
@@ -102,12 +102,12 @@
#define LT_TILD S(LT_GRV) // ~
#define LT_LPRN S(LT_9) // (
#define LT_RPRN S(LT_0) // )
-#define LT_UNDS S(LT_MINS) // *
+#define LT_UNDS S(LT_MINS) // _
// Row 2
#define LT_LCBR S(LT_LBRC) // {
#define LT_RCBR S(LT_RBRC) // }
// Row 3
-#define LT_COLN S(LT_SCLN) // ;
+#define LT_COLN S(LT_SCLN) // :
#define LT_DQUO S(LT_QUOT) // "
#define LT_PIPE S(LT_BSLS) // |
// Row 4
@@ -119,11 +119,11 @@
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
* │   │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │   │   │   │ = │       │
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │     │   │   │ € │   │   │   │   │   │   │   │   │   │     │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
- * │      │   │   │   │   │   │   │   │   │   │   │   │   │    │
- * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │        │   │   │   │   │   │   │   │   │   │   │          │
+ * │ │ │ │ € │ │ │ │ │ │ │ │ │ │ │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │ │ │ │ │ │ │ │ │ │ │ │ │ │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │ │ │ │ │ │ │ │ │ │ │ │ │
* ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
* │    │    │    │                        │    │    │    │    │
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
@@ -137,7 +137,7 @@
#define LT_6 ALGR(LT_SCAR) // 6
#define LT_7 ALGR(LT_UOGO) // 7
#define LT_8 ALGR(LT_UMAC) // 8
-#define LT_EQL ALGR(LT_PLUS) // =
+#define LT_EQL ALGR(LT_ZCAR) // =
// Row 2
#define LT_EURO ALGR(LT_E) // €
@@ -145,11 +145,11 @@
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
* │   │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │   │   │   │ + │       │
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │     │   │   │   │   │   │   │   │   │   │   │   │   │     │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
- * │      │   │   │   │   │   │   │   │   │   │   │   │   │    │
- * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │        │   │   │   │   │   │   │   │   │   │   │          │
+ * │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │ │ │ │ │ │ │ │ │ │ │ │ │ │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │ │ │ │ │ │ │ │ │ │ │ │ │
* ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
* │    │    │    │                        │    │    │    │    │
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
@@ -163,4 +163,4 @@
#define LT_CIRC S(ALGR(LT_SCAR)) // ^
#define LT_AMPR S(ALGR(LT_UOGO)) // &
#define LT_ASTR S(ALGR(LT_UMAC)) // *
-#define LT_PLUS S(ALGR(LT_PLUS)) // +
+#define LT_PLUS S(ALGR(LT_ZCAR)) // +
diff --git a/quantum/keymap_extras/keymap_norman.h b/quantum/keymap_extras/keymap_norman.h
index 45727467bc..3da80e0401 100644
--- a/quantum/keymap_extras/keymap_norman.h
+++ b/quantum/keymap_extras/keymap_norman.h
@@ -89,7 +89,7 @@
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
* │ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │       │
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │     │   │   │   │   │   │   │   │   │   │ ; │ { │ } │  |  │
+ * │ │ │ │ │ │ │ │ │ │ │ : │ { │ } │ | │
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
* │      │   │   │   │   │   │   │   │   │   │   │ " │        │
* ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
diff --git a/quantum/keymap_extras/keymap_spanish_dvorak.h b/quantum/keymap_extras/keymap_spanish_dvorak.h
index b6bc734c37..9f18bdea56 100644
--- a/quantum/keymap_extras/keymap_spanish_dvorak.h
+++ b/quantum/keymap_extras/keymap_spanish_dvorak.h
@@ -114,8 +114,8 @@
#define DV_QUES S(DV_QUOT) // ?
#define DV_IQUE S(DV_IEXL) // ¿
// Row 2
-#define DV_COLN S(KC_DOT) // :
-#define DV_SCLN S(KC_COMM) // ;
+#define DV_COLN S(DV_DOT) // :
+#define DV_SCLN S(DV_COMM) // ;
#define DV_CIRC S(DV_GRV) // ^ (dead)
#define DV_ASTR S(DV_PLUS) // *
// Row 3
diff --git a/quantum/keymap_extras/keymap_steno.h b/quantum/keymap_extras/keymap_steno.h
index b9115fb8bf..a8173d5293 100644
--- a/quantum/keymap_extras/keymap_steno.h
+++ b/quantum/keymap_extras/keymap_steno.h
@@ -72,3 +72,48 @@ enum steno_keycodes {
STN_ZR,
STN__MAX = STN_ZR, // must be less than QK_STENO_BOLT
};
+
+#ifdef STENO_COMBINEDMAP
+enum steno_combined_keycodes {
+ STN_S3 = QK_STENO_COMB,
+ STN_TKL,
+ STN_PWL,
+ STN_HRL,
+ STN_FRR,
+ STN_PBR,
+ STN_LGR,
+ STN_TSR,
+ STN_DZR,
+ STN_AO,
+ STN_EU,
+ STN_COMB_MAX = STN_EU,
+};
+#endif
+
+#ifdef STENO_ENABLE_BOLT
+// TxBolt Codes
+# define TXB_NUL 0
+# define TXB_S_L 0b00000001
+# define TXB_T_L 0b00000010
+# define TXB_K_L 0b00000100
+# define TXB_P_L 0b00001000
+# define TXB_W_L 0b00010000
+# define TXB_H_L 0b00100000
+# define TXB_R_L 0b01000001
+# define TXB_A_L 0b01000010
+# define TXB_O_L 0b01000100
+# define TXB_STR 0b01001000
+# define TXB_E_R 0b01010000
+# define TXB_U_R 0b01100000
+# define TXB_F_R 0b10000001
+# define TXB_R_R 0b10000010
+# define TXB_P_R 0b10000100
+# define TXB_B_R 0b10001000
+# define TXB_L_R 0b10010000
+# define TXB_G_R 0b10100000
+# define TXB_T_R 0b11000001
+# define TXB_S_R 0b11000010
+# define TXB_D_R 0b11000100
+# define TXB_Z_R 0b11001000
+# define TXB_NUM 0b11010000
+#endif // STENO_ENABLE_BOLT
diff --git a/quantum/keymap_extras/keymap_turkish_f.h b/quantum/keymap_extras/keymap_turkish_f.h
index acb130c838..aac27413c9 100644
--- a/quantum/keymap_extras/keymap_turkish_f.h
+++ b/quantum/keymap_extras/keymap_turkish_f.h
@@ -187,7 +187,7 @@
#define TR_CURR S(ALGR(TR_4)) // ¤
#define TR_IQUE S(ALGR(TR_SLSH)) // ¿
// Row 2
-#define TR_REGD S(ALGR(TR_I) // ®
+#define TR_REGD S(ALGR(TR_I)) // ®
// Row 3
#define TR_SECT S(ALGR(TR_IDOT)) // §
#define TR_FORD S(ALGR(TR_A)) // ª
diff --git a/quantum/keymap_extras/keymap_us_extended.h b/quantum/keymap_extras/keymap_us_extended.h
index fb3e9c7d36..8e71a8de25 100644
--- a/quantum/keymap_extras/keymap_us_extended.h
+++ b/quantum/keymap_extras/keymap_us_extended.h
@@ -145,7 +145,7 @@
#define US_CURR ALGR(US_4) // ¤
#define US_EURO ALGR(US_5) // €
#define US_DCIR ALGR(US_6) // ^ (dead)
-#define US_HORN ALGR(US_7) // ̛̛ (dead)
+#define US_HORN ALGR(US_7) // ̛ (dead)
#define US_OGON ALGR(US_8) // ˛ (dead)
#define US_LSQU ALGR(US_9) // ‘
#define US_RSQU ALGR(US_0) // ’
diff --git a/quantum/keymap_introspection.c b/quantum/keymap_introspection.c
new file mode 100644
index 0000000000..179b5eb037
--- /dev/null
+++ b/quantum/keymap_introspection.c
@@ -0,0 +1,32 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+// Pull the actual keymap code so that we can inspect stuff from it
+#include KEYMAP_C
+
+// Allow for keymap or userspace rules.mk to specify an alternate location for the keymap array
+#ifdef INTROSPECTION_KEYMAP_C
+# include INTROSPECTION_KEYMAP_C
+#endif // INTROSPECTION_KEYMAP_C
+
+#include "keymap_introspection.h"
+
+#define NUM_KEYMAP_LAYERS ((uint8_t)(sizeof(keymaps) / ((MATRIX_ROWS) * (MATRIX_COLS) * sizeof(uint16_t))))
+
+uint8_t keymap_layer_count(void) {
+ return NUM_KEYMAP_LAYERS;
+}
+
+_Static_assert(NUM_KEYMAP_LAYERS <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT");
+
+#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
+
+# define NUM_ENCODERMAP_LAYERS ((uint8_t)(sizeof(encoder_map) / ((NUM_ENCODERS) * (2) * sizeof(uint16_t))))
+
+uint8_t encodermap_layer_count(void) {
+ return NUM_ENCODERMAP_LAYERS;
+}
+
+_Static_assert(NUM_KEYMAP_LAYERS == NUM_ENCODERMAP_LAYERS, "Number of encoder_map layers doesn't match the number of keymap layers");
+
+#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
diff --git a/quantum/keymap_introspection.h b/quantum/keymap_introspection.h
new file mode 100644
index 0000000000..23f6f2016f
--- /dev/null
+++ b/quantum/keymap_introspection.h
@@ -0,0 +1,15 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#include <stdint.h>
+
+// Get the number of layers defined in the keymap
+uint8_t keymap_layer_count(void);
+
+#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
+
+// Get the number of layers defined in the encoder map
+uint8_t encodermap_layer_count(void);
+
+#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
diff --git a/quantum/led.c b/quantum/led.c
index c5ddbc22c5..444d38f751 100644
--- a/quantum/led.c
+++ b/quantum/led.c
@@ -15,6 +15,7 @@
*/
#include "led.h"
#include "host.h"
+#include "timer.h"
#include "debug.h"
#include "gpio.h"
@@ -54,6 +55,14 @@ static void handle_backlight_caps_lock(led_t led_state) {
}
#endif
+static uint32_t last_led_modification_time = 0;
+uint32_t last_led_activity_time(void) {
+ return last_led_modification_time;
+}
+uint32_t last_led_activity_elapsed(void) {
+ return timer_elapsed32(last_led_modification_time);
+}
+
/** \brief Lock LED set callback - keymap/user level
*
* \deprecated Use led_update_user() instead.
@@ -174,7 +183,8 @@ void led_task(void) {
// update LED
uint8_t led_status = host_keyboard_leds();
if (last_led_status != led_status) {
- last_led_status = led_status;
+ last_led_status = led_status;
+ last_led_modification_time = timer_read32();
if (debug_keyboard) {
debug("led_task: ");
diff --git a/quantum/led.h b/quantum/led.h
index 934d25312c..b8262cbd8e 100644
--- a/quantum/led.h
+++ b/quantum/led.h
@@ -61,6 +61,9 @@ void led_set_kb(uint8_t usb_led);
bool led_update_user(led_t led_state);
bool led_update_kb(led_t led_state);
+uint32_t last_led_activity_time(void); // Timestamp of the LED activity
+uint32_t last_led_activity_elapsed(void); // Number of milliseconds since the last LED activity
+
#ifdef __cplusplus
}
#endif
diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c
index 38ed79bed0..14dd0dd48a 100644
--- a/quantum/led_matrix/led_matrix.c
+++ b/quantum/led_matrix/led_matrix.c
@@ -618,10 +618,20 @@ void led_matrix_decrease_speed(void) {
led_matrix_decrease_speed_helper(true);
}
+void led_matrix_set_flags_eeprom_helper(led_flags_t flags, bool write_to_eeprom) {
+ led_matrix_eeconfig.flags = flags;
+ eeconfig_flag_led_matrix(write_to_eeprom);
+ dprintf("led matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.flags);
+}
+
led_flags_t led_matrix_get_flags(void) {
return led_matrix_eeconfig.flags;
}
void led_matrix_set_flags(led_flags_t flags) {
- led_matrix_eeconfig.flags = flags;
+ led_matrix_set_flags_eeprom_helper(flags, true);
+}
+
+void led_matrix_set_flags_noeeprom(led_flags_t flags) {
+ led_matrix_set_flags_eeprom_helper(flags, false);
}
diff --git a/quantum/led_matrix/led_matrix.h b/quantum/led_matrix/led_matrix.h
index d21f36e295..446f293c78 100644
--- a/quantum/led_matrix/led_matrix.h
+++ b/quantum/led_matrix/led_matrix.h
@@ -33,6 +33,9 @@
#ifdef IS31FL3733
# include "is31fl3733-simple.h"
#endif
+#ifdef CKLED2001
+# include "ckled2001-simple.h"
+#endif
#ifndef LED_MATRIX_LED_FLUSH_LIMIT
# define LED_MATRIX_LED_FLUSH_LIMIT 16
@@ -158,6 +161,7 @@ void led_matrix_decrease_speed(void);
void led_matrix_decrease_speed_noeeprom(void);
led_flags_t led_matrix_get_flags(void);
void led_matrix_set_flags(led_flags_t flags);
+void led_matrix_set_flags_noeeprom(led_flags_t flags);
typedef struct {
/* Perform any initialisation required for the other driver functions to work. */
diff --git a/quantum/led_matrix/led_matrix_drivers.c b/quantum/led_matrix/led_matrix_drivers.c
index 847ca1c310..f01b395c15 100644
--- a/quantum/led_matrix/led_matrix_drivers.c
+++ b/quantum/led_matrix/led_matrix_drivers.c
@@ -25,7 +25,7 @@
* in their own files.
*/
-#if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FLCOMMON)
+#if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FLCOMMON) || defined(CKLED2001)
# include "i2c_master.h"
static void init(void) {
@@ -78,6 +78,22 @@ static void init(void) {
# endif
# endif
# endif
+# elif defined(CKLED2001)
+# if defined(LED_DRIVER_SHUTDOWN_PIN)
+ setPinOutput(LED_DRIVER_SHUTDOWN_PIN);
+ writePinHigh(LED_DRIVER_SHUTDOWN_PIN);
+# endif
+
+ CKLED2001_init(DRIVER_ADDR_1);
+# if defined(DRIVER_ADDR_2)
+ CKLED2001_init(DRIVER_ADDR_2);
+# if defined(DRIVER_ADDR_3)
+ CKLED2001_init(DRIVER_ADDR_3);
+# if defined(DRIVER_ADDR_4)
+ CKLED2001_init(DRIVER_ADDR_4);
+# endif
+# endif
+# endif
# endif
for (int index = 0; index < DRIVER_LED_TOTAL; index++) {
@@ -87,6 +103,8 @@ static void init(void) {
IS31FL3733_set_led_control_register(index, true);
# elif defined(IS31FLCOMMON)
IS31FL_simple_set_scaling_buffer(index, true);
+# elif defined(CKLED2001)
+ CKLED2001_set_led_control_register(index, true);
# endif
}
@@ -129,6 +147,17 @@ static void init(void) {
# endif
# endif
# endif
+# elif defined(CKLED2001)
+ CKLED2001_update_led_control_registers(DRIVER_ADDR_1, 0);
+# if defined(DRIVER_ADDR_2)
+ CKLED2001_update_led_control_registers(DRIVER_ADDR_2, 1);
+# if defined(DRIVER_ADDR_3)
+ CKLED2001_update_led_control_registers(DRIVER_ADDR_3, 2);
+# if defined(DRIVER_ADDR_4)
+ CKLED2001_update_led_control_registers(DRIVER_ADDR_4, 3);
+# endif
+# endif
+# endif
# endif
}
@@ -194,5 +223,25 @@ const led_matrix_driver_t led_matrix_driver = {
.set_value = IS31FL_simple_set_brightness,
.set_value_all = IS31FL_simple_set_brigntness_all,
};
+# elif defined(CKLED2001)
+static void flush(void) {
+ CKLED2001_update_pwm_buffers(DRIVER_ADDR_1, 0);
+# if defined(DRIVER_ADDR_2)
+ CKLED2001_update_pwm_buffers(DRIVER_ADDR_2, 1);
+# if defined(DRIVER_ADDR_3)
+ CKLED2001_update_pwm_buffers(DRIVER_ADDR_3, 2);
+# if defined(DRIVER_ADDR_4)
+ CKLED2001_update_pwm_buffers(DRIVER_ADDR_4, 3);
+# endif
+# endif
+# endif
+}
+
+const led_matrix_driver_t led_matrix_driver = {
+ .init = init,
+ .flush = flush,
+ .set_value = CKLED2001_set_value,
+ .set_value_all = CKLED2001_set_value_all,
+};
# endif
#endif
diff --git a/quantum/logging/print.c b/quantum/logging/print.c
index 50a6b826ee..17e6737ac4 100644
--- a/quantum/logging/print.c
+++ b/quantum/logging/print.c
@@ -28,6 +28,6 @@ void print_set_sendchar(sendchar_func_t send) {
func = send;
}
-void _putchar(char character) {
+void putchar_(char character) {
func(character);
}
diff --git a/quantum/logging/print.h b/quantum/logging/print.h
index aa72fc7074..4c4195de50 100644
--- a/quantum/logging/print.h
+++ b/quantum/logging/print.h
@@ -32,6 +32,22 @@
void print_set_sendchar(sendchar_func_t func);
+/**
+ * @brief This macro suppress format warnings for the function that is passed
+ * in. The main use-case is that `b` format specifier for printing binary
+ * numbers is not in the official C standard. Inclusion is planned for the
+ * upcoming C2X C standard, but until then GCC will always output a warning for
+ * a unknown format specifier.
+ */
+#define IGNORE_FORMAT_WARNING(func) \
+ do { \
+ _Pragma("GCC diagnostic push"); \
+ _Pragma("GCC diagnostic ignored \"-Wformat\""); \
+ _Pragma("GCC diagnostic ignored \"-Wformat-extra-args\""); \
+ func; \
+ _Pragma("GCC diagnostic pop"); \
+ } while (0)
+
#ifndef NO_PRINT
# if __has_include_next("_print.h")
# include_next "_print.h" /* Include the platforms print.h */
@@ -78,25 +94,25 @@ void print_set_sendchar(sendchar_func_t func);
#define print_hex16(i) xprintf("%04X", i)
#define print_hex32(i) xprintf("%08lX", i)
/* binary */
-#define print_bin4(i) xprintf("%04b", i)
-#define print_bin8(i) xprintf("%08b", i)
-#define print_bin16(i) xprintf("%016b", i)
-#define print_bin32(i) xprintf("%032lb", i)
-#define print_bin_reverse8(i) xprintf("%08b", bitrev(i))
-#define print_bin_reverse16(i) xprintf("%016b", bitrev16(i))
-#define print_bin_reverse32(i) xprintf("%032lb", bitrev32(i))
+#define print_bin4(i) IGNORE_FORMAT_WARNING(xprintf("%04b", i))
+#define print_bin8(i) IGNORE_FORMAT_WARNING(xprintf("%08b", i))
+#define print_bin16(i) IGNORE_FORMAT_WARNING(xprintf("%016b", i))
+#define print_bin32(i) IGNORE_FORMAT_WARNING(xprintf("%032lb", i))
+#define print_bin_reverse8(i) IGNORE_FORMAT_WARNING(xprintf("%08b", bitrev(i)))
+#define print_bin_reverse16(i) IGNORE_FORMAT_WARNING(xprintf("%016b", bitrev16(i)))
+#define print_bin_reverse32(i) IGNORE_FORMAT_WARNING(xprintf("%032lb", bitrev32(i)))
/* print value utility */
#define print_val_dec(v) xprintf(#v ": %u\n", v)
#define print_val_decs(v) xprintf(#v ": %d\n", v)
#define print_val_hex8(v) xprintf(#v ": %X\n", v)
#define print_val_hex16(v) xprintf(#v ": %02X\n", v)
#define print_val_hex32(v) xprintf(#v ": %04lX\n", v)
-#define print_val_bin8(v) xprintf(#v ": %08b\n", v)
-#define print_val_bin16(v) xprintf(#v ": %016b\n", v)
-#define print_val_bin32(v) xprintf(#v ": %032lb\n", v)
-#define print_val_bin_reverse8(v) xprintf(#v ": %08b\n", bitrev(v))
-#define print_val_bin_reverse16(v) xprintf(#v ": %016b\n", bitrev16(v))
-#define print_val_bin_reverse32(v) xprintf(#v ": %032lb\n", bitrev32(v))
+#define print_val_bin8(v) IGNORE_FORMAT_WARNING(xprintf(#v ": %08b\n", v))
+#define print_val_bin16(v) IGNORE_FORMAT_WARNING(xprintf(#v ": %016b\n", v))
+#define print_val_bin32(v) IGNORE_FORMAT_WARNING(xprintf(#v ": %032lb\n", v))
+#define print_val_bin_reverse8(v) IGNORE_FORMAT_WARNING(xprintf(#v ": %08b\n", bitrev(v)))
+#define print_val_bin_reverse16(v) IGNORE_FORMAT_WARNING(xprintf(#v ": %016b\n", bitrev16(v)))
+#define print_val_bin_reverse32(v) IGNORE_FORMAT_WARNING(xprintf(#v ": %032lb\n", bitrev32(v)))
// User print disables the normal print messages in the body of QMK/TMK code and
// is meant as a lightweight alternative to NOPRINT. Use it when you only want to do
@@ -114,22 +130,22 @@ void print_set_sendchar(sendchar_func_t func);
#define uprint_hex16(i) uprintf("%04X", i)
#define uprint_hex32(i) uprintf("%08lX", i)
/* binary */
-#define uprint_bin4(i) uprintf("%04b", i)
-#define uprint_bin8(i) uprintf("%08b", i)
-#define uprint_bin16(i) uprintf("%016b", i)
-#define uprint_bin32(i) uprintf("%032lb", i)
-#define uprint_bin_reverse8(i) uprintf("%08b", bitrev(i))
-#define uprint_bin_reverse16(i) uprintf("%016b", bitrev16(i))
-#define uprint_bin_reverse32(i) uprintf("%032lb", bitrev32(i))
+#define uprint_bin4(i) IGNORE_FORMAT_WARNING(uprintf("%04b", i))
+#define uprint_bin8(i) IGNORE_FORMAT_WARNING(uprintf("%08b", i))
+#define uprint_bin16(i) IGNORE_FORMAT_WARNING(uprintf("%016b", i))
+#define uprint_bin32(i) IGNORE_FORMAT_WARNING(uprintf("%032lb", i))
+#define uprint_bin_reverse8(i) IGNORE_FORMAT_WARNING(uprintf("%08b", bitrev(i)))
+#define uprint_bin_reverse16(i) IGNORE_FORMAT_WARNING(uprintf("%016b", bitrev16(i)))
+#define uprint_bin_reverse32(i) IGNORE_FORMAT_WARNING(uprintf("%032lb", bitrev32(i)))
/* print value utility */
#define uprint_val_dec(v) uprintf(#v ": %u\n", v)
#define uprint_val_decs(v) uprintf(#v ": %d\n", v)
#define uprint_val_hex8(v) uprintf(#v ": %X\n", v)
#define uprint_val_hex16(v) uprintf(#v ": %02X\n", v)
#define uprint_val_hex32(v) uprintf(#v ": %04lX\n", v)
-#define uprint_val_bin8(v) uprintf(#v ": %08b\n", v)
-#define uprint_val_bin16(v) uprintf(#v ": %016b\n", v)
-#define uprint_val_bin32(v) uprintf(#v ": %032lb\n", v)
-#define uprint_val_bin_reverse8(v) uprintf(#v ": %08b\n", bitrev(v))
-#define uprint_val_bin_reverse16(v) uprintf(#v ": %016b\n", bitrev16(v))
-#define uprint_val_bin_reverse32(v) uprintf(#v ": %032lb\n", bitrev32(v))
+#define uprint_val_bin8(v) IGNORE_FORMAT_WARNING(uprintf(#v ": %08b\n", v))
+#define uprint_val_bin16(v) IGNORE_FORMAT_WARNING(uprintf(#v ": %016b\n", v))
+#define uprint_val_bin32(v) IGNORE_FORMAT_WARNING(uprintf(#v ": %032lb\n", v))
+#define uprint_val_bin_reverse8(v) IGNORE_FORMAT_WARNING(uprintf(#v ": %08b\n", bitrev(v)))
+#define uprint_val_bin_reverse16(v) IGNORE_FORMAT_WARNING(uprintf(#v ": %016b\n", bitrev16(v)))
+#define uprint_val_bin_reverse32(v) IGNORE_FORMAT_WARNING(uprintf(#v ": %032lb\n", bitrev32(v)))
diff --git a/quantum/logging/print.mk b/quantum/logging/print.mk
index 67c004192d..658c533dad 100644
--- a/quantum/logging/print.mk
+++ b/quantum/logging/print.mk
@@ -1,9 +1,12 @@
-PRINTF_PATH = $(LIB_PATH)/printf
+PRINTF_PATH = $(LIB_PATH)/printf/src
-VPATH += $(PRINTF_PATH)
-SRC += $(PRINTF_PATH)/printf.c
+VPATH += $(PRINTF_PATH) $(PRINTF_PATH)/printf
+SRC += printf.c
QUANTUM_SRC +=$(QUANTUM_DIR)/logging/print.c
-OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_FLOAT
-OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL
-OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_LONG_LONG
-OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T
+
+OPT_DEFS += -DPRINTF_SUPPORT_DECIMAL_SPECIFIERS=0
+OPT_DEFS += -DPRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS=0
+OPT_DEFS += -DPRINTF_SUPPORT_LONG_LONG=0
+OPT_DEFS += -DPRINTF_SUPPORT_WRITEBACK_SPECIFIER=0
+OPT_DEFS += -DSUPPORT_MSVC_STYLE_INTEGER_SPECIFIERS=0
+OPT_DEFS += -DPRINTF_ALIAS_STANDARD_FUNCTION_NAMES=1
diff --git a/quantum/matrix.c b/quantum/matrix.c
index db59b73754..db683104ed 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -337,10 +337,9 @@ uint8_t matrix_scan(void) {
if (changed) memcpy(raw_matrix, curr_matrix, sizeof(curr_matrix));
#ifdef SPLIT_KEYBOARD
- debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed);
- changed = (changed || matrix_post_scan());
+ changed = debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed) | matrix_post_scan();
#else
- debounce(raw_matrix, matrix, ROWS_PER_HAND, changed);
+ changed = debounce(raw_matrix, matrix, ROWS_PER_HAND, changed);
matrix_scan_quantum();
#endif
return (uint8_t)changed;
diff --git a/quantum/matrix_common.c b/quantum/matrix_common.c
index 2cf8484347..f2b9d58937 100644
--- a/quantum/matrix_common.c
+++ b/quantum/matrix_common.c
@@ -122,7 +122,7 @@ bool matrix_post_scan(void) {
}
#endif
-/* `matrix_io_delay ()` exists for backwards compatibility. From now on, use matrix_output_unselect_delay(). */
+/* `matrix_io_delay ()` exists for backwards compatibility. From now on, use matrix_output_unselect_delay(). */
__attribute__((weak)) void matrix_io_delay(void) {
wait_us(MATRIX_IO_DELAY);
}
@@ -169,10 +169,9 @@ __attribute__((weak)) uint8_t matrix_scan(void) {
bool changed = matrix_scan_custom(raw_matrix);
#ifdef SPLIT_KEYBOARD
- debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed);
- changed = (changed || matrix_post_scan());
+ changed = debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed) | matrix_post_scan();
#else
- debounce(raw_matrix, matrix, ROWS_PER_HAND, changed);
+ changed = debounce(raw_matrix, matrix, ROWS_PER_HAND, changed);
matrix_scan_quantum();
#endif
diff --git a/quantum/mousekey.c b/quantum/mousekey.c
index 33d71af083..25a89bdba7 100644
--- a/quantum/mousekey.c
+++ b/quantum/mousekey.c
@@ -66,15 +66,18 @@ uint8_t mk_time_to_max = MOUSEKEY_TIME_TO_MAX;
/* milliseconds between the initial key press and first repeated motion event (0-2550) */
uint8_t mk_wheel_delay = MOUSEKEY_WHEEL_DELAY / 10;
/* milliseconds between repeated motion events (0-255) */
-uint8_t mk_wheel_interval = MOUSEKEY_WHEEL_INTERVAL;
+# ifdef MK_KINETIC_SPEED
+float mk_wheel_interval = 1000.0f / MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
+# else
+uint8_t mk_wheel_interval = MOUSEKEY_WHEEL_INTERVAL;
+# endif
uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;
-bool should_mousekey_report_send(report_mouse_t *mouse_report) {
- return mouse_report->x || mouse_report->y || mouse_report->v || mouse_report->h;
-}
-
# ifndef MK_COMBINED
+# ifndef MK_KINETIC_SPEED
+
+/* Default accelerated mode */
static uint8_t move_unit(void) {
uint16_t unit;
@@ -112,8 +115,7 @@ static uint8_t wheel_unit(void) {
return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
}
-# else /* #ifndef MK_COMBINED */
-# ifdef MK_KINETIC_SPEED
+# else /* #ifndef MK_KINETIC_SPEED */
/*
* Kinetic movement acceleration algorithm
@@ -151,27 +153,27 @@ static uint8_t move_unit(void) {
return speed > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : speed;
}
-float mk_wheel_interval = 1000.0f / MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
-
static uint8_t wheel_unit(void) {
float speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
if (mousekey_accel & ((1 << 0) | (1 << 2))) {
speed = mousekey_accel & (1 << 2) ? MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS : MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS;
- } else if (mousekey_repeat && mouse_timer) {
+ } else if (mousekey_wheel_repeat && mouse_timer) {
if (mk_wheel_interval != MOUSEKEY_WHEEL_BASE_MOVEMENTS) {
const float time_elapsed = timer_elapsed(mouse_timer) / 50;
speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS + 1 * time_elapsed + 1 * 0.5 * time_elapsed * time_elapsed;
}
speed = speed > MOUSEKEY_WHEEL_BASE_MOVEMENTS ? MOUSEKEY_WHEEL_BASE_MOVEMENTS : speed;
}
-
mk_wheel_interval = 1000.0f / speed;
- return 1;
+ return (uint8_t)speed > MOUSEKEY_WHEEL_INITIAL_MOVEMENTS ? 2 : 1;
}
-# else /* #ifndef MK_KINETIC_SPEED */
+# endif /* #ifndef MK_KINETIC_SPEED */
+# else /* #ifndef MK_COMBINED */
+
+/* Combined mode */
static uint8_t move_unit(void) {
uint16_t unit;
@@ -209,8 +211,7 @@ static uint8_t wheel_unit(void) {
return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
}
-# endif /* #ifndef MK_KINETIC_SPEED */
-# endif /* #ifndef MK_COMBINED */
+# endif /* #ifndef MK_COMBINED */
void mousekey_task(void) {
// report cursor and scroll movement independently
@@ -499,3 +500,7 @@ static void mousekey_debug(void) {
report_mouse_t mousekey_get_report(void) {
return mouse_report;
}
+
+bool should_mousekey_report_send(report_mouse_t *mouse_report) {
+ return mouse_report->x || mouse_report->y || mouse_report->v || mouse_report->h;
+}
diff --git a/quantum/mousekey.h b/quantum/mousekey.h
index 03da5f282a..da2edb481a 100644
--- a/quantum/mousekey.h
+++ b/quantum/mousekey.h
@@ -39,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# ifndef MK_KINETIC_SPEED
# define MOUSEKEY_MOVE_DELTA 8
# else
-# define MOUSEKEY_MOVE_DELTA 5
+# define MOUSEKEY_MOVE_DELTA 16
# endif
# endif
# ifndef MOUSEKEY_WHEEL_DELTA
@@ -82,7 +82,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define MOUSEKEY_INITIAL_SPEED 100
# endif
# ifndef MOUSEKEY_BASE_SPEED
-# define MOUSEKEY_BASE_SPEED 1000
+# define MOUSEKEY_BASE_SPEED 5000
# endif
# ifndef MOUSEKEY_DECELERATED_SPEED
# define MOUSEKEY_DECELERATED_SPEED 400
@@ -174,6 +174,7 @@ void mousekey_off(uint8_t code);
void mousekey_clear(void);
void mousekey_send(void);
report_mouse_t mousekey_get_report(void);
+bool should_mousekey_report_send(report_mouse_t *mouse_report);
#ifdef __cplusplus
}
diff --git a/quantum/painter/qp.h b/quantum/painter/qp.h
index e1c14d156c..fb6904de22 100644
--- a/quantum/painter/qp.h
+++ b/quantum/painter/qp.h
@@ -440,10 +440,18 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai
# include "qp_ili9341.h"
#endif // QUANTUM_PAINTER_ILI9341_ENABLE
+#ifdef QUANTUM_PAINTER_ILI9488_ENABLE
+# include "qp_ili9488.h"
+#endif // QUANTUM_PAINTER_ILI9488_ENABLE
+
#ifdef QUANTUM_PAINTER_ST7789_ENABLE
# include "qp_st7789.h"
#endif // QUANTUM_PAINTER_ST7789_ENABLE
+#ifdef QUANTUM_PAINTER_ST7735_ENABLE
+# include "qp_st7735.h"
+#endif // QUANTUM_PAINTER_ST7735_ENABLE
+
#ifdef QUANTUM_PAINTER_GC9A01_ENABLE
# include "qp_gc9a01.h"
#endif // QUANTUM_PAINTER_GC9A01_ENABLE
diff --git a/quantum/painter/qp_draw_core.c b/quantum/painter/qp_draw_core.c
index c31c734132..309ef93dd0 100644
--- a/quantum/painter/qp_draw_core.c
+++ b/quantum/painter/qp_draw_core.c
@@ -20,17 +20,17 @@ _Static_assert((QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE > 0) && (QUANTUM_PAINTER_PIX
//
// Buffer used for transmitting native pixel data to the downstream device.
-uint8_t qp_internal_global_pixdata_buffer[QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE];
+__attribute__((__aligned__(4))) uint8_t qp_internal_global_pixdata_buffer[QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE];
// Static buffer to contain a generated color palette
-static bool generated_palette = false;
-static int16_t generated_steps = -1;
-static qp_pixel_t interpolated_fg_hsv888;
-static qp_pixel_t interpolated_bg_hsv888;
+static bool generated_palette = false;
+static int16_t generated_steps = -1;
+__attribute__((__aligned__(4))) static qp_pixel_t interpolated_fg_hsv888;
+__attribute__((__aligned__(4))) static qp_pixel_t interpolated_bg_hsv888;
#if QUANTUM_PAINTER_SUPPORTS_256_PALETTE
-qp_pixel_t qp_internal_global_pixel_lookup_table[256];
+__attribute__((__aligned__(4))) qp_pixel_t qp_internal_global_pixel_lookup_table[256];
#else
-qp_pixel_t qp_internal_global_pixel_lookup_table[16];
+__attribute__((__aligned__(4))) qp_pixel_t qp_internal_global_pixel_lookup_table[16];
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/quantum/painter/rules.mk b/quantum/painter/rules.mk
index 9115d3d406..91787dfe0e 100644
--- a/quantum/painter/rules.mk
+++ b/quantum/painter/rules.mk
@@ -3,7 +3,7 @@ QUANTUM_PAINTER_DRIVERS ?=
QUANTUM_PAINTER_ANIMATIONS_ENABLE ?= yes
# The list of permissible drivers that can be listed in QUANTUM_PAINTER_DRIVERS
-VALID_QUANTUM_PAINTER_DRIVERS := ili9163_spi ili9341_spi st7789_spi gc9a01_spi ssd1351_spi
+VALID_QUANTUM_PAINTER_DRIVERS := ili9163_spi ili9341_spi ili9488_spi st7789_spi st7735_spi gc9a01_spi ssd1351_spi
#-------------------------------------------------------------------------------
@@ -61,6 +61,17 @@ define handle_quantum_painter_driver
$(DRIVER_PATH)/painter/tft_panel/qp_tft_panel.c \
$(DRIVER_PATH)/painter/ili9xxx/qp_ili9341.c \
+ else ifeq ($$(strip $$(CURRENT_PAINTER_DRIVER)),ili9488_spi)
+ QUANTUM_PAINTER_NEEDS_COMMS_SPI := yes
+ QUANTUM_PAINTER_NEEDS_COMMS_SPI_DC_RESET := yes
+ OPT_DEFS += -DQUANTUM_PAINTER_ILI9488_ENABLE -DQUANTUM_PAINTER_ILI9488_SPI_ENABLE
+ COMMON_VPATH += \
+ $(DRIVER_PATH)/painter/tft_panel \
+ $(DRIVER_PATH)/painter/ili9xxx
+ SRC += \
+ $(DRIVER_PATH)/painter/tft_panel/qp_tft_panel.c \
+ $(DRIVER_PATH)/painter/ili9xxx/qp_ili9488.c \
+
else ifeq ($$(strip $$(CURRENT_PAINTER_DRIVER)),st7789_spi)
QUANTUM_PAINTER_NEEDS_COMMS_SPI := yes
QUANTUM_PAINTER_NEEDS_COMMS_SPI_DC_RESET := yes
@@ -72,6 +83,17 @@ define handle_quantum_painter_driver
$(DRIVER_PATH)/painter/tft_panel/qp_tft_panel.c \
$(DRIVER_PATH)/painter/st77xx/qp_st7789.c
+ else ifeq ($$(strip $$(CURRENT_PAINTER_DRIVER)),st7735_spi)
+ QUANTUM_PAINTER_NEEDS_COMMS_SPI := yes
+ QUANTUM_PAINTER_NEEDS_COMMS_SPI_DC_RESET := yes
+ OPT_DEFS += -DQUANTUM_PAINTER_ST7735_ENABLE -DQUANTUM_PAINTER_ST7735_SPI_ENABLE
+ COMMON_VPATH += \
+ $(DRIVER_PATH)/painter/tft_panel \
+ $(DRIVER_PATH)/painter/st77xx
+ SRC += \
+ $(DRIVER_PATH)/painter/tft_panel/qp_tft_panel.c \
+ $(DRIVER_PATH)/painter/st77xx/qp_st7735.c
+
else ifeq ($$(strip $$(CURRENT_PAINTER_DRIVER)),gc9a01_spi)
QUANTUM_PAINTER_NEEDS_COMMS_SPI := yes
QUANTUM_PAINTER_NEEDS_COMMS_SPI_DC_RESET := yes
diff --git a/quantum/pointing_device.c b/quantum/pointing_device/pointing_device.c
index a160647890..505a7a6ffd 100644
--- a/quantum/pointing_device.c
+++ b/quantum/pointing_device/pointing_device.c
@@ -25,6 +25,13 @@
#if (defined(POINTING_DEVICE_ROTATION_90) + defined(POINTING_DEVICE_ROTATION_180) + defined(POINTING_DEVICE_ROTATION_270)) > 1
# error More than one rotation selected. This is not supported.
#endif
+
+#if defined(POINTING_DEVICE_LEFT) || defined(POINTING_DEVICE_RIGHT) || defined(POINTING_DEVICE_COMBINED)
+# ifndef SPLIT_POINTING_ENABLE
+# error "Using POINTING_DEVICE_LEFT or POINTING_DEVICE_RIGHT or POINTING_DEVICE_COMBINED, then SPLIT_POINTING_ENABLE is required but has not been defined"
+# endif
+#endif
+
#if defined(SPLIT_POINTING_ENABLE)
# include "transactions.h"
# include "keyboard.h"
@@ -132,14 +139,15 @@ __attribute__((weak)) uint8_t pointing_device_handle_buttons(uint8_t buttons, bo
*/
__attribute__((weak)) void pointing_device_init(void) {
#if defined(SPLIT_POINTING_ENABLE)
- if (!(POINTING_DEVICE_THIS_SIDE)) {
- return;
- }
+ if ((POINTING_DEVICE_THIS_SIDE))
#endif
- pointing_device_driver.init();
+ {
+ pointing_device_driver.init();
#ifdef POINTING_DEVICE_MOTION_PIN
- setPinInputHigh(POINTING_DEVICE_MOTION_PIN);
+ setPinInputHigh(POINTING_DEVICE_MOTION_PIN);
#endif
+ }
+
pointing_device_init_kb();
pointing_device_init_user();
}
@@ -177,7 +185,8 @@ __attribute__((weak)) void pointing_device_send(void) {
report_mouse_t pointing_device_adjust_by_defines(report_mouse_t mouse_report) {
// Support rotation of the sensor data
#if defined(POINTING_DEVICE_ROTATION_90) || defined(POINTING_DEVICE_ROTATION_180) || defined(POINTING_DEVICE_ROTATION_270)
- int8_t x = mouse_report.x, y = mouse_report.y;
+ mouse_xy_report_t x = mouse_report.x;
+ mouse_xy_report_t y = mouse_report.y;
# if defined(POINTING_DEVICE_ROTATION_90)
mouse_report.x = y;
mouse_report.y = -x;
@@ -347,7 +356,7 @@ void pointing_device_set_cpi_on_side(bool left, uint16_t cpi) {
* @param[in] int16_t value
* @return int8_t clamped value
*/
-static inline int8_t pointing_device_movement_clamp(int16_t value) {
+static inline int8_t pointing_device_hv_clamp(int16_t value) {
if (value < INT8_MIN) {
return INT8_MIN;
} else if (value > INT8_MAX) {
@@ -358,6 +367,21 @@ static inline int8_t pointing_device_movement_clamp(int16_t value) {
}
/**
+ * @brief clamps int16_t to int8_t
+ *
+ * @param[in] clamp_range_t value
+ * @return mouse_xy_report_t clamped value
+ */
+static inline mouse_xy_report_t pointing_device_xy_clamp(clamp_range_t value) {
+ if (value < XY_REPORT_MIN) {
+ return XY_REPORT_MIN;
+ } else if (value > XY_REPORT_MAX) {
+ return XY_REPORT_MAX;
+ } else {
+ return value;
+ }
+}
+/**
* @brief combines 2 mouse reports and returns 2
*
* Combines 2 report_mouse_t structs, clamping movement values to int8_t and ignores report_id then returns the resulting report_mouse_t struct.
@@ -369,10 +393,10 @@ static inline int8_t pointing_device_movement_clamp(int16_t value) {
* @return combined report_mouse_t of left_report and right_report
*/
report_mouse_t pointing_device_combine_reports(report_mouse_t left_report, report_mouse_t right_report) {
- left_report.x = pointing_device_movement_clamp((int16_t)left_report.x + right_report.x);
- left_report.y = pointing_device_movement_clamp((int16_t)left_report.y + right_report.y);
- left_report.h = pointing_device_movement_clamp((int16_t)left_report.h + right_report.h);
- left_report.v = pointing_device_movement_clamp((int16_t)left_report.v + right_report.v);
+ left_report.x = pointing_device_xy_clamp((clamp_range_t)left_report.x + right_report.x);
+ left_report.y = pointing_device_xy_clamp((clamp_range_t)left_report.y + right_report.y);
+ left_report.h = pointing_device_hv_clamp((int16_t)left_report.h + right_report.h);
+ left_report.v = pointing_device_hv_clamp((int16_t)left_report.v + right_report.v);
left_report.buttons |= right_report.buttons;
return left_report;
}
@@ -389,8 +413,9 @@ report_mouse_t pointing_device_combine_reports(report_mouse_t left_report, repor
*/
report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_report) {
// Support rotation of the sensor data
-# if defined(POINTING_DEVICE_ROTATION_90_RIGHT) || defined(POINTING_DEVICE_ROTATION_RIGHT) || defined(POINTING_DEVICE_ROTATION_RIGHT)
- int8_t x = mouse_report.x, y = mouse_report.y;
+# if defined(POINTING_DEVICE_ROTATION_90_RIGHT) || defined(POINTING_DEVICE_ROTATION_180_RIGHT) || defined(POINTING_DEVICE_ROTATION_270_RIGHT)
+ mouse_xy_report_t x = mouse_report.x;
+ mouse_xy_report_t y = mouse_report.y;
# if defined(POINTING_DEVICE_ROTATION_90_RIGHT)
mouse_report.x = y;
mouse_report.y = -x;
diff --git a/quantum/pointing_device.h b/quantum/pointing_device/pointing_device.h
index 5c0eaeaf34..77db5471ea 100644
--- a/quantum/pointing_device.h
+++ b/quantum/pointing_device/pointing_device.h
@@ -31,6 +31,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "drivers/sensors/analog_joystick.h"
#elif defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_i2c) || defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi)
# include "drivers/sensors/cirque_pinnacle.h"
+# include "drivers/sensors/cirque_pinnacle_gestures.h"
+# include "pointing_device_gestures.h"
+#elif defined(POINTING_DEVICE_DRIVER_paw3204)
+# include "drivers/sensors/paw3204.h"
#elif defined(POINTING_DEVICE_DRIVER_pimoroni_trackball)
# include "i2c_master.h"
# include "drivers/sensors/pimoroni_trackball.h"
@@ -44,12 +48,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# ifdef PIMORONI_TRACKBALL_ROTATE
# define POINTING_DEVICE_ROTATION_90
# endif
-#elif defined(POINTING_DEVICE_DRIVER_pmw3360)
+#elif defined(POINTING_DEVICE_DRIVER_pmw3360) || defined(POINTING_DEVICE_DRIVER_pmw3389)
# include "spi_master.h"
-# include "drivers/sensors/pmw3360.h"
-#elif defined(POINTING_DEVICE_DRIVER_pmw3389)
-# include "spi_master.h"
-# include "drivers/sensors/pmw3389.h"
+# include "drivers/sensors/pmw33xx_common.h"
#else
void pointing_device_driver_init(void);
report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report);
@@ -75,6 +76,16 @@ typedef enum {
POINTING_DEVICE_BUTTON8,
} pointing_device_buttons_t;
+#ifdef MOUSE_EXTENDED_REPORT
+# define XY_REPORT_MIN INT16_MIN
+# define XY_REPORT_MAX INT16_MAX
+typedef int32_t clamp_range_t;
+#else
+# define XY_REPORT_MIN INT8_MIN
+# define XY_REPORT_MAX INT8_MAX
+typedef int16_t clamp_range_t;
+#endif
+
void pointing_device_init(void);
void pointing_device_task(void);
void pointing_device_send(void);
diff --git a/quantum/pointing_device/pointing_device_drivers.c b/quantum/pointing_device/pointing_device_drivers.c
new file mode 100644
index 0000000000..b96f8ff4b3
--- /dev/null
+++ b/quantum/pointing_device/pointing_device_drivers.c
@@ -0,0 +1,368 @@
+/* Copyright 2017 Joshua Broekhuijsen <snipeye+qmk@gmail.com>
+ * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2021 Dasky (@daskygit)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "pointing_device.h"
+#include "debug.h"
+#include "wait.h"
+#include "timer.h"
+#include <stddef.h>
+
+#define CONSTRAIN_HID(amt) ((amt) < INT8_MIN ? INT8_MIN : ((amt) > INT8_MAX ? INT8_MAX : (amt)))
+#define CONSTRAIN_HID_XY(amt) ((amt) < XY_REPORT_MIN ? XY_REPORT_MIN : ((amt) > XY_REPORT_MAX ? XY_REPORT_MAX : (amt)))
+
+// get_report functions should probably be moved to their respective drivers.
+
+#if defined(POINTING_DEVICE_DRIVER_adns5050)
+report_mouse_t adns5050_get_report(report_mouse_t mouse_report) {
+ report_adns5050_t data = adns5050_read_burst();
+
+ if (data.dx != 0 || data.dy != 0) {
+# ifdef CONSOLE_ENABLE
+ if (debug_mouse) dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy);
+# endif
+
+ mouse_report.x = (mouse_xy_report_t)data.dx;
+ mouse_report.y = (mouse_xy_report_t)data.dy;
+ }
+
+ return mouse_report;
+}
+
+// clang-format off
+const pointing_device_driver_t pointing_device_driver = {
+ .init = adns5050_init,
+ .get_report = adns5050_get_report,
+ .set_cpi = adns5050_set_cpi,
+ .get_cpi = adns5050_get_cpi,
+};
+// clang-format on
+
+#elif defined(POINTING_DEVICE_DRIVER_adns9800)
+
+report_mouse_t adns9800_get_report_driver(report_mouse_t mouse_report) {
+ report_adns9800_t sensor_report = adns9800_get_report();
+
+ mouse_report.x = CONSTRAIN_HID_XY(sensor_report.x);
+ mouse_report.y = CONSTRAIN_HID_XY(sensor_report.y);
+
+ return mouse_report;
+}
+
+// clang-format off
+const pointing_device_driver_t pointing_device_driver = {
+ .init = adns9800_init,
+ .get_report = adns9800_get_report_driver,
+ .set_cpi = adns9800_set_cpi,
+ .get_cpi = adns9800_get_cpi
+};
+// clang-format on
+
+#elif defined(POINTING_DEVICE_DRIVER_analog_joystick)
+report_mouse_t analog_joystick_get_report(report_mouse_t mouse_report) {
+ report_analog_joystick_t data = analog_joystick_read();
+
+# ifdef CONSOLE_ENABLE
+ if (debug_mouse) dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y);
+# endif
+
+ mouse_report.x = data.x;
+ mouse_report.y = data.y;
+
+ mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, data.button, POINTING_DEVICE_BUTTON1);
+
+ return mouse_report;
+}
+
+// clang-format off
+const pointing_device_driver_t pointing_device_driver = {
+ .init = analog_joystick_init,
+ .get_report = analog_joystick_get_report,
+ .set_cpi = NULL,
+ .get_cpi = NULL
+};
+// clang-format on
+
+#elif defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_i2c) || defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi)
+# ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
+static bool cursor_glide_enable = true;
+
+static cursor_glide_context_t glide = {.config = {
+ .coef = 102, /* Good default friction coef */
+ .interval = 10, /* 100sps */
+ .trigger_px = 10, /* Default threshold in case of hover, set to 0 if you'd like */
+ }};
+
+void cirque_pinnacle_enable_cursor_glide(bool enable) {
+ cursor_glide_enable = enable;
+}
+
+void cirque_pinnacle_configure_cursor_glide(float trigger_px) {
+ glide.config.trigger_px = trigger_px;
+}
+# endif
+
+# if CIRQUE_PINNACLE_POSITION_MODE
+report_mouse_t cirque_pinnacle_get_report(report_mouse_t mouse_report) {
+ pinnacle_data_t touchData = cirque_pinnacle_read_data();
+ mouse_xy_report_t report_x = 0, report_y = 0;
+ static uint16_t x = 0, y = 0;
+# ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
+ cursor_glide_t glide_report = {0};
+
+ if (cursor_glide_enable) {
+ glide_report = cursor_glide_check(&glide);
+ }
+# endif
+
+ if (!touchData.valid) {
+# ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
+ if (cursor_glide_enable && glide_report.valid) {
+ report_x = glide_report.dx;
+ report_y = glide_report.dy;
+ goto mouse_report_update;
+ }
+# endif
+ return mouse_report;
+ }
+
+# if CONSOLE_ENABLE
+ if (debug_mouse && touchData.touchDown) {
+ dprintf("cirque_pinnacle touchData x=%4d y=%4d z=%2d\n", touchData.xValue, touchData.yValue, touchData.zValue);
+ }
+# endif
+
+ // Scale coordinates to arbitrary X, Y resolution
+ cirque_pinnacle_scale_data(&touchData, cirque_pinnacle_get_scale(), cirque_pinnacle_get_scale());
+
+ if (!cirque_pinnacle_gestures(&mouse_report, touchData)) {
+ if (x && y && touchData.xValue && touchData.yValue) {
+ report_x = CONSTRAIN_HID_XY((int16_t)(touchData.xValue - x));
+ report_y = CONSTRAIN_HID_XY((int16_t)(touchData.yValue - y));
+ }
+ x = touchData.xValue;
+ y = touchData.yValue;
+
+# ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
+ if (cursor_glide_enable) {
+ if (touchData.touchDown) {
+ cursor_glide_update(&glide, report_x, report_y, touchData.zValue);
+ } else if (!glide_report.valid) {
+ glide_report = cursor_glide_start(&glide);
+ if (glide_report.valid) {
+ report_x = glide_report.dx;
+ report_y = glide_report.dy;
+ }
+ }
+ }
+# endif
+ }
+
+# ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
+mouse_report_update:
+# endif
+ mouse_report.x = report_x;
+ mouse_report.y = report_y;
+
+ return mouse_report;
+}
+
+uint16_t cirque_pinnacle_get_cpi(void) {
+ return CIRQUE_PINNACLE_PX_TO_INCH(cirque_pinnacle_get_scale());
+}
+void cirque_pinnacle_set_cpi(uint16_t cpi) {
+ cirque_pinnacle_set_scale(CIRQUE_PINNACLE_INCH_TO_PX(cpi));
+}
+
+// clang-format off
+const pointing_device_driver_t pointing_device_driver = {
+ .init = cirque_pinnacle_init,
+ .get_report = cirque_pinnacle_get_report,
+ .set_cpi = cirque_pinnacle_set_cpi,
+ .get_cpi = cirque_pinnacle_get_cpi
+};
+// clang-format on
+# else
+report_mouse_t cirque_pinnacle_get_report(report_mouse_t mouse_report) {
+ pinnacle_data_t touchData = cirque_pinnacle_read_data();
+
+ // Scale coordinates to arbitrary X, Y resolution
+ cirque_pinnacle_scale_data(&touchData, cirque_pinnacle_get_scale(), cirque_pinnacle_get_scale());
+
+ if (touchData.valid) {
+ mouse_report.buttons = touchData.buttons;
+ mouse_report.x = CONSTRAIN_HID_XY(touchData.xDelta);
+ mouse_report.y = CONSTRAIN_HID_XY(touchData.yDelta);
+ mouse_report.v = touchData.wheelCount;
+ }
+ return mouse_report;
+}
+
+// clang-format off
+const pointing_device_driver_t pointing_device_driver = {
+ .init = cirque_pinnacle_init,
+ .get_report = cirque_pinnacle_get_report,
+ .set_cpi = cirque_pinnacle_set_scale,
+ .get_cpi = cirque_pinnacle_get_scale
+};
+// clang-format on
+# endif
+
+#elif defined(POINTING_DEVICE_DRIVER_paw3204)
+
+report_mouse_t paw3204_get_report(report_mouse_t mouse_report) {
+ report_paw3204_t data = paw3204_read();
+ if (data.isMotion) {
+# ifdef CONSOLE_ENABLE
+ dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y);
+# endif
+
+ mouse_report.x = data.x;
+ mouse_report.y = data.y;
+ }
+
+ return mouse_report;
+}
+const pointing_device_driver_t pointing_device_driver = {
+ .init = paw3204_init,
+ .get_report = paw3204_get_report,
+ .set_cpi = paw3204_set_cpi,
+ .get_cpi = paw3204_get_cpi,
+};
+#elif defined(POINTING_DEVICE_DRIVER_pimoroni_trackball)
+
+mouse_xy_report_t pimoroni_trackball_adapt_values(clamp_range_t* offset) {
+ if (*offset > XY_REPORT_MAX) {
+ *offset -= XY_REPORT_MAX;
+ return (mouse_xy_report_t)XY_REPORT_MAX;
+ } else if (*offset < XY_REPORT_MIN) {
+ *offset += XY_REPORT_MAX;
+ return (mouse_xy_report_t)XY_REPORT_MIN;
+ } else {
+ mouse_xy_report_t temp_return = *offset;
+ *offset = 0;
+ return temp_return;
+ }
+}
+
+report_mouse_t pimoroni_trackball_get_report(report_mouse_t mouse_report) {
+ static uint16_t debounce = 0;
+ static uint8_t error_count = 0;
+ pimoroni_data_t pimoroni_data = {0};
+ static clamp_range_t x_offset = 0, y_offset = 0;
+
+ if (error_count < PIMORONI_TRACKBALL_ERROR_COUNT) {
+ i2c_status_t status = read_pimoroni_trackball(&pimoroni_data);
+
+ if (status == I2C_STATUS_SUCCESS) {
+ error_count = 0;
+
+ if (!(pimoroni_data.click & 128)) {
+ mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, false, POINTING_DEVICE_BUTTON1);
+ if (!debounce) {
+ x_offset += pimoroni_trackball_get_offsets(pimoroni_data.right, pimoroni_data.left, PIMORONI_TRACKBALL_SCALE);
+ y_offset += pimoroni_trackball_get_offsets(pimoroni_data.down, pimoroni_data.up, PIMORONI_TRACKBALL_SCALE);
+ mouse_report.x = pimoroni_trackball_adapt_values(&x_offset);
+ mouse_report.y = pimoroni_trackball_adapt_values(&y_offset);
+ } else {
+ debounce--;
+ }
+ } else {
+ mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, true, POINTING_DEVICE_BUTTON1);
+ debounce = PIMORONI_TRACKBALL_DEBOUNCE_CYCLES;
+ }
+ } else {
+ error_count++;
+ }
+ }
+ return mouse_report;
+}
+
+// clang-format off
+const pointing_device_driver_t pointing_device_driver = {
+ .init = pimoroni_trackball_device_init,
+ .get_report = pimoroni_trackball_get_report,
+ .set_cpi = pimoroni_trackball_set_cpi,
+ .get_cpi = pimoroni_trackball_get_cpi
+};
+// clang-format on
+
+#elif defined(POINTING_DEVICE_DRIVER_pmw3360) || defined(POINTING_DEVICE_DRIVER_pmw3389)
+static void pmw33xx_init_wrapper(void) {
+ pmw33xx_init(0);
+}
+
+static void pmw33xx_set_cpi_wrapper(uint16_t cpi) {
+ pmw33xx_set_cpi(0, cpi);
+}
+
+static uint16_t pmw33xx_get_cpi_wrapper(void) {
+ return pmw33xx_get_cpi(0);
+}
+
+report_mouse_t pmw33xx_get_report(report_mouse_t mouse_report) {
+ pmw33xx_report_t report = pmw33xx_read_burst(0);
+ static bool in_motion = false;
+
+ if (report.motion.b.is_lifted) {
+ return mouse_report;
+ }
+
+ if (!report.motion.b.is_motion) {
+ in_motion = false;
+ return mouse_report;
+ }
+
+ if (!in_motion) {
+ in_motion = true;
+ dprintf("PWM3360 (0): starting motion\n");
+ }
+
+ mouse_report.x = CONSTRAIN_HID_XY(report.delta_x);
+ mouse_report.y = CONSTRAIN_HID_XY(report.delta_y);
+ return mouse_report;
+}
+
+// clang-format off
+const pointing_device_driver_t pointing_device_driver = {
+ .init = pmw33xx_init_wrapper,
+ .get_report = pmw33xx_get_report,
+ .set_cpi = pmw33xx_set_cpi_wrapper,
+ .get_cpi = pmw33xx_get_cpi_wrapper
+};
+// clang-format on
+
+#else
+__attribute__((weak)) void pointing_device_driver_init(void) {}
+__attribute__((weak)) report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) {
+ return mouse_report;
+}
+__attribute__((weak)) uint16_t pointing_device_driver_get_cpi(void) {
+ return 0;
+}
+__attribute__((weak)) void pointing_device_driver_set_cpi(uint16_t cpi) {}
+
+// clang-format off
+const pointing_device_driver_t pointing_device_driver = {
+ .init = pointing_device_driver_init,
+ .get_report = pointing_device_driver_get_report,
+ .get_cpi = pointing_device_driver_get_cpi,
+ .set_cpi = pointing_device_driver_set_cpi
+};
+// clang-format on
+
+#endif
diff --git a/quantum/pointing_device/pointing_device_gestures.c b/quantum/pointing_device/pointing_device_gestures.c
new file mode 100644
index 0000000000..02b11ebe3f
--- /dev/null
+++ b/quantum/pointing_device/pointing_device_gestures.c
@@ -0,0 +1,133 @@
+/* Copyright 2022 Daniel Kao <daniel.m.kao@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <string.h>
+#include "pointing_device_gestures.h"
+#include "timer.h"
+
+#ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
+# ifdef POINTING_DEVICE_MOTION_PIN
+# error POINTING_DEVICE_MOTION_PIN not supported when using inertial cursor. Need repeated calls to get_report() to generate glide events.
+# endif
+
+static void cursor_glide_stop(cursor_glide_context_t* glide) {
+ memset(&glide->status, 0, sizeof(glide->status));
+}
+
+static cursor_glide_t cursor_glide(cursor_glide_context_t* glide) {
+ cursor_glide_status_t* status = &glide->status;
+ cursor_glide_t report;
+ int32_t p;
+ int32_t x, y;
+
+ if (status->v0 == 0) {
+ report.dx = 0;
+ report.dy = 0;
+ report.valid = false;
+ cursor_glide_stop(glide);
+ goto exit;
+ }
+
+ status->counter++;
+ /* Calculate current 1D position */
+ p = status->v0 * status->counter - (int32_t)glide->config.coef * status->counter * status->counter / 2;
+ /*
+ * Translate to x & y axes
+ * Done this way instead of applying friction to each axis separately, so we don't end up with the shorter axis stuck at 0 towards the end of diagonal movements.
+ */
+ x = (int32_t)(p * status->dx0 / status->v0);
+ y = (int32_t)(p * status->dy0 / status->v0);
+ report.dx = (mouse_xy_report_t)(x - status->x);
+ report.dy = (mouse_xy_report_t)(y - status->y);
+ report.valid = true;
+ if (report.dx <= 1 && report.dx >= -1 && report.dy <= 1 && report.dy >= -1) {
+ /* Stop gliding once speed is low enough */
+ cursor_glide_stop(glide);
+ goto exit;
+ }
+ status->x = x;
+ status->y = y;
+ status->timer = timer_read();
+
+exit:
+ return report;
+}
+
+cursor_glide_t cursor_glide_check(cursor_glide_context_t* glide) {
+ cursor_glide_t invalid_report = {0, 0, false};
+ cursor_glide_status_t* status = &glide->status;
+
+ if (status->z || (status->dx0 == 0 && status->dy0 == 0) || timer_elapsed(status->timer) < glide->config.interval) {
+ return invalid_report;
+ } else {
+ return cursor_glide(glide);
+ }
+}
+
+static inline uint16_t sqrt32(uint32_t x) {
+ uint32_t l, m, h;
+
+ if (x == 0) {
+ return 0;
+ } else if (x > (UINT16_MAX >> 2)) {
+ /* Safe upper bound to avoid integer overflow with m * m */
+ h = UINT16_MAX;
+ } else {
+ /* Upper bound based on closest log2 */
+ h = (1 << (((__builtin_clzl(1) - __builtin_clzl(x) + 1) + 1) >> 1));
+ }
+ /* Lower bound based on closest log2 */
+ l = (1 << ((__builtin_clzl(1) - __builtin_clzl(x)) >> 1));
+
+ /* Binary search to find integer square root */
+ while (l != h - 1) {
+ m = (l + h) / 2;
+ if (m * m <= x) {
+ l = m;
+ } else {
+ h = m;
+ }
+ }
+ return l;
+}
+
+cursor_glide_t cursor_glide_start(cursor_glide_context_t* glide) {
+ cursor_glide_t invalid_report = {0, 0, false};
+ cursor_glide_status_t* status = &glide->status;
+
+ status->timer = timer_read();
+ status->counter = 0;
+ status->v0 = (status->dx0 == 0 && status->dy0 == 0) ? 0.0 : sqrt32(((int32_t)status->dx0 * 256 * status->dx0 * 256) + ((int32_t)status->dy0 * 256 * status->dy0 * 256)); // skip trigonometry if not needed, calculate distance in Q8
+ status->x = 0;
+ status->y = 0;
+ status->z = 0;
+
+ if (status->v0 < ((uint32_t)glide->config.trigger_px * 256)) { /* Q8 comparison */
+ /* Not enough velocity to be worth gliding, abort */
+ cursor_glide_stop(glide);
+ return invalid_report;
+ }
+
+ return cursor_glide(glide);
+}
+
+void cursor_glide_update(cursor_glide_context_t* glide, mouse_xy_report_t dx, mouse_xy_report_t dy, uint16_t z) {
+ cursor_glide_status_t* status = &glide->status;
+
+ status->dx0 = dx;
+ status->dy0 = dy;
+ status->z = z;
+}
+#endif
diff --git a/quantum/pointing_device/pointing_device_gestures.h b/quantum/pointing_device/pointing_device_gestures.h
new file mode 100644
index 0000000000..d2ea44971b
--- /dev/null
+++ b/quantum/pointing_device/pointing_device_gestures.h
@@ -0,0 +1,58 @@
+/* Copyright 2022 Daniel Kao <daniel.m.kao@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include <stdint.h>
+#include "report.h"
+
+#ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
+typedef struct {
+ mouse_xy_report_t dx;
+ mouse_xy_report_t dy;
+ bool valid;
+} cursor_glide_t;
+
+typedef struct {
+ uint16_t trigger_px; /* Pixels of movement needed to trigger cursor glide */
+ uint16_t coef; /* Coefficient of friction */
+ uint16_t interval; /* Glide report interval, in milliseconds */
+} cursor_glide_config_t;
+
+typedef struct {
+ int32_t v0;
+ int32_t x;
+ int32_t y;
+ uint16_t z;
+ uint16_t timer;
+ uint16_t counter;
+ mouse_xy_report_t dx0;
+ mouse_xy_report_t dy0;
+} cursor_glide_status_t;
+
+typedef struct {
+ cursor_glide_config_t config;
+ cursor_glide_status_t status;
+} cursor_glide_context_t;
+
+/* Check glide report conditions, calculates glide coordinates */
+cursor_glide_t cursor_glide_check(cursor_glide_context_t* glide);
+
+/* Start glide reporting, gives first set of glide coordinates */
+cursor_glide_t cursor_glide_start(cursor_glide_context_t* glide);
+
+/* Update glide engine on the latest cursor movement, cursor glide is based on the final movement */
+void cursor_glide_update(cursor_glide_context_t* glide, mouse_xy_report_t dx, mouse_xy_report_t dy, uint16_t z);
+#endif
diff --git a/quantum/pointing_device_drivers.c b/quantum/pointing_device_drivers.c
deleted file mode 100644
index 56363c7ac6..0000000000
--- a/quantum/pointing_device_drivers.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/* Copyright 2017 Joshua Broekhuijsen <snipeye+qmk@gmail.com>
- * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
- * Copyright 2021 Dasky (@daskygit)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "pointing_device.h"
-#include "debug.h"
-#include "wait.h"
-#include "timer.h"
-#include <stddef.h>
-
-// hid mouse reports cannot exceed -127 to 127, so constrain to that value
-#define constrain_hid(amt) ((amt) < -127 ? -127 : ((amt) > 127 ? 127 : (amt)))
-
-// get_report functions should probably be moved to their respective drivers.
-#if defined(POINTING_DEVICE_DRIVER_adns5050)
-report_mouse_t adns5050_get_report(report_mouse_t mouse_report) {
- report_adns5050_t data = adns5050_read_burst();
-
- if (data.dx != 0 || data.dy != 0) {
-# ifdef CONSOLE_ENABLE
- if (debug_mouse) dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy);
-# endif
-
- mouse_report.x = data.dx;
- mouse_report.y = data.dy;
- }
-
- return mouse_report;
-}
-
-// clang-format off
-const pointing_device_driver_t pointing_device_driver = {
- .init = adns5050_init,
- .get_report = adns5050_get_report,
- .set_cpi = adns5050_set_cpi,
- .get_cpi = adns5050_get_cpi,
-};
-// clang-format on
-#elif defined(POINTING_DEVICE_DRIVER_adns9800)
-
-report_mouse_t adns9800_get_report_driver(report_mouse_t mouse_report) {
- report_adns9800_t sensor_report = adns9800_get_report();
-
- int8_t clamped_x = constrain_hid(sensor_report.x);
- int8_t clamped_y = constrain_hid(sensor_report.y);
-
- mouse_report.x = clamped_x;
- mouse_report.y = clamped_y;
-
- return mouse_report;
-}
-
-// clang-format off
-const pointing_device_driver_t pointing_device_driver = {
- .init = adns9800_init,
- .get_report = adns9800_get_report_driver,
- .set_cpi = adns9800_set_cpi,
- .get_cpi = adns9800_get_cpi
-};
-// clang-format on
-#elif defined(POINTING_DEVICE_DRIVER_analog_joystick)
-report_mouse_t analog_joystick_get_report(report_mouse_t mouse_report) {
- report_analog_joystick_t data = analog_joystick_read();
-
-# ifdef CONSOLE_ENABLE
- if (debug_mouse) dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y);
-# endif
-
- mouse_report.x = data.x;
- mouse_report.y = data.y;
-
- mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, data.button, POINTING_DEVICE_BUTTON1);
-
- return mouse_report;
-}
-
-// clang-format off
-const pointing_device_driver_t pointing_device_driver = {
- .init = analog_joystick_init,
- .get_report = analog_joystick_get_report,
- .set_cpi = NULL,
- .get_cpi = NULL
-};
-// clang-format on
-#elif defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_i2c) || defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi)
-# ifndef CIRQUE_PINNACLE_TAPPING_TERM
-# include "action.h"
-# include "action_tapping.h"
-# define CIRQUE_PINNACLE_TAPPING_TERM GET_TAPPING_TERM(KC_BTN1, &(keyrecord_t){})
-# endif
-# ifndef CIRQUE_PINNACLE_TOUCH_DEBOUNCE
-# define CIRQUE_PINNACLE_TOUCH_DEBOUNCE (CIRQUE_PINNACLE_TAPPING_TERM * 8)
-# endif
-
-report_mouse_t cirque_pinnacle_get_report(report_mouse_t mouse_report) {
- pinnacle_data_t touchData = cirque_pinnacle_read_data();
- static uint16_t x = 0, y = 0, mouse_timer = 0;
- int8_t report_x = 0, report_y = 0;
- static bool is_z_down = false;
-
- cirque_pinnacle_scale_data(&touchData, cirque_pinnacle_get_scale(), cirque_pinnacle_get_scale()); // Scale coordinates to arbitrary X, Y resolution
-
- if (x && y && touchData.xValue && touchData.yValue) {
- report_x = (int8_t)(touchData.xValue - x);
- report_y = (int8_t)(touchData.yValue - y);
- }
- x = touchData.xValue;
- y = touchData.yValue;
-
- if ((bool)touchData.zValue != is_z_down) {
- is_z_down = (bool)touchData.zValue;
- if (!touchData.zValue) {
- if (timer_elapsed(mouse_timer) < CIRQUE_PINNACLE_TAPPING_TERM && mouse_timer != 0) {
- mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, true, POINTING_DEVICE_BUTTON1);
- pointing_device_set_report(mouse_report);
- pointing_device_send();
-# if TAP_CODE_DELAY > 0
- wait_ms(TAP_CODE_DELAY);
-# endif
- mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, false, POINTING_DEVICE_BUTTON1);
- pointing_device_set_report(mouse_report);
- pointing_device_send();
- }
- }
- mouse_timer = timer_read();
- }
- if (timer_elapsed(mouse_timer) > (CIRQUE_PINNACLE_TOUCH_DEBOUNCE)) {
- mouse_timer = 0;
- }
- mouse_report.x = report_x;
- mouse_report.y = report_y;
-
- return mouse_report;
-}
-
-// clang-format off
-const pointing_device_driver_t pointing_device_driver = {
- .init = cirque_pinnacle_init,
- .get_report = cirque_pinnacle_get_report,
- .set_cpi = cirque_pinnacle_set_scale,
- .get_cpi = cirque_pinnacle_get_scale
-};
-// clang-format on
-
-#elif defined(POINTING_DEVICE_DRIVER_pimoroni_trackball)
-report_mouse_t pimoroni_trackball_get_report(report_mouse_t mouse_report) {
- static uint16_t debounce = 0;
- static uint8_t error_count = 0;
- pimoroni_data_t pimoroni_data = {0};
- static int16_t x_offset = 0, y_offset = 0;
-
- if (error_count < PIMORONI_TRACKBALL_ERROR_COUNT) {
- i2c_status_t status = read_pimoroni_trackball(&pimoroni_data);
-
- if (status == I2C_STATUS_SUCCESS) {
- error_count = 0;
-
- if (!(pimoroni_data.click & 128)) {
- mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, false, POINTING_DEVICE_BUTTON1);
- if (!debounce) {
- x_offset += pimoroni_trackball_get_offsets(pimoroni_data.right, pimoroni_data.left, PIMORONI_TRACKBALL_SCALE);
- y_offset += pimoroni_trackball_get_offsets(pimoroni_data.down, pimoroni_data.up, PIMORONI_TRACKBALL_SCALE);
- pimoroni_trackball_adapt_values(&mouse_report.x, &x_offset);
- pimoroni_trackball_adapt_values(&mouse_report.y, &y_offset);
- } else {
- debounce--;
- }
- } else {
- mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, true, POINTING_DEVICE_BUTTON1);
- debounce = PIMORONI_TRACKBALL_DEBOUNCE_CYCLES;
- }
- } else {
- error_count++;
- }
- }
- return mouse_report;
-}
-
-// clang-format off
-const pointing_device_driver_t pointing_device_driver = {
- .init = pimoroni_trackball_device_init,
- .get_report = pimoroni_trackball_get_report,
- .set_cpi = pimoroni_trackball_set_cpi,
- .get_cpi = pimoroni_trackball_get_cpi
-};
-// clang-format on
-#elif defined(POINTING_DEVICE_DRIVER_pmw3360)
-static void pmw3360_device_init(void) {
- pmw3360_init(0);
-}
-
-report_mouse_t pmw3360_get_report(report_mouse_t mouse_report) {
- report_pmw3360_t data = pmw3360_read_burst(0);
- static uint16_t MotionStart = 0; // Timer for accel, 0 is resting state
-
- if (data.isOnSurface && data.isMotion) {
- // Reset timer if stopped moving
- if (!data.isMotion) {
- if (MotionStart != 0) MotionStart = 0;
- return mouse_report;
- }
-
- // Set timer if new motion
- if ((MotionStart == 0) && data.isMotion) {
-# ifdef CONSOLE_ENABLE
- if (debug_mouse) dprintf("Starting motion.\n");
-# endif
- MotionStart = timer_read();
- }
- mouse_report.x = constrain_hid(data.dx);
- mouse_report.y = constrain_hid(data.dy);
- }
-
- return mouse_report;
-}
-
-// clang-format off
-const pointing_device_driver_t pointing_device_driver = {
- .init = pmw3360_device_init,
- .get_report = pmw3360_get_report,
- .set_cpi = pmw3360_set_cpi,
- .get_cpi = pmw3360_get_cpi
-};
-// clang-format on
-#elif defined(POINTING_DEVICE_DRIVER_pmw3389)
-static void pmw3389_device_init(void) {
- pmw3389_init();
-}
-
-report_mouse_t pmw3389_get_report(report_mouse_t mouse_report) {
- report_pmw3389_t data = pmw3389_read_burst();
- static uint16_t MotionStart = 0; // Timer for accel, 0 is resting state
-
- if (data.isOnSurface && data.isMotion) {
- // Reset timer if stopped moving
- if (!data.isMotion) {
- if (MotionStart != 0) MotionStart = 0;
- return mouse_report;
- }
-
- // Set timer if new motion
- if ((MotionStart == 0) && data.isMotion) {
-# ifdef CONSOLE_ENABLE
- if (debug_mouse) dprintf("Starting motion.\n");
-# endif
- MotionStart = timer_read();
- }
- mouse_report.x = constrain_hid(data.dx);
- mouse_report.y = constrain_hid(data.dy);
- }
-
- return mouse_report;
-}
-
-// clang-format off
-const pointing_device_driver_t pointing_device_driver = {
- .init = pmw3389_device_init,
- .get_report = pmw3389_get_report,
- .set_cpi = pmw3389_set_cpi,
- .get_cpi = pmw3389_get_cpi
-};
-// clang-format on
-#else
-__attribute__((weak)) void pointing_device_driver_init(void) {}
-__attribute__((weak)) report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) {
- return mouse_report;
-}
-__attribute__((weak)) uint16_t pointing_device_driver_get_cpi(void) {
- return 0;
-}
-__attribute__((weak)) void pointing_device_driver_set_cpi(uint16_t cpi) {}
-
-// clang-format off
-const pointing_device_driver_t pointing_device_driver = {
- .init = pointing_device_driver_init,
- .get_report = pointing_device_driver_get_report,
- .get_cpi = pointing_device_driver_get_cpi,
- .set_cpi = pointing_device_driver_set_cpi
-};
-// clang-format on
-#endif
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c
index e568c93e79..c990595597 100644
--- a/quantum/process_keycode/process_auto_shift.c
+++ b/quantum/process_keycode/process_auto_shift.c
@@ -126,7 +126,7 @@ static void autoshift_flush_shift(void) {
autoshift_flags.holding_shift = false;
# ifdef CAPS_WORD_ENABLE
if (!is_caps_word_on())
-# endif
+# endif // CAPS_WORD_ENABLE
{
del_weak_mods(MOD_BIT(KC_LSFT));
}
@@ -331,11 +331,13 @@ void autoshift_disable(void) {
# ifndef AUTO_SHIFT_NO_SETUP
void autoshift_timer_report(void) {
+# ifdef SEND_STRING_ENABLE
char display[8];
snprintf(display, 8, "\n%d\n", autoshift_timeout);
send_string((const char *)display);
+# endif
}
# endif
diff --git a/quantum/process_keycode/process_auto_shift.h b/quantum/process_keycode/process_auto_shift.h
index 3df4048678..86adb04985 100644
--- a/quantum/process_keycode/process_auto_shift.h
+++ b/quantum/process_keycode/process_auto_shift.h
@@ -29,16 +29,10 @@
// clang-format off
#define AUTO_SHIFT_ALPHA KC_A ... KC_Z
#define AUTO_SHIFT_NUMERIC KC_1 ... KC_0
-#ifdef NO_AUTO_SHIFT_TAB
-#define AUTO_SHIFT_SPECIAL \
- KC_MINUS ... KC_SLASH: \
- case KC_NONUS_BSLASH
-#else
#define AUTO_SHIFT_SPECIAL \
KC_TAB: \
case KC_MINUS ... KC_SLASH: \
- case KC_NONUS_BSLASH
-#endif
+ case KC_NONUS_BACKSLASH
// clang-format on
bool process_auto_shift(uint16_t keycode, keyrecord_t *record);
diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c
index 4eeb6eb722..fb33ffebb7 100644
--- a/quantum/process_keycode/process_caps_word.c
+++ b/quantum/process_keycode/process_caps_word.c
@@ -101,14 +101,34 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
return true;
#ifndef NO_ACTION_TAPPING
+ // Corresponding to mod keys above, a held mod-tap is handled as:
+ // * For shift mods, pass KC_LSFT or KC_RSFT to
+ // caps_word_press_user() to determine whether to continue.
+ // * For Shift + AltGr (MOD_RSFT | MOD_RALT), pass RSFT(KC_RALT).
+ // * AltGr (MOD_RALT) is ignored.
+ // * Otherwise stop Caps Word.
case QK_MOD_TAP ... QK_MOD_TAP_MAX:
- if (record->tap.count == 0) {
- // Deactivate if a mod becomes active through holding
- // a mod-tap key.
- caps_word_off();
- return true;
+ if (record->tap.count == 0) { // Mod-tap key is held.
+ const uint8_t mods = (keycode >> 8) & 0x1f;
+ switch (mods) {
+ case MOD_LSFT:
+ keycode = KC_LSFT;
+ break;
+ case MOD_RSFT:
+ keycode = KC_RSFT;
+ break;
+ case MOD_RSFT | MOD_RALT:
+ keycode = RSFT(KC_RALT);
+ break;
+ case MOD_RALT:
+ return true;
+ default:
+ caps_word_off();
+ return true;
+ }
+ } else {
+ keycode &= 0xff;
}
- keycode &= 0xff;
break;
# ifndef NO_ACTION_LAYER
@@ -135,7 +155,7 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
del_weak_mods(get_autoshift_state() ? ~MOD_BIT(KC_LSFT) : 0xff);
#else
clear_weak_mods();
-#endif
+#endif // AUTO_SHIFT_ENABLE
if (caps_word_press_user(keycode)) {
send_keyboard_report();
return true;
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index d5a649adb3..e5135e5a64 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -227,7 +227,16 @@ static inline void dump_key_buffer(void) {
#endif
}
record->event.time = 0;
+
+#if defined(CAPS_WORD_ENABLE) && defined(AUTO_SHIFT_ENABLE)
+ // Edge case: preserve the weak Left Shift mod if both Caps Word and
+ // Auto Shift are on. Caps Word capitalizes by setting the weak Left
+ // Shift mod during the press event, but Auto Shift doesn't send the
+ // key until it receives the release event.
+ del_weak_mods((is_caps_word_on() && get_autoshift_state()) ? ~MOD_BIT(KC_LSFT) : 0xff);
+#else
clear_weak_mods();
+#endif // defined(CAPS_WORD_ENABLE) && defined(AUTO_SHIFT_ENABLE)
#if TAP_CODE_DELAY > 0
// only delay once and for a non-tapping key
diff --git a/quantum/process_keycode/process_dynamic_macro.c b/quantum/process_keycode/process_dynamic_macro.c
index a1ada2d5a2..a7555fdd40 100644
--- a/quantum/process_keycode/process_dynamic_macro.c
+++ b/quantum/process_keycode/process_dynamic_macro.c
@@ -86,6 +86,9 @@ void dynamic_macro_play(keyrecord_t *macro_buffer, keyrecord_t *macro_end, int8_
while (macro_buffer != macro_end) {
process_record(macro_buffer);
macro_buffer += direction;
+#ifdef DYNAMIC_MACRO_DELAY
+ wait_ms(DYNAMIC_MACRO_DELAY);
+#endif
}
clear_keyboard();
diff --git a/quantum/process_keycode/process_dynamic_tapping_term.c b/quantum/process_keycode/process_dynamic_tapping_term.c
index bdc5529e33..b682f34da6 100644
--- a/quantum/process_keycode/process_dynamic_tapping_term.c
+++ b/quantum/process_keycode/process_dynamic_tapping_term.c
@@ -22,12 +22,14 @@
#endif
static void tapping_term_report(void) {
+#ifdef SEND_STRING_ENABLE
const char *tapping_term_str = get_u16_str(g_tapping_term, ' ');
// Skip padding spaces
while (*tapping_term_str == ' ') {
tapping_term_str++;
}
send_string(tapping_term_str);
+#endif
}
bool process_dynamic_tapping_term(uint16_t keycode, keyrecord_t *record) {
diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c
index 8c3e71616f..e867606074 100644
--- a/quantum/process_keycode/process_joystick.c
+++ b/quantum/process_keycode/process_joystick.c
@@ -106,7 +106,7 @@ bool process_joystick_analogread_quantum() {
wait_us(10);
-# if defined(__AVR__) || defined(PROTOCOL_CHIBIOS)
+# if defined(ANALOG_JOYSTICK_ENABLE) && (defined(__AVR__) || defined(PROTOCOL_CHIBIOS))
int16_t axis_val = analogReadPin(joystick_axes[axis_index].input_pin);
# else
// default to resting position
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c
index c2fd02e5c7..ae00b3227a 100644
--- a/quantum/process_keycode/process_leader.c
+++ b/quantum/process_keycode/process_leader.c
@@ -64,6 +64,7 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) {
} else {
leading = false;
leader_end();
+ return true;
}
# ifdef LEADER_PER_KEY_TIMING
leader_time = timer_read();
diff --git a/quantum/process_keycode/process_magic.c b/quantum/process_keycode/process_magic.c
index 10161adda3..ae60f29bf5 100644
--- a/quantum/process_keycode/process_magic.c
+++ b/quantum/process_keycode/process_magic.c
@@ -45,12 +45,16 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT:
case MAGIC_TOGGLE_GUI:
case MAGIC_TOGGLE_CONTROL_CAPSLOCK:
+ case MAGIC_SWAP_ESCAPE_CAPSLOCK ... MAGIC_TOGGLE_ESCAPE_CAPSLOCK:
/* keymap config */
keymap_config.raw = eeconfig_read_keymap();
switch (keycode) {
case MAGIC_SWAP_CONTROL_CAPSLOCK:
keymap_config.swap_control_capslock = true;
break;
+ case MAGIC_SWAP_ESCAPE_CAPSLOCK:
+ keymap_config.swap_escape_capslock = true;
+ break;
case MAGIC_CAPSLOCK_TO_CONTROL:
keymap_config.capslock_to_control = true;
break;
@@ -94,6 +98,9 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
case MAGIC_UNSWAP_CONTROL_CAPSLOCK:
keymap_config.swap_control_capslock = false;
break;
+ case MAGIC_UNSWAP_ESCAPE_CAPSLOCK:
+ keymap_config.swap_escape_capslock = false;
+ break;
case MAGIC_UNCAPSLOCK_TO_CONTROL:
keymap_config.capslock_to_control = false;
break;
@@ -172,6 +179,9 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
case MAGIC_TOGGLE_CONTROL_CAPSLOCK:
keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock;
break;
+ case MAGIC_TOGGLE_ESCAPE_CAPSLOCK:
+ keymap_config.swap_escape_capslock = !keymap_config.swap_escape_capslock;
+ break;
}
eeconfig_update_keymap(keymap_config.raw);
diff --git a/quantum/process_keycode/process_rgb.c b/quantum/process_keycode/process_rgb.c
index c805bd615d..dae129786e 100644
--- a/quantum/process_keycode/process_rgb.c
+++ b/quantum/process_keycode/process_rgb.c
@@ -52,7 +52,11 @@ static void __attribute__((noinline, unused)) handleKeycodeRGBMode(const uint8_t
*/
bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
// need to trigger on key-up for edge-case issue
+#ifndef RGB_TRIGGER_ON_KEYDOWN
if (!record->event.pressed) {
+#else
+ if (record->event.pressed) {
+#endif
#if (defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)) || (defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES))
uint8_t shifted = get_mods() & MOD_MASK_SHIFT;
#endif
diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c
index 12ee898212..30a0d4056f 100644
--- a/quantum/process_keycode/process_steno.c
+++ b/quantum/process_keycode/process_steno.c
@@ -1,4 +1,4 @@
-/* Copyright 2017 Joseph Wasson
+/* Copyright 2017, 2022 Joseph Wasson, Vladislav Kucheriavykh
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -15,77 +15,118 @@
*/
#include "process_steno.h"
#include "quantum_keycodes.h"
-#include "eeprom.h"
#include "keymap_steno.h"
-#include "virtser.h"
#include <string.h>
+#ifdef VIRTSER_ENABLE
+# include "virtser.h"
+#endif
+#ifdef STENO_ENABLE_ALL
+# include "eeprom.h"
+#endif
-// TxBolt Codes
-#define TXB_NUL 0
-#define TXB_S_L 0b00000001
-#define TXB_T_L 0b00000010
-#define TXB_K_L 0b00000100
-#define TXB_P_L 0b00001000
-#define TXB_W_L 0b00010000
-#define TXB_H_L 0b00100000
-#define TXB_R_L 0b01000001
-#define TXB_A_L 0b01000010
-#define TXB_O_L 0b01000100
-#define TXB_STR 0b01001000
-#define TXB_E_R 0b01010000
-#define TXB_U_R 0b01100000
-#define TXB_F_R 0b10000001
-#define TXB_R_R 0b10000010
-#define TXB_P_R 0b10000100
-#define TXB_B_R 0b10001000
-#define TXB_L_R 0b10010000
-#define TXB_G_R 0b10100000
-#define TXB_T_R 0b11000001
-#define TXB_S_R 0b11000010
-#define TXB_D_R 0b11000100
-#define TXB_Z_R 0b11001000
-#define TXB_NUM 0b11010000
-
-#define TXB_GRP0 0b00000000
-#define TXB_GRP1 0b01000000
-#define TXB_GRP2 0b10000000
-#define TXB_GRP3 0b11000000
-#define TXB_GRPMASK 0b11000000
-
-#define TXB_GET_GROUP(code) ((code & TXB_GRPMASK) >> 6)
-
-#define BOLT_STATE_SIZE 4
-#define GEMINI_STATE_SIZE 6
-#define MAX_STATE_SIZE GEMINI_STATE_SIZE
-
-static uint8_t state[MAX_STATE_SIZE] = {0};
-static uint8_t chord[MAX_STATE_SIZE] = {0};
-static int8_t pressed = 0;
+// All steno keys that have been pressed to form this chord,
+// stored in MAX_STROKE_SIZE groups of 8-bit arrays.
+static uint8_t chord[MAX_STROKE_SIZE] = {0};
+// The number of physical keys actually being held down.
+// This is not always equal to the number of 1 bits in `chord` because it is possible to
+// simultaneously press down four keys, then release three of those four keys and then press yet
+// another key while the fourth finger is still holding down its key.
+// At the end of this scenario given as an example, `chord` would have five bits set to 1 but
+// `n_pressed_keys` would be set to 2 because there are only two keys currently being pressed down.
+static int8_t n_pressed_keys = 0;
+
+#ifdef STENO_ENABLE_ALL
static steno_mode_t mode;
-
-static const uint8_t boltmap[64] PROGMEM = {TXB_NUL, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_S_L, TXB_S_L, TXB_T_L, TXB_K_L, TXB_P_L, TXB_W_L, TXB_H_L, TXB_R_L, TXB_A_L, TXB_O_L, TXB_STR, TXB_STR, TXB_NUL, TXB_NUL, TXB_NUL, TXB_STR, TXB_STR, TXB_E_R, TXB_U_R, TXB_F_R, TXB_R_R, TXB_P_R, TXB_B_R, TXB_L_R, TXB_G_R, TXB_T_R, TXB_S_R, TXB_D_R, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_Z_R};
-
-#ifdef STENO_COMBINEDMAP
-/* Used to look up when pressing the middle row key to combine two consonant or vowel keys */
-static const uint16_t combinedmap_first[] PROGMEM = {STN_S1, STN_TL, STN_PL, STN_HL, STN_FR, STN_PR, STN_LR, STN_TR, STN_DR, STN_A, STN_E};
-static const uint16_t combinedmap_second[] PROGMEM = {STN_S2, STN_KL, STN_WL, STN_RL, STN_RR, STN_BR, STN_GR, STN_SR, STN_ZR, STN_O, STN_U};
+#elif defined(STENO_ENABLE_GEMINI)
+static const steno_mode_t mode = STENO_MODE_GEMINI;
+#elif defined(STENO_ENABLE_BOLT)
+static const steno_mode_t mode = STENO_MODE_BOLT;
#endif
-static void steno_clear_state(void) {
- memset(state, 0, sizeof(state));
+static inline void steno_clear_chord(void) {
memset(chord, 0, sizeof(chord));
}
-static void send_steno_state(uint8_t size, bool send_empty) {
- for (uint8_t i = 0; i < size; ++i) {
- if (chord[i] || send_empty) {
-#ifdef VIRTSER_ENABLE
+#ifdef STENO_ENABLE_GEMINI
+
+# ifdef VIRTSER_ENABLE
+void send_steno_chord_gemini(void) {
+ // Set MSB to 1 to indicate the start of packet
+ chord[0] |= 0x80;
+ for (uint8_t i = 0; i < GEMINI_STROKE_SIZE; ++i) {
+ virtser_send(chord[i]);
+ }
+}
+# else
+# pragma message "VIRTSER_ENABLE = yes is required for Gemini PR to work properly out of the box!"
+# endif // VIRTSER_ENABLE
+
+/**
+ * @precondition: `key` is pressed
+ */
+bool add_gemini_key_to_chord(uint8_t key) {
+ // Although each group of the packet is 8 bits long, the MSB is reserved
+ // to indicate whether that byte is the first byte of the packet (MSB=1)
+ // or one of the remaining five bytes of the packet (MSB=0).
+ // As a consequence, only 7 out of the 8 bits are left to be used as a bit array
+ // for the steno keys of that group.
+ const int group_idx = key / 7;
+ const int intra_group_idx = key - group_idx * 7;
+ // The 0th steno key of the group has bit=0b01000000, the 1st has bit=0b00100000, etc.
+ const uint8_t bit = 1 << (6 - intra_group_idx);
+ chord[group_idx] |= bit;
+ return false;
+}
+#endif // STENO_ENABLE_GEMINI
+
+#ifdef STENO_ENABLE_BOLT
+
+# define TXB_GRP0 0b00000000
+# define TXB_GRP1 0b01000000
+# define TXB_GRP2 0b10000000
+# define TXB_GRP3 0b11000000
+# define TXB_GRPMASK 0b11000000
+
+# define TXB_GET_GROUP(code) ((code & TXB_GRPMASK) >> 6)
+
+static const uint8_t boltmap[64] PROGMEM = {TXB_NUL, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_S_L, TXB_S_L, TXB_T_L, TXB_K_L, TXB_P_L, TXB_W_L, TXB_H_L, TXB_R_L, TXB_A_L, TXB_O_L, TXB_STR, TXB_STR, TXB_NUL, TXB_NUL, TXB_NUL, TXB_STR, TXB_STR, TXB_E_R, TXB_U_R, TXB_F_R, TXB_R_R, TXB_P_R, TXB_B_R, TXB_L_R, TXB_G_R, TXB_T_R, TXB_S_R, TXB_D_R, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_Z_R};
+
+# ifdef VIRTSER_ENABLE
+static void send_steno_chord_bolt(void) {
+ for (uint8_t i = 0; i < BOLT_STROKE_SIZE; ++i) {
+ // TX Bolt uses variable length packets where each byte corresponds to a bit array of certain keys.
+ // If a user chorded the keys of the first group with keys of the last group, for example, there
+ // would be bytes of 0x00 in `chord` for the middle groups which we mustn't send.
+ if (chord[i]) {
virtser_send(chord[i]);
-#endif
}
}
+ // Sending a null packet is not always necessary, but it is simpler and more reliable
+ // to unconditionally send it every time instead of keeping track of more states and
+ // creating more branches in the execution of the program.
+ virtser_send(0);
}
+# else
+# pragma message "VIRTSER_ENABLE = yes is required for TX Bolt to work properly out of the box!"
+# endif // VIRTSER_ENABLE
+
+/**
+ * @precondition: `key` is pressed
+ */
+static bool add_bolt_key_to_chord(uint8_t key) {
+ uint8_t boltcode = pgm_read_byte(boltmap + key);
+ chord[TXB_GET_GROUP(boltcode)] |= boltcode;
+ return false;
+}
+#endif // STENO_ENABLE_BOLT
+
+#ifdef STENO_COMBINEDMAP
+/* Used to look up when pressing the middle row key to combine two consonant or vowel keys */
+static const uint16_t combinedmap_first[] PROGMEM = {STN_S1, STN_TL, STN_PL, STN_HL, STN_FR, STN_PR, STN_LR, STN_TR, STN_DR, STN_A, STN_E};
+static const uint16_t combinedmap_second[] PROGMEM = {STN_S2, STN_KL, STN_WL, STN_RL, STN_RR, STN_BR, STN_GR, STN_SR, STN_ZR, STN_O, STN_U};
+#endif
+#ifdef STENO_ENABLE_ALL
void steno_init() {
if (!eeconfig_is_enabled()) {
eeconfig_init();
@@ -94,19 +135,20 @@ void steno_init() {
}
void steno_set_mode(steno_mode_t new_mode) {
- steno_clear_state();
+ steno_clear_chord();
mode = new_mode;
eeprom_update_byte(EECONFIG_STENOMODE, mode);
}
+#endif // STENO_ENABLE_ALL
/* override to intercept chords right before they get sent.
* return zero to suppress normal sending behavior.
*/
-__attribute__((weak)) bool send_steno_chord_user(steno_mode_t mode, uint8_t chord[6]) {
+__attribute__((weak)) bool send_steno_chord_user(steno_mode_t mode, uint8_t chord[MAX_STROKE_SIZE]) {
return true;
}
-__attribute__((weak)) bool postprocess_steno_user(uint16_t keycode, keyrecord_t *record, steno_mode_t mode, uint8_t chord[6], int8_t pressed) {
+__attribute__((weak)) bool post_process_steno_user(uint16_t keycode, keyrecord_t *record, steno_mode_t mode, uint8_t chord[MAX_STROKE_SIZE], int8_t n_pressed_keys) {
return true;
}
@@ -114,108 +156,94 @@ __attribute__((weak)) bool process_steno_user(uint16_t keycode, keyrecord_t *rec
return true;
}
-static void send_steno_chord(void) {
- if (send_steno_chord_user(mode, chord)) {
- switch (mode) {
- case STENO_MODE_BOLT:
- send_steno_state(BOLT_STATE_SIZE, false);
-#ifdef VIRTSER_ENABLE
- virtser_send(0); // terminating byte
-#endif
- break;
- case STENO_MODE_GEMINI:
- chord[0] |= 0x80; // Indicate start of packet
- send_steno_state(GEMINI_STATE_SIZE, true);
- break;
- }
+bool process_steno(uint16_t keycode, keyrecord_t *record) {
+ if (keycode < QK_STENO || keycode > QK_STENO_MAX) {
+ return true; // Not a steno key, pass it further along the chain
+ /*
+ * Clearing or sending the chord state is not necessary as we intentionally ignore whatever
+ * normal keyboard keys the user may have tapped while chording steno keys.
+ */
}
- steno_clear_state();
-}
-
-uint8_t *steno_get_state(void) {
- return &state[0];
-}
-
-uint8_t *steno_get_chord(void) {
- return &chord[0];
-}
-
-static bool update_state_bolt(uint8_t key, bool press) {
- uint8_t boltcode = pgm_read_byte(boltmap + key);
- if (press) {
- state[TXB_GET_GROUP(boltcode)] |= boltcode;
- chord[TXB_GET_GROUP(boltcode)] |= boltcode;
- } else {
- state[TXB_GET_GROUP(boltcode)] &= ~boltcode;
+ if (IS_NOEVENT(record->event)) {
+ return true;
}
- return false;
-}
-
-static bool update_state_gemini(uint8_t key, bool press) {
- int idx = key / 7;
- uint8_t bit = 1 << (6 - (key % 7));
- if (press) {
- state[idx] |= bit;
- chord[idx] |= bit;
- } else {
- state[idx] &= ~bit;
+ if (!process_steno_user(keycode, record)) {
+ return false; // User fully processed the steno key themselves
}
- return false;
-}
-
-bool process_steno(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
+#ifdef STENO_ENABLE_ALL
case QK_STENO_BOLT:
- if (!process_steno_user(keycode, record)) {
- return false;
- }
if (IS_PRESSED(record->event)) {
steno_set_mode(STENO_MODE_BOLT);
}
return false;
case QK_STENO_GEMINI:
- if (!process_steno_user(keycode, record)) {
- return false;
- }
if (IS_PRESSED(record->event)) {
steno_set_mode(STENO_MODE_GEMINI);
}
return false;
+#endif // STENO_ENABLE_ALL
#ifdef STENO_COMBINEDMAP
case QK_STENO_COMB ... QK_STENO_COMB_MAX: {
- uint8_t result;
- result = process_steno(combinedmap_first[keycode - QK_STENO_COMB], record);
- result &= process_steno(combinedmap_second[keycode - QK_STENO_COMB], record);
- return result;
+ bool first_result = process_steno(combinedmap_first[keycode - QK_STENO_COMB], record);
+ bool second_result = process_steno(combinedmap_second[keycode - QK_STENO_COMB], record);
+ return first_result && second_result;
}
-#endif
+#endif // STENO_COMBINEDMAP
case STN__MIN ... STN__MAX:
- if (!process_steno_user(keycode, record)) {
- return false;
- }
- switch (mode) {
- case STENO_MODE_BOLT:
- update_state_bolt(keycode - QK_STENO, IS_PRESSED(record->event));
- break;
- case STENO_MODE_GEMINI:
- update_state_gemini(keycode - QK_STENO, IS_PRESSED(record->event));
- break;
- }
- // allow postprocessing hooks
- if (postprocess_steno_user(keycode, record, mode, chord, pressed)) {
- if (IS_PRESSED(record->event)) {
- ++pressed;
- } else {
- --pressed;
- if (pressed <= 0) {
- pressed = 0;
- send_steno_chord();
- }
+ if (IS_PRESSED(record->event)) {
+ n_pressed_keys++;
+ switch (mode) {
+#ifdef STENO_ENABLE_BOLT
+ case STENO_MODE_BOLT:
+ add_bolt_key_to_chord(keycode - QK_STENO);
+ break;
+#endif // STENO_ENABLE_BOLT
+#ifdef STENO_ENABLE_GEMINI
+ case STENO_MODE_GEMINI:
+ add_gemini_key_to_chord(keycode - QK_STENO);
+ break;
+#endif // STENO_ENABLE_GEMINI
+ default:
+ return false;
}
+ if (!post_process_steno_user(keycode, record, mode, chord, n_pressed_keys)) {
+ return false;
+ }
+ } else { // is released
+ n_pressed_keys--;
+ if (!post_process_steno_user(keycode, record, mode, chord, n_pressed_keys)) {
+ return false;
+ }
+ if (n_pressed_keys > 0) {
+ // User hasn't released all keys yet,
+ // so the chord cannot be sent
+ return false;
+ }
+ n_pressed_keys = 0;
+ if (!send_steno_chord_user(mode, chord)) {
+ steno_clear_chord();
+ return false;
+ }
+ switch (mode) {
+#if defined(STENO_ENABLE_BOLT) && defined(VIRTSER_ENABLE)
+ case STENO_MODE_BOLT:
+ send_steno_chord_bolt();
+ break;
+#endif // STENO_ENABLE_BOLT && VIRTSER_ENABLE
+#if defined(STENO_ENABLE_GEMINI) && defined(VIRTSER_ENABLE)
+ case STENO_MODE_GEMINI:
+ send_steno_chord_gemini();
+ break;
+#endif // STENO_ENABLE_GEMINI && VIRTSER_ENABLE
+ default:
+ break;
+ }
+ steno_clear_chord();
}
- return false;
+ break;
}
- return true;
+ return false;
}
diff --git a/quantum/process_keycode/process_steno.h b/quantum/process_keycode/process_steno.h
index d11fd40af0..68d6097b9b 100644
--- a/quantum/process_keycode/process_steno.h
+++ b/quantum/process_keycode/process_steno.h
@@ -18,10 +18,22 @@
#include "quantum.h"
-typedef enum { STENO_MODE_BOLT, STENO_MODE_GEMINI } steno_mode_t;
+#define BOLT_STROKE_SIZE 4
+#define GEMINI_STROKE_SIZE 6
-bool process_steno(uint16_t keycode, keyrecord_t *record);
-void steno_init(void);
-void steno_set_mode(steno_mode_t mode);
-uint8_t *steno_get_state(void);
-uint8_t *steno_get_chord(void);
+#ifdef STENO_ENABLE_GEMINI
+# define MAX_STROKE_SIZE GEMINI_STROKE_SIZE
+#else
+# define MAX_STROKE_SIZE BOLT_STROKE_SIZE
+#endif
+
+typedef enum {
+ STENO_MODE_GEMINI,
+ STENO_MODE_BOLT,
+} steno_mode_t;
+
+bool process_steno(uint16_t keycode, keyrecord_t *record);
+#ifdef STENO_ENABLE_ALL
+void steno_init(void);
+void steno_set_mode(steno_mode_t mode);
+#endif // STENO_ENABLE_ALL
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c
index db8df5f870..3270a1b000 100644
--- a/quantum/process_keycode/process_tap_dance.c
+++ b/quantum/process_keycode/process_tap_dance.c
@@ -15,12 +15,8 @@
*/
#include "quantum.h"
-#ifndef NO_ACTION_ONESHOT
-uint8_t get_oneshot_mods(void);
-#endif
-
-static uint16_t last_td;
-static int16_t highest_td = -1;
+static uint16_t active_td;
+static uint16_t last_tap_time;
void qk_tap_dance_pair_on_each_tap(qk_tap_dance_state_t *state, void *user_data) {
qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
@@ -34,18 +30,14 @@ void qk_tap_dance_pair_on_each_tap(qk_tap_dance_state_t *state, void *user_data)
void qk_tap_dance_pair_finished(qk_tap_dance_state_t *state, void *user_data) {
qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
- if (state->count == 1) {
- register_code16(pair->kc1);
- } else if (state->count == 2) {
- register_code16(pair->kc2);
- }
+ register_code16(pair->kc1);
}
void qk_tap_dance_pair_reset(qk_tap_dance_state_t *state, void *user_data) {
qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
- wait_ms(TAP_CODE_DELAY);
if (state->count == 1) {
+ wait_ms(TAP_CODE_DELAY);
unregister_code16(pair->kc1);
} else if (state->count == 2) {
unregister_code16(pair->kc2);
@@ -87,23 +79,40 @@ static inline void _process_tap_dance_action_fn(qk_tap_dance_state_t *state, voi
}
static inline void process_tap_dance_action_on_each_tap(qk_tap_dance_action_t *action) {
+ action->state.count++;
+ action->state.weak_mods = get_mods();
+ action->state.weak_mods |= get_weak_mods();
+#ifndef NO_ACTION_ONESHOT
+ action->state.oneshot_mods = get_oneshot_mods();
+#endif
_process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_each_tap);
}
-static inline void process_tap_dance_action_on_dance_finished(qk_tap_dance_action_t *action) {
- if (action->state.finished) return;
- action->state.finished = true;
- add_mods(action->state.oneshot_mods);
- add_weak_mods(action->state.weak_mods);
- send_keyboard_report();
- _process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_dance_finished);
-}
-
static inline void process_tap_dance_action_on_reset(qk_tap_dance_action_t *action) {
_process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_reset);
- del_mods(action->state.oneshot_mods);
del_weak_mods(action->state.weak_mods);
+#ifndef NO_ACTION_ONESHOT
+ del_mods(action->state.oneshot_mods);
+#endif
send_keyboard_report();
+ action->state = (const qk_tap_dance_state_t){0};
+}
+
+static inline void process_tap_dance_action_on_dance_finished(qk_tap_dance_action_t *action) {
+ if (!action->state.finished) {
+ action->state.finished = true;
+ add_weak_mods(action->state.weak_mods);
+#ifndef NO_ACTION_ONESHOT
+ add_mods(action->state.oneshot_mods);
+#endif
+ send_keyboard_report();
+ _process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_dance_finished);
+ }
+ active_td = 0;
+ if (!action->state.pressed) {
+ // There will not be a key release event, so reset now.
+ process_tap_dance_action_on_reset(action);
+ }
}
void preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
@@ -111,51 +120,33 @@ void preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
if (!record->event.pressed) return;
- if (highest_td == -1) return;
-
- for (int i = 0; i <= highest_td; i++) {
- action = &tap_dance_actions[i];
- if (action->state.count) {
- if (keycode == action->state.keycode && keycode == last_td) continue;
- action->state.interrupted = true;
- action->state.interrupting_keycode = keycode;
- process_tap_dance_action_on_dance_finished(action);
- reset_tap_dance(&action->state);
-
- // Tap dance actions can leave some weak mods active (e.g., if the tap dance is mapped to a keycode with
- // modifiers), but these weak mods should not affect the keypress which interrupted the tap dance.
- clear_weak_mods();
- }
- }
+ if (!active_td || keycode == active_td) return;
+
+ action = &tap_dance_actions[TD_INDEX(active_td)];
+ action->state.interrupted = true;
+ action->state.interrupting_keycode = keycode;
+ process_tap_dance_action_on_dance_finished(action);
+
+ // Tap dance actions can leave some weak mods active (e.g., if the tap dance is mapped to a keycode with
+ // modifiers), but these weak mods should not affect the keypress which interrupted the tap dance.
+ clear_weak_mods();
}
bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
- uint16_t idx = keycode - QK_TAP_DANCE;
qk_tap_dance_action_t *action;
switch (keycode) {
case QK_TAP_DANCE ... QK_TAP_DANCE_MAX:
- if ((int16_t)idx > highest_td) highest_td = idx;
- action = &tap_dance_actions[idx];
+ action = &tap_dance_actions[TD_INDEX(keycode)];
action->state.pressed = record->event.pressed;
if (record->event.pressed) {
- action->state.keycode = keycode;
- action->state.count++;
- action->state.timer = timer_read();
-#ifndef NO_ACTION_ONESHOT
- action->state.oneshot_mods = get_oneshot_mods();
-#else
- action->state.oneshot_mods = 0;
-#endif
- action->state.weak_mods = get_mods();
- action->state.weak_mods |= get_weak_mods();
+ last_tap_time = timer_read();
process_tap_dance_action_on_each_tap(action);
-
- last_td = keycode;
+ active_td = action->state.finished ? 0 : keycode;
} else {
- if (action->state.count && action->state.finished) {
- reset_tap_dance(&action->state);
+ if (action->state.finished) {
+ process_tap_dance_action_on_reset(action);
}
}
@@ -166,35 +157,17 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
}
void tap_dance_task() {
- if (highest_td == -1) return;
- uint16_t tap_user_defined;
-
- for (uint8_t i = 0; i <= highest_td; i++) {
- qk_tap_dance_action_t *action = &tap_dance_actions[i];
- if (action->custom_tapping_term > 0) {
- tap_user_defined = action->custom_tapping_term;
- } else {
- tap_user_defined = GET_TAPPING_TERM(action->state.keycode, &(keyrecord_t){});
- }
- if (action->state.count && timer_elapsed(action->state.timer) > tap_user_defined) {
- process_tap_dance_action_on_dance_finished(action);
- reset_tap_dance(&action->state);
- }
- }
-}
-
-void reset_tap_dance(qk_tap_dance_state_t *state) {
qk_tap_dance_action_t *action;
- if (state->pressed) return;
+ if (!active_td || timer_elapsed(last_tap_time) <= GET_TAPPING_TERM(active_td, &(keyrecord_t){})) return;
- action = &tap_dance_actions[state->keycode - QK_TAP_DANCE];
-
- process_tap_dance_action_on_reset(action);
+ action = &tap_dance_actions[TD_INDEX(active_td)];
+ if (!action->state.interrupted) {
+ process_tap_dance_action_on_dance_finished(action);
+ }
+}
- state->count = 0;
- state->interrupted = false;
- state->finished = false;
- state->interrupting_keycode = 0;
- last_td = 0;
+void reset_tap_dance(qk_tap_dance_state_t *state) {
+ active_td = 0;
+ process_tap_dance_action_on_reset((qk_tap_dance_action_t *)state);
}
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
index d9ffb1e73d..d97900d96b 100644
--- a/quantum/process_keycode/process_tap_dance.h
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -22,30 +22,27 @@
# include <inttypes.h>
typedef struct {
+ uint16_t interrupting_keycode;
uint8_t count;
- uint8_t oneshot_mods;
uint8_t weak_mods;
- uint16_t keycode;
- uint16_t interrupting_keycode;
- uint16_t timer;
- bool interrupted;
- bool pressed;
- bool finished;
+# ifndef NO_ACTION_ONESHOT
+ uint8_t oneshot_mods;
+# endif
+ bool pressed : 1;
+ bool finished : 1;
+ bool interrupted : 1;
} qk_tap_dance_state_t;
-# define TD(n) (QK_TAP_DANCE | ((n)&0xFF))
-
typedef void (*qk_tap_dance_user_fn_t)(qk_tap_dance_state_t *state, void *user_data);
typedef struct {
+ qk_tap_dance_state_t state;
struct {
qk_tap_dance_user_fn_t on_each_tap;
qk_tap_dance_user_fn_t on_dance_finished;
qk_tap_dance_user_fn_t on_reset;
} fn;
- qk_tap_dance_state_t state;
- uint16_t custom_tapping_term;
- void * user_data;
+ void *user_data;
} qk_tap_dance_action_t;
typedef struct {
@@ -62,31 +59,31 @@ typedef struct {
# define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) \
{ .fn = {qk_tap_dance_pair_on_each_tap, qk_tap_dance_pair_finished, qk_tap_dance_pair_reset}, .user_data = (void *)&((qk_tap_dance_pair_t){kc1, kc2}), }
-# define ACTION_TAP_DANCE_DUAL_ROLE(kc, layer) \
+# define ACTION_TAP_DANCE_LAYER_MOVE(kc, layer) \
{ .fn = {qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_move}), }
# define ACTION_TAP_DANCE_LAYER_TOGGLE(kc, layer) \
{ .fn = {NULL, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_invert}), }
-# define ACTION_TAP_DANCE_LAYER_MOVE(kc, layer) ACTION_TAP_DANCE_DUAL_ROLE(kc, layer)
-
# define ACTION_TAP_DANCE_FN(user_fn) \
{ .fn = {NULL, user_fn, NULL}, .user_data = NULL, }
# define ACTION_TAP_DANCE_FN_ADVANCED(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset) \
{ .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset}, .user_data = NULL, }
-# define ACTION_TAP_DANCE_FN_ADVANCED_TIME(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, tap_specific_tapping_term) \
- { .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset}, .user_data = NULL, .custom_tapping_term = tap_specific_tapping_term, }
+# define TD(n) (QK_TAP_DANCE | TD_INDEX(n))
+# define TD_INDEX(code) ((code)&0xFF)
+# define TAP_DANCE_KEYCODE(state) TD(((qk_tap_dance_action_t *)state) - tap_dance_actions)
extern qk_tap_dance_action_t tap_dance_actions[];
+void reset_tap_dance(qk_tap_dance_state_t *state);
+
/* To be used internally */
void preprocess_tap_dance(uint16_t keycode, keyrecord_t *record);
bool process_tap_dance(uint16_t keycode, keyrecord_t *record);
void tap_dance_task(void);
-void reset_tap_dance(qk_tap_dance_state_t *state);
void qk_tap_dance_pair_on_each_tap(qk_tap_dance_state_t *state, void *user_data);
void qk_tap_dance_pair_finished(qk_tap_dance_state_t *state, void *user_data);
diff --git a/quantum/process_keycode/process_terminal.c b/quantum/process_keycode/process_terminal.c
deleted file mode 100644
index da1c4d506f..0000000000
--- a/quantum/process_keycode/process_terminal.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/* Copyright 2017 Jack Humbert
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "process_terminal.h"
-#include <string.h>
-#include "version.h"
-#include <stdio.h>
-#include <math.h>
-
-#ifndef CMD_BUFF_SIZE
-# define CMD_BUFF_SIZE 5
-#endif
-
-bool terminal_enabled = false;
-char buffer[80] = "";
-char cmd_buffer[CMD_BUFF_SIZE][80];
-bool cmd_buffer_enabled = true; // replace with ifdef?
-char newline[2] = "\n";
-char arguments[6][20];
-bool firstTime = true;
-
-short int current_cmd_buffer_pos = 0; // used for up/down arrows - keeps track of where you are in the command buffer
-
-__attribute__((weak)) const char terminal_prompt[8] = "> ";
-
-#ifdef AUDIO_ENABLE
-# ifndef TERMINAL_SONG
-# define TERMINAL_SONG SONG(TERMINAL_SOUND)
-# endif
-float terminal_song[][2] = TERMINAL_SONG;
-# define TERMINAL_BELL() PLAY_SONG(terminal_song)
-#else
-# define TERMINAL_BELL()
-#endif
-
-__attribute__((weak)) const char keycode_to_ascii_lut[58] = {0, 0, 0, 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 0, 0, 0, '\t', ' ', '-', '=', '[', ']', '\\', 0, ';', '\'', '`', ',', '.', '/'};
-
-__attribute__((weak)) const char shifted_keycode_to_ascii_lut[58] = {0, 0, 0, 0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', 0, 0, 0, '\t', ' ', '_', '+', '{', '}', '|', 0, ':', '\'', '~', '<', '>', '?'};
-
-struct stringcase {
- char *string;
- void (*func)(void);
-} typedef stringcase;
-
-void enable_terminal(void) {
- terminal_enabled = true;
- strcpy(buffer, "");
- memset(cmd_buffer, 0, CMD_BUFF_SIZE * 80);
- for (int i = 0; i < 6; i++)
- strcpy(arguments[i], "");
- // select all text to start over
- // SEND_STRING(SS_LCTL("a"));
- send_string(terminal_prompt);
-}
-
-void disable_terminal(void) {
- terminal_enabled = false;
- SEND_STRING("\n");
-}
-
-void push_to_cmd_buffer(void) {
- if (cmd_buffer_enabled) {
- if (cmd_buffer == NULL) {
- return;
- } else {
- if (firstTime) {
- firstTime = false;
- strcpy(cmd_buffer[0], buffer);
- return;
- }
-
- for (int i = CMD_BUFF_SIZE - 1; i > 0; --i) {
- strncpy(cmd_buffer[i], cmd_buffer[i - 1], 80);
- }
-
- strcpy(cmd_buffer[0], buffer);
-
- return;
- }
- }
-}
-
-void terminal_about(void) {
- SEND_STRING("QMK Firmware\n");
- SEND_STRING(" v");
- SEND_STRING(QMK_VERSION);
- SEND_STRING("\n" SS_TAP(X_HOME) " Built: ");
- SEND_STRING(QMK_BUILDDATE);
- send_string(newline);
-#ifdef TERMINAL_HELP
- if (strlen(arguments[1]) != 0) {
- SEND_STRING("You entered: ");
- send_string(arguments[1]);
- send_string(newline);
- }
-#endif
-}
-
-void terminal_help(void);
-
-extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
-
-void terminal_keycode(void) {
- if (strlen(arguments[1]) != 0 && strlen(arguments[2]) != 0 && strlen(arguments[3]) != 0) {
- char keycode_dec[5];
- char keycode_hex[5];
- uint16_t layer = strtol(arguments[1], (char **)NULL, 10);
- uint16_t row = strtol(arguments[2], (char **)NULL, 10);
- uint16_t col = strtol(arguments[3], (char **)NULL, 10);
- uint16_t keycode = pgm_read_word(&keymaps[layer][row][col]);
- itoa(keycode, keycode_dec, 10);
- itoa(keycode, keycode_hex, 16);
- SEND_STRING("0x");
- send_string(keycode_hex);
- SEND_STRING(" (");
- send_string(keycode_dec);
- SEND_STRING(")\n");
- } else {
-#ifdef TERMINAL_HELP
- SEND_STRING("usage: keycode <layer> <row> <col>\n");
-#endif
- }
-}
-
-void terminal_keymap(void) {
- if (strlen(arguments[1]) != 0) {
- uint16_t layer = strtol(arguments[1], (char **)NULL, 10);
- for (int r = 0; r < MATRIX_ROWS; r++) {
- for (int c = 0; c < MATRIX_COLS; c++) {
- uint16_t keycode = pgm_read_word(&keymaps[layer][r][c]);
- char keycode_s[8];
- sprintf(keycode_s, "0x%04x,", keycode);
- send_string(keycode_s);
- }
- send_string(newline);
- }
- } else {
-#ifdef TERMINAL_HELP
- SEND_STRING("usage: keymap <layer>\n");
-#endif
- }
-}
-
-void print_cmd_buff(void) {
- /* without the below wait, a race condition can occur wherein the
- buffer can be printed before it has been fully moved */
- wait_ms(250);
- for (int i = 0; i < CMD_BUFF_SIZE; i++) {
- char tmpChar = ' ';
- itoa(i, &tmpChar, 10);
- const char *tmpCnstCharStr = &tmpChar; // because sned_string wont take a normal char *
- send_string(tmpCnstCharStr);
- SEND_STRING(". ");
- send_string(cmd_buffer[i]);
- SEND_STRING("\n");
- }
-}
-
-void flush_cmd_buffer(void) {
- memset(cmd_buffer, 0, CMD_BUFF_SIZE * 80);
- SEND_STRING("Buffer Cleared!\n");
-}
-
-stringcase terminal_cases[] = {{"about", terminal_about}, {"help", terminal_help}, {"keycode", terminal_keycode}, {"keymap", terminal_keymap}, {"flush-buffer", flush_cmd_buffer}, {"print-buffer", print_cmd_buff}, {"exit", disable_terminal}};
-
-void terminal_help(void) {
- SEND_STRING("commands available:\n ");
- for (stringcase *case_p = terminal_cases; case_p != terminal_cases + sizeof(terminal_cases) / sizeof(terminal_cases[0]); case_p++) {
- send_string(case_p->string);
- SEND_STRING(" ");
- }
- send_string(newline);
-}
-
-void command_not_found(void) {
- wait_ms(50); // sometimes buffer isnt grabbed quick enough
- SEND_STRING("command \"");
- send_string(buffer);
- SEND_STRING("\" not found\n");
-}
-
-void process_terminal_command(void) {
- // we capture return bc of the order of events, so we need to manually send a newline
- send_string(newline);
-
- char * pch;
- uint8_t i = 0;
- pch = strtok(buffer, " ");
- while (pch != NULL) {
- strcpy(arguments[i], pch);
- pch = strtok(NULL, " ");
- i++;
- }
-
- bool command_found = false;
- for (stringcase *case_p = terminal_cases; case_p != terminal_cases + sizeof(terminal_cases) / sizeof(terminal_cases[0]); case_p++) {
- if (0 == strcmp(case_p->string, buffer)) {
- command_found = true;
- (*case_p->func)();
- break;
- }
- }
-
- if (!command_found) command_not_found();
-
- if (terminal_enabled) {
- strcpy(buffer, "");
- for (int i = 0; i < 6; i++)
- strcpy(arguments[i], "");
- SEND_STRING(SS_TAP(X_HOME));
- send_string(terminal_prompt);
- }
-}
-void check_pos(void) {
- if (current_cmd_buffer_pos >= CMD_BUFF_SIZE) { // if over the top, move it back down to the top of the buffer so you can climb back down...
- current_cmd_buffer_pos = CMD_BUFF_SIZE - 1;
- } else if (current_cmd_buffer_pos < 0) { //...and if you fall under the bottom of the buffer, reset back to 0 so you can climb back up
- current_cmd_buffer_pos = 0;
- }
-}
-
-bool process_terminal(uint16_t keycode, keyrecord_t *record) {
- if (keycode == TERM_ON && record->event.pressed) {
- enable_terminal();
- return false;
- }
-
- if (terminal_enabled && record->event.pressed) {
- if (keycode == TERM_OFF && record->event.pressed) {
- disable_terminal();
- return false;
- }
-
- if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
- keycode = keycode & 0xFF;
- }
-
- if (keycode < 256) {
- uint8_t str_len;
- char char_to_add;
- switch (keycode) {
- case KC_ENTER:
- case KC_KP_ENTER:
- push_to_cmd_buffer();
- current_cmd_buffer_pos = 0;
- process_terminal_command();
- return false;
- break;
- case KC_ESCAPE:
- SEND_STRING("\n");
- enable_terminal();
- return false;
- break;
- case KC_BACKSPACE:
- str_len = strlen(buffer);
- if (str_len > 0) {
- buffer[str_len - 1] = 0;
- return true;
- } else {
- TERMINAL_BELL();
- return false;
- }
- break;
- case KC_LEFT:
- return false;
- break;
- case KC_RIGHT:
- return false;
- break;
- case KC_UP: // 0 = recent
- check_pos(); // check our current buffer position is valid
- if (current_cmd_buffer_pos <= CMD_BUFF_SIZE - 1) { // once we get to the top, dont do anything
- str_len = strlen(buffer);
- for (int i = 0; i < str_len; ++i) {
- send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already
- // process_terminal(KC_BACKSPACE,record);
- }
- strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 80);
-
- send_string(buffer);
- ++current_cmd_buffer_pos; // get ready to access the above cmd if up/down is pressed again
- }
- return false;
- break;
- case KC_DOWN:
- check_pos();
- if (current_cmd_buffer_pos >= 0) { // once we get to the bottom, dont do anything
- str_len = strlen(buffer);
- for (int i = 0; i < str_len; ++i) {
- send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already
- // process_terminal(KC_BACKSPACE,record);
- }
- strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 79);
-
- send_string(buffer);
- --current_cmd_buffer_pos; // get ready to access the above cmd if down/up is pressed again
- }
- return false;
- break;
- default:
- if (keycode <= 58) {
- char_to_add = 0;
- if (get_mods() & (MOD_BIT(KC_LEFT_SHIFT) | MOD_BIT(KC_RIGHT_SHIFT))) {
- char_to_add = shifted_keycode_to_ascii_lut[keycode];
- } else if (get_mods() == 0) {
- char_to_add = keycode_to_ascii_lut[keycode];
- }
- if (char_to_add != 0) {
- strncat(buffer, &char_to_add, 1);
- }
- }
- break;
- }
- }
- }
- return true;
-}
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
index 6cb2ba8dbb..8de31c055c 100644
--- a/quantum/process_keycode/process_unicode_common.c
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -117,6 +117,12 @@ __attribute__((weak)) void unicode_input_start(void) {
tap_code(UNICODE_KEY_WINC);
tap_code(KC_U);
break;
+ case UC_EMACS:
+ // The usual way to type unicode in emacs is C-x-8 <RET> then the unicode number in hex
+ tap_code16(LCTL(KC_X));
+ tap_code16(KC_8);
+ tap_code16(KC_ENTER);
+ break;
}
wait_ms(UNICODE_TYPE_DELAY);
@@ -142,6 +148,9 @@ __attribute__((weak)) void unicode_input_finish(void) {
case UC_WINC:
tap_code(KC_ENTER);
break;
+ case UC_EMACS:
+ tap_code16(KC_ENTER);
+ break;
}
set_mods(unicode_saved_mods); // Reregister previously set mods
@@ -167,6 +176,9 @@ __attribute__((weak)) void unicode_input_cancel(void) {
tap_code(KC_NUM_LOCK);
}
break;
+ case UC_EMACS:
+ tap_code16(LCTL(KC_G)); // C-g cancels
+ break;
}
set_mods(unicode_saved_mods); // Reregister previously set mods
@@ -299,14 +311,30 @@ bool process_unicode_common(uint16_t keycode, keyrecord_t *record) {
cycle_unicode_input_mode(shifted ? +1 : -1);
audio_helper();
break;
-
- case UNICODE_MODE_MAC ... UNICODE_MODE_WINC: {
- // Keycodes and input modes follow the same ordering
- uint8_t delta = keycode - UNICODE_MODE_MAC;
- set_unicode_input_mode(UC_MAC + delta);
+ case UNICODE_MODE_MAC:
+ set_unicode_input_mode(UC_MAC);
+ audio_helper();
+ break;
+ case UNICODE_MODE_LNX:
+ set_unicode_input_mode(UC_LNX);
+ audio_helper();
+ break;
+ case UNICODE_MODE_WIN:
+ set_unicode_input_mode(UC_WIN);
+ audio_helper();
+ break;
+ case UNICODE_MODE_BSD:
+ set_unicode_input_mode(UC_BSD);
+ audio_helper();
+ break;
+ case UNICODE_MODE_WINC:
+ set_unicode_input_mode(UC_WINC);
+ audio_helper();
+ break;
+ case UNICODE_MODE_EMACS:
+ set_unicode_input_mode(UC_EMACS);
audio_helper();
break;
- }
}
}
diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h
index 8a4494c939..15e798dbb3 100644
--- a/quantum/process_keycode/process_unicode_common.h
+++ b/quantum/process_keycode/process_unicode_common.h
@@ -64,6 +64,7 @@ enum unicode_input_modes {
UC_WIN, // Windows using EnableHexNumpad
UC_BSD, // BSD (not implemented)
UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose)
+ UC_EMACS, // Emacs is an operating system in search of a good text editor
UC__COUNT // Number of available input modes (always leave at the end)
};
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 62f3cb275b..4a0cf31592 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -94,16 +94,27 @@ __attribute__((weak)) void unregister_code16(uint16_t code) {
}
}
-__attribute__((weak)) void tap_code16(uint16_t code) {
+/** \brief Tap a keycode with a delay.
+ *
+ * \param code The modded keycode to tap.
+ * \param delay The amount of time in milliseconds to leave the keycode registered, before unregistering it.
+ */
+__attribute__((weak)) void tap_code16_delay(uint16_t code, uint16_t delay) {
register_code16(code);
- if (code == KC_CAPS_LOCK) {
- wait_ms(TAP_HOLD_CAPS_DELAY);
- } else if (TAP_CODE_DELAY > 0) {
- wait_ms(TAP_CODE_DELAY);
+ for (uint16_t i = delay; i > 0; i--) {
+ wait_ms(1);
}
unregister_code16(code);
}
+/** \brief Tap a keycode with the default delay.
+ *
+ * \param code The modded keycode to tap. If `code` is `KC_CAPS_LOCK`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined.
+ */
+__attribute__((weak)) void tap_code16(uint16_t code) {
+ tap_code16_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY);
+}
+
__attribute__((weak)) bool process_action_kb(keyrecord_t *record) {
return true;
}
@@ -311,9 +322,6 @@ bool process_record_quantum(keyrecord_t *record) {
#ifdef DYNAMIC_TAPPING_TERM_ENABLE
process_dynamic_tapping_term(keycode, record) &&
#endif
-#ifdef TERMINAL_ENABLE
- process_terminal(keycode, record) &&
-#endif
#ifdef SPACE_CADET_ENABLE
process_space_cadet(keycode, record) &&
#endif
@@ -407,6 +415,9 @@ bool process_record_quantum(keyrecord_t *record) {
SEND_STRING_DELAY(" compile ", TAP_CODE_DELAY);
}
SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP SS_TAP(X_ENTER), TAP_CODE_DELAY);
+ if (temp_mod & MOD_MASK_SHIFT && temp_mod & MOD_MASK_CTRL) {
+ reset_keyboard();
+ }
}
#endif
}
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 52c535589e..91134c1128 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -49,7 +49,6 @@
#include "action_util.h"
#include "action_tapping.h"
#include "print.h"
-#include "send_string.h"
#include "suspend.h"
#include <stddef.h>
#include <stdlib.h>
@@ -141,12 +140,6 @@ extern layer_state_t layer_state;
# include "process_key_lock.h"
#endif
-#ifdef TERMINAL_ENABLE
-# include "process_terminal.h"
-#else
-# include "process_terminal_nop.h"
-#endif
-
#ifdef SPACE_CADET_ENABLE
# include "process_space_cadet.h"
#endif
@@ -175,6 +168,10 @@ extern layer_state_t layer_state;
# include "hd44780.h"
#endif
+#ifdef SEND_STRING_ENABLE
+# include "send_string.h"
+#endif
+
#ifdef HAPTIC_ENABLE
# include "haptic.h"
# include "process_haptic.h"
@@ -277,6 +274,7 @@ void shutdown_user(void);
void register_code16(uint16_t code);
void unregister_code16(uint16_t code);
void tap_code16(uint16_t code);
+void tap_code16_delay(uint16_t code, uint16_t delay);
bool webusb_receive_kb(uint8_t *data, uint8_t length);
bool webusb_receive_user(uint8_t *data, uint8_t length);
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index a27d51d382..a08e5277a3 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -475,9 +475,9 @@ enum quantum_keycodes {
// Lock Key
KC_LOCK, // 5D2B
- // Terminal
- TERM_ON, // 5D2C
- TERM_OFF, // 5D2D
+ // Unused slots
+ UNUSED_000, // 5D2C
+ UNUSED_001, // 5D2D
// Sequencer
SQ_ON, // 5D2E
@@ -607,6 +607,12 @@ enum quantum_keycodes {
CAPS_WORD,
+ MAGIC_SWAP_ESCAPE_CAPSLOCK,
+ MAGIC_UNSWAP_ESCAPE_CAPSLOCK,
+ MAGIC_TOGGLE_ESCAPE_CAPSLOCK,
+
+ UNICODE_MODE_EMACS,
+
// Start of custom keycode range for keyboards and keymaps - always leave at the end
SAFE_RANGE
};
@@ -758,6 +764,10 @@ enum quantum_keycodes {
#define CL_CAPS MAGIC_UNCAPSLOCK_TO_CONTROL
#define CL_TOGG MAGIC_TOGGLE_CONTROL_CAPSLOCK
+#define EC_SWAP MAGIC_SWAP_ESCAPE_CAPSLOCK
+#define EC_NORM MAGIC_UNSWAP_ESCAPE_CAPSLOCK
+#define EC_TOGG MAGIC_TOGGLE_ESCAPE_CAPSLOCK
+
#define LCG_SWP MAGIC_SWAP_LCTL_LGUI
#define LCG_NRM MAGIC_UNSWAP_LCTL_LGUI
#define RCG_SWP MAGIC_SWAP_RCTL_RGUI
@@ -791,15 +801,8 @@ enum quantum_keycodes {
#define EH_LEFT MAGIC_EE_HANDS_LEFT
#define EH_RGHT MAGIC_EE_HANDS_RIGHT
-// GOTO layer - 16 layers max
-// when:
-// ON_PRESS = 1
-// ON_RELEASE = 2
-// Unless you have a good reason not to do so, prefer ON_PRESS (1) as your default.
-// In fact, we changed it to assume ON_PRESS for sanity/simplicity. If needed, you can add your own
-// keycode modeled after the old version, kept below for this.
-/* #define TO(layer, when) (QK_TO | (when << 0x4) | (layer & 0xFF)) */
-#define TO(layer) (QK_TO | (ON_PRESS << 0x4) | ((layer)&0xFF))
+// GOTO layer - 256 layer max
+#define TO(layer) (QK_TO | ((layer)&0xFF))
// Momentary switch layer - 256 layer max
#define MO(layer) (QK_MOMENTARY | ((layer)&0xFF))
@@ -895,6 +898,7 @@ enum quantum_keycodes {
#define UC_M_WI UNICODE_MODE_WIN
#define UC_M_BS UNICODE_MODE_BSD
#define UC_M_WC UNICODE_MODE_WINC
+#define UC_M_EM UNICODE_MODE_EMACS
// Swap Hands
#define SH_T(kc) (QK_SWAP_HANDS | (kc))
diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h
index ed9455ee74..51380d9c50 100644
--- a/quantum/quantum_keycodes_legacy.h
+++ b/quantum/quantum_keycodes_legacy.h
@@ -11,3 +11,6 @@
#define KC_GESC QK_GRAVE_ESCAPE
#define EEP_RST QK_CLEAR_EEPROM
+
+#define TERM_ON _Static_assert(false, "The Terminal feature has been removed from QMK. Please remove use of TERM_ON/TERM_OFF from your keymap.")
+#define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") \ No newline at end of file
diff --git a/quantum/rgb_matrix/animations/pixel_fractal_anim.h b/quantum/rgb_matrix/animations/pixel_fractal_anim.h
index 906da1a48e..b26d5c4100 100644
--- a/quantum/rgb_matrix/animations/pixel_fractal_anim.h
+++ b/quantum/rgb_matrix/animations/pixel_fractal_anim.h
@@ -1,19 +1,5 @@
-/* Copyright (C) 2021 @filterpaper
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
+// Copyright (C) 2022 @filterpaper
+// SPDX-License-Identifier: GPL-2.0-or-later
// Inspired from 4x12 fractal created by @schwarzgrau
#ifdef ENABLE_RGB_MATRIX_PIXEL_FRACTAL
@@ -22,12 +8,8 @@ RGB_MATRIX_EFFECT(PIXEL_FRACTAL)
static bool PIXEL_FRACTAL(effect_params_t* params) {
# define MID_COL MATRIX_COLS / 2
- static bool led[MATRIX_ROWS][MATRIX_COLS];
-
+ static bool led[MATRIX_ROWS][MID_COL];
static uint32_t wait_timer = 0;
- if (wait_timer > g_rgb_timer) {
- return false;
- }
inline uint32_t interval(void) {
return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16);
@@ -37,44 +19,40 @@ static bool PIXEL_FRACTAL(effect_params_t* params) {
rgb_matrix_set_color_all(0, 0, 0);
}
- RGB rgb = rgb_matrix_hsv_to_rgb(rgb_matrix_config.hsv);
- for (uint8_t h = 0; h < MATRIX_ROWS; ++h) {
- for (uint8_t l = 0; l < MID_COL - 1; ++l) { // Light and move left columns outwards
- if (led[h][l]) {
- rgb_matrix_set_color(g_led_config.matrix_co[h][l], rgb.r, rgb.g, rgb.b);
- } else {
- rgb_matrix_set_color(g_led_config.matrix_co[h][l], 0, 0, 0);
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+
+ if (g_rgb_timer > wait_timer) {
+ RGB rgb = rgb_matrix_hsv_to_rgb(rgb_matrix_config.hsv);
+ for (uint8_t h = 0; h < MATRIX_ROWS; ++h) {
+ // Light and copy columns outward
+ for (uint8_t l = 0; l < MID_COL - 1; ++l) {
+ if (led[h][l]) {
+ rgb_matrix_set_color(g_led_config.matrix_co[h][l], rgb.r, rgb.g, rgb.b);
+ rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - 1 - l], rgb.r, rgb.g, rgb.b);
+ } else {
+ rgb_matrix_set_color(g_led_config.matrix_co[h][l], 0, 0, 0);
+ rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - 1 - l], 0, 0, 0);
+ }
+ led[h][l] = led[h][l + 1];
}
- led[h][l] = led[h][l + 1];
- }
- for (uint8_t r = MATRIX_COLS - 1; r > MID_COL; --r) { // Light and move right columns outwards
- if (led[h][r]) {
- rgb_matrix_set_color(g_led_config.matrix_co[h][r], rgb.r, rgb.g, rgb.b);
+ // Light both middle columns
+ if (led[h][MID_COL - 1]) {
+ rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL - 1], rgb.r, rgb.g, rgb.b);
+ rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - MID_COL], rgb.r, rgb.g, rgb.b);
} else {
- rgb_matrix_set_color(g_led_config.matrix_co[h][r], 0, 0, 0);
+ rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL - 1], 0, 0, 0);
+ rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - MID_COL], 0, 0, 0);
}
- led[h][r] = led[h][r - 1];
- }
- // Light both middle columns
- if (led[h][MID_COL]) {
- rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL], rgb.r, rgb.g, rgb.b);
- } else {
- rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL], 0, 0, 0);
- }
- if (led[h][MID_COL - 1]) {
- rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL - 1], rgb.r, rgb.g, rgb.b);
- } else {
- rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL - 1], 0, 0, 0);
+ // Generate new random fractal column
+ led[h][MID_COL - 1] = (random8() & 3) ? false : true;
}
- // Generate new random fractal columns
- led[h][MID_COL] = led[h][MID_COL - 1] = (random8() & 3) ? false : true;
+ wait_timer = g_rgb_timer + interval();
}
- wait_timer = g_rgb_timer + interval();
- return false;
+ return rgb_matrix_check_finished_leds(led_max);
}
# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // ENABLE_RGB_MATRIX_PIXEL_FRACTAL
diff --git a/quantum/rgb_matrix/animations/pixel_rain_anim.h b/quantum/rgb_matrix/animations/pixel_rain_anim.h
index 03488b43df..ce2528a26d 100644
--- a/quantum/rgb_matrix/animations/pixel_rain_anim.h
+++ b/quantum/rgb_matrix/animations/pixel_rain_anim.h
@@ -20,17 +20,14 @@ RGB_MATRIX_EFFECT(PIXEL_RAIN)
static bool PIXEL_RAIN(effect_params_t* params) {
static uint32_t wait_timer = 0;
- if (wait_timer > g_rgb_timer) {
- return false;
- }
inline uint32_t interval(void) {
return 500 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16);
}
- bool rain_pixel(uint8_t i, effect_params_t * params, bool off) {
+ void rain_pixel(uint8_t i, effect_params_t * params, bool off) {
if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) {
- return true;
+ return;
}
if (off) {
rgb_matrix_set_color(i, 0, 0, 0);
@@ -40,10 +37,13 @@ static bool PIXEL_RAIN(effect_params_t* params) {
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
wait_timer = g_rgb_timer + interval();
- return false;
}
- return rain_pixel(mod8(random8(), DRIVER_LED_TOTAL), params, random8() & 2);
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ if (g_rgb_timer > wait_timer) {
+ rain_pixel(mod8(random8(), DRIVER_LED_TOTAL), params, random8() & 2);
+ }
+ return rgb_matrix_check_finished_leds(led_max);
}
# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix/animations/raindrops_anim.h b/quantum/rgb_matrix/animations/raindrops_anim.h
index 2d4b53b7b0..a508e51183 100644
--- a/quantum/rgb_matrix/animations/raindrops_anim.h
+++ b/quantum/rgb_matrix/animations/raindrops_anim.h
@@ -14,23 +14,22 @@ static void raindrops_set_color(int i, effect_params_t* params) {
deltaH += 256;
}
- hsv.h = rgb_matrix_config.hsv.h + (deltaH * (rand() & 0x03));
+ hsv.h = rgb_matrix_config.hsv.h + (deltaH * (random8() & 0x03));
RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
bool RAINDROPS(effect_params_t* params) {
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
if (!params->init) {
// Change one LED every tick, make sure speed is not 0
if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
- raindrops_set_color(rand() % DRIVER_LED_TOTAL, params);
+ raindrops_set_color(random8() % DRIVER_LED_TOTAL, params);
+ }
+ } else {
+ for (int i = led_min; i < led_max; i++) {
+ raindrops_set_color(i, params);
}
- return false;
- }
-
- RGB_MATRIX_USE_LIMITS(led_min, led_max);
- for (int i = led_min; i < led_max; i++) {
- raindrops_set_color(i, params);
}
return rgb_matrix_check_finished_leds(led_max);
}
diff --git a/quantum/rgb_matrix/animations/solid_reactive_anim.h b/quantum/rgb_matrix/animations/solid_reactive_anim.h
index d3a7ebbdf7..052bfb22fd 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_anim.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_anim.h
@@ -4,6 +4,9 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t offset) {
+# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
+ hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
+# endif
hsv.h += qsub8(130, offset);
return hsv;
}
diff --git a/quantum/rgb_matrix/animations/solid_reactive_cross.h b/quantum/rgb_matrix/animations/solid_reactive_cross.h
index 043a369b73..9e5703a0ea 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_cross.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_cross.h
@@ -19,6 +19,9 @@ static HSV SOLID_REACTIVE_CROSS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t di
dy = dy * 16 > 255 ? 255 : dy * 16;
effect += dx > dy ? dy : dx;
if (effect > 255) effect = 255;
+# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
+ hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
+# endif
hsv.v = qadd8(hsv.v, 255 - effect);
return hsv;
}
diff --git a/quantum/rgb_matrix/animations/solid_reactive_nexus.h b/quantum/rgb_matrix/animations/solid_reactive_nexus.h
index 8d62a49fea..64f5064cf9 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_nexus.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_nexus.h
@@ -16,6 +16,9 @@ static HSV SOLID_REACTIVE_NEXUS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t di
if (effect > 255) effect = 255;
if (dist > 72) effect = 255;
if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8)) effect = 255;
+# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
+ hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
+# endif
hsv.v = qadd8(hsv.v, 255 - effect);
hsv.h = rgb_matrix_config.hsv.h + dy / 4;
return hsv;
diff --git a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h
index 0d0a424cf3..bd3ce0817d 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h
@@ -4,6 +4,9 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV SOLID_REACTIVE_SIMPLE_math(HSV hsv, uint16_t offset) {
+# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
+ hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
+# endif
hsv.v = scale8(255 - offset, hsv.v);
return hsv;
}
diff --git a/quantum/rgb_matrix/animations/solid_reactive_wide.h b/quantum/rgb_matrix/animations/solid_reactive_wide.h
index 7598796316..24fedc2020 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_wide.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_wide.h
@@ -14,6 +14,9 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTIWIDE)
static HSV SOLID_REACTIVE_WIDE_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
uint16_t effect = tick + dist * 5;
if (effect > 255) effect = 255;
+# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
+ hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
+# endif
hsv.v = qadd8(hsv.v, 255 - effect);
return hsv;
}
diff --git a/quantum/rgb_matrix/animations/typing_heatmap_anim.h b/quantum/rgb_matrix/animations/typing_heatmap_anim.h
index 4b17c4c3ed..00d137f1a6 100644
--- a/quantum/rgb_matrix/animations/typing_heatmap_anim.h
+++ b/quantum/rgb_matrix/animations/typing_heatmap_anim.h
@@ -6,30 +6,41 @@ RGB_MATRIX_EFFECT(TYPING_HEATMAP)
# define RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS 25
# endif
+# ifndef RGB_MATRIX_TYPING_HEATMAP_SPREAD
+# define RGB_MATRIX_TYPING_HEATMAP_SPREAD 40
+# endif
+
+# ifndef RGB_MATRIX_TYPING_HEATMAP_AREA_LIMIT
+# define RGB_MATRIX_TYPING_HEATMAP_AREA_LIMIT 16
+# endif
void process_rgb_matrix_typing_heatmap(uint8_t row, uint8_t col) {
# ifdef RGB_MATRIX_TYPING_HEATMAP_SLIM
// Limit effect to pressed keys
g_rgb_frame_buffer[row][col] = qadd8(g_rgb_frame_buffer[row][col], 32);
# else
- uint8_t m_row = row - 1;
- uint8_t p_row = row + 1;
- uint8_t m_col = col - 1;
- uint8_t p_col = col + 1;
-
- if (m_col < col) g_rgb_frame_buffer[row][m_col] = qadd8(g_rgb_frame_buffer[row][m_col], 16);
- g_rgb_frame_buffer[row][col] = qadd8(g_rgb_frame_buffer[row][col], 32);
- if (p_col < MATRIX_COLS) g_rgb_frame_buffer[row][p_col] = qadd8(g_rgb_frame_buffer[row][p_col], 16);
-
- if (p_row < MATRIX_ROWS) {
- if (m_col < col) g_rgb_frame_buffer[p_row][m_col] = qadd8(g_rgb_frame_buffer[p_row][m_col], 13);
- g_rgb_frame_buffer[p_row][col] = qadd8(g_rgb_frame_buffer[p_row][col], 16);
- if (p_col < MATRIX_COLS) g_rgb_frame_buffer[p_row][p_col] = qadd8(g_rgb_frame_buffer[p_row][p_col], 13);
+ if (g_led_config.matrix_co[row][col] == NO_LED) { // skip as pressed key doesn't have an led position
+ return;
}
-
- if (m_row < row) {
- if (m_col < col) g_rgb_frame_buffer[m_row][m_col] = qadd8(g_rgb_frame_buffer[m_row][m_col], 13);
- g_rgb_frame_buffer[m_row][col] = qadd8(g_rgb_frame_buffer[m_row][col], 16);
- if (p_col < MATRIX_COLS) g_rgb_frame_buffer[m_row][p_col] = qadd8(g_rgb_frame_buffer[m_row][p_col], 13);
+ for (uint8_t i_row = 0; i_row < MATRIX_ROWS; i_row++) {
+ for (uint8_t i_col = 0; i_col < MATRIX_COLS; i_col++) {
+ if (g_led_config.matrix_co[i_row][i_col] == NO_LED) { // skip as target key doesn't have an led position
+ continue;
+ }
+ if (i_row == row && i_col == col) {
+ g_rgb_frame_buffer[row][col] = qadd8(g_rgb_frame_buffer[row][col], 32);
+ } else {
+# define LED_DISTANCE(led_a, led_b) sqrt16(((int16_t)(led_a.x - led_b.x) * (int16_t)(led_a.x - led_b.x)) + ((int16_t)(led_a.y - led_b.y) * (int16_t)(led_a.y - led_b.y)))
+ uint8_t distance = LED_DISTANCE(g_led_config.point[g_led_config.matrix_co[row][col]], g_led_config.point[g_led_config.matrix_co[i_row][i_col]]);
+# undef LED_DISTANCE
+ if (distance <= RGB_MATRIX_TYPING_HEATMAP_SPREAD) {
+ uint8_t amount = qsub8(RGB_MATRIX_TYPING_HEATMAP_SPREAD, distance);
+ if (amount > RGB_MATRIX_TYPING_HEATMAP_AREA_LIMIT) {
+ amount = RGB_MATRIX_TYPING_HEATMAP_AREA_LIMIT;
+ }
+ g_rgb_frame_buffer[i_row][i_col] = qadd8(g_rgb_frame_buffer[i_row][i_col], amount);
+ }
+ }
+ }
}
# endif
}
@@ -40,10 +51,7 @@ static uint16_t heatmap_decrease_timer;
static bool decrease_heatmap_values;
bool TYPING_HEATMAP(effect_params_t* params) {
- // Modified version of RGB_MATRIX_USE_LIMITS to work off of matrix row / col size
- uint8_t led_min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter;
- uint8_t led_max = led_min + RGB_MATRIX_LED_PROCESS_LIMIT;
- if (led_max > sizeof(g_rgb_frame_buffer)) led_max = sizeof(g_rgb_frame_buffer);
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
if (params->init) {
rgb_matrix_set_color_all(0, 0, 0);
@@ -63,28 +71,26 @@ bool TYPING_HEATMAP(effect_params_t* params) {
}
// Render heatmap & decrease
- for (int i = led_min; i < led_max; i++) {
- uint8_t row = i % MATRIX_ROWS;
- uint8_t col = i / MATRIX_ROWS;
- uint8_t val = g_rgb_frame_buffer[row][col];
-
- // set the pixel colour
- uint8_t led[LED_HITS_TO_REMEMBER];
- uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led);
- for (uint8_t j = 0; j < led_count; ++j) {
- if (!HAS_ANY_FLAGS(g_led_config.flags[led[j]], params->flags)) continue;
-
- HSV hsv = {170 - qsub8(val, 85), rgb_matrix_config.hsv.s, scale8((qadd8(170, val) - 170) * 3, rgb_matrix_config.hsv.v)};
- RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
- rgb_matrix_set_color(led[j], rgb.r, rgb.g, rgb.b);
- }
-
- if (decrease_heatmap_values) {
- g_rgb_frame_buffer[row][col] = qsub8(val, 1);
+ uint8_t count = 0;
+ for (uint8_t row = 0; row < MATRIX_ROWS && count < RGB_MATRIX_LED_PROCESS_LIMIT; row++) {
+ for (uint8_t col = 0; col < MATRIX_COLS && RGB_MATRIX_LED_PROCESS_LIMIT; col++) {
+ if (g_led_config.matrix_co[row][col] >= led_min && g_led_config.matrix_co[row][col] < led_max) {
+ count++;
+ uint8_t val = g_rgb_frame_buffer[row][col];
+ if (!HAS_ANY_FLAGS(g_led_config.flags[g_led_config.matrix_co[row][col]], params->flags)) continue;
+
+ HSV hsv = {170 - qsub8(val, 85), rgb_matrix_config.hsv.s, scale8((qadd8(170, val) - 170) * 3, rgb_matrix_config.hsv.v)};
+ RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
+ rgb_matrix_set_color(g_led_config.matrix_co[row][col], rgb.r, rgb.g, rgb.b);
+
+ if (decrease_heatmap_values) {
+ g_rgb_frame_buffer[row][col] = qsub8(val, 1);
+ }
+ }
}
}
- return led_max < sizeof(g_rgb_frame_buffer);
+ return rgb_matrix_check_finished_leds(led_max);
}
# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c
index 141e0a69f5..d2f8827319 100644
--- a/quantum/rgb_matrix/rgb_matrix.c
+++ b/quantum/rgb_matrix/rgb_matrix.c
@@ -249,8 +249,15 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) {
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP)
- if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) {
- process_rgb_matrix_typing_heatmap(row, col);
+# if defined(RGB_MATRIX_KEYRELEASES)
+ if (!pressed)
+# else
+ if (pressed)
+# endif // defined(RGB_MATRIX_KEYRELEASES)
+ {
+ if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) {
+ process_rgb_matrix_typing_heatmap(row, col);
+ }
}
#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP)
}
@@ -736,3 +743,7 @@ led_flags_t rgb_matrix_get_flags(void) {
void rgb_matrix_set_flags(led_flags_t flags) {
rgb_matrix_set_flags_eeprom_helper(flags, true);
}
+
+void rgb_matrix_set_flags_noeeprom(led_flags_t flags) {
+ rgb_matrix_set_flags_eeprom_helper(flags, false);
+}
diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h
index 359d507a4d..fc9fc3e020 100644
--- a/quantum/rgb_matrix/rgb_matrix.h
+++ b/quantum/rgb_matrix/rgb_matrix.h
@@ -182,6 +182,7 @@ void rgb_matrix_increase_speed_noeeprom(void);
void rgb_matrix_decrease_speed(void);
void rgb_matrix_decrease_speed_noeeprom(void);
led_flags_t rgb_matrix_get_flags(void);
+led_flags_t rgb_matrix_get_flags_noeeprom(void);
void rgb_matrix_set_flags(led_flags_t flags);
#ifndef RGBLIGHT_ENABLE
diff --git a/quantum/send_string.h b/quantum/send_string.h
deleted file mode 100644
index b90e6f6890..0000000000
--- a/quantum/send_string.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright 2021
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdint.h>
-
-#include "progmem.h"
-#include "send_string_keycodes.h"
-
-#define SEND_STRING(string) send_string_P(PSTR(string))
-#define SEND_STRING_DELAY(string, interval) send_string_with_delay_P(PSTR(string), interval)
-
-// Look-Up Tables (LUTs) to convert ASCII character to keycode sequence.
-extern const uint8_t ascii_to_shift_lut[16];
-extern const uint8_t ascii_to_altgr_lut[16];
-extern const uint8_t ascii_to_dead_lut[16];
-extern const uint8_t ascii_to_keycode_lut[128];
-
-// clang-format off
-#define KCLUT_ENTRY(a, b, c, d, e, f, g, h) \
- ( ((a) ? 1 : 0) << 0 \
- | ((b) ? 1 : 0) << 1 \
- | ((c) ? 1 : 0) << 2 \
- | ((d) ? 1 : 0) << 3 \
- | ((e) ? 1 : 0) << 4 \
- | ((f) ? 1 : 0) << 5 \
- | ((g) ? 1 : 0) << 6 \
- | ((h) ? 1 : 0) << 7 )
-// clang-format on
-
-void send_string(const char *str);
-void send_string_with_delay(const char *str, uint8_t interval);
-void send_string_P(const char *str);
-void send_string_with_delay_P(const char *str, uint8_t interval);
-void send_char(char ascii_code);
-
-void send_dword(uint32_t number);
-void send_word(uint16_t number);
-void send_byte(uint8_t number);
-void send_nibble(uint8_t number);
-
-void tap_random_base64(void);
diff --git a/quantum/send_string.c b/quantum/send_string/send_string.c
index 0de12ba12d..818a52f6dc 100644
--- a/quantum/send_string.c
+++ b/quantum/send_string/send_string.c
@@ -142,40 +142,36 @@ __attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
// Note: we bit-pack in "reverse" order to optimize loading
#define PGM_LOADBIT(mem, pos) ((pgm_read_byte(&((mem)[(pos) / 8])) >> ((pos) % 8)) & 0x01)
-void send_string(const char *str) {
- send_string_with_delay(str, 0);
+void send_string(const char *string) {
+ send_string_with_delay(string, 0);
}
-void send_string_P(const char *str) {
- send_string_with_delay_P(str, 0);
-}
-
-void send_string_with_delay(const char *str, uint8_t interval) {
+void send_string_with_delay(const char *string, uint8_t interval) {
while (1) {
- char ascii_code = *str;
+ char ascii_code = *string;
if (!ascii_code) break;
if (ascii_code == SS_QMK_PREFIX) {
- ascii_code = *(++str);
+ ascii_code = *(++string);
if (ascii_code == SS_TAP_CODE) {
// tap
- uint8_t keycode = *(++str);
+ uint8_t keycode = *(++string);
tap_code(keycode);
} else if (ascii_code == SS_DOWN_CODE) {
// down
- uint8_t keycode = *(++str);
+ uint8_t keycode = *(++string);
register_code(keycode);
} else if (ascii_code == SS_UP_CODE) {
// up
- uint8_t keycode = *(++str);
+ uint8_t keycode = *(++string);
unregister_code(keycode);
} else if (ascii_code == SS_DELAY_CODE) {
// delay
int ms = 0;
- uint8_t keycode = *(++str);
+ uint8_t keycode = *(++string);
while (isdigit(keycode)) {
ms *= 10;
ms += keycode - '0';
- keycode = *(++str);
+ keycode = *(++string);
}
while (ms--)
wait_ms(1);
@@ -183,50 +179,7 @@ void send_string_with_delay(const char *str, uint8_t interval) {
} else {
send_char(ascii_code);
}
- ++str;
- // interval
- {
- uint8_t ms = interval;
- while (ms--)
- wait_ms(1);
- }
- }
-}
-
-void send_string_with_delay_P(const char *str, uint8_t interval) {
- while (1) {
- char ascii_code = pgm_read_byte(str);
- if (!ascii_code) break;
- if (ascii_code == SS_QMK_PREFIX) {
- ascii_code = pgm_read_byte(++str);
- if (ascii_code == SS_TAP_CODE) {
- // tap
- uint8_t keycode = pgm_read_byte(++str);
- tap_code(keycode);
- } else if (ascii_code == SS_DOWN_CODE) {
- // down
- uint8_t keycode = pgm_read_byte(++str);
- register_code(keycode);
- } else if (ascii_code == SS_UP_CODE) {
- // up
- uint8_t keycode = pgm_read_byte(++str);
- unregister_code(keycode);
- } else if (ascii_code == SS_DELAY_CODE) {
- // delay
- int ms = 0;
- uint8_t keycode = pgm_read_byte(++str);
- while (isdigit(keycode)) {
- ms *= 10;
- ms += keycode - '0';
- keycode = pgm_read_byte(++str);
- }
- while (ms--)
- wait_ms(1);
- }
- } else {
- send_char(ascii_code);
- }
- ++str;
+ ++string;
// interval
{
uint8_t ms = interval;
@@ -250,17 +203,17 @@ void send_char(char ascii_code) {
bool is_dead = PGM_LOADBIT(ascii_to_dead_lut, (uint8_t)ascii_code);
if (is_shifted) {
- register_code(KC_LSFT);
+ register_code(KC_LEFT_SHIFT);
}
if (is_altgred) {
- register_code(KC_RALT);
+ register_code(KC_RIGHT_ALT);
}
tap_code(keycode);
if (is_altgred) {
- unregister_code(KC_RALT);
+ unregister_code(KC_RIGHT_ALT);
}
if (is_shifted) {
- unregister_code(KC_LSFT);
+ unregister_code(KC_LEFT_SHIFT);
}
if (is_dead) {
tap_code(KC_SPACE);
@@ -320,3 +273,52 @@ void tap_random_base64(void) {
break;
}
}
+
+#if defined(__AVR__)
+void send_string_P(const char *string) {
+ send_string_with_delay_P(string, 0);
+}
+
+void send_string_with_delay_P(const char *string, uint8_t interval) {
+ while (1) {
+ char ascii_code = pgm_read_byte(string);
+ if (!ascii_code) break;
+ if (ascii_code == SS_QMK_PREFIX) {
+ ascii_code = pgm_read_byte(++string);
+ if (ascii_code == SS_TAP_CODE) {
+ // tap
+ uint8_t keycode = pgm_read_byte(++string);
+ tap_code(keycode);
+ } else if (ascii_code == SS_DOWN_CODE) {
+ // down
+ uint8_t keycode = pgm_read_byte(++string);
+ register_code(keycode);
+ } else if (ascii_code == SS_UP_CODE) {
+ // up
+ uint8_t keycode = pgm_read_byte(++string);
+ unregister_code(keycode);
+ } else if (ascii_code == SS_DELAY_CODE) {
+ // delay
+ int ms = 0;
+ uint8_t keycode = pgm_read_byte(++string);
+ while (isdigit(keycode)) {
+ ms *= 10;
+ ms += keycode - '0';
+ keycode = pgm_read_byte(++string);
+ }
+ while (ms--)
+ wait_ms(1);
+ }
+ } else {
+ send_char(ascii_code);
+ }
+ ++string;
+ // interval
+ {
+ uint8_t ms = interval;
+ while (ms--)
+ wait_ms(1);
+ }
+ }
+}
+#endif
diff --git a/quantum/send_string/send_string.h b/quantum/send_string/send_string.h
new file mode 100644
index 0000000000..4eb55b88dc
--- /dev/null
+++ b/quantum/send_string/send_string.h
@@ -0,0 +1,152 @@
+/* Copyright 2021
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \defgroup send_string
+ *
+ * Send String API. These functions allow you to create macros by typing out sequences of keystrokes.
+ * \{
+ */
+
+#include <stdint.h>
+
+#include "progmem.h"
+#include "send_string_keycodes.h"
+
+// Look-Up Tables (LUTs) to convert ASCII character to keycode sequence.
+extern const uint8_t ascii_to_shift_lut[16];
+extern const uint8_t ascii_to_altgr_lut[16];
+extern const uint8_t ascii_to_dead_lut[16];
+extern const uint8_t ascii_to_keycode_lut[128];
+
+// clang-format off
+#define KCLUT_ENTRY(a, b, c, d, e, f, g, h) \
+ ( ((a) ? 1 : 0) << 0 \
+ | ((b) ? 1 : 0) << 1 \
+ | ((c) ? 1 : 0) << 2 \
+ | ((d) ? 1 : 0) << 3 \
+ | ((e) ? 1 : 0) << 4 \
+ | ((f) ? 1 : 0) << 5 \
+ | ((g) ? 1 : 0) << 6 \
+ | ((h) ? 1 : 0) << 7 )
+// clang-format on
+
+/**
+ * \brief Type out a string of ASCII characters.
+ *
+ * This function simply calls `send_string_with_delay(string, 0)`.
+ *
+ * Most keycodes from the basic keycode range are also supported by way of a special sequence - see `send_string_keycodes.h`.
+ *
+ * \param string The string to type out.
+ */
+void send_string(const char *string);
+
+/**
+ * \brief Type out a string of ASCII characters, with a delay between each character.
+ *
+ * \param string The string to type out.
+ * \param interval The amount of time, in milliseconds, to wait before typing the next character.
+ */
+void send_string_with_delay(const char *string, uint8_t interval);
+
+/**
+ * \brief Type out an ASCII character.
+ *
+ * \param ascii_code The character to type.
+ */
+void send_char(char ascii_code);
+
+/**
+ * \brief Type out an eight digit (unsigned 32-bit) hexadecimal value.
+ *
+ * The format is `[0-9a-f]{8}`, eg. `00000000` through `ffffffff`.
+ *
+ * \param number The value to type, from 0 to 4,294,967,295.
+ */
+void send_dword(uint32_t number);
+
+/**
+ * \brief Type out a four digit (unsigned 16-bit) hexadecimal value.
+ *
+ * The format is `[0-9a-f]{4}`, eg. `0000` through `ffff`.
+ *
+ * \param number The value to type, from 0 to 65,535.
+ */
+void send_word(uint16_t number);
+
+/**
+ * \brief Type out a two digit (8-bit) hexadecimal value.
+ *
+ * The format is `[0-9a-f]{2}`, eg. `00` through `ff`.
+ *
+ * \param number The value to type, from 0 to 255.
+ */
+void send_byte(uint8_t number);
+
+/**
+ * \brief Type out a single hexadecimal digit.
+ *
+ * The format is `[0-9a-f]{1}`, eg. `0` through `f`.
+ *
+ * \param number The value to type, from 0 to 15.
+ */
+void send_nibble(uint8_t number);
+
+/**
+ * \brief Type a pseudorandom character from the set `A-Z`, `a-z`, `0-9`, `+` and `/`.
+ */
+void tap_random_base64(void);
+
+#if defined(__AVR__) || defined(__DOXYGEN__)
+/**
+ * \brief Type out a PROGMEM string of ASCII characters.
+ *
+ * On ARM devices, this function is simply an alias for send_string_with_delay(string, 0).
+ *
+ * \param string The string to type out.
+ */
+void send_string_P(const char *string);
+
+/**
+ * \brief Type out a PROGMEM string of ASCII characters, with a delay between each character.
+ *
+ * On ARM devices, this function is simply an alias for send_string_with_delay(string, interval).
+ *
+ * \param string The string to type out.
+ * \param interval The amount of time, in milliseconds, to wait before typing the next character.
+ */
+void send_string_with_delay_P(const char *string, uint8_t interval);
+#else
+# define send_string_P(string) send_string_with_delay(string, 0)
+# define send_string_with_delay_P(string, interval) send_string_with_delay(string, interval)
+#endif
+
+/**
+ * \brief Shortcut macro for send_string_with_delay_P(PSTR(string), 0).
+ *
+ * On ARM devices, this define evaluates to send_string_with_delay(string, 0).
+ */
+#define SEND_STRING(string) send_string_with_delay_P(PSTR(string), 0)
+
+/**
+ * \brief Shortcut macro for send_string_with_delay_P(PSTR(string), interval).
+ *
+ * On ARM devices, this define evaluates to send_string_with_delay(string, interval).
+ */
+#define SEND_STRING_DELAY(string, interval) send_string_with_delay_P(PSTR(string), interval)
+
+/** \} */
diff --git a/quantum/send_string/send_string_keycodes.h b/quantum/send_string/send_string_keycodes.h
new file mode 100644
index 0000000000..802d9a8240
--- /dev/null
+++ b/quantum/send_string/send_string_keycodes.h
@@ -0,0 +1,436 @@
+/* Copyright 2019
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+// clang-format off
+
+/* Punctuation */
+#define X_ENT X_ENTER
+#define X_ESC X_ESCAPE
+#define X_BSPC X_BSPACE
+#define X_SPC X_SPACE
+#define X_MINS X_MINUS
+#define X_EQL X_EQUAL
+#define X_LBRC X_LBRACKET
+#define X_RBRC X_RBRACKET
+#define X_BSLS X_BSLASH
+#define X_NUHS X_NONUS_HASH
+#define X_SCLN X_SCOLON
+#define X_QUOT X_QUOTE
+#define X_GRV X_GRAVE
+#define X_COMM X_COMMA
+#define X_SLSH X_SLASH
+#define X_NUBS X_NONUS_BSLASH
+
+/* Lock Keys */
+#define X_CLCK X_CAPSLOCK
+#define X_CAPS X_CAPSLOCK
+#define X_SLCK X_SCROLLLOCK
+#define X_NLCK X_NUMLOCK
+#define X_LCAP X_LOCKING_CAPS
+#define X_LNUM X_LOCKING_NUM
+#define X_LSCR X_LOCKING_SCROLL
+
+/* Commands */
+#define X_PSCR X_PSCREEN
+#define X_PAUS X_PAUSE
+#define X_BRK X_PAUSE
+#define X_INS X_INSERT
+#define X_DEL X_DELETE
+#define X_PGDN X_PGDOWN
+#define X_RGHT X_RIGHT
+#define X_APP X_APPLICATION
+#define X_EXEC X_EXECUTE
+#define X_SLCT X_SELECT
+#define X_AGIN X_AGAIN
+#define X_PSTE X_PASTE
+#define X_ERAS X_ALT_ERASE
+#define X_CLR X_CLEAR
+
+/* Keypad */
+#define X_PSLS X_KP_SLASH
+#define X_PAST X_KP_ASTERISK
+#define X_PMNS X_KP_MINUS
+#define X_PPLS X_KP_PLUS
+#define X_PENT X_KP_ENTER
+#define X_P1 X_KP_1
+#define X_P2 X_KP_2
+#define X_P3 X_KP_3
+#define X_P4 X_KP_4
+#define X_P5 X_KP_5
+#define X_P6 X_KP_6
+#define X_P7 X_KP_7
+#define X_P8 X_KP_8
+#define X_P9 X_KP_9
+#define X_P0 X_KP_0
+#define X_PDOT X_KP_DOT
+#define X_PEQL X_KP_EQUAL
+#define X_PCMM X_KP_COMMA
+
+/* Japanese specific */
+#define X_ZKHK X_GRAVE
+#define X_RO X_INT1
+#define X_KANA X_INT2
+#define X_JYEN X_INT3
+#define X_HENK X_INT4
+#define X_MHEN X_INT5
+
+/* Korean specific */
+#define X_HAEN X_LANG1
+#define X_HANJ X_LANG2
+
+/* Modifiers */
+#define X_LCTL X_LCTRL
+#define X_LSFT X_LSHIFT
+#define X_LOPT X_LALT
+#define X_LCMD X_LGUI
+#define X_LWIN X_LGUI
+#define X_RCTL X_RCTRL
+#define X_RSFT X_RSHIFT
+#define X_ALGR X_RALT
+#define X_ROPT X_RALT
+#define X_RCMD X_RGUI
+#define X_RWIN X_RGUI
+
+/* Generic Desktop Page (0x01) */
+#define X_PWR X_SYSTEM_POWER
+#define X_SLEP X_SYSTEM_SLEEP
+#define X_WAKE X_SYSTEM_WAKE
+
+/* Consumer Page (0x0C) */
+#define X_MUTE X_AUDIO_MUTE
+#define X_VOLU X_AUDIO_VOL_UP
+#define X_VOLD X_AUDIO_VOL_DOWN
+#define X_MNXT X_MEDIA_NEXT_TRACK
+#define X_MPRV X_MEDIA_PREV_TRACK
+#define X_MSTP X_MEDIA_STOP
+#define X_MPLY X_MEDIA_PLAY_PAUSE
+#define X_MSEL X_MEDIA_SELECT
+#define X_EJCT X_MEDIA_EJECT
+#define X_CALC X_CALCULATOR
+#define X_MYCM X_MY_COMPUTER
+#define X_WSCH X_WWW_SEARCH
+#define X_WHOM X_WWW_HOME
+#define X_WBAK X_WWW_BACK
+#define X_WFWD X_WWW_FORWARD
+#define X_WSTP X_WWW_STOP
+#define X_WREF X_WWW_REFRESH
+#define X_WFAV X_WWW_FAVORITES
+#define X_MFFD X_MEDIA_FAST_FORWARD
+#define X_MRWD X_MEDIA_REWIND
+#define X_BRIU X_BRIGHTNESS_UP
+#define X_BRID X_BRIGHTNESS_DOWN
+
+/* System Specific */
+#define X_BRMU X_PAUSE
+#define X_BRMD X_SCROLLLOCK
+
+/* Mouse Keys */
+#define X_MS_U X_MS_UP
+#define X_MS_D X_MS_DOWN
+#define X_MS_L X_MS_LEFT
+#define X_MS_R X_MS_RIGHT
+#define X_BTN1 X_MS_BTN1
+#define X_BTN2 X_MS_BTN2
+#define X_BTN3 X_MS_BTN3
+#define X_BTN4 X_MS_BTN4
+#define X_BTN5 X_MS_BTN5
+#define X_WH_U X_MS_WH_UP
+#define X_WH_D X_MS_WH_DOWN
+#define X_WH_L X_MS_WH_LEFT
+#define X_WH_R X_MS_WH_RIGHT
+#define X_ACL0 X_MS_ACCEL0
+#define X_ACL1 X_MS_ACCEL1
+#define X_ACL2 X_MS_ACCEL2
+
+/* Keyboard/Keypad Page (0x07) */
+#define X_A 04
+#define X_B 05
+#define X_C 06
+#define X_D 07
+#define X_E 08
+#define X_F 09
+#define X_G 0a
+#define X_H 0b
+#define X_I 0c
+#define X_J 0d
+#define X_K 0e
+#define X_L 0f
+#define X_M 10
+#define X_N 11
+#define X_O 12
+#define X_P 13
+#define X_Q 14
+#define X_R 15
+#define X_S 16
+#define X_T 17
+#define X_U 18
+#define X_V 19
+#define X_W 1a
+#define X_X 1b
+#define X_Y 1c
+#define X_Z 1d
+#define X_1 1e
+#define X_2 1f
+#define X_3 20
+#define X_4 21
+#define X_5 22
+#define X_6 23
+#define X_7 24
+#define X_8 25
+#define X_9 26
+#define X_0 27
+#define X_ENTER 28
+#define X_ESCAPE 29
+#define X_BSPACE 2a
+#define X_TAB 2b
+#define X_SPACE 2c
+#define X_MINUS 2d
+#define X_EQUAL 2e
+#define X_LBRACKET 2f
+#define X_RBRACKET 30
+#define X_BSLASH 31
+#define X_NONUS_HASH 32
+#define X_SCOLON 33
+#define X_QUOTE 34
+#define X_GRAVE 35
+#define X_COMMA 36
+#define X_DOT 37
+#define X_SLASH 38
+#define X_CAPSLOCK 39
+#define X_F1 3a
+#define X_F2 3b
+#define X_F3 3c
+#define X_F4 3d
+#define X_F5 3e
+#define X_F6 3f
+#define X_F7 40
+#define X_F8 41
+#define X_F9 42
+#define X_F10 43
+#define X_F11 44
+#define X_F12 45
+#define X_PSCREEN 46
+#define X_SCROLLLOCK 47
+#define X_PAUSE 48
+#define X_INSERT 49
+#define X_HOME 4a
+#define X_PGUP 4b
+#define X_DELETE 4c
+#define X_END 4d
+#define X_PGDOWN 4e
+#define X_RIGHT 4f
+#define X_LEFT 50
+#define X_DOWN 51
+#define X_UP 52
+#define X_NUMLOCK 53
+#define X_KP_SLASH 54
+#define X_KP_ASTERISK 55
+#define X_KP_MINUS 56
+#define X_KP_PLUS 57
+#define X_KP_ENTER 58
+#define X_KP_1 59
+#define X_KP_2 5a
+#define X_KP_3 5b
+#define X_KP_4 5c
+#define X_KP_5 5d
+#define X_KP_6 5e
+#define X_KP_7 5f
+#define X_KP_8 60
+#define X_KP_9 61
+#define X_KP_0 62
+#define X_KP_DOT 63
+#define X_NONUS_BSLASH 64
+#define X_APPLICATION 65
+#define X_POWER 66
+#define X_KP_EQUAL 67
+#define X_F13 68
+#define X_F14 69
+#define X_F15 6a
+#define X_F16 6b
+#define X_F17 6c
+#define X_F18 6d
+#define X_F19 6e
+#define X_F20 6f
+#define X_F21 70
+#define X_F22 71
+#define X_F23 72
+#define X_F24 73
+#define X_EXECUTE 74
+#define X_HELP 75
+#define X_MENU 76
+#define X_SELECT 77
+#define X_STOP 78
+#define X_AGAIN 79
+#define X_UNDO 7a
+#define X_CUT 7b
+#define X_COPY 7c
+#define X_PASTE 7d
+#define X_FIND 7e
+#define X__MUTE 7f
+#define X__VOLUP 80
+#define X__VOLDOWN 81
+#define X_LOCKING_CAPS 82
+#define X_LOCKING_NUM 83
+#define X_LOCKING_SCROLL 84
+#define X_KP_COMMA 85
+#define X_KP_EQUAL_AS400 86
+#define X_INT1 87
+#define X_INT2 88
+#define X_INT3 89
+#define X_INT4 8a
+#define X_INT5 8b
+#define X_INT6 8c
+#define X_INT7 8d
+#define X_INT8 8e
+#define X_INT9 8f
+#define X_LANG1 90
+#define X_LANG2 91
+#define X_LANG3 92
+#define X_LANG4 93
+#define X_LANG5 94
+#define X_LANG6 95
+#define X_LANG7 96
+#define X_LANG8 97
+#define X_LANG9 98
+#define X_ALT_ERASE 99
+#define X_SYSREQ 9a
+#define X_CANCEL 9b
+#define X_CLEAR 9c
+#define X_PRIOR 9d
+#define X_RETURN 9e
+#define X_SEPARATOR 9f
+#define X_OUT a0
+#define X_OPER a1
+#define X_CLEAR_AGAIN a2
+#define X_CRSEL a3
+#define X_EXSEL a4
+
+/* Modifiers */
+#define X_LCTRL e0
+#define X_LSHIFT e1
+#define X_LALT e2
+#define X_LGUI e3
+#define X_RCTRL e4
+#define X_RSHIFT e5
+#define X_RALT e6
+#define X_RGUI e7
+
+/* Media and Function keys */
+/* Generic Desktop Page (0x01) */
+#define X_SYSTEM_POWER a5
+#define X_SYSTEM_SLEEP a6
+#define X_SYSTEM_WAKE a7
+
+/* Consumer Page (0x0C) */
+#define X_AUDIO_MUTE a8
+#define X_AUDIO_VOL_UP a9
+#define X_AUDIO_VOL_DOWN aa
+#define X_MEDIA_NEXT_TRACK ab
+#define X_MEDIA_PREV_TRACK ac
+#define X_MEDIA_STOP ad
+#define X_MEDIA_PLAY_PAUSE ae
+#define X_MEDIA_SELECT af
+#define X_MEDIA_EJECT b0
+#define X_MAIL b1
+#define X_CALCULATOR b2
+#define X_MY_COMPUTER b3
+#define X_WWW_SEARCH b4
+#define X_WWW_HOME b5
+#define X_WWW_BACK b6
+#define X_WWW_FORWARD b7
+#define X_WWW_STOP b8
+#define X_WWW_REFRESH b9
+#define X_WWW_FAVORITES ba
+#define X_MEDIA_FAST_FORWARD bb
+#define X_MEDIA_REWIND bc
+#define X_BRIGHTNESS_UP bd
+#define X_BRIGHTNESS_DOWN be
+
+/* Mouse Buttons (unallocated range in HID spec) */
+#ifdef VIA_ENABLE
+#define X_MS_UP f0
+#define X_MS_DOWN f1
+#define X_MS_LEFT f2
+#define X_MS_RIGHT f3
+#define X_MS_BTN1 f4
+#define X_MS_BTN2 f5
+#define X_MS_BTN3 f6
+#define X_MS_BTN4 f7
+#define X_MS_BTN5 f8
+#define X_MS_BTN6 f8
+#define X_MS_BTN7 f8
+#define X_MS_BTN8 f8
+#else
+#define X_MS_UP ed
+#define X_MS_DOWN ee
+#define X_MS_LEFT ef
+#define X_MS_RIGHT f0
+#define X_MS_BTN1 f1
+#define X_MS_BTN2 f2
+#define X_MS_BTN3 f3
+#define X_MS_BTN4 f4
+#define X_MS_BTN5 f5
+#define X_MS_BTN6 f6
+#define X_MS_BTN7 f7
+#define X_MS_BTN8 f8
+#endif
+#define X_MS_WH_UP f9
+#define X_MS_WH_DOWN fa
+#define X_MS_WH_LEFT fb
+#define X_MS_WH_RIGHT fc
+#define X_MS_ACCEL0 fd
+#define X_MS_ACCEL1 fe
+#define X_MS_ACCEL2 ff
+
+// Send string macros
+#define STRINGIZE(z) #z
+#define ADD_SLASH_X(y) STRINGIZE(\x##y)
+#define SYMBOL_STR(x) ADD_SLASH_X(x)
+
+#define SS_QMK_PREFIX 1
+
+#define SS_TAP_CODE 1
+#define SS_DOWN_CODE 2
+#define SS_UP_CODE 3
+#define SS_DELAY_CODE 4
+
+#define SS_TAP(keycode) "\1\1" SYMBOL_STR(keycode)
+#define SS_DOWN(keycode) "\1\2" SYMBOL_STR(keycode)
+#define SS_UP(keycode) "\1\3" SYMBOL_STR(keycode)
+#define SS_DELAY(msecs) "\1\4" STRINGIZE(msecs) "|"
+
+// `string` arguments must not be parenthesized
+#define SS_LCTL(string) SS_DOWN(X_LCTL) string SS_UP(X_LCTL)
+#define SS_LSFT(string) SS_DOWN(X_LSFT) string SS_UP(X_LSFT)
+#define SS_LALT(string) SS_DOWN(X_LALT) string SS_UP(X_LALT)
+#define SS_LGUI(string) SS_DOWN(X_LGUI) string SS_UP(X_LGUI)
+#define SS_LOPT(string) SS_LALT(string)
+#define SS_LCMD(string) SS_LGUI(string)
+#define SS_LWIN(string) SS_LGUI(string)
+
+#define SS_RCTL(string) SS_DOWN(X_RCTL) string SS_UP(X_RCTL)
+#define SS_RSFT(string) SS_DOWN(X_RSFT) string SS_UP(X_RSFT)
+#define SS_RALT(string) SS_DOWN(X_RALT) string SS_UP(X_RALT)
+#define SS_RGUI(string) SS_DOWN(X_RGUI) string SS_UP(X_RGUI)
+#define SS_ALGR(string) SS_RALT(string)
+#define SS_ROPT(string) SS_RALT(string)
+#define SS_RCMD(string) SS_RGUI(string)
+#define SS_RWIN(string) SS_RGUI(string)
+
+// DEPRECATED
+#define SS_LCTRL(string) SS_LCTL(string)
diff --git a/quantum/send_string_keycodes.h b/quantum/send_string_keycodes.h
deleted file mode 100644
index b35bf66b7b..0000000000
--- a/quantum/send_string_keycodes.h
+++ /dev/null
@@ -1,505 +0,0 @@
-/* Copyright 2019
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-// clang-format off
-
-/* Punctuation */
-#define X_ENT X_ENTER
-#define X_ESC X_ESCAPE
-#define X_BSPC X_BACKSPACE
-#define X_SPC X_SPACE
-#define X_MINS X_MINUS
-#define X_EQL X_EQUAL
-#define X_LBRC X_LEFT_BRACKET
-#define X_RBRC X_RIGHT_BRACKET
-#define X_BSLS X_BACKSLASH
-#define X_NUHS X_NONUS_HASH
-#define X_SCLN X_SEMICOLON
-#define X_QUOT X_QUOTE
-#define X_GRV X_GRAVE
-#define X_COMM X_COMMA
-#define X_SLSH X_SLASH
-#define X_NUBS X_NONUS_BACKSLASH
-
-/* Lock Keys */
-#define X_CAPS X_CAPS_LOCK
-#define X_SCRL X_SCROLL_LOCK
-#define X_NUM X_NUM_LOCK
-#define X_LCAP X_LOCKING_CAPS_LOCK
-#define X_LNUM X_LOCKING_NUM_LOCK
-#define X_LSCR X_LOCKING_SCROLL_LOCK
-
-/* Commands */
-#define X_PSCR X_PRINT_SCREEN
-#define X_PAUS X_PAUSE
-#define X_BRK X_PAUSE
-#define X_INS X_INSERT
-#define X_PGUP X_PAGE_UP
-#define X_DEL X_DELETE
-#define X_PGDN X_PAGE_DOWN
-#define X_RGHT X_RIGHT
-#define X_APP X_APPLICATION
-#define X_EXEC X_EXECUTE
-#define X_SLCT X_SELECT
-#define X_AGIN X_AGAIN
-#define X_PSTE X_PASTE
-#define X_ERAS X_ALTERNATE_ERASE
-#define X_SYRQ X_SYSTEM_REQUEST
-#define X_CNCL X_CANCEL
-#define X_CLR X_CLEAR
-#define X_PRIR X_PRIOR
-#define X_RETN X_RETURN
-#define X_SEPR X_SEPARATOR
-#define X_CLAG X_CLEAR_AGAIN
-#define X_CRSL X_CRSEL
-#define X_EXSL X_EXSEL
-
-/* Keypad */
-#define X_PSLS X_KP_SLASH
-#define X_PAST X_KP_ASTERISK
-#define X_PMNS X_KP_MINUS
-#define X_PPLS X_KP_PLUS
-#define X_PENT X_KP_ENTER
-#define X_P1 X_KP_1
-#define X_P2 X_KP_2
-#define X_P3 X_KP_3
-#define X_P4 X_KP_4
-#define X_P5 X_KP_5
-#define X_P6 X_KP_6
-#define X_P7 X_KP_7
-#define X_P8 X_KP_8
-#define X_P9 X_KP_9
-#define X_P0 X_KP_0
-#define X_PDOT X_KP_DOT
-#define X_PEQL X_KP_EQUAL
-#define X_PCMM X_KP_COMMA
-
-/* Language Specific */
-#define X_INT1 X_INTERNATIONAL_1
-#define X_INT2 X_INTERNATIONAL_2
-#define X_INT3 X_INTERNATIONAL_3
-#define X_INT4 X_INTERNATIONAL_4
-#define X_INT5 X_INTERNATIONAL_5
-#define X_INT6 X_INTERNATIONAL_6
-#define X_INT7 X_INTERNATIONAL_7
-#define X_INT8 X_INTERNATIONAL_8
-#define X_INT9 X_INTERNATIONAL_9
-#define X_LNG1 X_LANGUAGE_1
-#define X_LNG2 X_LANGUAGE_2
-#define X_LNG3 X_LANGUAGE_3
-#define X_LNG4 X_LANGUAGE_4
-#define X_LNG5 X_LANGUAGE_5
-#define X_LNG6 X_LANGUAGE_6
-#define X_LNG7 X_LANGUAGE_7
-#define X_LNG8 X_LANGUAGE_8
-#define X_LNG9 X_LANGUAGE_9
-
-/* Modifiers */
-#define X_LCTL X_LEFT_CTRL
-#define X_LSFT X_LEFT_SHIFT
-#define X_LALT X_LEFT_ALT
-#define X_LOPT X_LEFT_ALT
-#define X_LGUI X_LEFT_GUI
-#define X_LCMD X_LEFT_GUI
-#define X_LWIN X_LEFT_GUI
-#define X_RCTL X_RIGHT_CTRL
-#define X_RSFT X_RIGHT_SHIFT
-#define X_RALT X_RIGHT_ALT
-#define X_ALGR X_RIGHT_ALT
-#define X_ROPT X_RIGHT_ALT
-#define X_RGUI X_RIGHT_GUI
-#define X_RCMD X_RIGHT_GUI
-#define X_RWIN X_RIGHT_GUI
-
-/* Generic Desktop Page (0x01) */
-#define X_PWR X_SYSTEM_POWER
-#define X_SLEP X_SYSTEM_SLEEP
-#define X_WAKE X_SYSTEM_WAKE
-
-/* Consumer Page (0x0C) */
-#define X_MUTE X_AUDIO_MUTE
-#define X_VOLU X_AUDIO_VOL_UP
-#define X_VOLD X_AUDIO_VOL_DOWN
-#define X_MNXT X_MEDIA_NEXT_TRACK
-#define X_MPRV X_MEDIA_PREV_TRACK
-#define X_MSTP X_MEDIA_STOP
-#define X_MPLY X_MEDIA_PLAY_PAUSE
-#define X_MSEL X_MEDIA_SELECT
-#define X_EJCT X_MEDIA_EJECT
-#define X_CALC X_CALCULATOR
-#define X_MYCM X_MY_COMPUTER
-#define X_WSCH X_WWW_SEARCH
-#define X_WHOM X_WWW_HOME
-#define X_WBAK X_WWW_BACK
-#define X_WFWD X_WWW_FORWARD
-#define X_WSTP X_WWW_STOP
-#define X_WREF X_WWW_REFRESH
-#define X_WFAV X_WWW_FAVORITES
-#define X_MFFD X_MEDIA_FAST_FORWARD
-#define X_MRWD X_MEDIA_REWIND
-#define X_BRIU X_BRIGHTNESS_UP
-#define X_BRID X_BRIGHTNESS_DOWN
-
-/* System Specific */
-#define X_BRMU X_PAUSE
-#define X_BRMD X_SCROLL_LOCK
-
-/* Mouse Keys */
-#define X_MS_U X_MS_UP
-#define X_MS_D X_MS_DOWN
-#define X_MS_L X_MS_LEFT
-#define X_MS_R X_MS_RIGHT
-#define X_BTN1 X_MS_BTN1
-#define X_BTN2 X_MS_BTN2
-#define X_BTN3 X_MS_BTN3
-#define X_BTN4 X_MS_BTN4
-#define X_BTN5 X_MS_BTN5
-#define X_BTN6 X_MS_BTN6
-#define X_BTN7 X_MS_BTN7
-#define X_BTN8 X_MS_BTN8
-#define X_WH_U X_MS_WH_UP
-#define X_WH_D X_MS_WH_DOWN
-#define X_WH_L X_MS_WH_LEFT
-#define X_WH_R X_MS_WH_RIGHT
-#define X_ACL0 X_MS_ACCEL0
-#define X_ACL1 X_MS_ACCEL1
-#define X_ACL2 X_MS_ACCEL2
-
-/* Keyboard/Keypad Page (0x07) */
-#define X_A 04
-#define X_B 05
-#define X_C 06
-#define X_D 07
-#define X_E 08
-#define X_F 09
-#define X_G 0a
-#define X_H 0b
-#define X_I 0c
-#define X_J 0d
-#define X_K 0e
-#define X_L 0f
-#define X_M 10
-#define X_N 11
-#define X_O 12
-#define X_P 13
-#define X_Q 14
-#define X_R 15
-#define X_S 16
-#define X_T 17
-#define X_U 18
-#define X_V 19
-#define X_W 1a
-#define X_X 1b
-#define X_Y 1c
-#define X_Z 1d
-#define X_1 1e
-#define X_2 1f
-#define X_3 20
-#define X_4 21
-#define X_5 22
-#define X_6 23
-#define X_7 24
-#define X_8 25
-#define X_9 26
-#define X_0 27
-#define X_ENTER 28
-#define X_ESCAPE 29
-#define X_BACKSPACE 2a
-#define X_TAB 2b
-#define X_SPACE 2c
-#define X_MINUS 2d
-#define X_EQUAL 2e
-#define X_LEFT_BRACKET 2f
-#define X_RIGHT_BRACKET 30
-#define X_BACKSLASH 31
-#define X_NONUS_HASH 32
-#define X_SEMICOLON 33
-#define X_QUOTE 34
-#define X_GRAVE 35
-#define X_COMMA 36
-#define X_DOT 37
-#define X_SLASH 38
-#define X_CAPS_LOCK 39
-#define X_F1 3a
-#define X_F2 3b
-#define X_F3 3c
-#define X_F4 3d
-#define X_F5 3e
-#define X_F6 3f
-#define X_F7 40
-#define X_F8 41
-#define X_F9 42
-#define X_F10 43
-#define X_F11 44
-#define X_F12 45
-#define X_PRINT_SCREEN 46
-#define X_SCROLL_LOCK 47
-#define X_PAUSE 48
-#define X_INSERT 49
-#define X_HOME 4a
-#define X_PAGE_UP 4b
-#define X_DELETE 4c
-#define X_END 4d
-#define X_PAGE_DOWN 4e
-#define X_RIGHT 4f
-#define X_LEFT 50
-#define X_DOWN 51
-#define X_UP 52
-#define X_NUM_LOCK 53
-#define X_KP_SLASH 54
-#define X_KP_ASTERISK 55
-#define X_KP_MINUS 56
-#define X_KP_PLUS 57
-#define X_KP_ENTER 58
-#define X_KP_1 59
-#define X_KP_2 5a
-#define X_KP_3 5b
-#define X_KP_4 5c
-#define X_KP_5 5d
-#define X_KP_6 5e
-#define X_KP_7 5f
-#define X_KP_8 60
-#define X_KP_9 61
-#define X_KP_0 62
-#define X_KP_DOT 63
-#define X_NONUS_BACKSLASH 64
-#define X_APPLICATION 65
-#define X_KB_POWER 66
-#define X_KP_EQUAL 67
-#define X_F13 68
-#define X_F14 69
-#define X_F15 6a
-#define X_F16 6b
-#define X_F17 6c
-#define X_F18 6d
-#define X_F19 6e
-#define X_F20 6f
-#define X_F21 70
-#define X_F22 71
-#define X_F23 72
-#define X_F24 73
-#define X_EXECUTE 74
-#define X_HELP 75
-#define X_MENU 76
-#define X_SELECT 77
-#define X_STOP 78
-#define X_AGAIN 79
-#define X_UNDO 7a
-#define X_CUT 7b
-#define X_COPY 7c
-#define X_PASTE 7d
-#define X_FIND 7e
-#define X_KB_MUTE 7f
-#define X_KB_VOLUME_UP 80
-#define X_KB_VOLUME_DOWN 81
-#define X_LOCKING_CAPS_LOCK 82
-#define X_LOCKING_NUM_LOCK 83
-#define X_LOCKING_SCROLL_LOCK 84
-#define X_KP_COMMA 85
-#define X_KP_EQUAL_AS400 86
-#define X_INTERNATIONAL_1 87
-#define X_INTERNATIONAL_2 88
-#define X_INTERNATIONAL_3 89
-#define X_INTERNATIONAL_4 8a
-#define X_INTERNATIONAL_5 8b
-#define X_INTERNATIONAL_6 8c
-#define X_INTERNATIONAL_7 8d
-#define X_INTERNATIONAL_8 8e
-#define X_INTERNATIONAL_9 8f
-#define X_LANGUAGE_1 90
-#define X_LANGUAGE_2 91
-#define X_LANGUAGE_3 92
-#define X_LANGUAGE_4 93
-#define X_LANGUAGE_5 94
-#define X_LANGUAGE_6 95
-#define X_LANGUAGE_7 96
-#define X_LANGUAGE_8 97
-#define X_LANGUAGE_9 98
-#define X_ALTERNATE_ERASE 99
-#define X_SYSTEM_REQUEST 9a
-#define X_CANCEL 9b
-#define X_CLEAR 9c
-#define X_PRIOR 9d
-#define X_RETURN 9e
-#define X_SEPARATOR 9f
-#define X_OUT a0
-#define X_OPER a1
-#define X_CLEAR_AGAIN a2
-#define X_CRSEL a3
-#define X_EXSEL a4
-
-/* Modifiers */
-#define X_LEFT_CTRL e0
-#define X_LEFT_SHIFT e1
-#define X_LEFT_ALT e2
-#define X_LEFT_GUI e3
-#define X_RIGHT_CTRL e4
-#define X_RIGHT_SHIFT e5
-#define X_RIGHT_ALT e6
-#define X_RIGHT_GUI e7
-
-/* Media and Function keys */
-/* Generic Desktop Page (0x01) */
-#define X_SYSTEM_POWER a5
-#define X_SYSTEM_SLEEP a6
-#define X_SYSTEM_WAKE a7
-
-/* Consumer Page (0x0C) */
-#define X_AUDIO_MUTE a8
-#define X_AUDIO_VOL_UP a9
-#define X_AUDIO_VOL_DOWN aa
-#define X_MEDIA_NEXT_TRACK ab
-#define X_MEDIA_PREV_TRACK ac
-#define X_MEDIA_STOP ad
-#define X_MEDIA_PLAY_PAUSE ae
-#define X_MEDIA_SELECT af
-#define X_MEDIA_EJECT b0
-#define X_MAIL b1
-#define X_CALCULATOR b2
-#define X_MY_COMPUTER b3
-#define X_WWW_SEARCH b4
-#define X_WWW_HOME b5
-#define X_WWW_BACK b6
-#define X_WWW_FORWARD b7
-#define X_WWW_STOP b8
-#define X_WWW_REFRESH b9
-#define X_WWW_FAVORITES ba
-#define X_MEDIA_FAST_FORWARD bb
-#define X_MEDIA_REWIND bc
-#define X_BRIGHTNESS_UP bd
-#define X_BRIGHTNESS_DOWN be
-
-/* Mouse Buttons (unallocated range in HID spec) */
-#ifdef VIA_ENABLE
-#define X_MS_UP f0
-#define X_MS_DOWN f1
-#define X_MS_LEFT f2
-#define X_MS_RIGHT f3
-#define X_MS_BTN1 f4
-#define X_MS_BTN2 f5
-#define X_MS_BTN3 f6
-#define X_MS_BTN4 f7
-#define X_MS_BTN5 f8
-#define X_MS_BTN6 f8
-#define X_MS_BTN7 f8
-#define X_MS_BTN8 f8
-#else
-#define X_MS_UP ed
-#define X_MS_DOWN ee
-#define X_MS_LEFT ef
-#define X_MS_RIGHT f0
-#define X_MS_BTN1 f1
-#define X_MS_BTN2 f2
-#define X_MS_BTN3 f3
-#define X_MS_BTN4 f4
-#define X_MS_BTN5 f5
-#define X_MS_BTN6 f6
-#define X_MS_BTN7 f7
-#define X_MS_BTN8 f8
-#endif
-#define X_MS_WH_UP f9
-#define X_MS_WH_DOWN fa
-#define X_MS_WH_LEFT fb
-#define X_MS_WH_RIGHT fc
-#define X_MS_ACCEL0 fd
-#define X_MS_ACCEL1 fe
-#define X_MS_ACCEL2 ff
-
-// Send string macros
-#define STRINGIZE(z) #z
-#define ADD_SLASH_X(y) STRINGIZE(\x##y)
-#define SYMBOL_STR(x) ADD_SLASH_X(x)
-
-#define SS_QMK_PREFIX 1
-
-#define SS_TAP_CODE 1
-#define SS_DOWN_CODE 2
-#define SS_UP_CODE 3
-#define SS_DELAY_CODE 4
-
-#define SS_TAP(keycode) "\1\1" SYMBOL_STR(keycode)
-#define SS_DOWN(keycode) "\1\2" SYMBOL_STR(keycode)
-#define SS_UP(keycode) "\1\3" SYMBOL_STR(keycode)
-#define SS_DELAY(msecs) "\1\4" STRINGIZE(msecs) "|"
-
-// `string` arguments must not be parenthesized
-#define SS_LCTL(string) SS_DOWN(X_LCTL) string SS_UP(X_LCTL)
-#define SS_LSFT(string) SS_DOWN(X_LSFT) string SS_UP(X_LSFT)
-#define SS_LALT(string) SS_DOWN(X_LALT) string SS_UP(X_LALT)
-#define SS_LGUI(string) SS_DOWN(X_LGUI) string SS_UP(X_LGUI)
-#define SS_LCMD(string) SS_LGUI(string)
-#define SS_LWIN(string) SS_LGUI(string)
-
-#define SS_RCTL(string) SS_DOWN(X_RCTL) string SS_UP(X_RCTL)
-#define SS_RSFT(string) SS_DOWN(X_RSFT) string SS_UP(X_RSFT)
-#define SS_RALT(string) SS_DOWN(X_RALT) string SS_UP(X_RALT)
-#define SS_RGUI(string) SS_DOWN(X_RGUI) string SS_UP(X_RGUI)
-#define SS_ALGR(string) SS_RALT(string)
-#define SS_RCMD(string) SS_RGUI(string)
-#define SS_RWIN(string) SS_RGUI(string)
-
-// DEPRECATED
-#define X_BSPACE X_BACKSPACE
-#define X_LBRACKET X_LEFT_BRACKET
-#define X_RBRACKET X_RIGHT_BRACKET
-#define X_BSLASH X_BACKSLASH
-#define X_SCOLON X_SEMICOLON
-#define X_CAPSLOCK X_CAPS_LOCK
-#define X_PSCREEN X_PRINT_SCREEN
-#define X_SCROLLLOCK X_SCROLL_LOCK
-#define X_PGDOWN X_PAGE_DOWN
-#define X_NUMLOCK X_NUM_LOCK
-#define X_NONUS_BSLASH X_NONUS_BACKSLASH
-#define X_POWER X_KB_POWER
-#define X__MUTE X_KB_MUTE
-#define X__VOLUP X_KB_VOLUME_UP
-#define X__VOLDOWN X_KB_VOLUME_DOWN
-#define X_LOCKING_CAPS X_LOCKING_CAPS_LOCK
-#define X_LOCKING_NUM X_LOCKING_NUM_LOCK
-#define X_LOCKING_SCROLL X_LOCKING_SCROLL_LOCK
-#define X_LANG1 X_LANGUAGE_1
-#define X_LANG2 X_LANGUAGE_2
-#define X_LANG3 X_LANGUAGE_3
-#define X_LANG4 X_LANGUAGE_4
-#define X_LANG5 X_LANGUAGE_5
-#define X_LANG6 X_LANGUAGE_6
-#define X_LANG7 X_LANGUAGE_7
-#define X_LANG8 X_LANGUAGE_8
-#define X_LANG9 X_LANGUAGE_9
-#define X_ALT_ERASE X_ALTERNATE_ERASE
-#define X_SYSREQ X_SYSTEM_REQUEST
-
-#define X_LCTRL X_LEFT_CTRL
-#define X_LSHIFT X_LEFT_SHIFT
-#define X_RCTRL X_RIGHT_CTRL
-#define X_RSHIFT X_RIGHT_SHIFT
-
-#define X_ZKHK X_GRAVE
-#define X_RO X_INTERNATIONAL_1
-#define X_KANA X_INTERNATIONAL_2
-#define X_JYEN X_INTERNATIONAL_3
-#define X_HENK X_INTERNATIONAL_4
-#define X_MHEN X_INTERNATIONAL_5
-#define X_HAEN X_LANGUAGE_1
-#define X_HANJ X_LANGUAGE_2
-
-#define X_CLCK X_CAPS_LOCK
-#define X_SLCK X_SCROLL_LOCK
-#define X_NLCK X_NUM_LOCK
-
-#define SS_LCTRL(string) SS_LCTL(string)
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c
index 7d50adf758..4892b7f8d8 100644
--- a/quantum/split_common/split_util.c
+++ b/quantum/split_common/split_util.c
@@ -57,8 +57,9 @@ static uint8_t connection_errors = 0;
volatile bool isLeftHand = true;
#if defined(SPLIT_USB_DETECT)
+_Static_assert((SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL) <= UINT16_MAX, "Please lower SPLIT_USB_TIMEOUT and/or increase SPLIT_USB_TIMEOUT_POLL.");
static bool usbIsActive(void) {
- for (uint8_t i = 0; i < (SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL); i++) {
+ for (uint16_t i = 0; i < (SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL); i++) {
// This will return true if a USB connection has been established
if (usb_connected_state()) {
return true;
@@ -93,7 +94,6 @@ static uint8_t peek_matrix_intersection(pin_t out_pin, pin_t in_pin) {
__attribute__((weak)) bool is_keyboard_left(void) {
#if defined(SPLIT_HAND_PIN)
// Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand
- setPinInput(SPLIT_HAND_PIN);
# ifdef SPLIT_HAND_PIN_LOW_IS_LEFT
return !readPin(SPLIT_HAND_PIN);
# else
@@ -132,6 +132,14 @@ __attribute__((weak)) bool is_keyboard_master(void) {
// this code runs before the keyboard is fully initialized
void split_pre_init(void) {
+#if defined(SPLIT_HAND_PIN)
+ setPinInput(SPLIT_HAND_PIN);
+ wait_us(100);
+#elif defined(EE_HANDS)
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+#endif
isLeftHand = is_keyboard_left();
#if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c
index 9e3df534e3..719068908f 100644
--- a/quantum/split_common/transactions.c
+++ b/quantum/split_common/transactions.c
@@ -694,7 +694,7 @@ split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = {
#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
[PUT_RPC_INFO] = trans_initiator2target_initializer_cb(rpc_info, slave_rpc_info_callback),
[PUT_RPC_REQ_DATA] = trans_initiator2target_initializer(rpc_m2s_buffer),
- [EXECUTE_RPC] = trans_initiator2target_initializer_cb(rpc_info.transaction_id, slave_rpc_exec_callback),
+ [EXECUTE_RPC] = trans_initiator2target_initializer_cb(rpc_info.payload.transaction_id, slave_rpc_exec_callback),
[GET_RPC_RESP_DATA] = trans_target2initiator_initializer(rpc_s2m_buffer),
#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
};
@@ -760,7 +760,8 @@ bool transaction_rpc_exec(int8_t transaction_id, uint8_t initiator2target_buffer
if (target2initiator_buffer_size > RPC_S2M_BUFFER_SIZE) return false;
// Prepare the metadata block
- rpc_sync_info_t info = {.transaction_id = transaction_id, .m2s_length = initiator2target_buffer_size, .s2m_length = target2initiator_buffer_size};
+ rpc_sync_info_t info = {.payload = {.transaction_id = transaction_id, .m2s_length = initiator2target_buffer_size, .s2m_length = target2initiator_buffer_size}};
+ info.checksum = crc8(&info.payload, sizeof(info.payload));
// Make sure the local side knows that we're not sending the full block of data
split_transaction_table[PUT_RPC_REQ_DATA].initiator2target_buffer_size = initiator2target_buffer_size;
@@ -791,18 +792,23 @@ void slave_rpc_info_callback(uint8_t initiator2target_buffer_size, const void *i
// Ignore the args -- the `split_shmem` already has the info, we just need to act upon it.
// We must keep the `split_transaction_table` non-const, so that it is able to be modified at runtime.
- split_transaction_table[PUT_RPC_REQ_DATA].initiator2target_buffer_size = split_shmem->rpc_info.m2s_length;
- split_transaction_table[GET_RPC_RESP_DATA].target2initiator_buffer_size = split_shmem->rpc_info.s2m_length;
+ split_transaction_table[PUT_RPC_REQ_DATA].initiator2target_buffer_size = split_shmem->rpc_info.payload.m2s_length;
+ split_transaction_table[GET_RPC_RESP_DATA].target2initiator_buffer_size = split_shmem->rpc_info.payload.s2m_length;
}
void slave_rpc_exec_callback(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer) {
// We can assume that the buffer lengths are correctly set, now, given that sequentially the rpc_info callback was already executed.
// Go through the rpc_info and execute _that_ transaction's callback, with the scratch buffers as inputs.
- int8_t transaction_id = split_shmem->rpc_info.transaction_id;
+ // As a safety precaution we check that the received payload matches its checksum first.
+ if (crc8(&split_shmem->rpc_info.payload, sizeof(split_shmem->rpc_info.payload)) != split_shmem->rpc_info.checksum) {
+ return;
+ }
+
+ int8_t transaction_id = split_shmem->rpc_info.payload.transaction_id;
if (transaction_id < NUM_TOTAL_TRANSACTIONS) {
split_transaction_desc_t *trans = &split_transaction_table[transaction_id];
if (trans->slave_callback) {
- trans->slave_callback(split_shmem->rpc_info.m2s_length, split_shmem->rpc_m2s_buffer, split_shmem->rpc_info.s2m_length, split_shmem->rpc_s2m_buffer);
+ trans->slave_callback(split_shmem->rpc_info.payload.m2s_length, split_shmem->rpc_m2s_buffer, split_shmem->rpc_info.payload.s2m_length, split_shmem->rpc_s2m_buffer);
}
}
}
diff --git a/quantum/split_common/transport.h b/quantum/split_common/transport.h
index e62679990a..06778ad14a 100644
--- a/quantum/split_common/transport.h
+++ b/quantum/split_common/transport.h
@@ -116,9 +116,12 @@ typedef struct _split_slave_pointing_sync_t {
#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
typedef struct _rpc_sync_info_t {
- int8_t transaction_id;
- uint8_t m2s_length;
- uint8_t s2m_length;
+ uint8_t checksum;
+ struct {
+ int8_t transaction_id;
+ uint8_t m2s_length;
+ uint8_t s2m_length;
+ } payload;
} rpc_sync_info_t;
#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
diff --git a/quantum/via.c b/quantum/via.c
index 320bd5546d..37e2046a10 100644
--- a/quantum/via.c
+++ b/quantum/via.c
@@ -64,6 +64,7 @@ void via_qmk_rgblight_get_value(uint8_t *data);
#endif
#if defined(VIA_QMK_RGB_MATRIX_ENABLE)
+# include <lib/lib8tion/lib8tion.h>
void via_qmk_rgb_matrix_set_value(uint8_t *data);
void via_qmk_rgb_matrix_get_value(uint8_t *data);
void eeconfig_update_rgb_matrix(void);
@@ -396,6 +397,18 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
dynamic_keymap_set_buffer(offset, size, &command_data[3]);
break;
}
+#ifdef ENCODER_MAP_ENABLE
+ case id_dynamic_keymap_get_encoder: {
+ uint16_t keycode = dynamic_keymap_get_encoder(command_data[0], command_data[1], command_data[2] != 0);
+ command_data[3] = keycode >> 8;
+ command_data[4] = keycode & 0xFF;
+ break;
+ }
+ case id_dynamic_keymap_set_encoder: {
+ dynamic_keymap_set_encoder(command_data[0], command_data[1], command_data[2] != 0, (command_data[3] << 8) | command_data[4]);
+ break;
+ }
+#endif
default: {
// The command ID is not known
// Return the unhandled state
@@ -421,7 +434,7 @@ void via_qmk_backlight_get_value(uint8_t *data) {
switch (*value_id) {
case id_qmk_backlight_brightness: {
// level / BACKLIGHT_LEVELS * 255
- value_data[0] = ((uint16_t)get_backlight_level()) * 255 / BACKLIGHT_LEVELS;
+ value_data[0] = ((uint16_t)get_backlight_level() * UINT8_MAX) / BACKLIGHT_LEVELS;
break;
}
case id_qmk_backlight_effect: {
@@ -441,7 +454,7 @@ void via_qmk_backlight_set_value(uint8_t *data) {
switch (*value_id) {
case id_qmk_backlight_brightness: {
// level / 255 * BACKLIGHT_LEVELS
- backlight_level_noeeprom(((uint16_t)value_data[0]) * BACKLIGHT_LEVELS / 255);
+ backlight_level_noeeprom(((uint16_t)value_data[0] * BACKLIGHT_LEVELS) / UINT8_MAX);
break;
}
case id_qmk_backlight_effect: {
@@ -460,13 +473,16 @@ void via_qmk_backlight_set_value(uint8_t *data) {
#endif // #if defined(VIA_QMK_BACKLIGHT_ENABLE)
#if defined(VIA_QMK_RGBLIGHT_ENABLE)
+# ifndef RGBLIGHT_LIMIT_VAL
+# define RGBLIGHT_LIMIT_VAL 255
+# endif
void via_qmk_rgblight_get_value(uint8_t *data) {
uint8_t *value_id = &(data[0]);
uint8_t *value_data = &(data[1]);
switch (*value_id) {
case id_qmk_rgblight_brightness: {
- value_data[0] = rgblight_get_val();
+ value_data[0] = ((uint16_t)rgblight_get_val() * UINT8_MAX) / RGBLIGHT_LIMIT_VAL;
break;
}
case id_qmk_rgblight_effect: {
@@ -490,7 +506,7 @@ void via_qmk_rgblight_set_value(uint8_t *data) {
uint8_t *value_data = &(data[1]);
switch (*value_id) {
case id_qmk_rgblight_brightness: {
- rgblight_sethsv_noeeprom(rgblight_get_hue(), rgblight_get_sat(), value_data[0]);
+ rgblight_sethsv_noeeprom(rgblight_get_hue(), rgblight_get_sat(), ((uint16_t)value_data[0] * RGBLIGHT_LIMIT_VAL) / UINT8_MAX);
break;
}
case id_qmk_rgblight_effect: {
@@ -517,6 +533,11 @@ void via_qmk_rgblight_set_value(uint8_t *data) {
#if defined(VIA_QMK_RGB_MATRIX_ENABLE)
+# if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
+# undef RGB_MATRIX_MAXIMUM_BRIGHTNESS
+# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
+# endif
+
// VIA supports only 4 discrete values for effect speed; map these to some
// useful speed values for RGB Matrix.
enum speed_values {
@@ -557,7 +578,7 @@ void via_qmk_rgb_matrix_get_value(uint8_t *data) {
uint8_t *value_data = &(data[1]);
switch (*value_id) {
case id_qmk_rgblight_brightness:
- value_data[0] = rgb_matrix_get_val();
+ value_data[0] = ((uint16_t)rgb_matrix_get_val() * UINT8_MAX) / RGB_MATRIX_MAXIMUM_BRIGHTNESS;
break;
case id_qmk_rgblight_effect:
value_data[0] = rgb_matrix_get_mode();
@@ -577,7 +598,7 @@ void via_qmk_rgb_matrix_set_value(uint8_t *data) {
uint8_t *value_data = &(data[1]);
switch (*value_id) {
case id_qmk_rgblight_brightness:
- rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), value_data[0]);
+ rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), scale8(value_data[0], RGB_MATRIX_MAXIMUM_BRIGHTNESS));
break;
case id_qmk_rgblight_effect:
rgb_matrix_mode_noeeprom(value_data[0]);
diff --git a/quantum/via.h b/quantum/via.h
index ac29a58902..558ae95de4 100644
--- a/quantum/via.h
+++ b/quantum/via.h
@@ -54,9 +54,11 @@
# define VIA_EEPROM_CUSTOM_CONFIG_SIZE 0
#endif
+#define VIA_EEPROM_CONFIG_END (VIA_EEPROM_CUSTOM_CONFIG_ADDR + VIA_EEPROM_CUSTOM_CONFIG_SIZE)
+
// This is changed only when the command IDs change,
// so VIA Configurator can detect compatible firmware.
-#define VIA_PROTOCOL_VERSION 0x0009
+#define VIA_PROTOCOL_VERSION 0x000A
enum via_command_id {
id_get_protocol_version = 0x01, // always 0x01
@@ -78,6 +80,8 @@ enum via_command_id {
id_dynamic_keymap_get_layer_count = 0x11,
id_dynamic_keymap_get_buffer = 0x12,
id_dynamic_keymap_set_buffer = 0x13,
+ id_dynamic_keymap_get_encoder = 0x14,
+ id_dynamic_keymap_set_encoder = 0x15,
id_unhandled = 0xFF,
};
diff --git a/quantum/wear_leveling/tests/backing_mocks.cpp b/quantum/wear_leveling/tests/backing_mocks.cpp
new file mode 100644
index 0000000000..1dbb26f8e7
--- /dev/null
+++ b/quantum/wear_leveling/tests/backing_mocks.cpp
@@ -0,0 +1,154 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "backing_mocks.hpp"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Backing Store Mock implementation
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void MockBackingStore::reset_instance() {
+ for (auto&& e : backing_storage)
+ e.reset();
+
+ locked = true;
+
+ backing_erasure_count = 0;
+ backing_max_write_count = 0;
+ backing_total_write_count = 0;
+
+ backing_init_invoke_count = 0;
+ backing_unlock_invoke_count = 0;
+ backing_erase_invoke_count = 0;
+ backing_write_invoke_count = 0;
+ backing_lock_invoke_count = 0;
+
+ init_success_callback = [](std::uint64_t) { return true; };
+ erase_success_callback = [](std::uint64_t) { return true; };
+ unlock_success_callback = [](std::uint64_t) { return true; };
+ write_success_callback = [](std::uint64_t, std::uint32_t) { return true; };
+ lock_success_callback = [](std::uint64_t) { return true; };
+
+ write_log.clear();
+}
+
+bool MockBackingStore::init(void) {
+ ++backing_init_invoke_count;
+
+ if (init_success_callback) {
+ return init_success_callback(backing_init_invoke_count);
+ }
+ return true;
+}
+
+bool MockBackingStore::unlock(void) {
+ ++backing_unlock_invoke_count;
+
+ EXPECT_TRUE(is_locked()) << "Attempted to unlock but was not locked";
+ locked = false;
+
+ if (unlock_success_callback) {
+ return unlock_success_callback(backing_unlock_invoke_count);
+ }
+ return true;
+}
+
+bool MockBackingStore::erase(void) {
+ ++backing_erase_invoke_count;
+
+ // Erase each slot
+ for (std::size_t i = 0; i < backing_storage.size(); ++i) {
+ // Drop out of erase early with failure if we need to
+ if (erase_success_callback && !erase_success_callback(backing_erase_invoke_count)) {
+ append_log(true);
+ return false;
+ }
+
+ backing_storage[i].erase();
+ }
+
+ // Keep track of the erase in the write log so that we can verify during tests
+ append_log(true);
+
+ ++backing_erasure_count;
+ return true;
+}
+
+bool MockBackingStore::write(uint32_t address, backing_store_int_t value) {
+ ++backing_write_invoke_count;
+
+ // precondition: value's buffer size already matches BACKING_STORE_WRITE_SIZE
+ EXPECT_TRUE(address % BACKING_STORE_WRITE_SIZE == 0) << "Supplied address was not aligned with the backing store integral size";
+ EXPECT_TRUE(address + BACKING_STORE_WRITE_SIZE <= WEAR_LEVELING_BACKING_SIZE) << "Address would result of out-of-bounds access";
+ EXPECT_FALSE(is_locked()) << "Write was attempted without being unlocked first";
+
+ // Drop out of write early with failure if we need to
+ if (write_success_callback && !write_success_callback(backing_write_invoke_count, address)) {
+ return false;
+ }
+
+ // Write the complement as we're simulating flash memory -- 0xFF means 0x00
+ std::size_t index = address / BACKING_STORE_WRITE_SIZE;
+ backing_storage[index].set(~value);
+
+ // Keep track of the write log so that we can verify during tests
+ append_log(address, value);
+
+ // Keep track of the total number of writes into the backing store
+ ++backing_total_write_count;
+
+ return true;
+}
+
+bool MockBackingStore::lock(void) {
+ ++backing_lock_invoke_count;
+
+ EXPECT_FALSE(is_locked()) << "Attempted to lock but was not unlocked";
+ locked = true;
+
+ if (lock_success_callback) {
+ return lock_success_callback(backing_lock_invoke_count);
+ }
+ return true;
+}
+
+bool MockBackingStore::read(uint32_t address, backing_store_int_t& value) const {
+ // precondition: value's buffer size already matches BACKING_STORE_WRITE_SIZE
+ EXPECT_TRUE(address % BACKING_STORE_WRITE_SIZE == 0) << "Supplied address was not aligned with the backing store integral size";
+ EXPECT_TRUE(address + BACKING_STORE_WRITE_SIZE <= WEAR_LEVELING_BACKING_SIZE) << "Address would result of out-of-bounds access";
+
+ // Read and take the complement as we're simulating flash memory -- 0xFF means 0x00
+ std::size_t index = address / BACKING_STORE_WRITE_SIZE;
+ value = ~backing_storage[index].get();
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Backing Implementation
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+extern "C" bool backing_store_init(void) {
+ return MockBackingStore::Instance().init();
+}
+
+extern "C" bool backing_store_unlock(void) {
+ return MockBackingStore::Instance().unlock();
+}
+
+extern "C" bool backing_store_erase(void) {
+ return MockBackingStore::Instance().erase();
+}
+
+extern "C" bool backing_store_write(uint32_t address, backing_store_int_t value) {
+ return MockBackingStore::Instance().write(address, value);
+}
+
+extern "C" bool backing_store_lock(void) {
+ return MockBackingStore::Instance().lock();
+}
+
+extern "C" bool backing_store_read(uint32_t address, backing_store_int_t* value) {
+ return MockBackingStore::Instance().read(address, *value);
+}
diff --git a/quantum/wear_leveling/tests/backing_mocks.hpp b/quantum/wear_leveling/tests/backing_mocks.hpp
new file mode 100644
index 0000000000..e7af7895f3
--- /dev/null
+++ b/quantum/wear_leveling/tests/backing_mocks.hpp
@@ -0,0 +1,210 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+#include <algorithm>
+#include <array>
+#include <cstdint>
+#include <cstdlib>
+#include <functional>
+#include <type_traits>
+#include <vector>
+
+extern "C" {
+#include "fnv.h"
+#include "wear_leveling.h"
+#include "wear_leveling_internal.h"
+};
+
+// Maximum number of mock write log entries to keep
+using MOCK_WRITE_LOG_MAX_ENTRIES = std::integral_constant<std::size_t, 1024>;
+// Complement to the backing store integral, for emulating flash erases of all bytes=0xFF
+using BACKING_STORE_INTEGRAL_COMPLEMENT = std::integral_constant<backing_store_int_t, ((backing_store_int_t)(~(backing_store_int_t)0))>;
+// Total number of elements stored in the backing arrays
+using BACKING_STORE_ELEMENT_COUNT = std::integral_constant<std::size_t, (WEAR_LEVELING_BACKING_SIZE / sizeof(backing_store_int_t))>;
+
+class MockBackingStoreElement {
+ private:
+ backing_store_int_t value;
+ std::size_t writes;
+ std::size_t erases;
+
+ public:
+ MockBackingStoreElement() : value(BACKING_STORE_INTEGRAL_COMPLEMENT::value), writes(0), erases(0) {}
+ void reset() {
+ erase();
+ writes = 0;
+ erases = 0;
+ }
+ void erase() {
+ if (!is_erased()) {
+ ++erases;
+ }
+ value = BACKING_STORE_INTEGRAL_COMPLEMENT::value;
+ }
+ backing_store_int_t get() const {
+ return value;
+ }
+ void set(const backing_store_int_t& v) {
+ EXPECT_TRUE(is_erased()) << "Attempted write at index which isn't empty.";
+ value = v;
+ ++writes;
+ }
+ std::size_t num_writes() const {
+ return writes;
+ }
+ std::size_t num_erases() const {
+ return erases;
+ }
+ bool is_erased() const {
+ return value == BACKING_STORE_INTEGRAL_COMPLEMENT::value;
+ }
+};
+
+struct MockBackingStoreLogEntry {
+ MockBackingStoreLogEntry(uint32_t address, backing_store_int_t value) : address(address), value(value), erased(false) {}
+ MockBackingStoreLogEntry(bool erased) : address(0), value(0), erased(erased) {}
+ uint32_t address = 0; // The address of the operation
+ backing_store_int_t value = 0; // The value of the operation
+ bool erased = false; // Whether the entire backing store was erased
+};
+
+class MockBackingStore {
+ private:
+ MockBackingStore() {
+ reset_instance();
+ }
+
+ // Type containing each of the entries and the write counts
+ using storage_t = std::array<MockBackingStoreElement, BACKING_STORE_ELEMENT_COUNT::value>;
+
+ // Whether the backing store is locked
+ bool locked;
+ // The actual data stored in the emulated flash
+ storage_t backing_storage;
+ // The number of erase cycles that have occurred
+ std::uint64_t backing_erasure_count;
+ // The max number of writes to an element of the backing store
+ std::uint64_t backing_max_write_count;
+ // The total number of writes to all elements of the backing store
+ std::uint64_t backing_total_write_count;
+ // The write log for the backing store
+ std::vector<MockBackingStoreLogEntry> write_log;
+
+ // The number of times each API was invoked
+ std::uint64_t backing_init_invoke_count;
+ std::uint64_t backing_unlock_invoke_count;
+ std::uint64_t backing_erase_invoke_count;
+ std::uint64_t backing_write_invoke_count;
+ std::uint64_t backing_lock_invoke_count;
+
+ // Whether init should succeed
+ std::function<bool(std::uint64_t)> init_success_callback;
+ // Whether erase should succeed
+ std::function<bool(std::uint64_t)> erase_success_callback;
+ // Whether unlocks should succeed
+ std::function<bool(std::uint64_t)> unlock_success_callback;
+ // Whether writes should succeed
+ std::function<bool(std::uint64_t, std::uint32_t)> write_success_callback;
+ // Whether locks should succeed
+ std::function<bool(std::uint64_t)> lock_success_callback;
+
+ template <typename... Args>
+ void append_log(Args&&... args) {
+ if (write_log.size() < MOCK_WRITE_LOG_MAX_ENTRIES::value) {
+ write_log.emplace_back(std::forward<Args>(args)...);
+ }
+ }
+
+ public:
+ static MockBackingStore& Instance() {
+ static MockBackingStore instance;
+ return instance;
+ }
+
+ std::uint64_t erasure_count() const {
+ return backing_erasure_count;
+ }
+ std::uint64_t max_write_count() const {
+ return backing_max_write_count;
+ }
+ std::uint64_t total_write_count() const {
+ return backing_total_write_count;
+ }
+
+ // The number of times each API was invoked
+ std::uint64_t init_invoke_count() const {
+ return backing_init_invoke_count;
+ }
+ std::uint64_t unlock_invoke_count() const {
+ return backing_unlock_invoke_count;
+ }
+ std::uint64_t erase_invoke_count() const {
+ return backing_erase_invoke_count;
+ }
+ std::uint64_t write_invoke_count() const {
+ return backing_write_invoke_count;
+ }
+ std::uint64_t lock_invoke_count() const {
+ return backing_lock_invoke_count;
+ }
+
+ // Clear out the internal data for the next run
+ void reset_instance();
+
+ bool is_locked() const {
+ return locked;
+ }
+
+ // APIs for the backing store
+ bool init();
+ bool unlock();
+ bool erase();
+ bool write(std::uint32_t address, backing_store_int_t value);
+ bool lock();
+ bool read(std::uint32_t address, backing_store_int_t& value) const;
+
+ // Control over when init/writes/erases should succeed
+ void set_init_callback(std::function<bool(std::uint64_t)> callback) {
+ init_success_callback = callback;
+ }
+ void set_erase_callback(std::function<bool(std::uint64_t)> callback) {
+ erase_success_callback = callback;
+ }
+ void set_unlock_callback(std::function<bool(std::uint64_t)> callback) {
+ unlock_success_callback = callback;
+ }
+ void set_write_callback(std::function<bool(std::uint64_t, std::uint32_t)> callback) {
+ write_success_callback = callback;
+ }
+ void set_lock_callback(std::function<bool(std::uint64_t)> callback) {
+ lock_success_callback = callback;
+ }
+
+ auto storage_begin() const -> decltype(backing_storage.begin()) {
+ return backing_storage.begin();
+ }
+ auto storage_end() const -> decltype(backing_storage.end()) {
+ return backing_storage.end();
+ }
+
+ auto storage_begin() -> decltype(backing_storage.begin()) {
+ return backing_storage.begin();
+ }
+ auto storage_end() -> decltype(backing_storage.end()) {
+ return backing_storage.end();
+ }
+
+ auto log_begin() -> decltype(write_log.begin()) {
+ return write_log.begin();
+ }
+ auto log_end() -> decltype(write_log.end()) {
+ return write_log.end();
+ }
+
+ auto log_begin() const -> decltype(write_log.begin()) {
+ return write_log.begin();
+ }
+ auto log_end() const -> decltype(write_log.end()) {
+ return write_log.end();
+ }
+};
diff --git a/quantum/wear_leveling/tests/rules.mk b/quantum/wear_leveling/tests/rules.mk
new file mode 100644
index 0000000000..4d7a964049
--- /dev/null
+++ b/quantum/wear_leveling/tests/rules.mk
@@ -0,0 +1,66 @@
+wear_leveling_common_DEFS := \
+ -DWEAR_LEVELING_TESTS
+wear_leveling_common_SRC := \
+ $(LIB_PATH)/fnv/qmk_fnv_type_validation.c \
+ $(LIB_PATH)/fnv/hash_32a.c \
+ $(LIB_PATH)/fnv/hash_64a.c \
+ $(QUANTUM_PATH)/wear_leveling/wear_leveling.c \
+ $(QUANTUM_PATH)/wear_leveling/tests/backing_mocks.cpp
+wear_leveling_common_INC := \
+ $(LIB_PATH)/fnv \
+ $(QUANTUM_PATH)/wear_leveling
+
+wear_leveling_general_DEFS := \
+ $(wear_leveling_common_DEFS) \
+ -DBACKING_STORE_WRITE_SIZE=2 \
+ -DWEAR_LEVELING_BACKING_SIZE=48 \
+ -DWEAR_LEVELING_LOGICAL_SIZE=16
+wear_leveling_general_SRC := \
+ $(wear_leveling_common_SRC) \
+ $(QUANTUM_PATH)/wear_leveling/tests/wear_leveling_general.cpp
+wear_leveling_general_INC := \
+ $(wear_leveling_common_INC)
+
+wear_leveling_2byte_optimized_writes_DEFS := \
+ $(wear_leveling_common_DEFS) \
+ -DBACKING_STORE_WRITE_SIZE=2 \
+ -DWEAR_LEVELING_BACKING_SIZE=65536 \
+ -DWEAR_LEVELING_LOGICAL_SIZE=32768
+wear_leveling_2byte_optimized_writes_SRC := \
+ $(wear_leveling_common_SRC) \
+ $(QUANTUM_PATH)/wear_leveling/tests/wear_leveling_2byte_optimized_writes.cpp
+wear_leveling_2byte_optimized_writes_INC := \
+ $(wear_leveling_common_INC)
+
+wear_leveling_2byte_DEFS := \
+ $(wear_leveling_common_DEFS) \
+ -DBACKING_STORE_WRITE_SIZE=2 \
+ -DWEAR_LEVELING_BACKING_SIZE=48 \
+ -DWEAR_LEVELING_LOGICAL_SIZE=16
+wear_leveling_2byte_SRC := \
+ $(wear_leveling_common_SRC) \
+ $(QUANTUM_PATH)/wear_leveling/tests/wear_leveling_2byte.cpp
+wear_leveling_2byte_INC := \
+ $(wear_leveling_common_INC)
+
+wear_leveling_4byte_DEFS := \
+ $(wear_leveling_common_DEFS) \
+ -DBACKING_STORE_WRITE_SIZE=4 \
+ -DWEAR_LEVELING_BACKING_SIZE=48 \
+ -DWEAR_LEVELING_LOGICAL_SIZE=16
+wear_leveling_4byte_SRC := \
+ $(wear_leveling_common_SRC) \
+ $(QUANTUM_PATH)/wear_leveling/tests/wear_leveling_4byte.cpp
+wear_leveling_4byte_INC := \
+ $(wear_leveling_common_INC)
+
+wear_leveling_8byte_DEFS := \
+ $(wear_leveling_common_DEFS) \
+ -DBACKING_STORE_WRITE_SIZE=8 \
+ -DWEAR_LEVELING_BACKING_SIZE=48 \
+ -DWEAR_LEVELING_LOGICAL_SIZE=16
+wear_leveling_8byte_SRC := \
+ $(wear_leveling_common_SRC) \
+ $(QUANTUM_PATH)/wear_leveling/tests/wear_leveling_8byte.cpp
+wear_leveling_8byte_INC := \
+ $(wear_leveling_common_INC) \ No newline at end of file
diff --git a/quantum/wear_leveling/tests/testlist.mk b/quantum/wear_leveling/tests/testlist.mk
new file mode 100644
index 0000000000..32cfc178b4
--- /dev/null
+++ b/quantum/wear_leveling/tests/testlist.mk
@@ -0,0 +1,6 @@
+TEST_LIST += \
+ wear_leveling_general \
+ wear_leveling_2byte_optimized_writes \
+ wear_leveling_2byte \
+ wear_leveling_4byte \
+ wear_leveling_8byte
diff --git a/quantum/wear_leveling/tests/wear_leveling_2byte.cpp b/quantum/wear_leveling/tests/wear_leveling_2byte.cpp
new file mode 100644
index 0000000000..b749c32b04
--- /dev/null
+++ b/quantum/wear_leveling/tests/wear_leveling_2byte.cpp
@@ -0,0 +1,228 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <numeric>
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "backing_mocks.hpp"
+
+class WearLeveling2Byte : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ MockBackingStore::Instance().reset_instance();
+ wear_leveling_init();
+ }
+};
+
+static std::array<std::uint8_t, WEAR_LEVELING_LOGICAL_SIZE> verify_data;
+
+static wear_leveling_status_t test_write(const uint32_t address, const void* value, size_t length) {
+ memcpy(&verify_data[address], value, length);
+ return wear_leveling_write(address, value, length);
+}
+
+/**
+ * This test verifies that the first write after initialisation occurs after the FNV1a_64 hash location.
+ */
+TEST_F(WearLeveling2Byte, FirstWriteOccursAfterHash) {
+ auto& inst = MockBackingStore::Instance();
+ uint8_t test_value = 0x15;
+ test_write(0x02, &test_value, sizeof(test_value));
+ EXPECT_EQ(inst.log_begin()->address, WEAR_LEVELING_LOGICAL_SIZE + 8) << "Invalid first write address.";
+}
+
+/**
+ * This test verifies that the first write after initialisation occurs after the FNV1a_64 hash location, after an erase has occurred.
+ */
+TEST_F(WearLeveling2Byte, FirstWriteOccursAfterHash_AfterErase) {
+ auto& inst = MockBackingStore::Instance();
+ uint8_t test_value = 0x15;
+ wear_leveling_erase();
+ test_write(0x02, &test_value, sizeof(test_value));
+ EXPECT_EQ((inst.log_begin() + 1)->address, WEAR_LEVELING_LOGICAL_SIZE + 8) << "Invalid first write address.";
+}
+
+/**
+ * This test forces consolidation by writing enough to the write log that it overflows, consolidating the data into the
+ * base logical area.
+ */
+TEST_F(WearLeveling2Byte, ConsolidationOverflow) {
+ auto& inst = MockBackingStore::Instance();
+
+ // Generate a test block of data which forces OPTIMIZED_64 writes
+ std::array<std::uint8_t, WEAR_LEVELING_LOGICAL_SIZE> testvalue;
+
+ // Write the data
+ std::iota(testvalue.begin(), testvalue.end(), 0x20);
+ EXPECT_EQ(test_write(0, testvalue.data(), testvalue.size()), WEAR_LEVELING_CONSOLIDATED) << "Write returned incorrect status";
+ uint8_t dummy = 0x40;
+ EXPECT_EQ(test_write(0x04, &dummy, sizeof(dummy)), WEAR_LEVELING_SUCCESS) << "Write returned incorrect status";
+
+ // All writes are at address<64, so each logical byte written will generate 1 write log entry, thus 1 backing store write.
+ // Expected log:
+ // [0..11]: optimised64, backing address 0x18, logical address 0x00
+ // [12]: erase
+ // [13..20]: consolidated data, backing address 0x00, logical address 0x00
+ // [21..24]: FNV1a_64 result, backing address 0x10
+ // [25]: optimised64, backing address 0x18, logical address 0x04
+ EXPECT_EQ(std::distance(inst.log_begin(), inst.log_end()), 26);
+
+ // Verify the backing store writes for the write log
+ std::size_t index;
+ write_log_entry_t e;
+ for (index = 0; index < 12; ++index) {
+ auto write_iter = inst.log_begin() + index;
+ EXPECT_EQ(write_iter->address, WEAR_LEVELING_LOGICAL_SIZE + 8 + (index * BACKING_STORE_WRITE_SIZE)) << "Invalid write log address";
+ e.raw16[0] = write_iter->value;
+ EXPECT_EQ(LOG_ENTRY_GET_TYPE(e), LOG_ENTRY_TYPE_OPTIMIZED_64) << "Invalid write log entry type";
+ }
+
+ // Verify the backing store erase
+ {
+ index = 12;
+ auto write_iter = inst.log_begin() + index;
+ e.raw16[0] = write_iter->value;
+ EXPECT_TRUE(write_iter->erased) << "Backing store erase did not occur as required";
+ }
+
+ // Verify the backing store writes for consolidation
+ for (index = 13; index < 21; ++index) {
+ auto write_iter = inst.log_begin() + index;
+ EXPECT_EQ(write_iter->address, (index - 13) * BACKING_STORE_WRITE_SIZE) << "Invalid write log entry address";
+ }
+
+ // Verify the FNV1a_64 write
+ {
+ EXPECT_EQ((inst.log_begin() + 21)->address, WEAR_LEVELING_LOGICAL_SIZE) << "Invalid write log address";
+ e.raw16[0] = (inst.log_begin() + 21)->value;
+ e.raw16[1] = (inst.log_begin() + 22)->value;
+ e.raw16[2] = (inst.log_begin() + 23)->value;
+ e.raw16[3] = (inst.log_begin() + 24)->value;
+ EXPECT_EQ(e.raw64, fnv_64a_buf(testvalue.data(), testvalue.size(), FNV1A_64_INIT)) << "Invalid checksum"; // Note that checksum is based on testvalue, as we overwrote one byte and need to consult the consolidated data, not the current
+ }
+
+ // Verify the final write
+ EXPECT_EQ((inst.log_begin() + 25)->address, WEAR_LEVELING_LOGICAL_SIZE + 8) << "Invalid write log address";
+
+ // Verify the data is what we expected
+ std::array<std::uint8_t, WEAR_LEVELING_LOGICAL_SIZE> readback;
+ EXPECT_EQ(wear_leveling_read(0, readback.data(), WEAR_LEVELING_LOGICAL_SIZE), WEAR_LEVELING_SUCCESS) << "Failed to read back the saved data";
+ EXPECT_TRUE(memcmp(readback.data(), verify_data.data(), WEAR_LEVELING_LOGICAL_SIZE) == 0) << "Readback did not match";
+
+ // Re-init and re-read, verifying the reload capability
+ EXPECT_NE(wear_leveling_init(), WEAR_LEVELING_FAILED) << "Re-initialisation failed";
+ EXPECT_EQ(wear_leveling_read(0, readback.data(), WEAR_LEVELING_LOGICAL_SIZE), WEAR_LEVELING_SUCCESS) << "Failed to read back the saved data";
+ EXPECT_TRUE(memcmp(readback.data(), verify_data.data(), WEAR_LEVELING_LOGICAL_SIZE) == 0) << "Readback did not match";
+}
+
+/**
+ * This test verifies multibyte readback gets canceled with an out-of-bounds address.
+ */
+TEST_F(WearLeveling2Byte, PlaybackReadbackMultibyte_OOB) {
+ auto& inst = MockBackingStore::Instance();
+ auto logstart = inst.storage_begin() + (WEAR_LEVELING_LOGICAL_SIZE / sizeof(backing_store_int_t));
+
+ // Invalid FNV1a_64 hash
+ (logstart + 0)->set(0);
+ (logstart + 1)->set(0);
+ (logstart + 2)->set(0);
+ (logstart + 3)->set(0);
+
+ // Set up a 2-byte logical write of [0x11,0x12] at logical offset 0x01
+ auto entry0 = LOG_ENTRY_MAKE_MULTIBYTE(0x01, 2);
+ entry0.raw8[3] = 0x11;
+ entry0.raw8[4] = 0x12;
+ (logstart + 4)->set(~entry0.raw16[0]);
+ (logstart + 5)->set(~entry0.raw16[1]);
+ (logstart + 6)->set(~entry0.raw16[2]);
+
+ // Set up a 2-byte logical write of [0x13,0x14] at logical offset 0x1000 (out of bounds)
+ auto entry1 = LOG_ENTRY_MAKE_MULTIBYTE(0x1000, 2);
+ entry1.raw8[3] = 0x13;
+ entry1.raw8[4] = 0x14;
+ (logstart + 7)->set(~entry1.raw16[0]);
+ (logstart + 8)->set(~entry1.raw16[1]);
+ (logstart + 9)->set(~entry1.raw16[2]);
+
+ // Set up a 2-byte logical write of [0x15,0x16] at logical offset 0x01
+ auto entry2 = LOG_ENTRY_MAKE_MULTIBYTE(0x01, 2);
+ entry2.raw8[3] = 0x15;
+ entry2.raw8[4] = 0x16;
+ (logstart + 10)->set(~entry2.raw16[0]);
+ (logstart + 11)->set(~entry2.raw16[1]);
+ (logstart + 12)->set(~entry2.raw16[2]);
+
+ EXPECT_EQ(inst.erasure_count(), 0) << "Invalid initial erase count";
+ EXPECT_EQ(wear_leveling_init(), WEAR_LEVELING_CONSOLIDATED) << "Readback should have failed and triggered consolidation";
+ EXPECT_EQ(inst.erasure_count(), 1) << "Invalid final erase count";
+
+ uint8_t buf[2];
+ wear_leveling_read(0x01, buf, sizeof(buf));
+ EXPECT_EQ(buf[0], 0x11) << "Readback should have maintained the previous pre-failure value from the write log";
+ EXPECT_EQ(buf[1], 0x12) << "Readback should have maintained the previous pre-failure value from the write log";
+}
+
+/**
+ * This test verifies optimized 64 readback gets canceled with an out-of-bounds address.
+ */
+TEST_F(WearLeveling2Byte, PlaybackReadbackOptimized64_OOB) {
+ auto& inst = MockBackingStore::Instance();
+ auto logstart = inst.storage_begin() + (WEAR_LEVELING_LOGICAL_SIZE / sizeof(backing_store_int_t));
+
+ // Invalid FNV1a_64 hash
+ (logstart + 0)->set(0);
+ (logstart + 1)->set(0);
+ (logstart + 2)->set(0);
+ (logstart + 3)->set(0);
+
+ // Set up a 1-byte logical write of 0x11 at logical offset 0x01
+ auto entry0 = LOG_ENTRY_MAKE_OPTIMIZED_64(0x01, 0x11);
+ (logstart + 4)->set(~entry0.raw16[0]);
+
+ // Set up a 1-byte logical write of 0x11 at logical offset 0x30 (out of bounds)
+ auto entry1 = LOG_ENTRY_MAKE_OPTIMIZED_64(0x30, 0x11);
+ (logstart + 5)->set(~entry1.raw16[0]);
+
+ // Set up a 1-byte logical write of 0x12 at logical offset 0x01
+ auto entry2 = LOG_ENTRY_MAKE_OPTIMIZED_64(0x01, 0x12);
+ (logstart + 6)->set(~entry2.raw16[0]);
+
+ EXPECT_EQ(inst.erasure_count(), 0) << "Invalid initial erase count";
+ EXPECT_EQ(wear_leveling_init(), WEAR_LEVELING_CONSOLIDATED) << "Readback should have failed and triggered consolidation";
+ EXPECT_EQ(inst.erasure_count(), 1) << "Invalid final erase count";
+ uint8_t tmp;
+ wear_leveling_read(0x01, &tmp, sizeof(tmp));
+ EXPECT_EQ(tmp, 0x11) << "Readback should have maintained the previous pre-failure value from the write log";
+}
+
+/**
+ * This test verifies word 0/1 readback gets canceled with an out-of-bounds address.
+ */
+TEST_F(WearLeveling2Byte, PlaybackReadbackWord01_OOB) {
+ auto& inst = MockBackingStore::Instance();
+ auto logstart = inst.storage_begin() + (WEAR_LEVELING_LOGICAL_SIZE / sizeof(backing_store_int_t));
+
+ // Invalid FNV1a_64 hash
+ (logstart + 0)->set(0);
+ (logstart + 1)->set(0);
+ (logstart + 2)->set(0);
+ (logstart + 3)->set(0);
+
+ // Set up a 1-byte logical write of 1 at logical offset 0x02
+ auto entry0 = LOG_ENTRY_MAKE_WORD_01(0x02, 1);
+ (logstart + 4)->set(~entry0.raw16[0]);
+
+ // Set up a 1-byte logical write of 1 at logical offset 0x1000 (out of bounds)
+ auto entry1 = LOG_ENTRY_MAKE_WORD_01(0x1000, 1);
+ (logstart + 5)->set(~entry1.raw16[0]);
+
+ // Set up a 1-byte logical write of 0 at logical offset 0x02
+ auto entry2 = LOG_ENTRY_MAKE_WORD_01(0x02, 0);
+ (logstart + 6)->set(~entry2.raw16[0]);
+
+ EXPECT_EQ(inst.erasure_count(), 0) << "Invalid initial erase count";
+ EXPECT_EQ(wear_leveling_init(), WEAR_LEVELING_CONSOLIDATED) << "Readback should have failed and triggered consolidation";
+ EXPECT_EQ(inst.erasure_count(), 1) << "Invalid final erase count";
+ uint8_t tmp;
+ wear_leveling_read(0x02, &tmp, sizeof(tmp));
+ EXPECT_EQ(tmp, 1) << "Readback should have maintained the previous pre-failure value from the write log";
+}
diff --git a/quantum/wear_leveling/tests/wear_leveling_2byte_optimized_writes.cpp b/quantum/wear_leveling/tests/wear_leveling_2byte_optimized_writes.cpp
new file mode 100644
index 0000000000..0b03113c89
--- /dev/null
+++ b/quantum/wear_leveling/tests/wear_leveling_2byte_optimized_writes.cpp
@@ -0,0 +1,295 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <numeric>
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "backing_mocks.hpp"
+
+class WearLeveling2ByteOptimizedWrites : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ MockBackingStore::Instance().reset_instance();
+ wear_leveling_init();
+ }
+};
+
+static std::array<std::uint8_t, WEAR_LEVELING_LOGICAL_SIZE> verify_data;
+
+static wear_leveling_status_t test_write(const uint32_t address, const void* value, size_t length) {
+ memcpy(&verify_data[address], value, length);
+ return wear_leveling_write(address, value, length);
+}
+
+/**
+ * This test ensures the correct number of backing store writes occurs with a multibyte write, given the input buffer size.
+ */
+TEST_F(WearLeveling2ByteOptimizedWrites, MultibyteBackingStoreWriteCounts) {
+ auto& inst = MockBackingStore::Instance();
+
+ for (std::size_t length = 1; length <= 5; ++length) {
+ // Clear things out
+ std::fill(verify_data.begin(), verify_data.end(), 0);
+ inst.reset_instance();
+ wear_leveling_init();
+
+ // Generate a test block of data
+ std::vector<std::uint8_t> testvalue(length);
+ std::iota(testvalue.begin(), testvalue.end(), 0x20);
+
+ // Write the data
+ EXPECT_EQ(test_write(2000, testvalue.data(), testvalue.size()), WEAR_LEVELING_SUCCESS) << "Write failed with incorrect status";
+
+ std::size_t expected;
+ if (length > 3) {
+ expected = 4;
+ } else if (length > 1) {
+ expected = 3;
+ } else {
+ expected = 2;
+ }
+
+ // Check that we got the expected number of write log entries
+ EXPECT_EQ(std::distance(inst.log_begin(), inst.log_end()), expected);
+ }
+}
+
+/**
+ * This test runs through writing U16 values of `0` or `1` over the entire logical address range, to even addresses only.
+ * - Addresses <16384 will result in a single optimised backing write
+ * - Higher addresses will result in a multibyte write of 3 backing writes
+ */
+TEST_F(WearLeveling2ByteOptimizedWrites, WriteOneThenZeroToEvenAddresses) {
+ auto& inst = MockBackingStore::Instance();
+
+ // Only attempt writes for each address up to a limit that would NOT force a consolidated data write.
+ std::size_t writes_per_loop = (MOCK_WRITE_LOG_MAX_ENTRIES::value / 6) - 1; // Worst case is 6 writes for each pair of writes of 0/1
+ std::size_t final_address;
+ for (uint32_t address = 0; address < WEAR_LEVELING_LOGICAL_SIZE; address += (writes_per_loop * 2)) {
+ // Clear things out
+ std::fill(verify_data.begin(), verify_data.end(), 0);
+ inst.reset_instance();
+ wear_leveling_init();
+
+ // Loop through all the addresses in this range
+ std::size_t expected = 0;
+ for (uint32_t offset = 0; offset < (writes_per_loop * 2); offset += 2) {
+ // If we're about to exceed the limit of the logical store, skip the writes
+ if (address + offset + 2 > WEAR_LEVELING_LOGICAL_SIZE) {
+ break;
+ }
+
+ // The default erased value of the wear-leveling cache is zero, so we write a one first, then a zero, to ensure a backing store write occurs.
+ uint16_t val = 1;
+ EXPECT_EQ(test_write(address + offset, &val, sizeof(val)), WEAR_LEVELING_SUCCESS) << "Write failed with incorrect status";
+ val = 0;
+ EXPECT_EQ(test_write(address + offset, &val, sizeof(val)), WEAR_LEVELING_SUCCESS) << "Write failed with incorrect status";
+
+ std::size_t backing_store_writes_expected = 0;
+ if (address + offset < 16384) {
+ // A U16 value of 0/1 at an even address <16384 will result in 1 backing write each, so we need 2 backing writes for 2 logical writes
+ backing_store_writes_expected = 2;
+ } else {
+ // All other addresses result in a multibyte write (3 backing store writes) to write two local bytes of data
+ backing_store_writes_expected = 6;
+ }
+
+ // Keep track of the total number of expected writes to the backing store
+ expected += backing_store_writes_expected;
+
+ // Verify we're at the correct number of writes
+ EXPECT_EQ(std::distance(inst.log_begin(), inst.log_end()), expected) << "Write log doesn't match required number of backing store writes for address " << (address + offset);
+
+ // Verify that the write log entries we expect are actually present
+ std::size_t write_index = expected - backing_store_writes_expected;
+ auto write_iter = inst.log_begin() + write_index;
+ write_log_entry_t e;
+ if (address + offset < 16384) {
+ // A U16 value of 0/1 at an even address <16384 will result in 1 backing write each, so we need 2 backing writes for 2 logical writes
+ for (std::size_t i = 0; i < 2; ++i) {
+ e.raw16[0] = write_iter->value;
+ EXPECT_EQ(LOG_ENTRY_GET_TYPE(e), LOG_ENTRY_TYPE_WORD_01) << "Invalid write log entry type at " << (address + offset);
+ ++write_iter;
+ }
+ } else {
+ // Multibyte write
+ e.raw16[0] = write_iter->value;
+ EXPECT_EQ(LOG_ENTRY_GET_TYPE(e), LOG_ENTRY_TYPE_MULTIBYTE) << "Invalid write log entry type at " << (address + offset);
+ EXPECT_EQ(LOG_ENTRY_MULTIBYTE_GET_LENGTH(e), 2) << "Invalid write log entry length at " << (address + offset);
+ ++write_iter;
+ }
+
+ // Keep track of the final address written, so we can verify the entire logical range was handled
+ final_address = address + offset;
+ }
+
+ // Verify the number of writes that occurred to the backing store
+ size_t backing_write_count = std::distance(inst.log_begin(), inst.log_end());
+ EXPECT_EQ(backing_write_count, expected) << "Invalid write count at address " << address;
+
+ // Verify the data is what we expected
+ std::array<std::uint8_t, WEAR_LEVELING_LOGICAL_SIZE> readback;
+ EXPECT_EQ(wear_leveling_read(0, readback.data(), WEAR_LEVELING_LOGICAL_SIZE), WEAR_LEVELING_SUCCESS) << "Failed to read back the saved data";
+ EXPECT_TRUE(memcmp(readback.data(), verify_data.data(), WEAR_LEVELING_LOGICAL_SIZE) == 0) << "Readback for address " << address << " did not match";
+
+ // Re-init and re-read, testing the reload capability
+ EXPECT_NE(wear_leveling_init(), WEAR_LEVELING_FAILED) << "Re-initialisation failed";
+ EXPECT_EQ(wear_leveling_read(0, readback.data(), WEAR_LEVELING_LOGICAL_SIZE), WEAR_LEVELING_SUCCESS) << "Failed to read back the saved data";
+ EXPECT_TRUE(memcmp(readback.data(), verify_data.data(), WEAR_LEVELING_LOGICAL_SIZE) == 0) << "Readback for address " << address << " did not match";
+ }
+
+ // Verify the full range of the logical area got written
+ EXPECT_EQ(final_address, WEAR_LEVELING_LOGICAL_SIZE - 2) << "Invalid final write address";
+}
+
+/**
+ * This test runs through writing U16 values of `0` or `1` over the entire logical address range, to odd addresses only.
+ * - Addresses <63 will result in 2 optimised backing writes
+ * - Address 63 results in a single optimised backing write for the first logical byte, and a multibyte write of 2 backing writes for the second logical byte
+ * - Higher addresses will result in a multibyte write of 3 backing writes
+ */
+TEST_F(WearLeveling2ByteOptimizedWrites, WriteOneThenZeroToOddAddresses) {
+ auto& inst = MockBackingStore::Instance();
+
+ // Only attempt writes for each address up to a limit that would NOT force a consolidated data write.
+ std::size_t writes_per_loop = (MOCK_WRITE_LOG_MAX_ENTRIES::value / 6) - 1; // Worst case is 6 writes for each pair of writes of 0/1
+ std::size_t final_address;
+ for (uint32_t address = 1; address < WEAR_LEVELING_LOGICAL_SIZE; address += (writes_per_loop * 2)) {
+ // Clear things out
+ std::fill(verify_data.begin(), verify_data.end(), 0);
+ inst.reset_instance();
+ wear_leveling_init();
+
+ // Loop through all the addresses in this range
+ std::size_t expected = 0;
+ for (uint32_t offset = 0; offset < (writes_per_loop * 2); offset += 2) {
+ // If we're about to exceed the limit of the logical store, skip the writes
+ if (address + offset + 2 > WEAR_LEVELING_LOGICAL_SIZE) {
+ break;
+ }
+
+ // The default erased value of the wear-leveling cache is zero, so we write a one first, then a zero, to ensure a backing store write occurs.
+ uint16_t val = 1;
+ EXPECT_EQ(test_write(address + offset, &val, sizeof(val)), WEAR_LEVELING_SUCCESS) << "Write failed with incorrect status";
+ val = 0;
+ EXPECT_EQ(test_write(address + offset, &val, sizeof(val)), WEAR_LEVELING_SUCCESS) << "Write failed with incorrect status";
+
+ std::size_t backing_store_writes_expected = 0;
+ if (address + offset < 63) {
+ // A U16 value of 0/1 at an odd address <64 will result in 2 backing writes each, so we need 4 backing writes for 2 logical writes
+ backing_store_writes_expected = 4;
+ } else if (address + offset == 63) {
+ // If we're straddling the boundary for optimised bytes (addr==64), then the first logical byte is written using the optimised write (1 backing
+ // store write), and the second logical byte uses a multibyte write (2 backing store writes)
+ backing_store_writes_expected = 2 // First logical bytes written using optimised log entries
+ + 4; // Second logical bytes written using multibyte log entries
+ } else {
+ // All other addresses result in a multibyte write (3 backing store writes) to write two local bytes of data
+ backing_store_writes_expected = 6;
+ }
+
+ // Keep track of the total number of expected writes to the backing store
+ expected += backing_store_writes_expected;
+
+ // Verify we're at the correct number of writes
+ EXPECT_EQ(std::distance(inst.log_begin(), inst.log_end()), expected) << "Write log doesn't match required number of backing store writes for address " << (address + offset);
+
+ // Verify that the write log entries we expect are actually present
+ std::size_t write_index = expected - backing_store_writes_expected;
+ auto write_iter = inst.log_begin() + write_index;
+ write_log_entry_t e;
+ if (address + offset < 63) {
+ // A U16 value of 0/1 at an odd address <64 will result in 2 backing writes each, so we need 4 backing writes for 2 logical writes
+ for (std::size_t i = 0; i < 4; ++i) {
+ e.raw16[0] = write_iter->value;
+ EXPECT_EQ(LOG_ENTRY_GET_TYPE(e), LOG_ENTRY_TYPE_OPTIMIZED_64) << "Invalid write log entry type";
+ ++write_iter;
+ }
+ } else if (address + offset == 63) {
+ // First log entry is the 64-addr optimised one
+ e.raw16[0] = write_iter->value;
+ EXPECT_EQ(LOG_ENTRY_GET_TYPE(e), LOG_ENTRY_TYPE_OPTIMIZED_64) << "Invalid write log entry type";
+ ++write_iter;
+
+ // Second log entry is the multibyte entry for the second logical byte
+ e.raw16[0] = write_iter->value;
+ EXPECT_EQ(LOG_ENTRY_GET_TYPE(e), LOG_ENTRY_TYPE_MULTIBYTE) << "Invalid write log entry type";
+ EXPECT_EQ(LOG_ENTRY_MULTIBYTE_GET_LENGTH(e), 1) << "Invalid write log entry length";
+ ++write_iter;
+ } else {
+ // Multibyte write
+ e.raw16[0] = write_iter->value;
+ EXPECT_EQ(LOG_ENTRY_GET_TYPE(e), LOG_ENTRY_TYPE_MULTIBYTE) << "Invalid write log entry type";
+ EXPECT_EQ(LOG_ENTRY_MULTIBYTE_GET_LENGTH(e), 2) << "Invalid write log entry length";
+ ++write_iter;
+ }
+
+ // Keep track of the final address written, so we can verify the entire logical range was handled
+ final_address = address + offset;
+ }
+
+ // Verify the number of writes that occurred to the backing store
+ size_t backing_write_count = std::distance(inst.log_begin(), inst.log_end());
+ EXPECT_EQ(backing_write_count, expected) << "Invalid write count at address " << address;
+
+ // Verify the data is what we expected
+ std::array<std::uint8_t, WEAR_LEVELING_LOGICAL_SIZE> readback;
+ EXPECT_EQ(wear_leveling_read(0, readback.data(), WEAR_LEVELING_LOGICAL_SIZE), WEAR_LEVELING_SUCCESS) << "Failed to read back the saved data";
+ EXPECT_TRUE(memcmp(readback.data(), verify_data.data(), WEAR_LEVELING_LOGICAL_SIZE) == 0) << "Readback for address " << address << " did not match";
+
+ // Re-init and re-read, testing the reload capability
+ EXPECT_NE(wear_leveling_init(), WEAR_LEVELING_FAILED) << "Re-initialisation failed";
+ EXPECT_EQ(wear_leveling_read(0, readback.data(), WEAR_LEVELING_LOGICAL_SIZE), WEAR_LEVELING_SUCCESS) << "Failed to read back the saved data";
+ EXPECT_TRUE(memcmp(readback.data(), verify_data.data(), WEAR_LEVELING_LOGICAL_SIZE) == 0) << "Readback for address " << address << " did not match";
+ }
+
+ // Verify the full range of the logical area got written
+ EXPECT_EQ(final_address, WEAR_LEVELING_LOGICAL_SIZE - 3) << "Invalid final write address";
+}
+
+/**
+ * This test verifies readback after playback of the write log, simulating power loss and reboot.
+ */
+TEST_F(WearLeveling2ByteOptimizedWrites, PlaybackReadbackOptimized64_Success) {
+ auto& inst = MockBackingStore::Instance();
+ auto logstart = inst.storage_begin() + (WEAR_LEVELING_LOGICAL_SIZE / sizeof(backing_store_int_t));
+
+ // Invalid FNV1a_64 hash
+ (logstart + 0)->set(0);
+ (logstart + 1)->set(0);
+ (logstart + 2)->set(0);
+ (logstart + 3)->set(0);
+
+ // Set up a 1-byte logical write of 0x11 at logical offset 0x01
+ auto entry0 = LOG_ENTRY_MAKE_OPTIMIZED_64(0x01, 0x11);
+ (logstart + 4)->set(~entry0.raw16[0]); // start at offset 4 to skip FNV1a_64 result
+
+ wear_leveling_init();
+ uint8_t tmp;
+
+ wear_leveling_read(0x01, &tmp, sizeof(tmp));
+ EXPECT_EQ(tmp, 0x11) << "Failed to read back the seeded data";
+}
+
+/**
+ * This test verifies readback after playback of the write log, simulating power loss and reboot.
+ */
+TEST_F(WearLeveling2ByteOptimizedWrites, PlaybackReadbackWord01_Success) {
+ auto& inst = MockBackingStore::Instance();
+ auto logstart = inst.storage_begin() + (WEAR_LEVELING_LOGICAL_SIZE / sizeof(backing_store_int_t));
+
+ // Invalid FNV1a_64 hash
+ (logstart + 0)->set(0);
+ (logstart + 1)->set(0);
+ (logstart + 2)->set(0);
+ (logstart + 3)->set(0);
+
+ // Set up a 1-byte logical write of 1 at logical offset 0x02
+ auto entry0 = LOG_ENTRY_MAKE_WORD_01(0x02, 1);
+ (logstart + 4)->set(~entry0.raw16[0]); // start at offset 4 to skip FNV1a_64 result
+
+ wear_leveling_init();
+ uint8_t tmp;
+
+ wear_leveling_read(0x02, &tmp, sizeof(tmp));
+ EXPECT_EQ(tmp, 1) << "Failed to read back the seeded data";
+}
diff --git a/quantum/wear_leveling/tests/wear_leveling_4byte.cpp b/quantum/wear_leveling/tests/wear_leveling_4byte.cpp
new file mode 100644
index 0000000000..54482c5fe7
--- /dev/null
+++ b/quantum/wear_leveling/tests/wear_leveling_4byte.cpp
@@ -0,0 +1,193 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <numeric>
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "backing_mocks.hpp"
+
+class WearLeveling4Byte : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ MockBackingStore::Instance().reset_instance();
+ wear_leveling_init();
+ }
+};
+
+static std::array<std::uint8_t, WEAR_LEVELING_LOGICAL_SIZE> verify_data;
+
+static wear_leveling_status_t test_write(const uint32_t address, const void* value, size_t length) {
+ memcpy(&verify_data[address], value, length);
+ return wear_leveling_write(address, value, length);
+}
+
+/**
+ * This test verifies that the first write after initialisation occurs after the FNV1a_64 hash location.
+ */
+TEST_F(WearLeveling4Byte, FirstWriteOccursAfterHash) {
+ auto& inst = MockBackingStore::Instance();
+ uint8_t test_value = 0x15;
+ test_write(0x02, &test_value, sizeof(test_value));
+ EXPECT_EQ(inst.log_begin()->address, WEAR_LEVELING_LOGICAL_SIZE + 8) << "Invalid first write address.";
+}
+
+/**
+ * This test verifies that the first write after initialisation occurs after the FNV1a_64 hash location, after an erase has occurred.
+ */
+TEST_F(WearLeveling4Byte, FirstWriteOccursAfterHash_AfterErase) {
+ auto& inst = MockBackingStore::Instance();
+ uint8_t test_value = 0x15;
+ wear_leveling_erase();
+ test_write(0x02, &test_value, sizeof(test_value));
+ EXPECT_EQ((inst.log_begin() + 1)->address, WEAR_LEVELING_LOGICAL_SIZE + 8) << "Invalid first write address.";
+}
+
+/**
+ * This test ensures the correct number of backing store writes occurs with a multibyte write, given the input buffer size.
+ */
+TEST_F(WearLeveling4Byte, MultibyteBackingStoreWriteCounts) {
+ auto& inst = MockBackingStore::Instance();
+
+ for (std::size_t length = 1; length <= 5; ++length) {
+ // Clear things out
+ std::fill(verify_data.begin(), verify_data.end(), 0);
+ inst.reset_instance();
+ wear_leveling_init();
+
+ // Generate a test block of data
+ std::vector<std::uint8_t> testvalue(length);
+ std::iota(testvalue.begin(), testvalue.end(), 0x20);
+
+ // Write the data
+ EXPECT_EQ(test_write(0, testvalue.data(), testvalue.size()), WEAR_LEVELING_SUCCESS) << "Write failed with incorrect status";
+
+ std::size_t expected;
+ if (length > 1) {
+ expected = 2;
+ } else {
+ expected = 1;
+ }
+
+ // Check that we got the expected number of write log entries
+ EXPECT_EQ(std::distance(inst.log_begin(), inst.log_end()), expected);
+ }
+}
+
+/**
+ * This test forces consolidation by writing enough to the write log that it overflows, consolidating the data into the
+ * base logical area.
+ */
+TEST_F(WearLeveling4Byte, ConsolidationOverflow) {
+ auto& inst = MockBackingStore::Instance();
+
+ // Generate a test block of data
+ std::array<std::uint8_t, WEAR_LEVELING_LOGICAL_SIZE> testvalue;
+
+ // Write the data
+ std::iota(testvalue.begin(), testvalue.end(), 0x20);
+ EXPECT_EQ(test_write(0, testvalue.data(), testvalue.size()), WEAR_LEVELING_CONSOLIDATED) << "Write returned incorrect status";
+ uint8_t dummy = 0x40;
+ EXPECT_EQ(test_write(0x04, &dummy, sizeof(dummy)), WEAR_LEVELING_SUCCESS) << "Write returned incorrect status";
+
+ // Expected log:
+ // [0,1]: multibyte, 5 bytes, backing address 0x18, logical address 0x00
+ // [2,3]: multibyte, 5 bytes, backing address 0x20, logical address 0x05
+ // [4,5]: multibyte, 5 bytes, backing address 0x28, logical address 0x0A, triggers consolidation
+ // [6]: erase
+ // [7,8]: consolidated data, backing address 0x00, logical address 0x00
+ // [9,10]: consolidated data, backing address 0x08, logical address 0x08
+ // [11,12]: FNV1a_64 result, backing address 0x10
+ // [13]: multibyte, 1 byte, backing address 0x18, logical address 0x04
+ EXPECT_EQ(std::distance(inst.log_begin(), inst.log_end()), 14);
+
+ // Verify the backing store writes for the write log
+ std::size_t index;
+ write_log_entry_t e;
+ for (index = 0; index < 6; ++index) {
+ auto write_iter = inst.log_begin() + index;
+ EXPECT_EQ(write_iter->address, WEAR_LEVELING_LOGICAL_SIZE + 8 + (index * BACKING_STORE_WRITE_SIZE)) << "Invalid write log address";
+
+ // If this is the backing store write that contains the metadata, verify it
+ if (index % 2 == 0) {
+ write_log_entry_t e;
+ e.raw64 = write_iter->value;
+ EXPECT_EQ(LOG_ENTRY_GET_TYPE(e), LOG_ENTRY_TYPE_MULTIBYTE) << "Invalid write log entry type";
+ }
+ }
+
+ // Verify the backing store erase
+ {
+ index = 6;
+ auto write_iter = inst.log_begin() + index;
+ e.raw64 = write_iter->value;
+ EXPECT_TRUE(write_iter->erased) << "Backing store erase did not occur as required";
+ }
+
+ // Verify the backing store writes for consolidation
+ for (index = 7; index < 11; ++index) {
+ auto write_iter = inst.log_begin() + index;
+ EXPECT_EQ(write_iter->address, (index - 7) * BACKING_STORE_WRITE_SIZE) << "Invalid write log entry address";
+ }
+
+ // Verify the FNV1a_64 write
+ {
+ EXPECT_EQ((inst.log_begin() + 11)->address, WEAR_LEVELING_LOGICAL_SIZE) << "Invalid write log address";
+ e.raw32[0] = (inst.log_begin() + 11)->value;
+ e.raw32[1] = (inst.log_begin() + 12)->value;
+ EXPECT_EQ(e.raw64, fnv_64a_buf(testvalue.data(), testvalue.size(), FNV1A_64_INIT)) << "Invalid checksum"; // Note that checksum is based on testvalue, as we overwrote one byte and need to consult the consolidated data, not the current
+ }
+
+ // Verify the final write
+ EXPECT_EQ((inst.log_begin() + 13)->address, WEAR_LEVELING_LOGICAL_SIZE + 8) << "Invalid write log address";
+
+ // Verify the data is what we expected
+ std::array<std::uint8_t, WEAR_LEVELING_LOGICAL_SIZE> readback;
+ EXPECT_EQ(wear_leveling_read(0, readback.data(), WEAR_LEVELING_LOGICAL_SIZE), WEAR_LEVELING_SUCCESS) << "Failed to read back the saved data";
+ EXPECT_TRUE(memcmp(readback.data(), verify_data.data(), WEAR_LEVELING_LOGICAL_SIZE) == 0) << "Readback did not match";
+
+ // Re-init and re-read, verifying the reload capability
+ EXPECT_NE(wear_leveling_init(), WEAR_LEVELING_FAILED) << "Re-initialisation failed";
+ EXPECT_EQ(wear_leveling_read(0, readback.data(), WEAR_LEVELING_LOGICAL_SIZE), WEAR_LEVELING_SUCCESS) << "Failed to read back the saved data";
+ EXPECT_TRUE(memcmp(readback.data(), verify_data.data(), WEAR_LEVELING_LOGICAL_SIZE) == 0) << "Readback did not match";
+}
+
+/**
+ * This test verifies multibyte readback gets canceled with an out-of-bounds address.
+ */
+TEST_F(WearLeveling4Byte, PlaybackReadbackMultibyte_OOB) {
+ auto& inst = MockBackingStore::Instance();
+ auto logstart = inst.storage_begin() + (WEAR_LEVELING_LOGICAL_SIZE / sizeof(backing_store_int_t));
+
+ // Invalid FNV1a_64 hash
+ (logstart + 0)->set(0);
+ (logstart + 1)->set(0);
+
+ // Set up a 2-byte logical write of [0x11,0x12] at logical offset 0x01
+ auto entry0 = LOG_ENTRY_MAKE_MULTIBYTE(0x01, 2);
+ entry0.raw8[3] = 0x11;
+ entry0.raw8[4] = 0x12;
+ (logstart + 2)->set(~entry0.raw32[0]);
+ (logstart + 3)->set(~entry0.raw32[1]);
+
+ // Set up a 2-byte logical write of [0x13,0x14] at logical offset 0x1000 (out of bounds)
+ auto entry1 = LOG_ENTRY_MAKE_MULTIBYTE(0x1000, 2);
+ entry1.raw8[3] = 0x13;
+ entry1.raw8[4] = 0x14;
+ (logstart + 4)->set(~entry1.raw32[0]);
+ (logstart + 5)->set(~entry1.raw32[1]);
+
+ // Set up a 2-byte logical write of [0x15,0x16] at logical offset 0x10
+ auto entry2 = LOG_ENTRY_MAKE_MULTIBYTE(0x01, 2);
+ entry2.raw8[3] = 0x15;
+ entry2.raw8[4] = 0x16;
+ (logstart + 6)->set(~entry2.raw32[0]);
+ (logstart + 7)->set(~entry2.raw32[1]);
+
+ EXPECT_EQ(inst.erasure_count(), 0) << "Invalid initial erase count";
+ EXPECT_EQ(wear_leveling_init(), WEAR_LEVELING_CONSOLIDATED) << "Readback should have failed and triggered consolidation";
+ EXPECT_EQ(inst.erasure_count(), 1) << "Invalid final erase count";
+
+ uint8_t buf[2];
+ wear_leveling_read(0x01, buf, sizeof(buf));
+ EXPECT_EQ(buf[0], 0x11) << "Readback should have maintained the previous pre-failure value from the write log";
+ EXPECT_EQ(buf[1], 0x12) << "Readback should have maintained the previous pre-failure value from the write log";
+}
diff --git a/quantum/wear_leveling/tests/wear_leveling_8byte.cpp b/quantum/wear_leveling/tests/wear_leveling_8byte.cpp
new file mode 100644
index 0000000000..c27c21d034
--- /dev/null
+++ b/quantum/wear_leveling/tests/wear_leveling_8byte.cpp
@@ -0,0 +1,178 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <numeric>
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "backing_mocks.hpp"
+
+class WearLeveling8Byte : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ MockBackingStore::Instance().reset_instance();
+ wear_leveling_init();
+ }
+};
+
+static std::array<std::uint8_t, WEAR_LEVELING_LOGICAL_SIZE> verify_data;
+
+static wear_leveling_status_t test_write(const uint32_t address, const void* value, size_t length) {
+ memcpy(&verify_data[address], value, length);
+ return wear_leveling_write(address, value, length);
+}
+
+/**
+ * This test verifies that the first write after initialisation occurs after the FNV1a_64 hash location.
+ */
+TEST_F(WearLeveling8Byte, FirstWriteOccursAfterHash) {
+ auto& inst = MockBackingStore::Instance();
+ uint8_t test_value = 0x15;
+ test_write(0x02, &test_value, sizeof(test_value));
+ EXPECT_EQ(inst.log_begin()->address, WEAR_LEVELING_LOGICAL_SIZE + 8) << "Invalid first write address.";
+}
+
+/**
+ * This test verifies that the first write after initialisation occurs after the FNV1a_64 hash location, after an erase has occurred.
+ */
+TEST_F(WearLeveling8Byte, FirstWriteOccursAfterHash_AfterErase) {
+ auto& inst = MockBackingStore::Instance();
+ uint8_t test_value = 0x15;
+ wear_leveling_erase();
+ test_write(0x02, &test_value, sizeof(test_value));
+ EXPECT_EQ((inst.log_begin() + 1)->address, WEAR_LEVELING_LOGICAL_SIZE + 8) << "Invalid first write address.";
+}
+
+/**
+ * This test ensures the correct number of backing store writes occurs with a multibyte write, given the input buffer size.
+ */
+TEST_F(WearLeveling8Byte, MultibyteBackingStoreWriteCounts) {
+ auto& inst = MockBackingStore::Instance();
+
+ for (std::size_t length = 1; length <= 5; ++length) {
+ // Clear things out
+ std::fill(verify_data.begin(), verify_data.end(), 0);
+ inst.reset_instance();
+ wear_leveling_init();
+
+ // Generate a test block of data
+ std::vector<std::uint8_t> testvalue(length);
+ std::iota(testvalue.begin(), testvalue.end(), 0x20);
+
+ // Write the data
+ EXPECT_EQ(test_write(0, testvalue.data(), testvalue.size()), WEAR_LEVELING_SUCCESS) << "Write failed with incorrect status";
+
+ // Check that we got the expected number of write log entries
+ EXPECT_EQ(std::distance(inst.log_begin(), inst.log_end()), 1);
+ }
+}
+
+/**
+ * This test forces consolidation by writing enough to the write log that it overflows, consolidating the data into the
+ * base logical area.
+ */
+TEST_F(WearLeveling8Byte, ConsolidationOverflow) {
+ auto& inst = MockBackingStore::Instance();
+
+ // Generate a test block of data
+ std::array<std::uint8_t, WEAR_LEVELING_LOGICAL_SIZE> testvalue;
+
+ // Write the data
+ std::iota(testvalue.begin(), testvalue.end(), 0x20);
+ EXPECT_EQ(test_write(0, testvalue.data(), testvalue.size()), WEAR_LEVELING_CONSOLIDATED) << "Write returned incorrect status";
+ uint8_t dummy = 0x40;
+ EXPECT_EQ(test_write(0x04, &dummy, sizeof(dummy)), WEAR_LEVELING_SUCCESS) << "Write returned incorrect status";
+
+ // Expected log:
+ // [0]: multibyte, 5 bytes, backing address 0x18, logical address 0x00
+ // [1]: multibyte, 5 bytes, backing address 0x20, logical address 0x05
+ // [2]: multibyte, 5 bytes, backing address 0x28, logical address 0x0A, triggers consolidation
+ // [3]: erase
+ // [4]: consolidated data, backing address 0x00, logical address 0x00
+ // [5]: consolidated data, backing address 0x08, logical address 0x08
+ // [6]: FNV1a_64 result, backing address 0x10
+ // [7]: multibyte, 1 byte, backing address 0x18, logical address 0x04
+ EXPECT_EQ(std::distance(inst.log_begin(), inst.log_end()), 8);
+
+ // Verify the backing store writes for the write log
+ std::size_t index;
+ write_log_entry_t e;
+ for (index = 0; index < 3; ++index) {
+ auto write_iter = inst.log_begin() + index;
+ EXPECT_EQ(write_iter->address, WEAR_LEVELING_LOGICAL_SIZE + 8 + (index * BACKING_STORE_WRITE_SIZE)) << "Invalid write log address";
+
+ write_log_entry_t e;
+ e.raw64 = write_iter->value;
+ EXPECT_EQ(LOG_ENTRY_GET_TYPE(e), LOG_ENTRY_TYPE_MULTIBYTE) << "Invalid write log entry type";
+ }
+
+ // Verify the backing store erase
+ {
+ index = 3;
+ auto write_iter = inst.log_begin() + index;
+ e.raw64 = write_iter->value;
+ EXPECT_TRUE(write_iter->erased) << "Backing store erase did not occur as required";
+ }
+
+ // Verify the backing store writes for consolidation
+ for (index = 4; index < 6; ++index) {
+ auto write_iter = inst.log_begin() + index;
+ EXPECT_EQ(write_iter->address, (index - 4) * BACKING_STORE_WRITE_SIZE) << "Invalid write log entry address";
+ }
+
+ // Verify the FNV1a_64 write
+ {
+ EXPECT_EQ((inst.log_begin() + 6)->address, WEAR_LEVELING_LOGICAL_SIZE) << "Invalid write log address";
+ e.raw64 = (inst.log_begin() + 6)->value;
+ EXPECT_EQ(e.raw64, fnv_64a_buf(testvalue.data(), testvalue.size(), FNV1A_64_INIT)) << "Invalid checksum"; // Note that checksum is based on testvalue, as we overwrote one byte and need to consult the consolidated data, not the current
+ }
+
+ // Verify the final write
+ EXPECT_EQ((inst.log_begin() + 7)->address, WEAR_LEVELING_LOGICAL_SIZE + 8) << "Invalid write log address";
+
+ // Verify the data is what we expected
+ std::array<std::uint8_t, WEAR_LEVELING_LOGICAL_SIZE> readback;
+ EXPECT_EQ(wear_leveling_read(0, readback.data(), WEAR_LEVELING_LOGICAL_SIZE), WEAR_LEVELING_SUCCESS) << "Failed to read back the saved data";
+ EXPECT_TRUE(memcmp(readback.data(), verify_data.data(), WEAR_LEVELING_LOGICAL_SIZE) == 0) << "Readback did not match";
+
+ // Re-init and re-read, verifying the reload capability
+ EXPECT_NE(wear_leveling_init(), WEAR_LEVELING_FAILED) << "Re-initialisation failed";
+ EXPECT_EQ(wear_leveling_read(0, readback.data(), WEAR_LEVELING_LOGICAL_SIZE), WEAR_LEVELING_SUCCESS) << "Failed to read back the saved data";
+ EXPECT_TRUE(memcmp(readback.data(), verify_data.data(), WEAR_LEVELING_LOGICAL_SIZE) == 0) << "Readback did not match";
+}
+
+/**
+ * This test verifies multibyte readback gets canceled with an out-of-bounds address.
+ */
+TEST_F(WearLeveling8Byte, PlaybackReadbackMultibyte_OOB) {
+ auto& inst = MockBackingStore::Instance();
+ auto logstart = inst.storage_begin() + (WEAR_LEVELING_LOGICAL_SIZE / sizeof(backing_store_int_t));
+
+ // Invalid FNV1a_64 hash
+ (logstart + 0)->set(0);
+
+ // Set up a 2-byte logical write of [0x11,0x12] at logical offset 0x01
+ auto entry0 = LOG_ENTRY_MAKE_MULTIBYTE(0x01, 2);
+ entry0.raw8[3] = 0x11;
+ entry0.raw8[4] = 0x12;
+ (logstart + 1)->set(~entry0.raw64);
+
+ // Set up a 2-byte logical write of [0x13,0x14] at logical offset 0x1000 (out of bounds)
+ auto entry1 = LOG_ENTRY_MAKE_MULTIBYTE(0x1000, 2);
+ entry1.raw8[3] = 0x13;
+ entry1.raw8[4] = 0x14;
+ (logstart + 2)->set(~entry1.raw64);
+
+ // Set up a 2-byte logical write of [0x15,0x16] at logical offset 0x10
+ auto entry2 = LOG_ENTRY_MAKE_MULTIBYTE(0x01, 2);
+ entry2.raw8[3] = 0x15;
+ entry2.raw8[4] = 0x16;
+ (logstart + 3)->set(~entry2.raw64);
+
+ EXPECT_EQ(inst.erasure_count(), 0) << "Invalid initial erase count";
+ EXPECT_EQ(wear_leveling_init(), WEAR_LEVELING_CONSOLIDATED) << "Readback should have failed and triggered consolidation";
+ EXPECT_EQ(inst.erasure_count(), 1) << "Invalid final erase count";
+
+ uint8_t buf[2];
+ wear_leveling_read(0x01, buf, sizeof(buf));
+ EXPECT_EQ(buf[0], 0x11) << "Readback should have maintained the previous pre-failure value from the write log";
+ EXPECT_EQ(buf[1], 0x12) << "Readback should have maintained the previous pre-failure value from the write log";
+}
diff --git a/quantum/wear_leveling/tests/wear_leveling_general.cpp b/quantum/wear_leveling/tests/wear_leveling_general.cpp
new file mode 100644
index 0000000000..76a4bf7bf3
--- /dev/null
+++ b/quantum/wear_leveling/tests/wear_leveling_general.cpp
@@ -0,0 +1,204 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <numeric>
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "backing_mocks.hpp"
+
+class WearLevelingGeneral : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ MockBackingStore::Instance().reset_instance();
+ wear_leveling_init();
+ }
+};
+
+/**
+ * This test verifies that even if there is consolidated data present, if the checksum doesn't match then the cache is zero'd after reading the consolidated area, but before write log is played back.
+ */
+TEST_F(WearLevelingGeneral, InvalidChecksum_ConsolidatedDataIgnored) {
+ auto& inst = MockBackingStore::Instance();
+ auto logstart = inst.storage_begin() + (WEAR_LEVELING_LOGICAL_SIZE / sizeof(backing_store_int_t));
+
+ // Generate a test block of data
+ std::array<std::uint8_t, WEAR_LEVELING_LOGICAL_SIZE> testvalue;
+ std::iota(testvalue.begin(), testvalue.end(), 0x20);
+
+ // Write the data
+ EXPECT_EQ(wear_leveling_write(0, testvalue.data(), testvalue.size()), WEAR_LEVELING_CONSOLIDATED) << "Write returned incorrect status";
+
+ // Invalidate the checksum
+ (logstart + 0)->erase();
+ (logstart + 1)->erase();
+ (logstart + 2)->erase();
+ (logstart + 3)->erase();
+
+ // Set up a 1-byte logical write of [0x11] at logical offset 0x01
+ auto entry0 = LOG_ENTRY_MAKE_OPTIMIZED_64(0x01, 0x11);
+ (logstart + 4)->set(~entry0.raw16[0]);
+
+ // Re-init
+ EXPECT_EQ(wear_leveling_init(), WEAR_LEVELING_SUCCESS) << "Init returned incorrect status";
+ EXPECT_EQ(wear_leveling_read(0, testvalue.data(), testvalue.size()), WEAR_LEVELING_SUCCESS) << "Failed to read";
+ for (int i = 0; i < WEAR_LEVELING_LOGICAL_SIZE; ++i) {
+ EXPECT_EQ(testvalue[i], i == 0x01 ? 0x11 : 0x00) << "Invalid readback";
+ }
+}
+
+/**
+ * This test verifies that writing the same data multiple times does not result in subsequent writes to the backing store.
+ */
+TEST_F(WearLevelingGeneral, SameValue_SingleBackingWrite) {
+ auto& inst = MockBackingStore::Instance();
+
+ uint8_t test_val = 0x14;
+ EXPECT_EQ(wear_leveling_write(0x02, &test_val, sizeof(test_val)), WEAR_LEVELING_SUCCESS) << "First overall write operation should have succeeded";
+
+ uint64_t invoke_count = inst.unlock_invoke_count();
+ uint64_t erase_count = inst.erase_invoke_count();
+ uint64_t write_count = inst.write_invoke_count();
+ uint64_t lock_count = inst.lock_invoke_count();
+
+ for (int i = 0; i < 10; ++i) {
+ EXPECT_EQ(wear_leveling_write(0x02, &test_val, sizeof(test_val)), WEAR_LEVELING_SUCCESS) << "Subsequent overall write operation should have succeeded";
+
+ EXPECT_EQ(inst.unlock_invoke_count(), invoke_count) << "Unlock count should match";
+ EXPECT_EQ(inst.erase_invoke_count(), erase_count) << "Erase count should match";
+ EXPECT_EQ(inst.write_invoke_count(), write_count) << "Write count should match";
+ EXPECT_EQ(inst.lock_invoke_count(), lock_count) << "Lock count should match";
+ }
+}
+
+/**
+ * This test verifies that no other invocations occur if `backing_store_init()` fails.
+ */
+TEST_F(WearLevelingGeneral, InitFailure) {
+ auto& inst = MockBackingStore::Instance();
+ inst.reset_instance(); // make sure the counters are all zero
+ inst.set_init_callback([](std::uint64_t count) { return false; });
+
+ EXPECT_EQ(inst.erasure_count(), 0) << "Invalid initial erase count";
+ EXPECT_EQ(wear_leveling_init(), WEAR_LEVELING_FAILED) << "Init should have failed";
+ EXPECT_EQ(inst.erasure_count(), 0) << "Invalid final erase count";
+
+ EXPECT_EQ(inst.init_invoke_count(), 1) << "Init should have been invoked once";
+ EXPECT_EQ(inst.unlock_invoke_count(), 0) << "Unlock should not have been invoked";
+ EXPECT_EQ(inst.erase_invoke_count(), 0) << "Erase should not have been invoked";
+ EXPECT_EQ(inst.write_invoke_count(), 0) << "Write should not have been invoked";
+ EXPECT_EQ(inst.lock_invoke_count(), 0) << "Lock should not have been invoked";
+}
+
+/**
+ * This test verifies that no invocations occur if the supplied address is out of range while writing.
+ */
+TEST_F(WearLevelingGeneral, WriteFailure_OOB) {
+ auto& inst = MockBackingStore::Instance();
+
+ uint8_t test_val = 0x14;
+ EXPECT_EQ(wear_leveling_write(0x21349830, &test_val, sizeof(test_val)), WEAR_LEVELING_FAILED) << "Overall write operation should have failed";
+
+ EXPECT_EQ(inst.unlock_invoke_count(), 0) << "Unlock should not have been invoked";
+ EXPECT_EQ(inst.erase_invoke_count(), 0) << "Erase should not have been invoked";
+ EXPECT_EQ(inst.write_invoke_count(), 0) << "Write should not have been invoked";
+ EXPECT_EQ(inst.lock_invoke_count(), 0) << "Lock should not have been invoked";
+}
+
+/**
+ * This test verifies that a single write occurs if the supplied address and data length hits the edge of the logical area.
+ */
+TEST_F(WearLevelingGeneral, WriteSuccess_BoundaryOK) {
+ auto& inst = MockBackingStore::Instance();
+
+ uint16_t test_val = 0x14;
+ EXPECT_EQ(wear_leveling_write(WEAR_LEVELING_LOGICAL_SIZE - sizeof(test_val), &test_val, sizeof(test_val)), WEAR_LEVELING_SUCCESS) << "Overall write operation should have succeeded";
+
+ EXPECT_EQ(inst.unlock_invoke_count(), 1) << "Unlock should have been invoked once";
+ EXPECT_EQ(inst.erase_invoke_count(), 0) << "Erase should not have been invoked";
+ EXPECT_EQ(inst.write_invoke_count(), 2) << "Write should have been invoked twice";
+ EXPECT_EQ(inst.lock_invoke_count(), 1) << "Lock should have been invoked once";
+}
+
+/**
+ * This test verifies that no invocations occur if the supplied address and length would generate writes outside the logical range.
+ */
+TEST_F(WearLevelingGeneral, WriteFailure_BoundaryOverflow) {
+ auto& inst = MockBackingStore::Instance();
+
+ uint16_t test_val = 0x14;
+ EXPECT_EQ(wear_leveling_write(WEAR_LEVELING_LOGICAL_SIZE - sizeof(test_val) + 1, &test_val, sizeof(test_val)), WEAR_LEVELING_FAILED) << "Overall write operation should have failed";
+
+ EXPECT_EQ(inst.unlock_invoke_count(), 0) << "Unlock should not have been invoked";
+ EXPECT_EQ(inst.erase_invoke_count(), 0) << "Erase should not have been invoked";
+ EXPECT_EQ(inst.write_invoke_count(), 0) << "Write should not have been invoked";
+ EXPECT_EQ(inst.lock_invoke_count(), 0) << "Lock should not have been invoked";
+}
+
+/**
+ * This test verifies that no invocations occur if the supplied address is out of range while reading.
+ */
+TEST_F(WearLevelingGeneral, ReadFailure_OOB) {
+ auto& inst = MockBackingStore::Instance();
+
+ uint8_t test_val = 0;
+ EXPECT_EQ(wear_leveling_read(0x21349830, &test_val, sizeof(test_val)), WEAR_LEVELING_FAILED) << "Overall read operation should have failed";
+
+ EXPECT_EQ(inst.unlock_invoke_count(), 0) << "Unlock should not have been invoked";
+ EXPECT_EQ(inst.erase_invoke_count(), 0) << "Erase should not have been invoked";
+ EXPECT_EQ(inst.write_invoke_count(), 0) << "Write should not have been invoked";
+ EXPECT_EQ(inst.lock_invoke_count(), 0) << "Lock should not have been invoked";
+}
+
+/**
+ * This test verifies that no write invocations occur if `backing_store_unlock()` fails.
+ */
+TEST_F(WearLevelingGeneral, UnlockFailure_NoWrite) {
+ auto& inst = MockBackingStore::Instance();
+ inst.set_unlock_callback([](std::uint64_t count) { return false; });
+
+ uint8_t test_val = 0x14;
+ EXPECT_EQ(wear_leveling_write(0x04, &test_val, sizeof(test_val)), WEAR_LEVELING_FAILED) << "Overall write operation should have failed";
+
+ EXPECT_EQ(inst.unlock_invoke_count(), 1) << "Unlock should have been invoked once";
+ EXPECT_EQ(inst.erase_invoke_count(), 0) << "Erase should not have been invoked";
+ EXPECT_EQ(inst.write_invoke_count(), 0) << "Write should not have been invoked";
+ EXPECT_EQ(inst.lock_invoke_count(), 0) << "Lock should not have been invoked";
+
+ test_val = 0;
+ wear_leveling_read(0x04, &test_val, sizeof(test_val));
+ EXPECT_EQ(test_val, 0x14) << "Readback should come from cache regardless of unlock failure";
+}
+
+/**
+ * This test verifies that no erase invocations occur if `backing_store_unlock()` fails.
+ */
+TEST_F(WearLevelingGeneral, UnlockFailure_NoErase) {
+ auto& inst = MockBackingStore::Instance();
+ inst.set_unlock_callback([](std::uint64_t count) { return false; });
+
+ EXPECT_EQ(wear_leveling_erase(), WEAR_LEVELING_FAILED) << "Overall erase operation should have failed";
+
+ EXPECT_EQ(inst.unlock_invoke_count(), 1) << "Unlock should have been invoked once";
+ EXPECT_EQ(inst.erase_invoke_count(), 0) << "Erase should not have been invoked";
+ EXPECT_EQ(inst.write_invoke_count(), 0) << "Write should not have been invoked";
+ EXPECT_EQ(inst.lock_invoke_count(), 0) << "Lock should not have been invoked";
+}
+
+/**
+ * This test verifies that only one write invocation occurs if `backing_store_write()` fails.
+ */
+TEST_F(WearLevelingGeneral, WriteFailure_NoSubsequentWrites) {
+ auto& inst = MockBackingStore::Instance();
+ inst.set_write_callback([](std::uint64_t count, std::uint32_t address) { return false; });
+
+ uint8_t test_val = 0x14;
+ EXPECT_EQ(wear_leveling_write(0x04, &test_val, sizeof(test_val)), WEAR_LEVELING_FAILED) << "Overall write operation should have failed";
+
+ EXPECT_EQ(inst.unlock_invoke_count(), 1) << "Unlock should have been invoked once";
+ EXPECT_EQ(inst.erase_invoke_count(), 0) << "Erase should not have been invoked";
+ EXPECT_EQ(inst.write_invoke_count(), 1) << "Write should have been invoked once";
+ EXPECT_EQ(inst.lock_invoke_count(), 1) << "Lock should have been invoked once";
+
+ test_val = 0;
+ wear_leveling_read(0x04, &test_val, sizeof(test_val));
+ EXPECT_EQ(test_val, 0x14) << "Readback should come from cache regardless of unlock failure";
+}
diff --git a/quantum/wear_leveling/wear_leveling.c b/quantum/wear_leveling/wear_leveling.c
new file mode 100644
index 0000000000..429df45df5
--- /dev/null
+++ b/quantum/wear_leveling/wear_leveling.c
@@ -0,0 +1,768 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <stdbool.h>
+#include "fnv.h"
+#include "wear_leveling.h"
+#include "wear_leveling_internal.h"
+
+/*
+ This wear leveling algorithm is adapted from algorithms from previous
+ implementations in QMK, namely:
+ - Artur F. (http://engsta.com/stm32-flash-memory-eeprom-emulator/)
+ - Yiancar -- QMK's base implementation for STM32F303
+ - Ilya Zhuravlev -- initial wear leveling algorithm
+ - Don Kjer -- increased flash density algorithm
+ - Nick Brassel (@tzarc) -- decoupled for use on other peripherals
+
+ At this layer, it is assumed that any reads/writes from the backing store
+ have a "reset state" after erasure of zero.
+ It is up to the backing store to perform translation of values, such as
+ taking the complement in order to deal with flash memory's reset value.
+
+ Terminology:
+
+ - Backing store: this is the storage area used by the wear leveling
+ algorithm.
+
+ - Backing size: this is the amount of storage provided by the backing
+ store for use by the wear leveling algorithm.
+
+ - Backing write size: this is the minimum number of bytes the backing
+ store can write in a single operation.
+
+ - Logical data: this is the externally-visible "emulated EEPROM" that
+ external subsystems "see" when performing reads/writes.
+
+ - Logical size: this is the amount of storage available for use
+ externally. Effectively, the "size of the EEPROM".
+
+ - Write log: this is a section of the backing store used to keep track
+ of modifications without overwriting existing data. This log is
+ "played back" on startup such that any subsequent reads are capable
+ of returning the latest data.
+
+ - Consolidated data: this is a section of the backing store reserved for
+ use for the latest copy of logical data. This is only ever written
+ when the write log is full -- the latest values for the logical data
+ are written here and the write log is cleared.
+
+ Configurables:
+
+ - BACKING_STORE_WRITE_SIZE: The number of bytes requires for a write
+ operation. This is defined by the capabilities of the backing store.
+
+ - WEAR_LEVELING_BACKING_SIZE: The number of bytes provided by the
+ backing store for use by the wear leveling algorithm. This is
+ defined by the capabilities of the backing store. This value must
+ also be at least twice the size of the logical size, as well as a
+ multiple of the logical size.
+
+ - WEAR_LEVELING_LOGICAL_SIZE: The number of bytes externally visible
+ to other subsystems performing reads/writes. This must be a multiple
+ of the write size.
+
+ General algorithm:
+
+ During initialization:
+ * The contents of the consolidated data section are read into cache.
+ * The contents of the write log are "played back" and update the
+ cache accordingly.
+
+ During reads:
+ * Logical data is served from the cache.
+
+ During writes:
+ * The cache is updated with the new data.
+ * A new write log entry is appended to the log.
+ * If the log's full, data is consolidated and the write log cleared.
+
+ Write log structure:
+
+ The first 8 bytes of the write log are a FNV1a_64 hash of the contents
+ of the consolidated data area, in an attempt to detect and guard against
+ any data corruption.
+
+ The write log follows the hash:
+
+ Given that the algorithm needs to cater for 2-, 4-, and 8-byte writes,
+ a variable-length write log entry is used such that the minimal amount
+ of storage is used based off the backing store write size.
+
+ Firstly, an empty log entry is expected to be all zeros. If the backing
+ store uses 0xFF for cleared bytes, it should return the complement, such
+ that this wear-leveling algorithm "receives" zeros.
+
+ For multi-byte writes, up to 8 bytes will be used for each log entry,
+ depending on the size of backing store writes:
+
+ ╔ Multi-byte Log Entry (2, 4-byte) ═╗
+ ║00XXXYYY║YYYYYYYY║YYYYYYYY║AAAAAAAA║
+ ║ └┬┘└┬┘║└──┬───┘║└──┬───┘║└──┬───┘║
+ ║ LenAdd║ Address║ Address║Value[0]║
+ ╚════════╩════════╩════════╩════════╝
+ ╔ Multi-byte Log Entry (2-byte) ══════════════════════╗
+ ║00XXXYYY║YYYYYYYY║YYYYYYYY║AAAAAAAA║BBBBBBBB║CCCCCCCC║
+ ║ └┬┘└┬┘║└──┬───┘║└──┬───┘║└──┬───┘║└──┬───┘║└──┬───┘║
+ ║ LenAdd║ Address║ Address║Value[0]║Value[1]║Value[2]║
+ ╚════════╩════════╩════════╩════════╩════════╩════════╝
+ ╔ Multi-byte Log Entry (2, 4, 8-byte) ══════════════════════════════════╗
+ ║00XXXYYY║YYYYYYYY║YYYYYYYY║AAAAAAAA║BBBBBBBB║CCCCCCCC║DDDDDDDD║EEEEEEEE║
+ ║ └┬┘└┬┘║└──┬───┘║└──┬───┘║└──┬───┘║└──┬───┘║└──┬───┘║└──┬───┘║└──┬───┘║
+ ║ LenAdd║ Address║ Address║Value[0]║Value[1]║Value[2]║Value[3]║Value[4]║
+ ╚════════╩════════╩════════╩════════╩════════╩════════╩════════╩════════╝
+
+ 19 bits are used for the address, which allows for a max logical size of
+ 512kB. Up to 5 bytes can be included in a single log entry.
+
+ For 2-byte backing store writes, the last two bytes are optional
+ depending on the length of data to be written. Accordingly, either 3
+ or 4 backing store write operations will occur.
+ For 4-byte backing store writes, either one or two write operations
+ occur, depending on the length.
+ For 8-byte backing store writes, one write operation occur.
+
+ 2-byte backing store optimizations:
+
+ For single byte writes, addresses between 0...63 are encoded in a single
+ backing store write operation. 4- and 8-byte backing stores do not have
+ this optimization as it does not minimize the number of bytes written.
+
+ ╔ Byte-Entry ════╗
+ ║01XXXXXXYYYYYYYY║
+ ║ └─┬──┘└──┬───┘║
+ ║ Address Value ║
+ ╚════════════════╝
+ 0 <= Address < 0x40 (64)
+
+ A second optimization takes into account uint16_t writes of 0 or 1,
+ specifically catering for KC_NO and KC_TRANSPARENT in the dynamic keymap
+ subsystem. This is valid only for the first 16kB of logical data --
+ addresses outside this range will use the multi-byte encoding above.
+
+ ╔ U16-Encoded 0 ═╗
+ ║100XXXXXXXXXXXXX║
+ ║ │└─────┬─────┘║
+ ║ │Address >> 1 ║
+ ║ └── Value: 0 ║
+ ╚════════════════╝
+ 0 <= Address <= 0x3FFE (16382)
+
+ ╔ U16-Encoded 1 ═╗
+ ║101XXXXXXXXXXXXX║
+ ║ │└─────┬─────┘║
+ ║ │Address >> 1 ║
+ ║ └── Value: 1 ║
+ ╚════════════════╝
+ 0 <= Address <= 0x3FFE (16382) */
+
+/**
+ * Storage area for the wear-leveling cache.
+ */
+static struct __attribute__((__aligned__(BACKING_STORE_WRITE_SIZE))) {
+ __attribute__((__aligned__(BACKING_STORE_WRITE_SIZE))) uint8_t cache[(WEAR_LEVELING_LOGICAL_SIZE)];
+ uint32_t write_address;
+ bool unlocked;
+} wear_leveling;
+
+/**
+ * Locking helper: status
+ */
+typedef enum backing_store_lock_status_t { STATUS_FAILURE = 0, STATUS_SUCCESS, STATUS_UNCHANGED } backing_store_lock_status_t;
+
+/**
+ * Locking helper: unlock
+ */
+static inline backing_store_lock_status_t wear_leveling_unlock(void) {
+ if (wear_leveling.unlocked) {
+ return STATUS_UNCHANGED;
+ }
+ if (!backing_store_unlock()) {
+ return STATUS_FAILURE;
+ }
+ wear_leveling.unlocked = true;
+ return STATUS_SUCCESS;
+}
+
+/**
+ * Locking helper: lock
+ */
+static inline backing_store_lock_status_t wear_leveling_lock(void) {
+ if (!wear_leveling.unlocked) {
+ return STATUS_UNCHANGED;
+ }
+ if (!backing_store_lock()) {
+ return STATUS_FAILURE;
+ }
+ wear_leveling.unlocked = false;
+ return STATUS_SUCCESS;
+}
+
+/**
+ * Resets the cache, ensuring the write address is correctly initialised.
+ */
+static void wear_leveling_clear_cache(void) {
+ memset(wear_leveling.cache, 0, (WEAR_LEVELING_LOGICAL_SIZE));
+ wear_leveling.write_address = (WEAR_LEVELING_LOGICAL_SIZE) + 8; // +8 is due to the FNV1a_64 of the consolidated buffer
+}
+
+/**
+ * Reads the consolidated data from the backing store into the cache.
+ * Does not consider the write log.
+ */
+static wear_leveling_status_t wear_leveling_read_consolidated(void) {
+ wl_dprintf("Reading consolidated data\n");
+
+ wear_leveling_status_t status = WEAR_LEVELING_SUCCESS;
+ if (!backing_store_read_bulk(0, (backing_store_int_t *)wear_leveling.cache, sizeof(wear_leveling.cache) / sizeof(backing_store_int_t))) {
+ wl_dprintf("Failed to read from backing store\n");
+ status = WEAR_LEVELING_FAILED;
+ }
+
+ // Verify the FNV1a_64 result
+ if (status != WEAR_LEVELING_FAILED) {
+ uint64_t expected = fnv_64a_buf(wear_leveling.cache, (WEAR_LEVELING_LOGICAL_SIZE), FNV1A_64_INIT);
+ write_log_entry_t entry;
+ wl_dprintf("Reading checksum\n");
+#if BACKING_STORE_WRITE_SIZE == 2
+ backing_store_read_bulk((WEAR_LEVELING_LOGICAL_SIZE), entry.raw16, 4);
+#elif BACKING_STORE_WRITE_SIZE == 4
+ backing_store_read_bulk((WEAR_LEVELING_LOGICAL_SIZE), entry.raw32, 2);
+#elif BACKING_STORE_WRITE_SIZE == 8
+ backing_store_read((WEAR_LEVELING_LOGICAL_SIZE) + 0, &entry.raw64);
+#endif
+ // If we have a mismatch, clear the cache but do not flag a failure,
+ // which will cater for the completely clean MCU case.
+ if (entry.raw64 == expected) {
+ wl_dprintf("Checksum matches, consolidated data is correct\n");
+ } else {
+ wl_dprintf("Checksum mismatch, clearing cache\n");
+ wear_leveling_clear_cache();
+ }
+ }
+
+ // If we failed for any reason, then clear the cache
+ if (status == WEAR_LEVELING_FAILED) {
+ wear_leveling_clear_cache();
+ }
+
+ return status;
+}
+
+/**
+ * Writes the current cache to consolidated data at the beginning of the backing store.
+ * Does not clear the write log.
+ * Pre-condition: this is just after an erase, so we can write directly without reading.
+ */
+static wear_leveling_status_t wear_leveling_write_consolidated(void) {
+ wl_dprintf("Writing consolidated data\n");
+
+ backing_store_lock_status_t lock_status = wear_leveling_unlock();
+ wear_leveling_status_t status = WEAR_LEVELING_CONSOLIDATED;
+ if (!backing_store_write_bulk(0, (backing_store_int_t *)wear_leveling.cache, sizeof(wear_leveling.cache) / sizeof(backing_store_int_t))) {
+ wl_dprintf("Failed to write to backing store\n");
+ status = WEAR_LEVELING_FAILED;
+ }
+
+ if (status != WEAR_LEVELING_FAILED) {
+ // Write out the FNV1a_64 result of the consolidated data
+ write_log_entry_t entry;
+ entry.raw64 = fnv_64a_buf(wear_leveling.cache, (WEAR_LEVELING_LOGICAL_SIZE), FNV1A_64_INIT);
+ wl_dprintf("Writing checksum\n");
+ do {
+#if BACKING_STORE_WRITE_SIZE == 2
+ if (!backing_store_write_bulk((WEAR_LEVELING_LOGICAL_SIZE), entry.raw16, 4)) {
+ status = WEAR_LEVELING_FAILED;
+ break;
+ }
+#elif BACKING_STORE_WRITE_SIZE == 4
+ if (!backing_store_write_bulk((WEAR_LEVELING_LOGICAL_SIZE), entry.raw32, 2)) {
+ status = WEAR_LEVELING_FAILED;
+ break;
+ }
+#elif BACKING_STORE_WRITE_SIZE == 8
+ if (!backing_store_write((WEAR_LEVELING_LOGICAL_SIZE), entry.raw64)) {
+ status = WEAR_LEVELING_FAILED;
+ break;
+ }
+#endif
+ } while (0);
+ }
+
+ if (lock_status == STATUS_SUCCESS) {
+ wear_leveling_lock();
+ }
+ return status;
+}
+
+/**
+ * Forces a write of the current cache.
+ * Erases the backing store, including the write log.
+ * During this operation, there is the potential for data loss if a power loss occurs.
+ */
+static wear_leveling_status_t wear_leveling_consolidate_force(void) {
+ wl_dprintf("Erasing backing store\n");
+
+ // Erase the backing store. Expectation is that any un-written values that are read back after this call come back as zero.
+ bool ok = backing_store_erase();
+ if (!ok) {
+ wl_dprintf("Failed to erase backing store\n");
+ return WEAR_LEVELING_FAILED;
+ }
+
+ // Write the cache to the first section of the backing store.
+ wear_leveling_status_t status = wear_leveling_write_consolidated();
+ if (status == WEAR_LEVELING_FAILED) {
+ wl_dprintf("Failed to write consolidated data\n");
+ }
+
+ // Next write of the log occurs after the consolidated values at the start of the backing store.
+ wear_leveling.write_address = (WEAR_LEVELING_LOGICAL_SIZE) + 8; // +8 due to the FNV1a_64 of the consolidated area
+
+ return status;
+}
+
+/**
+ * Potential write of the current cache to the backing store.
+ * Skipped if the current write log position is not at the end of the backing store.
+ * During this operation, there is the potential for data loss if a power loss occurs.
+ *
+ * @return true if consolidation occurred
+ */
+static wear_leveling_status_t wear_leveling_consolidate_if_needed(void) {
+ if (wear_leveling.write_address >= (WEAR_LEVELING_BACKING_SIZE)) {
+ return wear_leveling_consolidate_force();
+ }
+
+ return WEAR_LEVELING_SUCCESS;
+}
+
+/**
+ * Appends the supplied fixed-width entry to the write log, optionally consolidating if the log is full.
+ *
+ * @return true if consolidation occurred
+ */
+static wear_leveling_status_t wear_leveling_append_raw(backing_store_int_t value) {
+ bool ok = backing_store_write(wear_leveling.write_address, value);
+ if (!ok) {
+ wl_dprintf("Failed to write to backing store\n");
+ return WEAR_LEVELING_FAILED;
+ }
+ wear_leveling.write_address += (BACKING_STORE_WRITE_SIZE);
+ return wear_leveling_consolidate_if_needed();
+}
+
+/**
+ * Handles writing multi_byte-encoded data to the backing store.
+ *
+ * @return true if consolidation occurred
+ */
+static wear_leveling_status_t wear_leveling_write_raw_multibyte(uint32_t address, const void *value, size_t length) {
+ const uint8_t * p = value;
+ write_log_entry_t log = LOG_ENTRY_MAKE_MULTIBYTE(address, length);
+ for (size_t i = 0; i < length; ++i) {
+ log.raw8[3 + i] = p[i];
+ }
+
+ // Write to the backing store. See the multi-byte log format in the documentation header at the top of the file.
+ wear_leveling_status_t status;
+#if BACKING_STORE_WRITE_SIZE == 2
+ status = wear_leveling_append_raw(log.raw16[0]);
+ if (status != WEAR_LEVELING_SUCCESS) {
+ return status;
+ }
+
+ status = wear_leveling_append_raw(log.raw16[1]);
+ if (status != WEAR_LEVELING_SUCCESS) {
+ return status;
+ }
+
+ if (length > 1) {
+ status = wear_leveling_append_raw(log.raw16[2]);
+ if (status != WEAR_LEVELING_SUCCESS) {
+ return status;
+ }
+ }
+
+ if (length > 3) {
+ status = wear_leveling_append_raw(log.raw16[3]);
+ if (status != WEAR_LEVELING_SUCCESS) {
+ return status;
+ }
+ }
+#elif BACKING_STORE_WRITE_SIZE == 4
+ status = wear_leveling_append_raw(log.raw32[0]);
+ if (status != WEAR_LEVELING_SUCCESS) {
+ return status;
+ }
+
+ if (length > 1) {
+ status = wear_leveling_append_raw(log.raw32[1]);
+ if (status != WEAR_LEVELING_SUCCESS) {
+ return status;
+ }
+ }
+#elif BACKING_STORE_WRITE_SIZE == 8
+ status = wear_leveling_append_raw(log.raw64);
+ if (status != WEAR_LEVELING_SUCCESS) {
+ return status;
+ }
+#endif
+ return status;
+}
+
+/**
+ * Handles the actual writing of logical data into the write log section of the backing store.
+ */
+static wear_leveling_status_t wear_leveling_write_raw(uint32_t address, const void *value, size_t length) {
+ const uint8_t * p = value;
+ size_t remaining = length;
+ wear_leveling_status_t status = WEAR_LEVELING_SUCCESS;
+ while (remaining > 0) {
+#if BACKING_STORE_WRITE_SIZE == 2
+ // Small-write optimizations - uint16_t, 0 or 1, address is even, address <16384:
+ if (remaining >= 2 && address % 2 == 0 && address < 16384) {
+ const uint16_t v = ((uint16_t)p[1]) << 8 | p[0]; // don't just dereference a uint16_t here -- if unaligned it generates faults on some MCUs
+ if (v == 0 || v == 1) {
+ const write_log_entry_t log = LOG_ENTRY_MAKE_WORD_01(address, v);
+ status = wear_leveling_append_raw(log.raw16[0]);
+ if (status != WEAR_LEVELING_SUCCESS) {
+ // If consolidation occurred, then the cache has already been written to the consolidated area. No need to continue.
+ // If a failure occurred, pass it on.
+ return status;
+ }
+
+ remaining -= 2;
+ address += 2;
+ p += 2;
+ continue;
+ }
+ }
+
+ // Small-write optimizations - address<64:
+ if (address < 64) {
+ const write_log_entry_t log = LOG_ENTRY_MAKE_OPTIMIZED_64(address, *p);
+ status = wear_leveling_append_raw(log.raw16[0]);
+ if (status != WEAR_LEVELING_SUCCESS) {
+ // If consolidation occurred, then the cache has already been written to the consolidated area. No need to continue.
+ // If a failure occurred, pass it on.
+ return status;
+ }
+
+ remaining--;
+ address++;
+ p++;
+ continue;
+ }
+#endif // BACKING_STORE_WRITE_SIZE == 2
+ const size_t this_length = remaining >= LOG_ENTRY_MULTIBYTE_MAX_BYTES ? LOG_ENTRY_MULTIBYTE_MAX_BYTES : remaining;
+ status = wear_leveling_write_raw_multibyte(address, p, this_length);
+ if (status != WEAR_LEVELING_SUCCESS) {
+ // If consolidation occurred, then the cache has already been written to the consolidated area. No need to continue.
+ // If a failure occurred, pass it on.
+ return status;
+ }
+ remaining -= this_length;
+ address += (uint32_t)this_length;
+ p += this_length;
+ }
+
+ return status;
+}
+
+/**
+ * "Replays" the write log from the backing store, updating the local cache with updated values.
+ */
+static wear_leveling_status_t wear_leveling_playback_log(void) {
+ wl_dprintf("Playback write log\n");
+
+ wear_leveling_status_t status = WEAR_LEVELING_SUCCESS;
+ bool cancel_playback = false;
+ uint32_t address = (WEAR_LEVELING_LOGICAL_SIZE) + 8; // +8 due to the FNV1a_64 of the consolidated area
+ while (!cancel_playback && address < (WEAR_LEVELING_BACKING_SIZE)) {
+ backing_store_int_t value;
+ bool ok = backing_store_read(address, &value);
+ if (!ok) {
+ wl_dprintf("Failed to load from backing store, skipping playback of write log\n");
+ cancel_playback = true;
+ status = WEAR_LEVELING_FAILED;
+ break;
+ }
+ if (value == 0) {
+ wl_dprintf("Found empty slot, no more log entries\n");
+ cancel_playback = true;
+ break;
+ }
+
+ // If we got a nonzero value, then we need to increment the address to ensure next write occurs at next location
+ address += (BACKING_STORE_WRITE_SIZE);
+
+ // Read from the write log
+ write_log_entry_t log;
+#if BACKING_STORE_WRITE_SIZE == 2
+ log.raw16[0] = value;
+#elif BACKING_STORE_WRITE_SIZE == 4
+ log.raw32[0] = value;
+#elif BACKING_STORE_WRITE_SIZE == 8
+ log.raw64 = value;
+#endif
+
+ switch (LOG_ENTRY_GET_TYPE(log)) {
+ case LOG_ENTRY_TYPE_MULTIBYTE: {
+#if BACKING_STORE_WRITE_SIZE == 2
+ ok = backing_store_read(address, &log.raw16[1]);
+ if (!ok) {
+ wl_dprintf("Failed to load from backing store, skipping playback of write log\n");
+ cancel_playback = true;
+ status = WEAR_LEVELING_FAILED;
+ break;
+ }
+ address += (BACKING_STORE_WRITE_SIZE);
+#endif // BACKING_STORE_WRITE_SIZE == 2
+ const uint32_t a = LOG_ENTRY_MULTIBYTE_GET_ADDRESS(log);
+ const uint8_t l = LOG_ENTRY_MULTIBYTE_GET_LENGTH(log);
+
+ if (a + l > (WEAR_LEVELING_LOGICAL_SIZE)) {
+ cancel_playback = true;
+ status = WEAR_LEVELING_FAILED;
+ break;
+ }
+
+#if BACKING_STORE_WRITE_SIZE == 2
+ if (l > 1) {
+ ok = backing_store_read(address, &log.raw16[2]);
+ if (!ok) {
+ wl_dprintf("Failed to load from backing store, skipping playback of write log\n");
+ cancel_playback = true;
+ status = WEAR_LEVELING_FAILED;
+ break;
+ }
+ address += (BACKING_STORE_WRITE_SIZE);
+ }
+ if (l > 3) {
+ ok = backing_store_read(address, &log.raw16[3]);
+ if (!ok) {
+ wl_dprintf("Failed to load from backing store, skipping playback of write log\n");
+ cancel_playback = true;
+ status = WEAR_LEVELING_FAILED;
+ break;
+ }
+ address += (BACKING_STORE_WRITE_SIZE);
+ }
+#elif BACKING_STORE_WRITE_SIZE == 4
+ if (l > 1) {
+ ok = backing_store_read(address, &log.raw32[1]);
+ if (!ok) {
+ wl_dprintf("Failed to load from backing store, skipping playback of write log\n");
+ cancel_playback = true;
+ status = WEAR_LEVELING_FAILED;
+ break;
+ }
+ address += (BACKING_STORE_WRITE_SIZE);
+ }
+#endif
+
+ memcpy(&wear_leveling.cache[a], &log.raw8[3], l);
+ } break;
+#if BACKING_STORE_WRITE_SIZE == 2
+ case LOG_ENTRY_TYPE_OPTIMIZED_64: {
+ const uint32_t a = LOG_ENTRY_OPTIMIZED_64_GET_ADDRESS(log);
+ const uint8_t v = LOG_ENTRY_OPTIMIZED_64_GET_VALUE(log);
+
+ if (a >= (WEAR_LEVELING_LOGICAL_SIZE)) {
+ cancel_playback = true;
+ status = WEAR_LEVELING_FAILED;
+ break;
+ }
+
+ wear_leveling.cache[a] = v;
+ } break;
+ case LOG_ENTRY_TYPE_WORD_01: {
+ const uint32_t a = LOG_ENTRY_WORD_01_GET_ADDRESS(log);
+ const uint8_t v = LOG_ENTRY_WORD_01_GET_VALUE(log);
+
+ if (a + 1 >= (WEAR_LEVELING_LOGICAL_SIZE)) {
+ cancel_playback = true;
+ status = WEAR_LEVELING_FAILED;
+ break;
+ }
+
+ wear_leveling.cache[a + 0] = v;
+ wear_leveling.cache[a + 1] = 0;
+ } break;
+#endif // BACKING_STORE_WRITE_SIZE == 2
+ default: {
+ cancel_playback = true;
+ status = WEAR_LEVELING_FAILED;
+ } break;
+ }
+ }
+
+ // We've reached the end of the log, so we're at the new write location
+ wear_leveling.write_address = address;
+
+ if (status == WEAR_LEVELING_FAILED) {
+ // If we had a failure during readback, assume we're corrupted -- force a consolidation with the data we already have
+ status = wear_leveling_consolidate_force();
+ } else {
+ // Consolidate the cache + write log if required
+ status = wear_leveling_consolidate_if_needed();
+ }
+
+ return status;
+}
+
+/**
+ * Wear-leveling initialization
+ */
+wear_leveling_status_t wear_leveling_init(void) {
+ wl_dprintf("Init\n");
+
+ // Reset the cache
+ wear_leveling_clear_cache();
+
+ // Initialise the backing store
+ if (!backing_store_init()) {
+ // If it failed, clear the cache and return with failure
+ wear_leveling_clear_cache();
+ return WEAR_LEVELING_FAILED;
+ }
+
+ // Read the previous consolidated values, then replay the existing write log so that the cache has the "live" values
+ wear_leveling_status_t status = wear_leveling_read_consolidated();
+ if (status == WEAR_LEVELING_FAILED) {
+ // If it failed, clear the cache and return with failure
+ wear_leveling_clear_cache();
+ return status;
+ }
+
+ status = wear_leveling_playback_log();
+ if (status == WEAR_LEVELING_FAILED) {
+ // If it failed, clear the cache and return with failure
+ wear_leveling_clear_cache();
+ return status;
+ }
+
+ return status;
+}
+
+/**
+ * Wear-leveling erase.
+ * Post-condition: any reads from the backing store directly after an erase operation must come back as zero.
+ */
+wear_leveling_status_t wear_leveling_erase(void) {
+ wl_dprintf("Erase\n");
+
+ // Unlock the backing store
+ backing_store_lock_status_t lock_status = wear_leveling_unlock();
+ if (lock_status == STATUS_FAILURE) {
+ wear_leveling_lock();
+ return WEAR_LEVELING_FAILED;
+ }
+
+ // Perform the erase
+ bool ret = backing_store_erase();
+ wear_leveling_clear_cache();
+
+ // Lock the backing store if we acquired the lock successfully
+ if (lock_status == STATUS_SUCCESS) {
+ ret &= (wear_leveling_lock() != STATUS_FAILURE);
+ }
+
+ return ret ? WEAR_LEVELING_SUCCESS : WEAR_LEVELING_FAILED;
+}
+
+/**
+ * Writes logical data into the backing store. Skips writes if there are no changes to values.
+ */
+wear_leveling_status_t wear_leveling_write(const uint32_t address, const void *value, size_t length) {
+ wl_assert(address + length <= (WEAR_LEVELING_LOGICAL_SIZE));
+ if (address + length > (WEAR_LEVELING_LOGICAL_SIZE)) {
+ return WEAR_LEVELING_FAILED;
+ }
+
+ wl_dprintf("Write ");
+ wl_dump(address, value, length);
+
+ // Skip write if there's no change compared to the current cached value
+ if (memcmp(value, &wear_leveling.cache[address], length) == 0) {
+ return true;
+ }
+
+ // Update the cache before writing to the backing store -- if we hit the end of the backing store during writes to the log then we'll force a consolidation in-line
+ memcpy(&wear_leveling.cache[address], value, length);
+
+ // Unlock the backing store
+ backing_store_lock_status_t lock_status = wear_leveling_unlock();
+ if (lock_status == STATUS_FAILURE) {
+ wear_leveling_lock();
+ return WEAR_LEVELING_FAILED;
+ }
+
+ // Perform the actual write
+ wear_leveling_status_t status = wear_leveling_write_raw(address, value, length);
+ switch (status) {
+ case WEAR_LEVELING_CONSOLIDATED:
+ case WEAR_LEVELING_FAILED:
+ // If the write triggered consolidation, or the write failed, then nothing else needs to occur.
+ break;
+
+ case WEAR_LEVELING_SUCCESS:
+ // Consolidate the cache + write log if required
+ status = wear_leveling_consolidate_if_needed();
+ break;
+
+ default:
+ // Unsure how we'd get here...
+ status = WEAR_LEVELING_FAILED;
+ break;
+ }
+
+ if (lock_status == STATUS_SUCCESS) {
+ if (wear_leveling_lock() == STATUS_FAILURE) {
+ status = WEAR_LEVELING_FAILED;
+ }
+ }
+
+ return status;
+}
+
+/**
+ * Reads logical data from the cache.
+ */
+wear_leveling_status_t wear_leveling_read(const uint32_t address, void *value, size_t length) {
+ wl_assert(address + length <= (WEAR_LEVELING_LOGICAL_SIZE));
+ if (address + length > (WEAR_LEVELING_LOGICAL_SIZE)) {
+ return WEAR_LEVELING_FAILED;
+ }
+
+ // Only need to copy from the cache
+ memcpy(value, &wear_leveling.cache[address], length);
+
+ wl_dprintf("Read ");
+ wl_dump(address, value, length);
+ return WEAR_LEVELING_SUCCESS;
+}
+
+/**
+ * Weak implementation of bulk read, drivers can implement more optimised implementations.
+ */
+__attribute__((weak)) bool backing_store_read_bulk(uint32_t address, backing_store_int_t *values, size_t item_count) {
+ for (size_t i = 0; i < item_count; ++i) {
+ if (!backing_store_read(address + (i * BACKING_STORE_WRITE_SIZE), &values[i])) {
+ return false;
+ }
+ }
+ return true;
+}
+
+/**
+ * Weak implementation of bulk write, drivers can implement more optimised implementations.
+ */
+__attribute__((weak)) bool backing_store_write_bulk(uint32_t address, backing_store_int_t *values, size_t item_count) {
+ for (size_t i = 0; i < item_count; ++i) {
+ if (!backing_store_write(address + (i * BACKING_STORE_WRITE_SIZE), values[i])) {
+ return false;
+ }
+ }
+ return true;
+}
diff --git a/quantum/wear_leveling/wear_leveling.h b/quantum/wear_leveling/wear_leveling.h
new file mode 100644
index 0000000000..6641bc49b3
--- /dev/null
+++ b/quantum/wear_leveling/wear_leveling.h
@@ -0,0 +1,54 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+#include <stdint.h>
+#include <stdlib.h>
+
+/**
+ * @typedef Status returned from any wear-leveling API.
+ */
+typedef enum wear_leveling_status_t {
+ WEAR_LEVELING_FAILED, //< Invocation failed
+ WEAR_LEVELING_SUCCESS, //< Invocation succeeded
+ WEAR_LEVELING_CONSOLIDATED //< Invocation succeeded, consolidation occurred
+} wear_leveling_status_t;
+
+/**
+ * Wear-leveling initialization
+ *
+ * @return Status of the request
+ */
+wear_leveling_status_t wear_leveling_init(void);
+
+/**
+ * Wear-leveling erasure.
+ *
+ * Clears the wear-leveling area, with the definition that the "reset state" of all data is zero.
+ *
+ * @return Status of the request
+ */
+wear_leveling_status_t wear_leveling_erase(void);
+
+/**
+ * Writes logical data into the backing store.
+ *
+ * Skips writes if there are no changes to written values. The entire written block is considered when attempting to
+ * determine if an overwrite should occur -- if there is any data mismatch the entire block will be written to the log,
+ * not just the changed bytes.
+ *
+ * @param address[in] the logical address to write data
+ * @param value[in] pointer to the source buffer
+ * @param length[in] length of the data
+ * @return Status of the request
+ */
+wear_leveling_status_t wear_leveling_write(uint32_t address, const void* value, size_t length);
+
+/**
+ * Reads logical data from the cache.
+ *
+ * @param address[in] the logical address to read data
+ * @param value[out] pointer to the destination buffer
+ * @param length[in] length of the data
+ * @return Status of the request
+ */
+wear_leveling_status_t wear_leveling_read(uint32_t address, void* value, size_t length);
diff --git a/quantum/wear_leveling/wear_leveling_internal.h b/quantum/wear_leveling/wear_leveling_internal.h
new file mode 100644
index 0000000000..e83f9b22ea
--- /dev/null
+++ b/quantum/wear_leveling/wear_leveling_internal.h
@@ -0,0 +1,151 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#ifdef __cplusplus
+# define _Static_assert static_assert
+#endif
+
+#include <stdint.h>
+#include <string.h>
+
+#if BACKING_STORE_WRITE_SIZE == 2
+typedef uint16_t backing_store_int_t;
+#elif BACKING_STORE_WRITE_SIZE == 4
+typedef uint32_t backing_store_int_t;
+#elif BACKING_STORE_WRITE_SIZE == 8
+typedef uint64_t backing_store_int_t;
+#else
+# error Invalid BACKING_STORE_WRITE_SIZE, needs to be 2/4/8.
+#endif
+
+#ifndef WEAR_LEVELING_BACKING_SIZE
+# error WEAR_LEVELING_BACKING_SIZE was not set.
+#endif
+
+#ifndef WEAR_LEVELING_LOGICAL_SIZE
+# error WEAR_LEVELING_LOGICAL_SIZE was not set.
+#endif
+
+#ifdef WEAR_LEVELING_DEBUG_OUTPUT
+# include <debug.h>
+# define bs_dprintf(...) dprintf("Backing store: " __VA_ARGS__)
+# define wl_dprintf(...) dprintf("Wear leveling: " __VA_ARGS__)
+# define wl_dump(address, value, length) \
+ do { \
+ dprintf("[0x%04X]: ", (int)(address)); \
+ const uint8_t* p = (const uint8_t*)(value); \
+ for (int i = 0; i < (length); ++i) { \
+ dprintf(" %02X", (int)p[i]); \
+ } \
+ dprintf("\n"); \
+ } while (0)
+#else
+# define wl_dprintf(...) \
+ do { \
+ } while (0)
+# define bs_dprintf(...) \
+ do { \
+ } while (0)
+# define wl_dump(...) \
+ do { \
+ } while (0)
+#endif // WEAR_LEVELING_DEBUG_OUTPUT
+
+#ifdef WEAR_LEVELING_ASSERTS
+# include <assert.h>
+# define wl_assert(...) assert(__VA_ARGS__)
+#else
+# define wl_assert(...) \
+ do { \
+ } while (0)
+#endif // WEAR_LEVELING_ASSERTS
+
+// Compile-time validation of configurable options
+_Static_assert(WEAR_LEVELING_BACKING_SIZE >= (WEAR_LEVELING_LOGICAL_SIZE * 2), "Total backing size must be at least twice the size of the logical size");
+_Static_assert(WEAR_LEVELING_LOGICAL_SIZE % BACKING_STORE_WRITE_SIZE == 0, "Logical size must be a multiple of write size");
+_Static_assert(WEAR_LEVELING_BACKING_SIZE % WEAR_LEVELING_LOGICAL_SIZE == 0, "Backing size must be a multiple of logical size");
+
+// Backing Store API, to be implemented elsewhere by flash driver etc.
+bool backing_store_init(void);
+bool backing_store_unlock(void);
+bool backing_store_erase(void);
+bool backing_store_write(uint32_t address, backing_store_int_t value);
+bool backing_store_write_bulk(uint32_t address, backing_store_int_t* values, size_t item_count); // weak implementation already provided, optimized implementation can be implemented by driver
+bool backing_store_lock(void);
+bool backing_store_read(uint32_t address, backing_store_int_t* value);
+bool backing_store_read_bulk(uint32_t address, backing_store_int_t* values, size_t item_count); // weak implementation already provided, optimized implementation can be implemented by driver
+
+/**
+ * Helper type used to contain a write log entry.
+ */
+typedef union write_log_entry_t {
+ uint64_t raw64;
+ uint32_t raw32[2];
+ uint16_t raw16[4];
+ uint8_t raw8[8];
+} write_log_entry_t;
+
+_Static_assert(sizeof(write_log_entry_t) == 8, "Wear leveling write log entry size was not 8");
+
+/**
+ * Log entry type discriminator.
+ */
+enum {
+ // 0x00 -- Multi-byte storage type
+ LOG_ENTRY_TYPE_MULTIBYTE,
+
+ // 0x01 -- 2-byte backing store write optimization: address < 64
+ LOG_ENTRY_TYPE_OPTIMIZED_64,
+
+ // 0x02 -- 2-byte backing store write optimization: word-encoded 0/1 values
+ LOG_ENTRY_TYPE_WORD_01,
+
+ LOG_ENTRY_TYPES
+};
+
+_Static_assert(LOG_ENTRY_TYPES <= (1 << 2), "Too many log entry types to fit into 2 bits of storage");
+
+#define BITMASK_FOR_BITCOUNT(n) ((1 << (n)) - 1)
+
+#define LOG_ENTRY_GET_TYPE(entry) (((entry).raw8[0] >> 6) & BITMASK_FOR_BITCOUNT(2))
+
+#define LOG_ENTRY_MULTIBYTE_MAX_BYTES 5
+#define LOG_ENTRY_MULTIBYTE_GET_ADDRESS(entry) (((((uint32_t)((entry).raw8[0])) & BITMASK_FOR_BITCOUNT(3)) << 16) | (((uint32_t)((entry).raw8[1])) << 8) | (entry).raw8[2])
+#define LOG_ENTRY_MULTIBYTE_GET_LENGTH(entry) ((uint8_t)(((entry).raw8[0] >> 3) & BITMASK_FOR_BITCOUNT(3)))
+#define LOG_ENTRY_MAKE_MULTIBYTE(address, length) \
+ (write_log_entry_t) { \
+ .raw8 = { \
+ [0] = (((((uint8_t)LOG_ENTRY_TYPE_MULTIBYTE) & BITMASK_FOR_BITCOUNT(2)) << 6) /* type */ \
+ | ((((uint8_t)(length)) & BITMASK_FOR_BITCOUNT(3)) << 3) /* length */ \
+ | ((((uint8_t)((address) >> 16))) & BITMASK_FOR_BITCOUNT(3)) /* address */ \
+ ), \
+ [1] = (((uint8_t)((address) >> 8)) & BITMASK_FOR_BITCOUNT(8)), /* address */ \
+ [2] = (((uint8_t)(address)) & BITMASK_FOR_BITCOUNT(8)), /* address */ \
+ } \
+ }
+
+#define LOG_ENTRY_OPTIMIZED_64_GET_ADDRESS(entry) ((uint32_t)((entry).raw8[0] & BITMASK_FOR_BITCOUNT(6)))
+#define LOG_ENTRY_OPTIMIZED_64_GET_VALUE(entry) ((entry).raw8[1])
+#define LOG_ENTRY_MAKE_OPTIMIZED_64(address, value) \
+ (write_log_entry_t) { \
+ .raw8 = { \
+ [0] = (((((uint8_t)LOG_ENTRY_TYPE_OPTIMIZED_64) & BITMASK_FOR_BITCOUNT(2)) << 6) /* type */ \
+ | ((((uint8_t)(address))) & BITMASK_FOR_BITCOUNT(6)) /* address */ \
+ ), \
+ [1] = ((uint8_t)(value)), /* value */ \
+ } \
+ }
+
+#define LOG_ENTRY_WORD_01_GET_ADDRESS(entry) ((((uint32_t)(((entry).raw8[0]) & BITMASK_FOR_BITCOUNT(5))) << 9) | (((uint32_t)((entry).raw8[1])) << 1))
+#define LOG_ENTRY_WORD_01_GET_VALUE(entry) ((uint8_t)((entry).raw8[0] >> 5) & BITMASK_FOR_BITCOUNT(1))
+#define LOG_ENTRY_MAKE_WORD_01(address, value) \
+ (write_log_entry_t) { \
+ .raw8 = { \
+ [0] = (((((uint8_t)LOG_ENTRY_TYPE_WORD_01) & BITMASK_FOR_BITCOUNT(2)) << 6) /* type */ \
+ | (((((uint8_t)((value) ? 1 : 0))) & BITMASK_FOR_BITCOUNT(1)) << 5) /* value */ \
+ | ((((uint8_t)((address) >> 9))) & BITMASK_FOR_BITCOUNT(5)) /* address */ \
+ ), \
+ [1] = (uint8_t)((address) >> 1), /* address */ \
+ } \
+ }
diff --git a/readme.md b/readme.md
index eae209d218..75f82b471c 100644
--- a/readme.md
+++ b/readme.md
@@ -54,7 +54,7 @@ QMK is developed and maintained by Jack Humbert of OLKB with contributions from
- To remove all of the keyboard exept the ones we want:
```sh
find ./keyboards -mindepth 1 -maxdepth 1 -type d -not -name ergodox_ez -not -name planck -not -name moonlander -not -name pytest -exec git rm -rf '{}' \;
- find ./keyboards/planck -mindepth 1 -maxdepth 1 -type d -not -name ez -not -name keymaps -exec git rm -rf '{}' \;
+ find ./keyboards/planck -mindepth 1 -maxdepth 1 -type d -not -name ez -not -name base -not -name keymaps -exec git rm -rf '{}' \;
```
- To remove all of the keymaps from folder that we don't want:
```sh
diff --git a/requirements.txt b/requirements.txt
index e09d58d829..6bee746324 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,11 +2,12 @@
appdirs
argcomplete
colorama
+dotty-dict
hid
hjson
jsonschema>=4
milc>=1.4.2
pygments
+pyserial
pyusb
-qmk-dotty-dict
pillow
diff --git a/shell.nix b/shell.nix
index 4701c83bb6..63e5af0525 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,9 +1,29 @@
let
# We specify sources via Niv: use "niv update nixpkgs" to update nixpkgs, for example.
sources = import ./util/nix/sources.nix { };
+
+ # `tomlkit` >= 0.8.0 is required to build `jsonschema` >= 4.11.0 (older
+ # version do not support some valid TOML syntax: sdispater/tomlkit#148). The
+ # updated `tomlkit` must be used by `makeRemoveSpecialDependenciesHook`
+ # inside `poetry2nix`, therefore just providing the updated version through
+ # our `nix/pyproject.toml` does not work, and using an overlay is required.
+ pythonOverlay = final: prev: {
+ python3 = prev.python3.override {
+ packageOverrides = self: super: {
+ tomlkit = super.tomlkit.overridePythonAttrs(old: rec {
+ version = "0.11.4";
+ src = super.fetchPypi {
+ inherit (old) pname;
+ inherit version;
+ sha256 = "sha256-MjWpAQ+uVDI+cnw6wG+3IHUv5mNbNCbjedrsYPvUSoM=";
+ };
+ });
+ };
+ };
+ };
in
# However, if you want to override Niv's inputs, this will let you do that.
-{ pkgs ? import sources.nixpkgs { }
+{ pkgs ? import sources.nixpkgs { overlays = [ pythonOverlay ]; }
, poetry2nix ? pkgs.callPackage (import sources.poetry2nix) { }
, avr ? true
, arm ? true
@@ -29,6 +49,14 @@ let
pythonEnv = poetry2nix.mkPoetryEnv {
projectDir = ./util/nix;
overrides = poetry2nix.overrides.withDefaults (self: super: {
+ pillow = super.pillow.overridePythonAttrs(old: {
+ # Use preConfigure from nixpkgs to fix library detection issues and
+ # impurities which can break the build process; this also requires
+ # adding propagatedBuildInputs and buildInputs from the same source.
+ propagatedBuildInputs = (old.buildInputs or []) ++ pkgs.python3.pkgs.pillow.propagatedBuildInputs;
+ buildInputs = (old.buildInputs or []) ++ pkgs.python3.pkgs.pillow.buildInputs;
+ preConfigure = (old.preConfigure or "") + pkgs.python3.pkgs.pillow.preConfigure;
+ });
qmk = super.qmk.overridePythonAttrs(old: {
# Allow QMK CLI to run "qmk" as a subprocess (the wrapper changes
# $PATH and breaks these invocations).
@@ -40,7 +68,7 @@ in
mkShell {
name = "qmk-firmware";
- buildInputs = [ clang-tools dfu-programmer dfu-util diffutils git pythonEnv poetry niv ]
+ buildInputs = [ clang-tools dfu-programmer dfu-util diffutils git pythonEnv niv ]
++ lib.optional avr [
pkgsCross.avr.buildPackages.binutils
pkgsCross.avr.buildPackages.gcc8
diff --git a/tests/auto_shift/test_auto_shift.cpp b/tests/auto_shift/test_auto_shift.cpp
index a83f436c33..0cc5fd2672 100644
--- a/tests/auto_shift/test_auto_shift.cpp
+++ b/tests/auto_shift/test_auto_shift.cpp
@@ -61,6 +61,7 @@ TEST_F(AutoShift, key_release_after_timeout) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release regular key */
+ EXPECT_REPORT(driver, (KC_LSFT));
EXPECT_REPORT(driver, (KC_LSFT, KC_A));
EXPECT_REPORT(driver, (KC_LSFT));
EXPECT_EMPTY_REPORT(driver);
diff --git a/tests/basic/test_keypress.cpp b/tests/basic/test_keypress.cpp
index bb68ced557..6d5b502a00 100644
--- a/tests/basic/test_keypress.cpp
+++ b/tests/basic/test_keypress.cpp
@@ -64,11 +64,7 @@ TEST_F(KeyPress, CorrectKeysAreReportedWhenTwoKeysArePressed) {
key_b.press();
key_c.press();
- // Note that QMK only processes one key at a time
- // See issue #1476 for more information
EXPECT_REPORT(driver, (key_b.report_code));
- keyboard_task();
-
EXPECT_REPORT(driver, (key_b.report_code, key_c.report_code));
keyboard_task();
@@ -76,8 +72,6 @@ TEST_F(KeyPress, CorrectKeysAreReportedWhenTwoKeysArePressed) {
key_c.release();
// Note that the first key released is the first one in the matrix order
EXPECT_REPORT(driver, (key_c.report_code));
- keyboard_task();
-
EXPECT_EMPTY_REPORT(driver);
keyboard_task();
}
@@ -92,10 +86,7 @@ TEST_F(KeyPress, LeftShiftIsReportedCorrectly) {
key_lsft.press();
key_a.press();
- // Unfortunately modifiers are also processed in the wrong order
- // See issue #1476 for more information
EXPECT_REPORT(driver, (key_a.report_code));
- keyboard_task();
EXPECT_REPORT(driver, (key_a.report_code, key_lsft.report_code));
keyboard_task();
@@ -118,11 +109,7 @@ TEST_F(KeyPress, PressLeftShiftAndControl) {
key_lsft.press();
key_lctrl.press();
- // Unfortunately modifiers are also processed in the wrong order
- // See issue #1476 for more information
EXPECT_REPORT(driver, (key_lsft.report_code));
- keyboard_task();
-
EXPECT_REPORT(driver, (key_lsft.report_code, key_lctrl.report_code));
keyboard_task();
@@ -130,8 +117,6 @@ TEST_F(KeyPress, PressLeftShiftAndControl) {
key_lctrl.release();
EXPECT_REPORT(driver, (key_lctrl.report_code));
- keyboard_task();
-
EXPECT_EMPTY_REPORT(driver);
keyboard_task();
}
@@ -145,20 +130,13 @@ TEST_F(KeyPress, LeftAndRightShiftCanBePressedAtTheSameTime) {
key_lsft.press();
key_rsft.press();
- // Unfortunately modifiers are also processed in the wrong order
- // See issue #1476 for more information
EXPECT_REPORT(driver, (key_lsft.report_code));
- keyboard_task();
-
EXPECT_REPORT(driver, (key_lsft.report_code, key_rsft.report_code));
keyboard_task();
key_lsft.release();
key_rsft.release();
-
EXPECT_REPORT(driver, (key_rsft.report_code));
- keyboard_task();
-
EXPECT_EMPTY_REPORT(driver);
keyboard_task();
}
diff --git a/tests/caps_word/caps_word_autoshift/test_caps_word_autoshift.cpp b/tests/caps_word/caps_word_autoshift/test_caps_word_autoshift.cpp
index deb4d95766..ba21c527a6 100644
--- a/tests/caps_word/caps_word_autoshift/test_caps_word_autoshift.cpp
+++ b/tests/caps_word/caps_word_autoshift/test_caps_word_autoshift.cpp
@@ -19,6 +19,14 @@
#include "test_fixture.hpp"
#include "test_keymap_key.hpp"
+// Allow reports with no keys or only KC_LSFT.
+// clang-format off
+#define EXPECT_EMPTY_OR_LSFT(driver) \
+ EXPECT_CALL(driver, send_keyboard_mock(AnyOf( \
+ KeyboardReport(), \
+ KeyboardReport(KC_LSFT))))
+// clang-format on
+
using ::testing::_;
using ::testing::AnyNumber;
using ::testing::AnyOf;
@@ -39,13 +47,7 @@ TEST_F(CapsWord, AutoShiftKeys) {
KeymapKey key_spc(0, 1, 0, KC_SPC);
set_keymap({key_a, key_spc});
- // Allow any number of reports with no keys or only KC_LSFT.
- // clang-format off
- EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
- KeyboardReport(),
- KeyboardReport(KC_LSFT))))
- .Times(AnyNumber());
- // clang-format on
+ EXPECT_EMPTY_OR_LSFT(driver).Times(AnyNumber());
{ // Expect: "A, A, space, a".
InSequence s;
EXPECT_REPORT(driver, (KC_LSFT, KC_A));
@@ -65,6 +67,46 @@ TEST_F(CapsWord, AutoShiftKeys) {
testing::Mock::VerifyAndClearExpectations(&driver);
}
+// Test Caps Word + Auto Shift where keys A and B are rolled.
+TEST_F(CapsWord, AutoShiftRolledShiftedKeys) {
+ TestDriver driver;
+ KeymapKey key_a(0, 0, 0, KC_A);
+ KeymapKey key_b(0, 0, 1, KC_B);
+ set_keymap({key_a, key_b});
+
+ EXPECT_EMPTY_OR_LSFT(driver).Times(AnyNumber());
+ { // Expect: "A, B, A, B".
+ InSequence s;
+ EXPECT_REPORT(driver, (KC_LSFT, KC_A));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_B));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_A));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_B));
+ }
+
+ caps_word_on();
+
+ key_a.press(); // Overlapping taps: A down, B down, A up, B up.
+ run_one_scan_loop();
+ key_b.press();
+ run_one_scan_loop();
+ key_a.release();
+ run_one_scan_loop();
+ key_b.release();
+ run_one_scan_loop();
+
+ key_a.press(); // Nested taps: A down, B down, B up, A up.
+ run_one_scan_loop();
+ key_b.press();
+ run_one_scan_loop();
+ key_b.release();
+ run_one_scan_loop();
+ key_a.release();
+ run_one_scan_loop();
+
+ caps_word_off();
+ testing::Mock::VerifyAndClearExpectations(&driver);
+}
+
// Tests that with tap-hold keys with Retro Shift, letter keys are shifted by
// Caps Word regardless of whether they are retroshifted.
TEST_F(CapsWord, RetroShiftKeys) {
@@ -73,13 +115,7 @@ TEST_F(CapsWord, RetroShiftKeys) {
KeymapKey key_layertap_b(0, 1, 0, LT(1, KC_B));
set_keymap({key_modtap_a, key_layertap_b});
- // Allow any number of reports with no keys or only KC_LSFT.
- // clang-format off
- EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
- KeyboardReport(),
- KeyboardReport(KC_LSFT))))
- .Times(AnyNumber());
- // clang-format on
+ EXPECT_EMPTY_OR_LSFT(driver).Times(AnyNumber());
{ // Expect: "B, A, B, A".
InSequence s;
EXPECT_REPORT(driver, (KC_LSFT, KC_B));
diff --git a/tests/caps_word/caps_word_combo/config.h b/tests/caps_word/caps_word_combo/config.h
new file mode 100644
index 0000000000..92dbe045b2
--- /dev/null
+++ b/tests/caps_word/caps_word_combo/config.h
@@ -0,0 +1,20 @@
+// Copyright 2022 Google LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#pragma once
+
+#include "test_common.h"
+
+#define TAPPING_TERM 200
diff --git a/tests/caps_word/caps_word_combo/test.mk b/tests/caps_word/caps_word_combo/test.mk
new file mode 100644
index 0000000000..9f2e157189
--- /dev/null
+++ b/tests/caps_word/caps_word_combo/test.mk
@@ -0,0 +1,19 @@
+# Copyright 2022 Google LLC
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+CAPS_WORD_ENABLE = yes
+COMBO_ENABLE = yes
+AUTO_SHIFT_ENABLE = yes
+
diff --git a/tests/caps_word/caps_word_combo/test_caps_word_combo.cpp b/tests/caps_word/caps_word_combo/test_caps_word_combo.cpp
new file mode 100644
index 0000000000..3a0530b854
--- /dev/null
+++ b/tests/caps_word/caps_word_combo/test_caps_word_combo.cpp
@@ -0,0 +1,212 @@
+// Copyright 2022 Google LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+// Test Caps Word + Combos, with and without Auto Shift.
+
+#include <algorithm>
+#include <numeric>
+#include <vector>
+
+#include "keyboard_report_util.hpp"
+#include "keycode.h"
+#include "test_common.hpp"
+#include "test_fixture.hpp"
+#include "test_keymap_key.hpp"
+
+// Allow reports with no keys or only KC_LSFT.
+// clang-format off
+#define EXPECT_EMPTY_OR_LSFT(driver) \
+ EXPECT_CALL(driver, send_keyboard_mock(AnyOf( \
+ KeyboardReport(), \
+ KeyboardReport(KC_LSFT))))
+// clang-format on
+
+using ::testing::AnyNumber;
+using ::testing::AnyOf;
+using ::testing::InSequence;
+using ::testing::TestParamInfo;
+
+extern "C" {
+// Define some combos to use for the test, including overlapping combos and
+// combos that chord tap-hold keys.
+enum combo_events { AB_COMBO, BC_COMBO, AD_COMBO, DE_COMBO, FGHI_COMBO, COMBO_LENGTH };
+uint16_t COMBO_LEN = COMBO_LENGTH;
+
+const uint16_t ab_combo[] PROGMEM = {KC_A, KC_B, COMBO_END};
+const uint16_t bc_combo[] PROGMEM = {KC_B, KC_C, COMBO_END};
+const uint16_t ad_combo[] PROGMEM = {KC_A, LCTL_T(KC_D), COMBO_END};
+const uint16_t de_combo[] PROGMEM = {LCTL_T(KC_D), LT(1, KC_E), COMBO_END};
+const uint16_t fghi_combo[] PROGMEM = {KC_F, KC_G, KC_H, KC_I, COMBO_END};
+
+// clang-format off
+combo_t key_combos[] = {
+ [AB_COMBO] = COMBO(ab_combo, KC_SPC), // KC_A + KC_B = KC_SPC
+ [BC_COMBO] = COMBO(bc_combo, KC_X), // KC_B + KC_C = KC_X
+ [AD_COMBO] = COMBO(ad_combo, KC_Y), // KC_A + LCTL_T(KC_D) = KC_Y
+ [DE_COMBO] = COMBO(de_combo, KC_Z), // LCTL_T(KC_D) + LT(1, KC_E) = KC_Z
+ [FGHI_COMBO] = COMBO(fghi_combo, KC_W) // KC_F + KC_G + KC_H + KC_I = KC_W
+};
+// clang-format on
+} // extern "C"
+
+namespace {
+
+// To test combos thorougly, we test them with pressing the chord keys with
+// a few different orders and timings.
+struct TestParams {
+ std::string name;
+ bool autoshift_on;
+
+ static const std::string& GetName(const TestParamInfo<TestParams>& info) {
+ return info.param.name;
+ }
+};
+
+class CapsWord : public ::testing::WithParamInterface<TestParams>, public TestFixture {
+ public:
+ void SetUp() override {
+ caps_word_off();
+ if (GetParam().autoshift_on) {
+ autoshift_enable();
+ } else {
+ autoshift_disable();
+ }
+ }
+};
+
+// Test pressing the keys in a combo with different orders and timings.
+TEST_P(CapsWord, SingleCombo) {
+ TestDriver driver;
+ KeymapKey key_b(0, 0, 1, KC_B);
+ KeymapKey key_c(0, 0, 2, KC_C);
+ set_keymap({key_b, key_c});
+
+ EXPECT_EMPTY_OR_LSFT(driver).Times(AnyNumber());
+ EXPECT_REPORT(driver, (KC_LSFT, KC_X));
+
+ caps_word_on();
+ tap_combo({key_b, key_c});
+
+ EXPECT_TRUE(is_caps_word_on());
+ caps_word_off();
+
+ testing::Mock::VerifyAndClearExpectations(&driver);
+}
+
+// Test a longer 4-key combo.
+TEST_P(CapsWord, LongerCombo) {
+ TestDriver driver;
+ KeymapKey key_f(0, 0, 0, KC_F);
+ KeymapKey key_g(0, 0, 1, KC_G);
+ KeymapKey key_h(0, 0, 2, KC_H);
+ KeymapKey key_i(0, 0, 3, KC_I);
+ set_keymap({key_f, key_g, key_h, key_i});
+
+ EXPECT_EMPTY_OR_LSFT(driver).Times(AnyNumber());
+ EXPECT_REPORT(driver, (KC_LSFT, KC_W));
+
+ caps_word_on();
+ tap_combo({key_f, key_g, key_h, key_i});
+
+ EXPECT_TRUE(is_caps_word_on());
+ caps_word_off();
+
+ testing::Mock::VerifyAndClearExpectations(&driver);
+}
+
+// Test with two overlapping combos on regular keys:
+// KC_A + KC_B = KC_SPC,
+// KC_B + KC_C = KC_X.
+TEST_P(CapsWord, ComboRegularKeys) {
+ TestDriver driver;
+ KeymapKey key_a(0, 0, 0, KC_A);
+ KeymapKey key_b(0, 0, 1, KC_B);
+ KeymapKey key_c(0, 0, 2, KC_C);
+ KeymapKey key_1(0, 0, 3, KC_1);
+ set_keymap({key_a, key_b, key_c, key_1});
+
+ EXPECT_EMPTY_OR_LSFT(driver).Times(AnyNumber());
+ { // Expect: "A, B, 1, X, 1, C, space, a".
+ InSequence s;
+ EXPECT_REPORT(driver, (KC_LSFT, KC_A));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_B));
+ EXPECT_REPORT(driver, (KC_1));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_X));
+ EXPECT_REPORT(driver, (KC_1));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_C));
+ EXPECT_REPORT(driver, (KC_SPC));
+ EXPECT_REPORT(driver, (KC_A));
+ }
+
+ caps_word_on();
+ tap_key(key_a);
+ tap_key(key_b);
+ tap_key(key_1);
+ tap_combo({key_b, key_c}); // BC combo types "x".
+ tap_key(key_1);
+ tap_key(key_c);
+ tap_combo({key_a, key_b}); // AB combo types space.
+ tap_key(key_a);
+
+ EXPECT_FALSE(is_caps_word_on());
+ testing::Mock::VerifyAndClearExpectations(&driver);
+}
+
+// Test where combo chords involve tap-hold keys:
+// KC_A + LCTL_T(KC_D) = KC_Y,
+// LCTL_T(KC_D) + LT(1, KC_E) = KC_Z,
+TEST_P(CapsWord, ComboModTapKey) {
+ TestDriver driver;
+ KeymapKey key_a(0, 0, 0, KC_A);
+ KeymapKey key_modtap_d(0, 0, 1, LCTL_T(KC_D));
+ KeymapKey key_layertap_e(0, 0, 2, LT(1, KC_E));
+ set_keymap({key_a, key_modtap_d, key_layertap_e});
+
+ EXPECT_EMPTY_OR_LSFT(driver).Times(AnyNumber());
+ { // Expect: "A, D, E, Y, Z".
+ InSequence s;
+ EXPECT_REPORT(driver, (KC_LSFT, KC_A));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_D));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_E));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_Y));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_Z));
+ }
+
+ caps_word_on();
+ tap_key(key_a);
+ tap_key(key_modtap_d);
+ tap_key(key_layertap_e);
+ tap_combo({key_a, key_modtap_d}); // AD combo types "y".
+ tap_combo({key_modtap_d, key_layertap_e}); // DE combo types "z".
+
+ EXPECT_TRUE(is_caps_word_on());
+ caps_word_off();
+
+ testing::Mock::VerifyAndClearExpectations(&driver);
+}
+
+// clang-format off
+INSTANTIATE_TEST_CASE_P(
+ Combos,
+ CapsWord,
+ ::testing::Values(
+ TestParams{"AutoshiftDisabled", false},
+ TestParams{"AutoshiftEnabled", true}
+ ),
+ TestParams::GetName
+ );
+// clang-format on
+
+} // namespace
diff --git a/tests/caps_word/test_caps_word.cpp b/tests/caps_word/test_caps_word.cpp
index 0af4b0175d..3f59ed3744 100644
--- a/tests/caps_word/test_caps_word.cpp
+++ b/tests/caps_word/test_caps_word.cpp
@@ -25,10 +25,47 @@ using ::testing::AnyOf;
using ::testing::InSequence;
using ::testing::TestParamInfo;
+namespace {
+
+bool press_user_default(uint16_t keycode) {
+ switch (keycode) {
+ // Keycodes that continue Caps Word, with shift applied.
+ case KC_A ... KC_Z:
+ case KC_MINS:
+ add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to next key.
+ return true;
+
+ // Keycodes that continue Caps Word, without shifting.
+ case KC_1 ... KC_0:
+ case KC_BSPC:
+ case KC_DEL:
+ case KC_UNDS:
+ return true;
+
+ default:
+ return false; // Deactivate Caps Word.
+ }
+}
+
+uint16_t passed_keycode;
+bool press_user_save_passed_keycode(uint16_t keycode) {
+ passed_keycode = keycode;
+ return true;
+}
+
+bool (*press_user_fun)(uint16_t) = press_user_default;
+
+extern "C" {
+bool caps_word_press_user(uint16_t keycode) {
+ return press_user_fun(keycode);
+}
+} // extern "C"
+
class CapsWord : public TestFixture {
public:
void SetUp() override {
caps_word_off();
+ press_user_fun = press_user_default;
}
};
@@ -226,6 +263,126 @@ TEST_F(CapsWord, ShiftsAltGrSymbols) {
testing::Mock::VerifyAndClearExpectations(&driver);
}
+// Tests typing "AltGr + A" using a mod-tap key.
+TEST_F(CapsWord, ShiftsModTapAltGrSymbols) {
+ TestDriver driver;
+ KeymapKey key_a(0, 0, 0, KC_A);
+ KeymapKey key_altgr_t(0, 1, 0, RALT_T(KC_B));
+ set_keymap({key_a, key_altgr_t});
+
+ // Allow any number of reports with no keys or only modifiers.
+ // clang-format off
+ EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
+ KeyboardReport(),
+ KeyboardReport(KC_RALT),
+ KeyboardReport(KC_LSFT, KC_RALT))))
+ .Times(AnyNumber());
+ // Expect "Shift + AltGr + A".
+ EXPECT_REPORT(driver, (KC_LSFT, KC_RALT, KC_A));
+ // clang-format on
+
+ // Turn on Caps Word and type "AltGr + A".
+ caps_word_on();
+
+ key_altgr_t.press();
+ idle_for(TAPPING_TERM + 1);
+ tap_key(key_a);
+ run_one_scan_loop();
+ key_altgr_t.release();
+
+ EXPECT_TRUE(is_caps_word_on());
+ testing::Mock::VerifyAndClearExpectations(&driver);
+}
+
+struct CapsWordPressUserParams {
+ std::string name;
+ uint16_t keycode;
+ uint16_t delay_ms;
+ uint16_t expected_passed_keycode;
+ bool continues_caps_word;
+
+ static const std::string& GetName(const TestParamInfo<CapsWordPressUserParams>& info) {
+ return info.param.name;
+ }
+};
+
+class CapsWordPressUser : public ::testing::WithParamInterface<CapsWordPressUserParams>, public CapsWord {
+ void SetUp() override {
+ caps_word_on();
+ passed_keycode = KC_NO;
+ press_user_fun = press_user_save_passed_keycode;
+ }
+};
+
+// Tests keycodes passed to caps_word_press_user() function for various keys.
+TEST_P(CapsWordPressUser, KeyCode) {
+ TestDriver driver;
+ KeymapKey key(0, 0, 0, GetParam().keycode);
+ set_keymap({key});
+
+ EXPECT_ANY_REPORT(driver).Times(AnyNumber());
+ tap_key(key, GetParam().delay_ms);
+
+ EXPECT_EQ(passed_keycode, GetParam().expected_passed_keycode);
+ EXPECT_EQ(is_caps_word_on(), GetParam().continues_caps_word);
+ clear_oneshot_mods();
+ testing::Mock::VerifyAndClearExpectations(&driver);
+}
+
+const uint16_t LT_1_KC_A = LT(1, KC_A);
+// clang-format off
+INSTANTIATE_TEST_CASE_P(
+ PressUser,
+ CapsWordPressUser,
+ ::testing::Values(
+ CapsWordPressUserParams{
+ "KC_A", KC_A, 1, KC_A, true},
+ CapsWordPressUserParams{
+ "KC_HASH", KC_HASH, 1, KC_HASH, true},
+ CapsWordPressUserParams{
+ "KC_LSFT", KC_LSFT, 1, KC_LSFT, true},
+ CapsWordPressUserParams{
+ "KC_RSFT", KC_RSFT, 1, KC_RSFT, true},
+ CapsWordPressUserParams{
+ "LSFT_T_tapped", LSFT_T(KC_A), 1, KC_A, true},
+ CapsWordPressUserParams{
+ "LSFT_T_held", LSFT_T(KC_A), TAPPING_TERM + 1, KC_LSFT, true},
+ CapsWordPressUserParams{
+ "RSFT_T_held", RSFT_T(KC_A), TAPPING_TERM + 1, KC_RSFT, true},
+ CapsWordPressUserParams{
+ "RSA_T_held", RSA_T(KC_A), TAPPING_TERM + 1, RSFT(KC_RALT), true},
+ // Holding a mod-tap other than Shift or AltGr stops Caps Word.
+ CapsWordPressUserParams{
+ "LCTL_T_held", LCTL_T(KC_A), TAPPING_TERM + 1, KC_NO, false},
+ CapsWordPressUserParams{
+ "LALT_T_held", LALT_T(KC_A), TAPPING_TERM + 1, KC_NO, false},
+ CapsWordPressUserParams{
+ "LGUI_T_held", LGUI_T(KC_A), TAPPING_TERM + 1, KC_NO, false},
+ // Layer keys are ignored and continue Caps Word.
+ CapsWordPressUserParams{
+ "MO", MO(1), 1, KC_NO, true},
+ CapsWordPressUserParams{
+ "TO", TO(1), 1, KC_NO, true},
+ CapsWordPressUserParams{
+ "TG", TG(1), 1, KC_NO, true},
+ CapsWordPressUserParams{
+ "TT", TT(1), 1, KC_NO, true},
+ CapsWordPressUserParams{
+ "OSL", OSL(1), 1, KC_NO, true},
+ CapsWordPressUserParams{
+ "LT_held", LT_1_KC_A, TAPPING_TERM + 1, KC_NO, true},
+ // AltGr keys are ignored and continue Caps Word.
+ CapsWordPressUserParams{
+ "KC_RALT", KC_RALT, 1, KC_NO, true},
+ CapsWordPressUserParams{
+ "OSM_MOD_RALT", OSM(MOD_RALT), 1, KC_NO, true},
+ CapsWordPressUserParams{
+ "RALT_T_held", RALT_T(KC_A), TAPPING_TERM + 1, KC_NO, true}
+ ),
+ CapsWordPressUserParams::GetName
+ );
+// clang-format on
+
struct CapsWordBothShiftsParams {
std::string name;
uint16_t left_shift_keycode;
@@ -435,3 +592,5 @@ INSTANTIATE_TEST_CASE_P(
CapsWordDoubleTapShiftParams::GetName
);
// clang-format on
+
+} // namespace
diff --git a/quantum/process_keycode/process_terminal_nop.h b/tests/tap_dance/config.h
index 36e25320c5..6aada3efd3 100644
--- a/quantum/process_keycode/process_terminal_nop.h
+++ b/tests/tap_dance/config.h
@@ -1,4 +1,4 @@
-/* Copyright 2017 Jack Humbert
+/* Copyright 2022 Jouke Witteveen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,7 +16,4 @@
#pragma once
-#include "quantum.h"
-
-#define TERM_ON KC_NO
-#define TERM_OFF KC_NO
+#include "test_common.h"
diff --git a/tests/tap_dance/examples.c b/tests/tap_dance/examples.c
new file mode 100644
index 0000000000..4a5be41b08
--- /dev/null
+++ b/tests/tap_dance/examples.c
@@ -0,0 +1,199 @@
+/* Copyright 2022 Jouke Witteveen
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "quantum.h"
+#include "examples.h"
+
+// Example code from the tap dance documentation, adapted for testing
+
+// clang-format off
+
+// Example 1
+
+void dance_egg(qk_tap_dance_state_t *state, void *user_data) {
+ if (state->count >= 100) {
+ // SEND_STRING("Safety dance!");
+ tap_code(KC_C);
+ reset_tap_dance(state);
+ }
+}
+
+
+// Example 2
+
+void dance_flsh_each(qk_tap_dance_state_t *state, void *user_data) {
+ switch (state->count) {
+ case 1:
+ register_code(KC_3);
+ break;
+ case 2:
+ register_code(KC_2);
+ break;
+ case 3:
+ register_code(KC_1);
+ break;
+ case 4:
+ unregister_code(KC_3);
+ // wait_ms(50);
+ unregister_code(KC_2);
+ // wait_ms(50);
+ unregister_code(KC_1);
+ }
+}
+
+void dance_flsh_finished(qk_tap_dance_state_t *state, void *user_data) {
+ if (state->count >= 4) {
+ // reset_keyboard();
+ tap_code(KC_R);
+ }
+}
+
+void dance_flsh_reset(qk_tap_dance_state_t *state, void *user_data) {
+ unregister_code(KC_1);
+ // wait_ms(50);
+ unregister_code(KC_2);
+ // wait_ms(50);
+ unregister_code(KC_3);
+}
+
+
+// Example 3
+
+typedef struct {
+ uint16_t tap;
+ uint16_t hold;
+ uint16_t held;
+} tap_dance_tap_hold_t;
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ qk_tap_dance_action_t *action;
+
+ switch (keycode) {
+ case TD(CT_CLN):
+ action = &tap_dance_actions[TD_INDEX(keycode)];
+ if (!record->event.pressed && action->state.count && !action->state.finished) {
+ tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data;
+ tap_code16(tap_hold->tap);
+ }
+ }
+ return true;
+}
+
+void tap_dance_tap_hold_finished(qk_tap_dance_state_t *state, void *user_data) {
+ tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)user_data;
+
+ if (state->pressed) {
+ if (state->count == 1
+#ifndef PERMISSIVE_HOLD
+ && !state->interrupted
+#endif
+ ) {
+ register_code16(tap_hold->hold);
+ tap_hold->held = tap_hold->hold;
+ } else {
+ register_code16(tap_hold->tap);
+ tap_hold->held = tap_hold->tap;
+ }
+ }
+}
+
+void tap_dance_tap_hold_reset(qk_tap_dance_state_t *state, void *user_data) {
+ tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)user_data;
+
+ if (tap_hold->held) {
+ unregister_code16(tap_hold->held);
+ tap_hold->held = 0;
+ }
+}
+
+#define ACTION_TAP_DANCE_TAP_HOLD(tap, hold) \
+ { .fn = {NULL, tap_dance_tap_hold_finished, tap_dance_tap_hold_reset}, .user_data = (void *)&((tap_dance_tap_hold_t){tap, hold, 0}), }
+
+
+// Example 4
+
+typedef enum {
+ TD_NONE,
+ TD_UNKNOWN,
+ TD_SINGLE_TAP,
+ TD_SINGLE_HOLD,
+ TD_DOUBLE_TAP,
+ TD_DOUBLE_HOLD,
+ TD_DOUBLE_SINGLE_TAP,
+ TD_TRIPLE_TAP,
+ TD_TRIPLE_HOLD
+} td_state_t;
+
+typedef struct {
+ bool is_press_action;
+ td_state_t state;
+} td_tap_t;
+
+td_state_t cur_dance(qk_tap_dance_state_t *state) {
+ if (state->count == 1) {
+ if (state->interrupted || !state->pressed) return TD_SINGLE_TAP;
+ else return TD_SINGLE_HOLD;
+ } else if (state->count == 2) {
+ if (state->interrupted) return TD_DOUBLE_SINGLE_TAP;
+ else if (state->pressed) return TD_DOUBLE_HOLD;
+ else return TD_DOUBLE_TAP;
+ }
+
+ if (state->count == 3) {
+ if (state->interrupted || !state->pressed) return TD_TRIPLE_TAP;
+ else return TD_TRIPLE_HOLD;
+ } else return TD_UNKNOWN;
+}
+
+static td_tap_t xtap_state = {
+ .is_press_action = true,
+ .state = TD_NONE
+};
+
+void x_finished(qk_tap_dance_state_t *state, void *user_data) {
+ xtap_state.state = cur_dance(state);
+ switch (xtap_state.state) {
+ case TD_SINGLE_TAP: register_code(KC_X); break;
+ case TD_SINGLE_HOLD: register_code(KC_LCTL); break;
+ case TD_DOUBLE_TAP: register_code(KC_ESC); break;
+ case TD_DOUBLE_HOLD: register_code(KC_LALT); break;
+ case TD_DOUBLE_SINGLE_TAP: tap_code(KC_X); register_code(KC_X);
+ default: break; // Not present in documentation
+ }
+}
+
+void x_reset(qk_tap_dance_state_t *state, void *user_data) {
+ switch (xtap_state.state) {
+ case TD_SINGLE_TAP: unregister_code(KC_X); break;
+ case TD_SINGLE_HOLD: unregister_code(KC_LCTL); break;
+ case TD_DOUBLE_TAP: unregister_code(KC_ESC); break;
+ case TD_DOUBLE_HOLD: unregister_code(KC_LALT);
+ case TD_DOUBLE_SINGLE_TAP: unregister_code(KC_X);
+ default: break; // Not present in documentation
+ }
+ xtap_state.state = TD_NONE;
+}
+
+
+qk_tap_dance_action_t tap_dance_actions[] = {
+ [TD_ESC_CAPS] = ACTION_TAP_DANCE_DOUBLE(KC_ESC, KC_CAPS),
+ [CT_EGG] = ACTION_TAP_DANCE_FN(dance_egg),
+ [CT_FLSH] = ACTION_TAP_DANCE_FN_ADVANCED(dance_flsh_each, dance_flsh_finished, dance_flsh_reset),
+ [CT_CLN] = ACTION_TAP_DANCE_TAP_HOLD(KC_COLN, KC_SCLN),
+ [X_CTL] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, x_finished, x_reset)
+};
+
+// clang-format on
diff --git a/quantum/process_keycode/process_terminal.h b/tests/tap_dance/examples.h
index 0159131e5b..2622af6b2f 100644
--- a/quantum/process_keycode/process_terminal.h
+++ b/tests/tap_dance/examples.h
@@ -1,4 +1,4 @@
-/* Copyright 2017 Jack Humbert
+/* Copyright 2022 Jouke Witteveen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,9 +16,18 @@
#pragma once
-#include "quantum.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
-extern const char keycode_to_ascii_lut[58];
-extern const char shifted_keycode_to_ascii_lut[58];
-extern const char terminal_prompt[8];
-bool process_terminal(uint16_t keycode, keyrecord_t *record);
+enum {
+ TD_ESC_CAPS,
+ CT_EGG,
+ CT_FLSH,
+ CT_CLN,
+ X_CTL,
+};
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/tests/tap_dance/test.mk b/tests/tap_dance/test.mk
new file mode 100644
index 0000000000..041d9b4dc9
--- /dev/null
+++ b/tests/tap_dance/test.mk
@@ -0,0 +1,22 @@
+# Copyright 2022 Jouke Witteveen
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# --------------------------------------------------------------------------------
+# Keep this file, even if it is empty, as a marker that this folder contains tests
+# --------------------------------------------------------------------------------
+
+TAP_DANCE_ENABLE = yes
+
+SRC += examples.c
diff --git a/tests/tap_dance/test_examples.cpp b/tests/tap_dance/test_examples.cpp
new file mode 100644
index 0000000000..6dabc45513
--- /dev/null
+++ b/tests/tap_dance/test_examples.cpp
@@ -0,0 +1,318 @@
+/* Copyright 2022 Jouke Witteveen
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "keyboard_report_util.hpp"
+#include "keycode.h"
+#include "test_common.hpp"
+#include "action_tapping.h"
+#include "test_keymap_key.hpp"
+#include "examples.h"
+
+using testing::_;
+using testing::InSequence;
+
+class TapDance : public TestFixture {};
+
+TEST_F(TapDance, DoubleTap) {
+ TestDriver driver;
+ InSequence s;
+ auto key_esc_caps = KeymapKey{0, 1, 0, TD(TD_ESC_CAPS)};
+
+ set_keymap({key_esc_caps});
+
+ /* The tap dance key does nothing on the first press */
+ key_esc_caps.press();
+ run_one_scan_loop();
+ key_esc_caps.release();
+ EXPECT_NO_REPORT(driver);
+
+ /* We get the key press and the release on timeout */
+ idle_for(TAPPING_TERM);
+ EXPECT_REPORT(driver, (KC_ESC));
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+
+ /* Double tap gets us the second key */
+ tap_key(key_esc_caps);
+ EXPECT_NO_REPORT(driver);
+ key_esc_caps.press();
+ EXPECT_REPORT(driver, (KC_CAPS));
+ run_one_scan_loop();
+ key_esc_caps.release();
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+}
+
+TEST_F(TapDance, DoubleTapWithMod) {
+ TestDriver driver;
+ InSequence s;
+ auto key_esc_caps = KeymapKey{0, 1, 0, TD(TD_ESC_CAPS)};
+ auto key_shift = KeymapKey{0, 2, 0, KC_LSFT};
+
+ set_keymap({key_esc_caps, key_shift});
+
+ /* The tap dance key does nothing on the first press */
+ key_shift.press();
+ EXPECT_REPORT(driver, (KC_LSFT));
+ run_one_scan_loop();
+ key_esc_caps.press();
+ run_one_scan_loop();
+
+ key_esc_caps.release();
+ key_shift.release();
+ EXPECT_EMPTY_REPORT(driver);
+
+ /* We get the key press and the release */
+ idle_for(TAPPING_TERM);
+ EXPECT_REPORT(driver, (KC_LSFT));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_ESC));
+ EXPECT_REPORT(driver, (KC_LSFT));
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+
+ /* Double tap gets us the second key */
+ key_shift.press();
+ EXPECT_REPORT(driver, (KC_LSFT));
+ run_one_scan_loop();
+ tap_key(key_esc_caps);
+ EXPECT_NO_REPORT(driver);
+ key_shift.release();
+ key_esc_caps.press();
+ EXPECT_REPORT(driver, (KC_LSFT, KC_CAPS));
+ EXPECT_REPORT(driver, (KC_CAPS));
+ run_one_scan_loop();
+ key_esc_caps.release();
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+}
+
+TEST_F(TapDance, DoubleTapInterrupted) {
+ TestDriver driver;
+ InSequence s;
+ auto key_esc_caps = KeymapKey{0, 1, 0, TD(TD_ESC_CAPS)};
+ auto regular_key = KeymapKey(0, 2, 0, KC_A);
+
+ set_keymap({key_esc_caps, regular_key});
+
+ /* Interrupted double tap */
+ tap_key(key_esc_caps);
+ regular_key.press();
+ /* Immediate tap of the first key */
+ EXPECT_REPORT(driver, (KC_ESC));
+ EXPECT_EMPTY_REPORT(driver);
+ /* Followed by the interrupting key */
+ EXPECT_REPORT(driver, (KC_A));
+ run_one_scan_loop();
+ regular_key.release();
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+
+ /* Second tap after being interrupted acts as a single tap */
+ key_esc_caps.press();
+ run_one_scan_loop();
+ key_esc_caps.release();
+ idle_for(TAPPING_TERM);
+ EXPECT_REPORT(driver, (KC_ESC));
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+}
+
+TEST_F(TapDance, DanceFn) {
+ TestDriver driver;
+ InSequence s;
+ auto key_egg = KeymapKey(0, 1, 0, TD(CT_EGG));
+
+ set_keymap({key_egg});
+
+ /* 99 taps do nothing */
+ for (int i = 0; i < 99; i++) {
+ run_one_scan_loop();
+ key_egg.press();
+ run_one_scan_loop();
+ key_egg.release();
+ }
+ idle_for(TAPPING_TERM);
+ EXPECT_NO_REPORT(driver);
+ run_one_scan_loop();
+
+ /* 100 taps trigger the action */
+ for (int i = 0; i < 100; i++) {
+ run_one_scan_loop();
+ key_egg.press();
+ run_one_scan_loop();
+ key_egg.release();
+ }
+ idle_for(TAPPING_TERM);
+ EXPECT_REPORT(driver, (KC_C));
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+
+ /* 250 taps act the same as 100 taps */
+ /* Taps are counted in an uint8_t, so the count overflows after 255 taps */
+ for (int i = 0; i < 250; i++) {
+ run_one_scan_loop();
+ key_egg.press();
+ run_one_scan_loop();
+ key_egg.release();
+ }
+ idle_for(TAPPING_TERM);
+ EXPECT_REPORT(driver, (KC_C));
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+}
+
+TEST_F(TapDance, DanceFnAdvanced) {
+ TestDriver driver;
+ InSequence s;
+ auto key_flsh = KeymapKey(0, 1, 0, TD(CT_FLSH));
+
+ set_keymap({key_flsh});
+
+ /* Three taps don't trigger a reset */
+ EXPECT_REPORT(driver, (KC_3));
+ EXPECT_REPORT(driver, (KC_3, KC_2));
+ EXPECT_REPORT(driver, (KC_3, KC_2, KC_1));
+ for (int i = 0; i < 3; i++) {
+ run_one_scan_loop();
+ key_flsh.press();
+ run_one_scan_loop();
+ key_flsh.release();
+ }
+ idle_for(TAPPING_TERM);
+ EXPECT_REPORT(driver, (KC_3, KC_2));
+ EXPECT_REPORT(driver, (KC_3));
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+
+ /* Four taps trigger a reset */
+ EXPECT_REPORT(driver, (KC_3));
+ EXPECT_REPORT(driver, (KC_3, KC_2));
+ EXPECT_REPORT(driver, (KC_3, KC_2, KC_1));
+ EXPECT_REPORT(driver, (KC_2, KC_1));
+ EXPECT_REPORT(driver, (KC_1));
+ EXPECT_EMPTY_REPORT(driver);
+ for (int i = 0; i < 4; i++) {
+ run_one_scan_loop();
+ key_flsh.press();
+ run_one_scan_loop();
+ key_flsh.release();
+ }
+ idle_for(TAPPING_TERM);
+ EXPECT_REPORT(driver, (KC_R));
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+}
+
+TEST_F(TapDance, TapHold) {
+ TestDriver driver;
+ InSequence s;
+ auto key_cln = KeymapKey{0, 1, 0, TD(CT_CLN)};
+
+ set_keymap({key_cln});
+
+ /* Short taps fire on release */
+ key_cln.press();
+ run_one_scan_loop();
+ key_cln.release();
+ EXPECT_REPORT(driver, (KC_LSFT));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_SCLN));
+ EXPECT_REPORT(driver, (KC_LSFT));
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+
+ /* Holds immediate following a tap apply to the tap key */
+ key_cln.press();
+ EXPECT_REPORT(driver, (KC_LSFT));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_SCLN));
+ idle_for(TAPPING_TERM * 2);
+ key_cln.release();
+ EXPECT_REPORT(driver, (KC_LSFT));
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+
+ /* Holds trigger the hold key */
+ key_cln.press();
+ idle_for(TAPPING_TERM);
+ run_one_scan_loop();
+ EXPECT_REPORT(driver, (KC_SCLN));
+ run_one_scan_loop();
+ key_cln.release();
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+}
+
+TEST_F(TapDance, QuadFunction) {
+ TestDriver driver;
+ InSequence s;
+ auto key_quad = KeymapKey{0, 1, 0, TD(X_CTL)};
+ auto regular_key = KeymapKey(0, 2, 0, KC_A);
+
+ set_keymap({key_quad, regular_key});
+
+ /* Single tap */
+ key_quad.press();
+ run_one_scan_loop();
+ key_quad.release();
+ idle_for(TAPPING_TERM);
+ EXPECT_REPORT(driver, (KC_X));
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+
+ /* Single hold */
+ key_quad.press();
+ run_one_scan_loop();
+ idle_for(TAPPING_TERM);
+ EXPECT_REPORT(driver, (KC_LCTL));
+ run_one_scan_loop();
+ key_quad.release();
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+
+ /* Double tap */
+ tap_key(key_quad);
+ key_quad.press();
+ run_one_scan_loop();
+ key_quad.release();
+ idle_for(TAPPING_TERM);
+ EXPECT_REPORT(driver, (KC_ESC));
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+
+ /* Double tap and hold */
+ tap_key(key_quad);
+ key_quad.press();
+ run_one_scan_loop();
+ idle_for(TAPPING_TERM);
+ EXPECT_REPORT(driver, (KC_LALT));
+ run_one_scan_loop();
+ key_quad.release();
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+
+ /* Double single tap */
+ tap_key(key_quad);
+ tap_key(key_quad);
+ regular_key.press();
+ EXPECT_REPORT(driver, (KC_X));
+ EXPECT_EMPTY_REPORT(driver);
+ EXPECT_REPORT(driver, (KC_X));
+ EXPECT_EMPTY_REPORT(driver);
+ EXPECT_REPORT(driver, (KC_A));
+ run_one_scan_loop();
+ regular_key.release();
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+}
diff --git a/tests/tap_hold_configurations/default_mod_tap/test_tap_hold.cpp b/tests/tap_hold_configurations/default_mod_tap/test_tap_hold.cpp
index ecb79c2560..b70efe4aed 100644
--- a/tests/tap_hold_configurations/default_mod_tap/test_tap_hold.cpp
+++ b/tests/tap_hold_configurations/default_mod_tap/test_tap_hold.cpp
@@ -133,15 +133,13 @@ TEST_F(DefaultTapHold, tap_regular_key_while_layer_tap_key_is_held) {
EXPECT_REPORT(driver, (KC_P));
EXPECT_REPORT(driver, (KC_P, KC_A));
EXPECT_REPORT(driver, (KC_P));
- EXPECT_CALL(driver, send_keyboard_mock(_));
+ EXPECT_EMPTY_REPORT(driver);
layer_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
}
TEST_F(DefaultTapHold, tap_mod_tap_hold_key_two_times) {
- GTEST_SKIP() << "TODO:Holding a modtap key results in out of bounds access to the keymap, this is a bug in QMK.";
-
TestDriver driver;
InSequence s;
auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
@@ -175,8 +173,6 @@ TEST_F(DefaultTapHold, tap_mod_tap_hold_key_two_times) {
}
TEST_F(DefaultTapHold, tap_mod_tap_hold_key_twice_and_hold_on_second_time) {
- GTEST_SKIP() << "TODO:Holding a modtap key results in out of bounds access to the keymap, this is a bug in QMK.";
-
TestDriver driver;
InSequence s;
auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
@@ -217,7 +213,7 @@ TEST_F(DefaultTapHold, tap_and_hold_mod_tap_hold_key) {
set_keymap({mod_tap_hold_key});
/* Press mod-tap-hold key. */
- EXPECT_REPORT(driver, (KC_LSHIFT));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
mod_tap_hold_key.press();
idle_for(TAPPING_TERM + 1);
testing::Mock::VerifyAndClearExpectations(&driver);
diff --git a/tests/tap_hold_configurations/ignore_mod_tap_interrupt/test_tap_hold.cpp b/tests/tap_hold_configurations/ignore_mod_tap_interrupt/test_tap_hold.cpp
index 5ece124c1d..319de61070 100644
--- a/tests/tap_hold_configurations/ignore_mod_tap_interrupt/test_tap_hold.cpp
+++ b/tests/tap_hold_configurations/ignore_mod_tap_interrupt/test_tap_hold.cpp
@@ -53,10 +53,10 @@ TEST_F(IgnoreModTapInterrupt, tap_regular_key_while_mod_tap_key_is_held) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release mod-tap-hold key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A, KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_REPORT(driver, (KC_A, KC_P));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_EMPTY_REPORT(driver);
mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -89,10 +89,10 @@ TEST_F(IgnoreModTapInterrupt, tap_mod_tap_key_while_mod_tap_key_is_held) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release first mod-tap-hold key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A, KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_REPORT(driver, (KC_A, KC_P));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_EMPTY_REPORT(driver);
first_mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -126,10 +126,10 @@ TEST_F(IgnoreModTapInterrupt, tap_regular_key_while_layer_tap_key_is_held) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release layer-tap-hold key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P, regular_key.report_code)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_REPORT(driver, (KC_P, regular_key.report_code));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_EMPTY_REPORT(driver);
layer_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
diff --git a/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp b/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp
index 64a6ff58e6..1328b5fc0f 100644
--- a/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp
+++ b/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp
@@ -44,14 +44,14 @@ TEST_P(OneShotParametrizedTestFixture, OSMAsRegularModifierWithAdditionalKeypres
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release regular key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(osm_key.report_code))).Times(2);
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code, osm_key.report_code))).Times(1);
+ EXPECT_REPORT(driver, (osm_key.report_code)).Times(2);
+ EXPECT_REPORT(driver, (regular_key.report_code, osm_key.report_code)).Times(1);
regular_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release OSM */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
+ EXPECT_EMPTY_REPORT(driver).Times(1);
osm_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
diff --git a/tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp b/tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp
index 28fb17ca66..74e81f347f 100644
--- a/tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp
+++ b/tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp
@@ -46,15 +46,15 @@ TEST_F(PermissiveHold, tap_regular_key_while_mod_tap_key_is_held) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release regular key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT, regular_key.report_code)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT)));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT, regular_key.report_code));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
regular_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release mod-tap-hold key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -81,15 +81,15 @@ TEST_F(PermissiveHold, tap_mod_tap_key_while_mod_tap_key_is_held) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release second mod-tap-hold key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT, second_mod_tap_hold_key.report_code)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT)));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT, second_mod_tap_hold_key.report_code));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
second_mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release first mod-tap-hold key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
first_mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -117,8 +117,8 @@ TEST_F(PermissiveHold, tap_regular_key_while_layer_tap_key_is_held) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release regular key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(layer_key.report_code)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (layer_key.report_code));
+ EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
diff --git a/tests/tap_hold_configurations/permissive_hold_ignore_mod_tap_interrupt/test_tap_hold.cpp b/tests/tap_hold_configurations/permissive_hold_ignore_mod_tap_interrupt/test_tap_hold.cpp
index f2d576e875..ee7e707c94 100644
--- a/tests/tap_hold_configurations/permissive_hold_ignore_mod_tap_interrupt/test_tap_hold.cpp
+++ b/tests/tap_hold_configurations/permissive_hold_ignore_mod_tap_interrupt/test_tap_hold.cpp
@@ -48,15 +48,15 @@ TEST_F(PermissiveHold_IgnoreModTapInterrupt, tap_regular_key_while_mod_tap_key_i
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release regular key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
+ EXPECT_REPORT(driver, (KC_LSFT));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_A));
+ EXPECT_REPORT(driver, (KC_LSFT));
regular_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release mod-tap-hold key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -83,15 +83,15 @@ TEST_F(PermissiveHold_IgnoreModTapInterrupt, tap_mod_tap_key_while_mod_tap_key_i
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release second tap-hold key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
+ EXPECT_REPORT(driver, (KC_LSFT));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_A));
+ EXPECT_REPORT(driver, (KC_LSFT));
second_mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release first mod-tap-hold key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
first_mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -119,8 +119,8 @@ TEST_F(PermissiveHold_IgnoreModTapInterrupt, tap_regular_key_while_layer_tap_key
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release regular key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_B));
+ EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
diff --git a/tests/tap_hold_configurations/retro_tapping/test_tap_hold.cpp b/tests/tap_hold_configurations/retro_tapping/test_tap_hold.cpp
index b3d4e520f6..e08c600dbd 100644
--- a/tests/tap_hold_configurations/retro_tapping/test_tap_hold.cpp
+++ b/tests/tap_hold_configurations/retro_tapping/test_tap_hold.cpp
@@ -42,10 +42,10 @@ TEST_F(RetroTapping, tap_and_hold_mod_tap_hold_key) {
/* Release mod-tap-hold key. */
/* TODO: Why is LSHIFT send at all? */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
+ EXPECT_EMPTY_REPORT(driver);
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_EMPTY_REPORT(driver);
mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
diff --git a/tests/tap_hold_configurations/retro_tapping/test_tapping.cpp b/tests/tap_hold_configurations/retro_tapping/test_tapping.cpp
index cd73f1e784..42139d50da 100644
--- a/tests/tap_hold_configurations/retro_tapping/test_tapping.cpp
+++ b/tests/tap_hold_configurations/retro_tapping/test_tapping.cpp
@@ -37,13 +37,13 @@ TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) {
idle_for(TAPPING_TERM);
testing::Mock::VerifyAndClearExpectations(&driver);
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
+ EXPECT_REPORT(driver, (KC_LSFT));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_EMPTY_REPORT(driver);
mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -63,20 +63,20 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release mod_tap_hold key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_EMPTY_REPORT(driver);
key_shift_hold_p_tap.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Press mod_tap_hold key again */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
+ EXPECT_REPORT(driver, (KC_P));
key_shift_hold_p_tap.press();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release mod_tap_hold key again */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
key_shift_hold_p_tap.release();
idle_for(TAPPING_TERM + 1);
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -88,8 +88,8 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release mod_tap_hold key again */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_EMPTY_REPORT(driver);
key_shift_hold_p_tap.release();
idle_for(TAPPING_TERM + 1);
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -102,10 +102,10 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) {
/* Release mod_tap_hold key again */
/* TODO: Why is KC_LSFT send? */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_LSFT));
+ EXPECT_EMPTY_REPORT(driver);
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_EMPTY_REPORT(driver);
key_shift_hold_p_tap.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
diff --git a/tests/tap_hold_configurations/tapping_force_hold/test_action_layer.cpp b/tests/tap_hold_configurations/tapping_force_hold/test_action_layer.cpp
index a67c6629e0..965c702d7a 100644
--- a/tests/tap_hold_configurations/tapping_force_hold/test_action_layer.cpp
+++ b/tests/tap_hold_configurations/tapping_force_hold/test_action_layer.cpp
@@ -66,13 +66,13 @@ TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) {
testing::Mock::VerifyAndClearExpectations(&driver);
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A))).Times(1);
+ EXPECT_REPORT(driver, (KC_A)).Times(1);
regular_key.press();
run_one_scan_loop();
expect_layer_state(0);
testing::Mock::VerifyAndClearExpectations(&driver);
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
+ EXPECT_EMPTY_REPORT(driver).Times(1);
regular_key.release();
run_one_scan_loop();
expect_layer_state(0);
diff --git a/tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp b/tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp
index 04e66a02d9..604f9a4a54 100644
--- a/tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp
+++ b/tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp
@@ -54,15 +54,15 @@ TEST_F(TappingForceHold, tap_regular_key_while_mod_tap_key_is_held) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release mod-tap-hold key. */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
+ EXPECT_REPORT(driver, (KC_LSFT));
mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Idle for tapping term of mod tap hold key. */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_A));
+ EXPECT_REPORT(driver, (KC_LSFT));
+ EXPECT_EMPTY_REPORT(driver);
idle_for(TAPPING_TERM - 3);
testing::Mock::VerifyAndClearExpectations(&driver);
}
@@ -94,15 +94,15 @@ TEST_F(TappingForceHold, tap_mod_tap_key_while_mod_tap_key_is_held) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release first mod-tap-hold key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
+ EXPECT_REPORT(driver, (KC_LSFT));
first_mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Idle for tapping term of first mod tap hold key. */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_A));
+ EXPECT_REPORT(driver, (KC_LSFT));
+ EXPECT_EMPTY_REPORT(driver);
idle_for(TAPPING_TERM - 3);
testing::Mock::VerifyAndClearExpectations(&driver);
}
@@ -135,10 +135,10 @@ TEST_F(TappingForceHold, tap_regular_key_while_layer_tap_key_is_held) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release layer-tap-hold key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A, KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(_));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_REPORT(driver, (KC_A, KC_P));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_EMPTY_REPORT(driver);
layer_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -158,8 +158,8 @@ TEST_F(TappingForceHold, tap_mod_tap_hold_key_two_times) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release mod-tap-hold key. */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_EMPTY_REPORT(driver);
mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -171,8 +171,8 @@ TEST_F(TappingForceHold, tap_mod_tap_hold_key_two_times) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release mod-tap-hold key. */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_EMPTY_REPORT(driver);
mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -192,8 +192,8 @@ TEST_F(TappingForceHold, tap_mod_tap_hold_key_twice_and_hold_on_second_time) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release mod-tap-hold key. */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_EMPTY_REPORT(driver);
mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -205,8 +205,8 @@ TEST_F(TappingForceHold, tap_mod_tap_hold_key_twice_and_hold_on_second_time) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release mod-tap-hold key. */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
+ EXPECT_EMPTY_REPORT(driver);
mod_tap_hold_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp
index 5fc6964054..44694cd390 100644
--- a/tests/test_common/test_fixture.cpp
+++ b/tests/test_common/test_fixture.cpp
@@ -108,6 +108,22 @@ void TestFixture::tap_key(KeymapKey key, unsigned delay_ms) {
run_one_scan_loop();
}
+void TestFixture::tap_combo(const std::vector<KeymapKey>& chord_keys, unsigned delay_ms) {
+ for (KeymapKey key : chord_keys) { // Press each key.
+ key.press();
+ run_one_scan_loop();
+ }
+
+ if (delay_ms > 1) {
+ idle_for(delay_ms - 1);
+ }
+
+ for (KeymapKey key : chord_keys) { // Release each key.
+ key.release();
+ run_one_scan_loop();
+ }
+}
+
void TestFixture::set_keymap(std::initializer_list<KeymapKey> keys) {
this->keymap.clear();
for (auto& key : keys) {
diff --git a/tests/test_common/test_fixture.hpp b/tests/test_common/test_fixture.hpp
index 81906f76c7..2590acd006 100644
--- a/tests/test_common/test_fixture.hpp
+++ b/tests/test_common/test_fixture.hpp
@@ -53,6 +53,13 @@ class TestFixture : public testing::Test {
}
}
+ /**
+ * @brief Taps a combo with `delay_ms` delay between press and release.
+ *
+ * Example: `tap_combo({key_a, key_b})` to tap the chord A + B.
+ */
+ void tap_combo(const std::vector<KeymapKey>& chord_keys, unsigned delay_ms = 1);
+
void run_one_scan_loop();
void idle_for(unsigned ms);
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
index 3ed83a44a6..52fe86d297 100644
--- a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
+++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
@@ -450,7 +450,7 @@ static void md_rgb_matrix_config_override(int i) {
float bo = 0;
float po;
- uint8_t highest_active_layer = biton32(layer_state);
+ uint8_t highest_active_layer = get_highest_layer(layer_state);
if (led_animation_circular) {
// TODO: should use min/max values from LED configuration instead of
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index 04ae3d7f4d..b61228511d 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -32,6 +32,7 @@
#include "usb_main.h"
#include "host.h"
+#include "chibios_config.h"
#include "debug.h"
#include "suspend.h"
#ifdef SLEEP_LED_ENABLE
@@ -103,6 +104,13 @@ uint8_t extra_report_blank[3] = {0};
* ---------------------------------------------------------
*/
+/* USB Low Level driver specific endpoint fields */
+#if !defined(usb_lld_endpoint_fields)
+# define usb_lld_endpoint_fields \
+ 2, /* IN multiplier */ \
+ NULL, /* SETUP buffer (not a SETUP endpoint) */
+#endif
+
/* HID specific constants */
#define HID_GET_REPORT 0x01
#define HID_GET_IDLE 0x02
@@ -133,16 +141,15 @@ static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype
static USBInEndpointState kbd_ep_state;
/* keyboard endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */
static const USBEndpointConfig kbd_ep_config = {
- USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
- NULL, /* SETUP packet notification callback */
- kbd_in_cb, /* IN notification callback */
- NULL, /* OUT notification callback */
- KEYBOARD_EPSIZE, /* IN maximum packet size */
- 0, /* OUT maximum packet size */
- &kbd_ep_state, /* IN Endpoint state */
- NULL, /* OUT endpoint state */
- 2, /* IN multiplier */
- NULL /* SETUP buffer (not a SETUP endpoint) */
+ USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
+ NULL, /* SETUP packet notification callback */
+ kbd_in_cb, /* IN notification callback */
+ NULL, /* OUT notification callback */
+ KEYBOARD_EPSIZE, /* IN maximum packet size */
+ 0, /* OUT maximum packet size */
+ &kbd_ep_state, /* IN Endpoint state */
+ NULL, /* OUT endpoint state */
+ usb_lld_endpoint_fields /* USB driver specific endpoint fields */
};
#endif
@@ -152,16 +159,15 @@ static USBInEndpointState mouse_ep_state;
/* mouse endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */
static const USBEndpointConfig mouse_ep_config = {
- USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
- NULL, /* SETUP packet notification callback */
- mouse_in_cb, /* IN notification callback */
- NULL, /* OUT notification callback */
- MOUSE_EPSIZE, /* IN maximum packet size */
- 0, /* OUT maximum packet size */
- &mouse_ep_state, /* IN Endpoint state */
- NULL, /* OUT endpoint state */
- 2, /* IN multiplier */
- NULL /* SETUP buffer (not a SETUP endpoint) */
+ USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
+ NULL, /* SETUP packet notification callback */
+ mouse_in_cb, /* IN notification callback */
+ NULL, /* OUT notification callback */
+ MOUSE_EPSIZE, /* IN maximum packet size */
+ 0, /* OUT maximum packet size */
+ &mouse_ep_state, /* IN Endpoint state */
+ NULL, /* OUT endpoint state */
+ usb_lld_endpoint_fields /* USB driver specific endpoint fields */
};
#endif
@@ -171,36 +177,19 @@ static USBInEndpointState shared_ep_state;
/* shared endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */
static const USBEndpointConfig shared_ep_config = {
- USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
- NULL, /* SETUP packet notification callback */
- shared_in_cb, /* IN notification callback */
- NULL, /* OUT notification callback */
- SHARED_EPSIZE, /* IN maximum packet size */
- 0, /* OUT maximum packet size */
- &shared_ep_state, /* IN Endpoint state */
- NULL, /* OUT endpoint state */
- 2, /* IN multiplier */
- NULL /* SETUP buffer (not a SETUP endpoint) */
+ USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
+ NULL, /* SETUP packet notification callback */
+ shared_in_cb, /* IN notification callback */
+ NULL, /* OUT notification callback */
+ SHARED_EPSIZE, /* IN maximum packet size */
+ 0, /* OUT maximum packet size */
+ &shared_ep_state, /* IN Endpoint state */
+ NULL, /* OUT endpoint state */
+ usb_lld_endpoint_fields /* USB driver specific endpoint fields */
};
#endif
-#ifdef WEBUSB_ENABLE
-/** Microsoft OS 2.0 Descriptor. This is used by Windows to select the USB driver for the device.
- *
- * For WebUSB in Chrome, the correct driver is WinUSB, which is selected via CompatibleID.
- *
- * Additionally, while Chrome is built using libusb, a magic registry key needs to be set containing a GUID for
- * the device.
- */
-const MS_OS_20_Descriptor_t PROGMEM MS_OS_20_Descriptor = MS_OS_20_DESCRIPTOR;
-
-/** URL descriptor string. This is a UTF-8 string containing a URL excluding the prefix. At least one of these must be
- * defined and returned when the Landing Page descriptor index is requested.
- */
-const WebUSB_URL_Descriptor_t PROGMEM WebUSB_LandingPage = WEBUSB_URL_DESCRIPTOR(WEBUSB_LANDING_PAGE_URL);
-#endif
-
-#if STM32_USB_USE_OTG1
+#ifdef USB_ENDPOINTS_ARE_REORDERABLE
typedef struct {
size_t queue_capacity_in;
size_t queue_capacity_out;
@@ -227,23 +216,22 @@ typedef struct {
} usb_driver_config_t;
#endif
-#if STM32_USB_USE_OTG1
+#ifdef USB_ENDPOINTS_ARE_REORDERABLE
/* Reusable initialization structure - see USBEndpointConfig comment at top of file */
# define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \
{ \
.queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \
.inout_ep_config = \
{ \
- stream##_IN_MODE, /* Interrupt EP */ \
- NULL, /* SETUP packet notification callback */ \
- qmkusbDataTransmitted, /* IN notification callback */ \
- qmkusbDataReceived, /* OUT notification callback */ \
- stream##_EPSIZE, /* IN maximum packet size */ \
- stream##_EPSIZE, /* OUT maximum packet size */ \
- NULL, /* IN Endpoint state */ \
- NULL, /* OUT endpoint state */ \
- 2, /* IN multiplier */ \
- NULL /* SETUP buffer (not a SETUP endpoint) */ \
+ stream##_IN_MODE, /* Interrupt EP */ \
+ NULL, /* SETUP packet notification callback */ \
+ qmkusbDataTransmitted, /* IN notification callback */ \
+ qmkusbDataReceived, /* OUT notification callback */ \
+ stream##_EPSIZE, /* IN maximum packet size */ \
+ stream##_EPSIZE, /* OUT maximum packet size */ \
+ NULL, /* IN Endpoint state */ \
+ NULL, /* OUT endpoint state */ \
+ usb_lld_endpoint_fields /* USB driver specific endpoint fields */ \
}, \
.int_ep_config = \
{ \
@@ -255,8 +243,7 @@ typedef struct {
0, /* OUT maximum packet size */ \
NULL, /* IN Endpoint state */ \
NULL, /* OUT endpoint state */ \
- 2, /* IN multiplier */ \
- NULL, /* SETUP buffer (not a SETUP endpoint) */ \
+ usb_lld_endpoint_fields /* USB driver specific endpoint fields */ \
}, \
.config = { \
.usbp = &USB_DRIVER, \
@@ -279,29 +266,27 @@ typedef struct {
.queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \
.in_ep_config = \
{ \
- stream##_IN_MODE, /* Interrupt EP */ \
- NULL, /* SETUP packet notification callback */ \
- qmkusbDataTransmitted, /* IN notification callback */ \
- NULL, /* OUT notification callback */ \
- stream##_EPSIZE, /* IN maximum packet size */ \
- 0, /* OUT maximum packet size */ \
- NULL, /* IN Endpoint state */ \
- NULL, /* OUT endpoint state */ \
- 2, /* IN multiplier */ \
- NULL /* SETUP buffer (not a SETUP endpoint) */ \
+ stream##_IN_MODE, /* Interrupt EP */ \
+ NULL, /* SETUP packet notification callback */ \
+ qmkusbDataTransmitted, /* IN notification callback */ \
+ NULL, /* OUT notification callback */ \
+ stream##_EPSIZE, /* IN maximum packet size */ \
+ 0, /* OUT maximum packet size */ \
+ NULL, /* IN Endpoint state */ \
+ NULL, /* OUT endpoint state */ \
+ usb_lld_endpoint_fields /* USB driver specific endpoint fields */ \
}, \
.out_ep_config = \
{ \
- stream##_OUT_MODE, /* Interrupt EP */ \
- NULL, /* SETUP packet notification callback */ \
- NULL, /* IN notification callback */ \
- qmkusbDataReceived, /* OUT notification callback */ \
- 0, /* IN maximum packet size */ \
- stream##_EPSIZE, /* OUT maximum packet size */ \
- NULL, /* IN Endpoint state */ \
- NULL, /* OUT endpoint state */ \
- 2, /* IN multiplier */ \
- NULL, /* SETUP buffer (not a SETUP endpoint) */ \
+ stream##_OUT_MODE, /* Interrupt EP */ \
+ NULL, /* SETUP packet notification callback */ \
+ NULL, /* IN notification callback */ \
+ qmkusbDataReceived, /* OUT notification callback */ \
+ 0, /* IN maximum packet size */ \
+ stream##_EPSIZE, /* OUT maximum packet size */ \
+ NULL, /* IN Endpoint state */ \
+ NULL, /* OUT endpoint state */ \
+ usb_lld_endpoint_fields /* USB driver specific endpoint fields */ \
}, \
.int_ep_config = \
{ \
@@ -313,8 +298,7 @@ typedef struct {
0, /* OUT maximum packet size */ \
NULL, /* IN Endpoint state */ \
NULL, /* OUT endpoint state */ \
- 2, /* IN multiplier */ \
- NULL, /* SETUP buffer (not a SETUP endpoint) */ \
+ usb_lld_endpoint_fields /* USB driver specific endpoint fields */ \
}, \
.config = { \
.usbp = &USB_DRIVER, \
@@ -526,7 +510,7 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) {
usbInitEndpointI(usbp, SHARED_IN_EPNUM, &shared_ep_config);
#endif
for (int i = 0; i < NUM_USB_DRIVERS; i++) {
-#if STM32_USB_USE_OTG1
+#ifdef USB_ENDPOINTS_ARE_REORDERABLE
usbInitEndpointI(usbp, drivers.array[i].config.bulk_in, &drivers.array[i].inout_ep_config);
#else
usbInitEndpointI(usbp, drivers.array[i].config.bulk_in, &drivers.array[i].in_ep_config);
@@ -774,7 +758,7 @@ static const USBConfig usbcfg = {
*/
void init_usb_driver(USBDriver *usbp) {
for (int i = 0; i < NUM_USB_DRIVERS; i++) {
-#if STM32_USB_USE_OTG1
+#ifdef USB_ENDPOINTS_ARE_REORDERABLE
QMKUSBDriver *driver = &drivers.array[i].driver;
drivers.array[i].inout_ep_config.in_state = &drivers.array[i].in_ep_state;
drivers.array[i].inout_ep_config.out_state = &drivers.array[i].out_ep_state;
diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c
index 053d2b79e3..3d8604d541 100644
--- a/tmk_core/protocol/host.c
+++ b/tmk_core/protocol/host.c
@@ -94,6 +94,11 @@ void host_mouse_send(report_mouse_t *report) {
#ifdef MOUSE_SHARED_EP
report->report_id = REPORT_ID_MOUSE;
#endif
+#ifdef MOUSE_EXTENDED_REPORT
+ // clip and copy to Boot protocol XY
+ report->boot_x = (report->x > 127) ? 127 : ((report->x < -127) ? -127 : report->x);
+ report->boot_y = (report->y > 127) ? 127 : ((report->y < -127) ? -127 : report->y);
+#endif
(*driver->send_mouse)(report);
}
diff --git a/tmk_core/protocol/midi/midi.c b/tmk_core/protocol/midi/midi.c
index f3792552f4..1ba3e73a40 100644
--- a/tmk_core/protocol/midi/midi.c
+++ b/tmk_core/protocol/midi/midi.c
@@ -19,7 +19,9 @@
#include "midi.h"
#include <string.h> //for memcpy
-#define MIN(x, y) (((x) < (y)) ? (x) : (y))
+#ifndef MIN
+# define MIN(x, y) (((x) < (y)) ? (x) : (y))
+#endif
#ifndef NULL
# define NULL 0
diff --git a/tmk_core/protocol/report.h b/tmk_core/protocol/report.h
index 7bbeb78af7..735ccdb4a1 100644
--- a/tmk_core/protocol/report.h
+++ b/tmk_core/protocol/report.h
@@ -201,15 +201,25 @@ typedef struct {
uint32_t usage;
} __attribute__((packed)) report_programmable_button_t;
+#ifdef MOUSE_EXTENDED_REPORT
+typedef int16_t mouse_xy_report_t;
+#else
+typedef int8_t mouse_xy_report_t;
+#endif
+
typedef struct {
#ifdef MOUSE_SHARED_EP
uint8_t report_id;
#endif
uint8_t buttons;
- int8_t x;
- int8_t y;
- int8_t v;
- int8_t h;
+#ifdef MOUSE_EXTENDED_REPORT
+ int8_t boot_x;
+ int8_t boot_y;
+#endif
+ mouse_xy_report_t x;
+ mouse_xy_report_t y;
+ int8_t v;
+ int8_t h;
} __attribute__((packed)) report_mouse_t;
typedef struct {
diff --git a/tmk_core/protocol/serial.h b/tmk_core/protocol/serial.h
deleted file mode 100644
index 0204b84a92..0000000000
--- a/tmk_core/protocol/serial.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-Copyright 2012 Jun WAKO <wakojun@gmail.com>
-
-This software is licensed with a Modified BSD License.
-All of this is supposed to be Free Software, Open Source, DFSG-free,
-GPL-compatible, and OK to use in both free and proprietary applications.
-Additions and corrections to this file are welcome.
-
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
-* Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
-* Neither the name of the copyright holders nor the names of
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#pragma once
-
-#define SERIAL_UART_DATA UDR1
-
-/* host role */
-void serial_init(void);
-uint8_t serial_recv(void);
-int16_t serial_recv2(void);
-void serial_send(uint8_t data);
diff --git a/tmk_core/protocol/serial_soft.c b/tmk_core/protocol/serial_soft.c
deleted file mode 100644
index 8624ef733c..0000000000
--- a/tmk_core/protocol/serial_soft.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
-Copyright 2012 Jun WAKO <wakojun@gmail.com>
-
-This software is licensed with a Modified BSD License.
-All of this is supposed to be Free Software, Open Source, DFSG-free,
-GPL-compatible, and OK to use in both free and proprietary applications.
-Additions and corrections to this file are welcome.
-
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
-* Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
-* Neither the name of the copyright holders nor the names of
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <stdbool.h>
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <util/delay.h>
-#include "serial.h"
-
-/*
- * Stupid Inefficient Busy-wait Software Serial
- * which is still useful for negative logic signal like Sun protocol
- * if it is not supported by hardware UART.
- *
- * TODO: delay is not accurate enough. Instruction cycle should be counted and inline assemby is needed.
- */
-
-#define WAIT_US (1000000L / SERIAL_SOFT_BAUD)
-
-#ifdef SERIAL_SOFT_LOGIC_NEGATIVE
-# define SERIAL_SOFT_RXD_IN() !(SERIAL_SOFT_RXD_READ())
-# define SERIAL_SOFT_TXD_ON() SERIAL_SOFT_TXD_LO()
-# define SERIAL_SOFT_TXD_OFF() SERIAL_SOFT_TXD_HI()
-#else
-# define SERIAL_SOFT_RXD_IN() !!(SERIAL_SOFT_RXD_READ())
-# define SERIAL_SOFT_TXD_ON() SERIAL_SOFT_TXD_HI()
-# define SERIAL_SOFT_TXD_OFF() SERIAL_SOFT_TXD_LO()
-#endif
-
-#ifdef SERIAL_SOFT_PARITY_EVEN
-# define SERIAL_SOFT_PARITY_VAL 0
-#elif defined(SERIAL_SOFT_PARITY_ODD)
-# define SERIAL_SOFT_PARITY_VAL 1
-#endif
-
-/* debug for signal timing, see debug pin with oscilloscope */
-#ifdef SERIAL_SOFT_DEBUG
-# define SERIAL_SOFT_DEBUG_INIT() (DDRD |= 1 << 7)
-# define SERIAL_SOFT_DEBUG_TGL() (PORTD ^= 1 << 7)
-#else
-# define SERIAL_SOFT_DEBUG_INIT()
-# define SERIAL_SOFT_DEBUG_TGL()
-#endif
-
-void serial_init(void) {
- SERIAL_SOFT_DEBUG_INIT();
-
- SERIAL_SOFT_RXD_INIT();
- SERIAL_SOFT_TXD_INIT();
-}
-
-/* RX ring buffer */
-#define RBUF_SIZE 8
-static uint8_t rbuf[RBUF_SIZE];
-static uint8_t rbuf_head = 0;
-static uint8_t rbuf_tail = 0;
-
-uint8_t serial_recv(void) {
- uint8_t data = 0;
- if (rbuf_head == rbuf_tail) {
- return 0;
- }
-
- data = rbuf[rbuf_tail];
- rbuf_tail = (rbuf_tail + 1) % RBUF_SIZE;
- return data;
-}
-
-int16_t serial_recv2(void) {
- uint8_t data = 0;
- if (rbuf_head == rbuf_tail) {
- return -1;
- }
-
- data = rbuf[rbuf_tail];
- rbuf_tail = (rbuf_tail + 1) % RBUF_SIZE;
- return data;
-}
-
-void serial_send(uint8_t data) {
- /* signal state: IDLE: ON, START: OFF, STOP: ON, DATA0: OFF, DATA1: ON */
-
-#ifdef SERIAL_SOFT_BIT_ORDER_MSB
-# ifdef SERIAL_SOFT_DATA_7BIT
- uint8_t mask = 0x40;
-# else
- uint8_t mask = 0x80;
-# endif
-#else
- uint8_t mask = 0x01;
-#endif
-
- uint8_t parity = 0;
-
- /* start bit */
- SERIAL_SOFT_TXD_OFF();
- _delay_us(WAIT_US);
-
-#ifdef SERIAL_SOFT_DATA_7BIT
- while (mask & 0x7F) {
-#else
- while (mask & 0xFF) {
-#endif
- if (data & mask) {
- SERIAL_SOFT_TXD_ON();
- parity ^= 1;
- } else {
- SERIAL_SOFT_TXD_OFF();
- }
- _delay_us(WAIT_US);
-
-#ifdef SERIAL_SOFT_BIT_ORDER_MSB
- mask >>= 1;
-#else
- mask <<= 1;
-#endif
- }
-
-#if defined(SERIAL_SOFT_PARITY_EVEN) || defined(SERIAL_SOFT_PARITY_ODD)
- /* to center of parity bit */
- if (parity != SERIAL_SOFT_PARITY_VAL) {
- SERIAL_SOFT_TXD_ON();
- } else {
- SERIAL_SOFT_TXD_OFF();
- }
- _delay_us(WAIT_US);
-#endif
-
- /* stop bit */
- SERIAL_SOFT_TXD_ON();
- _delay_us(WAIT_US);
-}
-
-/* detect edge of start bit */
-ISR(SERIAL_SOFT_RXD_VECT) {
- SERIAL_SOFT_DEBUG_TGL();
- SERIAL_SOFT_RXD_INT_ENTER();
-
- uint8_t data = 0;
-
-#ifdef SERIAL_SOFT_BIT_ORDER_MSB
-# ifdef SERIAL_SOFT_DATA_7BIT
- uint8_t mask = 0x40;
-# else
- uint8_t mask = 0x80;
-# endif
-#else
- uint8_t mask = 0x01;
-#endif
-
- uint8_t parity = 0;
-
- /* to center of start bit */
- _delay_us(WAIT_US / 2);
- SERIAL_SOFT_DEBUG_TGL();
- do {
- /* to center of next bit */
- _delay_us(WAIT_US);
-
- SERIAL_SOFT_DEBUG_TGL();
- if (SERIAL_SOFT_RXD_IN()) {
- data |= mask;
- parity ^= 1;
- }
-#ifdef SERIAL_SOFT_BIT_ORDER_MSB
- mask >>= 1;
-#else
- mask <<= 1;
-#endif
-#ifdef SERIAL_SOFT_DATA_7BIT
- } while (mask & 0x7F);
-#else
- } while (mask & 0xFF);
-#endif
-
-#if defined(SERIAL_SOFT_PARITY_EVEN) || defined(SERIAL_SOFT_PARITY_ODD)
- /* to center of parity bit */
- _delay_us(WAIT_US);
- if (SERIAL_SOFT_RXD_IN()) {
- parity ^= 1;
- }
- SERIAL_SOFT_DEBUG_TGL();
-#endif
-
- /* to center of stop bit */
- _delay_us(WAIT_US);
-
- uint8_t next = (rbuf_head + 1) % RBUF_SIZE;
-#if defined(SERIAL_SOFT_PARITY_EVEN) || defined(SERIAL_SOFT_PARITY_ODD)
- if ((parity == SERIAL_SOFT_PARITY_VAL) && next != rbuf_tail) {
-#else
- if (next != rbuf_tail) {
-#endif
- rbuf[rbuf_head] = data;
- rbuf_head = next;
- }
-
- SERIAL_SOFT_RXD_INT_EXIT();
- SERIAL_SOFT_DEBUG_TGL();
-}
diff --git a/tmk_core/protocol/serial_uart.c b/tmk_core/protocol/serial_uart.c
deleted file mode 100644
index d5b5657095..0000000000
--- a/tmk_core/protocol/serial_uart.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
-Copyright 2013 Jun WAKO <wakojun@gmail.com>
-
-This software is licensed with a Modified BSD License.
-All of this is supposed to be Free Software, Open Source, DFSG-free,
-GPL-compatible, and OK to use in both free and proprietary applications.
-Additions and corrections to this file are welcome.
-
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
-* Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
-* Neither the name of the copyright holders nor the names of
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <stdbool.h>
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include "serial.h"
-
-#ifndef SERIAL_UART_BAUD
-# define SERIAL_UART_BAUD 9600
-#endif
-
-#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
-#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
-#define SERIAL_UART_RXD_VECT USART1_RX_vect
-
-#ifndef SERIAL_UART_INIT_CUSTOM
-# define SERIAL_UART_INIT_CUSTOM \
- /* enable TX */ \
- UCSR1B = _BV(TXEN1); \
- /* 8-bit data */ \
- UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
-#endif
-
-#if defined(SERIAL_UART_RTS_LO) && defined(SERIAL_UART_RTS_HI)
-// Buffer state
-// Empty: RBUF_SPACE == RBUF_SIZE(head==tail)
-// Last 1 space: RBUF_SPACE == 2
-// Full: RBUF_SPACE == 1(last cell of rbuf be never used.)
-# define RBUF_SPACE() (rbuf_head < rbuf_tail ? (rbuf_tail - rbuf_head) : (RBUF_SIZE - rbuf_head + rbuf_tail))
-// allow to send
-# define rbuf_check_rts_lo() \
- do { \
- if (RBUF_SPACE() > 2) SERIAL_UART_RTS_LO(); \
- } while (0)
-// prohibit to send
-# define rbuf_check_rts_hi() \
- do { \
- if (RBUF_SPACE() <= 2) SERIAL_UART_RTS_HI(); \
- } while (0)
-#else
-# define rbuf_check_rts_lo()
-# define rbuf_check_rts_hi()
-#endif
-
-void serial_init(void) {
- do {
- // Set baud rate
- UBRR1L = SERIAL_UART_UBRR;
- UBRR1L = SERIAL_UART_UBRR >> 8;
- SERIAL_UART_INIT_CUSTOM;
- } while (0);
-}
-
-// RX ring buffer
-#define RBUF_SIZE 256
-static uint8_t rbuf[RBUF_SIZE];
-static uint8_t rbuf_head = 0;
-static uint8_t rbuf_tail = 0;
-
-uint8_t serial_recv(void) {
- uint8_t data = 0;
- if (rbuf_head == rbuf_tail) {
- return 0;
- }
-
- data = rbuf[rbuf_tail];
- rbuf_tail = (rbuf_tail + 1) % RBUF_SIZE;
- rbuf_check_rts_lo();
- return data;
-}
-
-int16_t serial_recv2(void) {
- uint8_t data = 0;
- if (rbuf_head == rbuf_tail) {
- return -1;
- }
-
- data = rbuf[rbuf_tail];
- rbuf_tail = (rbuf_tail + 1) % RBUF_SIZE;
- rbuf_check_rts_lo();
- return data;
-}
-
-void serial_send(uint8_t data) {
- while (!SERIAL_UART_TXD_READY)
- ;
- SERIAL_UART_DATA = data;
-}
-
-// USART RX complete interrupt
-ISR(SERIAL_UART_RXD_VECT) {
- uint8_t next = (rbuf_head + 1) % RBUF_SIZE;
- if (next != rbuf_tail) {
- rbuf[rbuf_head] = SERIAL_UART_DATA;
- rbuf_head = next;
- }
- rbuf_check_rts_hi();
-}
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index 8e60b2d249..4905096354 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -48,6 +48,9 @@
# include "joystick.h"
#endif
+// TODO: wb32 support defines ISO macro which breaks PRODUCT stringification
+#undef ISO
+
// clang-format off
/*
@@ -129,14 +132,27 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
- // X/Y position (2 bytes)
+# ifdef MOUSE_EXTENDED_REPORT
+ // Boot protocol XY ignored in Report protocol
+ HID_RI_REPORT_COUNT(8, 0x02),
+ HID_RI_REPORT_SIZE(8, 0x08),
+ HID_RI_INPUT(8, HID_IOF_CONSTANT),
+# endif
+ // X/Y position (2 or 4 bytes)
HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
HID_RI_USAGE(8, 0x30), // X
HID_RI_USAGE(8, 0x31), // Y
+# ifndef MOUSE_EXTENDED_REPORT
HID_RI_LOGICAL_MINIMUM(8, -127),
HID_RI_LOGICAL_MAXIMUM(8, 127),
HID_RI_REPORT_COUNT(8, 0x02),
HID_RI_REPORT_SIZE(8, 0x08),
+# else
+ HID_RI_LOGICAL_MINIMUM(16, -32767),
+ HID_RI_LOGICAL_MAXIMUM(16, 32767),
+ HID_RI_REPORT_COUNT(8, 0x02),
+ HID_RI_REPORT_SIZE(8, 0x10),
+# endif
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
// Vertical wheel (1 byte)
diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h
index df77f50c91..fd25376f90 100644
--- a/tmk_core/protocol/usb_descriptor.h
+++ b/tmk_core/protocol/usb_descriptor.h
@@ -47,6 +47,9 @@
#ifdef PROTOCOL_CHIBIOS
# include <hal.h>
+# if STM32_USB_USE_OTG1 == TRUE
+# define USB_ENDPOINTS_ARE_REORDERABLE
+# endif
#endif
#ifdef WEBUSB_ENABLE
# include "webusb_descriptor.h"
@@ -229,7 +232,7 @@ enum usb_endpoints {
#ifdef RAW_ENABLE
RAW_IN_EPNUM = NEXT_EPNUM,
-# if STM32_USB_USE_OTG1
+# ifdef USB_ENDPOINTS_ARE_REORDERABLE
# define RAW_OUT_EPNUM RAW_IN_EPNUM
# else
RAW_OUT_EPNUM = NEXT_EPNUM,
@@ -247,7 +250,7 @@ enum usb_endpoints {
// ChibiOS has enough memory and descriptor to actually enable the endpoint
// It could use the same endpoint numbers, as that's supported by ChibiOS
// But the QMK code currently assumes that the endpoint numbers are different
-# if STM32_USB_USE_OTG1
+# ifdef USB_ENDPOINTS_ARE_REORDERABLE
# define CONSOLE_OUT_EPNUM CONSOLE_IN_EPNUM
# else
CONSOLE_OUT_EPNUM = NEXT_EPNUM,
@@ -259,7 +262,7 @@ enum usb_endpoints {
#ifdef MIDI_ENABLE
MIDI_STREAM_IN_EPNUM = NEXT_EPNUM,
-# if STM32_USB_USE_OTG1
+# ifdef USB_ENDPOINTS_ARE_REORDERABLE
# define MIDI_STREAM_OUT_EPNUM MIDI_STREAM_IN_EPNUM
# else
MIDI_STREAM_OUT_EPNUM = NEXT_EPNUM,
@@ -269,7 +272,7 @@ enum usb_endpoints {
#ifdef VIRTSER_ENABLE
CDC_NOTIFICATION_EPNUM = NEXT_EPNUM,
CDC_IN_EPNUM = NEXT_EPNUM,
-# if STM32_USB_USE_OTG1
+# ifdef USB_ENDPOINTS_ARE_REORDERABLE
# define CDC_OUT_EPNUM CDC_IN_EPNUM
# else
CDC_OUT_EPNUM = NEXT_EPNUM,
@@ -285,7 +288,7 @@ enum usb_endpoints {
#ifdef JOYSTICK_ENABLE
JOYSTICK_IN_EPNUM = NEXT_EPNUM,
-# if STM32_USB_USE_OTG1
+# ifdef USB_ENDPOINTS_ARE_REORDERABLE
JOYSTICK_OUT_EPNUM = JOYSTICK_IN_EPNUM,
# else
JOYSTICK_OUT_EPNUM = NEXT_EPNUM,
@@ -295,7 +298,7 @@ enum usb_endpoints {
#ifdef DIGITIZER_ENABLE
# if !defined(DIGITIZER_SHARED_EP)
DIGITIZER_IN_EPNUM = NEXT_EPNUM,
-# if STM32_USB_USE_OTG1
+# ifdef USB_ENDPOINTS_ARE_REORDERABLE
DIGITIZER_OUT_EPNUM = DIGITIZER_IN_EPNUM,
# else
DIGITIZER_OUT_EPNUM = NEXT_EPNUM,
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index ebde955d3b..d07cc0d27e 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -482,14 +482,28 @@ const PROGMEM uchar shared_hid_report[] = {
0x75, 0x01, // Report Size (1)
0x81, 0x02, // Input (Data, Variable, Absolute)
- // X/Y position (2 bytes)
+# ifdef MOUSE_EXTENDED_REPORT
+ // Boot protocol XY ignored in Report protocol
+ 0x95, 0x02, // Report Count (2)
+ 0x75, 0x08, // Report Size (8)
+ 0x81, 0x03, // Input (Constant)
+# endif
+
+ // X/Y position (2 or 4 bytes)
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
+# ifndef MOUSE_EXTENDED_REPORT
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7F, // Logical Maximum (127)
0x95, 0x02, // Report Count (2)
0x75, 0x08, // Report Size (8)
+# else
+ 0x16, 0x01, 0x80, // Logical Minimum (-32767)
+ 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
+ 0x95, 0x02, // Report Count (2)
+ 0x75, 0x10, // Report Size (16)
+# endif
0x81, 0x06, // Input (Data, Variable, Relative)
// Vertical wheel (1 byte)
diff --git a/util/chibios_conf_updater.sh b/util/chibios_conf_updater.sh
index a5699ca3cb..3c400ab63c 100755
--- a/util/chibios_conf_updater.sh
+++ b/util/chibios_conf_updater.sh
@@ -12,11 +12,14 @@ umask 022
# wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
# sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
# sudo apt-get update && sudo apt-get install adoptopenjdk-8-hotspot
-
+#
+# For Fedora 36-ish distros:
+# # Prep yum repository from https://adoptium.net/installation/linux/
+# sudo dnf install -y ant temurin-8-jdk
+# export JAVA_HOME=/usr/lib/jvm/temurin-8-jdk
sinfo() { echo "$@" >&2 ; }
shead() { sinfo "" ; sinfo "---------------------------------" ; sinfo "-- $@" ; sinfo "---------------------------------" ; }
-havecmd() { command command type "${1}" >/dev/null 2>&1 || return 1 ; }
this_script="$(realpath "${BASH_SOURCE[0]}")"
script_dir="$(realpath "$(dirname "$this_script")")"
@@ -31,7 +34,7 @@ build_fmpp() {
|| { mkdir "$script_dir/fmpp" && tar xf "$script_dir/fmpp.tar.gz" -C "$script_dir/fmpp" --strip-components=1 ; }
pushd "$script_dir/fmpp" >/dev/null 2>&1
sed -e "s#bootclasspath.path=.*#bootclasspath.path=$(find /usr/lib/jvm -name 'rt.jar' | sort | tail -n1)#g" \
- -e "s#ant.jar.path=.*#ant.jar.path=$(find /usr/share/java -name 'ant-1*.jar' | sort | tail -n1)#g" \
+ -e "s#ant.jar.path=.*#ant.jar.path=$(find /usr/share/java -name 'ant-1*.jar' -or -name 'ant.jar' | sort | tail -n1)#g" \
build.properties.sample > build.properties
sed -e 's#source="1.5"#source="1.8"#g' \
-e 's#target="1.5"#target="1.8"#g' \
@@ -98,7 +101,8 @@ upgrade_mcuconf_files() {
popd >/dev/null 2>&1
}
-havecmd fmpp || build_fmpp
+hash -r
+[[ -n "$(which fmpp 2>/dev/null)" ]] || build_fmpp
upgrade_mcuconf_files
upgrade_chconf_files
diff --git a/util/docker_build.sh b/util/docker_build.sh
index 368b0f13fc..7e10a4f76b 100755
--- a/util/docker_build.sh
+++ b/util/docker_build.sh
@@ -19,7 +19,7 @@ if [ $# -gt 1 ]; then
exit 1
fi
-# Allow $RUNTIME to be overriden by the user as an environment variable
+# Allow $RUNTIME to be overridden by the user as an environment variable
# Else check if either docker or podman exit and set them as runtime
# if none are found error out
if [ -z "$RUNTIME" ]; then
diff --git a/util/docker_cmd.sh b/util/docker_cmd.sh
index 2ea113d24a..f3c4c7804f 100755
--- a/util/docker_cmd.sh
+++ b/util/docker_cmd.sh
@@ -15,7 +15,7 @@ for arg; do
fi
done
-# Allow $RUNTIME to be overriden by the user as an environment variable
+# Allow $RUNTIME to be overridden by the user as an environment variable
# Else check if either docker or podman exit and set them as runtime
# if none are found error out
if [ -z "$RUNTIME" ]; then
diff --git a/util/install/fedora.sh b/util/install/fedora.sh
index b140438b42..6380f6d33f 100755
--- a/util/install/fedora.sh
+++ b/util/install/fedora.sh
@@ -6,9 +6,9 @@ _qmk_install() {
# TODO: Check whether devel/headers packages are really needed
sudo dnf $SKIP_PROMPT install \
clang diffutils git gcc glibc-headers kernel-devel kernel-headers \
- make unzip wget zip python3 avr-binutils avr-gcc avr-libc \
- arm-none-eabi-binutils-cs arm-none-eabi-gcc-cs arm-none-eabi-newlib \
- avrdude dfu-programmer dfu-util hidapi libusb1-devel
+ make unzip wget zip python3 avr-binutils avr-gcc avr-gcc-c++ avr-libc \
+ arm-none-eabi-binutils-cs arm-none-eabi-gcc-cs arm-none-eabi-gcc-cs-c++ \
+ arm-none-eabi-newlib avrdude dfu-programmer dfu-util hidapi libusb-devel
python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt
}
diff --git a/util/install/msys2.sh b/util/install/msys2.sh
index c57c455eb4..fa422023ab 100755
--- a/util/install/msys2.sh
+++ b/util/install/msys2.sh
@@ -7,17 +7,14 @@ _qmk_install_prepare() {
_qmk_install() {
echo "Installing dependencies"
- pacman --needed --noconfirm --disable-download-timeout -S pactoys-git
+ pacman --needed --noconfirm --disable-download-timeout -S pactoys
pacboy sync --needed --noconfirm --disable-download-timeout \
- base-devel: toolchain:x clang:x git: unzip: python3-pip:x \
- avr-binutils:x avr-gcc:x avr-libc:x arm-none-eabi-binutils:x \
- arm-none-eabi-gcc:x arm-none-eabi-newlib:x avrdude:x bootloadhid:x \
- dfu-programmer:x dfu-util:x teensy-loader-cli:x hidapi:x \
- python-appdirs:x python-colorama:x python-jsonschema:x python-pillow:x python-pygments:x
+ base-devel: toolchain:x clang:x python-qmk:x hidapi:x \
+ avr-binutils:x avr-gcc:x avr-libc:x \
+ arm-none-eabi-binutils:x arm-none-eabi-gcc:x arm-none-eabi-newlib:x \
+ avrdude:x bootloadhid:x dfu-programmer:x dfu-util:x hid-bootloader-cli:x mdloader:x teensy-loader-cli:x wb32-dfu-updater:x
_qmk_install_drivers
-
- python3 -m pip install -r "$QMK_FIRMWARE_DIR/requirements.txt"
}
_qmk_install_drivers() {
diff --git a/util/nix/poetry.lock b/util/nix/poetry.lock
index 9bb0f64deb..dc1b38be84 100644
--- a/util/nix/poetry.lock
+++ b/util/nix/poetry.lock
@@ -8,71 +8,81 @@ python-versions = "*"
[[package]]
name = "argcomplete"
-version = "1.12.3"
+version = "2.0.0"
description = "Bash tab completion for argparse"
category = "main"
optional = false
-python-versions = "*"
+python-versions = ">=3.6"
[package.extras]
-test = ["coverage", "flake8", "pexpect", "wheel"]
+test = ["wheel", "pexpect", "flake8", "coverage"]
+
+[[package]]
+name = "atomicwrites"
+version = "1.4.1"
+description = "Atomic file writes."
+category = "dev"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
name = "attrs"
-version = "21.2.0"
+version = "22.1.0"
description = "Classes Without Boilerplate"
category = "main"
optional = false
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
+python-versions = ">=3.5"
[package.extras]
-dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit"]
-docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"]
-tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface"]
-tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins"]
+tests_no_zope = ["cloudpickle", "pytest-mypy-plugins", "mypy (>=0.900,!=0.940)", "pytest (>=4.3.0)", "pympler", "hypothesis", "coverage[toml] (>=5.0.2)"]
+tests = ["cloudpickle", "zope.interface", "pytest-mypy-plugins", "mypy (>=0.900,!=0.940)", "pytest (>=4.3.0)", "pympler", "hypothesis", "coverage[toml] (>=5.0.2)"]
+docs = ["sphinx-notfound-page", "zope.interface", "sphinx", "furo"]
+dev = ["cloudpickle", "pre-commit", "sphinx-notfound-page", "sphinx", "furo", "zope.interface", "pytest-mypy-plugins", "mypy (>=0.900,!=0.940)", "pytest (>=4.3.0)", "pympler", "hypothesis", "coverage[toml] (>=5.0.2)"]
[[package]]
name = "colorama"
-version = "0.4.4"
+version = "0.4.5"
description = "Cross-platform colored terminal text."
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
-name = "coverage"
-version = "5.5"
-description = "Code coverage measurement for Python"
-category = "dev"
+name = "dotty-dict"
+version = "1.3.1"
+description = "Dictionary wrapper for quick access to deeply nested keys."
+category = "main"
optional = false
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
+python-versions = ">=3.5,<4.0"
-[package.extras]
-toml = ["toml"]
+[[package]]
+name = "editables"
+version = "0.3"
+description = "Editable installations"
+category = "dev"
+optional = false
+python-versions = ">=3.7"
[[package]]
name = "flake8"
-version = "3.9.2"
+version = "5.0.4"
description = "the modular source code checker: pep8 pyflakes and co"
category = "dev"
optional = false
-python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
+python-versions = ">=3.6.1"
[package.dependencies]
-mccabe = ">=0.6.0,<0.7.0"
-pycodestyle = ">=2.7.0,<2.8.0"
-pyflakes = ">=2.3.0,<2.4.0"
+mccabe = ">=0.7.0,<0.8.0"
+pycodestyle = ">=2.9.0,<2.10.0"
+pyflakes = ">=2.5.0,<2.6.0"
[[package]]
-name = "flake8-polyfill"
-version = "1.0.2"
-description = "Polyfill package for Flake8 plugins"
+name = "flit-core"
+version = "3.7.1"
+description = "Distribution-building parts of Flit. See flit package for more information"
category = "dev"
optional = false
-python-versions = "*"
-
-[package.dependencies]
-flake8 = "*"
+python-versions = ">=3.6"
[[package]]
name = "halo"
@@ -90,11 +100,54 @@ spinners = ">=0.0.24"
termcolor = ">=1.1.0"
[package.extras]
-ipython = ["IPython (==5.7.0)", "ipywidgets (==7.1.0)"]
+ipython = ["ipywidgets (==7.1.0)", "IPython (==5.7.0)"]
+
+[[package]]
+name = "hatch-fancy-pypi-readme"
+version = "22.3.0"
+description = "Fancy PyPI READMEs with Hatch"
+category = "dev"
+optional = false
+python-versions = ">=3.7"
+
+[package.dependencies]
+hatchling = "*"
+tomli = {version = "*", markers = "python_version < \"3.11\""}
+
+[package.extras]
+tests = ["wheel", "pytest-icdiff", "pytest", "coverage", "build"]
+dev = ["mypy", "hatch-fancy-pypi-readme"]
+
+[[package]]
+name = "hatch-vcs"
+version = "0.2.0"
+description = "Hatch plugin for versioning with your preferred VCS"
+category = "dev"
+optional = false
+python-versions = "*"
+
+[package.dependencies]
+hatchling = ">=0.21.0"
+setuptools-scm = {version = ">=6.4.0", markers = "python_version > \"3\""}
+
+[[package]]
+name = "hatchling"
+version = "1.8.0"
+description = "Modern, extensible Python build backend"
+category = "dev"
+optional = false
+python-versions = ">=3.7"
+
+[package.dependencies]
+editables = ">=0.3"
+packaging = ">=21.3"
+pathspec = ">=0.9"
+pluggy = ">=1.0.0"
+tomli = {version = ">=1.2.2", markers = "python_version < \"3.11\""}
[[package]]
name = "hid"
-version = "1.0.4"
+version = "1.0.5"
description = "ctypes bindings for hidapi"
category = "main"
optional = false
@@ -102,28 +155,52 @@ python-versions = "*"
[[package]]
name = "hjson"
-version = "3.0.2"
+version = "3.1.0"
description = "Hjson, a user interface for JSON."
category = "main"
optional = false
python-versions = "*"
[[package]]
+name = "importlib-resources"
+version = "5.9.0"
+description = "Read resources from Python packages"
+category = "main"
+optional = false
+python-versions = ">=3.7"
+
+[package.dependencies]
+zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""}
+
+[package.extras]
+testing = ["pytest-mypy (>=0.9.1)", "pytest-black (>=0.3.7)", "pytest-enabler (>=1.3)", "pytest-cov", "pytest-flake8", "pytest-checkdocs (>=2.4)", "pytest (>=6)"]
+docs = ["jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "jaraco.packaging (>=9)", "sphinx"]
+
+[[package]]
+name = "iniconfig"
+version = "1.1.1"
+description = "iniconfig: brain-dead simple config-ini parsing"
+category = "dev"
+optional = false
+python-versions = "*"
+
+[[package]]
name = "jsonschema"
-version = "3.2.0"
+version = "4.14.0"
description = "An implementation of JSON Schema validation for Python"
category = "main"
optional = false
-python-versions = "*"
+python-versions = ">=3.7"
[package.dependencies]
attrs = ">=17.4.0"
-pyrsistent = ">=0.14.0"
-six = ">=1.11.0"
+importlib-resources = {version = ">=1.4.0", markers = "python_version < \"3.9\""}
+pkgutil-resolve-name = {version = ">=1.3.10", markers = "python_version < \"3.9\""}
+pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2"
[package.extras]
-format = ["idna", "jsonpointer (>1.13)", "rfc3987", "strict-rfc3339", "webcolors"]
-format_nongpl = ["idna", "jsonpointer (>1.13)", "webcolors", "rfc3986-validator (>0.1.0)", "rfc3339-validator"]
+format-nongpl = ["webcolors (>=1.11)", "uri-template", "rfc3986-validator (>0.1.0)", "rfc3339-validator", "jsonpointer (>1.13)", "isoduration", "idna", "fqdn"]
+format = ["webcolors (>=1.11)", "uri-template", "rfc3987", "rfc3339-validator", "jsonpointer (>1.13)", "isoduration", "idna", "fqdn"]
[[package]]
name = "log-symbols"
@@ -138,15 +215,15 @@ colorama = ">=0.3.9"
[[package]]
name = "mccabe"
-version = "0.6.1"
+version = "0.7.0"
description = "McCabe checker, plugin for flake8"
category = "dev"
optional = false
-python-versions = "*"
+python-versions = ">=3.6"
[[package]]
name = "milc"
-version = "1.6.2"
+version = "1.6.6"
description = "Opinionated Batteries-Included Python 3 CLI Framework."
category = "main"
optional = false
@@ -161,63 +238,171 @@ spinners = "*"
[[package]]
name = "nose2"
-version = "0.10.0"
-description = "unittest2 with plugins, the succesor to nose"
+version = "0.12.0"
+description = "unittest2 with plugins, the successor to nose"
category = "dev"
optional = false
python-versions = "*"
+[package.extras]
+dev = ["sphinx-issues", "mock", "sphinx-rtd-theme", "sphinx"]
+coverage_plugin = ["coverage"]
+
+[[package]]
+name = "packaging"
+version = "21.3"
+description = "Core utilities for Python packages"
+category = "dev"
+optional = false
+python-versions = ">=3.6"
+
[package.dependencies]
-coverage = ">=4.4.1"
-six = ">=1.7"
+pyparsing = ">=2.0.2,<3.0.5 || >3.0.5"
-[package.extras]
-coverage_plugin = ["coverage (>=4.4.1)"]
-dev = ["Sphinx (>=1.6.5)", "sphinx-rtd-theme", "mock", "coverage"]
+[[package]]
+name = "pathspec"
+version = "0.9.0"
+description = "Utility library for gitignore style pattern matching of file paths."
+category = "dev"
+optional = false
+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
[[package]]
name = "pep8-naming"
-version = "0.12.1"
+version = "0.13.2"
description = "Check PEP-8 naming conventions, plugin for flake8"
category = "dev"
optional = false
-python-versions = "*"
+python-versions = ">=3.7"
[package.dependencies]
flake8 = ">=3.9.1"
-flake8-polyfill = ">=1.0.2,<2"
+
+[[package]]
+name = "pillow"
+version = "9.2.0"
+description = "Python Imaging Library (Fork)"
+category = "main"
+optional = false
+python-versions = ">=3.7"
+
+[package.extras]
+tests = ["pytest-timeout", "pytest-cov", "pytest", "pyroma", "packaging", "olefile", "markdown2", "defusedxml", "coverage", "check-manifest"]
+docs = ["sphinxext-opengraph", "sphinx-removed-in", "sphinx-issues (>=3.0.1)", "sphinx-copybutton", "sphinx (>=2.4)", "olefile", "furo"]
+
+[[package]]
+name = "pkgutil-resolve-name"
+version = "1.3.10"
+description = "Resolve a name to an object."
+category = "main"
+optional = false
+python-versions = ">=3.6"
+
+[[package]]
+name = "pluggy"
+version = "1.0.0"
+description = "plugin and hook calling mechanisms for python"
+category = "dev"
+optional = false
+python-versions = ">=3.6"
+
+[package.extras]
+testing = ["pytest-benchmark", "pytest"]
+dev = ["tox", "pre-commit"]
+
+[[package]]
+name = "poetry-core"
+version = "1.0.8"
+description = "Poetry PEP 517 Build Backend"
+category = "dev"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
+
+[[package]]
+name = "py"
+version = "1.11.0"
+description = "library with cross-python path, ini-parsing, io, code, log facilities"
+category = "dev"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
name = "pycodestyle"
-version = "2.7.0"
+version = "2.9.1"
description = "Python style guide checker"
category = "dev"
optional = false
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
+python-versions = ">=3.6"
[[package]]
name = "pyflakes"
-version = "2.3.1"
+version = "2.5.0"
description = "passive checker of Python programs"
category = "dev"
optional = false
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
+python-versions = ">=3.6"
[[package]]
name = "pygments"
-version = "2.10.0"
+version = "2.13.0"
description = "Pygments is a syntax highlighting package written in Python."
category = "main"
optional = false
-python-versions = ">=3.5"
+python-versions = ">=3.6"
+
+[package.extras]
+plugins = ["importlib-metadata"]
+
+[[package]]
+name = "pyparsing"
+version = "3.0.9"
+description = "pyparsing module - Classes and methods to define and execute parsing grammars"
+category = "dev"
+optional = false
+python-versions = ">=3.6.8"
+
+[package.extras]
+diagrams = ["jinja2", "railroad-diagrams"]
[[package]]
name = "pyrsistent"
-version = "0.18.0"
+version = "0.18.1"
description = "Persistent/Functional/Immutable data structures"
category = "main"
optional = false
-python-versions = ">=3.6"
+python-versions = ">=3.7"
+
+[[package]]
+name = "pyserial"
+version = "3.5"
+description = "Python Serial Port Extension"
+category = "main"
+optional = false
+python-versions = "*"
+
+[package.extras]
+cp2110 = ["hidapi"]
+
+[[package]]
+name = "pytest"
+version = "7.1.2"
+description = "pytest: simple powerful testing with Python"
+category = "dev"
+optional = false
+python-versions = ">=3.7"
+
+[package.dependencies]
+atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""}
+attrs = ">=19.2.0"
+colorama = {version = "*", markers = "sys_platform == \"win32\""}
+iniconfig = "*"
+packaging = "*"
+pluggy = ">=0.12,<2.0"
+py = ">=1.8.2"
+tomli = ">=1.0.0"
+
+[package.extras]
+testing = ["xmlschema", "requests", "pygments (>=2.7.2)", "nose", "mock", "hypothesis (>=3.56)", "argcomplete"]
[[package]]
name = "pyusb"
@@ -229,28 +414,39 @@ python-versions = ">=3.6.0"
[[package]]
name = "qmk"
-version = "1.0.0"
+version = "1.1.1"
description = "A program to help users work with QMK Firmware."
category = "main"
optional = false
-python-versions = "*"
+python-versions = ">=3.7"
[package.dependencies]
+dotty-dict = "*"
hid = "*"
hjson = "*"
-jsonschema = ">=3"
+jsonschema = ">=4"
milc = ">=1.4.2"
+pillow = "*"
pygments = "*"
+pyserial = "*"
pyusb = "*"
-qmk-dotty-dict = "*"
[[package]]
-name = "qmk-dotty-dict"
-version = "1.3.0.post1"
-description = "Dictionary wrapper for quick access to deeply nested keys."
-category = "main"
+name = "setuptools-scm"
+version = "7.0.5"
+description = "the blessed package to manage your versions by scm tags"
+category = "dev"
optional = false
-python-versions = "*"
+python-versions = ">=3.7"
+
+[package.dependencies]
+packaging = ">=20.0"
+tomli = ">=1.0.0"
+typing-extensions = "*"
+
+[package.extras]
+toml = ["setuptools (>=42)"]
+test = ["virtualenv (>20)", "pytest (>=6.2)"]
[[package]]
name = "six"
@@ -277,17 +473,45 @@ optional = false
python-versions = "*"
[[package]]
+name = "tomli"
+version = "2.0.1"
+description = "A lil' TOML parser"
+category = "dev"
+optional = false
+python-versions = ">=3.7"
+
+[[package]]
+name = "typing-extensions"
+version = "4.3.0"
+description = "Backported and Experimental Type Hints for Python 3.7+"
+category = "dev"
+optional = false
+python-versions = ">=3.7"
+
+[[package]]
name = "yapf"
-version = "0.31.0"
+version = "0.32.0"
description = "A formatter for Python code."
category = "dev"
optional = false
python-versions = "*"
+[[package]]
+name = "zipp"
+version = "3.8.1"
+description = "Backport of pathlib-compatible object wrapper for zip files"
+category = "main"
+optional = false
+python-versions = ">=3.7"
+
+[package.extras]
+testing = ["pytest-mypy (>=0.9.1)", "pytest-black (>=0.3.7)", "func-timeout", "jaraco.itertools", "pytest-enabler (>=1.3)", "pytest-cov", "pytest-flake8", "pytest-checkdocs (>=2.4)", "pytest (>=6)"]
+docs = ["jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "jaraco.packaging (>=9)", "sphinx"]
+
[metadata]
lock-version = "1.1"
python-versions = "^3.8"
-content-hash = "468ae51aaddfe2ce62938f131c688bbc447e41608d4dd7d30db36391c38bda20"
+content-hash = "71855d16c0f315ff383322272ddfca2b4917dbba9fa5ca1863b3bd537e35fee1"
[metadata.files]
appdirs = [
@@ -295,161 +519,234 @@ appdirs = [
{file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"},
]
argcomplete = [
- {file = "argcomplete-1.12.3-py2.py3-none-any.whl", hash = "sha256:291f0beca7fd49ce285d2f10e4c1c77e9460cf823eef2de54df0c0fec88b0d81"},
- {file = "argcomplete-1.12.3.tar.gz", hash = "sha256:2c7dbffd8c045ea534921e63b0be6fe65e88599990d8dc408ac8c542b72a5445"},
+ {file = "argcomplete-2.0.0-py2.py3-none-any.whl", hash = "sha256:cffa11ea77999bb0dd27bb25ff6dc142a6796142f68d45b1a26b11f58724561e"},
+ {file = "argcomplete-2.0.0.tar.gz", hash = "sha256:6372ad78c89d662035101418ae253668445b391755cfe94ea52f1b9d22425b20"},
+]
+atomicwrites = [
+ {file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"},
]
attrs = [
- {file = "attrs-21.2.0-py2.py3-none-any.whl", hash = "sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1"},
- {file = "attrs-21.2.0.tar.gz", hash = "sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb"},
+ {file = "attrs-22.1.0-py2.py3-none-any.whl", hash = "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c"},
+ {file = "attrs-22.1.0.tar.gz", hash = "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6"},
]
colorama = [
- {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"},
- {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"},
-]
-coverage = [
- {file = "coverage-5.5-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:b6d534e4b2ab35c9f93f46229363e17f63c53ad01330df9f2d6bd1187e5eaacf"},
- {file = "coverage-5.5-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:b7895207b4c843c76a25ab8c1e866261bcfe27bfaa20c192de5190121770672b"},
- {file = "coverage-5.5-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:c2723d347ab06e7ddad1a58b2a821218239249a9e4365eaff6649d31180c1669"},
- {file = "coverage-5.5-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:900fbf7759501bc7807fd6638c947d7a831fc9fdf742dc10f02956ff7220fa90"},
- {file = "coverage-5.5-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:004d1880bed2d97151facef49f08e255a20ceb6f9432df75f4eef018fdd5a78c"},
- {file = "coverage-5.5-cp27-cp27m-win32.whl", hash = "sha256:06191eb60f8d8a5bc046f3799f8a07a2d7aefb9504b0209aff0b47298333302a"},
- {file = "coverage-5.5-cp27-cp27m-win_amd64.whl", hash = "sha256:7501140f755b725495941b43347ba8a2777407fc7f250d4f5a7d2a1050ba8e82"},
- {file = "coverage-5.5-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:372da284cfd642d8e08ef606917846fa2ee350f64994bebfbd3afb0040436905"},
- {file = "coverage-5.5-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:8963a499849a1fc54b35b1c9f162f4108017b2e6db2c46c1bed93a72262ed083"},
- {file = "coverage-5.5-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:869a64f53488f40fa5b5b9dcb9e9b2962a66a87dab37790f3fcfb5144b996ef5"},
- {file = "coverage-5.5-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:4a7697d8cb0f27399b0e393c0b90f0f1e40c82023ea4d45d22bce7032a5d7b81"},
- {file = "coverage-5.5-cp310-cp310-macosx_10_14_x86_64.whl", hash = "sha256:8d0a0725ad7c1a0bcd8d1b437e191107d457e2ec1084b9f190630a4fb1af78e6"},
- {file = "coverage-5.5-cp310-cp310-manylinux1_x86_64.whl", hash = "sha256:51cb9476a3987c8967ebab3f0fe144819781fca264f57f89760037a2ea191cb0"},
- {file = "coverage-5.5-cp310-cp310-win_amd64.whl", hash = "sha256:c0891a6a97b09c1f3e073a890514d5012eb256845c451bd48f7968ef939bf4ae"},
- {file = "coverage-5.5-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:3487286bc29a5aa4b93a072e9592f22254291ce96a9fbc5251f566b6b7343cdb"},
- {file = "coverage-5.5-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:deee1077aae10d8fa88cb02c845cfba9b62c55e1183f52f6ae6a2df6a2187160"},
- {file = "coverage-5.5-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:f11642dddbb0253cc8853254301b51390ba0081750a8ac03f20ea8103f0c56b6"},
- {file = "coverage-5.5-cp35-cp35m-manylinux2010_i686.whl", hash = "sha256:6c90e11318f0d3c436a42409f2749ee1a115cd8b067d7f14c148f1ce5574d701"},
- {file = "coverage-5.5-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:30c77c1dc9f253283e34c27935fded5015f7d1abe83bc7821680ac444eaf7793"},
- {file = "coverage-5.5-cp35-cp35m-win32.whl", hash = "sha256:9a1ef3b66e38ef8618ce5fdc7bea3d9f45f3624e2a66295eea5e57966c85909e"},
- {file = "coverage-5.5-cp35-cp35m-win_amd64.whl", hash = "sha256:972c85d205b51e30e59525694670de6a8a89691186012535f9d7dbaa230e42c3"},
- {file = "coverage-5.5-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:af0e781009aaf59e25c5a678122391cb0f345ac0ec272c7961dc5455e1c40066"},
- {file = "coverage-5.5-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:74d881fc777ebb11c63736622b60cb9e4aee5cace591ce274fb69e582a12a61a"},
- {file = "coverage-5.5-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:92b017ce34b68a7d67bd6d117e6d443a9bf63a2ecf8567bb3d8c6c7bc5014465"},
- {file = "coverage-5.5-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:d636598c8305e1f90b439dbf4f66437de4a5e3c31fdf47ad29542478c8508bbb"},
- {file = "coverage-5.5-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:41179b8a845742d1eb60449bdb2992196e211341818565abded11cfa90efb821"},
- {file = "coverage-5.5-cp36-cp36m-win32.whl", hash = "sha256:040af6c32813fa3eae5305d53f18875bedd079960822ef8ec067a66dd8afcd45"},
- {file = "coverage-5.5-cp36-cp36m-win_amd64.whl", hash = "sha256:5fec2d43a2cc6965edc0bb9e83e1e4b557f76f843a77a2496cbe719583ce8184"},
- {file = "coverage-5.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:18ba8bbede96a2c3dde7b868de9dcbd55670690af0988713f0603f037848418a"},
- {file = "coverage-5.5-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:2910f4d36a6a9b4214bb7038d537f015346f413a975d57ca6b43bf23d6563b53"},
- {file = "coverage-5.5-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:f0b278ce10936db1a37e6954e15a3730bea96a0997c26d7fee88e6c396c2086d"},
- {file = "coverage-5.5-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:796c9c3c79747146ebd278dbe1e5c5c05dd6b10cc3bcb8389dfdf844f3ead638"},
- {file = "coverage-5.5-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:53194af30d5bad77fcba80e23a1441c71abfb3e01192034f8246e0d8f99528f3"},
- {file = "coverage-5.5-cp37-cp37m-win32.whl", hash = "sha256:184a47bbe0aa6400ed2d41d8e9ed868b8205046518c52464fde713ea06e3a74a"},
- {file = "coverage-5.5-cp37-cp37m-win_amd64.whl", hash = "sha256:2949cad1c5208b8298d5686d5a85b66aae46d73eec2c3e08c817dd3513e5848a"},
- {file = "coverage-5.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:217658ec7187497e3f3ebd901afdca1af062b42cfe3e0dafea4cced3983739f6"},
- {file = "coverage-5.5-cp38-cp38-manylinux1_i686.whl", hash = "sha256:1aa846f56c3d49205c952d8318e76ccc2ae23303351d9270ab220004c580cfe2"},
- {file = "coverage-5.5-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:24d4a7de75446be83244eabbff746d66b9240ae020ced65d060815fac3423759"},
- {file = "coverage-5.5-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:d1f8bf7b90ba55699b3a5e44930e93ff0189aa27186e96071fac7dd0d06a1873"},
- {file = "coverage-5.5-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:970284a88b99673ccb2e4e334cfb38a10aab7cd44f7457564d11898a74b62d0a"},
- {file = "coverage-5.5-cp38-cp38-win32.whl", hash = "sha256:01d84219b5cdbfc8122223b39a954820929497a1cb1422824bb86b07b74594b6"},
- {file = "coverage-5.5-cp38-cp38-win_amd64.whl", hash = "sha256:2e0d881ad471768bf6e6c2bf905d183543f10098e3b3640fc029509530091502"},
- {file = "coverage-5.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:d1f9ce122f83b2305592c11d64f181b87153fc2c2bbd3bb4a3dde8303cfb1a6b"},
- {file = "coverage-5.5-cp39-cp39-manylinux1_i686.whl", hash = "sha256:13c4ee887eca0f4c5a247b75398d4114c37882658300e153113dafb1d76de529"},
- {file = "coverage-5.5-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:52596d3d0e8bdf3af43db3e9ba8dcdaac724ba7b5ca3f6358529d56f7a166f8b"},
- {file = "coverage-5.5-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:2cafbbb3af0733db200c9b5f798d18953b1a304d3f86a938367de1567f4b5bff"},
- {file = "coverage-5.5-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:44d654437b8ddd9eee7d1eaee28b7219bec228520ff809af170488fd2fed3e2b"},
- {file = "coverage-5.5-cp39-cp39-win32.whl", hash = "sha256:d314ed732c25d29775e84a960c3c60808b682c08d86602ec2c3008e1202e3bb6"},
- {file = "coverage-5.5-cp39-cp39-win_amd64.whl", hash = "sha256:13034c4409db851670bc9acd836243aeee299949bd5673e11844befcb0149f03"},
- {file = "coverage-5.5-pp36-none-any.whl", hash = "sha256:f030f8873312a16414c0d8e1a1ddff2d3235655a2174e3648b4fa66b3f2f1079"},
- {file = "coverage-5.5-pp37-none-any.whl", hash = "sha256:2a3859cb82dcbda1cfd3e6f71c27081d18aa251d20a17d87d26d4cd216fb0af4"},
- {file = "coverage-5.5.tar.gz", hash = "sha256:ebe78fe9a0e874362175b02371bdfbee64d8edc42a044253ddf4ee7d3c15212c"},
+ {file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"},
+ {file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"},
+]
+dotty-dict = [
+ {file = "dotty_dict-1.3.1-py3-none-any.whl", hash = "sha256:5022d234d9922f13aa711b4950372a06a6d64cb6d6db9ba43d0ba133ebfce31f"},
+ {file = "dotty_dict-1.3.1.tar.gz", hash = "sha256:4b016e03b8ae265539757a53eba24b9bfda506fb94fbce0bee843c6f05541a15"},
+]
+editables = [
+ {file = "editables-0.3-py3-none-any.whl", hash = "sha256:ee686a8db9f5d91da39849f175ffeef094dd0e9c36d6a59a2e8c7f92a3b80020"},
+ {file = "editables-0.3.tar.gz", hash = "sha256:167524e377358ed1f1374e61c268f0d7a4bf7dbd046c656f7b410cde16161b1a"},
]
flake8 = [
- {file = "flake8-3.9.2-py2.py3-none-any.whl", hash = "sha256:bf8fd333346d844f616e8d47905ef3a3384edae6b4e9beb0c5101e25e3110907"},
- {file = "flake8-3.9.2.tar.gz", hash = "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b6b1d78057c576b"},
+ {file = "flake8-5.0.4-py2.py3-none-any.whl", hash = "sha256:7a1cf6b73744f5806ab95e526f6f0d8c01c66d7bbe349562d22dfca20610b248"},
+ {file = "flake8-5.0.4.tar.gz", hash = "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db"},
]
-flake8-polyfill = [
- {file = "flake8-polyfill-1.0.2.tar.gz", hash = "sha256:e44b087597f6da52ec6393a709e7108b2905317d0c0b744cdca6208e670d8eda"},
- {file = "flake8_polyfill-1.0.2-py2.py3-none-any.whl", hash = "sha256:12be6a34ee3ab795b19ca73505e7b55826d5f6ad7230d31b18e106400169b9e9"},
+flit-core = [
+ {file = "flit_core-3.7.1-py3-none-any.whl", hash = "sha256:e454fdbf68c7036e1c7435ec7479383f9d9a1650ca5b304feb184eba1efcdcef"},
+ {file = "flit_core-3.7.1.tar.gz", hash = "sha256:14955af340c43035dbfa96b5ee47407e377ee337f69e70f73064940d27d0a44f"},
]
halo = [
{file = "halo-0.0.31-py2-none-any.whl", hash = "sha256:5350488fb7d2aa7c31a1344120cee67a872901ce8858f60da7946cef96c208ab"},
{file = "halo-0.0.31.tar.gz", hash = "sha256:7b67a3521ee91d53b7152d4ee3452811e1d2a6321975137762eb3d70063cc9d6"},
]
+hatch-fancy-pypi-readme = [
+ {file = "hatch_fancy_pypi_readme-22.3.0-py3-none-any.whl", hash = "sha256:97c7ea026fe0d305163f5380c5df1dde51051e63d0dd4a47811214a5cd4e39b4"},
+ {file = "hatch_fancy_pypi_readme-22.3.0.tar.gz", hash = "sha256:7d4651f8f07825931c92873cb51137214a938badb7a759b85c1d95bf74f86efa"},
+]
+hatch-vcs = [
+ {file = "hatch_vcs-0.2.0-py2.py3-none-any.whl", hash = "sha256:86432a0dd49acae0e69e14f285667693fcd31d9869ca21634520acc30d482f07"},
+ {file = "hatch_vcs-0.2.0.tar.gz", hash = "sha256:9913d733b34eec9bb0345d0626ca32165a4ad2de15d1ce643c36d09ca908abff"},
+]
+hatchling = [
+ {file = "hatchling-1.8.0-py3-none-any.whl", hash = "sha256:1f7d920b1478221c8709841eb2aa6069856038463816d3a27b84ca5e99000e06"},
+ {file = "hatchling-1.8.0.tar.gz", hash = "sha256:a4f982fdca0717d8c46bfe7b501302f90aaf2a5302845d550b49c8739681feb2"},
+]
hid = [
- {file = "hid-1.0.4-py2-none-any.whl", hash = "sha256:fba9913f07030b01059b822b24c83b370ca3f444e9e6443bd662f9f1aa3f0780"},
- {file = "hid-1.0.4.tar.gz", hash = "sha256:f61b0382f37a334bc8ba8604bc84b94875ee4f594fbbaf82b2c3b3e827883fc1"},
+ {file = "hid-1.0.5-py2-none-any.whl", hash = "sha256:11836b877e81ab68cdd3abc44f2e230f0e6146c7e17ac45c185b72e0159fc9c7"},
+ {file = "hid-1.0.5.tar.gz", hash = "sha256:1e954e7f7ab9b7c9dfc78db59504692c17db3b71249492b976b1525b97dbb0e8"},
]
hjson = [
- {file = "hjson-3.0.2-py3-none-any.whl", hash = "sha256:5546438bf4e1b52bc964c6a47c4ed10fa5fba8a1b264e22efa893e333baad2db"},
- {file = "hjson-3.0.2.tar.gz", hash = "sha256:2838fd7200e5839ea4516ece953f3a19892c41089f0d933ba3f68e596aacfcd5"},
+ {file = "hjson-3.1.0-py3-none-any.whl", hash = "sha256:65713cdcf13214fb554eb8b4ef803419733f4f5e551047c9b711098ab7186b89"},
+ {file = "hjson-3.1.0.tar.gz", hash = "sha256:55af475a27cf83a7969c808399d7bccdec8fb836a07ddbd574587593b9cdcf75"},
+]
+importlib-resources = [
+ {file = "importlib_resources-5.9.0-py3-none-any.whl", hash = "sha256:f78a8df21a79bcc30cfd400bdc38f314333de7c0fb619763f6b9dabab8268bb7"},
+ {file = "importlib_resources-5.9.0.tar.gz", hash = "sha256:5481e97fb45af8dcf2f798952625591c58fe599d0735d86b10f54de086a61681"},
+]
+iniconfig = [
+ {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
+ {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
]
jsonschema = [
- {file = "jsonschema-3.2.0-py2.py3-none-any.whl", hash = "sha256:4e5b3cf8216f577bee9ce139cbe72eca3ea4f292ec60928ff24758ce626cd163"},
- {file = "jsonschema-3.2.0.tar.gz", hash = "sha256:c8a85b28d377cc7737e46e2d9f2b4f44ee3c0e1deac6bf46ddefc7187d30797a"},
+ {file = "jsonschema-4.14.0-py3-none-any.whl", hash = "sha256:9892b8d630a82990521a9ca630d3446bd316b5ad54dbe981338802787f3e0d2d"},
+ {file = "jsonschema-4.14.0.tar.gz", hash = "sha256:15062f4cc6f591400cd528d2c355f2cfa6a57e44c820dc783aee5e23d36a831f"},
]
log-symbols = [
{file = "log_symbols-0.0.14-py3-none-any.whl", hash = "sha256:4952106ff8b605ab7d5081dd2c7e6ca7374584eff7086f499c06edd1ce56dcca"},
{file = "log_symbols-0.0.14.tar.gz", hash = "sha256:cf0bbc6fe1a8e53f0d174a716bc625c4f87043cc21eb55dd8a740cfe22680556"},
]
mccabe = [
- {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"},
- {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"},
+ {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"},
+ {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"},
]
milc = [
- {file = "milc-1.6.2-py2.py3-none-any.whl", hash = "sha256:cb26404c7f3d6797c9c42005de732161e45e21294cde85845e914b279321bdad"},
- {file = "milc-1.6.2.tar.gz", hash = "sha256:779710a0b9300bef3c5748158887e6c734659e147d55548d9e4701d7a7d5dddf"},
+ {file = "milc-1.6.6-py2.py3-none-any.whl", hash = "sha256:5735022d25bc7aa259139ae680efa2867ce91bab769aa3b2482c63a3158120a5"},
+ {file = "milc-1.6.6.tar.gz", hash = "sha256:a4a1673718aaceefeb62c1799e48825bc6f4e56bfd8ad4a8e341a7622e6ff000"},
]
nose2 = [
- {file = "nose2-0.10.0-py2.py3-none-any.whl", hash = "sha256:aa620e759f2c5018d9ba041340391913e282ecebd3c392027f1575847b093ec6"},
- {file = "nose2-0.10.0.tar.gz", hash = "sha256:886ba617a96de0130c54b24479bd5c2d74d5c940d40f3809c3a275511a0c4a60"},
+ {file = "nose2-0.12.0-py2.py3-none-any.whl", hash = "sha256:da7eb5e3cbe2abb693a053e17b4fbefca98ea9ea79fc729b0b0f41e8b4196304"},
+ {file = "nose2-0.12.0.tar.gz", hash = "sha256:956e79b9bd558ee08b6200c05ad2c76465b7e3860c0c0537686089285c320113"},
+]
+packaging = [
+ {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
+ {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
+]
+pathspec = [
+ {file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"},
+ {file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"},
]
pep8-naming = [
- {file = "pep8-naming-0.12.1.tar.gz", hash = "sha256:bb2455947757d162aa4cad55dba4ce029005cd1692f2899a21d51d8630ca7841"},
- {file = "pep8_naming-0.12.1-py2.py3-none-any.whl", hash = "sha256:4a8daeaeb33cfcde779309fc0c9c0a68a3bbe2ad8a8308b763c5068f86eb9f37"},
+ {file = "pep8-naming-0.13.2.tar.gz", hash = "sha256:93eef62f525fd12a6f8c98f4dcc17fa70baae2f37fa1f73bec00e3e44392fa48"},
+ {file = "pep8_naming-0.13.2-py3-none-any.whl", hash = "sha256:59e29e55c478db69cffbe14ab24b5bd2cd615c0413edf790d47d3fb7ba9a4e23"},
+]
+pillow = [
+ {file = "Pillow-9.2.0-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:a9c9bc489f8ab30906d7a85afac4b4944a572a7432e00698a7239f44a44e6efb"},
+ {file = "Pillow-9.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:510cef4a3f401c246cfd8227b300828715dd055463cdca6176c2e4036df8bd4f"},
+ {file = "Pillow-9.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7888310f6214f19ab2b6df90f3f06afa3df7ef7355fc025e78a3044737fab1f5"},
+ {file = "Pillow-9.2.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:831e648102c82f152e14c1a0938689dbb22480c548c8d4b8b248b3e50967b88c"},
+ {file = "Pillow-9.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1cc1d2451e8a3b4bfdb9caf745b58e6c7a77d2e469159b0d527a4554d73694d1"},
+ {file = "Pillow-9.2.0-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:136659638f61a251e8ed3b331fc6ccd124590eeff539de57c5f80ef3a9594e58"},
+ {file = "Pillow-9.2.0-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:6e8c66f70fb539301e064f6478d7453e820d8a2c631da948a23384865cd95544"},
+ {file = "Pillow-9.2.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:37ff6b522a26d0538b753f0b4e8e164fdada12db6c6f00f62145d732d8a3152e"},
+ {file = "Pillow-9.2.0-cp310-cp310-win32.whl", hash = "sha256:c79698d4cd9318d9481d89a77e2d3fcaeff5486be641e60a4b49f3d2ecca4e28"},
+ {file = "Pillow-9.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:254164c57bab4b459f14c64e93df11eff5ded575192c294a0c49270f22c5d93d"},
+ {file = "Pillow-9.2.0-cp311-cp311-macosx_10_10_universal2.whl", hash = "sha256:408673ed75594933714482501fe97e055a42996087eeca7e5d06e33218d05aa8"},
+ {file = "Pillow-9.2.0-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:727dd1389bc5cb9827cbd1f9d40d2c2a1a0c9b32dd2261db522d22a604a6eec9"},
+ {file = "Pillow-9.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50dff9cc21826d2977ef2d2a205504034e3a4563ca6f5db739b0d1026658e004"},
+ {file = "Pillow-9.2.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cb6259196a589123d755380b65127ddc60f4c64b21fc3bb46ce3a6ea663659b0"},
+ {file = "Pillow-9.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7b0554af24df2bf96618dac71ddada02420f946be943b181108cac55a7a2dcd4"},
+ {file = "Pillow-9.2.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:15928f824870535c85dbf949c09d6ae7d3d6ac2d6efec80f3227f73eefba741c"},
+ {file = "Pillow-9.2.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:bdd0de2d64688ecae88dd8935012c4a72681e5df632af903a1dca8c5e7aa871a"},
+ {file = "Pillow-9.2.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:d5b87da55a08acb586bad5c3aa3b86505f559b84f39035b233d5bf844b0834b1"},
+ {file = "Pillow-9.2.0-cp311-cp311-win32.whl", hash = "sha256:b6d5e92df2b77665e07ddb2e4dbd6d644b78e4c0d2e9272a852627cdba0d75cf"},
+ {file = "Pillow-9.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:6bf088c1ce160f50ea40764f825ec9b72ed9da25346216b91361eef8ad1b8f8c"},
+ {file = "Pillow-9.2.0-cp37-cp37m-macosx_10_10_x86_64.whl", hash = "sha256:2c58b24e3a63efd22554c676d81b0e57f80e0a7d3a5874a7e14ce90ec40d3069"},
+ {file = "Pillow-9.2.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eef7592281f7c174d3d6cbfbb7ee5984a671fcd77e3fc78e973d492e9bf0eb3f"},
+ {file = "Pillow-9.2.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:dcd7b9c7139dc8258d164b55696ecd16c04607f1cc33ba7af86613881ffe4ac8"},
+ {file = "Pillow-9.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a138441e95562b3c078746a22f8fca8ff1c22c014f856278bdbdd89ca36cff1b"},
+ {file = "Pillow-9.2.0-cp37-cp37m-manylinux_2_28_aarch64.whl", hash = "sha256:93689632949aff41199090eff5474f3990b6823404e45d66a5d44304e9cdc467"},
+ {file = "Pillow-9.2.0-cp37-cp37m-manylinux_2_28_x86_64.whl", hash = "sha256:f3fac744f9b540148fa7715a435d2283b71f68bfb6d4aae24482a890aed18b59"},
+ {file = "Pillow-9.2.0-cp37-cp37m-win32.whl", hash = "sha256:fa768eff5f9f958270b081bb33581b4b569faabf8774726b283edb06617101dc"},
+ {file = "Pillow-9.2.0-cp37-cp37m-win_amd64.whl", hash = "sha256:69bd1a15d7ba3694631e00df8de65a8cb031911ca11f44929c97fe05eb9b6c1d"},
+ {file = "Pillow-9.2.0-cp38-cp38-macosx_10_10_x86_64.whl", hash = "sha256:030e3460861488e249731c3e7ab59b07c7853838ff3b8e16aac9561bb345da14"},
+ {file = "Pillow-9.2.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:74a04183e6e64930b667d321524e3c5361094bb4af9083db5c301db64cd341f3"},
+ {file = "Pillow-9.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d33a11f601213dcd5718109c09a52c2a1c893e7461f0be2d6febc2879ec2402"},
+ {file = "Pillow-9.2.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1fd6f5e3c0e4697fa7eb45b6e93996299f3feee73a3175fa451f49a74d092b9f"},
+ {file = "Pillow-9.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a647c0d4478b995c5e54615a2e5360ccedd2f85e70ab57fbe817ca613d5e63b8"},
+ {file = "Pillow-9.2.0-cp38-cp38-manylinux_2_28_aarch64.whl", hash = "sha256:4134d3f1ba5f15027ff5c04296f13328fecd46921424084516bdb1b2548e66ff"},
+ {file = "Pillow-9.2.0-cp38-cp38-manylinux_2_28_x86_64.whl", hash = "sha256:bc431b065722a5ad1dfb4df354fb9333b7a582a5ee39a90e6ffff688d72f27a1"},
+ {file = "Pillow-9.2.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:1536ad017a9f789430fb6b8be8bf99d2f214c76502becc196c6f2d9a75b01b76"},
+ {file = "Pillow-9.2.0-cp38-cp38-win32.whl", hash = "sha256:2ad0d4df0f5ef2247e27fc790d5c9b5a0af8ade9ba340db4a73bb1a4a3e5fb4f"},
+ {file = "Pillow-9.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:ec52c351b35ca269cb1f8069d610fc45c5bd38c3e91f9ab4cbbf0aebc136d9c8"},
+ {file = "Pillow-9.2.0-cp39-cp39-macosx_10_10_x86_64.whl", hash = "sha256:0ed2c4ef2451de908c90436d6e8092e13a43992f1860275b4d8082667fbb2ffc"},
+ {file = "Pillow-9.2.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4ad2f835e0ad81d1689f1b7e3fbac7b01bb8777d5a985c8962bedee0cc6d43da"},
+ {file = "Pillow-9.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ea98f633d45f7e815db648fd7ff0f19e328302ac36427343e4432c84432e7ff4"},
+ {file = "Pillow-9.2.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7761afe0126d046974a01e030ae7529ed0ca6a196de3ec6937c11df0df1bc91c"},
+ {file = "Pillow-9.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9a54614049a18a2d6fe156e68e188da02a046a4a93cf24f373bffd977e943421"},
+ {file = "Pillow-9.2.0-cp39-cp39-manylinux_2_28_aarch64.whl", hash = "sha256:5aed7dde98403cd91d86a1115c78d8145c83078e864c1de1064f52e6feb61b20"},
+ {file = "Pillow-9.2.0-cp39-cp39-manylinux_2_28_x86_64.whl", hash = "sha256:13b725463f32df1bfeacbf3dd197fb358ae8ebcd8c5548faa75126ea425ccb60"},
+ {file = "Pillow-9.2.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:808add66ea764ed97d44dda1ac4f2cfec4c1867d9efb16a33d158be79f32b8a4"},
+ {file = "Pillow-9.2.0-cp39-cp39-win32.whl", hash = "sha256:337a74fd2f291c607d220c793a8135273c4c2ab001b03e601c36766005f36885"},
+ {file = "Pillow-9.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:fac2d65901fb0fdf20363fbd345c01958a742f2dc62a8dd4495af66e3ff502a4"},
+ {file = "Pillow-9.2.0-pp37-pypy37_pp73-macosx_10_10_x86_64.whl", hash = "sha256:ad2277b185ebce47a63f4dc6302e30f05762b688f8dc3de55dbae4651872cdf3"},
+ {file = "Pillow-9.2.0-pp37-pypy37_pp73-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7c7b502bc34f6e32ba022b4a209638f9e097d7a9098104ae420eb8186217ebbb"},
+ {file = "Pillow-9.2.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3d1f14f5f691f55e1b47f824ca4fdcb4b19b4323fe43cc7bb105988cad7496be"},
+ {file = "Pillow-9.2.0-pp37-pypy37_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:dfe4c1fedfde4e2fbc009d5ad420647f7730d719786388b7de0999bf32c0d9fd"},
+ {file = "Pillow-9.2.0-pp38-pypy38_pp73-macosx_10_10_x86_64.whl", hash = "sha256:f07f1f00e22b231dd3d9b9208692042e29792d6bd4f6639415d2f23158a80013"},
+ {file = "Pillow-9.2.0-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1802f34298f5ba11d55e5bb09c31997dc0c6aed919658dfdf0198a2fe75d5490"},
+ {file = "Pillow-9.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:17d4cafe22f050b46d983b71c707162d63d796a1235cdf8b9d7a112e97b15bac"},
+ {file = "Pillow-9.2.0-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:96b5e6874431df16aee0c1ba237574cb6dff1dcb173798faa6a9d8b399a05d0e"},
+ {file = "Pillow-9.2.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:0030fdbd926fb85844b8b92e2f9449ba89607231d3dd597a21ae72dc7fe26927"},
+ {file = "Pillow-9.2.0.tar.gz", hash = "sha256:75e636fd3e0fb872693f23ccb8a5ff2cd578801251f3a4f6854c6a5d437d3c04"},
+]
+pkgutil-resolve-name = [
+ {file = "pkgutil_resolve_name-1.3.10-py3-none-any.whl", hash = "sha256:ca27cc078d25c5ad71a9de0a7a330146c4e014c2462d9af19c6b828280649c5e"},
+ {file = "pkgutil_resolve_name-1.3.10.tar.gz", hash = "sha256:357d6c9e6a755653cfd78893817c0853af365dd51ec97f3d358a819373bbd174"},
+]
+pluggy = [
+ {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},
+ {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"},
+]
+poetry-core = [
+ {file = "poetry-core-1.0.8.tar.gz", hash = "sha256:951fc7c1f8d710a94cb49019ee3742125039fc659675912ea614ac2aa405b118"},
+ {file = "poetry_core-1.0.8-py2.py3-none-any.whl", hash = "sha256:54b0fab6f7b313886e547a52f8bf52b8cf43e65b2633c65117f8755289061924"},
+]
+py = [
+ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"},
+ {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"},
]
pycodestyle = [
- {file = "pycodestyle-2.7.0-py2.py3-none-any.whl", hash = "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068"},
- {file = "pycodestyle-2.7.0.tar.gz", hash = "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef"},
+ {file = "pycodestyle-2.9.1-py2.py3-none-any.whl", hash = "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b"},
+ {file = "pycodestyle-2.9.1.tar.gz", hash = "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785"},
]
pyflakes = [
- {file = "pyflakes-2.3.1-py2.py3-none-any.whl", hash = "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3"},
- {file = "pyflakes-2.3.1.tar.gz", hash = "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db"},
+ {file = "pyflakes-2.5.0-py2.py3-none-any.whl", hash = "sha256:4579f67d887f804e67edb544428f264b7b24f435b263c4614f384135cea553d2"},
+ {file = "pyflakes-2.5.0.tar.gz", hash = "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3"},
]
pygments = [
- {file = "Pygments-2.10.0-py3-none-any.whl", hash = "sha256:b8e67fe6af78f492b3c4b3e2970c0624cbf08beb1e493b2c99b9fa1b67a20380"},
- {file = "Pygments-2.10.0.tar.gz", hash = "sha256:f398865f7eb6874156579fdf36bc840a03cab64d1cde9e93d68f46a425ec52c6"},
+ {file = "Pygments-2.13.0-py3-none-any.whl", hash = "sha256:f643f331ab57ba3c9d89212ee4a2dabc6e94f117cf4eefde99a0574720d14c42"},
+ {file = "Pygments-2.13.0.tar.gz", hash = "sha256:56a8508ae95f98e2b9bdf93a6be5ae3f7d8af858b43e02c5a2ff083726be40c1"},
+]
+pyparsing = [
+ {file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
+ {file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"},
]
pyrsistent = [
- {file = "pyrsistent-0.18.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f4c8cabb46ff8e5d61f56a037974228e978f26bfefce4f61a4b1ac0ba7a2ab72"},
- {file = "pyrsistent-0.18.0-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:da6e5e818d18459fa46fac0a4a4e543507fe1110e808101277c5a2b5bab0cd2d"},
- {file = "pyrsistent-0.18.0-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:5e4395bbf841693eaebaa5bb5c8f5cdbb1d139e07c975c682ec4e4f8126e03d2"},
- {file = "pyrsistent-0.18.0-cp36-cp36m-win32.whl", hash = "sha256:527be2bfa8dc80f6f8ddd65242ba476a6c4fb4e3aedbf281dfbac1b1ed4165b1"},
- {file = "pyrsistent-0.18.0-cp36-cp36m-win_amd64.whl", hash = "sha256:2aaf19dc8ce517a8653746d98e962ef480ff34b6bc563fc067be6401ffb457c7"},
- {file = "pyrsistent-0.18.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:58a70d93fb79dc585b21f9d72487b929a6fe58da0754fa4cb9f279bb92369396"},
- {file = "pyrsistent-0.18.0-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:4916c10896721e472ee12c95cdc2891ce5890898d2f9907b1b4ae0f53588b710"},
- {file = "pyrsistent-0.18.0-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:73ff61b1411e3fb0ba144b8f08d6749749775fe89688093e1efef9839d2dcc35"},
- {file = "pyrsistent-0.18.0-cp37-cp37m-win32.whl", hash = "sha256:b29b869cf58412ca5738d23691e96d8aff535e17390128a1a52717c9a109da4f"},
- {file = "pyrsistent-0.18.0-cp37-cp37m-win_amd64.whl", hash = "sha256:097b96f129dd36a8c9e33594e7ebb151b1515eb52cceb08474c10a5479e799f2"},
- {file = "pyrsistent-0.18.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:772e94c2c6864f2cd2ffbe58bb3bdefbe2a32afa0acb1a77e472aac831f83427"},
- {file = "pyrsistent-0.18.0-cp38-cp38-manylinux1_i686.whl", hash = "sha256:c1a9ff320fa699337e05edcaae79ef8c2880b52720bc031b219e5b5008ebbdef"},
- {file = "pyrsistent-0.18.0-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:cd3caef37a415fd0dae6148a1b6957a8c5f275a62cca02e18474608cb263640c"},
- {file = "pyrsistent-0.18.0-cp38-cp38-win32.whl", hash = "sha256:e79d94ca58fcafef6395f6352383fa1a76922268fa02caa2272fff501c2fdc78"},
- {file = "pyrsistent-0.18.0-cp38-cp38-win_amd64.whl", hash = "sha256:a0c772d791c38bbc77be659af29bb14c38ced151433592e326361610250c605b"},
- {file = "pyrsistent-0.18.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:d5ec194c9c573aafaceebf05fc400656722793dac57f254cd4741f3c27ae57b4"},
- {file = "pyrsistent-0.18.0-cp39-cp39-manylinux1_i686.whl", hash = "sha256:6b5eed00e597b5b5773b4ca30bd48a5774ef1e96f2a45d105db5b4ebb4bca680"},
- {file = "pyrsistent-0.18.0-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:48578680353f41dca1ca3dc48629fb77dfc745128b56fc01096b2530c13fd426"},
- {file = "pyrsistent-0.18.0-cp39-cp39-win32.whl", hash = "sha256:f3ef98d7b76da5eb19c37fda834d50262ff9167c65658d1d8f974d2e4d90676b"},
- {file = "pyrsistent-0.18.0-cp39-cp39-win_amd64.whl", hash = "sha256:404e1f1d254d314d55adb8d87f4f465c8693d6f902f67eb6ef5b4526dc58e6ea"},
- {file = "pyrsistent-0.18.0.tar.gz", hash = "sha256:773c781216f8c2900b42a7b638d5b517bb134ae1acbebe4d1e8f1f41ea60eb4b"},
+ {file = "pyrsistent-0.18.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:df46c854f490f81210870e509818b729db4488e1f30f2a1ce1698b2295a878d1"},
+ {file = "pyrsistent-0.18.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5d45866ececf4a5fff8742c25722da6d4c9e180daa7b405dc0a2a2790d668c26"},
+ {file = "pyrsistent-0.18.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4ed6784ceac462a7d6fcb7e9b663e93b9a6fb373b7f43594f9ff68875788e01e"},
+ {file = "pyrsistent-0.18.1-cp310-cp310-win32.whl", hash = "sha256:e4f3149fd5eb9b285d6bfb54d2e5173f6a116fe19172686797c056672689daf6"},
+ {file = "pyrsistent-0.18.1-cp310-cp310-win_amd64.whl", hash = "sha256:636ce2dc235046ccd3d8c56a7ad54e99d5c1cd0ef07d9ae847306c91d11b5fec"},
+ {file = "pyrsistent-0.18.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:e92a52c166426efbe0d1ec1332ee9119b6d32fc1f0bbfd55d5c1088070e7fc1b"},
+ {file = "pyrsistent-0.18.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7a096646eab884bf8bed965bad63ea327e0d0c38989fc83c5ea7b8a87037bfc"},
+ {file = "pyrsistent-0.18.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cdfd2c361b8a8e5d9499b9082b501c452ade8bbf42aef97ea04854f4a3f43b22"},
+ {file = "pyrsistent-0.18.1-cp37-cp37m-win32.whl", hash = "sha256:7ec335fc998faa4febe75cc5268a9eac0478b3f681602c1f27befaf2a1abe1d8"},
+ {file = "pyrsistent-0.18.1-cp37-cp37m-win_amd64.whl", hash = "sha256:6455fc599df93d1f60e1c5c4fe471499f08d190d57eca040c0ea182301321286"},
+ {file = "pyrsistent-0.18.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:fd8da6d0124efa2f67d86fa70c851022f87c98e205f0594e1fae044e7119a5a6"},
+ {file = "pyrsistent-0.18.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7bfe2388663fd18bd8ce7db2c91c7400bf3e1a9e8bd7d63bf7e77d39051b85ec"},
+ {file = "pyrsistent-0.18.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0e3e1fcc45199df76053026a51cc59ab2ea3fc7c094c6627e93b7b44cdae2c8c"},
+ {file = "pyrsistent-0.18.1-cp38-cp38-win32.whl", hash = "sha256:b568f35ad53a7b07ed9b1b2bae09eb15cdd671a5ba5d2c66caee40dbf91c68ca"},
+ {file = "pyrsistent-0.18.1-cp38-cp38-win_amd64.whl", hash = "sha256:d1b96547410f76078eaf66d282ddca2e4baae8964364abb4f4dcdde855cd123a"},
+ {file = "pyrsistent-0.18.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:f87cc2863ef33c709e237d4b5f4502a62a00fab450c9e020892e8e2ede5847f5"},
+ {file = "pyrsistent-0.18.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6bc66318fb7ee012071b2792024564973ecc80e9522842eb4e17743604b5e045"},
+ {file = "pyrsistent-0.18.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:914474c9f1d93080338ace89cb2acee74f4f666fb0424896fcfb8d86058bf17c"},
+ {file = "pyrsistent-0.18.1-cp39-cp39-win32.whl", hash = "sha256:1b34eedd6812bf4d33814fca1b66005805d3640ce53140ab8bbb1e2651b0d9bc"},
+ {file = "pyrsistent-0.18.1-cp39-cp39-win_amd64.whl", hash = "sha256:e24a828f57e0c337c8d8bb9f6b12f09dfdf0273da25fda9e314f0b684b415a07"},
+ {file = "pyrsistent-0.18.1.tar.gz", hash = "sha256:d4d61f8b993a7255ba714df3aca52700f8125289f84f704cf80916517c46eb96"},
+]
+pyserial = [
+ {file = "pyserial-3.5-py2.py3-none-any.whl", hash = "sha256:c4451db6ba391ca6ca299fb3ec7bae67a5c55dde170964c7a14ceefec02f2cf0"},
+ {file = "pyserial-3.5.tar.gz", hash = "sha256:3c77e014170dfffbd816e6ffc205e9842efb10be9f58ec16d3e8675b4925cddb"},
+]
+pytest = [
+ {file = "pytest-7.1.2-py3-none-any.whl", hash = "sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c"},
+ {file = "pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"},
]
pyusb = [
{file = "pyusb-1.2.1-py3-none-any.whl", hash = "sha256:2b4c7cb86dbadf044dfb9d3a4ff69fd217013dbe78a792177a3feb172449ea36"},
{file = "pyusb-1.2.1.tar.gz", hash = "sha256:a4cc7404a203144754164b8b40994e2849fde1cfff06b08492f12fff9d9de7b9"},
]
qmk = [
- {file = "qmk-1.0.0-py2.py3-none-any.whl", hash = "sha256:63d69b97a533d91b0cfa7887e68cac7df52c6f7bddf4bf44d17ef1241d85ffff"},
- {file = "qmk-1.0.0.tar.gz", hash = "sha256:da62eec73c4548cc37b0b9be3937202dc3a301dc2f2663610ecca751a610f9ca"},
+ {file = "qmk-1.1.1-py2.py3-none-any.whl", hash = "sha256:8694300678d9be1e594a500e82bfc9fb08a8ac0983b25fcb663ddd72b4861d97"},
+ {file = "qmk-1.1.1.tar.gz", hash = "sha256:dd028e09ebcd61f8bdf8cb82929dfafc0e007d97a5a3803b45819b4641773269"},
]
-qmk-dotty-dict = [
- {file = "qmk_dotty_dict-1.3.0.post1-py3-none-any.whl", hash = "sha256:a9cb7fc3ff9631190fee0ecac14986a0ac7b4b6892347dc9d7486a4c4ea24492"},
- {file = "qmk_dotty_dict-1.3.0.post1.tar.gz", hash = "sha256:3b611e393660bfaa6835c68e94784bae80fe07b8490978b5ecab03a0d2fc7ea2"},
+setuptools-scm = [
+ {file = "setuptools_scm-7.0.5-py3-none-any.whl", hash = "sha256:7930f720905e03ccd1e1d821db521bff7ec2ac9cf0ceb6552dd73d24a45d3b02"},
+ {file = "setuptools_scm-7.0.5.tar.gz", hash = "sha256:031e13af771d6f892b941adb6ea04545bbf91ebc5ce68c78aaf3fff6e1fb4844"},
]
six = [
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
@@ -462,7 +759,19 @@ spinners = [
termcolor = [
{file = "termcolor-1.1.0.tar.gz", hash = "sha256:1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b"},
]
+tomli = [
+ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
+ {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
+]
+typing-extensions = [
+ {file = "typing_extensions-4.3.0-py3-none-any.whl", hash = "sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02"},
+ {file = "typing_extensions-4.3.0.tar.gz", hash = "sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"},
+]
yapf = [
- {file = "yapf-0.31.0-py2.py3-none-any.whl", hash = "sha256:e3a234ba8455fe201eaa649cdac872d590089a18b661e39bbac7020978dd9c2e"},
- {file = "yapf-0.31.0.tar.gz", hash = "sha256:408fb9a2b254c302f49db83c59f9aa0b4b0fd0ec25be3a5c51181327922ff63d"},
+ {file = "yapf-0.32.0-py2.py3-none-any.whl", hash = "sha256:8fea849025584e486fd06d6ba2bed717f396080fd3cc236ba10cb97c4c51cf32"},
+ {file = "yapf-0.32.0.tar.gz", hash = "sha256:a3f5085d37ef7e3e004c4ba9f9b3e40c54ff1901cd111f05145ae313a7c67d1b"},
+]
+zipp = [
+ {file = "zipp-3.8.1-py3-none-any.whl", hash = "sha256:47c40d7fe183a6f21403a199b3e4192cca5774656965b0a4988ad2f8feb5f009"},
+ {file = "zipp-3.8.1.tar.gz", hash = "sha256:05b45f1ee8f807d0cc928485ca40a07cb491cf092ff587c0df9cb1fd154848d2"},
]
diff --git a/util/nix/pyproject.toml b/util/nix/pyproject.toml
index 1ec8aacd4a..ff484dbe79 100644
--- a/util/nix/pyproject.toml
+++ b/util/nix/pyproject.toml
@@ -12,13 +12,15 @@ python = "^3.8"
appdirs = "*"
argcomplete = "*"
colorama = "*"
+dotty-dict = "*"
hid = "*"
hjson = "*"
-jsonschema = ">=3"
+jsonschema = ">=4"
milc = ">=1.4.2"
Pygments = "*"
+pyserial = "*"
pyusb = "*"
-qmk-dotty-dict = "*"
+pillow = "*"
# This dependency is not mentioned in requirements.txt (QMK CLI is not a
# library package that is required by the Python code in qmk_firmware), but is
@@ -29,8 +31,31 @@ qmk = "*"
nose2 = "*"
flake8 = "*"
pep8-naming = "*"
+pyflakes = "*"
yapf = "*"
+# These dependencies are required by the jsonschema >= 4.11.0 build system, but
+# are not detected automatically; they are also not present in the used Nixpkgs
+# snapshot, so need to be obtained through Poetry.
+hatchling = "*"
+hatch-vcs = "*"
+hatch-fancy-pypi-readme = "*"
+
+# The `pytest` module in the used Nixpkgs snapshot has an upper bound on the
+# `pluggy` dependency, which conflicts with the dependency of the `hatchling`
+# module; upgrading the `pytest` module fixes the conflict.
+pytest = "*"
+
+# Building the `tomli` module, which is in the dependency tree of `hatchling`,
+# requires a newer `flit-core` module than found in the used Nixpkgs snapshot.
+flit-core = "*"
+
+# Building `dotty-dict` >= 1.3.1 requires the `poetry-core` module, and the
+# version of that module provided by the used Nixpkgs snapshot cannot be built
+# on Darwin due to the regex compatibility issue in the old Nixpkgs code
+# (https://github.com/NixOS/nix/issues/4758).
+poetry-core = "*"
+
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
diff --git a/util/nix/sources.json b/util/nix/sources.json
index caf5cb7d29..8cdb9e4996 100644
--- a/util/nix/sources.json
+++ b/util/nix/sources.json
@@ -29,10 +29,10 @@
"homepage": "",
"owner": "nix-community",
"repo": "poetry2nix",
- "rev": "2d27d44397242b28c3f0081e0432e4f6c951f3a1",
- "sha256": "06syfg150r59m4kksj5547b5kwxjxjaif5hiljcq966kb9hxsvmv",
+ "rev": "11c0df8e348c0f169cd73a2e3d63f65c92baf666",
+ "sha256": "0i3wbp2p0x6bpj07sqpvkbx4lvjm0irvpmv2bjqx8k02mpjm7dg2",
"type": "tarball",
- "url": "https://github.com/nix-community/poetry2nix/archive/2d27d44397242b28c3f0081e0432e4f6c951f3a1.tar.gz",
+ "url": "https://github.com/nix-community/poetry2nix/archive/11c0df8e348c0f169cd73a2e3d63f65c92baf666.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
diff --git a/util/size_regression.sh b/util/size_regression.sh
index d474d8d0d5..6da2d360bb 100755
--- a/util/size_regression.sh
+++ b/util/size_regression.sh
@@ -59,6 +59,14 @@ done
shift $((OPTIND-1))
keyboard_target=$1
+# Helper for resetting submodule existence
+fixup_submodules() {
+ [ -e lib/ugfx ] && rm -rf lib/ugfx
+ [ -e lib/pico-sdk ] && rm -rf lib/pico-sdk
+ [ -e lib/chibios-contrib/ext/mcux-sdk ] && rm -rf lib/chibios-contrib/ext/mcux-sdk
+ make git-submodule
+}
+
last_size=0
last_line=""
function build_executor() {
@@ -68,6 +76,7 @@ function build_executor() {
make distclean >/dev/null 2>&1
git checkout -f $revision >/dev/null 2>&1 || { echo "Failed to check out revision ${revision}" >&2 ; exit 1 ; }
+ fixup_submodules >/dev/null 2>&1
make -j${job_count} $keyboard_target >/dev/null 2>&1 || true
file_size=$(arm-none-eabi-size .build/*.elf 2>/dev/null | awk '/elf/ {print $1}' 2>/dev/null || true)
@@ -76,7 +85,7 @@ function build_executor() {
if [[ -n "$last_line" ]] ; then
size_delta=$(( $last_size - $file_size ))
- if { [[ -n "${skip_zero:-}" ]] && [[ $size_delta -ne 0 ]] ; } || [[ $file_size -eq 0 ]] ; then
+ if { [[ -n "${skip_zero:-}" ]] && [[ $size_delta -ne 0 ]] ; } || [[ -z "${skip_zero:-}" ]] || [[ $file_size -eq 0 ]] ; then
printf "Size: %8d, delta: %+6d -- %s\n" "$last_size" "$size_delta" "$last_line"
fi
fi
diff --git a/util/udev/50-qmk.rules b/util/udev/50-qmk.rules
index 57806f9df0..86f1dc9004 100644
--- a/util/udev/50-qmk.rules
+++ b/util/udev/50-qmk.rules
@@ -28,6 +28,9 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05df", TAG+="uacc
# USBAspLoader
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc", TAG+="uaccess"
+# USBtinyISP
+SUBSYSTEMS=="usb", ATTRS{idVendor}=="1782", ATTRS{idProduct}=="0c9f", TAG+="uaccess"
+
# ModemManager should ignore the following devices
# Atmel SAM-BA (Massdrop)
SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="6124", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1"
@@ -72,3 +75,9 @@ KERNEL=="hidraw*", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2067", TAG+="uaccess"
## PJRC's HalfKay
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="0478", TAG+="uaccess"
+
+# APM32 DFU
+SUBSYSTEMS=="usb", ATTRS{idVendor}=="314b", ATTRS{idProduct}=="0106", TAG+="uaccess"
+
+# GD32V DFU
+SUBSYSTEMS=="usb", ATTRS{idVendor}=="28e9", ATTRS{idProduct}=="0189", TAG+="uaccess"
diff --git a/util/uf2conv.py b/util/uf2conv.py
index df94b5ac99..7f5645414a 100755
--- a/util/uf2conv.py
+++ b/util/uf2conv.py
@@ -219,6 +219,9 @@ def get_drives():
tmp = rootpath + "/" + os.environ["USER"]
if os.path.isdir(tmp):
rootpath = tmp
+ tmp = "/run" + rootpath + "/" + os.environ["USER"]
+ if os.path.isdir(tmp):
+ rootpath = tmp
for d in os.listdir(rootpath):
drives.append(os.path.join(rootpath, d))
diff --git a/util/update_chibios_mirror.sh b/util/update_chibios_mirror.sh
index e6666c55c9..bd4c5c1529 100755
--- a/util/update_chibios_mirror.sh
+++ b/util/update_chibios_mirror.sh
@@ -7,7 +7,7 @@
chibios_branches="trunk stable_20.3.x stable_21.11.x"
# The ChibiOS tags to mirror
-chibios_tags="ver20.3.1 ver20.3.2 ver20.3.3 ver20.3.4 ver21.11.1"
+chibios_tags="ver20.3.1 ver20.3.2 ver20.3.3 ver20.3.4 ver21.11.1 ver21.11.2"
# The ChibiOS-Contrib branches to mirror
contrib_branches="chibios-20.3.x chibios-21.11.x"