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 minimal STM32F103C6 support #17853

Merged
merged 1 commit into from
Aug 11, 2022
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
6 changes: 6 additions & 0 deletions keyboards/handwired/onekey/bluepill_f103c6/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright 2022 Sergey Vlasov (@sigprof)
// SPDX-License-Identifier: GPL-2.0-or-later
#include_next <board.h>

#undef STM32F103xB
#define STM32F103x6
40 changes: 40 additions & 0 deletions keyboards/handwired/onekey/bluepill_f103c6/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* Copyright 2019
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "config_common.h"

#define PRODUCT Onekey Bluepill STM32F103C6

#define MATRIX_COL_PINS { B0 }
#define MATRIX_ROW_PINS { A7 }
#define UNUSED_PINS

#define BACKLIGHT_PIN A0
#define BACKLIGHT_PWM_DRIVER PWMD2
#define BACKLIGHT_PWM_CHANNEL 1

#define RGB_DI_PIN A1

#define ADC_PIN A0

// This code does not fit into the really small flash of STM32F103x6 together
// with CONSOLE_ENABLE=yes, and the debugging console is probably more
// important for the "okeney" testing firmware. In a real firmware you may be
// able to use these features if you keep the debugging console disabled.
#define NO_ACTION_LAYER
#define NO_ACTION_TAPPING
26 changes: 26 additions & 0 deletions keyboards/handwired/onekey/bluepill_f103c6/halconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* Copyright 2020 QMK
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/*
* This file was auto-generated by:
* `qmk chibios-confmigrate -i keyboards/handwired/onekey/bluepill/halconf.h -r platforms/chibios/common/configs/halconf.h`
*/

#pragma once

#define HAL_USE_PWM TRUE

#include_next <halconf.h>
30 changes: 30 additions & 0 deletions keyboards/handwired/onekey/bluepill_f103c6/mcuconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright 2020 QMK
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/*
* This file was auto-generated by:
* `qmk chibios-confmigrate -i keyboards/handwired/onekey/bluepill/mcuconf.h -r platforms/chibios/STM32_F103_STM32DUINO/configs/mcuconf.h`
*/

#pragma once

#include_next <mcuconf.h>

#undef STM32_PWM_USE_TIM2
#define STM32_PWM_USE_TIM2 TRUE

#undef STM32_SPI_USE_SPI2
#define STM32_SPI_USE_SPI2 FALSE
7 changes: 7 additions & 0 deletions keyboards/handwired/onekey/bluepill_f103c6/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# STM32F103C6xx Bluepill onekey

* Supported hardware: Bluepill boards with the STM32F103C**6**xx chips

Note that STM32F103C6xx chips have only 32 KiB of flash and 10 KiB of RAM, and the stm32duino bootloader occupies 8 KiB of flash, leaving only 24 KiB for the firmware, therefore the capabilities of this board are severely restricted in comparison to proper Bluepill boards with STM32F103CBxx or STM32F103C8xx chips (128 or 64 KiB of flash and 20 KiB of RAM). You may need to disable many features in the QMK firmware to bring its compiled size below 24 KiB. Please avoid designing new keyboards with these MCUs unless you are stuck with some hardware that you already have and don't want to just throw away.

To trigger keypress, short together pins *B0* and *A7*.
27 changes: 27 additions & 0 deletions keyboards/handwired/onekey/bluepill_f103c6/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# MCU name
MCU = STM32F103

# Bootloader selection
# Cannot use `BOOTLOADER = stm32duino` due to the need to override
# `MCU_LDSCRIPT`, therefore all parameters need to be specified here manually.
OPT_DEFS += -DBOOTLOADER_STM32DUINO
MCU_LDSCRIPT = STM32F103x6_stm32duino_bootloader
BOARD = STM32_F103_STM32DUINO
BOOTLOADER_TYPE = stm32duino
DFU_ARGS = -d 1EAF:0003 -a 2 -R
DFU_SUFFIX_ARGS = -v 1EAF -p 0003

# Enter lower-power sleep mode when on the ChibiOS idle thread
OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE

# LTO is required to fit the firmware into the available 24K of flash
LTO_ENABLE = yes

# Disable some features which still don't fit into flash even with LTO
MOUSEKEY_ENABLE = no
NKRO_ENABLE = no

# EEPROM emulation not supported yet (need to implement a proper firmware size
# check first, otherwise the chance of the EEPROM backing store overwriting
# some part of the firmware code is really high).
EEPROM_DRIVER = transient
2 changes: 2 additions & 0 deletions platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const PALConfig pal_default_config =
{VAL_GPIOBODR, VAL_GPIOBCRL, VAL_GPIOBCRH},
{VAL_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH},
{VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH},
# if STM32_HAS_GPIOE
{VAL_GPIOEODR, VAL_GPIOECRL, VAL_GPIOECRH},
# endif
};
#endif

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
* STM32F103x6 memory setup for use with the STM32Duino bootloader.
*/
f103_flash_size = 32k;
f103_ram_size = 10k;

INCLUDE stm32duino_bootloader_common.ld
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
* STM32F103x8 memory setup for use with the STM32Duino bootloader.
*/
f103_flash_size = 64k;
f103_ram_size = 20k;

INCLUDE stm32duino_bootloader_common.ld
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
* STM32F103xB memory setup for use with the STM32Duino bootloader.
*/
f103_flash_size = 128k;
f103_ram_size = 20k;

INCLUDE stm32duino_bootloader_common.ld
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ MEMORY
flash5 : org = 0x00000000, len = 0
flash6 : org = 0x00000000, len = 0
flash7 : org = 0x00000000, len = 0
ram0 : org = 0x20000000, len = 20k
ram0 : org = 0x20000000, len = f103_ram_size
ram1 : org = 0x00000000, len = 0
ram2 : org = 0x00000000, len = 0
ram3 : org = 0x00000000, len = 0
Expand Down