diff --git a/config/generic-bigtreetech-skr-e3-dip.cfg b/config/generic-bigtreetech-skr-e3-dip.cfg index 985b99fd..01655d4f 100644 --- a/config/generic-bigtreetech-skr-e3-dip.cfg +++ b/config/generic-bigtreetech-skr-e3-dip.cfg @@ -1,8 +1,8 @@ # This file contains common pin mappings for the BIGTREETECH SKR E3 # DIP. To use this config, the firmware should be compiled for the -# STM32F103 with a "28KiB bootloader". Also, select "Enable extra -# low-level configuration options" and configure "GPIO pins to set at -# micro-controller startup" to "!PC13". +# STM32F103 with a "28KiB bootloader" and USB communication. Also, +# select "Enable extra low-level configuration options" and configure +# "GPIO pins to set at micro-controller startup" to "!PC13". # The "make flash" command does not work on the SKR E3 DIP. Instead, # after running "make", copy the generated "out/klipper.bin" file to a diff --git a/config/generic-bigtreetech-skr-mini-e3-v1.0.cfg b/config/generic-bigtreetech-skr-mini-e3-v1.0.cfg index eb7ef45d..463c90e3 100644 --- a/config/generic-bigtreetech-skr-mini-e3-v1.0.cfg +++ b/config/generic-bigtreetech-skr-mini-e3-v1.0.cfg @@ -1,8 +1,8 @@ # This file contains common pin mappings for the BIGTREETECH SKR mini # E3. To use this config, the firmware should be compiled for the -# STM32F103 with a "28KiB bootloader". Also, select "Enable extra -# low-level configuration options" and configure "GPIO pins to set at -# micro-controller startup" to "!PC13". +# STM32F103 with a "28KiB bootloader" and USB communication. Also, +# select "Enable extra low-level configuration options" and configure +# "GPIO pins to set at micro-controller startup" to "!PC13". # The "make flash" command does not work on the SKR mini E3. Instead, # after running "make", copy the generated "out/klipper.bin" file to a diff --git a/config/generic-bigtreetech-skr-mini-e3-v1.2.cfg b/config/generic-bigtreetech-skr-mini-e3-v1.2.cfg index 2e9a9c8a..a255224b 100644 --- a/config/generic-bigtreetech-skr-mini-e3-v1.2.cfg +++ b/config/generic-bigtreetech-skr-mini-e3-v1.2.cfg @@ -1,8 +1,8 @@ # This file contains common pin mappings for the BIGTREETECH SKR mini # E3 v1.2. To use this config, the firmware should be compiled for the -# STM32F103 with a "28KiB bootloader". Also, select "Enable extra -# low-level configuration options" and configure "GPIO pins to set at -# micro-controller startup" to "!PC13". +# STM32F103 with a "28KiB bootloader" and USB communication. Also, +# select "Enable extra low-level configuration options" and configure +# "GPIO pins to set at micro-controller startup" to "!PC13". # The "make flash" command does not work on the SKR mini E3. Instead, # after running "make", copy the generated "out/klipper.bin" file to a diff --git a/config/generic-bigtreetech-skr-mini-e3-v2.0.cfg b/config/generic-bigtreetech-skr-mini-e3-v2.0.cfg index 788cb150..6fb341b7 100644 --- a/config/generic-bigtreetech-skr-mini-e3-v2.0.cfg +++ b/config/generic-bigtreetech-skr-mini-e3-v2.0.cfg @@ -1,8 +1,8 @@ # This file contains common pin mappings for the BIGTREETECH SKR mini # E3 v2.0. To use this config, the firmware should be compiled for the -# STM32F103 with a "28KiB bootloader". Also, select "Enable extra -# low-level configuration options" and configure "GPIO pins to set at -# micro-controller startup" to "!PA14". +# STM32F103 with a "28KiB bootloader" and USB communication. Also, +# select "Enable extra low-level configuration options" and configure +# "GPIO pins to set at micro-controller startup" to "!PA14". # The "make flash" command does not work on the SKR mini E3. Instead, # after running "make", copy the generated "out/klipper.bin" file to a diff --git a/config/generic-bigtreetech-skr-mini-mz.cfg b/config/generic-bigtreetech-skr-mini-mz.cfg index 2384e53b..c5268a0a 100644 --- a/config/generic-bigtreetech-skr-mini-mz.cfg +++ b/config/generic-bigtreetech-skr-mini-mz.cfg @@ -1,8 +1,8 @@ # This file contains common pin mappings for the BIGTREETECH SKR mini # MZ v1.0. To use this config, the firmware should be compiled for the -# STM32F103 with a "28KiB bootloader". Also, select "Enable extra -# low-level configuration options" and configure "GPIO pins to set at -# micro-controller startup" to "!PA14". +# STM32F103 with a "28KiB bootloader" and USB communication. Also, +# select "Enable extra low-level configuration options" and configure +# "GPIO pins to set at micro-controller startup" to "!PA14". # The "make flash" command does not work on the SKR mini MZ. Instead, # after running "make", copy the generated "out/klipper.bin" file to a diff --git a/config/generic-bigtreetech-skr-mini.cfg b/config/generic-bigtreetech-skr-mini.cfg index b085b013..f2cf080d 100644 --- a/config/generic-bigtreetech-skr-mini.cfg +++ b/config/generic-bigtreetech-skr-mini.cfg @@ -1,6 +1,6 @@ # This file contains common pin mappings for the BIGTREETECH SKR # MINI. To use this config, the firmware should be compiled for the -# STM32F103 with a "28KiB bootloader". +# STM32F103 with a "28KiB bootloader" and USB communication. # The "make flash" command does not work on the SKR mini. Instead, # after running "make", copy the generated "out/klipper.bin" file to a diff --git a/config/generic-creality-v4.2.7.cfg b/config/generic-creality-v4.2.7.cfg index ef09fb41..41226828 100644 --- a/config/generic-creality-v4.2.7.cfg +++ b/config/generic-creality-v4.2.7.cfg @@ -1,11 +1,11 @@ # This file contains pin mappings for the Creality "v4.2.7" board. To # use this config, during "make menuconfig" select the STM32F103 with -# a "28KiB bootloader" and with "Use USB for communication" disabled. +# a "28KiB bootloader" and serial (on USART1 PA10/PA9) communication. # If you prefer a direct serial connection, in "make menuconfig" -# select "Enable extra low-level configuration options" and select the -# USART3 serial port, which is broken out on the 10 pin IDC cable used -# for the LCD module as follows: +# select "Enable extra low-level configuration options" and select +# serial (on USART3 PB11/PB10), which is broken out on the 10 pin IDC +# cable used for the LCD module as follows: # 3: Tx, 4: Rx, 9: GND, 10: VCC # Flash this firmware by copying "out/klipper.bin" to a SD card and diff --git a/config/generic-fysetc-cheetah-v1.1.cfg b/config/generic-fysetc-cheetah-v1.1.cfg index cae8f932..9650f37e 100644 --- a/config/generic-fysetc-cheetah-v1.1.cfg +++ b/config/generic-fysetc-cheetah-v1.1.cfg @@ -1,7 +1,7 @@ # This file contains common pin mappings for the Fysetc Cheetah v1.1 # board. To use this config, the firmware should be compiled for the -# STM32F103 with "No bootloader" and with "Use USB for communication" -# disabled. +# STM32F103 with "No bootloader" and serial (on USART1 PA10/PA9) +# communication. # The "make flash" command does not work on the Cheetah. Instead, # after running "make", run the following command to flash the board: diff --git a/config/generic-mks-robin-e3.cfg b/config/generic-mks-robin-e3.cfg index dac9d804..41eee77b 100644 --- a/config/generic-mks-robin-e3.cfg +++ b/config/generic-mks-robin-e3.cfg @@ -1,8 +1,8 @@ # This file contains common pin mappings for MKS Robin E3 boards. To # use this config, the firmware should be compiled for the STM32F103. # When running "make menuconfig", enable "extra low-level -# configuration setup", select the 20KiB bootloader, disable "USB for -# communication", and select USART1 for the "Serial Port". +# configuration setup", select the 20KiB bootloader, and serial (on +# USART1 PA10/PA9) communication. # Note that the "make flash" command does not work with MKS Robin # boards. After running "make", run the following command: diff --git a/config/generic-mks-robin-nano-v1.cfg b/config/generic-mks-robin-nano-v1.cfg index 62e40119..bb096c81 100644 --- a/config/generic-mks-robin-nano-v1.cfg +++ b/config/generic-mks-robin-nano-v1.cfg @@ -1,8 +1,8 @@ # This file contains common pin mappings for MKS Robin Nano (v1.2.004) # boards. To use this config, the firmware should be compiled for the # STM32F103. When running "make menuconfig", enable "extra low-level -# configuration setup", select the 28KiB bootloader, disable "USB for -# communication", and select USART3 for the "Serial Port". +# configuration setup", select the 28KiB bootloader, and serial (on +# USART3 PB11/PB10) communication. # Note that the "make flash" command does not work with MKS Robin # boards. After running "make", run the following command: diff --git a/config/generic-mks-robin-nano-v2.cfg b/config/generic-mks-robin-nano-v2.cfg index 80c707d7..e9da5115 100644 --- a/config/generic-mks-robin-nano-v2.cfg +++ b/config/generic-mks-robin-nano-v2.cfg @@ -1,8 +1,8 @@ # This file contains common pin mappings for MKS Robin Nano V2 # boards. To use this config, the firmware should be compiled for the # STM32F103. When running "make menuconfig", enable "extra low-level -# configuration setup", select the 28KiB bootloader, disable "USB for -# communication", and select USART3 for the "Serial Port". +# configuration setup", select the 28KiB bootloader, and serial (on +# USART3 PB11/PB10) communication. # Note that the "make flash" command does not work with MKS Robin # boards. After running "make", run the following command: diff --git a/config/printer-alfawise-u30-2018.cfg b/config/printer-alfawise-u30-2018.cfg index 0cdaae1d..d8b375e1 100644 --- a/config/printer-alfawise-u30-2018.cfg +++ b/config/printer-alfawise-u30-2018.cfg @@ -1,9 +1,9 @@ # This file contains common pin mappings for the Alfawise U30 printer. # To use this config, the firmware should be compiled for the # STM32F103. When running "make menuconfig", enable "extra low-level -# configuration setup", select the 64KiB bootloader, disable "USB for -# communication", and set "GPIO pins to set at micro-controller -# startup" to "!PC4,!PD12". +# configuration setup", select the 64KiB bootloader, serial (on USART1 +# PA10/PA9) communication, and set "GPIO pins to set at +# micro-controller startup" to "!PC4,!PD12". # The "make flash" command does not work on the Alfawise U30. Instead, # after running "make", copy the generated "out/klipper.bin" file to a diff --git a/config/printer-creality-cr6se-2020.cfg b/config/printer-creality-cr6se-2020.cfg index 10e5476f..11d827ea 100644 --- a/config/printer-creality-cr6se-2020.cfg +++ b/config/printer-creality-cr6se-2020.cfg @@ -1,7 +1,7 @@ # This file contains pin mappings for the stock 2020 Creality CR6-SE. -# To use this config, during "make menuconfig" select the -# STM32F103 with a "28KiB bootloader" and with "Use USB for -# communication" disabled. +# To use this config, during "make menuconfig" select the STM32F103 +# with a "28KiB bootloader" and serial (on USART1 PA10/PA9) +# communication. # Flash this firmware by copying "out/klipper.bin" to a SD card and # turning on the printer with the card inserted. The firmware diff --git a/config/printer-creality-ender3-v2-2020.cfg b/config/printer-creality-ender3-v2-2020.cfg index 7efe5fe2..a0ca79cb 100644 --- a/config/printer-creality-ender3-v2-2020.cfg +++ b/config/printer-creality-ender3-v2-2020.cfg @@ -1,12 +1,12 @@ # This file contains pin mappings for the stock 2020 Creality Ender 3 # V2. To use this config, during "make menuconfig" select the -# STM32F103 with a "28KiB bootloader" and with "Use USB for -# communication" disabled. +# STM32F103 with a "28KiB bootloader" and serial (on USART1 PA10/PA9) +# communication. # If you prefer a direct serial connection, in "make menuconfig" -# select "Enable extra low-level configuration options" and select the -# USART3 serial port, which is broken out on the 10 pin IDC cable used -# for the LCD module as follows: +# select "Enable extra low-level configuration options" and select +# serial (on USART3 PB11/PB10), which is broken out on the 10 pin IDC +# cable used for the LCD module as follows: # 3: Tx, 4: Rx, 9: GND, 10: VCC # Flash this firmware by copying "out/klipper.bin" to a SD card and diff --git a/config/printer-creality-ender3max-2021.cfg b/config/printer-creality-ender3max-2021.cfg index fa7559d7..dd975e02 100644 --- a/config/printer-creality-ender3max-2021.cfg +++ b/config/printer-creality-ender3max-2021.cfg @@ -1,7 +1,7 @@ # This file contains pin mappings for the stock 2020 Creality Ender 3 # MAX. To use this config, during "make menuconfig" select the -# STM32F103 with a "28KiB bootloader" and with "Use USB for -# communication" disabled. +# STM32F103 with a "28KiB bootloader" and serial (on USART1 PA10/PA9) +# communication. # Because this printer has factory wiring, mounts, and firmware for # a BLTouch, but does not ship with one at this time, default values @@ -10,9 +10,9 @@ # customize the offsets, particularly z-offset, for their specific unit. # If you prefer a direct serial connection, in "make menuconfig" -# select "Enable extra low-level configuration options" and select the -# USART3 serial port, which is broken out on the 10 pin IDC cable used -# for the LCD module as follows: +# select "Enable extra low-level configuration options" and select +# serial (on USART3 PB11/PB10), which is broken out on the 10 pin IDC +# cable used for the LCD module as follows: # 3: Tx, 4: Rx, 9: GND, 10: VCC # Flash this firmware by copying "out/klipper.bin" to a SD card and diff --git a/config/printer-creality-ender3pro-2020.cfg b/config/printer-creality-ender3pro-2020.cfg index b3a35528..04b5f004 100644 --- a/config/printer-creality-ender3pro-2020.cfg +++ b/config/printer-creality-ender3pro-2020.cfg @@ -1,12 +1,12 @@ # This file contains pin mappings for the stock 2020 Creality Ender 3 # Pro with the 32-bit Creality 4.2.2 board. To use this config, during # "make menuconfig" select the STM32F103 with a "28KiB bootloader" and -# with "Use USB for communication" disabled. +# serial (on USART1 PA10/PA9) communication. # If you prefer a direct serial connection, in "make menuconfig" -# select "Enable extra low-level configuration options" and select the -# USART3 serial port, which is broken out on the 10 pin IDC cable used -# for the LCD module as follows: +# select "Enable extra low-level configuration options" and select +# serial (on USART3 PB11/PB10), which is broken out on the 10 pin IDC +# cable used for the LCD module as follows: # 3: Tx, 4: Rx, 9: GND, 10: VCC # Flash this firmware by copying "out/klipper.bin" to a SD card and diff --git a/config/printer-creality-ender6-2020.cfg b/config/printer-creality-ender6-2020.cfg index 00875018..a5791a84 100644 --- a/config/printer-creality-ender6-2020.cfg +++ b/config/printer-creality-ender6-2020.cfg @@ -1,7 +1,7 @@ # This file contains pin mappings for the stock 2020 Creality Ender 6. -# To use this config, during "make menuconfig" select the -# STM32F103 with a "28KiB bootloader" and with "Use USB for -# communication" disabled. +# To use this config, during "make menuconfig" select the STM32F103 +# with a "28KiB bootloader" and serial (on USART1 PA10/PA9) +# communication. # Because this printer has factory wiring, mounts, and firmware for # a BLTouch, but does not ship with one at this time, default values @@ -10,9 +10,9 @@ # customize the offsets, particularly z-offset, for their specific unit. # If you prefer a direct serial connection, in "make menuconfig" -# select "Enable extra low-level configuration options" and select the -# USART3 serial port, which is broken out on the 10 pin IDC cable used -# for the LCD module as follows: +# select "Enable extra low-level configuration options" and select +# serial (on USART3 PB11/PB10), which is broken out on the 10 pin IDC +# cable used for the LCD module as follows: # 3: Tx, 4: Rx, 9: GND, 10: VCC # Flash this firmware by copying "out/klipper.bin" to a SD card and diff --git a/config/printer-flsun-q5-2020.cfg b/config/printer-flsun-q5-2020.cfg index 477309b7..59a44dca 100644 --- a/config/printer-flsun-q5-2020.cfg +++ b/config/printer-flsun-q5-2020.cfg @@ -3,8 +3,8 @@ # To use this config, the firmware should be compiled for the # STM32F103. When running "make menuconfig", enable "extra low-level -# configuration setup", select the 28KiB bootloader, disable "USB for -# communication", and select USART3 for the "Serial Port". +# configuration setup", select the 28KiB bootloader, and serial (on +# USART3 PB11/PB10) communication. # Note that the "make flash" command does not work with MKS Robin # boards. After running "make", run the following command: diff --git a/config/printer-monoprice-mini-delta-2017.cfg b/config/printer-monoprice-mini-delta-2017.cfg index 0115ba77..b8cfc5e5 100644 --- a/config/printer-monoprice-mini-delta-2017.cfg +++ b/config/printer-monoprice-mini-delta-2017.cfg @@ -1,7 +1,6 @@ # This file contains common pin mappings for the 2017 Monoprice # Mini Delta. To use this config, the firmware should be compiled for the -# STM32F070 microcontroller with an 8MHz crystal and USB for communication -# (instead of serial). +# STM32F070 microcontroller with an 8MHz crystal and USB for communication. # # IMPORTANT: Use of Kipper with a Monoprice Mini Delta requires a power supply # with a _minimum_ 120 W (i.e. 10 A) capacity! The stock power supply will not diff --git a/config/printer-monoprice-select-mini-v2-2018.cfg b/config/printer-monoprice-select-mini-v2-2018.cfg index dd4ded29..3bc86c75 100644 --- a/config/printer-monoprice-select-mini-v2-2018.cfg +++ b/config/printer-monoprice-select-mini-v2-2018.cfg @@ -1,7 +1,6 @@ # This file contains common pin mappings for the 2019 Monoprice # Select Mini v2. To use this config, the firmware should be compiled for the -# STM32F070 microcontroller with an 8MHz crystal and USB for communication -# (instead of serial). +# STM32F070 microcontroller with an 8MHz crystal and USB for communication. # # Use the following settings in make menuconfig: # diff --git a/config/printer-tronxy-x5sa-v6-2019.cfg b/config/printer-tronxy-x5sa-v6-2019.cfg index 96639a99..069f60d6 100644 --- a/config/printer-tronxy-x5sa-v6-2019.cfg +++ b/config/printer-tronxy-x5sa-v6-2019.cfg @@ -1,15 +1,15 @@ -# This is a Klipper configuration for TronXY X5SA, with -# CXY-V6 motherboard. - +# This is a Klipper configuration for TronXY X5SA, with CXY-V6 +# motherboard. # === FLASHING WITH STOCK BOOTLOADER === # You should make firmware for STM32F103 with bootloader offset -# at 0x8008800 (Chitu v6 Bootloader). Uncheck USB, and leave default -# serial settings. -# -# Use "./scripts/update_chitu.py ./out/klipper.bin ./out/update.cbd" after make to generate update.cbd. -# Put `update.cbd` onto SD card, and reboot the printer. -# It will be automatically installed, and you will be able to update it this way. +# at 0x8008800 (Chitu v6 Bootloader) and serial (on USART1 PA10/PA9) +# communication. + +# Use "./scripts/update_chitu.py ./out/klipper.bin ./out/update.cbd" +# after make to generate update.cbd. Put `update.cbd` onto SD card, +# and reboot the printer. It will be automatically installed, and you +# will be able to update it this way. [mcu] serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 diff --git a/config/printer-twotrees-sapphire-plus-2020.cfg b/config/printer-twotrees-sapphire-plus-2020.cfg index 5212610d..9193ab56 100644 --- a/config/printer-twotrees-sapphire-plus-2020.cfg +++ b/config/printer-twotrees-sapphire-plus-2020.cfg @@ -5,8 +5,7 @@ # When running "make menuconfig" you have to: # - enable "extra low-level configuration setup", # - select the 28KiB bootloader, -# - disable "USB for communication" -# - select USART3 for the "Serial Port" +# - select serial (on USART3 PB11/PB10) communication # - set "GPIO pins to set at micro-controller startup" to "!PC6,!PD13" # Note that the "make flash" command does not work with the Sapphire diff --git a/src/stm32/Kconfig b/src/stm32/Kconfig index 646eb8bc..f2b16d4d 100644 --- a/src/stm32/Kconfig +++ b/src/stm32/Kconfig @@ -17,6 +17,11 @@ config BOARD_DIRECTORY string default "stm32" + +###################################################################### +# Chip selection +###################################################################### + choice prompt "Processor model" config MACH_STM32F103 @@ -61,12 +66,13 @@ config MACH_STM32F4 bool config HAVE_STM32_USBFS bool - default y if MACH_STM32F103 || MACH_STM32F0 - default n + default y if MACH_STM32F103 || MACH_STM32F042 || MACH_STM32F070 config HAVE_STM32_USBOTG bool default y if MACH_STM32F2 || MACH_STM32F4 - default n +config HAVE_STM32_CANBUS + bool + default y if MACH_STM32F1 || MACH_STM32F2 || MACH_STM32F4 || MACH_STM32F042 config MCU string @@ -118,6 +124,11 @@ config STACK_SIZE int default 512 + +###################################################################### +# Bootloader +###################################################################### + choice prompt "Bootloader offset" if MACH_STM32F207 || MACH_STM32F407 || MACH_STM32F405 || MACH_STM32F103 || MACH_STM32F070 config STM32_FLASH_START_2000 @@ -161,6 +172,11 @@ config ARMCM_RAM_VECTORTABLE default y if MACH_STM32F0 && FLASH_START != 0x8000000 default n + +###################################################################### +# Clock +###################################################################### + choice prompt "Clock Reference" if LOW_LEVEL_OPTIONS config STM32_CLOCK_REF_8M @@ -182,35 +198,6 @@ config CLOCK_REF_FREQ default 1 if STM32_CLOCK_REF_INTERNAL default 8000000 -config USBSERIAL - bool "Use USB for communication (instead of serial)" - depends on HAVE_STM32_USBFS || HAVE_STM32_USBOTG - default y - -config CANSERIAL - bool "Use CAN for communication (instead of serial)" - depends on !USBSERIAL - default n -config CANBUS_FREQUENCY - int "CAN bus speed" if LOW_LEVEL_OPTIONS && CANSERIAL - default 500000 -choice - depends on CANSERIAL - prompt "CAN pins" - config CAN_PINS_PA11_PA12 - bool "Pins PA11(rx) and PA12(tx)" - config CAN_PINS_PB8_PB9 - bool "Pins PB8(rx) and PB9(tx)" - config CAN_PINS_PI8_PH13 - bool "Pins PI9(rx) and PH13(tx)" if MACH_STM32F4 - config CAN_PINS_PB5_PB6 - bool "Pins PB5(rx) and PB6(tx)" if MACH_STM32F4 - config CAN_PINS_PB12_PB13 - bool "Pins PB12(rx) and PB13(tx)" if MACH_STM32F4 - config CAN_PINS_PD0_PD1 - bool "Pins PD0(rx) and PD1(tx)" if MACH_STM32F4 -endchoice - config STM32F0_TRIM int "Internal clock trim override" if LOW_LEVEL_OPTIONS && MACH_STM32F0 && STM32_CLOCK_REF_INTERNAL && !USBSERIAL default 16 @@ -220,39 +207,69 @@ config STM32F0_TRIM Default is 16 (use factory default). Each increment increases the clock rate by ~240KHz. -config STM32F042_PIN_SWAP - bool "Use PA9/PA10 for USB or CAN" if MACH_STM32F042 - depends on (USBSERIAL || CANSERIAL) && MACH_STM32F042 - default y if (USBSERIAL || CANSERIAL) - default n - help - Remaps logical pins PA11/PA12 to physical PA9/PA10 on low pincount F042 devices. -config SERIAL - depends on !USBSERIAL && !CANSERIAL + +###################################################################### +# Communication inteface +###################################################################### + +config USBSERIAL + bool +config SERIAL + bool +config CANSERIAL bool - default y choice - depends on SERIAL - prompt "Serial Port" if LOW_LEVEL_OPTIONS - help - Select the serial device to use. + prompt "Communication interface" + config STM32_USB_PA11_PA12 + bool "USB (on PA11/PA12)" if HAVE_STM32_USBFS || HAVE_STM32_USBOTG + select USBSERIAL + config STM32_USB_PA11_PA12_REMAP + bool "USB (on PA9/PA10)" if LOW_LEVEL_OPTIONS && MACH_STM32F042 + select USBSERIAL config STM32_SERIAL_USART1 - bool "USART1" + bool "Serial (on USART1 PA10/PA9)" + select SERIAL config STM32_SERIAL_USART1_ALT - bool "USART1 (on PA15/PA14)" if MACH_STM32F0 + bool "Serial (on USART1 PA15/PA14)" if LOW_LEVEL_OPTIONS && MACH_STM32F0 + select SERIAL config STM32_SERIAL_USART2 - bool "USART2 (on PA3/PA2)" + bool "Serial (on USART2 PA3/PA2)" if LOW_LEVEL_OPTIONS + select SERIAL config STM32_SERIAL_USART2_ALT - bool "USART2 (on PA15/PA14)" if MACH_STM32F0 + bool "Serial (on USART2 PA15/PA14)" if LOW_LEVEL_OPTIONS && MACH_STM32F0 + select SERIAL config STM32_SERIAL_USART3 - bool "USART3" + bool "Serial (on USART3 PB11/PB10)" if LOW_LEVEL_OPTIONS && !MACH_STM32F0 + select SERIAL config STM32_SERIAL_USART3_ALT - bool "USART3 (on PD9/PD8)" if MACH_STM32F405 || MACH_STM32F407 + depends on LOW_LEVEL_OPTIONS && (MACH_STM32F405 || MACH_STM32F407) + bool "Serial (on USART3 PD9/PD8)" + select SERIAL + config STM32_CANBUS_PA11_PA12 + bool "CAN bus (on PA11/PA12)" if HAVE_STM32_CANBUS + select CANSERIAL + config STM32_CANBUS_PA11_PA12_REMAP + bool "CAN bus (on PA9/PA10)" if LOW_LEVEL_OPTIONS && MACH_STM32F042 + select CANSERIAL + config STM32_CANBUS_PB8_PB9 + bool "CAN bus (on PB8/PB9)" if LOW_LEVEL_OPTIONS && HAVE_STM32_CANBUS + select CANSERIAL + config STM32_CANBUS_PI8_PH13 + bool "CAN bus (on PI9/PH13)" if LOW_LEVEL_OPTIONS && MACH_STM32F4 + select CANSERIAL + config STM32_CANBUS_PB5_PB6 + bool "CAN bus (on PB5/PB6)" if LOW_LEVEL_OPTIONS && MACH_STM32F4 + select CANSERIAL + config STM32_CANBUS_PB12_PB13 + bool "CAN bus (on PB12/PB13)" if LOW_LEVEL_OPTIONS && MACH_STM32F4 + select CANSERIAL + config STM32_CANBUS_PD0_PD1 + bool "CAN bus (on PD0/PD1)" if LOW_LEVEL_OPTIONS && MACH_STM32F4 + select CANSERIAL endchoice -config SERIAL_PORT - int - default 3 if STM32_SERIAL_USART3 || STM32_SERIAL_USART3_ALT - default 2 if STM32_SERIAL_USART2 || STM32_SERIAL_USART2_ALT - default 1 + +config CANBUS_FREQUENCY + int "CAN bus speed" if LOW_LEVEL_OPTIONS && CANSERIAL + default 500000 endif diff --git a/src/stm32/can.c b/src/stm32/can.c index 867bbfd7..360ea1ff 100644 --- a/src/stm32/can.c +++ b/src/stm32/can.c @@ -17,32 +17,32 @@ #include "internal.h" // enable_pclock #include "sched.h" // DECL_INIT -#if CONFIG_CAN_PINS_PA11_PA12 +#if CONFIG_STM32_CANBUS_PA11_PA12 || CONFIG_STM32_CANBUS_PA11_PA12_REMAP DECL_CONSTANT_STR("RESERVE_PINS_CAN", "PA11,PA12"); #define GPIO_Rx GPIO('A', 11) #define GPIO_Tx GPIO('A', 12) #endif -#if CONFIG_CAN_PINS_PB8_PB9 +#if CONFIG_STM32_CANBUS_PB8_PB9 DECL_CONSTANT_STR("RESERVE_PINS_CAN", "PB8,PB9"); #define GPIO_Rx GPIO('B', 8) #define GPIO_Tx GPIO('B', 9) #endif -#if CONFIG_CAN_PINS_PI8_PH13 +#if CONFIG_STM32_CANBUS_PI8_PH13 DECL_CONSTANT_STR("RESERVE_PINS_CAN", "PI9,PH13"); #define GPIO_Rx GPIO('I', 9) #define GPIO_Tx GPIO('H', 13) #endif -#if CONFIG_CAN_PINS_PB5_PB6 +#if CONFIG_STM32_CANBUS_PB5_PB6 DECL_CONSTANT_STR("RESERVE_PINS_CAN", "PB5,PB6"); #define GPIO_Rx GPIO('B', 5) #define GPIO_Tx GPIO('B', 6) #endif -#if CONFIG_CAN_PINS_PB12_PB13 +#if CONFIG_STM32_CANBUS_PB12_PB13 DECL_CONSTANT_STR("RESERVE_PINS_CAN", "PB12,PB13"); #define GPIO_Rx GPIO('B', 12) #define GPIO_Tx GPIO('B', 13) #endif -#if CONFIG_CAN_PINS_PD0_PD1 +#if CONFIG_STM32_CANBUS_PD0_PD1 DECL_CONSTANT_STR("RESERVE_PINS_CAN", "PD0,PD1"); #define GPIO_Rx GPIO('D', 0) #define GPIO_Tx GPIO('D', 1) @@ -68,14 +68,14 @@ #if CONFIG_MACH_STM32F4 #warning CAN on STM32F4 is untested - #if (CONFIG_CAN_PINS_PA11_PA12 || CONFIG_CAN_PINS_PB8_PB9 \ - || CONFIG_CAN_PINS_PD0_PD1 || CONFIG_CAN_PINS_PI9_PH13) + #if (CONFIG_STM32_CANBUS_PA11_PA12 || CONFIG_STM32_CANBUS_PB8_PB9 \ + || CONFIG_STM32_CANBUS_PD0_PD1 || CONFIG_STM32_CANBUS_PI9_PH13) #define SOC_CAN CAN1 #define CAN_RX0_IRQn CAN1_RX0_IRQn #define CAN_RX1_IRQn CAN1_RX1_IRQn #define CAN_TX_IRQn CAN1_TX_IRQn #define CAN_SCE_IRQn CAN1_SCE_IRQn - #elif CONFIG_CAN_PINS_PB5_PB6 || CONFIG_CAN_PINS_PB12_PB13 + #elif CONFIG_STM32_CANBUS_PB5_PB6 || CONFIG_STM32_CANBUS_PB12_PB13 #define SOC_CAN CAN2 #define CAN_RX0_IRQn CAN2_RX0_IRQn #define CAN_RX1_IRQn CAN2_RX1_IRQn diff --git a/src/stm32/serial.c b/src/stm32/serial.c index 9c3e7e84..2e11304e 100644 --- a/src/stm32/serial.c +++ b/src/stm32/serial.c @@ -12,28 +12,28 @@ #include "sched.h" // DECL_INIT // Select the configured serial port -#if CONFIG_SERIAL_PORT == 1 +#if CONFIG_STM32_SERIAL_USART1 DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA10,PA9"); #define GPIO_Rx GPIO('A', 10) #define GPIO_Tx GPIO('A', 9) #define USARTx USART1 #define USARTx_IRQn USART1_IRQn -#elif CONFIG_SERIAL_PORT == 2 +#elif CONFIG_STM32_SERIAL_USART2 DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA3,PA2"); #define GPIO_Rx GPIO('A', 3) #define GPIO_Tx GPIO('A', 2) #define USARTx USART2 #define USARTx_IRQn USART2_IRQn -#elif CONFIG_SERIAL_PORT == 3 - #if CONFIG_STM32_SERIAL_USART3_ALT - DECL_CONSTANT_STR("RESERVE_PINS_serial", "PD9,PD8"); - #define GPIO_Rx GPIO('D', 9) - #define GPIO_Tx GPIO('D', 8) - #else - DECL_CONSTANT_STR("RESERVE_PINS_serial", "PB11,PB10"); - #define GPIO_Rx GPIO('B', 11) - #define GPIO_Tx GPIO('B', 10) - #endif +#elif CONFIG_STM32_SERIAL_USART3 + DECL_CONSTANT_STR("RESERVE_PINS_serial", "PB11,PB10"); + #define GPIO_Rx GPIO('B', 11) + #define GPIO_Tx GPIO('B', 10) + #define USARTx USART3 + #define USARTx_IRQn USART3_IRQn +#elif CONFIG_STM32_SERIAL_USART3_ALT + DECL_CONSTANT_STR("RESERVE_PINS_serial", "PD9,PD8"); + #define GPIO_Rx GPIO('D', 9) + #define GPIO_Tx GPIO('D', 8) #define USARTx USART3 #define USARTx_IRQn USART3_IRQn #endif diff --git a/src/stm32/stm32f0.c b/src/stm32/stm32f0.c index b876db35..a2a3a52f 100644 --- a/src/stm32/stm32f0.c +++ b/src/stm32/stm32f0.c @@ -224,7 +224,8 @@ armcm_main(void) // Support pin remapping USB/CAN pins on low pinout stm32f042 #ifdef SYSCFG_CFGR1_PA11_PA12_RMP - if (CONFIG_STM32F042_PIN_SWAP) { + if (CONFIG_STM32_USB_PA11_PA12_REMAP + || CONFIG_STM32_CANBUS_PA11_PA12_REMAP) { enable_pclock(SYSCFG_BASE); SYSCFG->CFGR1 |= SYSCFG_CFGR1_PA11_PA12_RMP; } diff --git a/src/stm32/stm32f0_serial.c b/src/stm32/stm32f0_serial.c index 5736e109..4a299441 100644 --- a/src/stm32/stm32f0_serial.c +++ b/src/stm32/stm32f0_serial.c @@ -12,28 +12,28 @@ #include "sched.h" // DECL_INIT // Select the configured serial port -#if CONFIG_SERIAL_PORT == 1 - #if CONFIG_STM32_SERIAL_USART1_ALT - DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA15,PA14"); - #define GPIO_Rx GPIO('A', 15) - #define GPIO_Tx GPIO('A', 14) - #else - DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA10,PA9"); - #define GPIO_Rx GPIO('A', 10) - #define GPIO_Tx GPIO('A', 9) - #endif +#if CONFIG_STM32_SERIAL_USART1 + DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA10,PA9"); + #define GPIO_Rx GPIO('A', 10) + #define GPIO_Tx GPIO('A', 9) #define USARTx USART1 #define USARTx_IRQn USART1_IRQn -#elif CONFIG_SERIAL_PORT == 2 - #if CONFIG_STM32_SERIAL_USART2_ALT - DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA15,PA14"); - #define GPIO_Rx GPIO('A', 15) - #define GPIO_Tx GPIO('A', 14) - #else - DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA3,PA2"); - #define GPIO_Rx GPIO('A', 3) - #define GPIO_Tx GPIO('A', 2) - #endif +#elif CONFIG_STM32_SERIAL_USART1_ALT + DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA15,PA14"); + #define GPIO_Rx GPIO('A', 15) + #define GPIO_Tx GPIO('A', 14) + #define USARTx USART1 + #define USARTx_IRQn USART1_IRQn +#elif CONFIG_STM32_SERIAL_USART2 + DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA3,PA2"); + #define GPIO_Rx GPIO('A', 3) + #define GPIO_Tx GPIO('A', 2) + #define USARTx USART2 + #define USARTx_IRQn USART2_IRQn +#elif CONFIG_STM32_SERIAL_USART2_ALT + DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA15,PA14"); + #define GPIO_Rx GPIO('A', 15) + #define GPIO_Tx GPIO('A', 14) #define USARTx USART2 #define USARTx_IRQn USART2_IRQn #endif diff --git a/test/configs/stm32f031.config b/test/configs/stm32f031.config index 8bed1a5b..719c6563 100644 --- a/test/configs/stm32f031.config +++ b/test/configs/stm32f031.config @@ -1,4 +1,3 @@ # Base config file for STM32F031 boards CONFIG_MACH_STM32=y CONFIG_MACH_STM32F031=y -CONFIG_USBSERIAL=n diff --git a/test/configs/stm32f103-serial.config b/test/configs/stm32f103-serial.config index a1ae2580..36a453ea 100644 --- a/test/configs/stm32f103-serial.config +++ b/test/configs/stm32f103-serial.config @@ -1,4 +1,4 @@ # Base config file for STM32F1 ARM processor using serial communication CONFIG_MACH_STM32=y CONFIG_MACH_STM32F103=y -CONFIG_USBSERIAL=n +CONFIG_STM32_SERIAL_USART1=y