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

Initial support for SHIFT v2 #21756

Merged
merged 2 commits into from
Aug 21, 2023
Merged
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
54 changes: 54 additions & 0 deletions keyboards/drop/lib/common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2023 Massdrop, Inc.
// SPDX-License-Identifier: GPL-2.0-or-later
#ifdef RGB_MATRIX_ENABLE
# include "host.h"
# include "rgb_matrix.h"

# define LED_FLAG_ANY_SWITCH (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR)

# ifdef RGB_MATRIX_CAPS_LOCK_INDEX
bool rgb_matrix_indicators_kb(void) {
if (!rgb_matrix_indicators_user()) {
return false;
}

if (host_keyboard_led_state().caps_lock) {
rgb_matrix_set_color(RGB_MATRIX_CAPS_LOCK_INDEX, RGB_WHITE);
} else if ((rgb_matrix_get_flags() & LED_FLAG_ANY_SWITCH) == 0) {
rgb_matrix_set_color(RGB_MATRIX_CAPS_LOCK_INDEX, RGB_OFF);
}
return true;
}
# endif

# ifdef RGB_MATRIX_CYCLE_ZONES_ENABLE
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (!process_record_user(keycode, record)) {
return false;
}

if (!record->event.pressed) {
switch (keycode) {
case RGB_TOG:
switch (rgb_matrix_get_flags()) {
case LED_FLAG_ALL:
rgb_matrix_set_flags(LED_FLAG_ANY_SWITCH);
break;
case LED_FLAG_ANY_SWITCH:
rgb_matrix_set_flags(LED_FLAG_UNDERGLOW);
break;
case LED_FLAG_UNDERGLOW:
rgb_matrix_set_flags(LED_FLAG_NONE);
break;
default:
rgb_matrix_set_flags(LED_FLAG_ALL);
break;
}
return false;
}
}
return true;
};
# endif

#endif
94 changes: 94 additions & 0 deletions keyboards/drop/lib/mux.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Copyright 2023 Massdrop, Inc.
// SPDX-License-Identifier: GPL-2.0-or-later
#include "keyboard.h"
#include "analog.h"
#include "gpio.h"
#include "wait.h"

#define S_UP B12
#define E_UP_N B13
#define S_DN1 B14
#define E_DN1_N B15
#define E_VBUS_1 A8
#define E_VBUS_2 A15
#define SRC_1 B8
#define SRC_2 B9
#define HUB_RESET_N D2
#define IRST B1
#define SDB_N B2
#define C1_A5_SENSE A4
#define C1_B5_SENSE A7
#define C2_A5_SENSE C4
#define C2_B5_SENSE B0

static inline void digital_write(pin_t pin, uint8_t level) {
setPinOutput(pin);
writePin(pin, level);
}

uint16_t v_con_1 = 0;
uint16_t v_con_2 = 0;
uint16_t v_con_3 = 0;
uint16_t v_con_4 = 0;

void keyboard_USB_enable(void) {
// initial state
digital_write(S_UP, 0);
digital_write(E_UP_N, 1);
digital_write(S_DN1, 1);
digital_write(E_DN1_N, 1);
digital_write(E_VBUS_1, 0);
digital_write(E_VBUS_2, 0);
digital_write(SRC_1, 1);
digital_write(SRC_2, 1);

setPinInput(C1_A5_SENSE);
setPinInput(C1_B5_SENSE);
setPinInput(C2_A5_SENSE);
setPinInput(C2_B5_SENSE);

// reset hub
digital_write(HUB_RESET_N, 0);
wait_ms(100);
digital_write(HUB_RESET_N, 1);

wait_ms(500); // Allow power dissipation time on CC lines

v_con_1 = analogReadPin(C1_A5_SENSE);
v_con_2 = analogReadPin(C1_B5_SENSE);
v_con_3 = analogReadPin(C2_A5_SENSE);
v_con_4 = analogReadPin(C2_B5_SENSE);

// TODO: dynamic port port configure logic?
digital_write(E_UP_N, 0); // HOST enable
digital_write(E_DN1_N, 0); // EXTRA enable
digital_write(E_VBUS_1, 1); // USBC-1 enable full power I/O
digital_write(E_VBUS_2, 1); // USBC-2 enable full power I/O

if ((v_con_1 + v_con_2) > (v_con_3 + v_con_4)) {
digital_write(S_UP, 0); // HOST to USBC-1
digital_write(S_DN1, 1); // EXTRA to USBC-2
digital_write(SRC_1, 1); // HOST on USBC-1
digital_write(SRC_2, 0); // EXTRA available on USBC-2
} else {
digital_write(S_UP, 1); // EXTRA to USBC-1
digital_write(S_DN1, 0); // HOST to USBC-2
digital_write(SRC_1, 0); // EXTRA available on USBC-1
digital_write(SRC_2, 1); // HOST on USBC-2
}
}

