Merge remote-tracking branch 'qmk/master' into merge-2023-03-12
This commit is contained in:
commit
06a2fdcc9c
19466 changed files with 296791 additions and 222541 deletions
48
platforms/arm_atsam/bootloader.mk
Normal file
48
platforms/arm_atsam/bootloader.mk
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# Copyright 2017 Jack Humbert
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
# If it's possible that multiple bootloaders can be used for one project,
|
||||
# you can leave this unset, and the correct size will be selected
|
||||
# automatically.
|
||||
#
|
||||
# Sets the bootloader defined in the keyboard's/keymap's rules.mk
|
||||
#
|
||||
# Current options for ARM (ATSAM):
|
||||
# md-boot Atmel SAM-BA (only used by Drop boards)
|
||||
#
|
||||
# If you need to provide your own implementation, you can set inside `rules.mk`
|
||||
# `BOOTLOADER = custom` -- you'll need to provide your own implementations. See
|
||||
# the respective file under `platforms/<PLATFORM>/bootloaders/custom.c` to see
|
||||
# which functions may be overridden.
|
||||
|
||||
FIRMWARE_FORMAT?=bin
|
||||
|
||||
ifeq ($(strip $(BOOTLOADER)), custom)
|
||||
OPT_DEFS += -DBOOTLOADER_CUSTOM
|
||||
BOOTLOADER_TYPE = custom
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(BOOTLOADER)), md-boot)
|
||||
OPT_DEFS += -DBOOTLOADER_MD_BOOT
|
||||
BOOTLOADER_TYPE = md_boot
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(BOOTLOADER_TYPE)),)
|
||||
ifneq ($(strip $(BOOTLOADER)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,Invalid bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
|
||||
else
|
||||
$(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,No bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
|
||||
endif
|
||||
endif
|
||||
|
|
@ -13,6 +13,7 @@ mdloader: bin
|
|||
$(call EXEC_MDLOADER)
|
||||
|
||||
flash: bin
|
||||
$(SILENT) || printf "Flashing for bootloader: $(BLUE)$(BOOTLOADER)$(NO_COLOR)\n"
|
||||
ifneq ($(strip $(PROGRAM_CMD)),)
|
||||
$(UNSYNC_OUTPUT_CMD) && $(PROGRAM_CMD)
|
||||
else ifeq ($(strip $(ARM_ATSAM)),SAMD51J18A)
|
||||
|
|
|
|||
|
|
@ -24,9 +24,13 @@
|
|||
# define ATOMIC_BLOCK _Static_assert(0, "ATOMIC_BLOCK not implemented")
|
||||
# define ATOMIC_BLOCK_RESTORESTATE _Static_assert(0, "ATOMIC_BLOCK_RESTORESTATE not implemented")
|
||||
# define ATOMIC_BLOCK_FORCEON _Static_assert(0, "ATOMIC_BLOCK_FORCEON not implemented")
|
||||
# define ATOMIC_FORCEON _Static_assert(0, "ATOMIC_FORCEON not implemented")
|
||||
# define ATOMIC_RESTORESTATE _Static_assert(0, "ATOMIC_RESTORESTATE not implemented")
|
||||
# endif
|
||||
#else /* do nothing atomic macro */
|
||||
# define ATOMIC_BLOCK for (uint8_t __ToDo = 1; __ToDo; __ToDo = 0)
|
||||
# define ATOMIC_BLOCK_RESTORESTATE ATOMIC_BLOCK
|
||||
# define ATOMIC_BLOCK_FORCEON ATOMIC_BLOCK
|
||||
# define ATOMIC_BLOCK(t) for (uint8_t __ToDo = 1; __ToDo; __ToDo = 0)
|
||||
# define ATOMIC_FORCEON
|
||||
# define ATOMIC_RESTORESTATE
|
||||
# define ATOMIC_BLOCK_RESTORESTATE ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
|
||||
# define ATOMIC_BLOCK_FORCEON ATOMIC_BLOCK(ATOMIC_FORCEON)
|
||||
#endif
|
||||
|
|
|
|||
146
platforms/avr/bootloader.mk
Normal file
146
platforms/avr/bootloader.mk
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
# Copyright 2017 Jack Humbert
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
# If it's possible that multiple bootloaders can be used for one project,
|
||||
# you can leave this unset, and the correct size will be selected
|
||||
# automatically.
|
||||
#
|
||||
# Sets the bootloader defined in the keyboard's/keymap's rules.mk
|
||||
#
|
||||
# Current options for AVR:
|
||||
# halfkay PJRC Teensy
|
||||
# caterina Pro Micro (Sparkfun/generic)
|
||||
# atmel-dfu Atmel factory DFU
|
||||
# lufa-dfu LUFA DFU
|
||||
# qmk-dfu QMK DFU (LUFA + blinkenlight)
|
||||
# qmk-hid QMK HID (LUFA + blinkenlight)
|
||||
# bootloadhid HIDBootFlash compatible (ATmega32A)
|
||||
# usbasploader USBaspLoader (ATmega328P)
|
||||
#
|
||||
# If you need to provide your own implementation, you can set inside `rules.mk`
|
||||
# `BOOTLOADER = custom` -- you'll need to provide your own implementations. See
|
||||
# the respective file under `platforms/<PLATFORM>/bootloaders/custom.c` to see
|
||||
# which functions may be overridden.
|
||||
#
|
||||
# BOOTLOADER_SIZE can still be defined manually, but it's recommended
|
||||
# you add any possible configuration to this list
|
||||
|
||||
FIRMWARE_FORMAT?=hex
|
||||
|
||||
ifeq ($(strip $(BOOTLOADER)), custom)
|
||||
OPT_DEFS += -DBOOTLOADER_CUSTOM
|
||||
BOOTLOADER_TYPE = custom
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(BOOTLOADER)), atmel-dfu)
|
||||
OPT_DEFS += -DBOOTLOADER_ATMEL_DFU
|
||||
OPT_DEFS += -DBOOTLOADER_DFU
|
||||
BOOTLOADER_TYPE = dfu
|
||||
|
||||
ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
|
||||
BOOTLOADER_SIZE = 4096
|
||||
endif
|
||||
ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
|
||||
BOOTLOADER_SIZE = 8192
|
||||
endif
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), lufa-dfu)
|
||||
OPT_DEFS += -DBOOTLOADER_LUFA_DFU
|
||||
OPT_DEFS += -DBOOTLOADER_DFU
|
||||
BOOTLOADER_TYPE = dfu
|
||||
|
||||
ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
|
||||
BOOTLOADER_SIZE ?= 4096
|
||||
endif
|
||||
ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
|
||||
BOOTLOADER_SIZE ?= 8192
|
||||
endif
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), qmk-dfu)
|
||||
OPT_DEFS += -DBOOTLOADER_QMK_DFU
|
||||
OPT_DEFS += -DBOOTLOADER_DFU
|
||||
BOOTLOADER_TYPE = dfu
|
||||
|
||||
ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
|
||||
BOOTLOADER_SIZE ?= 4096
|
||||
endif
|
||||
ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
|
||||
BOOTLOADER_SIZE ?= 8192
|
||||
endif
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), qmk-hid)
|
||||
OPT_DEFS += -DBOOTLOADER_QMK_HID
|
||||
OPT_DEFS += -DBOOTLOADER_HID
|
||||
BOOTLOADER_TYPE = dfu
|
||||
|
||||
BOOTLOADER_SIZE ?= 4096
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), halfkay)
|
||||
OPT_DEFS += -DBOOTLOADER_HALFKAY
|
||||
BOOTLOADER_TYPE = halfkay
|
||||
|
||||
# Teensy 2.0
|
||||
ifeq ($(strip $(MCU)), atmega32u4)
|
||||
BOOTLOADER_SIZE = 512
|
||||
endif
|
||||
# Teensy 2.0++
|
||||
ifeq ($(strip $(MCU)), at90usb1286)
|
||||
BOOTLOADER_SIZE = 1024
|
||||
endif
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), caterina)
|
||||
OPT_DEFS += -DBOOTLOADER_CATERINA
|
||||
BOOTLOADER_TYPE = caterina
|
||||
|
||||
BOOTLOADER_SIZE = 4096
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), bootloadhid)
|
||||
OPT_DEFS += -DBOOTLOADER_BOOTLOADHID
|
||||
BOOTLOADER_TYPE = bootloadhid
|
||||
|
||||
BOOTLOADER_SIZE = 4096
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), usbasploader)
|
||||
OPT_DEFS += -DBOOTLOADER_USBASP
|
||||
BOOTLOADER_TYPE = usbasploader
|
||||
|
||||
BOOTLOADER_SIZE = 4096
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), lufa-ms)
|
||||
OPT_DEFS += -DBOOTLOADER_MS
|
||||
BOOTLOADER_TYPE = dfu
|
||||
|
||||
BOOTLOADER_SIZE ?= 8192
|
||||
FIRMWARE_FORMAT = bin
|
||||
cpfirmware: lufa_warning
|
||||
.INTERMEDIATE: lufa_warning
|
||||
lufa_warning: $(FIRMWARE_FORMAT)
|
||||
$(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@)
|
||||
$(info LUFA MASS STORAGE Bootloader selected)
|
||||
$(info DO NOT USE THIS BOOTLOADER IN NEW PROJECTS!)
|
||||
$(info It is extremely prone to bricking, and is only included to support existing boards.)
|
||||
$(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@)
|
||||
endif
|
||||
ifdef BOOTLOADER_SIZE
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=$(strip $(BOOTLOADER_SIZE))
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(BOOTLOADER_TYPE)),)
|
||||
ifneq ($(strip $(BOOTLOADER)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,Invalid bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
|
||||
else
|
||||
$(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,No bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
|
||||
endif
|
||||
endif
|
||||
|
|
@ -217,7 +217,7 @@ void channel_2_stop(void) {
|
|||
}
|
||||
#endif
|
||||
|
||||
void audio_driver_initialize() {
|
||||
void audio_driver_initialize(void) {
|
||||
#ifdef AUDIO1_PIN_SET
|
||||
channel_1_stop();
|
||||
setPinOutput(AUDIO1_PIN);
|
||||
|
|
@ -258,7 +258,7 @@ void audio_driver_initialize() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void audio_driver_stop() {
|
||||
void audio_driver_stop(void) {
|
||||
#ifdef AUDIO1_PIN_SET
|
||||
channel_1_stop();
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ AVRDUDE_PROGRAMMER ?= avrdude
|
|||
define EXEC_AVRDUDE
|
||||
list_devices() { \
|
||||
if $(GREP) -q -s icrosoft /proc/version; then \
|
||||
wmic.exe path Win32_SerialPort get DeviceID 2>/dev/null | LANG=C perl -pne 's/COM(\d+)/COM.($$1-1)/e' | sed 's!COM!/dev/ttyS!' | xargs echo -n | sort; \
|
||||
powershell.exe 'Get-CimInstance -Class Win32_SerialPort | Select -ExpandProperty "DeviceID"' 2>/dev/null | sed -e "s/\r//g" | LANG=C perl -pne 's/COM(\d+)/COM.($$1-1)/e' | sed 's!COM!/dev/ttyS!' | sort; \
|
||||
elif [ "`uname`" = "FreeBSD" ]; then \
|
||||
ls /dev/tty* | grep -v '\.lock$$' | grep -v '\.init$$'; \
|
||||
else \
|
||||
|
|
@ -168,7 +168,8 @@ endef
|
|||
hid_bootloader: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
|
||||
$(call EXEC_HID_LUFA)
|
||||
|
||||
flash: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
|
||||
flash: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
|
||||
$(SILENT) || printf "Flashing for bootloader: $(BLUE)$(BOOTLOADER)$(NO_COLOR)\n"
|
||||
ifneq ($(strip $(PROGRAM_CMD)),)
|
||||
$(UNSYNC_OUTPUT_CMD) && $(PROGRAM_CMD)
|
||||
else ifeq ($(strip $(BOOTLOADER)), caterina)
|
||||
|
|
@ -177,9 +178,9 @@ else ifeq ($(strip $(BOOTLOADER)), halfkay)
|
|||
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_TEENSY)
|
||||
else ifeq (dfu,$(findstring dfu,$(BOOTLOADER)))
|
||||
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU)
|
||||
else ifneq (,$(filter $(BOOTLOADER), usbasploader USBasp))
|
||||
else ifeq ($(strip $(BOOTLOADER)), usbasploader)
|
||||
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_USBASP)
|
||||
else ifneq (,$(filter $(BOOTLOADER), bootloadhid bootloadHID))
|
||||
else ifeq ($(strip $(BOOTLOADER)), bootloadhid)
|
||||
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_BOOTLOADHID)
|
||||
else ifeq ($(strip $(BOOTLOADER)), qmk-hid)
|
||||
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_HID_LUFA)
|
||||
|
|
|
|||
95
platforms/avr/mcu_selection.mk
Normal file
95
platforms/avr/mcu_selection.mk
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
ifneq (,$(filter $(MCU),at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647 at90usb1286 at90usb1287))
|
||||
PROTOCOL = LUFA
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU ?= 16000000
|
||||
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB ?= $(F_CPU)
|
||||
|
||||
# Interrupt driven control endpoint task
|
||||
ifeq (,$(filter $(NO_INTERRUPT_CONTROL_ENDPOINT),yes))
|
||||
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
endif
|
||||
ifneq (,$(filter $(MCU),at90usb162 atmega16u2 atmega32u2))
|
||||
NO_I2C = yes
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(MCU),atmega32a))
|
||||
# MCU name for avrdude
|
||||
AVRDUDE_MCU = m32
|
||||
|
||||
PROTOCOL = VUSB
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
F_CPU ?= 12000000
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(MCU),atmega328p))
|
||||
# MCU name for avrdude
|
||||
AVRDUDE_MCU = m328p
|
||||
|
||||
PROTOCOL = VUSB
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
F_CPU ?= 16000000
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(MCU),atmega328))
|
||||
# MCU name for avrdude
|
||||
AVRDUDE_MCU = m328
|
||||
|
||||
PROTOCOL = VUSB
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
F_CPU ?= 16000000
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(MCU),attiny85))
|
||||
PROTOCOL = VUSB
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
F_CPU ?= 16500000
|
||||
endif
|
||||
|
|
@ -30,8 +30,19 @@ static __inline__ void __interrupt_enable__(const uint8_t *__s) {
|
|||
(void)__s;
|
||||
}
|
||||
|
||||
#define ATOMIC_BLOCK(type) for (type, __ToDo = __interrupt_disable__(); __ToDo; __ToDo = 0)
|
||||
#define ATOMIC_FORCEON uint8_t sreg_save __attribute__((__cleanup__(__interrupt_enable__))) = 0
|
||||
static __inline__ syssts_t __interrupt_lock__(void) {
|
||||
return chSysGetStatusAndLockX();
|
||||
}
|
||||
|
||||
#define ATOMIC_BLOCK_RESTORESTATE _Static_assert(0, "ATOMIC_BLOCK_RESTORESTATE not implemented")
|
||||
static __inline__ void __interrupt_unlock__(const syssts_t *__s) {
|
||||
chSysRestoreStatusX(*__s);
|
||||
|
||||
__asm__ volatile("" ::: "memory");
|
||||
}
|
||||
|
||||
#define ATOMIC_BLOCK(type) for (type, __ToDo = 1; __ToDo; __ToDo = 0)
|
||||
#define ATOMIC_FORCEON uint8_t status_save __attribute__((__cleanup__(__interrupt_enable__))) = __interrupt_disable__()
|
||||
#define ATOMIC_RESTORESTATE syssts_t status_save __attribute__((__cleanup__(__interrupt_unlock__))) = __interrupt_lock__()
|
||||
|
||||
#define ATOMIC_BLOCK_RESTORESTATE ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
|
||||
#define ATOMIC_BLOCK_FORCEON ATOMIC_BLOCK(ATOMIC_FORCEON)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
// Force B9 as input to align with qmk defaults
|
||||
#undef VAL_GPIOB_MODER
|
||||
|
|
|
|||
|
|
@ -19,12 +19,22 @@
|
|||
|
||||
#ifndef STM32_LSECLK
|
||||
# define STM32_LSECLK 32768U
|
||||
#endif // STM32_LSECLK
|
||||
#endif // STM32_LSECLK
|
||||
|
||||
#ifndef STM32_HSECLK
|
||||
# define STM32_HSECLK 25000000U
|
||||
#endif // STM32_HSECLK
|
||||
#endif // STM32_HSECLK
|
||||
|
||||
#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
|
||||
# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
|
||||
#endif
|
||||
|
||||
#ifdef WEAR_LEVELING_EMBEDDED_FLASH
|
||||
# ifndef WEAR_LEVELING_EFL_FIRST_SECTOR
|
||||
# ifdef BOOTLOADER_TINYUF2
|
||||
# define WEAR_LEVELING_EFL_FIRST_SECTOR 3
|
||||
# else
|
||||
# define WEAR_LEVELING_EFL_FIRST_SECTOR 1
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef STM32_HSE_BYPASS
|
||||
|
|
|
|||
|
|
@ -19,12 +19,22 @@
|
|||
|
||||
#ifndef STM32_LSECLK
|
||||
# define STM32_LSECLK 32768U
|
||||
#endif // STM32_LSECLK
|
||||
#endif // STM32_LSECLK
|
||||
|
||||
#ifndef STM32_HSECLK
|
||||
# define STM32_HSECLK 25000000U
|
||||
#endif // STM32_HSECLK
|
||||
#endif // STM32_HSECLK
|
||||
|
||||
#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
|
||||
# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
|
||||
#endif
|
||||
|
||||
#ifdef WEAR_LEVELING_EMBEDDED_FLASH
|
||||
# ifndef WEAR_LEVELING_EFL_FIRST_SECTOR
|
||||
# ifdef BOOTLOADER_TINYUF2
|
||||
# define WEAR_LEVELING_EFL_FIRST_SECTOR 3
|
||||
# else
|
||||
# define WEAR_LEVELING_EFL_FIRST_SECTOR 1
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
|||
9
platforms/chibios/boards/BONSAI_C4/board/board.mk
Normal file
9
platforms/chibios/boards/BONSAI_C4/board/board.mk
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# List of all the board related files.
|
||||
BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F411RE/board.c
|
||||
|
||||
# Required include directories
|
||||
BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F411RE
|
||||
|
||||
# Shared variables
|
||||
ALLCSRC += $(BOARDSRC)
|
||||
ALLINC += $(BOARDINC)
|
||||
|
|
@ -17,4 +17,4 @@
|
|||
|
||||
#include_next <board.h>
|
||||
|
||||
// #undef STM32_HSE_BYPASS
|
||||
#undef STM32_HSE_BYPASS
|
||||
92
platforms/chibios/boards/BONSAI_C4/configs/config.h
Normal file
92
platforms/chibios/boards/BONSAI_C4/configs/config.h
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/* Copyright 2022 David Hoelscher, customMK
|
||||
*
|
||||
* 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 3 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// Bonsai C4 includes Vbus sensing; derived designs that use PA9 for other purposes
|
||||
// may disable Vbus sensing with #define BOARD_OTG_NOVBUSSENS 1
|
||||
|
||||
#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
|
||||
# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
|
||||
#endif
|
||||
|
||||
// FRAM configuration
|
||||
#ifndef EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN
|
||||
# define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN PAL_LINE(GPIOA, 0)
|
||||
# define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 // 96MHz / 8 = 12MHz; max supported by MB85R64 is 20MHz
|
||||
# define EXTERNAL_EEPROM_BYTE_COUNT 8192
|
||||
# define EXTERNAL_EEPROM_PAGE_SIZE 64 // does not matter for FRAM, just sets the RAM buffer size in STM32F chip
|
||||
# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191
|
||||
#endif
|
||||
|
||||
// External flash configuration
|
||||
#ifndef EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN
|
||||
# define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN PAL_LINE(GPIOB, 12)
|
||||
# define EXTERNAL_FLASH_SPI_CLOCK_DIVISOR 2 // 48MHz; max supported by W25Q128JV is 133MHz
|
||||
# define EXTERNAL_FLASH_BYTE_COUNT (16 * 1024 * 1024) //128Mbit or 16MByte
|
||||
# define EXTERNAL_FLASH_PAGE_SIZE 256
|
||||
# define EXTERNAL_FLASH_SPI_TIMEOUT 200000 //datasheet max is 200 seconds for flash chip erase
|
||||
#endif
|
||||
|
||||
// SPI Configuration (needed for FRAM and FLASH)
|
||||
#ifndef SPI_DRIVER
|
||||
# define SPI_DRIVER SPID1
|
||||
#endif
|
||||
#ifndef SPI_SCK_PIN
|
||||
# define SPI_SCK_PIN PAL_LINE(GPIOB, 3)
|
||||
#endif
|
||||
#ifndef SPI_MOSI_PIN
|
||||
# define SPI_MOSI_PIN PAL_LINE(GPIOB, 5)
|
||||
#endif
|
||||
#ifndef SPI_MISO_PIN
|
||||
# define SPI_MISO_PIN PAL_LINE(GPIOB, 4)
|
||||
#endif
|
||||
|
||||
|
||||
// I2C Configuration
|
||||
#ifdef CONVERT_TO_BONSAI_C4
|
||||
# ifndef I2C1_SCL_PIN
|
||||
# define I2C1_SCL_PIN PAL_LINE(GPIOB, 6)
|
||||
# endif
|
||||
# ifndef I2C1_SDA_PIN
|
||||
# define I2C1_SDA_PIN PAL_LINE(GPIOB, 9)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// WS2812-style LED control on pin A10
|
||||
#ifdef WS2812_DRIVER_PWM
|
||||
# ifndef RGB_DI_PIN
|
||||
# define RGB_DI_PIN PAL_LINE(GPIOA, 10)
|
||||
# endif
|
||||
# ifndef WS2812_PWM_DRIVER
|
||||
# define WS2812_PWM_DRIVER PWMD1
|
||||
# endif
|
||||
# ifndef WS2812_PWM_CHANNEL
|
||||
# define WS2812_PWM_CHANNEL 3
|
||||
# endif
|
||||
# ifndef WS2812_PWM_PAL_MODE
|
||||
# define WS2812_PWM_PAL_MODE 1
|
||||
# endif
|
||||
# ifndef WS2812_DMA_STREAM
|
||||
# define WS2812_DMA_STREAM STM32_DMA2_STREAM5
|
||||
# endif
|
||||
# ifndef WS2812_DMA_CHANNEL
|
||||
# define WS2812_DMA_CHANNEL 6
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef USB_VBUS_PIN
|
||||
# define USB_VBUS_PIN PAL_LINE(GPIOA, 9)
|
||||
#endif
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright 2020 Nick Brassel (tzarc)
|
||||
/* Copyright 2022 David Hoelscher, customMK
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,6 +15,35 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
// #define HAL_USE_DAC TRUE
|
||||
#ifndef HAL_USE_SPI
|
||||
# define HAL_USE_SPI TRUE
|
||||
#endif
|
||||
|
||||
#include_next <halconf.h>
|
||||
#ifndef HAL_USE_I2C
|
||||
# define HAL_USE_I2C TRUE
|
||||
#endif
|
||||
|
||||
#ifdef SPLIT_KEYBOARD
|
||||
# ifndef HAL_USE_SERIAL
|
||||
# define HAL_USE_SERIAL TRUE
|
||||
# endif
|
||||
# ifndef SERIAL_BUFFERS_SIZE
|
||||
# define SERIAL_BUFFERS_SIZE 256
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef WS2812_DRIVER_PWM
|
||||
# ifndef HAL_USE_PWM
|
||||
# define HAL_USE_PWM TRUE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SPI_SELECT_MODE
|
||||
# define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
|
||||
#endif
|
||||
|
||||
#ifndef SPI_USE_WAIT
|
||||
# define SPI_USE_WAIT TRUE
|
||||
#endif
|
||||
|
||||
#include_next <halconf.h>
|
||||
252
platforms/chibios/boards/BONSAI_C4/configs/mcuconf.h
Normal file
252
platforms/chibios/boards/BONSAI_C4/configs/mcuconf.h
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2020 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.
|
||||
*/
|
||||
|
||||
#ifndef MCUCONF_H
|
||||
#define MCUCONF_H
|
||||
|
||||
/*
|
||||
* STM32F4xx drivers configuration.
|
||||
* The following settings override the default settings present in
|
||||
* the various device driver implementation headers.
|
||||
* Note that the settings for each driver only have effect if the whole
|
||||
* driver is enabled in halconf.h.
|
||||
*
|
||||
* IRQ priorities:
|
||||
* 15...0 Lowest...Highest.
|
||||
*
|
||||
* DMA priorities:
|
||||
* 0...3 Lowest...Highest.
|
||||
*/
|
||||
|
||||
#define STM32F4xx_MCUCONF
|
||||
#define STM32F411_MCUCONF
|
||||
|
||||
/*
|
||||
* HAL driver system settings.
|
||||
*/
|
||||
#define STM32_NO_INIT FALSE
|
||||
#define STM32_PVD_ENABLE FALSE
|
||||
#define STM32_PLS STM32_PLS_LEV0
|
||||
#define STM32_BKPRAM_ENABLE FALSE
|
||||
#define STM32_HSI_ENABLED TRUE
|
||||
#define STM32_LSI_ENABLED TRUE
|
||||
#define STM32_HSE_ENABLED TRUE
|
||||
#define STM32_LSE_ENABLED FALSE
|
||||
#define STM32_CLOCK48_REQUIRED TRUE
|
||||
#define STM32_SW STM32_SW_PLL
|
||||
#define STM32_PLLSRC STM32_PLLSRC_HSE
|
||||
#define STM32_PLLM_VALUE 4
|
||||
#define STM32_PLLN_VALUE 96
|
||||
#define STM32_PLLP_VALUE 2
|
||||
#define STM32_PLLQ_VALUE 4
|
||||
#define STM32_HPRE STM32_HPRE_DIV1
|
||||
#define STM32_PPRE1 STM32_PPRE1_DIV2
|
||||
#define STM32_PPRE2 STM32_PPRE2_DIV1
|
||||
#define STM32_RTCSEL STM32_RTCSEL_LSI
|
||||
#define STM32_RTCPRE_VALUE 8
|
||||
#define STM32_MCO1SEL STM32_MCO1SEL_HSI
|
||||
#define STM32_MCO1PRE STM32_MCO1PRE_DIV1
|
||||
#define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK
|
||||
#define STM32_MCO2PRE STM32_MCO2PRE_DIV5
|
||||
#define STM32_I2SSRC STM32_I2SSRC_CKIN
|
||||
#define STM32_PLLI2SN_VALUE 192
|
||||
#define STM32_PLLI2SR_VALUE 5
|
||||
|
||||
/*
|
||||
* IRQ system settings.
|
||||
*/
|
||||
#define STM32_IRQ_EXTI0_PRIORITY 6
|
||||
#define STM32_IRQ_EXTI1_PRIORITY 6
|
||||
#define STM32_IRQ_EXTI2_PRIORITY 6
|
||||
#define STM32_IRQ_EXTI3_PRIORITY 6
|
||||
#define STM32_IRQ_EXTI4_PRIORITY 6
|
||||
#define STM32_IRQ_EXTI5_9_PRIORITY 6
|
||||
#define STM32_IRQ_EXTI10_15_PRIORITY 6
|
||||
#define STM32_IRQ_EXTI16_PRIORITY 6
|
||||
#define STM32_IRQ_EXTI17_PRIORITY 15
|
||||
#define STM32_IRQ_EXTI18_PRIORITY 6
|
||||
#define STM32_IRQ_EXTI19_PRIORITY 6
|
||||
#define STM32_IRQ_EXTI20_PRIORITY 6
|
||||
#define STM32_IRQ_EXTI21_PRIORITY 15
|
||||
#define STM32_IRQ_EXTI22_PRIORITY 15
|
||||
|
||||
#define STM32_IRQ_TIM1_BRK_TIM9_PRIORITY 7
|
||||
#define STM32_IRQ_TIM1_UP_TIM10_PRIORITY 7
|
||||
#define STM32_IRQ_TIM1_TRGCO_TIM11_PRIORITY 7
|
||||
#define STM32_IRQ_TIM1_CC_PRIORITY 7
|
||||
#define STM32_IRQ_TIM2_PRIORITY 7
|
||||
#define STM32_IRQ_TIM3_PRIORITY 7
|
||||
#define STM32_IRQ_TIM4_PRIORITY 7
|
||||
#define STM32_IRQ_TIM5_PRIORITY 7
|
||||
|
||||
#define STM32_IRQ_USART1_PRIORITY 12
|
||||
#define STM32_IRQ_USART2_PRIORITY 12
|
||||
#define STM32_IRQ_USART6_PRIORITY 12
|
||||
|
||||
/*
|
||||
* ADC driver system settings.
|
||||
*/
|
||||
#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4
|
||||
#define STM32_ADC_USE_ADC1 FALSE
|
||||
#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
|
||||
#define STM32_ADC_ADC1_DMA_PRIORITY 2
|
||||
#define STM32_ADC_IRQ_PRIORITY 6
|
||||
#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 6
|
||||
|
||||
/*
|
||||
* GPT driver system settings.
|
||||
*/
|
||||
#define STM32_GPT_USE_TIM1 FALSE
|
||||
#define STM32_GPT_USE_TIM2 FALSE
|
||||
#define STM32_GPT_USE_TIM3 FALSE
|
||||
#define STM32_GPT_USE_TIM4 FALSE
|
||||
#define STM32_GPT_USE_TIM5 FALSE
|
||||
#define STM32_GPT_USE_TIM9 FALSE
|
||||
#define STM32_GPT_USE_TIM10 FALSE
|
||||
#define STM32_GPT_USE_TIM11 FALSE
|
||||
|
||||
/*
|
||||
* I2C driver system settings.
|
||||
*/
|
||||
#define STM32_I2C_USE_I2C1 TRUE
|
||||
#define STM32_I2C_USE_I2C2 FALSE
|
||||
#define STM32_I2C_USE_I2C3 FALSE
|
||||
#define STM32_I2C_BUSY_TIMEOUT 50
|
||||
#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
|
||||
#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
|
||||
#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
|
||||
#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
|
||||
#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
|
||||
#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
|
||||
#define STM32_I2C_I2C1_IRQ_PRIORITY 5
|
||||
#define STM32_I2C_I2C2_IRQ_PRIORITY 5
|
||||
#define STM32_I2C_I2C3_IRQ_PRIORITY 5
|
||||
#define STM32_I2C_I2C1_DMA_PRIORITY 3
|
||||
#define STM32_I2C_I2C2_DMA_PRIORITY 3
|
||||
#define STM32_I2C_I2C3_DMA_PRIORITY 3
|
||||
#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
|
||||
|
||||
/*
|
||||
* I2S driver system settings.
|
||||
*/
|
||||
#define STM32_I2S_USE_SPI2 FALSE
|
||||
#define STM32_I2S_USE_SPI3 FALSE
|
||||
#define STM32_I2S_SPI2_IRQ_PRIORITY 10
|
||||
#define STM32_I2S_SPI3_IRQ_PRIORITY 10
|
||||
#define STM32_I2S_SPI2_DMA_PRIORITY 1
|
||||
#define STM32_I2S_SPI3_DMA_PRIORITY 1
|
||||
#define STM32_I2S_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
|
||||
#define STM32_I2S_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
|
||||
#define STM32_I2S_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
|
||||
#define STM32_I2S_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
|
||||
#define STM32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure")
|
||||
|
||||
/*
|
||||
* ICU driver system settings.
|
||||
*/
|
||||
#define STM32_ICU_USE_TIM1 FALSE
|
||||
#define STM32_ICU_USE_TIM2 FALSE
|
||||
#define STM32_ICU_USE_TIM3 FALSE
|
||||
#define STM32_ICU_USE_TIM4 FALSE
|
||||
#define STM32_ICU_USE_TIM5 FALSE
|
||||
#define STM32_ICU_USE_TIM9 FALSE
|
||||
#define STM32_ICU_USE_TIM10 FALSE
|
||||
#define STM32_ICU_USE_TIM11 FALSE
|
||||
|
||||
/*
|
||||
* PWM driver system settings.
|
||||
*/
|
||||
#define STM32_PWM_USE_TIM1 TRUE
|
||||
#define STM32_PWM_USE_TIM2 FALSE
|
||||
#define STM32_PWM_USE_TIM3 TRUE
|
||||
#define STM32_PWM_USE_TIM4 FALSE
|
||||
#define STM32_PWM_USE_TIM5 FALSE
|
||||
#define STM32_PWM_USE_TIM9 FALSE
|
||||
#define STM32_PWM_USE_TIM10 FALSE
|
||||
#define STM32_PWM_USE_TIM11 FALSE
|
||||
|
||||
/*
|
||||
* RTC driver system settings.
|
||||
*/
|
||||
#define STM32_RTC_PRESA_VALUE 32
|
||||
#define STM32_RTC_PRESS_VALUE 1024
|
||||
#define STM32_RTC_CR_INIT 0
|
||||
#define STM32_RTC_TAMPCR_INIT 0
|
||||
|
||||
/*
|
||||
* SERIAL driver system settings.
|
||||
*/
|
||||
#define STM32_SERIAL_USE_USART1 TRUE
|
||||
#define STM32_SERIAL_USE_USART2 FALSE
|
||||
#define STM32_SERIAL_USE_USART6 FALSE
|
||||
|
||||
/*
|
||||
* SPI driver system settings.
|
||||
*/
|
||||
#define STM32_SPI_USE_SPI1 TRUE
|
||||
#define STM32_SPI_USE_SPI2 FALSE
|
||||
#define STM32_SPI_USE_SPI3 FALSE
|
||||
#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0)
|
||||
#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
|
||||
#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
|
||||
#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
|
||||
#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
|
||||
#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
|
||||
#define STM32_SPI_SPI1_DMA_PRIORITY 1
|
||||
#define STM32_SPI_SPI2_DMA_PRIORITY 1
|
||||
#define STM32_SPI_SPI3_DMA_PRIORITY 1
|
||||
#define STM32_SPI_SPI1_IRQ_PRIORITY 10
|
||||
#define STM32_SPI_SPI2_IRQ_PRIORITY 10
|
||||
#define STM32_SPI_SPI3_IRQ_PRIORITY 10
|
||||
#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
|
||||
|
||||
/*
|
||||
* ST driver system settings.
|
||||
*/
|
||||
#define STM32_ST_IRQ_PRIORITY 8
|
||||
#define STM32_ST_USE_TIMER 2
|
||||
|
||||
/*
|
||||
* UART driver system settings.
|
||||
*/
|
||||
#define STM32_UART_USE_USART1 FALSE
|
||||
#define STM32_UART_USE_USART2 FALSE
|
||||
#define STM32_UART_USE_USART6 FALSE
|
||||
#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
|
||||
#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
|
||||
#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
|
||||
#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
|
||||
#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
|
||||
#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
|
||||
#define STM32_UART_USART1_DMA_PRIORITY 0
|
||||
#define STM32_UART_USART2_DMA_PRIORITY 0
|
||||
#define STM32_UART_USART6_DMA_PRIORITY 0
|
||||
#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
|
||||
|
||||
/*
|
||||
* USB driver system settings.
|
||||
*/
|
||||
#define STM32_USB_USE_OTG1 TRUE
|
||||
#define STM32_USB_OTG1_IRQ_PRIORITY 14
|
||||
#define STM32_USB_OTG1_RX_FIFO_SIZE 512
|
||||
#define STM32_USB_HOST_WAKEUP_DURATION 2
|
||||
|
||||
/*
|
||||
* WDG driver system settings.
|
||||
*/
|
||||
#define STM32_WDG_USE_IWDG FALSE
|
||||
|
||||
#endif /* MCUCONF_H */
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef BOARD_RP_PICO_RP2040
|
||||
#define BOARD_GENERIC_PROMICRO_RP2040
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
*========================**/
|
||||
|
||||
#if !defined(I2C_DRIVER)
|
||||
# define I2C_DRIVER I2CD2
|
||||
# define I2C_DRIVER I2CD1
|
||||
#endif
|
||||
|
||||
#if !defined(I2C1_SDA_PIN)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
#define RP_IRQ_TIMER_ALARM1_PRIORITY 2
|
||||
#define RP_IRQ_TIMER_ALARM2_PRIORITY 2
|
||||
#define RP_IRQ_TIMER_ALARM3_PRIORITY 2
|
||||
#define RP_IRQ_ADC1_PRIORITY 3
|
||||
#define RP_IRQ_UART0_PRIORITY 3
|
||||
#define RP_IRQ_UART1_PRIORITY 3
|
||||
#define RP_IRQ_SPI0_PRIORITY 2
|
||||
|
|
@ -57,7 +58,7 @@
|
|||
/*
|
||||
* ADC driver system settings.
|
||||
*/
|
||||
#define RP_ADC_USE_ADC1 FALSE
|
||||
#define RP_ADC_USE_ADC1 TRUE
|
||||
|
||||
/*
|
||||
* SIO driver system settings.
|
||||
|
|
@ -78,6 +79,19 @@
|
|||
#define RP_SPI_SPI1_DMA_PRIORITY 1
|
||||
#define RP_SPI_DMA_ERROR_HOOK(spip)
|
||||
|
||||
/*
|
||||
* PWM driver system settings.
|
||||
*/
|
||||
#define RP_PWM_USE_PWM0 FALSE
|
||||
#define RP_PWM_USE_PWM1 FALSE
|
||||
#define RP_PWM_USE_PWM2 FALSE
|
||||
#define RP_PWM_USE_PWM3 FALSE
|
||||
#define RP_PWM_USE_PWM4 FALSE
|
||||
#define RP_PWM_USE_PWM5 FALSE
|
||||
#define RP_PWM_USE_PWM6 FALSE
|
||||
#define RP_PWM_USE_PWM7 FALSE
|
||||
#define RP_PWM_IRQ_WRAP_NUMBER_PRIORITY 3
|
||||
|
||||
/*
|
||||
* I2C driver system settings.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef BOARD_RP_PICO_RP2040
|
||||
#define BOARD_GENERIC_RP2040
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
#define RP_IRQ_TIMER_ALARM1_PRIORITY 2
|
||||
#define RP_IRQ_TIMER_ALARM2_PRIORITY 2
|
||||
#define RP_IRQ_TIMER_ALARM3_PRIORITY 2
|
||||
#define RP_IRQ_ADC1_PRIORITY 3
|
||||
#define RP_IRQ_UART0_PRIORITY 3
|
||||
#define RP_IRQ_UART1_PRIORITY 3
|
||||
#define RP_IRQ_SPI0_PRIORITY 2
|
||||
|
|
@ -78,6 +79,19 @@
|
|||
#define RP_SPI_SPI1_DMA_PRIORITY 1
|
||||
#define RP_SPI_DMA_ERROR_HOOK(spip)
|
||||
|
||||
/*
|
||||
* PWM driver system settings.
|
||||
*/
|
||||
#define RP_PWM_USE_PWM0 FALSE
|
||||
#define RP_PWM_USE_PWM1 FALSE
|
||||
#define RP_PWM_USE_PWM2 FALSE
|
||||
#define RP_PWM_USE_PWM3 FALSE
|
||||
#define RP_PWM_USE_PWM4 FALSE
|
||||
#define RP_PWM_USE_PWM5 FALSE
|
||||
#define RP_PWM_USE_PWM6 FALSE
|
||||
#define RP_PWM_USE_PWM7 FALSE
|
||||
#define RP_PWM_IRQ_WRAP_NUMBER_PRIORITY 3
|
||||
|
||||
/*
|
||||
* I2C driver system settings.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef STM32_HSE_BYPASS
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@
|
|||
#define STM32_ADC_ADC1_DMA_PRIORITY 2
|
||||
#define STM32_ADC_IRQ_PRIORITY 2
|
||||
#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 2
|
||||
#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)
|
||||
|
||||
/*
|
||||
* GPT driver system settings.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef STM32_HSE_BYPASS
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
// Force B9 as input to align with qmk defaults
|
||||
#undef VAL_GPIOB_MODER
|
||||
|
|
|
|||
|
|
@ -20,3 +20,13 @@
|
|||
#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
|
||||
# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
|
||||
#endif
|
||||
|
||||
#ifdef WEAR_LEVELING_EMBEDDED_FLASH
|
||||
# ifndef WEAR_LEVELING_EFL_FIRST_SECTOR
|
||||
# ifdef BOOTLOADER_TINYUF2
|
||||
# define WEAR_LEVELING_EFL_FIRST_SECTOR 3
|
||||
# else
|
||||
# define WEAR_LEVELING_EFL_FIRST_SECTOR 1
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@
|
|||
#define STM32_PLLP_VALUE 4
|
||||
#define STM32_PLLQ_VALUE 7
|
||||
#define STM32_HPRE STM32_HPRE_DIV1
|
||||
#define STM32_PPRE1 STM32_PPRE1_DIV2
|
||||
#define STM32_PPRE2 STM32_PPRE2_DIV1
|
||||
#define STM32_PPRE1 STM32_PPRE1_DIV2
|
||||
#define STM32_PPRE2 STM32_PPRE2_DIV1
|
||||
#define STM32_RTCSEL STM32_RTCSEL_LSI
|
||||
#define STM32_RTCPRE_VALUE 8
|
||||
#define STM32_MCO1SEL STM32_MCO1SEL_HSI
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
// The following is required to disable the pull-down on PA9, when PA9 is used for the keyboard matrix:
|
||||
#define BOARD_OTG_NOVBUSSENS
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef STM32_HSE_BYPASS
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@
|
|||
// The following is required to disable the pull-down on PA9, when PA9 is used for the keyboard matrix:
|
||||
#define BOARD_OTG_NOVBUSSENS
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef STM32_HSE_BYPASS
|
||||
|
|
@ -15,6 +15,6 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef STM32_HSE_BYPASS
|
||||
|
|
|
|||
|
|
@ -20,3 +20,13 @@
|
|||
#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
|
||||
# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
|
||||
#endif
|
||||
|
||||
#ifdef WEAR_LEVELING_EMBEDDED_FLASH
|
||||
# ifndef WEAR_LEVELING_EFL_FIRST_SECTOR
|
||||
# ifdef BOOTLOADER_TINYUF2
|
||||
# define WEAR_LEVELING_EFL_FIRST_SECTOR 3
|
||||
# else
|
||||
# define WEAR_LEVELING_EFL_FIRST_SECTOR 1
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@
|
|||
// The following is required to disable the pull-down on PA9, when PA9 is used for the keyboard matrix:
|
||||
#define BOARD_OTG_NOVBUSSENS
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef STM32_HSE_BYPASS
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef STM32L432xx
|
||||
#define STM32L422xx
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef STM32L432xx
|
||||
|
||||
|
|
|
|||
|
|
@ -80,3 +80,7 @@ void __early_init(void) {
|
|||
void boardInit(void) {
|
||||
|
||||
}
|
||||
|
||||
void restart_usb_driver(USBDriver *usbp) {
|
||||
// Do nothing. Restarting the USB driver on these boards breaks it.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,3 +80,7 @@ void __early_init(void) {
|
|||
void boardInit(void) {
|
||||
|
||||
}
|
||||
|
||||
void restart_usb_driver(USBDriver *usbp) {
|
||||
// Do nothing. Restarting the USB driver on these boards breaks it.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,3 +18,5 @@
|
|||
#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
|
||||
# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
|
||||
#endif
|
||||
|
||||
#define USB_ENDPOINTS_ARE_REORDERABLE
|
||||
|
|
|
|||
11
platforms/chibios/boards/PJRC_TEENSY_3_5/board/board.mk
Normal file
11
platforms/chibios/boards/PJRC_TEENSY_3_5/board/board.mk
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
include $(CHIBIOS_CONTRIB)/os/hal/boards/PJRC_TEENSY_3_5/board.mk
|
||||
|
||||
# List of all the board related files.
|
||||
BOARDSRC += $(BOARD_PATH)/board/extra.c
|
||||
|
||||
# Required include directories
|
||||
BOARDINC += $(BOARD_PATH)/board
|
||||
|
||||
# Shared variables
|
||||
ALLCSRC += $(BOARDSRC)
|
||||
ALLINC += $(BOARDINC)
|
||||
7
platforms/chibios/boards/PJRC_TEENSY_3_5/board/extra.c
Normal file
7
platforms/chibios/boards/PJRC_TEENSY_3_5/board/extra.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <hal.h>
|
||||
|
||||
void restart_usb_driver(USBDriver *usbp) {
|
||||
// Do nothing. Restarting the USB driver on the Teensy 3.6 breaks it,
|
||||
// resulting in a keyboard which can wake up a PC from Suspend-to-RAM, but
|
||||
// does not actually produce any keypresses until you un-plug and re-plug.
|
||||
}
|
||||
11
platforms/chibios/boards/PJRC_TEENSY_3_6/board/board.mk
Normal file
11
platforms/chibios/boards/PJRC_TEENSY_3_6/board/board.mk
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
include $(CHIBIOS_CONTRIB)/os/hal/boards/PJRC_TEENSY_3_6/board.mk
|
||||
|
||||
# List of all the board related files.
|
||||
BOARDSRC += $(BOARD_PATH)/board/extra.c
|
||||
|
||||
# Required include directories
|
||||
BOARDINC += $(BOARD_PATH)/board
|
||||
|
||||
# Shared variables
|
||||
ALLCSRC += $(BOARDSRC)
|
||||
ALLINC += $(BOARDINC)
|
||||
7
platforms/chibios/boards/PJRC_TEENSY_3_6/board/extra.c
Normal file
7
platforms/chibios/boards/PJRC_TEENSY_3_6/board/extra.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <hal.h>
|
||||
|
||||
void restart_usb_driver(USBDriver *usbp) {
|
||||
// Do nothing. Restarting the USB driver on the Teensy 3.6 breaks it,
|
||||
// resulting in a keyboard which can wake up a PC from Suspend-to-RAM, but
|
||||
// does not actually produce any keypresses until you un-plug and re-plug.
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef BOARD_RP_PICO_RP2040
|
||||
#define BOARD_PM2040
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef I2C_DRIVER
|
||||
# define I2C_DRIVER I2CD2
|
||||
# define I2C_DRIVER I2CD1
|
||||
#endif
|
||||
#ifndef I2C1_SDA_PIN
|
||||
# define I2C1_SDA_PIN D1
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define HAL_USE_ADC TRUE
|
||||
#define HAL_USE_I2C TRUE
|
||||
#define HAL_USE_SPI TRUE
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
#define RP_IRQ_TIMER_ALARM1_PRIORITY 2
|
||||
#define RP_IRQ_TIMER_ALARM2_PRIORITY 2
|
||||
#define RP_IRQ_TIMER_ALARM3_PRIORITY 2
|
||||
#define RP_IRQ_ADC1_PRIORITY 3
|
||||
#define RP_IRQ_UART0_PRIORITY 3
|
||||
#define RP_IRQ_UART1_PRIORITY 3
|
||||
#define RP_IRQ_SPI0_PRIORITY 2
|
||||
|
|
@ -57,7 +58,7 @@
|
|||
/*
|
||||
* ADC driver system settings.
|
||||
*/
|
||||
#define RP_ADC_USE_ADC1 FALSE
|
||||
#define RP_ADC_USE_ADC1 TRUE
|
||||
|
||||
/*
|
||||
* SIO driver system settings.
|
||||
|
|
@ -78,6 +79,19 @@
|
|||
#define RP_SPI_SPI1_DMA_PRIORITY 1
|
||||
#define RP_SPI_DMA_ERROR_HOOK(spip)
|
||||
|
||||
/*
|
||||
* PWM driver system settings.
|
||||
*/
|
||||
#define RP_PWM_USE_PWM0 FALSE
|
||||
#define RP_PWM_USE_PWM1 FALSE
|
||||
#define RP_PWM_USE_PWM2 FALSE
|
||||
#define RP_PWM_USE_PWM3 FALSE
|
||||
#define RP_PWM_USE_PWM4 FALSE
|
||||
#define RP_PWM_USE_PWM5 FALSE
|
||||
#define RP_PWM_USE_PWM6 FALSE
|
||||
#define RP_PWM_USE_PWM7 FALSE
|
||||
#define RP_PWM_IRQ_WRAP_NUMBER_PRIORITY 3
|
||||
|
||||
/*
|
||||
* I2C driver system settings.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef STM32_HSE_BYPASS
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#define HALCONF_H
|
||||
|
||||
#define _CHIBIOS_HAL_CONF_
|
||||
#define _CHIBIOS_HAL_CONF_VER_8_0_
|
||||
#define _CHIBIOS_HAL_CONF_VER_8_4_
|
||||
|
||||
#include <mcuconf.h>
|
||||
|
||||
|
|
@ -335,15 +335,18 @@
|
|||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Delays insertions.
|
||||
* @details If enabled this options inserts delays into the MMC waiting
|
||||
* routines releasing some extra CPU time for the threads with
|
||||
* lower priority, this may slow down the driver a bit however.
|
||||
* This option is recommended also if the SPI driver does not
|
||||
* use a DMA channel and heavily loads the CPU.
|
||||
* @brief Timeout before assuming a failure while waiting for card idle.
|
||||
* @note Time is in milliseconds.
|
||||
*/
|
||||
#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
|
||||
#define MMC_NICE_WAITING TRUE
|
||||
#if !defined(MMC_IDLE_TIMEOUT_MS) || defined(__DOXYGEN__)
|
||||
#define MMC_IDLE_TIMEOUT_MS 1000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Mutual exclusion on the SPI bus.
|
||||
*/
|
||||
#if !defined(MMC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||
#define MMC_USE_MUTUAL_EXCLUSION TRUE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include_next "board.h"
|
||||
#include_next <board.h>
|
||||
|
||||
#undef STM32_HSE_BYPASS
|
||||
|
|
|
|||
|
|
@ -1,5 +1,18 @@
|
|||
// Copyright 2022 Mega Mind (@megamind4089)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
ChibiOS - Copyright (C) 2006..2020 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.
|
||||
*/
|
||||
|
||||
#ifndef MCUCONF_H
|
||||
#define MCUCONF_H
|
||||
|
|
@ -165,6 +178,14 @@
|
|||
#define STM32_PWM_USE_TIM10 FALSE
|
||||
#define STM32_PWM_USE_TIM11 FALSE
|
||||
|
||||
/*
|
||||
* RTC driver system settings.
|
||||
*/
|
||||
#define STM32_RTC_PRESA_VALUE 32
|
||||
#define STM32_RTC_PRESS_VALUE 1024
|
||||
#define STM32_RTC_CR_INIT 0
|
||||
#define STM32_RTC_TAMPCR_INIT 0
|
||||
|
||||
/*
|
||||
* SERIAL driver system settings.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#define HALCONF_H
|
||||
|
||||
#define _CHIBIOS_HAL_CONF_
|
||||
#define _CHIBIOS_HAL_CONF_VER_8_0_
|
||||
#define _CHIBIOS_HAL_CONF_VER_8_4_
|
||||
|
||||
#include <mcuconf.h>
|
||||
|
||||
|
|
@ -335,15 +335,18 @@
|
|||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Delays insertions.
|
||||
* @details If enabled this options inserts delays into the MMC waiting
|
||||
* routines releasing some extra CPU time for the threads with
|
||||
* lower priority, this may slow down the driver a bit however.
|
||||
* This option is recommended also if the SPI driver does not
|
||||
* use a DMA channel and heavily loads the CPU.
|
||||
* @brief Timeout before assuming a failure while waiting for card idle.
|
||||
* @note Time is in milliseconds.
|
||||
*/
|
||||
#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
|
||||
#define MMC_NICE_WAITING TRUE
|
||||
#if !defined(MMC_IDLE_TIMEOUT_MS) || defined(__DOXYGEN__)
|
||||
#define MMC_IDLE_TIMEOUT_MS 1000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Mutual exclusion on the SPI bus.
|
||||
*/
|
||||
#if !defined(MMC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||
#define MMC_USE_MUTUAL_EXCLUSION TRUE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
|||
88
platforms/chibios/boards/common/ld/STM32F103xB_uf2boot.ld
Normal file
88
platforms/chibios/boards/common/ld/STM32F103xB_uf2boot.ld
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2018 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ST32F103xB memory setup.
|
||||
*/
|
||||
MEMORY
|
||||
{
|
||||
flash0 (rx) : org = 0x08000000 + 16K, len = 128k - 16K
|
||||
flash1 (rx) : org = 0x00000000, len = 0
|
||||
flash2 (rx) : org = 0x00000000, len = 0
|
||||
flash3 (rx) : org = 0x00000000, len = 0
|
||||
flash4 (rx) : org = 0x00000000, len = 0
|
||||
flash5 (rx) : org = 0x00000000, len = 0
|
||||
flash6 (rx) : org = 0x00000000, len = 0
|
||||
flash7 (rx) : org = 0x00000000, len = 0
|
||||
ram0 (wx) : org = 0x20000000, len = 20k
|
||||
ram1 (wx) : org = 0x00000000, len = 0
|
||||
ram2 (wx) : org = 0x00000000, len = 0
|
||||
ram3 (wx) : org = 0x00000000, len = 0
|
||||
ram4 (wx) : org = 0x00000000, len = 0
|
||||
ram5 (wx) : org = 0x00000000, len = 0
|
||||
ram6 (wx) : org = 0x00000000, len = 0
|
||||
ram7 (wx) : org = 0x00000000, len = 0
|
||||
}
|
||||
|
||||
/* For each data/text section two region are defined, a virtual region
|
||||
and a load region (_LMA suffix).*/
|
||||
|
||||
/* Flash region to be used for exception vectors.*/
|
||||
REGION_ALIAS("VECTORS_FLASH", flash0);
|
||||
REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
|
||||
|
||||
/* Flash region to be used for constructors and destructors.*/
|
||||
REGION_ALIAS("XTORS_FLASH", flash0);
|
||||
REGION_ALIAS("XTORS_FLASH_LMA", flash0);
|
||||
|
||||
/* Flash region to be used for code text.*/
|
||||
REGION_ALIAS("TEXT_FLASH", flash0);
|
||||
REGION_ALIAS("TEXT_FLASH_LMA", flash0);
|
||||
|
||||
/* Flash region to be used for read only data.*/
|
||||
REGION_ALIAS("RODATA_FLASH", flash0);
|
||||
REGION_ALIAS("RODATA_FLASH_LMA", flash0);
|
||||
|
||||
/* Flash region to be used for various.*/
|
||||
REGION_ALIAS("VARIOUS_FLASH", flash0);
|
||||
REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);
|
||||
|
||||
/* Flash region to be used for RAM(n) initialization data.*/
|
||||
REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);
|
||||
|
||||
/* RAM region to be used for Main stack. This stack accommodates the processing
|
||||
of all exceptions and interrupts.*/
|
||||
REGION_ALIAS("MAIN_STACK_RAM", ram0);
|
||||
|
||||
/* RAM region to be used for the process stack. This is the stack used by
|
||||
the main() function.*/
|
||||
REGION_ALIAS("PROCESS_STACK_RAM", ram0);
|
||||
|
||||
/* RAM region to be used for data segment.*/
|
||||
REGION_ALIAS("DATA_RAM", ram0);
|
||||
REGION_ALIAS("DATA_RAM_LMA", flash0);
|
||||
|
||||
/* RAM region to be used for BSS segment.*/
|
||||
REGION_ALIAS("BSS_RAM", ram0);
|
||||
|
||||
/* RAM region to be used for the default heap.*/
|
||||
REGION_ALIAS("HEAP_RAM", ram0);
|
||||
|
||||
/* Generic rules inclusion.*/
|
||||
INCLUDE rules.ld
|
||||
|
||||
/* Bootloader reset support */
|
||||
_board_magic_reg = ORIGIN(ram0) + 16k; /* this is based off the code within backup.c */
|
||||
88
platforms/chibios/boards/common/ld/STM32F303xC_tinyuf2.ld
Normal file
88
platforms/chibios/boards/common/ld/STM32F303xC_tinyuf2.ld
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2018 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* STM32F303xC memory setup.
|
||||
*/
|
||||
MEMORY
|
||||
{
|
||||
flash0 (rx) : org = 0x08000000 + 16k, len = 256k - 16k
|
||||
flash1 (rx) : org = 0x00000000, len = 0
|
||||
flash2 (rx) : org = 0x00000000, len = 0
|
||||
flash3 (rx) : org = 0x00000000, len = 0
|
||||
flash4 (rx) : org = 0x00000000, len = 0
|
||||
flash5 (rx) : org = 0x00000000, len = 0
|
||||
flash6 (rx) : org = 0x00000000, len = 0
|
||||
flash7 (rx) : org = 0x00000000, len = 0
|
||||
ram0 (wx) : org = 0x20000000, len = 40k
|
||||
ram1 (wx) : org = 0x00000000, len = 0
|
||||
ram2 (wx) : org = 0x00000000, len = 0
|
||||
ram3 (wx) : org = 0x00000000, len = 0
|
||||
ram4 (wx) : org = 0x10000000, len = 8k
|
||||
ram5 (wx) : org = 0x00000000, len = 0
|
||||
ram6 (wx) : org = 0x00000000, len = 0
|
||||
ram7 (wx) : org = 0x00000000, len = 0
|
||||
}
|
||||
|
||||
/* For each data/text section two region are defined, a virtual region
|
||||
and a load region (_LMA suffix).*/
|
||||
|
||||
/* Flash region to be used for exception vectors.*/
|
||||
REGION_ALIAS("VECTORS_FLASH", flash0);
|
||||
REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
|
||||
|
||||
/* Flash region to be used for constructors and destructors.*/
|
||||
REGION_ALIAS("XTORS_FLASH", flash0);
|
||||
REGION_ALIAS("XTORS_FLASH_LMA", flash0);
|
||||
|
||||
/* Flash region to be used for code text.*/
|
||||
REGION_ALIAS("TEXT_FLASH", flash0);
|
||||
REGION_ALIAS("TEXT_FLASH_LMA", flash0);
|
||||
|
||||
/* Flash region to be used for read only data.*/
|
||||
REGION_ALIAS("RODATA_FLASH", flash0);
|
||||
REGION_ALIAS("RODATA_FLASH_LMA", flash0);
|
||||
|
||||
/* Flash region to be used for various.*/
|
||||
REGION_ALIAS("VARIOUS_FLASH", flash0);
|
||||
REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);
|
||||
|
||||
/* Flash region to be used for RAM(n) initialization data.*/
|
||||
REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);
|
||||
|
||||
/* RAM region to be used for Main stack. This stack accommodates the processing
|
||||
of all exceptions and interrupts.*/
|
||||
REGION_ALIAS("MAIN_STACK_RAM", ram0);
|
||||
|
||||
/* RAM region to be used for the process stack. This is the stack used by
|
||||
the main() function.*/
|
||||
REGION_ALIAS("PROCESS_STACK_RAM", ram0);
|
||||
|
||||
/* RAM region to be used for data segment.*/
|
||||
REGION_ALIAS("DATA_RAM", ram0);
|
||||
REGION_ALIAS("DATA_RAM_LMA", flash0);
|
||||
|
||||
/* RAM region to be used for BSS segment.*/
|
||||
REGION_ALIAS("BSS_RAM", ram0);
|
||||
|
||||
/* RAM region to be used for the default heap.*/
|
||||
REGION_ALIAS("HEAP_RAM", ram0);
|
||||
|
||||
/* Generic rules inclusion.*/
|
||||
INCLUDE rules.ld
|
||||
|
||||
/* TinyUF2 bootloader reset support */
|
||||
_board_dfu_dbl_tap = ORIGIN(ram0) + 40k - 4; /* this is based off the linker file for tinyuf2 */
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
/* Copyright 2020 Nick Brassel (tzarc)
|
||||
*
|
||||
* 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 3 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// #define CH_CFG_OPTIMIZE_SPEED TRUE
|
||||
|
||||
#include_next <chconf.h>
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
/* Copyright 2020 Nick Brassel (tzarc)
|
||||
*
|
||||
* 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 3 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include_next <mcuconf.h>
|
||||
|
||||
// #undef STM32_HSE_ENABLED
|
||||
// #define STM32_HSE_ENABLED FALSE
|
||||
140
platforms/chibios/bootloader.mk
Normal file
140
platforms/chibios/bootloader.mk
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
# Copyright 2017 Jack Humbert
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
# If it's possible that multiple bootloaders can be used for one project,
|
||||
# you can leave this unset, and the correct size will be selected
|
||||
# automatically.
|
||||
#
|
||||
# Sets the bootloader defined in the keyboard's/keymap's rules.mk
|
||||
#
|
||||
# Current options for ARM:
|
||||
# halfkay PJRC Teensy
|
||||
# kiibohd Input:Club Kiibohd bootloader (only used on their boards)
|
||||
# stm32duino STM32Duino (STM32F103x8)
|
||||
# stm32-dfu STM32 USB DFU in ROM
|
||||
# apm32-dfu APM32 USB DFU in ROM
|
||||
# wb32-dfu WB32 USB DFU in ROM
|
||||
# tinyuf2 TinyUF2
|
||||
# rp2040 Raspberry Pi RP2040
|
||||
# Current options for RISC-V:
|
||||
# gd32v-dfu GD32V USB DFU in ROM
|
||||
#
|
||||
# If you need to provide your own implementation, you can set inside `rules.mk`
|
||||
# `BOOTLOADER = custom` -- you'll need to provide your own implementations. See
|
||||
# the respective file under `platforms/<PLATFORM>/bootloaders/custom.c` to see
|
||||
# which functions may be overridden.
|
||||
|
||||
FIRMWARE_FORMAT?=bin
|
||||
|
||||
ifeq ($(strip $(BOOTLOADER)), custom)
|
||||
OPT_DEFS += -DBOOTLOADER_CUSTOM
|
||||
BOOTLOADER_TYPE = custom
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(BOOTLOADER)), halfkay)
|
||||
OPT_DEFS += -DBOOTLOADER_HALFKAY
|
||||
BOOTLOADER_TYPE = halfkay
|
||||
|
||||
# Teensy LC, 3.0, 3.1/2, 3.5, 3.6
|
||||
ifneq (,$(filter $(MCU_ORIG), MKL26Z64 MK20DX128 MK20DX256 MK64FX512 MK66FX1M0))
|
||||
FIRMWARE_FORMAT = hex
|
||||
endif
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), stm32-dfu)
|
||||
OPT_DEFS += -DBOOTLOADER_STM32_DFU
|
||||
BOOTLOADER_TYPE = stm32_dfu
|
||||
|
||||
# Options to pass to dfu-util when flashing
|
||||
DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
|
||||
DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), apm32-dfu)
|
||||
OPT_DEFS += -DBOOTLOADER_APM32_DFU
|
||||
BOOTLOADER_TYPE = stm32_dfu
|
||||
|
||||
# Options to pass to dfu-util when flashing
|
||||
DFU_ARGS ?= -d 314B:0106 -a 0 -s 0x08000000:leave
|
||||
DFU_SUFFIX_ARGS ?= -v 314B -p 0106
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), gd32v-dfu)
|
||||
OPT_DEFS += -DBOOTLOADER_GD32V_DFU
|
||||
BOOTLOADER_TYPE = gd32v_dfu
|
||||
|
||||
# Options to pass to dfu-util when flashing
|
||||
DFU_ARGS ?= -d 28E9:0189 -a 0 -s 0x08000000:leave
|
||||
DFU_SUFFIX_ARGS ?= -v 28E9 -p 0189
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), kiibohd)
|
||||
OPT_DEFS += -DBOOTLOADER_KIIBOHD
|
||||
BOOTLOADER_TYPE = kiibohd
|
||||
|
||||
ifeq ($(strip $(MCU_ORIG)), MK20DX128)
|
||||
MCU_LDSCRIPT = MK20DX128BLDR4
|
||||
endif
|
||||
ifeq ($(strip $(MCU_ORIG)), MK20DX256)
|
||||
MCU_LDSCRIPT = MK20DX256BLDR8
|
||||
endif
|
||||
|
||||
# Options to pass to dfu-util when flashing
|
||||
DFU_ARGS = -d 1C11:B007
|
||||
DFU_SUFFIX_ARGS = -v 1C11 -p B007
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), stm32duino)
|
||||
OPT_DEFS += -DBOOTLOADER_STM32DUINO
|
||||
MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader
|
||||
BOARD = STM32_F103_STM32DUINO
|
||||
BOOTLOADER_TYPE = stm32duino
|
||||
|
||||
# Options to pass to dfu-util when flashing
|
||||
DFU_ARGS = -d 1EAF:0003 -a 2 -R
|
||||
DFU_SUFFIX_ARGS = -v 1EAF -p 0003
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), vibl)
|
||||
MCU_LDSCRIPT = STM32_F103_vibl
|
||||
BOARD = STM32_F103_vibl
|
||||
PROGRAM_CMD = echo 'CLI flashing not supported' >&2
|
||||
OPT_DEFS += -DBOOTLOADER_VIBL
|
||||
BOOTLOADER_TYPE = vibl
|
||||
|
||||
DFU_ARGS =
|
||||
DFU_SUFFIX_ARGS =
|
||||
VIBL = 1
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), tinyuf2)
|
||||
OPT_DEFS += -DBOOTLOADER_TINYUF2
|
||||
BOOTLOADER_TYPE = tinyuf2
|
||||
FIRMWARE_FORMAT = uf2
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), uf2boot)
|
||||
OPT_DEFS += -DBOOTLOADER_UF2BOOT
|
||||
BOOTLOADER_TYPE = uf2boot
|
||||
FIRMWARE_FORMAT = uf2
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), rp2040)
|
||||
OPT_DEFS += -DBOOTLOADER_RP2040
|
||||
BOOTLOADER_TYPE = rp2040
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), wb32-dfu)
|
||||
OPT_DEFS += -DBOOTLOADER_WB32_DFU
|
||||
BOOTLOADER_TYPE = wb32_dfu
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(BOOTLOADER_TYPE)),)
|
||||
ifneq ($(strip $(BOOTLOADER)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,Invalid bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
|
||||
else
|
||||
$(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,No bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
|
||||
endif
|
||||
endif
|
||||
|
|
@ -27,7 +27,7 @@ extern uint32_t __ram0_end__;
|
|||
#endif
|
||||
|
||||
#if STM32_BOOTLOADER_DUAL_BANK
|
||||
# include "config_common.h"
|
||||
# include "gpio.h"
|
||||
|
||||
# ifndef STM32_BOOTLOADER_DUAL_BANK_GPIO
|
||||
# error "No STM32_BOOTLOADER_DUAL_BANK_GPIO defined, don't know which pin to toggle"
|
||||
|
|
|
|||
23
platforms/chibios/bootloaders/uf2boot.c
Normal file
23
platforms/chibios/bootloaders/uf2boot.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2023 QMK
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "bootloader.h"
|
||||
|
||||
// From mmoskal/uf2-stm32f103's backup.c
|
||||
#define MAGIC_BOOT 0x544F4F42UL
|
||||
|
||||
// defined by linker script
|
||||
extern uint32_t _board_magic_reg[];
|
||||
#define MAGIC_REG _board_magic_reg[0]
|
||||
|
||||
void bootloader_jump(void) {
|
||||
MAGIC_REG = MAGIC_BOOT;
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void mcu_reset(void) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
/* not needed, no two-stage reset */
|
||||
void enter_bootloader_mode_if_requested(void) {}
|
||||
|
|
@ -28,6 +28,18 @@
|
|||
# define USE_GPIOV1
|
||||
# define PAL_OUTPUT_TYPE_OPENDRAIN _Static_assert(0, "RP2040 has no Open Drain GPIO configuration, setting this is not possible");
|
||||
|
||||
/* Aliases for GPIO PWM channels - every pin has at least one PWM channel
|
||||
* assigned */
|
||||
# define RP2040_PWM_CHANNEL_A 1U
|
||||
# define RP2040_PWM_CHANNEL_B 2U
|
||||
|
||||
# define BACKLIGHT_PAL_MODE (PAL_MODE_ALTERNATE_PWM | PAL_RP_PAD_DRIVE12 | PAL_RP_GPIO_OE)
|
||||
# define BACKLIGHT_PWM_COUNTER_FREQUENCY 1000000
|
||||
# define BACKLIGHT_PWM_PERIOD BACKLIGHT_PWM_COUNTER_FREQUENCY / 2048
|
||||
|
||||
# define AUDIO_PWM_PAL_MODE (PAL_MODE_ALTERNATE_PWM | PAL_RP_PAD_DRIVE12 | PAL_RP_GPIO_OE)
|
||||
# define AUDIO_PWM_COUNTER_FREQUENCY 500000
|
||||
|
||||
# define usb_lld_endpoint_fields
|
||||
|
||||
# define I2C1_SCL_PAL_MODE (PAL_MODE_ALTERNATE_I2C | PAL_RP_PAD_SLEWFAST | PAL_RP_PAD_PUE | PAL_RP_PAD_DRIVE4)
|
||||
|
|
@ -51,6 +63,7 @@
|
|||
# define USE_GPIOV1
|
||||
# define PAL_MODE_ALTERNATE_OPENDRAIN PAL_MODE_STM32_ALTERNATE_OPENDRAIN
|
||||
# define PAL_MODE_ALTERNATE_PUSHPULL PAL_MODE_STM32_ALTERNATE_PUSHPULL
|
||||
# define AUDIO_PWM_PAL_MODE PAL_MODE_ALTERNATE_PUSHPULL
|
||||
# else
|
||||
# define PAL_OUTPUT_TYPE_OPENDRAIN PAL_STM32_OTYPE_OPENDRAIN
|
||||
# define PAL_OUTPUT_TYPE_PUSHPULL PAL_STM32_OTYPE_PUSHPULL
|
||||
|
|
@ -72,6 +85,7 @@
|
|||
# define USE_I2CV1
|
||||
# define PAL_MODE_ALTERNATE_OPENDRAIN PAL_MODE_GD32_ALTERNATE_OPENDRAIN
|
||||
# define PAL_MODE_ALTERNATE_PUSHPULL PAL_MODE_GD32_ALTERNATE_PUSHPULL
|
||||
# define AUDIO_PWM_PAL_MODE PAL_MODE_GD32_ALTERNATE_PUSHPULL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
CONVERTER:=platforms/chibios/converters/elite_c_to_rp2040_ce
|
||||
ACTIVE_CONVERTER:=rp2040_ce
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
CONVERTER:=platforms/chibios/converters/elite_c_to_rp2040_ce
|
||||
ACTIVE_CONVERTER:=rp2040_ce
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2023 QMK
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
// Left side (front)
|
||||
#define D3 0U
|
||||
#define D2 1U
|
||||
// GND
|
||||
// GND
|
||||
#define D1 2U
|
||||
#define D0 3U
|
||||
#define D4 4U
|
||||
#define C6 5U
|
||||
#define D7 6U
|
||||
#define E6 7U
|
||||
#define B4 8U
|
||||
#define B5 9U
|
||||
|
||||
// Right side (front)
|
||||
// RAW
|
||||
// GND
|
||||
// RESET
|
||||
// VCC
|
||||
#define F4 29U
|
||||
#define F5 28U
|
||||
#define F6 27U
|
||||
#define F7 26U
|
||||
#define B1 22U
|
||||
#define B3 20U
|
||||
#define B2 23U
|
||||
#define B6 21U
|
||||
|
||||
// Bottom row
|
||||
#define B7 12U
|
||||
#define D5 13U
|
||||
#define C7 14U
|
||||
#define F1 15U
|
||||
#define F0 16U
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
# rp2040_ce MCU settings for converting AVR projects
|
||||
MCU := RP2040
|
||||
BOARD := QMK_PM2040
|
||||
BOOTLOADER := rp2040
|
||||
|
||||
# These are defaults based on what has been implemented for RP2040 boards
|
||||
SERIAL_DRIVER ?= vendor
|
||||
WS2812_DRIVER ?= vendor
|
||||
BACKLIGHT_DRIVER ?= software
|
||||
OPT_DEFS += -DUSB_VBUS_PIN=19U
|
||||
54
platforms/chibios/converters/elite_c_to_stemcell/_pin_defs.h
Normal file
54
platforms/chibios/converters/elite_c_to_stemcell/_pin_defs.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright 2022 Mega Mind (@megamind4089)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
// Pindefs for v2.0.0
|
||||
// https://megamind4089.github.io/STeMCell/pinout/
|
||||
|
||||
// Left side (front)
|
||||
#ifdef STEMCELL_UART_SWAP
|
||||
# define D3 PAL_LINE(GPIOA, 3)
|
||||
# define D2 PAL_LINE(GPIOA, 2)
|
||||
#else
|
||||
# define D3 PAL_LINE(GPIOA, 2)
|
||||
# define D2 PAL_LINE(GPIOA, 3)
|
||||
#endif
|
||||
// GND
|
||||
// GND
|
||||
#ifdef STEMCELL_I2C_SWAP
|
||||
# define D1 PAL_LINE(GPIOB, 6)
|
||||
# define D0 PAL_LINE(GPIOB, 7)
|
||||
#else
|
||||
# define D1 PAL_LINE(GPIOB, 7)
|
||||
# define D0 PAL_LINE(GPIOB, 6)
|
||||
#endif
|
||||
|
||||
#define D4 PAL_LINE(GPIOA, 15)
|
||||
#define C6 PAL_LINE(GPIOB, 3)
|
||||
#define D7 PAL_LINE(GPIOB, 4)
|
||||
#define E6 PAL_LINE(GPIOB, 5)
|
||||
#define B4 PAL_LINE(GPIOB, 8)
|
||||
#define B5 PAL_LINE(GPIOB, 9)
|
||||
|
||||
// Right side (front)
|
||||
// RAW
|
||||
// GND
|
||||
// RESET
|
||||
// VCC
|
||||
#define F4 PAL_LINE(GPIOB, 10)
|
||||
#define F5 PAL_LINE(GPIOB, 2)
|
||||
#define F6 PAL_LINE(GPIOB, 1)
|
||||
#define F7 PAL_LINE(GPIOB, 0)
|
||||
|
||||
#define B1 PAL_LINE(GPIOA, 5)
|
||||
#define B3 PAL_LINE(GPIOA, 6)
|
||||
#define B2 PAL_LINE(GPIOA, 7)
|
||||
#define B6 PAL_LINE(GPIOA, 4)
|
||||
|
||||
// Bottom row
|
||||
#define B7 PAL_LINE(GPIOC, 13)
|
||||
#define D5 PAL_LINE(GPIOC, 14)
|
||||
#define C7 PAL_LINE(GPIOC, 15)
|
||||
#define F1 PAL_LINE(GPIOA, 0)
|
||||
#define F0 PAL_LINE(GPIOA, 1)
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# Copyright 2022 Mega Mind (@megamind4089)
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
MCU := STM32F411
|
||||
BOARD := STEMCELL
|
||||
BOOTLOADER := tinyuf2
|
||||
|
||||
SERIAL_DRIVER ?= usart
|
||||
WS2812_DRIVER ?= bitbang
|
||||
|
||||
ifeq ($(strip $(STMC_US)), yes)
|
||||
OPT_DEFS += -DSTEMCELL_UART_SWAP
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(STMC_IS)), yes)
|
||||
OPT_DEFS += -DSTEMCELL_I2C_SWAP
|
||||
endif
|
||||
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
CONVERTER:=platforms/chibios/converters/promicro_to_proton_c
|
||||
ACTIVE_CONVERTER:=proton_c
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Proton C MCU settings for converting AVR projects
|
||||
MCU := STM32F411
|
||||
BOARD := GENERIC_STM32_F411XE
|
||||
BOOTLOADER := stm32-dfu
|
||||
BOARD := BONSAI_C4
|
||||
BOOTLOADER := stm32-dfu
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
BACKLIGHT_DRIVER ?= pwm
|
||||
WS2812_DRIVER ?= pwm
|
||||
SERIAL_DRIVER ?= usart
|
||||
FLASH_DRIVER ?= spi
|
||||
EEPROM_DRIVER ?= spi
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
CONVERTER:=platforms/chibios/converters/promicro_to_rp2040_ce
|
||||
ACTIVE_CONVERTER:=rp2040_ce
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
CONVERTER:=platforms/chibios/converters/promicro_to_rp2040_ce
|
||||
ACTIVE_CONVERTER:=rp2040_ce
|
||||
36
platforms/chibios/converters/promicro_to_michi/_pin_defs.h
Normal file
36
platforms/chibios/converters/promicro_to_michi/_pin_defs.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2022 QMK
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
// Left side (front)
|
||||
#define D3 0U
|
||||
#define D2 1U
|
||||
// GND
|
||||
// GND
|
||||
#define D1 2U
|
||||
#define D0 3U
|
||||
#define D4 13U
|
||||
#define C6 4U
|
||||
#define D7 9U
|
||||
#define E6 10U
|
||||
#define B4 11U
|
||||
#define B5 12U
|
||||
|
||||
// Right side (front)
|
||||
// RAW
|
||||
// GND
|
||||
// RESET
|
||||
// VCC
|
||||
#define F4 29U
|
||||
#define F5 28U
|
||||
#define F6 27U
|
||||
#define F7 26U
|
||||
#define B1 20U
|
||||
#define B3 19U
|
||||
#define B2 18U
|
||||
#define B6 17U
|
||||
|
||||
// LEDs (Mapped to unused pins to avoid collisions)
|
||||
#define D5 14U
|
||||
#define B0 15U
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# Michi MCU settings for converting AVR projects
|
||||
MCU := RP2040
|
||||
BOARD := QMK_PM2040
|
||||
BOOTLOADER := rp2040
|
||||
|
||||
# These are defaults based on what has been implemented for RP2040 boards
|
||||
SERIAL_DRIVER ?= vendor
|
||||
WS2812_DRIVER ?= vendor
|
||||
BACKLIGHT_DRIVER ?= software
|
||||
|
|
@ -0,0 +1 @@
|
|||
BACKLIGHT_DRIVER ?= software
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2023 QMK
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
// Left side (front)
|
||||
#define D3 0U
|
||||
#define D2 1U
|
||||
// GND
|
||||
// GND
|
||||
#define D1 2U
|
||||
#define D0 3U
|
||||
#define D4 4U
|
||||
#define C6 5U
|
||||
#define D7 6U
|
||||
#define E6 7U
|
||||
#define B4 8U
|
||||
#define B5 9U
|
||||
|
||||
// Right side (front)
|
||||
// RAW
|
||||
// GND
|
||||
// RESET
|
||||
// VCC
|
||||
#define F4 29U
|
||||
#define F5 28U
|
||||
#define F6 27U
|
||||
#define F7 26U
|
||||
#define B1 22U
|
||||
#define B3 20U
|
||||
#define B2 23U
|
||||
#define B6 21U
|
||||
|
||||
// LEDs
|
||||
#define D5 12U
|
||||
#define B0 13U
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
# rp2040_ce MCU settings for converting AVR projects
|
||||
MCU := RP2040
|
||||
BOARD := QMK_PM2040
|
||||
BOOTLOADER := rp2040
|
||||
|
||||
# These are defaults based on what has been implemented for RP2040 boards
|
||||
SERIAL_DRIVER ?= vendor
|
||||
WS2812_DRIVER ?= vendor
|
||||
BACKLIGHT_DRIVER ?= software
|
||||
OPT_DEFS += -DUSB_VBUS_PIN=19U
|
||||
|
|
@ -22,8 +22,8 @@
|
|||
# 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
|
||||
# error "You need to set one of the 'STM32_ADC_USE_ADCx' settings to TRUE in your mcuconf.h to use the ADC."
|
||||
#if !RP_ADC_USE_ADC1 && !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 'xxx_ADC_USE_ADCx' settings to TRUE in your mcuconf.h to use the ADC."
|
||||
#endif
|
||||
|
||||
#if STM32_ADC_DUAL_MODE
|
||||
|
|
@ -37,12 +37,12 @@
|
|||
// 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
|
||||
|
||||
// BODGE to make v2 look like v1,3 and 4
|
||||
#ifdef USE_ADCV2
|
||||
#if defined(USE_ADCV2) || defined(RP2040)
|
||||
# if !defined(ADC_SMPR_SMP_1P5) && defined(ADC_SAMPLE_3)
|
||||
# define ADC_SMPR_SMP_1P5 ADC_SAMPLE_3
|
||||
# define ADC_SMPR_SMP_7P5 ADC_SAMPLE_15
|
||||
|
|
@ -74,7 +74,7 @@
|
|||
|
||||
/* User configurable ADC options */
|
||||
#ifndef ADC_COUNT
|
||||
# if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F4XX) || defined(GD32VF103)
|
||||
# if defined(RP2040) || defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F4XX) || defined(GD32VF103) || defined(WB32F3G71xx) || defined(WB32FQ95xx)
|
||||
# define ADC_COUNT 1
|
||||
# elif defined(STM32F3XX)
|
||||
# define ADC_COUNT 4
|
||||
|
|
@ -121,11 +121,13 @@ 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),
|
||||
.smpr1 = ADC_SMPR1_SMP_AN10(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN11(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN12(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN13(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN14(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN15(ADC_SAMPLING_RATE),
|
||||
#elif defined(RP2040)
|
||||
// RP2040 does not have any extra config here
|
||||
#else
|
||||
.cfgr = ADC_CFGR_CONT | ADC_RESOLUTION,
|
||||
.smpr = {ADC_SMPR1_SMP_AN0(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN1(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN2(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN3(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN4(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN5(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN6(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN7(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN8(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN9(ADC_SAMPLING_RATE), ADC_SMPR2_SMP_AN10(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN11(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN12(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN13(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN14(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN15(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN16(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN17(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN18(ADC_SAMPLING_RATE)},
|
||||
|
|
@ -136,22 +138,22 @@ static ADCConversionGroup adcConversionGroup = {
|
|||
__attribute__((weak)) adc_mux pinToMux(pin_t pin) {
|
||||
switch (pin) {
|
||||
#if defined(STM32F0XX)
|
||||
case A0: return TO_MUX( ADC_CHSELR_CHSEL0, 0 );
|
||||
case A1: return TO_MUX( ADC_CHSELR_CHSEL1, 0 );
|
||||
case A2: return TO_MUX( ADC_CHSELR_CHSEL2, 0 );
|
||||
case A3: return TO_MUX( ADC_CHSELR_CHSEL3, 0 );
|
||||
case A4: return TO_MUX( ADC_CHSELR_CHSEL4, 0 );
|
||||
case A5: return TO_MUX( ADC_CHSELR_CHSEL5, 0 );
|
||||
case A6: return TO_MUX( ADC_CHSELR_CHSEL6, 0 );
|
||||
case A7: return TO_MUX( ADC_CHSELR_CHSEL7, 0 );
|
||||
case B0: return TO_MUX( ADC_CHSELR_CHSEL8, 0 );
|
||||
case B1: return TO_MUX( ADC_CHSELR_CHSEL9, 0 );
|
||||
case C0: return TO_MUX( ADC_CHSELR_CHSEL10, 0 );
|
||||
case C1: return TO_MUX( ADC_CHSELR_CHSEL11, 0 );
|
||||
case C2: return TO_MUX( ADC_CHSELR_CHSEL12, 0 );
|
||||
case C3: return TO_MUX( ADC_CHSELR_CHSEL13, 0 );
|
||||
case C4: return TO_MUX( ADC_CHSELR_CHSEL14, 0 );
|
||||
case C5: return TO_MUX( ADC_CHSELR_CHSEL15, 0 );
|
||||
case A0: return TO_MUX( 0, 0 );
|
||||
case A1: return TO_MUX( 1, 0 );
|
||||
case A2: return TO_MUX( 2, 0 );
|
||||
case A3: return TO_MUX( 3, 0 );
|
||||
case A4: return TO_MUX( 4, 0 );
|
||||
case A5: return TO_MUX( 5, 0 );
|
||||
case A6: return TO_MUX( 6, 0 );
|
||||
case A7: return TO_MUX( 7, 0 );
|
||||
case B0: return TO_MUX( 8, 0 );
|
||||
case B1: return TO_MUX( 9, 0 );
|
||||
case C0: return TO_MUX( 10, 0 );
|
||||
case C1: return TO_MUX( 11, 0 );
|
||||
case C2: return TO_MUX( 12, 0 );
|
||||
case C3: return TO_MUX( 13, 0 );
|
||||
case C4: return TO_MUX( 14, 0 );
|
||||
case C5: return TO_MUX( 15, 0 );
|
||||
#elif defined(STM32F3XX)
|
||||
case A0: return TO_MUX( ADC_CHANNEL_IN1, 0 );
|
||||
case A1: return TO_MUX( ADC_CHANNEL_IN2, 0 );
|
||||
|
|
@ -219,7 +221,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 );
|
||||
|
|
@ -238,6 +240,11 @@ __attribute__((weak)) adc_mux pinToMux(pin_t pin) {
|
|||
case C5: return TO_MUX( ADC_CHANNEL_IN15, 0 );
|
||||
// STM32F103x[C-G] in 144-pin packages also have analog inputs on F6...F10, but they are on ADC3, and the
|
||||
// ChibiOS ADC driver for STM32F1xx currently supports only ADC1, therefore these pins are not usable.
|
||||
#elif defined(RP2040)
|
||||
case 26U: return TO_MUX(0, 0);
|
||||
case 27U: return TO_MUX(1, 0);
|
||||
case 28U: return TO_MUX(2, 0);
|
||||
case 29U: return TO_MUX(3, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +255,7 @@ __attribute__((weak)) adc_mux pinToMux(pin_t pin) {
|
|||
|
||||
static inline ADCDriver* intToADCDriver(uint8_t adcInt) {
|
||||
switch (adcInt) {
|
||||
#if STM32_ADC_USE_ADC1
|
||||
#if RP_ADC_USE_ADC1 || STM32_ADC_USE_ADC1 || WB32_ADC_USE_ADC1
|
||||
case 0:
|
||||
return &ADCD1;
|
||||
#endif
|
||||
|
|
@ -296,6 +303,8 @@ int16_t adc_read(adc_mux mux) {
|
|||
adcConversionGroup.chselr = 1 << mux.input; /*no macro to convert N to ADC_CHSELR_CHSEL1*/
|
||||
#elif defined(USE_ADCV2)
|
||||
adcConversionGroup.sqr3 = ADC_SQR3_SQ1_N(mux.input);
|
||||
#elif defined(RP2040)
|
||||
adcConversionGroup.channel_mask = 1 << mux.input;
|
||||
#else
|
||||
adcConversionGroup.sqr[0] = ADC_SQR1_SQ1_N(mux.input);
|
||||
#endif
|
||||
|
|
@ -310,7 +319,7 @@ int16_t adc_read(adc_mux mux) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef USE_ADCV2
|
||||
#if defined(USE_ADCV2) || defined(RP2040)
|
||||
// fake 12-bit -> N-bit scale
|
||||
return (*sampleBuffer) >> (12 - ADC_RESOLUTION);
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ static const DACConfig dac_conf = {.init = AUDIO_DAC_OFF_VALUE, .datamode = DAC_
|
|||
*/
|
||||
static const DACConversionGroup dac_conv_cfg = {.num_channels = 1U, .end_cb = dac_end, .error_cb = dac_error, .trigger = DAC_TRG(0b000)};
|
||||
|
||||
void audio_driver_initialize() {
|
||||
void audio_driver_initialize(void) {
|
||||
if ((AUDIO_PIN == A4) || (AUDIO_PIN_ALT == A4)) {
|
||||
palSetLineMode(A4, PAL_MODE_INPUT_ANALOG);
|
||||
dacStart(&DACD1, &dac_conf);
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ static void gpt_audio_state_cb(GPTDriver *gptp) {
|
|||
}
|
||||
}
|
||||
|
||||
void audio_driver_initialize() {
|
||||
void audio_driver_initialize(void) {
|
||||
if ((AUDIO_PIN == A4) || (AUDIO_PIN_ALT == A4)) {
|
||||
palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG);
|
||||
dacStart(&DACD1, &dac_conf_ch1);
|
||||
|
|
|
|||
|
|
@ -1,29 +1,15 @@
|
|||
/* Copyright 2020 Jack Humbert
|
||||
* Copyright 2020 JohSchneider
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
// Copyright 2022 Stefan Kerkmann
|
||||
// Copyright 2020 Jack Humbert
|
||||
// Copyright 2020 JohSchneider
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
/*
|
||||
Audio Driver: PWM
|
||||
|
||||
the duty-cycle is always kept at 50%, and the pwm-period is adjusted to match the frequency of a note to be played back.
|
||||
|
||||
this driver uses the chibios-PWM system to produce a square-wave on specific output pins that are connected to the PWM hardware.
|
||||
The hardware directly toggles the pin via its alternate function. see your MCUs data-sheet for which pin can be driven by what timer - looking for TIMx_CHy and the corresponding alternate function.
|
||||
|
||||
*/
|
||||
// Audio Driver: PWM the duty-cycle is always kept at 50%, and the pwm-period is
|
||||
// adjusted to match the frequency of a note to be played back. This driver uses
|
||||
// the chibios-PWM system to produce a square-wave on specific output pins that
|
||||
// are connected to the PWM hardware. The hardware directly toggles the pin via
|
||||
// its alternate function. see your MCUs data-sheet for which pin can be driven
|
||||
// by what timer - looking for TIMx_CHy and the corresponding alternate
|
||||
// function.
|
||||
|
||||
#include "audio.h"
|
||||
#include "ch.h"
|
||||
|
|
@ -33,53 +19,36 @@ The hardware directly toggles the pin via its alternate function. see your MCUs
|
|||
# error "Audio feature enabled, but no pin selected - see docs/feature_audio under the ARM PWM settings"
|
||||
#endif
|
||||
|
||||
#if !defined(AUDIO_PWM_COUNTER_FREQUENCY)
|
||||
# define AUDIO_PWM_COUNTER_FREQUENCY 100000
|
||||
#endif
|
||||
|
||||
extern bool playing_note;
|
||||
extern bool playing_melody;
|
||||
extern uint8_t note_timbre;
|
||||
|
||||
static PWMConfig pwmCFG = {
|
||||
.frequency = 100000, /* PWM clock frequency */
|
||||
// CHIBIOS-BUG? can't set the initial period to <2, or the pwm (hard or software) takes ~130ms with .frequency=500000 for a pwmChangePeriod to take effect; with no output=silence in the meantime
|
||||
.period = 2, /* initial PWM period (in ticks) 1S (1/10kHz=0.1mS 0.1ms*10000 ticks=1S) */
|
||||
.callback = NULL, /* no callback, the hardware directly toggles the pin */
|
||||
.channels =
|
||||
{
|
||||
#if AUDIO_PWM_CHANNEL == 4
|
||||
{PWM_OUTPUT_DISABLED, NULL}, /* channel 0 -> TIMx_CH1 */
|
||||
{PWM_OUTPUT_DISABLED, NULL}, /* channel 1 -> TIMx_CH2 */
|
||||
{PWM_OUTPUT_DISABLED, NULL}, /* channel 2 -> TIMx_CH3 */
|
||||
{PWM_OUTPUT_ACTIVE_HIGH, NULL} /* channel 3 -> TIMx_CH4 */
|
||||
#elif AUDIO_PWM_CHANNEL == 3
|
||||
{PWM_OUTPUT_DISABLED, NULL},
|
||||
{PWM_OUTPUT_DISABLED, NULL},
|
||||
{PWM_OUTPUT_ACTIVE_HIGH, NULL}, /* TIMx_CH3 */
|
||||
{PWM_OUTPUT_DISABLED, NULL}
|
||||
#elif AUDIO_PWM_CHANNEL == 2
|
||||
{PWM_OUTPUT_DISABLED, NULL},
|
||||
{PWM_OUTPUT_ACTIVE_HIGH, NULL}, /* TIMx_CH2 */
|
||||
{PWM_OUTPUT_DISABLED, NULL},
|
||||
{PWM_OUTPUT_DISABLED, NULL}
|
||||
#else /*fallback to CH1 */
|
||||
{PWM_OUTPUT_ACTIVE_HIGH, NULL}, /* TIMx_CH1 */
|
||||
{PWM_OUTPUT_DISABLED, NULL},
|
||||
{PWM_OUTPUT_DISABLED, NULL},
|
||||
{PWM_OUTPUT_DISABLED, NULL}
|
||||
#endif
|
||||
},
|
||||
};
|
||||
static PWMConfig pwmCFG = {.frequency = AUDIO_PWM_COUNTER_FREQUENCY, /* PWM clock frequency */
|
||||
.period = 2,
|
||||
.callback = NULL,
|
||||
.channels = {[(AUDIO_PWM_CHANNEL - 1)] = {.mode = PWM_OUTPUT_ACTIVE_HIGH, .callback = NULL}}};
|
||||
|
||||
static float channel_1_frequency = 0.0f;
|
||||
void channel_1_set_frequency(float freq) {
|
||||
|
||||
void channel_1_set_frequency(float freq) {
|
||||
channel_1_frequency = freq;
|
||||
|
||||
if (freq <= 0.0) // a pause/rest has freq=0
|
||||
if (freq <= 0.0) {
|
||||
// a pause/rest has freq=0
|
||||
return;
|
||||
}
|
||||
|
||||
pwmcnt_t period = (pwmCFG.frequency / freq);
|
||||
pwmChangePeriod(&AUDIO_PWM_DRIVER, period);
|
||||
pwmEnableChannel(&AUDIO_PWM_DRIVER, AUDIO_PWM_CHANNEL - 1,
|
||||
// adjust the duty-cycle so that the output is for 'note_timbre' duration HIGH
|
||||
PWM_PERCENTAGE_TO_WIDTH(&AUDIO_PWM_DRIVER, (100 - note_timbre) * 100));
|
||||
chSysLockFromISR();
|
||||
pwmChangePeriodI(&AUDIO_PWM_DRIVER, period);
|
||||
pwmEnableChannelI(&AUDIO_PWM_DRIVER, AUDIO_PWM_CHANNEL - 1,
|
||||
// adjust the duty-cycle so that the output is for 'note_timbre' duration HIGH
|
||||
PWM_PERCENTAGE_TO_WIDTH(&AUDIO_PWM_DRIVER, (100 - note_timbre) * 100));
|
||||
chSysUnlockFromISR();
|
||||
}
|
||||
|
||||
float channel_1_get_frequency(void) {
|
||||
|
|
@ -95,54 +64,53 @@ void channel_1_stop(void) {
|
|||
pwmStop(&AUDIO_PWM_DRIVER);
|
||||
}
|
||||
|
||||
static void gpt_callback(GPTDriver *gptp);
|
||||
GPTConfig gptCFG = {
|
||||
/* a whole note is one beat, which is - per definition in musical_notes.h - set to 64
|
||||
the longest note is BREAVE_DOT=128+64=192, the shortest SIXTEENTH=4
|
||||
the tempo (which might vary!) is in bpm (beats per minute)
|
||||
therefore: if the timer ticks away at .frequency = (60*64)Hz,
|
||||
and the .interval counts from 64 downwards - audio_update_state is
|
||||
called just often enough to not miss any notes
|
||||
*/
|
||||
.frequency = 60 * 64,
|
||||
.callback = gpt_callback,
|
||||
};
|
||||
static virtual_timer_t audio_vt;
|
||||
static void audio_callback(virtual_timer_t *vtp, void *p);
|
||||
|
||||
void audio_driver_initialize(void) {
|
||||
pwmStart(&AUDIO_PWM_DRIVER, &pwmCFG);
|
||||
|
||||
// connect the AUDIO_PIN to the PWM hardware
|
||||
#if defined(USE_GPIOV1) // STM32F103C8
|
||||
palSetLineMode(AUDIO_PIN, PAL_MODE_ALTERNATE_PUSHPULL);
|
||||
#else // GPIOv2 (or GPIOv3 for f4xx, which is the same/compatible at this command)
|
||||
palSetLineMode(AUDIO_PIN, PAL_MODE_ALTERNATE(AUDIO_PWM_PAL_MODE));
|
||||
#endif
|
||||
|
||||
gptStart(&AUDIO_STATE_TIMER, &gptCFG);
|
||||
}
|
||||
|
||||
void audio_driver_start(void) {
|
||||
channel_1_stop();
|
||||
channel_1_start();
|
||||
|
||||
if (playing_note || playing_melody) {
|
||||
gptStartContinuous(&AUDIO_STATE_TIMER, 64);
|
||||
}
|
||||
}
|
||||
|
||||
void audio_driver_stop(void) {
|
||||
channel_1_stop();
|
||||
gptStopTimer(&AUDIO_STATE_TIMER);
|
||||
}
|
||||
|
||||
/* a regular timer task, that checks the note to be currently played
|
||||
* and updates the pwm to output that frequency
|
||||
*/
|
||||
static void gpt_callback(GPTDriver *gptp) {
|
||||
// a regular timer task, that checks the note to be currently played and updates
|
||||
// the pwm to output that frequency.
|
||||
static void audio_callback(virtual_timer_t *vtp, void *p) {
|
||||
float freq; // TODO: freq_alt
|
||||
|
||||
if (audio_update_state()) {
|
||||
freq = audio_get_processed_frequency(0); // freq_alt would be index=1
|
||||
channel_1_set_frequency(freq);
|
||||
}
|
||||
|
||||
chSysLockFromISR();
|
||||
chVTSetI(&audio_vt, TIME_MS2I(16), audio_callback, NULL);
|
||||
chSysUnlockFromISR();
|
||||
}
|
||||
|
||||
void audio_driver_initialize(void) {
|
||||
pwmStart(&AUDIO_PWM_DRIVER, &pwmCFG);
|
||||
|
||||
// connect the AUDIO_PIN to the PWM hardware
|
||||
#if defined(USE_GPIOV1) // STM32F103C8, RP2040
|
||||
palSetLineMode(AUDIO_PIN, AUDIO_PWM_PAL_MODE);
|
||||
#else // GPIOv2 (or GPIOv3 for f4xx, which is the same/compatible at this command)
|
||||
palSetLineMode(AUDIO_PIN, PAL_MODE_ALTERNATE(AUDIO_PWM_PAL_MODE));
|
||||
#endif
|
||||
|
||||
chVTObjectInit(&audio_vt);
|
||||
}
|
||||
|
||||
void audio_driver_start(void) {
|
||||
channel_1_stop();
|
||||
channel_1_start();
|
||||
|
||||
if ((playing_note || playing_melody) && !chVTIsArmed(&audio_vt)) {
|
||||
// a whole note is one beat, which is - per definition in
|
||||
// musical_notes.h - set to 64 the longest note is
|
||||
// BREAVE_DOT=128+64=192, the shortest SIXTEENTH=4 the tempo (which
|
||||
// might vary!) is in bpm (beats per minute) therefore: if the timer
|
||||
// ticks away at 64Hz (~16.6ms) audio_update_state is called just often
|
||||
// enough to not miss any notes
|
||||
chVTSet(&audio_vt, TIME_MS2I(16), audio_callback, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void audio_driver_stop(void) {
|
||||
channel_1_stop();
|
||||
chVTReset(&audio_vt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include <ch.h>
|
||||
#include <hal.h>
|
||||
|
||||
#include "eeprom_teensy.h"
|
||||
#include "eeprom_kinetis_flexram.h"
|
||||
#include "eeconfig.h"
|
||||
|
||||
/*************************************/
|
||||
|
|
@ -22,8 +22,8 @@
|
|||
#include <stdbool.h>
|
||||
#include "util.h"
|
||||
#include "debug.h"
|
||||
#include "eeprom_stm32.h"
|
||||
#include "flash_stm32.h"
|
||||
#include "eeprom_legacy_emulated_flash.h"
|
||||
#include "legacy_flash_ops.h"
|
||||
|
||||
/*
|
||||
* We emulate eeprom by writing a snapshot compacted view of eeprom contents,
|
||||
|
|
@ -132,7 +132,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "eeprom_stm32_defs.h"
|
||||
#include "eeprom_legacy_emulated_flash_defs.h"
|
||||
/* These bits are used for optimizing encoding of bytes, 0 and 1 */
|
||||
#define FEE_WORD_ENCODING 0x8000
|
||||
#define FEE_VALUE_NEXT 0x6000
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <hal.h>
|
||||
#include "flash_stm32.h"
|
||||
#include "legacy_flash_ops.h"
|
||||
|
||||
#if defined(STM32F1XX)
|
||||
# define FLASH_SR_WRPERR FLASH_SR_WRPRTERR
|
||||
|
|
@ -24,7 +24,7 @@ extern "C" {
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef FLASH_STM32_MOCKED
|
||||
#ifdef LEGACY_FLASH_OPS_MOCKED
|
||||
extern uint8_t FlashBuf[MOCK_FLASH_SIZE];
|
||||
#endif
|
||||
|
||||
|
|
@ -102,15 +102,11 @@ static inline bool react_to_transaction(void) {
|
|||
* @return bool Indicates success of transaction.
|
||||
*/
|
||||
bool soft_serial_transaction(int index) {
|
||||
bool result = initiate_transaction((uint8_t)index);
|
||||
/* Clear the receive queue, to start with a clean slate.
|
||||
* Parts of failed transactions or spurious bytes could still be in it. */
|
||||
serial_transport_driver_clear();
|
||||
|
||||
if (unlikely(!result)) {
|
||||
/* Clear the receive queue, to start with a clean slate.
|
||||
* Parts of failed transactions or spurious bytes could still be in it. */
|
||||
serial_transport_driver_clear();
|
||||
}
|
||||
|
||||
return result;
|
||||
return initiate_transaction((uint8_t)index);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -72,27 +72,17 @@ inline void serial_transport_driver_clear(void) {
|
|||
|
||||
#elif HAL_USE_SIO
|
||||
|
||||
void clear_rx_evt_cb(SIODriver* siop) {
|
||||
osalSysLockFromISR();
|
||||
/* If errors occured during transactions this callback is invoked. We just
|
||||
* clear the error sources and move on. We rely on the fact that we check
|
||||
* for the success of the transaction by comparing the received/send bytes
|
||||
* with the actual received/send bytes in the send/receive functions. */
|
||||
sioGetAndClearEventsI(serial_driver);
|
||||
osalSysUnlockFromISR();
|
||||
}
|
||||
|
||||
static const SIOOperation serial_usart_operation = {.rx_cb = NULL, .rx_idle_cb = NULL, .tx_cb = NULL, .tx_end_cb = NULL, .rx_evt_cb = &clear_rx_evt_cb};
|
||||
|
||||
/**
|
||||
* @brief SIO Driver startup routine.
|
||||
*/
|
||||
static inline void usart_driver_start(void) {
|
||||
sioStart(serial_driver, &serial_config);
|
||||
sioStartOperation(serial_driver, &serial_usart_operation);
|
||||
}
|
||||
|
||||
inline void serial_transport_driver_clear(void) {
|
||||
if (sioHasRXErrorsX(serial_driver)) {
|
||||
sioGetAndClearErrors(serial_driver);
|
||||
}
|
||||
osalSysLock();
|
||||
while (!sioIsRXEmptyX(serial_driver)) {
|
||||
(void)sioGetX(serial_driver);
|
||||
|
|
@ -132,10 +122,10 @@ inline bool serial_transport_send(const uint8_t* source, const size_t size) {
|
|||
return serial_transport_receive(dump, bytes_left);
|
||||
# else
|
||||
/* The SIO driver directly accesses the hardware FIFOs of the USART
|
||||
* peripheral. As these are limited in depth, the RX FIFO might have been
|
||||
* overflowed by a large that we just send. Therefore we attempt to read
|
||||
* back all the data we send or until the FIFO runs empty in case it
|
||||
* overflowed and data was truncated. */
|
||||
* peripheral. As these are limited in depth, the RX FIFO might have
|
||||
* been overflowed by a large transaction that we just send. Therefore
|
||||
* we attempt to read back all the data we send or until the FIFO runs
|
||||
* empty in case it overflowed and data was truncated. */
|
||||
if (unlikely(sioSynchronizeTXEnd(serial_driver, TIME_MS2I(SERIAL_USART_TIMEOUT)) < MSG_OK)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
#include "quantum.h"
|
||||
|
||||
#if defined(WB32F3G71xx) || defined(WB32FQ95xx)
|
||||
#if defined(MCU_KINETIS)
|
||||
static SerialConfig serialConfig = {SERIAL_DEFAULT_BITRATE};
|
||||
#elif defined(WB32F3G71xx) || defined(WB32FQ95xx)
|
||||
static SerialConfig serialConfig = {SERIAL_DEFAULT_BITRATE, SD1_WRDLEN, SD1_STPBIT, SD1_PARITY, SD1_ATFLCT};
|
||||
#else
|
||||
static SerialConfig serialConfig = {SERIAL_DEFAULT_BITRATE, SD1_CR1, SD1_CR2, SD1_CR3};
|
||||
|
|
@ -30,14 +32,18 @@ void uart_init(uint32_t baud) {
|
|||
if (!is_initialised) {
|
||||
is_initialised = true;
|
||||
|
||||
#if defined(MCU_KINETIS)
|
||||
serialConfig.sc_speed = baud;
|
||||
#else
|
||||
serialConfig.speed = baud;
|
||||
#endif
|
||||
|
||||
#if defined(USE_GPIOV1)
|
||||
palSetLineMode(SD1_TX_PIN, PAL_MODE_ALTERNATE_OPENDRAIN);
|
||||
palSetLineMode(SD1_RX_PIN, PAL_MODE_ALTERNATE_OPENDRAIN);
|
||||
palSetLineMode(SD1_TX_PIN, SD1_TX_PAL_MODE);
|
||||
palSetLineMode(SD1_RX_PIN, SD1_RX_PAL_MODE);
|
||||
#else
|
||||
palSetLineMode(SD1_TX_PIN, PAL_MODE_ALTERNATE(SD1_TX_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN);
|
||||
palSetLineMode(SD1_RX_PIN, PAL_MODE_ALTERNATE(SD1_RX_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN);
|
||||
palSetLineMode(SD1_TX_PIN, PAL_MODE_ALTERNATE(SD1_TX_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST);
|
||||
palSetLineMode(SD1_RX_PIN, PAL_MODE_ALTERNATE(SD1_RX_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST);
|
||||
#endif
|
||||
sdStart(&SERIAL_DRIVER, &serialConfig);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,32 +28,47 @@
|
|||
# define SD1_TX_PIN A9
|
||||
#endif
|
||||
|
||||
#ifndef SD1_TX_PAL_MODE
|
||||
# define SD1_TX_PAL_MODE 7
|
||||
#endif
|
||||
|
||||
#ifndef SD1_RX_PIN
|
||||
# define SD1_RX_PIN A10
|
||||
#endif
|
||||
|
||||
#ifndef SD1_RX_PAL_MODE
|
||||
# define SD1_RX_PAL_MODE 7
|
||||
#endif
|
||||
|
||||
#ifndef SD1_CTS_PIN
|
||||
# define SD1_CTS_PIN A11
|
||||
#endif
|
||||
|
||||
#ifndef SD1_CTS_PAL_MODE
|
||||
# define SD1_CTS_PAL_MODE 7
|
||||
#endif
|
||||
|
||||
#ifndef SD1_RTS_PIN
|
||||
# define SD1_RTS_PIN A12
|
||||
#endif
|
||||
|
||||
#ifndef SD1_RTS_PAL_MODE
|
||||
# define SD1_RTS_PAL_MODE 7
|
||||
#ifdef USE_GPIOV1
|
||||
# ifndef SD1_TX_PAL_MODE
|
||||
# define SD1_TX_PAL_MODE PAL_MODE_ALTERNATE_PUSHPULL
|
||||
# endif
|
||||
# ifndef SD1_RX_PAL_MODE
|
||||
# define SD1_RX_PAL_MODE PAL_MODE_INPUT
|
||||
# endif
|
||||
# ifndef SD1_CTS_PAL_MODE
|
||||
# define SD1_CTS_PAL_MODE PAL_MODE_INPUT
|
||||
# endif
|
||||
# ifndef SD1_RTS_PAL_MODE
|
||||
# define SD1_RTS_PAL_MODE PAL_MODE_ALTERNATE_PUSHPULL
|
||||
# endif
|
||||
#else
|
||||
# ifndef SD1_TX_PAL_MODE
|
||||
# define SD1_TX_PAL_MODE 7
|
||||
# endif
|
||||
|
||||
# ifndef SD1_RX_PAL_MODE
|
||||
# define SD1_RX_PAL_MODE 7
|
||||
# endif
|
||||
|
||||
# ifndef SD1_CTS_PAL_MODE
|
||||
# define SD1_CTS_PAL_MODE 7
|
||||
# endif
|
||||
|
||||
# ifndef SD1_RTS_PAL_MODE
|
||||
# define SD1_RTS_PAL_MODE 7
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SD1_CR1
|
||||
|
|
|
|||
|
|
@ -140,9 +140,8 @@ void pio_serve_interrupt(void) {
|
|||
// strength is chosen because the transmitting side must still be able to drive
|
||||
// the signal low. With this configuration the rise times are fast enough and
|
||||
// the generated low level with 360mV will generate a logical zero.
|
||||
static inline void enter_rx_state(void) {
|
||||
static void __no_inline_not_in_flash_func(enter_rx_state)(void) {
|
||||
osalSysLock();
|
||||
nvicEnableVector(RP_USBCTRL_IRQ_NUMBER, RP_IRQ_USB0_PRIORITY);
|
||||
// Wait for the transmitting state machines FIFO to run empty. At this point
|
||||
// the last byte has been pulled from the transmitting state machines FIFO
|
||||
// into the output shift register. We have to wait a tiny bit more until
|
||||
|
|
@ -162,11 +161,8 @@ static inline void enter_rx_state(void) {
|
|||
osalSysUnlock();
|
||||
}
|
||||
|
||||
static inline void leave_rx_state(void) {
|
||||
static void __no_inline_not_in_flash_func(leave_rx_state)(void) {
|
||||
osalSysLock();
|
||||
// We don't want to be interrupted by frequent (1KHz) USB interrupts while
|
||||
// doing our timing critical sending operation.
|
||||
nvicDisableVector(RP_USBCTRL_IRQ_NUMBER);
|
||||
// In Half-duplex operation the tx pin dual-functions as sender and
|
||||
// receiver. To not receive the data we will send, we disable the receiving
|
||||
// state machine.
|
||||
|
|
@ -185,12 +181,13 @@ static inline void leave_rx_state(void) {}
|
|||
#endif
|
||||
|
||||
/**
|
||||
* @brief Clear the RX and TX hardware FIFOs of the state machines.
|
||||
* @brief Clear the FIFO of the RX state machine.
|
||||
*/
|
||||
inline void serial_transport_driver_clear(void) {
|
||||
osalSysLock();
|
||||
pio_sm_clear_fifos(pio, rx_state_machine);
|
||||
pio_sm_clear_fifos(pio, tx_state_machine);
|
||||
while (!pio_sm_is_rx_fifo_empty(pio, rx_state_machine)) {
|
||||
pio_sm_clear_fifos(pio, rx_state_machine);
|
||||
}
|
||||
osalSysUnlock();
|
||||
}
|
||||
|
||||
|
|
@ -198,11 +195,6 @@ static inline msg_t sync_tx(sysinterval_t timeout) {
|
|||
msg_t msg = MSG_OK;
|
||||
osalSysLock();
|
||||
while (pio_sm_is_tx_fifo_full(pio, tx_state_machine)) {
|
||||
#if !defined(SERIAL_USART_FULL_DUPLEX)
|
||||
// Enable USB interrupts again, because we might sleep for a long time
|
||||
// here and don't want to be disconnected from the host.
|
||||
nvicEnableVector(RP_USBCTRL_IRQ_NUMBER, RP_IRQ_USB0_PRIORITY);
|
||||
#endif
|
||||
pio_set_irq0_source_enabled(pio, pis_sm0_tx_fifo_not_full + tx_state_machine, true);
|
||||
msg = osalThreadSuspendTimeoutS(&tx_thread, timeout);
|
||||
if (msg < MSG_OK) {
|
||||
|
|
@ -210,10 +202,6 @@ static inline msg_t sync_tx(sysinterval_t timeout) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
#if !defined(SERIAL_USART_FULL_DUPLEX)
|
||||
// Entering timing critical territory again.
|
||||
nvicDisableVector(RP_USBCTRL_IRQ_NUMBER);
|
||||
#endif
|
||||
osalSysUnlock();
|
||||
return msg;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
// Copyright 2022 Stefan Kerkmann
|
||||
// Copyright 2022 Stefan Kerkmann (@KarlK90)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "quantum.h"
|
||||
#include "ws2812.h"
|
||||
#include "hardware/pio.h"
|
||||
#include "hardware/timer.h"
|
||||
#include "hardware/clocks.h"
|
||||
// Keep this exact include order otherwise we run into naming conflicts between
|
||||
// pico-sdk and rp2040.h which we don't control.
|
||||
#include "quantum.h"
|
||||
#include "hardware/pio.h"
|
||||
|
||||
#if !defined(MCU_RP)
|
||||
# error PIO Driver is only available for Raspberry Pi 2040 MCUs!
|
||||
|
|
@ -17,53 +20,156 @@ static const PIO pio = pio0;
|
|||
#endif
|
||||
|
||||
#if !defined(RP_DMA_PRIORITY_WS2812)
|
||||
# define RP_DMA_PRIORITY_WS2812 12
|
||||
# define RP_DMA_PRIORITY_WS2812 3
|
||||
#endif
|
||||
|
||||
static int state_machine = -1;
|
||||
|
||||
#define WS2812_WRAP_TARGET 0
|
||||
#define WS2812_WRAP 3
|
||||
|
||||
#define WS2812_T1 2
|
||||
#define WS2812_T2 5
|
||||
#define WS2812_T3 3
|
||||
|
||||
#if defined(WS2812_EXTERNAL_PULLUP)
|
||||
|
||||
# pragma message "The GPIOs of the RP2040 are NOT 5V tolerant! Make sure to NOT apply any voltage over 3.3V to the RGB data pin."
|
||||
|
||||
// clang-format off
|
||||
static const uint16_t ws2812_program_instructions[] = {
|
||||
// .wrap_target
|
||||
0x7221, // 0: out x, 1 side 1 [2]
|
||||
0x0123, // 1: jmp !x, 3 side 0 [1]
|
||||
0x0400, // 2: jmp 0 side 0 [4]
|
||||
0xb442, // 3: nop side 1 [4]
|
||||
// .wrap
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
static const uint16_t ws2812_program_instructions[] = {
|
||||
// .wrap_target
|
||||
0x6221, // 0: out x, 1 side 0 [2]
|
||||
0x1123, // 1: jmp !x, 3 side 1 [1]
|
||||
0x1400, // 2: jmp 0 side 1 [4]
|
||||
0xa442, // 3: nop side 0 [4]
|
||||
// .wrap
|
||||
};
|
||||
// clang-format on
|
||||
#endif
|
||||
|
||||
/*================== WS2812 PIO TIMINGS =================*/
|
||||
|
||||
// WS2812_T1L rounded to 50ns intervals and split into two wait timings
|
||||
#define PIO_T1L (WS2812_T1L / 50)
|
||||
#define PIO_T1L_A (MAX(CEILING(PIO_T1L, 2) - 1, 0))
|
||||
#define PIO_T1L_B (MAX(PIO_T1L / 2 - 1, 0))
|
||||
|
||||
// WS2812_T0L rounded to 50ns intervals
|
||||
#define PIO_T0L (MAX(WS2812_T0L / 50 - PIO_T1L, 0))
|
||||
#define PIO_T0L_A (MAX(PIO_T0L - 1, 0))
|
||||
|
||||
// WS2812_T0H rounded to 50ns intervals
|
||||
#define PIO_T0H (WS2812_T0H / 50)
|
||||
#define PIO_T0H_A MAX(PIO_T0H - 1, 0)
|
||||
|
||||
// WS2812_T1H rounded to 50ns intervals and split into two wait timings
|
||||
#define PIO_T1H (MAX(WS2812_T1H / 50 - PIO_T0H, 0))
|
||||
#define PIO_T1H_A (MAX((CEILING(PIO_T1H, 2) - 1), 0))
|
||||
#define PIO_T1H_B (MAX((PIO_T1H / 2) - 1, 0))
|
||||
|
||||
#if (WS2812_T0L % 50) != 0
|
||||
# pragma message "WS2812_T0L is not given in an 50ns interval, it will be rounded to the next 50ns"
|
||||
#endif
|
||||
|
||||
#if (WS2812_T0H % 50) != 0
|
||||
# pragma message "WS2812_T0H is not given in an 50ns interval, it will be rounded to the next 50ns"
|
||||
#endif
|
||||
|
||||
#if (WS2812_T1L % 50) != 0
|
||||
# pragma message "WS2812_T0L is not given in an 50ns interval, it will be rounded to the next 50ns"
|
||||
#endif
|
||||
|
||||
#if (WS2812_T1H % 50) != 0
|
||||
# pragma message "WS2812_T0H is not given in an 50ns interval, it will be rounded to the next 50ns"
|
||||
#endif
|
||||
|
||||
#if WS2812_T0L < WS2812_T1L
|
||||
# error WS2812_T0L is shorter than WS2812_T1L, this is impossible to express in the RP2040 PIO driver. Please correct your timings.
|
||||
#endif
|
||||
|
||||
#if WS2812_T1H < WS2812_T0H
|
||||
# error WS2812_T1H is shorter than WS2812_T0H, this is impossible to express in the RP2040 PIO driver. Please correct your timings.
|
||||
#endif
|
||||
|
||||
#if WS2812_T0L > (850 + WS2812_T1L)
|
||||
# error WS2812_T0L is longer than 850ns + WS2812_T1L, this is impossible to express in the RP2040 PIO driver. Please correct your timings.
|
||||
#endif
|
||||
|
||||
#if WS2812_T0H > 850
|
||||
# error WS2812_T0H is longer than 850ns, this is impossible to express in the RP2040 PIO driver. Please correct your timings.
|
||||
#endif
|
||||
|
||||
#if WS2812_T1H > (1700 + WS2812_T0H)
|
||||
# error WS2812_T1H is longer than 1700ns + WS2812_T0H, this is impossible to express in the RP2040 PIO driver. Please correct your timings.
|
||||
#endif
|
||||
|
||||
#if WS2812_T1L > 1700
|
||||
# error WS2812_T1L is longer than 1700ns, this is impossible to express in the RP2040 PIO driver. Please correct your timings.
|
||||
#endif
|
||||
|
||||
#if WS2812_T0L < (50 + WS2812_T1L)
|
||||
# error WS2812_T0L is shorter than 50ns + WS2812_T1L, this is impossible to express in the RP2040 PIO driver. Please correct your timings.
|
||||
#endif
|
||||
|
||||
#if WS2812_T0H < 50
|
||||
# error WS2812_T0H is shorter than 50ns, this is impossible to express in the RP2040 PIO driver. Please correct your timings.
|
||||
#endif
|
||||
|
||||
#if WS2812_T1H < (100 + WS2812_T0H)
|
||||
# error WS2812_T1H is longer than 100ns + WS2812_T0H, this is impossible to express in the RP2040 PIO driver. Please correct your timings.
|
||||
#endif
|
||||
|
||||
#if WS2812_T1L < 100
|
||||
# error WS2812_T1L is longer than 1700ns, this is impossible to express in the RP2040 PIO driver. Please correct your timings.
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Helper macro to binary patch the delay part of an per-compiled PIO
|
||||
* opcode.
|
||||
*/
|
||||
#define PIO_DELAY(delay, opcode) (((delay & 0xF) << 8U) | opcode)
|
||||
|
||||
#define WS2812_WRAP_TARGET 0
|
||||
#define WS2812_WRAP 5
|
||||
|
||||
static const uint16_t ws2812_program_instructions[] = {
|
||||
// .wrap_target
|
||||
PIO_DELAY(PIO_T1L_A, 0x6021), // 0: out x, 1 side 0 // T1L (max. 1700ns)
|
||||
PIO_DELAY(PIO_T1L_B, 0xa042), // 1: nop side 0 // T1L
|
||||
PIO_DELAY(PIO_T0H_A, 0x1025), // 2: jmp !x, 5 side 1 // T0H (max. 850ns)
|
||||
PIO_DELAY(PIO_T1H_A, 0xb042), // 3: nop side 1 // T1H (max. 1700ns + T0H)
|
||||
PIO_DELAY(PIO_T1H_B, 0x1000), // 4: jmp 0 side 1 // T1H
|
||||
PIO_DELAY(PIO_T0L_A, 0xa042), // 5: nop side 0 // T0L (max. 850ns + T1L)
|
||||
// .wrap
|
||||
};
|
||||
|
||||
static const pio_program_t ws2812_program = {
|
||||
.instructions = ws2812_program_instructions,
|
||||
.length = 4,
|
||||
.length = ARRAY_SIZE(ws2812_program_instructions),
|
||||
.origin = -1,
|
||||
};
|
||||
|
||||
static uint32_t WS2812_BUFFER[RGBLED_NUM];
|
||||
static uint32_t WS2812_BUFFER[WS2812_LED_COUNT];
|
||||
static const rp_dma_channel_t* WS2812_DMA_CHANNEL;
|
||||
static uint32_t RP_DMA_MODE_WS2812;
|
||||
static int STATE_MACHINE = -1;
|
||||
|
||||
static SEMAPHORE_DECL(TRANSFER_COUNTER, 1);
|
||||
static absolute_time_t LAST_TRANSFER;
|
||||
|
||||
/**
|
||||
* @brief Convert RGBW value into WS2812 compatible 32-bit data word.
|
||||
*/
|
||||
__always_inline static uint32_t rgbw8888_to_u32(uint8_t red, uint8_t green, uint8_t blue, uint8_t white) {
|
||||
#if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB)
|
||||
return ((uint32_t)green << 24) | ((uint32_t)red << 16) | ((uint32_t)blue << 8) | ((uint32_t)white);
|
||||
#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_RGB)
|
||||
return ((uint32_t)red << 24) | ((uint32_t)green << 16) | ((uint32_t)blue << 8) | ((uint32_t)white);
|
||||
#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_BGR)
|
||||
return ((uint32_t)blue << 24) | ((uint32_t)green << 16) | ((uint32_t)red << 8) | ((uint32_t)white);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ws2812_dma_callback(void* p, uint32_t ct) {
|
||||
// We assume that there is at least one frame left in the OSR even if the TX
|
||||
// FIFO is already empty.
|
||||
rtcnt_t time_to_completion = (pio_sm_get_tx_fifo_level(pio, STATE_MACHINE) + 1) * MAX(WS2812_T1H + WS2812_T1L, WS2812_T0H + WS2812_T0L);
|
||||
|
||||
#if defined(RGBW)
|
||||
time_to_completion *= 32;
|
||||
#else
|
||||
time_to_completion *= 24;
|
||||
#endif
|
||||
|
||||
// Convert from ns to us
|
||||
time_to_completion /= 1000;
|
||||
|
||||
update_us_since_boot(&LAST_TRANSFER, time_us_64() + time_to_completion + WS2812_TRST_US);
|
||||
|
||||
osalSysLockFromISR();
|
||||
chSemSignalI(&TRANSFER_COUNTER);
|
||||
osalSysUnlockFromISR();
|
||||
}
|
||||
|
||||
bool ws2812_init(void) {
|
||||
uint pio_idx = pio_get_index(pio);
|
||||
|
|
@ -73,20 +179,23 @@ bool ws2812_init(void) {
|
|||
// clang-format off
|
||||
iomode_t rgb_pin_mode = PAL_RP_PAD_SLEWFAST |
|
||||
PAL_RP_GPIO_OE |
|
||||
#if defined(WS2812_EXTERNAL_PULLUP)
|
||||
PAL_RP_IOCTRL_OEOVER_DRVINVPERI |
|
||||
#endif
|
||||
(pio_idx == 0 ? PAL_MODE_ALTERNATE_PIO0 : PAL_MODE_ALTERNATE_PIO1);
|
||||
// clang-format on
|
||||
|
||||
palSetLineMode(RGB_DI_PIN, rgb_pin_mode);
|
||||
|
||||
state_machine = pio_claim_unused_sm(pio, true);
|
||||
if (state_machine < 0) {
|
||||
STATE_MACHINE = pio_claim_unused_sm(pio, true);
|
||||
if (STATE_MACHINE < 0) {
|
||||
dprintln("ERROR: Failed to acquire state machine for WS2812 output!");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint offset = pio_add_program(pio, &ws2812_program);
|
||||
|
||||
pio_sm_set_consecutive_pindirs(pio, state_machine, RGB_DI_PIN, 1, true);
|
||||
pio_sm_set_consecutive_pindirs(pio, STATE_MACHINE, RGB_DI_PIN, 1, true);
|
||||
|
||||
pio_sm_config config = pio_get_default_sm_config();
|
||||
sm_config_set_wrap(&config, offset + WS2812_WRAP_TARGET, offset + WS2812_WRAP);
|
||||
|
|
@ -113,58 +222,44 @@ bool ws2812_init(void) {
|
|||
sm_config_set_out_shift(&config, false, true, 24);
|
||||
#endif
|
||||
|
||||
int cycles_per_bit = WS2812_T1 + WS2812_T2 + WS2812_T3;
|
||||
float div = clock_get_hz(clk_sys) / (800.0f * KHZ * cycles_per_bit);
|
||||
// Every instruction takes 50ns to execute with a clock speed of 20 MHz,
|
||||
// giving the WS2812 PIO driver its time resolution
|
||||
float div = clock_get_hz(clk_sys) / (20.0f * MHZ);
|
||||
sm_config_set_clkdiv(&config, div);
|
||||
|
||||
pio_sm_init(pio, state_machine, offset, &config);
|
||||
pio_sm_set_enabled(pio, state_machine, true);
|
||||
pio_sm_init(pio, STATE_MACHINE, offset, &config);
|
||||
pio_sm_set_enabled(pio, STATE_MACHINE, true);
|
||||
|
||||
WS2812_DMA_CHANNEL = dmaChannelAlloc(RP_DMA_CHANNEL_ID_ANY, RP_DMA_PRIORITY_WS2812, NULL, NULL);
|
||||
WS2812_DMA_CHANNEL = dmaChannelAlloc(RP_DMA_CHANNEL_ID_ANY, RP_DMA_PRIORITY_WS2812, (rp_dmaisr_t)ws2812_dma_callback, NULL);
|
||||
dmaChannelEnableInterruptX(WS2812_DMA_CHANNEL);
|
||||
dmaChannelSetDestinationX(WS2812_DMA_CHANNEL, (uint32_t)&pio->txf[STATE_MACHINE]);
|
||||
|
||||
// clang-format off
|
||||
uint32_t mode = DMA_CTRL_TRIG_INCR_READ |
|
||||
DMA_CTRL_TRIG_DATA_SIZE_WORD |
|
||||
DMA_CTRL_TRIG_IRQ_QUIET |
|
||||
DMA_CTRL_TRIG_TREQ_SEL(pio_idx == 0 ? state_machine : state_machine + 8);
|
||||
RP_DMA_MODE_WS2812 = DMA_CTRL_TRIG_INCR_READ |
|
||||
DMA_CTRL_TRIG_DATA_SIZE_WORD |
|
||||
DMA_CTRL_TRIG_TREQ_SEL(pio == pio0 ? STATE_MACHINE : STATE_MACHINE + 8) |
|
||||
DMA_CTRL_TRIG_PRIORITY(RP_DMA_PRIORITY_WS2812);
|
||||
// clang-format on
|
||||
|
||||
dmaChannelSetModeX(WS2812_DMA_CHANNEL, mode);
|
||||
dmaChannelSetDestinationX(WS2812_DMA_CHANNEL, (uint32_t)&pio->txf[state_machine]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert RGBW value into WS2812 compatible 32-bit data word.
|
||||
*/
|
||||
__always_inline static uint32_t rgbw8888_to_u32(uint8_t red, uint8_t green, uint8_t blue, uint8_t white) {
|
||||
#if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB)
|
||||
return ((uint32_t)green << 24) | ((uint32_t)red << 16) | ((uint32_t)blue << 8) | ((uint32_t)white);
|
||||
#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_RGB)
|
||||
return ((uint32_t)red << 24) | ((uint32_t)green << 16) | ((uint32_t)blue << 8) | ((uint32_t)white);
|
||||
#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_BGR)
|
||||
return ((uint32_t)blue << 24) | ((uint32_t)green << 16) | ((uint32_t)red << 8) | ((uint32_t)white);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void sync_ws2812_transfer(void) {
|
||||
if (unlikely(dmaChannelIsBusyX(WS2812_DMA_CHANNEL) || !pio_sm_is_tx_fifo_empty(pio, state_machine))) {
|
||||
fast_timer_t start = timer_read_fast();
|
||||
do {
|
||||
// Abort the synchronization if we have to wait longer than the total
|
||||
// count of LEDs in millisecounds. This is safely much longer than it
|
||||
// would take to push all the data out.
|
||||
if (unlikely(timer_elapsed_fast(start) > RGBLED_NUM)) {
|
||||
dprintln("ERROR: WS2812 DMA transfer has stalled, aborting!");
|
||||
dmaChannelDisableX(WS2812_DMA_CHANNEL);
|
||||
return;
|
||||
}
|
||||
|
||||
} while (dmaChannelIsBusyX(WS2812_DMA_CHANNEL) || !pio_sm_is_tx_fifo_empty(pio, state_machine));
|
||||
// We wait for the WS2812 chain to reset after all data has been pushed
|
||||
// out.
|
||||
if (chSemWaitTimeout(&TRANSFER_COUNTER, TIME_MS2I(WS2812_LED_COUNT)) == MSG_TIMEOUT) {
|
||||
// Abort the synchronization if we have to wait longer than the total
|
||||
// count of LEDs in milliseconds. This is safely much longer than it
|
||||
// would take to push all the data out.
|
||||
dprintln("ERROR: WS2812 DMA transfer has stalled, aborting!");
|
||||
dmaChannelDisableX(WS2812_DMA_CHANNEL);
|
||||
pio_sm_clear_fifos(pio, STATE_MACHINE);
|
||||
pio_sm_restart(pio, STATE_MACHINE);
|
||||
chSemReset(&TRANSFER_COUNTER, 0);
|
||||
wait_us(WS2812_TRST_US);
|
||||
return;
|
||||
}
|
||||
|
||||
// Busy wait until last transfer has finished
|
||||
busy_wait_until(LAST_TRANSFER);
|
||||
}
|
||||
|
||||
void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) {
|
||||
|
|
@ -185,5 +280,6 @@ void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) {
|
|||
|
||||
dmaChannelSetSourceX(WS2812_DMA_CHANNEL, (uint32_t)WS2812_BUFFER);
|
||||
dmaChannelSetCounterX(WS2812_DMA_CHANNEL, leds);
|
||||
dmaChannelSetModeX(WS2812_DMA_CHANNEL, RP_DMA_MODE_WS2812);
|
||||
dmaChannelEnableX(WS2812_DMA_CHANNEL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,27 +17,25 @@ static flash_sector_t first_sector = UINT16_MAX;
|
|||
static flash_sector_t sector_count = UINT16_MAX;
|
||||
static BaseFlash * flash;
|
||||
|
||||
#ifndef WEAR_LEVELING_EFL_FIRST_SECTOR
|
||||
// "Automatic" detection of the flash size -- ideally ChibiOS would have this already, but alas, it doesn't.
|
||||
static inline uint32_t detect_flash_size(void) {
|
||||
# if defined(WEAR_LEVELING_EFL_FLASH_SIZE)
|
||||
#if defined(WEAR_LEVELING_EFL_FLASH_SIZE)
|
||||
return WEAR_LEVELING_EFL_FLASH_SIZE;
|
||||
# elif defined(FLASH_BANK_SIZE)
|
||||
#elif defined(FLASH_BANK_SIZE)
|
||||
return FLASH_BANK_SIZE;
|
||||
# elif defined(FLASH_SIZE)
|
||||
#elif defined(FLASH_SIZE)
|
||||
return FLASH_SIZE;
|
||||
# elif defined(FLASHSIZE_BASE)
|
||||
# if defined(QMK_MCU_SERIES_STM32F0XX) || defined(QMK_MCU_SERIES_STM32F1XX) || defined(QMK_MCU_SERIES_STM32F3XX) || defined(QMK_MCU_SERIES_STM32F4XX) || defined(QMK_MCU_SERIES_STM32G4XX) || defined(QMK_MCU_SERIES_STM32L0XX) || defined(QMK_MCU_SERIES_STM32L4XX) || defined(QMK_MCU_SERIES_GD32VF103)
|
||||
#elif defined(FLASHSIZE_BASE)
|
||||
# if defined(QMK_MCU_SERIES_STM32F0XX) || defined(QMK_MCU_SERIES_STM32F1XX) || defined(QMK_MCU_SERIES_STM32F3XX) || defined(QMK_MCU_SERIES_STM32F4XX) || defined(QMK_MCU_SERIES_STM32G4XX) || defined(QMK_MCU_SERIES_STM32L0XX) || defined(QMK_MCU_SERIES_STM32L4XX) || defined(QMK_MCU_SERIES_GD32VF103)
|
||||
return ((*(uint32_t *)FLASHSIZE_BASE) & 0xFFFFU) << 10U; // this register has the flash size in kB, so we convert it to bytes
|
||||
# elif defined(QMK_MCU_SERIES_STM32L1XX)
|
||||
# error This MCU family has an uncommon flash size register definition and has not been implemented. Perhaps try using the true EEPROM on the MCU instead?
|
||||
# endif
|
||||
# else
|
||||
# error Unknown flash size definition.
|
||||
return 0;
|
||||
# elif defined(QMK_MCU_SERIES_STM32L1XX)
|
||||
# error This MCU family has an uncommon flash size register definition and has not been implemented. Perhaps try using the true EEPROM on the MCU instead?
|
||||
# endif
|
||||
#else
|
||||
# error Unknown flash size definition.
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif // WEAR_LEVELING_EFL_FIRST_SECTOR
|
||||
|
||||
bool backing_store_init(void) {
|
||||
bs_dprintf("Init\n");
|
||||
|
|
@ -46,8 +44,9 @@ bool backing_store_init(void) {
|
|||
// Need to re-lock the EFL, as if we've just had the bootloader executing it'll already be unlocked.
|
||||
backing_store_lock();
|
||||
|
||||
const flash_descriptor_t *desc = flashGetDescriptor(flash);
|
||||
uint32_t counter = 0;
|
||||
const flash_descriptor_t *desc = flashGetDescriptor(flash);
|
||||
uint32_t counter = 0;
|
||||
uint32_t flash_size = detect_flash_size();
|
||||
|
||||
#if defined(WEAR_LEVELING_EFL_FIRST_SECTOR)
|
||||
|
||||
|
|
@ -68,7 +67,6 @@ bool backing_store_init(void) {
|
|||
#else // defined(WEAR_LEVELING_EFL_FIRST_SECTOR)
|
||||
|
||||
// Work out how many sectors we want to use, working backwards from the end of the flash
|
||||
uint32_t flash_size = detect_flash_size();
|
||||
flash_sector_t last_sector = desc->sectors_count;
|
||||
for (flash_sector_t i = 0; i < desc->sectors_count; ++i) {
|
||||
first_sector = desc->sectors_count - i - 1;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@
|
|||
# if defined(STM32_FLASH_LINE_SIZE) // from some family's stm32_registry.h file
|
||||
# define BACKING_STORE_WRITE_SIZE (STM32_FLASH_LINE_SIZE)
|
||||
# else
|
||||
# if defined(QMK_MCU_SERIES_STM32F1XX)
|
||||
# if defined(QMK_MCU_SERIES_STM32F0XX)
|
||||
# define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c
|
||||
# elif defined(QMK_MCU_SERIES_STM32F1XX)
|
||||
# define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c
|
||||
# elif defined(QMK_MCU_SERIES_STM32F3XX)
|
||||
# define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c
|
||||
|
|
@ -41,12 +43,12 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
// 2kB backing space allocated
|
||||
// 8kB backing space allocated
|
||||
#ifndef WEAR_LEVELING_BACKING_SIZE
|
||||
# define WEAR_LEVELING_BACKING_SIZE 2048
|
||||
# define WEAR_LEVELING_BACKING_SIZE 8192
|
||||
#endif // WEAR_LEVELING_BACKING_SIZE
|
||||
|
||||
// 1kB logical EEPROM
|
||||
// 4kB logical EEPROM
|
||||
#ifndef WEAR_LEVELING_LOGICAL_SIZE
|
||||
# define WEAR_LEVELING_LOGICAL_SIZE 1024
|
||||
# define WEAR_LEVELING_LOGICAL_SIZE 4096
|
||||
#endif // WEAR_LEVELING_LOGICAL_SIZE
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "timer.h"
|
||||
#include "wear_leveling.h"
|
||||
#include "wear_leveling_internal.h"
|
||||
#include "flash_stm32.h"
|
||||
#include "legacy_flash_ops.h"
|
||||
|
||||
bool backing_store_init(void) {
|
||||
bs_dprintf("Init\n");
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@
|
|||
*/
|
||||
#define WS2812_COLOR_BITS (WS2812_CHANNELS * 8)
|
||||
#define WS2812_RESET_BIT_N (1000 * WS2812_TRST_US / WS2812_TIMING)
|
||||
#define WS2812_COLOR_BIT_N (RGBLED_NUM * WS2812_COLOR_BITS) /**< Number of data bits */
|
||||
#define WS2812_BIT_N (WS2812_COLOR_BIT_N + WS2812_RESET_BIT_N) /**< Total number of bits in a frame */
|
||||
#define WS2812_COLOR_BIT_N (WS2812_LED_COUNT * WS2812_COLOR_BITS) /**< Number of data bits */
|
||||
#define WS2812_BIT_N (WS2812_COLOR_BIT_N + WS2812_RESET_BIT_N) /**< Total number of bits in a frame */
|
||||
|
||||
/**
|
||||
* @brief High period for a zero, in ticks
|
||||
|
|
@ -133,7 +133,7 @@
|
|||
/**
|
||||
* @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given bit
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref RGBLED_NUM)
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_COUNT)
|
||||
* @param[in] byte: The byte number [0, 2]
|
||||
* @param[in] bit: The bit number [0, 7]
|
||||
*
|
||||
|
|
@ -147,7 +147,7 @@
|
|||
*
|
||||
* @note The red byte is the middle byte in the color packet
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref RGBLED_NUM)
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_COUNT)
|
||||
* @param[in] bit: The bit number [0, 7]
|
||||
*
|
||||
* @return The bit index
|
||||
|
|
@ -159,7 +159,7 @@
|
|||
*
|
||||
* @note The red byte is the first byte in the color packet
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref RGBLED_NUM)
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_COUNT)
|
||||
* @param[in] bit: The bit number [0, 7]
|
||||
*
|
||||
* @return The bit index
|
||||
|
|
@ -171,7 +171,7 @@
|
|||
*
|
||||
* @note The red byte is the last byte in the color packet
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref RGBLED_NUM)
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_COUNT)
|
||||
* @param[in] bit: The bit index [0, 7]
|
||||
*
|
||||
* @return The bit index
|
||||
|
|
@ -184,7 +184,7 @@
|
|||
*
|
||||
* @note The red byte is the middle byte in the color packet
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref RGBLED_NUM)
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_COUNT)
|
||||
* @param[in] bit: The bit number [0, 7]
|
||||
*
|
||||
* @return The bit index
|
||||
|
|
@ -196,7 +196,7 @@
|
|||
*
|
||||
* @note The red byte is the first byte in the color packet
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref RGBLED_NUM)
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_COUNT)
|
||||
* @param[in] bit: The bit number [0, 7]
|
||||
*
|
||||
* @return The bit index
|
||||
|
|
@ -208,7 +208,7 @@
|
|||
*
|
||||
* @note The red byte is the last byte in the color packet
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref RGBLED_NUM)
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_COUNT)
|
||||
* @param[in] bit: The bit index [0, 7]
|
||||
*
|
||||
* @return The bit index
|
||||
|
|
@ -221,7 +221,7 @@
|
|||
*
|
||||
* @note The red byte is the middle byte in the color packet
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref RGBLED_NUM)
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_COUNT)
|
||||
* @param[in] bit: The bit number [0, 7]
|
||||
*
|
||||
* @return The bit index
|
||||
|
|
@ -233,7 +233,7 @@
|
|||
*
|
||||
* @note The red byte is the first byte in the color packet
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref RGBLED_NUM)
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_COUNT)
|
||||
* @param[in] bit: The bit number [0, 7]
|
||||
*
|
||||
* @return The bit index
|
||||
|
|
@ -245,7 +245,7 @@
|
|||
*
|
||||
* @note The red byte is the last byte in the color packet
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref RGBLED_NUM)
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_COUNT)
|
||||
* @param[in] bit: The bit index [0, 7]
|
||||
*
|
||||
* @return The bit index
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@
|
|||
# define WS2812_CHANNELS 3
|
||||
#endif
|
||||
#define BYTES_FOR_LED (BYTES_FOR_LED_BYTE * WS2812_CHANNELS)
|
||||
#define DATA_SIZE (BYTES_FOR_LED * RGBLED_NUM)
|
||||
#define DATA_SIZE (BYTES_FOR_LED * WS2812_LED_COUNT)
|
||||
#define RESET_SIZE (1000 * WS2812_TRST_US / (2 * WS2812_TIMING))
|
||||
#define PREAMBLE_SIZE 4
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ void ws2812_init(void) {
|
|||
spiStart(&WS2812_SPI, &spicfg); /* Setup transfer parameters. */
|
||||
spiSelect(&WS2812_SPI); /* Slave Select assertion. */
|
||||
#ifdef WS2812_SPI_USE_CIRCULAR_BUFFER
|
||||
spiStartSend(&WS2812_SPI, sizeof(txbuf) / sizeof(txbuf[0]), txbuf);
|
||||
spiStartSend(&WS2812_SPI, ARRAY_SIZE(txbuf), txbuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -200,9 +200,9 @@ void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) {
|
|||
// Instead spiSend can be used to send synchronously (or the thread logic can be added back).
|
||||
#ifndef WS2812_SPI_USE_CIRCULAR_BUFFER
|
||||
# ifdef WS2812_SPI_SYNC
|
||||
spiSend(&WS2812_SPI, sizeof(txbuf) / sizeof(txbuf[0]), txbuf);
|
||||
spiSend(&WS2812_SPI, ARRAY_SIZE(txbuf), txbuf);
|
||||
# else
|
||||
spiStartSend(&WS2812_SPI, sizeof(txbuf) / sizeof(txbuf[0]), txbuf);
|
||||
spiStartSend(&WS2812_SPI, ARRAY_SIZE(txbuf), txbuf);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ define EXEC_DFU_UTIL
|
|||
$(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
|
||||
endef
|
||||
|
||||
WB32_DFU_UPDATER ?= wb32-dfu-updater_cli
|
||||
|
||||
define EXEC_WB32_DFU_UPDATER
|
||||
if ! wb32-dfu-updater_cli -l | grep -q "Found DFU"; then \
|
||||
|
|
@ -34,7 +35,7 @@ define EXEC_WB32_DFU_UPDATER
|
|||
done ;\
|
||||
printf "\n" ;\
|
||||
fi
|
||||
wb32-dfu-updater_cli -D $(BUILD_DIR)/$(TARGET).bin
|
||||
$(WB32_DFU_UPDATER) -D $(BUILD_DIR)/$(TARGET).bin && $(WB32_DFU_UPDATER) -R
|
||||
endef
|
||||
|
||||
dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
|
||||
|
|
@ -100,14 +101,16 @@ endef
|
|||
teensy: $(BUILD_DIR)/$(TARGET).hex cpfirmware sizeafter
|
||||
$(call EXEC_TEENSY)
|
||||
|
||||
|
||||
flash: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
|
||||
$(SILENT) || printf "Flashing for bootloader: $(BLUE)$(BOOTLOADER)$(NO_COLOR)\n"
|
||||
ifneq ($(strip $(PROGRAM_CMD)),)
|
||||
$(UNSYNC_OUTPUT_CMD) && $(PROGRAM_CMD)
|
||||
else ifeq ($(strip $(BOOTLOADER)),kiibohd)
|
||||
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL)
|
||||
else ifeq ($(strip $(BOOTLOADER)),tinyuf2)
|
||||
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_UF2_UTIL_DEPLOY)
|
||||
else ifeq ($(strip $(BOOTLOADER)),uf2boot)
|
||||
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_UF2_UTIL_DEPLOY)
|
||||
else ifeq ($(strip $(BOOTLOADER)),rp2040)
|
||||
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_UF2_UTIL_DEPLOY)
|
||||
else ifeq ($(strip $(MCU_FAMILY)),KINETIS)
|
||||
|
|
|
|||
|
|
@ -6,10 +6,15 @@
|
|||
|
||||
hardware_id_t get_hardware_id(void) {
|
||||
hardware_id_t id = {0};
|
||||
#ifdef UID_BASE
|
||||
#if defined(RP2040)
|
||||
// Forward declare as including "hardware/flash.h" here causes more issues...
|
||||
void flash_get_unique_id(uint8_t *);
|
||||
|
||||
flash_get_unique_id((uint8_t *)&id);
|
||||
#elif defined(UID_BASE)
|
||||
id.data[0] = (uint32_t)(*((uint32_t *)UID_BASE));
|
||||
id.data[1] = (uint32_t)(*((uint32_t *)(UID_BASE + 4)));
|
||||
id.data[1] = (uint32_t)(*((uint32_t *)(UID_BASE + 8)));
|
||||
id.data[2] = (uint32_t)(*((uint32_t *)(UID_BASE + 8)));
|
||||
#endif
|
||||
return id;
|
||||
}
|
||||
|
|
|
|||
825
platforms/chibios/mcu_selection.mk
Normal file
825
platforms/chibios/mcu_selection.mk
Normal file
|
|
@ -0,0 +1,825 @@
|
|||
ifneq ($(findstring MKL26Z64, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m0plus
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 6
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = KINETIS
|
||||
MCU_SERIES = KL2x
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= MKL26Z64
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/ports/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= kl2x
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= PJRC_TEENSY_LC
|
||||
endif
|
||||
|
||||
ifneq ($(findstring MK20DX128, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = KINETIS
|
||||
MCU_SERIES = K20x
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= MK20DX128
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/ports/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= k20x5
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= PJRC_TEENSY_3
|
||||
endif
|
||||
|
||||
ifneq ($(findstring MK20DX256, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = KINETIS
|
||||
MCU_SERIES = K20x
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= MK20DX256
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/ports/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= k20x7
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= PJRC_TEENSY_3_1
|
||||
endif
|
||||
|
||||
ifneq ($(findstring MK64FX512, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = KINETIS
|
||||
MCU_SERIES = K60x
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= MK64FX512
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= k60x
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= PJRC_TEENSY_3_5
|
||||
endif
|
||||
|
||||
ifneq ($(findstring MK66FX1M0, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = KINETIS
|
||||
MCU_SERIES = MK66F18
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= MK66FX1M0
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= MK66F18
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= PJRC_TEENSY_3_6
|
||||
endif
|
||||
|
||||
ifneq ($(findstring RP2040, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m0plus
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
CHIBIOS_PORT = ARMv6-M-RP2
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = RP
|
||||
MCU_SERIES = RP2040
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
STARTUPLD_CONTRIB = $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/ld
|
||||
MCU_LDSCRIPT ?= RP2040_FLASH_TIMECRIT
|
||||
LDFLAGS += -L $(STARTUPLD_CONTRIB)
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= rp2040
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_PROMICRO_RP2040
|
||||
|
||||
# Default UF2 Bootloader settings
|
||||
UF2_FAMILY ?= RP2040
|
||||
FIRMWARE_FORMAT ?= uf2
|
||||
endif
|
||||
|
||||
ifneq ($(findstring STM32F042, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m0
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 6
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32F0xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= STM32F042x6
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32f0xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_F042X6
|
||||
|
||||
USE_FPU ?= no
|
||||
|
||||
# UF2 settings
|
||||
UF2_FAMILY ?= STM32F0
|
||||
|
||||
# Stack sizes: Since this chip has limited RAM capacity, the stack area needs to be reduced.
|
||||
# This ensures that the EEPROM page buffer fits into RAM
|
||||
USE_PROCESS_STACKSIZE = 0x600
|
||||
USE_EXCEPTIONS_STACKSIZE = 0x300
|
||||
|
||||
# Bootloader address for STM32 DFU
|
||||
STM32_BOOTLOADER_ADDRESS ?= 0x1FFFC400
|
||||
endif
|
||||
|
||||
ifneq ($(findstring STM32F072, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m0
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 6
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32F0xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= STM32F072xB
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32f0xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_F072XB
|
||||
|
||||
USE_FPU ?= no
|
||||
|
||||
# UF2 settings
|
||||
UF2_FAMILY ?= STM32F0
|
||||
|
||||
# Bootloader address for STM32 DFU
|
||||
STM32_BOOTLOADER_ADDRESS ?= 0x1FFFC800
|
||||
endif
|
||||
|
||||
ifneq ($(findstring STM32F103, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m3
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32F1xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
ifeq ($(strip $(BOOTLOADER)), uf2boot)
|
||||
MCU_LDSCRIPT ?= STM32F103xB_uf2boot
|
||||
else
|
||||
MCU_LDSCRIPT ?= STM32F103x8
|
||||
endif
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32f1xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_F103
|
||||
|
||||
USE_FPU ?= no
|
||||
|
||||
# UF2 settings
|
||||
UF2_FAMILY ?= STM32F1
|
||||
endif
|
||||
|
||||
ifneq ($(findstring STM32F303, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32F3xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
ifeq ($(strip $(BOOTLOADER)), tinyuf2)
|
||||
MCU_LDSCRIPT ?= STM32F303xC_tinyuf2
|
||||
else
|
||||
MCU_LDSCRIPT ?= STM32F303xC
|
||||
endif
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32f3xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_F303XC
|
||||
|
||||
USE_FPU ?= yes
|
||||
|
||||
# UF2 settings
|
||||
UF2_FAMILY ?= STM32F3
|
||||
|
||||
# Bootloader address for STM32 DFU
|
||||
STM32_BOOTLOADER_ADDRESS ?= 0x1FFFD800
|
||||
endif
|
||||
|
||||
ifneq ($(findstring STM32F401, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32F4xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
ifeq ($(strip $(BOOTLOADER)), tinyuf2)
|
||||
MCU_LDSCRIPT ?= STM32F401xC_tinyuf2
|
||||
else
|
||||
MCU_LDSCRIPT ?= STM32F401xC
|
||||
endif
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32f4xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_F401XC
|
||||
|
||||
USE_FPU ?= yes
|
||||
|
||||
# UF2 settings
|
||||
UF2_FAMILY ?= STM32F4
|
||||
|
||||
# Bootloader address for STM32 DFU
|
||||
STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000
|
||||
|
||||
# Revert to legacy wear-leveling driver until ChibiOS's EFL driver is fixed with 128kB and 384kB variants.
|
||||
EEPROM_DRIVER ?= wear_leveling
|
||||
WEAR_LEVELING_DRIVER ?= legacy
|
||||
endif
|
||||
|
||||
ifneq ($(findstring STM32F405, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32F4xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= STM32F405xG
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32f4xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_F405XG
|
||||
|
||||
USE_FPU ?= yes
|
||||
|
||||
# UF2 settings
|
||||
UF2_FAMILY ?= STM32F4
|
||||
|
||||
# Bootloader address for STM32 DFU
|
||||
STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000
|
||||
endif
|
||||
|
||||
ifneq ($(findstring STM32F407, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32F4xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= STM32F407xE
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32f4xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_F407XE
|
||||
|
||||
USE_FPU ?= yes
|
||||
|
||||
# UF2 settings
|
||||
UF2_FAMILY ?= STM32F4
|
||||
|
||||
# Bootloader address for STM32 DFU
|
||||
STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000
|
||||
endif
|
||||
|
||||
ifneq ($(findstring STM32F411, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32F4xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
ifeq ($(strip $(BOOTLOADER)), tinyuf2)
|
||||
MCU_LDSCRIPT ?= STM32F411xE_tinyuf2
|
||||
else
|
||||
MCU_LDSCRIPT ?= STM32F411xE
|
||||
endif
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32f4xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_F411XE
|
||||
|
||||
USE_FPU ?= yes
|
||||
|
||||
# UF2 settings
|
||||
UF2_FAMILY ?= STM32F4
|
||||
|
||||
# Bootloader address for STM32 DFU
|
||||
STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000
|
||||
endif
|
||||
|
||||
ifneq ($(findstring STM32F446, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32F4xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= STM32F446xE
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32f4xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_F446XE
|
||||
|
||||
USE_FPU ?= yes
|
||||
|
||||
# Bootloader address for STM32 DFU
|
||||
STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000
|
||||
|
||||
# Default as no chibios efl config
|
||||
EEPROM_DRIVER ?= transient
|
||||
endif
|
||||
|
||||
ifneq ($(findstring STM32G431, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32G4xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= STM32G431xB
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32g4xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_G431XB
|
||||
|
||||
USE_FPU ?= yes
|
||||
|
||||
# UF2 settings
|
||||
UF2_FAMILY ?= STM32G4
|
||||
|
||||
# Bootloader address for STM32 DFU
|
||||
STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000
|
||||
endif
|
||||
|
||||
ifneq ($(findstring STM32G474, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32G4xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= STM32G474xE
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32g4xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_G474XE
|
||||
|
||||
USE_FPU ?= yes
|
||||
|
||||
# UF2 settings
|
||||
UF2_FAMILY ?= STM32G4
|
||||
|
||||
# Bootloader address for STM32 DFU
|
||||
STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(MCU),STM32L432 STM32L442))
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32L4xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= STM32L432xC
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32l4xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_L432XC
|
||||
|
||||
PLATFORM_NAME ?= platform_l432
|
||||
|
||||
USE_FPU ?= yes
|
||||
|
||||
# UF2 settings
|
||||
UF2_FAMILY ?= STM32L4
|
||||
|
||||
# Bootloader address for STM32 DFU
|
||||
STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(MCU),STM32L433 STM32L443))
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32L4xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= STM32L432xC
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32l4xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_L433XC
|
||||
|
||||
PLATFORM_NAME ?= platform_l432
|
||||
|
||||
USE_FPU ?= yes
|
||||
|
||||
# UF2 settings
|
||||
UF2_FAMILY ?= STM32L4
|
||||
|
||||
# Bootloader address for STM32 DFU
|
||||
STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(MCU),STM32L412 STM32L422))
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32L4xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= STM32L412xB
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= stm32l4xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_STM32_L412XB
|
||||
|
||||
PLATFORM_NAME ?= platform_l412_l422
|
||||
|
||||
USE_FPU ?= yes
|
||||
|
||||
# UF2 settings
|
||||
UF2_FAMILY ?= STM32L4
|
||||
|
||||
# Bootloader address for STM32 DFU
|
||||
STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000
|
||||
endif
|
||||
|
||||
ifneq ($(findstring WB32F3G71, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m3
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = WB32
|
||||
MCU_SERIES = WB32F3G71xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= WB32F3G71x9
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= wb32f3g71xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_WB32_F3G71XX
|
||||
|
||||
USE_FPU ?= no
|
||||
|
||||
# Bootloader address for WB32 DFU
|
||||
WB32_BOOTLOADER_ADDRESS ?= 0x1FFFE000
|
||||
endif
|
||||
|
||||
ifneq ($(findstring WB32FQ95, $(MCU)),)
|
||||
# Cortex version
|
||||
MCU = cortex-m3
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = WB32
|
||||
MCU_SERIES = WB32FQ95xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= WB32FQ95xB
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= wb32fq95xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= GENERIC_WB32_FQ95XX
|
||||
|
||||
USE_FPU ?= no
|
||||
|
||||
# Bootloader address for WB32 DFU
|
||||
WB32_BOOTLOADER_ADDRESS ?= 0x1FFFE000
|
||||
endif
|
||||
|
||||
ifneq ($(findstring GD32VF103, $(MCU)),)
|
||||
# RISC-V
|
||||
MCU = risc-v
|
||||
|
||||
# RISC-V extensions and abi configuration
|
||||
MCU_ARCH = rv32imac
|
||||
MCU_ABI = ilp32
|
||||
MCU_CMODEL = medlow
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES)
|
||||
# OR
|
||||
# <chibios[-contrib]>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_PORT_NAME = GD
|
||||
MCU_FAMILY = GD32V
|
||||
MCU_SERIES = GD32VF103
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/startup/RISCV-ECLIC/compilers/GCC/ld/
|
||||
# or <keyboard_dir>/ld/
|
||||
MCU_LDSCRIPT ?= GD32VF103xB
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/RISCV-ECLIC/compilers/GCC/mk/
|
||||
MCU_STARTUP ?= gd32vf103
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/,
|
||||
# <keyboard_dir>/boards/, or drivers/boards/
|
||||
BOARD ?= SIPEED_LONGAN_NANO
|
||||
|
||||
USE_FPU ?= no
|
||||
endif
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue