Skip to content

Commit

Permalink
add steelseries prime, take 1, duplicated from prime+ and oled removed
Browse files Browse the repository at this point in the history
  • Loading branch information
alinelena committed Dec 15, 2024
1 parent ce4dd4e commit 60c9eab
Show file tree
Hide file tree
Showing 13 changed files with 275 additions and 2 deletions.
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": [
{"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}
]
}
}
}
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

}

43 changes: 43 additions & 0 deletions keyboards/steelseries/prime/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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.

you may need to remove write protection to flash, eg openocd

```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
2 changes: 1 addition & 1 deletion lib/chibios
Submodule chibios updated 69 files
+0 −2 demos/STM32/RT-STM32-LWIP-FATFS-USB/cfg/stm32h735ig_discovery/mcuconf.h
+0 −2 demos/STM32/RT-STM32H723ZG-NUCLEO144/cfg/mcuconf.h
+0 −2 demos/STM32/RT-STM32H735IG-DISCOVERY/cfg/mcuconf.h
+1 −1 demos/STM32/RT-STM32H750XB-DISCOVERY/cfg/halconf.h
+15 −41 demos/STM32/RT-STM32H750XB-DISCOVERY/cfg/mcuconf.h
+5 −5 demos/STM32/RT-STM32H750XB-DISCOVERY/main.c
+2 −19 os/common/ports/ARMv6-M-RP2/chcore.h
+2 −19 os/common/ports/ARMv6-M/chcore.h
+2 −19 os/common/ports/ARMv7-M-ALT/chcore.h
+2 −19 os/common/ports/ARMv7-M/chcore.h
+2 −19 os/common/ports/ARMv8-M-ML-TZ/chcore.h
+2 −19 os/common/ports/ARMv8-M-ML/chcore.h
+26 −17 os/common/ports/templates/chcore.h
+1 −1 os/hal/boards/ST_STM32H750XB_DISCOVERY/board.c
+19 −20 os/hal/boards/ST_STM32H750XB_DISCOVERY/board.h
+7 −7 os/hal/boards/ST_STM32H750XB_DISCOVERY/cfg/board.chcfg
+2 −2 os/hal/include/hal.h
+141 −198 os/hal/ports/STM32/LLD/FDCANv1/hal_can_lld.c
+40 −172 os/hal/ports/STM32/LLD/FDCANv1/hal_can_lld.h
+0 −217 os/hal/ports/STM32/LLD/FDCANv1/stm32_fdcan.h
+0 −9 os/hal/ports/STM32/LLD/FDCANv2/driver.mk
+0 −876 os/hal/ports/STM32/LLD/FDCANv2/hal_can_lld.c
+0 −615 os/hal/ports/STM32/LLD/FDCANv2/hal_can_lld.h
+0 −290 os/hal/ports/STM32/LLD/FDCANv2/stm32_fdcan.h
+0 −106 os/hal/ports/STM32/LLD/FDCANv2/stm32_fdcan1.inc
+0 −106 os/hal/ports/STM32/LLD/FDCANv2/stm32_fdcan2.inc
+0 −106 os/hal/ports/STM32/LLD/FDCANv2/stm32_fdcan3.inc
+2 −15 os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c
+2 −2 os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.c
+4 −4 os/hal/ports/STM32/LLD/USARTv3/hal_serial_lld.c
+2 −2 os/hal/ports/STM32/STM32F7xx/stm32_registry.h
+24 −0 os/hal/ports/STM32/STM32G4xx/stm32_registry.h
+1 −1 os/hal/ports/STM32/STM32H7xx/platform.mk
+1 −1 os/hal/ports/STM32/STM32H7xx/platform_type2.mk
+0 −3 os/hal/ports/STM32/STM32H7xx/stm32_isr.c
+0 −4 os/hal/ports/STM32/STM32H7xx/stm32_isr.h
+25 −2 os/hal/ports/STM32/STM32H7xx/stm32_registry.h
+2 −3 os/hal/src/hal_rtc.c
+1 −1 os/hal/src/hal_sdc.c
+2 −9 os/nil/include/ch.h
+6 −12 os/nil/src/ch.c
+829 −855 os/oslib/src/chfactory.c
+2 −2 os/rt/include/ch.h
+0 −7 os/rt/include/chport.h
+2 −8 os/rt/include/chsys.h
+3 −9 os/rt/src/chsys.c
+20 −16 os/rt/src/chthreads.c
+9 −28 os/various/lwip_bindings/arch/sys_arch.c
+0 −7 readme.txt
+1 −1 test/rt/configuration.xml
+0 −10 test/rt/source/test/rt_test_sequence_002.c
+0 −56 testhal/STM32/STM32G4xx/CAN/.cproject
+0 −38 testhal/STM32/STM32G4xx/CAN/.project
+0 −186 testhal/STM32/STM32G4xx/CAN/Makefile
+0 −817 testhal/STM32/STM32G4xx/CAN/cfg/chconf.h
+0 −553 testhal/STM32/STM32G4xx/CAN/cfg/halconf.h
+0 −406 testhal/STM32/STM32G4xx/CAN/cfg/mcuconf.h
+0 −163 testhal/STM32/STM32G4xx/CAN/main.c
+0 −37 testhal/STM32/STM32G4xx/CAN/readme.txt
+0 −55 testhal/STM32/STM32H7xx/CAN/.cproject
+0 −91 testhal/STM32/STM32H7xx/CAN/.project
+0 −188 testhal/STM32/STM32H7xx/CAN/Makefile
+0 −840 testhal/STM32/STM32H7xx/CAN/cfg/chconf.h
+0 −553 testhal/STM32/STM32H7xx/CAN/cfg/halconf.h
+0 −527 testhal/STM32/STM32H7xx/CAN/cfg/mcuconf.h
+0 −145 testhal/STM32/STM32H7xx/CAN/main.c
+0 −2 testhal/STM32/multi/USB_CDC/cfg/stm32h723zg_nucleo144/mcuconf.h
+0 −2 testhal/STM32/multi/WSPI-MFS/cfg/stm32h735ig_discovery/mcuconf.h
+0 −2 tools/ftl/processors/conf/mcuconf_stm32h723xx/mcuconf.h.ftl
2 changes: 1 addition & 1 deletion lib/chibios-contrib
Submodule chibios-contrib updated 261 files

0 comments on commit 60c9eab

Please sign in to comment.