Refactor CTPC logic to allow future converters (#16621)

* Refactor CTPC logic to allow future converters

* Update builddefs/converters.mk

Co-authored-by: Stefan Kerkmann <karlk90@pm.me>

Co-authored-by: Stefan Kerkmann <karlk90@pm.me>
This commit is contained in:
Joel Challis 2022-04-03 18:22:52 +01:00 committed by GitHub
parent e6a7e7ac8e
commit 1660b2d2e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 330 additions and 311 deletions

View File

@ -172,13 +172,7 @@ generated-files: $(KEYMAP_OUTPUT)/src/config.h $(KEYMAP_OUTPUT)/src/keymap.c
endif
ifeq ($(strip $(CTPC)), yes)
CONVERT_TO_PROTON_C=yes
endif
ifeq ($(strip $(CONVERT_TO_PROTON_C)), yes)
include platforms/chibios/boards/QMK_PROTON_C/convert_to_proton_c.mk
endif
include $(BUILDDEFS_PATH)/converters.mk
include $(BUILDDEFS_PATH)/mcu_selection.mk

26
builddefs/converters.mk Normal file
View File

@ -0,0 +1,26 @@
ifeq ($(strip $(CTPC)), yes)
CONVERT_TO_PROTON_C=yes
endif
ifeq ($(strip $(CONVERT_TO_PROTON_C)), yes)
CONVERT_TO=proton_c
endif
# TODO: opt in rather than assume everything uses a pro micro
PIN_COMPATIBLE ?= promicro
ifneq ($(CONVERT_TO),)
# glob to search each platfrorm and/or check for valid converter
CONVERTER := $(wildcard $(PLATFORM_PATH)/*/converters/$(PIN_COMPATIBLE)_to_$(CONVERT_TO)/)
ifeq ($(CONVERTER),)
$(call CATASTROPHIC_ERROR,Converting from '$(PIN_COMPATIBLE)' to '$(CONVERT_TO)' not possible!)
endif
TARGET := $(TARGET)_$(CONVERT_TO)
# Configure any defaults
OPT_DEFS += -DCONVERT_TO_$(strip $(shell echo $(CONVERT_TO) | tr '[:lower:]' '[:upper:]'))
OPT_DEFS += -DCONVERTER_ENABLED
VPATH += $(CONVERTER)
# Finally run any converter specific logic
include $(CONVERTER)/converter.mk
endif

View File

@ -21,45 +21,6 @@
# include <hal.h>
#endif
// Defines mapping for Proton C replacement
#ifdef CONVERT_TO_PROTON_C
// Left side (front)
# define D3 PAL_LINE(GPIOA, 9)
# define D2 PAL_LINE(GPIOA, 10)
// GND
// GND
# define D1 PAL_LINE(GPIOB, 7)
# define D0 PAL_LINE(GPIOB, 6)
# define D4 PAL_LINE(GPIOB, 5)
# define C6 PAL_LINE(GPIOB, 4)
# define D7 PAL_LINE(GPIOB, 3)
# define E6 PAL_LINE(GPIOB, 2)
# define B4 PAL_LINE(GPIOB, 1)
# define B5 PAL_LINE(GPIOB, 0)
// Right side (front)
// RAW
// GND
// RESET
// VCC
# define F4 PAL_LINE(GPIOA, 2)
# define F5 PAL_LINE(GPIOA, 1)
# define F6 PAL_LINE(GPIOA, 0)
# define F7 PAL_LINE(GPIOB, 8)
# define B1 PAL_LINE(GPIOB, 13)
# define B3 PAL_LINE(GPIOB, 14)
# define B2 PAL_LINE(GPIOB, 15)
# define B6 PAL_LINE(GPIOB, 9)
// LEDs (only D5/C13 uses an actual LED)
# ifdef CONVERT_TO_PROTON_C_RXLED
# define D5 PAL_LINE(GPIOC, 14)
# define B0 PAL_LINE(GPIOC, 13)
# else
# define D5 PAL_LINE(GPIOC, 13)
# define B0 PAL_LINE(GPIOC, 14)
# endif
#else
#define A0 PAL_LINE(GPIOA, 0)
#define A1 PAL_LINE(GPIOA, 1)
#define A2 PAL_LINE(GPIOA, 2)
@ -326,4 +287,3 @@
# define K14 PAL_LINE(GPIOK, 14)
# define K15 PAL_LINE(GPIOK, 15)
#endif
#endif

View File

@ -0,0 +1,41 @@
// Copyright 2022 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
// Left side (front)
#define D3 PAL_LINE(GPIOA, 9)
#define D2 PAL_LINE(GPIOA, 10)
// GND
// GND
#define D1 PAL_LINE(GPIOB, 7)
#define D0 PAL_LINE(GPIOB, 6)
#define D4 PAL_LINE(GPIOB, 5)
#define C6 PAL_LINE(GPIOB, 4)
#define D7 PAL_LINE(GPIOB, 3)
#define E6 PAL_LINE(GPIOB, 2)
#define B4 PAL_LINE(GPIOB, 1)
#define B5 PAL_LINE(GPIOB, 0)
// Right side (front)
// RAW
// GND
// RESET
// VCC
#define F4 PAL_LINE(GPIOA, 2)
#define F5 PAL_LINE(GPIOA, 1)
#define F6 PAL_LINE(GPIOA, 0)
#define F7 PAL_LINE(GPIOB, 8)
#define B1 PAL_LINE(GPIOB, 13)
#define B3 PAL_LINE(GPIOB, 14)
#define B2 PAL_LINE(GPIOB, 15)
#define B6 PAL_LINE(GPIOB, 9)
// LEDs (only D5/C13 uses an actual LED)
#ifdef CONVERT_TO_PROTON_C_RXLED
# define D5 PAL_LINE(GPIOC, 14)
# define B0 PAL_LINE(GPIOC, 13)
#else
# define D5 PAL_LINE(GPIOC, 13)
# define B0 PAL_LINE(GPIOC, 14)
#endif

View File

@ -1,9 +1,7 @@
# Proton C MCU settings for converting AVR projects
TARGET := $(TARGET)_proton_c
MCU := STM32F303
BOARD := QMK_PROTON_C
BOOTLOADER := stm32-dfu
OPT_DEFS += -DCONVERT_TO_PROTON_C
# These are defaults based on what has been implemented for ARM boards
AUDIO_ENABLE ?= yes