From 7e23b6f507aca7f65841f551b17a16f97f9c1d0a Mon Sep 17 00:00:00 2001 From: Tim Brown Date: Sat, 25 Jan 2025 12:02:17 +0000 Subject: [PATCH 1/2] Sofle APM32 config that reports debug info --- keyboards/sofle/apm32/chconf.h | 31 ++++++ keyboards/sofle/apm32/config.h | 49 +++++++++ keyboards/sofle/apm32/halconf.h | 34 ++++++ keyboards/sofle/apm32/keyboard.json | 156 ++++++++++++++++++++++++++++ keyboards/sofle/apm32/mcuconf.h | 46 ++++++++ keyboards/sofle/apm32/rules.mk | 6 ++ 6 files changed, 322 insertions(+) create mode 100644 keyboards/sofle/apm32/chconf.h create mode 100644 keyboards/sofle/apm32/config.h create mode 100644 keyboards/sofle/apm32/halconf.h create mode 100644 keyboards/sofle/apm32/keyboard.json create mode 100644 keyboards/sofle/apm32/mcuconf.h create mode 100644 keyboards/sofle/apm32/rules.mk diff --git a/keyboards/sofle/apm32/chconf.h b/keyboards/sofle/apm32/chconf.h new file mode 100644 index 000000000000..7239dcafc8db --- /dev/null +++ b/keyboards/sofle/apm32/chconf.h @@ -0,0 +1,31 @@ +/* Copyright 2020 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 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 . + */ + +/* + * This file was auto-generated by: + * `qmk chibios-confmigrate -i keyboards/cannonkeys/tsukuyomi/chconf.h -r platforms/chibios/common/configs/chconf.h` + */ + +#pragma once + +#define CH_CFG_ST_FREQUENCY 10000 + +#define CH_CFG_OPTIMIZE_SPEED FALSE + +#define CH_CFG_USE_CONDVARS_TIMEOUT FALSE + +#include_next + diff --git a/keyboards/sofle/apm32/config.h b/keyboards/sofle/apm32/config.h new file mode 100644 index 000000000000..f23ff39c0702 --- /dev/null +++ b/keyboards/sofle/apm32/config.h @@ -0,0 +1,49 @@ +/* Copyright + * 2021 solartempest + * 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 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 . + */ + +#pragma once + +#define SPLIT_USB_DETECT +#define SPLIT_MASTER_TIMER 2000 + +#define MASTER_RIGHT + + +// OLED settings +#undef OLED_ENABLE +#define OLED_ENABLE +#define OLED_TIMEOUT 80000 +#define OLED_BRIGHTNESS 90 + +#define SERIAL_USART_FULL_DUPLEX // Enable full duplex operation mode. +//#define SERIAL_USART_TX_PIN A2 +//#define SERIAL_USART_RX_PIN A3 +#define SERIAL_USART_DRIVER SD2 +#define SERIAL_USART_TX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7 +#define SERIAL_USART_RX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7 +#define SERIAL_USART_TIMEOUT 100 // USART driver timeout. default 100 +#define SERIAL_USART_SPEED 921600 + +#define BACKLIGHT_PWM_DRIVER PWMD3 +#define BACKLIGHT_PWM_CHANNEL 1 +#define BACKLIGHT_PAL_MODE 1 + +#define WS2812_SPI_DRIVER SPID2 +#define WS2812_SPI_MOSI_PAL_MODE 0 +#define WS2812_SPI_SCK_PAL_MODE 0 +#define WS2812_SPI_SCK_PIN B13 \ No newline at end of file diff --git a/keyboards/sofle/apm32/halconf.h b/keyboards/sofle/apm32/halconf.h new file mode 100644 index 000000000000..2eeb39bdd59d --- /dev/null +++ b/keyboards/sofle/apm32/halconf.h @@ -0,0 +1,34 @@ +/* Copyright 2020 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 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 . + */ + +/* + * This file was auto-generated by: + * `qmk chibios-confmigrate -i keyboards/sofle/apm32/halconf.h -r platforms/chibios/common/configs/halconf.h` + */ + +#pragma once + +#undef HAL_USE_I2C +#define HAL_USE_I2C TRUE + +#define HAL_USE_PWM TRUE + +#define HAL_USE_SPI TRUE + +#define HAL_USE_SERIAL TRUE + +#include_next + diff --git a/keyboards/sofle/apm32/keyboard.json b/keyboards/sofle/apm32/keyboard.json new file mode 100644 index 000000000000..1bb429b317f8 --- /dev/null +++ b/keyboards/sofle/apm32/keyboard.json @@ -0,0 +1,156 @@ +{ + "keyboard_name": "Sofle", + "manufacturer": "JosefAdamcik", + "processor": "STM32F072", + "bootloader": "stm32-dfu", + "features": { + "bootmagic": true, + "mousekey": false, + "extrakey": false, + "console": true, + "command": true, + "nkro": false, + "backlight": false, + "oled": true, + "rgblight": true + }, + "usb": { + "pid": "0x1289", + "device_version": "0.0.2" + }, + "rgblight": { + "led_count": 37, + "animations": { + "breathing": true, + "rainbow_mood": true, + "rainbow_swirl": true, + "snake": true, + "knight": true, + "christmas": true, + "static_gradient": true, + "rgb_test": true, + "alternating": true, + "twinkle": true + } + }, + "ws2812": { + "pin": "B15", + "driver": "spi" + }, + "matrix_pins": { + "cols": ["A3", "A4", "A5", "B0", "B1", "B2"], + "rows": ["B11", "B10", "A7", "A6", "C13"] + }, + "encoder": { + "rotary": [ + {"pin_a": "A1", "pin_b": "A0"} + ] + }, + "split": { + "encoder": { + "right": { + "rotary": [ + {"pin_a": "A1", "pin_b": "A0", "resolution": 2} + ] + } + }, + "serial": { + "pin": "A2", + "driver": "usart" + }, + "matrix_pins": { + "right": { + "cols": ["B9", "C13", "C14", "C15", "A6", "A7"], + "rows": ["A13", "B3", "B4", "B5", "B8"] + } + }, + "transport": { + "sync": { + "matrix_state": true, + "oled": true, + "wpm": true + } + } + }, + "qmk": { + "locking": { + "enabled": true, + "resync": true + } + }, + "layouts": { + "LAYOUT": { + "layout": [ + {"matrix": [0, 0], "x": 0, "y": 0.5}, + {"matrix": [0, 1], "x": 1, "y": 0.375}, + {"matrix": [0, 2], "x": 2, "y": 0.125}, + {"matrix": [0, 3], "x": 3, "y": 0}, + {"matrix": [0, 4], "x": 4, "y": 0.125}, + {"matrix": [0, 5], "x": 5, "y": 0.25}, + + {"matrix": [5, 5], "x": 10.5, "y": 0.25}, + {"matrix": [5, 4], "x": 11.5, "y": 0.125}, + {"matrix": [5, 3], "x": 12.5, "y": 0}, + {"matrix": [5, 2], "x": 13.5, "y": 0.125}, + {"matrix": [5, 1], "x": 14.5, "y": 0.375}, + {"matrix": [5, 0], "x": 15.5, "y": 0.5}, + + {"matrix": [1, 0], "x": 0, "y": 1.5}, + {"matrix": [1, 1], "x": 1, "y": 1.375}, + {"matrix": [1, 2], "x": 2, "y": 1.125}, + {"matrix": [1, 3], "x": 3, "y": 1}, + {"matrix": [1, 4], "x": 4, "y": 1.125}, + {"matrix": [1, 5], "x": 5, "y": 1.25}, + + {"matrix": [6, 5], "x": 10.5, "y": 1.25}, + {"matrix": [6, 4], "x": 11.5, "y": 1.125}, + {"matrix": [6, 3], "x": 12.5, "y": 1}, + {"matrix": [6, 2], "x": 13.5, "y": 1.125}, + {"matrix": [6, 1], "x": 14.5, "y": 1.375}, + {"matrix": [6, 0], "x": 15.5, "y": 1.5}, + + {"matrix": [2, 0], "x": 0, "y": 2.5}, + {"matrix": [2, 1], "x": 1, "y": 2.375}, + {"matrix": [2, 2], "x": 2, "y": 2.125}, + {"matrix": [2, 3], "x": 3, "y": 2}, + {"matrix": [2, 4], "x": 4, "y": 2.125}, + {"matrix": [2, 5], "x": 5, "y": 2.25}, + + {"matrix": [7, 5], "x": 10.5, "y": 2.25}, + {"matrix": [7, 4], "x": 11.5, "y": 2.125}, + {"matrix": [7, 3], "x": 12.5, "y": 2}, + {"matrix": [7, 2], "x": 13.5, "y": 2.125}, + {"matrix": [7, 1], "x": 14.5, "y": 2.375}, + {"matrix": [7, 0], "x": 15.5, "y": 2.5}, + + {"matrix": [3, 0], "x": 0, "y": 3.5}, + {"matrix": [3, 1], "x": 1, "y": 3.375}, + {"matrix": [3, 2], "x": 2, "y": 3.125}, + {"matrix": [3, 3], "x": 3, "y": 3}, + {"matrix": [3, 4], "x": 4, "y": 3.125}, + {"matrix": [3, 5], "x": 5, "y": 3.25}, + {"matrix": [4, 0], "x": 6, "y": 2.75}, + + {"matrix": [9, 5], "x": 9.5, "y": 2.75}, + {"matrix": [8, 5], "x": 10.5, "y": 3.25}, + {"matrix": [8, 4], "x": 11.5, "y": 3.125}, + {"matrix": [8, 3], "x": 12.5, "y": 3}, + {"matrix": [8, 2], "x": 13.5, "y": 3.125}, + {"matrix": [8, 1], "x": 14.5, "y": 3.375}, + {"matrix": [8, 0], "x": 15.5, "y": 3.5}, + + {"matrix": [4, 1], "x": 1.5, "y": 4.375}, + {"matrix": [4, 2], "x": 2.5, "y": 4.125}, + {"matrix": [4, 3], "x": 3.5, "y": 4.15}, + {"matrix": [4, 4], "x": 4.5, "y": 4.25}, + {"matrix": [4, 5], "x": 6, "y": 4.25, "h": 1.5}, + + {"matrix": [9, 4], "x": 9.5, "y": 4.25, "h": 1.5}, + {"matrix": [9, 3], "x": 11, "y": 4.25}, + {"matrix": [9, 2], "x": 12, "y": 4.15}, + {"matrix": [9, 1], "x": 13, "y": 4.125}, + {"matrix": [9, 0], "x": 14, "y": 4.375} + ] + } + } +} diff --git a/keyboards/sofle/apm32/mcuconf.h b/keyboards/sofle/apm32/mcuconf.h new file mode 100644 index 000000000000..7ba5909c017f --- /dev/null +++ b/keyboards/sofle/apm32/mcuconf.h @@ -0,0 +1,46 @@ +/* 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 . + */ + +#pragma once + +#include_next + +#undef STM32_SERIAL_USE_USART2 +#define STM32_SERIAL_USE_USART2 TRUE + +#undef STM32_PWM_USE_TIM3 +#define STM32_PWM_USE_TIM3 TRUE + +#undef STM32_SPI_USE_SPI2 +#define STM32_SPI_USE_SPI2 TRUE + +#undef STM32_I2C_USE_DMA +#define STM32_I2C_USE_DMA FALSE + +#undef STM32_I2C_USE_I2C1 +#define STM32_I2C_USE_I2C1 TRUE + +//undef STM32_SPI_USE_SPI2 +//#define STM32_SPI_USE_SPI2 TRUE + +/* +#undef STM32_I2C_USE_DMA +#define STM32_I2C_USE_DMA FALSE + +#undef STM32_PWM_USE_TIM3 +#define STM32_PWM_USE_TIM3 YES + +*/ \ No newline at end of file diff --git a/keyboards/sofle/apm32/rules.mk b/keyboards/sofle/apm32/rules.mk new file mode 100644 index 000000000000..0d8f72804de9 --- /dev/null +++ b/keyboards/sofle/apm32/rules.mk @@ -0,0 +1,6 @@ +# Wildcard to allow APM32 MCU +DFU_SUFFIX_ARGS = -v FFFF -p FFFF + +I2C_DRIVER_REQUIRED = no + +WS2812_DRIVER_REQUIRED = yes \ No newline at end of file From 67c60c8c38c5d5baa1fa3d56d56908a614869c45 Mon Sep 17 00:00:00 2001 From: Tim Brown Date: Sat, 25 Jan 2025 21:54:03 +0000 Subject: [PATCH 2/2] Add some debug, reorder json to be similar order to tsukuyomi, got keys working after timeout waiting for other half --- keyboards/sofle/apm32/config.h | 22 +++++++++---- keyboards/sofle/apm32/halconf.h | 5 ++- keyboards/sofle/apm32/keyboard.json | 42 ++++++++++++++---------- keyboards/sofle/apm32/mcuconf.h | 5 +++ keyboards/sofle/apm32/rules.mk | 4 --- keyboards/sofle/keymaps/default/keymap.c | 25 ++++++++++++++ 6 files changed, 75 insertions(+), 28 deletions(-) diff --git a/keyboards/sofle/apm32/config.h b/keyboards/sofle/apm32/config.h index f23ff39c0702..50e7f4f61cb5 100644 --- a/keyboards/sofle/apm32/config.h +++ b/keyboards/sofle/apm32/config.h @@ -18,11 +18,14 @@ #pragma once -#define SPLIT_USB_DETECT -#define SPLIT_MASTER_TIMER 2000 +#define DEBUG_TO_SCREEN 1 -#define MASTER_RIGHT +#define EE_HANDS + +//#define SPLIT_USB_DETECT +//#define SPLIT_MASTER_TIMER 2000 +#define MASTER_RIGHT // OLED settings #undef OLED_ENABLE @@ -30,15 +33,22 @@ #define OLED_TIMEOUT 80000 #define OLED_BRIGHTNESS 90 -#define SERIAL_USART_FULL_DUPLEX // Enable full duplex operation mode. -//#define SERIAL_USART_TX_PIN A2 -//#define SERIAL_USART_RX_PIN A3 +//#define OLED_IC OLED_IC_SSD1306 +#define OLED_DC_PIN B6 +#define OLED_CS_PIN B7 + +#define I2C1_SCL_PIN B6 +#define I2C1_SDA_PIN B7 +#define I2C_DRIVER I2CD1 + +#define SERIAL_USART_HALF_DUPLEX // Enable full duplex operation mode. #define SERIAL_USART_DRIVER SD2 #define SERIAL_USART_TX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7 #define SERIAL_USART_RX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7 #define SERIAL_USART_TIMEOUT 100 // USART driver timeout. default 100 #define SERIAL_USART_SPEED 921600 + #define BACKLIGHT_PWM_DRIVER PWMD3 #define BACKLIGHT_PWM_CHANNEL 1 #define BACKLIGHT_PAL_MODE 1 diff --git a/keyboards/sofle/apm32/halconf.h b/keyboards/sofle/apm32/halconf.h index 2eeb39bdd59d..f545e936e1ce 100644 --- a/keyboards/sofle/apm32/halconf.h +++ b/keyboards/sofle/apm32/halconf.h @@ -21,13 +21,16 @@ #pragma once -#undef HAL_USE_I2C +// For OLED? #define HAL_USE_I2C TRUE +// Backlight #define HAL_USE_PWM TRUE +// For RGB? #define HAL_USE_SPI TRUE +// For split comms? #define HAL_USE_SERIAL TRUE #include_next diff --git a/keyboards/sofle/apm32/keyboard.json b/keyboards/sofle/apm32/keyboard.json index 1bb429b317f8..18a55ef142a0 100644 --- a/keyboards/sofle/apm32/keyboard.json +++ b/keyboards/sofle/apm32/keyboard.json @@ -3,23 +3,23 @@ "manufacturer": "JosefAdamcik", "processor": "STM32F072", "bootloader": "stm32-dfu", - "features": { - "bootmagic": true, - "mousekey": false, - "extrakey": false, - "console": true, - "command": true, - "nkro": false, - "backlight": false, - "oled": true, - "rgblight": true - }, "usb": { "pid": "0x1289", "device_version": "0.0.2" }, + "matrix_pins": { + "cols": ["A2", "A4", "A5", "B0", "B1", "B2"], + "rows": ["B10", "B10", "A7", "A6", "C13"] + }, + "diode_direction": "COL2ROW", "rgblight": { - "led_count": 37, + "led_count": 76, + "default": { + "on": true + }, + "driver": "ws2812", + "split": true, + "split_count": [37, 37], "animations": { "breathing": true, "rainbow_mood": true, @@ -37,9 +37,16 @@ "pin": "B15", "driver": "spi" }, - "matrix_pins": { - "cols": ["A3", "A4", "A5", "B0", "B1", "B2"], - "rows": ["B11", "B10", "A7", "A6", "C13"] + "features": { + "bootmagic": false, + "mousekey": false, + "extrakey": false, + "console": true, + "command": true, + "nkro": false, + "backlight": false, + "oled": true, + "rgblight": true }, "encoder": { "rotary": [ @@ -47,6 +54,7 @@ ] }, "split": { + "enabled": true, "encoder": { "right": { "rotary": [ @@ -60,8 +68,8 @@ }, "matrix_pins": { "right": { - "cols": ["B9", "C13", "C14", "C15", "A6", "A7"], - "rows": ["A13", "B3", "B4", "B5", "B8"] + "cols": ["B9", "C13", "C14", "C15", "A7", "A6"], + "rows": ["A15", "B3", "B4", "B5", "B8"] } }, "transport": { diff --git a/keyboards/sofle/apm32/mcuconf.h b/keyboards/sofle/apm32/mcuconf.h index 7ba5909c017f..c41cfea7a44d 100644 --- a/keyboards/sofle/apm32/mcuconf.h +++ b/keyboards/sofle/apm32/mcuconf.h @@ -18,6 +18,7 @@ #include_next +// TX on A2 #undef STM32_SERIAL_USE_USART2 #define STM32_SERIAL_USE_USART2 TRUE @@ -30,9 +31,13 @@ #undef STM32_I2C_USE_DMA #define STM32_I2C_USE_DMA FALSE +// For OLED? #undef STM32_I2C_USE_I2C1 #define STM32_I2C_USE_I2C1 TRUE +#undef STM32_I2C_USE_I2C2 +#define STM32_I2C_USE_I2C2 TRUE + //undef STM32_SPI_USE_SPI2 //#define STM32_SPI_USE_SPI2 TRUE diff --git a/keyboards/sofle/apm32/rules.mk b/keyboards/sofle/apm32/rules.mk index 0d8f72804de9..0ab54aaaf718 100644 --- a/keyboards/sofle/apm32/rules.mk +++ b/keyboards/sofle/apm32/rules.mk @@ -1,6 +1,2 @@ # Wildcard to allow APM32 MCU DFU_SUFFIX_ARGS = -v FFFF -p FFFF - -I2C_DRIVER_REQUIRED = no - -WS2812_DRIVER_REQUIRED = yes \ No newline at end of file diff --git a/keyboards/sofle/keymaps/default/keymap.c b/keyboards/sofle/keymaps/default/keymap.c index 564a624c58b1..47f389236792 100644 --- a/keyboards/sofle/keymaps/default/keymap.c +++ b/keyboards/sofle/keymaps/default/keymap.c @@ -18,6 +18,31 @@ enum custom_keycodes { KC_LEND }; +// Debug function, should be removed in working config. +void keyboard_post_init_user(void) { + // Customise these values to desired behaviour + debug_enable=true; + debug_matrix=true; + //debug_keyboard=true; + //debug_mouse=true; + printf("Keyboard booting up...\n"); + wait_ms(2000); + oled_init(OLED_ROTATION_0); + printf("OLED initialised...\n"); +} + + +void i2c_init(void) { + printf("In I2C init...\n"); + gpio_set_pin_input(B6); // Try releasing special pins for a short time + gpio_set_pin_input(B7); + wait_ms(10); // Wait for the release to happen + + palSetPadMode(GPIOB, 6, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP); // Set B6 to I2C function + palSetPadMode(GPIOB, 7, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP); // Set B7 to I2C function + printf("I2C initialised...\n"); +} + #define KC_QWERTY PDF(_QWERTY) #define KC_COLEMAK PDF(_COLEMAK)