diff --git a/keyboards/steelseries/prime/board.h b/keyboards/steelseries/prime/board.h new file mode 100644 index 000000000000..edb9e1072c33 --- /dev/null +++ b/keyboards/steelseries/prime/board.h @@ -0,0 +1,9 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include_next + +#undef STM32_HSECLK +#define STM32_HSECLK 12000000 diff --git a/keyboards/steelseries/prime/config.h b/keyboards/steelseries/prime/config.h new file mode 100644 index 000000000000..2e041f4a46da --- /dev/null +++ b/keyboards/steelseries/prime/config.h @@ -0,0 +1,23 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define POINTING_DEVICE_CS_PIN A4 +#define POINTING_DEVICE_MOTION_PIN B0 +#define POINTING_DEVICE_TASK_THROTTLE_MS 1 + +#define SPI_DRIVER SPID1 +#define SPI_SCK_PIN A5 +#define SPI_MOSI_PIN A7 +#define SPI_MISO_PIN A6 + +#define RGB_PWM_DRIVER PWMD1 +#define RGB_BLUE_PIN A10 +#define RGB_BLUE_PWM_CHANNEL 3 +#define RGB_GREEN_PIN A8 +#define RGB_GREEN_PWM_CHANNEL 1 +#define RGB_RED_PIN A9 +#define RGB_RED_PWM_CHANNEL 2 + +#define OPTICAL_SW_PWR A2 diff --git a/keyboards/steelseries/prime/halconf.h b/keyboards/steelseries/prime/halconf.h new file mode 100644 index 000000000000..e1498a877a30 --- /dev/null +++ b/keyboards/steelseries/prime/halconf.h @@ -0,0 +1,9 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define HAL_USE_SPI TRUE +#define HAL_USE_PWM TRUE + +#include_next diff --git a/keyboards/steelseries/prime/keyboard.json b/keyboards/steelseries/prime/keyboard.json new file mode 100644 index 000000000000..539c0c3d04bd --- /dev/null +++ b/keyboards/steelseries/prime/keyboard.json @@ -0,0 +1,58 @@ +{ + "manufacturer": "SteelSeries", + "keyboard_name": "Prime+", + "maintainer": "Dasky", + "bootloader": "uf2boot", + "build": { + "debounce_type": "asym_eager_defer_pk", + "lto": true + }, + "encoder": { + "rotary": [ + {"pin_a": "B5", "pin_b": "B4", "resolution": 2} + ] + }, + "features": { + "bootmagic": true, + "encoder": true, + "extrakey": true, + "mousekey": true, + "pointing_device": true, + "rgblight": true + }, + "matrix_pins": { + "direct": [ + ["A0", "C15", "A1", "C13", "C14", "A3"] + ] + }, + "processor": "STM32F103", + "rgblight": { + "animations": { + "breathing": true, + "rainbow_mood": true + }, + "default": { + "animation": "rainbow_mood" + }, + "driver": "custom", + "led_count": 1 + }, + "url": "https://steelseries.com/gaming-mice/prime", + "usb": { + "device_version": "1.0.0", + "pid": "0x0000", + "vid": "0xFEED" + }, + "layouts": { + "LAYOUT": { + "layout": [ + {"matrix": [0, 0], "x": 0, "y": 0}, + {"matrix": [0, 1], "x": 1, "y": 0}, + {"matrix": [0, 2], "x": 2, "y": 0}, + {"matrix": [0, 3], "x": 0, "y": 1}, + {"matrix": [0, 4], "x": 0, "y": 2}, + {"matrix": [0, 5], "x": 2, "y": 2} + ] + } + } +} diff --git a/keyboards/steelseries/prime/keymaps/default/keymap.c b/keyboards/steelseries/prime/keymaps/default/keymap.c new file mode 100644 index 000000000000..803f6b47daa4 --- /dev/null +++ b/keyboards/steelseries/prime/keymaps/default/keymap.c @@ -0,0 +1,29 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include QMK_KEYBOARD_H + +// clang-format off +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + // Left, Middle, Right, + // Forward + // Back + // Underneath + [0] = LAYOUT( + MS_BTN1, MS_BTN3, MS_BTN2, + MS_BTN5, + MS_BTN4, + QK_BOOT + ) +}; +// clang-format on + +void pointing_device_init_kb(void) { + pointing_device_set_cpi(1600); +} + +#if defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { + [0] = {ENCODER_CCW_CW(MS_WHLU, MS_WHLD)}, +}; +#endif diff --git a/keyboards/steelseries/prime/keymaps/default/rules.mk b/keyboards/steelseries/prime/keymaps/default/rules.mk new file mode 100644 index 000000000000..ee325681483f --- /dev/null +++ b/keyboards/steelseries/prime/keymaps/default/rules.mk @@ -0,0 +1 @@ +ENCODER_MAP_ENABLE = yes diff --git a/keyboards/steelseries/prime/mcuconf.h b/keyboards/steelseries/prime/mcuconf.h new file mode 100644 index 000000000000..fee1c8be2cb2 --- /dev/null +++ b/keyboards/steelseries/prime/mcuconf.h @@ -0,0 +1,18 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include_next + +##undef STM32_I2C_USE_I2C1 +##define STM32_I2C_USE_I2C1 TRUE + +#undef STM32_PWM_USE_TIM1 +#define STM32_PWM_USE_TIM1 TRUE + +#undef STM32_SPI_USE_SPI1 +#define STM32_SPI_USE_SPI1 TRUE + +#undef STM32_PLLMUL_VALUE +#define STM32_PLLMUL_VALUE 6 diff --git a/keyboards/steelseries/prime/prime.c b/keyboards/steelseries/prime/prime.c new file mode 100644 index 000000000000..11c528eea830 --- /dev/null +++ b/keyboards/steelseries/prime/prime.c @@ -0,0 +1,16 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "quantum.h" + + +void board_init(void) { + + gpio_set_pin_output(A15); + gpio_write_pin_high(A15); // Activate D+ pullup + + gpio_set_pin_output(OPTICAL_SW_PWR); + gpio_write_pin_low(OPTICAL_SW_PWR); // Enable power for optical switches + +} + diff --git a/keyboards/steelseries/prime/readme.md b/keyboards/steelseries/prime/readme.md new file mode 100644 index 000000000000..a55742f1f183 --- /dev/null +++ b/keyboards/steelseries/prime/readme.md @@ -0,0 +1,28 @@ +# SteelSeries Prime + +![Prime+](https://i.imgur.com/QhNHmwxh.png) + +This firmware does not support the dedicated lift off sensor. + +Erase with an stlink and flash this [uf2boot bootloader](https://github.com/daskygit/uf2-prime-plus), this is a a one way procedure voiding any warranty so be sure you don't want to use the original manufacturers firmware. + +* Keyboard Maintainer: [Dasky](https://github.com/daskygit) +* Hardware Supported: SteelSeries Prime+ +* Hardware Availability: https://steelseries.com/gaming-mice/prime + +Make example for this keyboard (after setting up your build environment): + + make steelseries/prime:default + +Flashing example for this keyboard: + + make steelseries/prime:default:flash + +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). + +## Bootloader + +Enter the bootloader in 2 ways: + +* **Bootmagic reset**: Hold down left mouse button and plug in. +* **Bootloader entry**: Hold the underneath button while plugging in. diff --git a/keyboards/steelseries/prime/rgblight_custom.c b/keyboards/steelseries/prime/rgblight_custom.c new file mode 100644 index 000000000000..273605258748 --- /dev/null +++ b/keyboards/steelseries/prime/rgblight_custom.c @@ -0,0 +1,65 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include "chibios_config.h" +#include "gpio.h" +#include "color.h" +#include "rgblight_drivers.h" + +static PWMConfig pwmCFG = { + .frequency = 0xFFFF, + .period = 256, +}; + +rgb_t prime_leds[RGBLIGHT_LED_COUNT]; + +void init_custom(void) { + palSetPadMode(PAL_PORT(RGB_RED_PIN), PAL_PAD(RGB_RED_PIN), PAL_MODE_ALTERNATE_PUSHPULL); + palSetPadMode(PAL_PORT(RGB_GREEN_PIN), PAL_PAD(RGB_GREEN_PIN), PAL_MODE_ALTERNATE_PUSHPULL); + palSetPadMode(PAL_PORT(RGB_BLUE_PIN), PAL_PAD(RGB_BLUE_PIN), PAL_MODE_ALTERNATE_PUSHPULL); + pwmCFG.channels[RGB_RED_PWM_CHANNEL - 1].mode = PWM_OUTPUT_ACTIVE_HIGH; + pwmCFG.channels[RGB_GREEN_PWM_CHANNEL - 1].mode = PWM_OUTPUT_ACTIVE_HIGH; + pwmCFG.channels[RGB_BLUE_PWM_CHANNEL - 1].mode = PWM_OUTPUT_ACTIVE_HIGH; + pwmStart(&RGB_PWM_DRIVER, &pwmCFG); +} + +void set_color_custom(int index, uint8_t red, uint8_t green, uint8_t blue) { + prime_leds[index].r = red; + prime_leds[index].g = green; + prime_leds[index].b = blue; +} + +void set_color_all_custom(uint8_t red, uint8_t green, uint8_t blue) { + for (int i = 0; i < RGBLIGHT_LED_COUNT; i++) { + set_color_custom(i, red, green, blue); + } +} + +void flush_custom(void) { + if (prime_leds[0].r == 0) { + pwmDisableChannel(&RGB_PWM_DRIVER, RGB_RED_PWM_CHANNEL - 1); + } else { + uint32_t duty = ((uint32_t)0xFFFF * prime_leds[0].r) / 0xFF; + pwmEnableChannel(&RGB_PWM_DRIVER, RGB_RED_PWM_CHANNEL - 1, PWM_FRACTION_TO_WIDTH(&RGB_PWM_DRIVER, 0xFFFF, duty)); + } + if (prime_leds[0].g == 0) { + pwmDisableChannel(&RGB_PWM_DRIVER, RGB_GREEN_PWM_CHANNEL - 1); + } else { + uint32_t duty = ((uint32_t)0xFFFF * prime_leds[0].g) / 0xFF; + pwmEnableChannel(&RGB_PWM_DRIVER, RGB_GREEN_PWM_CHANNEL - 1, PWM_FRACTION_TO_WIDTH(&RGB_PWM_DRIVER, 0xFFFF, duty)); + } + if (prime_leds[0].b == 0) { + pwmDisableChannel(&RGB_PWM_DRIVER, RGB_BLUE_PWM_CHANNEL - 1); + } else { + uint32_t duty = ((uint32_t)0xFFFF * prime_leds[0].b) / 0xFF; + pwmEnableChannel(&RGB_PWM_DRIVER, RGB_BLUE_PWM_CHANNEL - 1, PWM_FRACTION_TO_WIDTH(&RGB_PWM_DRIVER, 0xFFFF, duty)); + } +} + +const rgblight_driver_t rgblight_driver = { + .init = init_custom, + .set_color = set_color_custom, + .set_color_all = set_color_all_custom, + .flush = flush_custom, +}; diff --git a/keyboards/steelseries/prime/rules.mk b/keyboards/steelseries/prime/rules.mk new file mode 100644 index 000000000000..5ab86b1b6938 --- /dev/null +++ b/keyboards/steelseries/prime/rules.mk @@ -0,0 +1,5 @@ +MCU_LDSCRIPT = STM32F103xB_uf2boot + +POINTING_DEVICE_DRIVER = pmw3389 + +SRC += rgblight_custom.c diff --git a/lib/chibios b/lib/chibios index 9dd6eaf669e8..be44b3305f9a 160000 --- a/lib/chibios +++ b/lib/chibios @@ -1 +1 @@ -Subproject commit 9dd6eaf669e83eb9d5aaabe736ecfdf2f790a9fd +Subproject commit be44b3305f9a9fe5f2f49a4e7b978db322dc463e diff --git a/lib/chibios-contrib b/lib/chibios-contrib index b643aad980d0..77cb0a4f7589 160000 --- a/lib/chibios-contrib +++ b/lib/chibios-contrib @@ -1 +1 @@ -Subproject commit b643aad980d061021565c55745925c2cde4a3c6f +Subproject commit 77cb0a4f7589f89e724f5e6ecb1d76d514dd1212