Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add SteelSeries prime, a stripped down prime+ #24719

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions keyboards/steelseries/prime/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright 2024 Dasky (@daskygit)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include_next <board.h>

#undef STM32_HSECLK
#define STM32_HSECLK 12000000
23 changes: 23 additions & 0 deletions keyboards/steelseries/prime/config.h
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions keyboards/steelseries/prime/halconf.h
Original file line number Diff line number Diff line change
@@ -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 <halconf.h>
58 changes: 58 additions & 0 deletions keyboards/steelseries/prime/keyboard.json
Original file line number Diff line number Diff line change
@@ -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": [
{"label": "Left Click", "matrix": [0, 0], "x": 0, "y": 0},
{"label": "Middle Click", "matrix": [0, 1], "x": 1, "y": 0},
{"label": "Right Click", "matrix": [0, 2], "x": 2, "y": 0},
{"label": "Side forward", "matrix": [0, 3], "x": 0, "y": 2},
{"label": "Side back", "matrix": [0, 4], "x": 0, "y": 3},
{"label": "boot", "matrix": [0, 5], "x": 1, "y": 1}
]
}
}
}
29 changes: 29 additions & 0 deletions keyboards/steelseries/prime/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions keyboards/steelseries/prime/keymaps/default/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENCODER_MAP_ENABLE = yes
15 changes: 15 additions & 0 deletions keyboards/steelseries/prime/mcuconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2024 Dasky (@daskygit)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include_next <mcuconf.h>

#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
16 changes: 16 additions & 0 deletions keyboards/steelseries/prime/prime.c
Original file line number Diff line number Diff line change
@@ -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

}

41 changes: 41 additions & 0 deletions keyboards/steelseries/prime/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# SteelSeries Prime

![Prime](https://i.imgur.com/rPIKok3.jpeg)

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.

you may need to remove write protection to flash, e.g. with openocd in linux

```sh
openocd -f interface/stlink.cfg -f target/stm32f1x.cfg -c "init; reset halt; stm32f1x unlock 0; flash protect 0 0 last off; reset halt; exit"

```

and write the new bootloader

```sh

openocd -f interface/stlink.cfg -f target/stm32f1x.cfg -c "program build/PRIME_PLUS/uf2boot.bin verify reset exit 0x8000000"

```

* 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.
65 changes: 65 additions & 0 deletions keyboards/steelseries/prime/rgblight_custom.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2024 Dasky (@daskygit)
// SPDX-License-Identifier: GPL-2.0-or-later

#include <hal.h>
#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,
};
5 changes: 5 additions & 0 deletions keyboards/steelseries/prime/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MCU_LDSCRIPT = STM32F103xB_uf2boot

POINTING_DEVICE_DRIVER = pmw3389

SRC += rgblight_custom.c
Loading