void keyboard_ISSI_enable(void) {
#ifdef RGB_MATRIX_ENABLE
digital_write(IRST, 0);
digital_write(SDB_N, 1);
#endif
}


void keyboard_pre_init_kb(void) {
keyboard_USB_enable();
keyboard_ISSI_enable();

keyboard_pre_init_user();
}
22 changes: 22 additions & 0 deletions keyboards/drop/shift/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2023 Massdrop, Inc.
// SPDX-License-Identifier: GPL-2.0-or-later
#include QMK_KEYBOARD_H

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_1800_ansi(
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_HOME, KC_END, KC_PGUP, KC_PGDN,
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_NUM, KC_PSLS, KC_PAST, KC_PSCR,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_P7, KC_P8, KC_P9, KC_PMNS,
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6, KC_PPLS,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT
),
[1] = LAYOUT_1800_ansi(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, KC_MPLY, KC_MSTP, KC_VOLU, KC_MUTE,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, KC_VOLD, KC_SCRL,
_______, RGB_TOG, RGB_VAI, RGB_SPI, RGB_HUI, RGB_SAI, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_MOD, RGB_VAD, RGB_SPD, RGB_HUD, RGB_SAD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_M_P, RGB_M_B, RGB_M_R, RGB_M_SW,QK_BOOT, NK_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, EE_CLR, KC_APP, _______, _______, _______, _______, _______, _______
)
};
5 changes: 5 additions & 0 deletions keyboards/drop/shift/keymaps/via/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright 2023 Massdrop, Inc.
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#define DYNAMIC_KEYMAP_LAYER_COUNT 8
22 changes: 22 additions & 0 deletions keyboards/drop/shift/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2023 Massdrop, Inc.
// SPDX-License-Identifier: GPL-2.0-or-later
#include QMK_KEYBOARD_H

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_1800_ansi(
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_HOME, KC_END, KC_PGUP, KC_PGDN,
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_NUM, KC_PSLS, KC_PAST, KC_PSCR,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_P7, KC_P8, KC_P9, KC_PMNS,
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6, KC_PPLS,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT
),
[1] = LAYOUT_1800_ansi(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, KC_MPLY, KC_MSTP, KC_VOLU, KC_MUTE,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, KC_VOLD, KC_SCRL,
_______, RGB_TOG, RGB_VAI, RGB_SPI, RGB_HUI, RGB_SAI, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_MOD, RGB_VAD, RGB_SPD, RGB_HUD, RGB_SAD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_M_P, RGB_M_B, RGB_M_R, RGB_M_SW,QK_BOOT, NK_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, EE_CLR, KC_APP, _______, _______, _______, _______, _______, _______
)
};
1 change: 1 addition & 0 deletions keyboards/drop/shift/keymaps/via/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VIA_ENABLE = yes
8 changes: 8 additions & 0 deletions keyboards/drop/shift/v2/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2023 Massdrop, Inc.
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include_next <board.h>

#undef STM32_HSECLK
#define STM32_HSECLK 16000000U
29 changes: 29 additions & 0 deletions keyboards/drop/shift/v2/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2023 Massdrop, Inc.
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#define ADC_BUFFER_DEPTH 4
#define ADC_SAMPLING_RATE ADC_SMPR_SMP_601P5
#define ADC_RESOLUTION ADC_CFGR_RES_12BITS

#define I2C_DRIVER I2CD2
#define I2C1_SCL_PIN A9
#define I2C1_SDA_PIN A10

#define EXTERNAL_EEPROM_I2C_BASE_ADDRESS 0b10101000
#define EXTERNAL_EEPROM_WP_PIN B5
#define EEPROM_I2C_24LC256

#define DRIVER_ADDR_1 0b1010011
#define DRIVER_ADDR_2 0b1011111
#define DRIVER_ADDR_3 0b1010000
#define DRIVER_COUNT 3
#define RGB_MATRIX_LED_COUNT 166
#define ISSI_PWM_FREQUENCY 0b010 // 26k

#define RGB_DISABLE_WHEN_USB_SUSPENDED
#define RGB_MATRIX_DEFAULT_VAL 100
#define RGB_MATRIX_KEYPRESSES
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS

#define RGB_MATRIX_CYCLE_ZONES_ENABLE
8 changes: 8 additions & 0 deletions keyboards/drop/shift/v2/halconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2023 Massdrop, Inc.
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#define HAL_USE_ADC TRUE
#define HAL_USE_I2C TRUE

#include_next <halconf.h>
Loading