From 9435ad19eedba9e56fa6a33989bc5c788f080e54 Mon Sep 17 00:00:00 2001 From: Joy Lee Date: Tue, 1 Nov 2022 12:04:15 +0800 Subject: Added analog support for WB32 MCU. (#18289) Co-authored-by: Joy --- keyboards/handwired/onekey/evb_wb32f3g71/config.h | 25 ++++++++++++++++++++++ keyboards/handwired/onekey/evb_wb32f3g71/halconf.h | 11 ++++++++++ keyboards/handwired/onekey/evb_wb32f3g71/info.json | 6 ++++++ keyboards/handwired/onekey/evb_wb32f3g71/mcuconf.h | 17 +++++++++++++++ keyboards/handwired/onekey/evb_wb32f3g71/rules.mk | 4 +--- keyboards/handwired/onekey/evb_wb32fq95/config.h | 25 ++++++++++++++++++++++ keyboards/handwired/onekey/evb_wb32fq95/halconf.h | 11 ++++++++++ keyboards/handwired/onekey/evb_wb32fq95/info.json | 6 ++++++ keyboards/handwired/onekey/evb_wb32fq95/mcuconf.h | 17 +++++++++++++++ keyboards/handwired/onekey/evb_wb32fq95/rules.mk | 4 +--- platforms/chibios/drivers/analog.c | 12 +++++------ 11 files changed, 126 insertions(+), 12 deletions(-) create mode 100644 keyboards/handwired/onekey/evb_wb32f3g71/config.h create mode 100644 keyboards/handwired/onekey/evb_wb32f3g71/halconf.h create mode 100644 keyboards/handwired/onekey/evb_wb32f3g71/mcuconf.h create mode 100644 keyboards/handwired/onekey/evb_wb32fq95/config.h create mode 100644 keyboards/handwired/onekey/evb_wb32fq95/halconf.h create mode 100644 keyboards/handwired/onekey/evb_wb32fq95/mcuconf.h diff --git a/keyboards/handwired/onekey/evb_wb32f3g71/config.h b/keyboards/handwired/onekey/evb_wb32f3g71/config.h new file mode 100644 index 0000000000..d1f87b4e3e --- /dev/null +++ b/keyboards/handwired/onekey/evb_wb32f3g71/config.h @@ -0,0 +1,25 @@ +// Copyright 2022 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "config_common.h" + +#define ADC_PIN A0 + +#define BACKLIGHT_PWM_DRIVER PWMD4 +#define BACKLIGHT_PWM_CHANNEL 3 +#define BACKLIGHT_PAL_MODE 2 + +#define APA102_NOPS (100 / (1000000000L / (CPU_CLOCK / 4))) +#define RGB_CI_PIN B8 + +#define SOLENOID_PIN B12 +#define SOLENOID_PINS { B12, B13, B14, B15 } +#define SOLENOID_PINS_ACTIVE_STATE { high, high, low } + +#define I2C1_SDA_PIN B7 +#define I2C1_SCL_PIN B6 +#define I2C1_SCL_PAL_MODE 4 +#define I2C1_OPMODE OPMODE_I2C +#define I2C1_CLOCK_SPEED 100000 diff --git a/keyboards/handwired/onekey/evb_wb32f3g71/halconf.h b/keyboards/handwired/onekey/evb_wb32f3g71/halconf.h new file mode 100644 index 0000000000..f0cf0a179f --- /dev/null +++ b/keyboards/handwired/onekey/evb_wb32f3g71/halconf.h @@ -0,0 +1,11 @@ +// Copyright 2022 QMK +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#define HAL_USE_ADC TRUE + +#define HAL_USE_I2C TRUE + +#define HAL_USE_PWM TRUE + +#include_next diff --git a/keyboards/handwired/onekey/evb_wb32f3g71/info.json b/keyboards/handwired/onekey/evb_wb32f3g71/info.json index 6287cdc34a..304517d266 100644 --- a/keyboards/handwired/onekey/evb_wb32f3g71/info.json +++ b/keyboards/handwired/onekey/evb_wb32f3g71/info.json @@ -5,5 +5,11 @@ "matrix_pins": { "cols": ["B12"], "rows": ["B13"] + }, + "backlight": { + "pin": "B8" + }, + "rgblight": { + "pin": "A0" } } diff --git a/keyboards/handwired/onekey/evb_wb32f3g71/mcuconf.h b/keyboards/handwired/onekey/evb_wb32f3g71/mcuconf.h new file mode 100644 index 0000000000..7ef36ff66c --- /dev/null +++ b/keyboards/handwired/onekey/evb_wb32f3g71/mcuconf.h @@ -0,0 +1,17 @@ +// Copyright 2022 QMK +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include_next "mcuconf.h" + +#undef WB32_ADC_USE_ADC1 +#define WB32_ADC_USE_ADC1 TRUE + +#undef WB32_DMA_REQUIRED +#define WB32_DMA_REQUIRED TRUE + +#undef WB32_I2C_USE_I2C1 +#define WB32_I2C_USE_I2C1 TRUE + +#undef WB32_PWM_USE_TIM4 +#define WB32_PWM_USE_TIM4 TRUE diff --git a/keyboards/handwired/onekey/evb_wb32f3g71/rules.mk b/keyboards/handwired/onekey/evb_wb32f3g71/rules.mk index 033dd66aa4..1071cf62ee 100644 --- a/keyboards/handwired/onekey/evb_wb32f3g71/rules.mk +++ b/keyboards/handwired/onekey/evb_wb32f3g71/rules.mk @@ -1,3 +1 @@ -MOUSEKEY_ENABLE = no # Mouse keys -EXTRAKEY_ENABLE = no # Audio control and System control -NKRO_ENABLE = no # Enable N-Key Rollover +KEYBOARD_SHARED_EP = yes diff --git a/keyboards/handwired/onekey/evb_wb32fq95/config.h b/keyboards/handwired/onekey/evb_wb32fq95/config.h new file mode 100644 index 0000000000..d1f87b4e3e --- /dev/null +++ b/keyboards/handwired/onekey/evb_wb32fq95/config.h @@ -0,0 +1,25 @@ +// Copyright 2022 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "config_common.h" + +#define ADC_PIN A0 + +#define BACKLIGHT_PWM_DRIVER PWMD4 +#define BACKLIGHT_PWM_CHANNEL 3 +#define BACKLIGHT_PAL_MODE 2 + +#define APA102_NOPS (100 / (1000000000L / (CPU_CLOCK / 4))) +#define RGB_CI_PIN B8 + +#define SOLENOID_PIN B12 +#define SOLENOID_PINS { B12, B13, B14, B15 } +#define SOLENOID_PINS_ACTIVE_STATE { high, high, low } + +#define I2C1_SDA_PIN B7 +#define I2C1_SCL_PIN B6 +#define I2C1_SCL_PAL_MODE 4 +#define I2C1_OPMODE OPMODE_I2C +#define I2C1_CLOCK_SPEED 100000 diff --git a/keyboards/handwired/onekey/evb_wb32fq95/halconf.h b/keyboards/handwired/onekey/evb_wb32fq95/halconf.h new file mode 100644 index 0000000000..f0cf0a179f --- /dev/null +++ b/keyboards/handwired/onekey/evb_wb32fq95/halconf.h @@ -0,0 +1,11 @@ +// Copyright 2022 QMK +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#define HAL_USE_ADC TRUE + +#define HAL_USE_I2C TRUE + +#define HAL_USE_PWM TRUE + +#include_next diff --git a/keyboards/handwired/onekey/evb_wb32fq95/info.json b/keyboards/handwired/onekey/evb_wb32fq95/info.json index 3fc1c88657..bbf5139668 100644 --- a/keyboards/handwired/onekey/evb_wb32fq95/info.json +++ b/keyboards/handwired/onekey/evb_wb32fq95/info.json @@ -5,5 +5,11 @@ "matrix_pins": { "cols": ["B12"], "rows": ["B13"] + }, + "backlight": { + "pin": "B8" + }, + "rgblight": { + "pin": "A0" } } diff --git a/keyboards/handwired/onekey/evb_wb32fq95/mcuconf.h b/keyboards/handwired/onekey/evb_wb32fq95/mcuconf.h new file mode 100644 index 0000000000..7ef36ff66c --- /dev/null +++ b/keyboards/handwired/onekey/evb_wb32fq95/mcuconf.h @@ -0,0 +1,17 @@ +// Copyright 2022 QMK +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include_next "mcuconf.h" + +#undef WB32_ADC_USE_ADC1 +#define WB32_ADC_USE_ADC1 TRUE + +#undef WB32_DMA_REQUIRED +#define WB32_DMA_REQUIRED TRUE + +#undef WB32_I2C_USE_I2C1 +#define WB32_I2C_USE_I2C1 TRUE + +#undef WB32_PWM_USE_TIM4 +#define WB32_PWM_USE_TIM4 TRUE diff --git a/keyboards/handwired/onekey/evb_wb32fq95/rules.mk b/keyboards/handwired/onekey/evb_wb32fq95/rules.mk index 033dd66aa4..1071cf62ee 100644 --- a/keyboards/handwired/onekey/evb_wb32fq95/rules.mk +++ b/keyboards/handwired/onekey/evb_wb32fq95/rules.mk @@ -1,3 +1 @@ -MOUSEKEY_ENABLE = no # Mouse keys -EXTRAKEY_ENABLE = no # Audio control and System control -NKRO_ENABLE = no # Enable N-Key Rollover +KEYBOARD_SHARED_EP = yes diff --git a/platforms/chibios/drivers/analog.c b/platforms/chibios/drivers/analog.c index a7b7ec76d7..8b03e73849 100644 --- a/platforms/chibios/drivers/analog.c +++ b/platforms/chibios/drivers/analog.c @@ -22,7 +22,7 @@ # error "You need to set HAL_USE_ADC to TRUE in your halconf.h to use the ADC." #endif -#if !STM32_ADC_USE_ADC1 && !STM32_ADC_USE_ADC2 && !STM32_ADC_USE_ADC3 && !STM32_ADC_USE_ADC4 +#if !STM32_ADC_USE_ADC1 && !STM32_ADC_USE_ADC2 && !STM32_ADC_USE_ADC3 && !STM32_ADC_USE_ADC4 && !WB32_ADC_USE_ADC1 # error "You need to set one of the 'STM32_ADC_USE_ADCx' settings to TRUE in your mcuconf.h to use the ADC." #endif @@ -37,7 +37,7 @@ // Otherwise assume V3 #if defined(STM32F0XX) || defined(STM32L0XX) # define USE_ADCV1 -#elif defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) || defined(GD32VF103) +#elif defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) || defined(GD32VF103) || defined(WB32F3G71xx) || defined(WB32FQ95xx) # define USE_ADCV2 #endif @@ -74,7 +74,7 @@ /* User configurable ADC options */ #ifndef ADC_COUNT -# if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F4XX) || defined(GD32VF103) +# if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F4XX) || defined(GD32VF103) || defined(WB32F3G71xx) || defined(WB32FQ95xx) # define ADC_COUNT 1 # elif defined(STM32F3XX) # define ADC_COUNT 4 @@ -121,7 +121,7 @@ static ADCConversionGroup adcConversionGroup = { .cfgr1 = ADC_CFGR1_CONT | ADC_RESOLUTION, .smpr = ADC_SAMPLING_RATE, #elif defined(USE_ADCV2) -# if !defined(STM32F1XX) && !defined(GD32VF103) +# if !defined(STM32F1XX) && !defined(GD32VF103) && !defined(WB32F3G71xx) && !defined(WB32FQ95xx) .cr2 = ADC_CR2_SWSTART, // F103 seem very unhappy with, F401 seems very unhappy without... # endif .smpr2 = ADC_SMPR2_SMP_AN0(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN1(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN2(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN3(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN4(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN5(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN6(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN7(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN8(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN9(ADC_SAMPLING_RATE), @@ -219,7 +219,7 @@ __attribute__((weak)) adc_mux pinToMux(pin_t pin) { case F9: return TO_MUX( ADC_CHANNEL_IN7, 2 ); case F10: return TO_MUX( ADC_CHANNEL_IN8, 2 ); # endif -#elif defined(STM32F1XX) || defined(GD32VF103) +#elif defined(STM32F1XX) || defined(GD32VF103) || defined(WB32F3G71xx) || defined(WB32FQ95xx) case A0: return TO_MUX( ADC_CHANNEL_IN0, 0 ); case A1: return TO_MUX( ADC_CHANNEL_IN1, 0 ); case A2: return TO_MUX( ADC_CHANNEL_IN2, 0 ); @@ -248,7 +248,7 @@ __attribute__((weak)) adc_mux pinToMux(pin_t pin) { static inline ADCDriver* intToADCDriver(uint8_t adcInt) { switch (adcInt) { -#if STM32_ADC_USE_ADC1 +#if STM32_ADC_USE_ADC1 || WB32_ADC_USE_ADC1 case 0: return &ADCD1; #endif -- cgit v1.2.3