Commit Graph

190 Commits

Author SHA1 Message Date
Kevin O'Connor 7731c30422 stm32: Allow 32KiB bootloader to be specified for all STM32F4 builds
Reported by @GerogeFu.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-03-14 12:26:41 -04:00
Kevin O'Connor e3beafbdb4 stm32: Clarify CCIPR2 setting in stm32g0.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-03-11 14:12:11 -05:00
Kevin O'Connor 4ce2d379bb stm32: Simplify CCIPR2 register assignment on stm32g0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-03-09 13:28:00 -05:00
BIGTREETECH d75154d695
stm32: USB clock source from PLLQCLK on stm32g0 (#5341)
Signed-off-by: Alan.Ma from BigTreeTech <tech@biqu3d.com>
2022-03-09 13:11:04 -05:00
Kevin O'Connor e3cbe7ea36 stm32: Clear SPE flag on a change to SPI CR1 register
The stm32 specs indicate that the SPE bit must be cleared before
changing the CPHA or CPOL bits.

Reported by @cbc02009 and @bigtreetech.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-02-10 18:12:01 -05:00
Kevin O'Connor 99d55185a2 stm32: Wait for transmission to complete before returning from spi_transfer()
It's possible for the SCLK pin to still be updating even after the
last byte of data has been read from the receive pin.  (In particular
in spi mode 0 and 1.)  Exiting early from spi_transfer() in this case
could result in the CS pin being raised before the final updates to
SCLK pin.

Add an additional wait at the end of spi_transfer() to avoid this
issue.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-02-10 17:27:55 -05:00
adelyser 9174c0241e
stm32: Fix ADC on stm32h7 (#5239)
Don't reset the ADC peripheral if the clock is already enabled.
Fixes #5236

Signed-off-by: Aaron DeLyser <bluwolf@gmail.com>
2022-02-06 18:29:53 -05:00
Sergey1560 fb6d6d381c
stm32: Add remap CAN to PD0/PD1 for stm32f103 (#5173)
Signed-off-by: Sergey Terentiev <sergey@terentiev.me>
2022-01-26 18:06:55 -05:00
Kevin O'Connor 4c8d24ae03 stm32: Update Kconfig as CANBUS isn't available on stm32f401
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-01-07 22:17:26 -05:00
Kevin O'Connor 8b6753d68f stm32: Unify enable_pclock() code
Unify the handling of the enable_pclock() and is_enabled_pclock() code
across all stm32 chips.  All chips will now perform a peripheral reset
on enable_pclock() (this is a change for stm32f0 and stm32h7).  The
enable_pclock() code will now also disable irqs during the enable.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-30 12:18:05 -05:00
adelyser 9bdd61758e
stm32: Fix the GPIO register for stm32h7 (#5077)
Signed-off-by: Aaron DeLyser <bluwolf@gmail.com>
2021-12-29 18:01:28 -05:00
Kevin O'Connor 247cd753e2 stm32: Fix ADC on stm32f042
It seems the stm32f042 chip needs a small delay during ADC enable.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-24 19:27:04 -05:00
Kevin O'Connor c89a01c83b stm32: Enable SPI support on stm32g0
Signed-off-by: Alan.Ma from BigTreeTech <tech@biqu3d.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:26 -05:00
Kevin O'Connor 1c24317380 stm32: Enable ADC support on stm32g0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:26 -05:00
Kevin O'Connor 88325b6c93 stm32: Rework register access on stm32f0_adc.c
Avoid read-modify-write operations where possible.  The register
values are in a known state so prefer absolute writes.

Improve handling of race conditions with hardware updates.

Remove the adc reference from "struct gpio_adc" as it is a constant.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:26 -05:00
Kevin O'Connor 20ac48f680 stm32: Minor whitespace changes to stm32f0_adc.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:26 -05:00
Kevin O'Connor b710174107 stm32: Enable I2C on stm32g0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:26 -05:00
Kevin O'Connor 9549a3b4fb stm32: Add support for USB on stm32g0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:26 -05:00
Kevin O'Connor 8d7a6e4ca4 stm32: Rework USB transfer memory layout in usbfs.c
Use a fixed layout for the USB transfer memory and remove the ep_mem
struct definition.

This is in preparation for stm32g0 support.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:26 -05:00
Kevin O'Connor a4a02e86af stm32: Fix buffer size calculation in usbfs.c
When the buffers are over 32 bytes, a block count of 1 starts at 0.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:25 -05:00
Kevin O'Connor 7d2c966241 stm32: Simplify irq declaration in usbfs.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:25 -05:00
Kevin O'Connor 6e8f28117b stm32: Initial support for stm32g0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:25 -05:00
Kevin O'Connor dc3ac2b424 stm32: Enable optimized gpio_clock_enable() function on stm32h7
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:25 -05:00
Kevin O'Connor e56b63fd7e stm32: Reorganize stm32h7.c into major code blocks
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:25 -05:00
Kevin O'Connor de35790709 stm32: Remove USB boot stubs from stm32h7.c
The USB dfu bootloader wasn't enabled on stm32h7, so remove the
copy-and-paste code stubs for it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:25 -05:00
Kevin O'Connor 617f620f00 stm32: Fix DFU entry point on stm32f072
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:25 -05:00
Kevin O'Connor e14dca0f06 stm32: Reorganize usb bootloader code in stm32f0.c
Reorganize stm32f0.c into major code blocks.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:25 -05:00
Kevin O'Connor e55011cde8 stm32: Reorganize usb bootloader code in stm32f4.c
Reorganize stm32f4.c into major code blocks.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:25 -05:00
Kevin O'Connor d29f97cd99 stm32: Reorganize code in stm32f1.c
Reorganize stm32f1.c into major code blocks.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:25 -05:00
Kevin O'Connor 2ee1f48895 stm32: Add new gpioperiph.c file for gpio_peripheral() code
The gpio_peripheral() code is the same in stm32f0.c, stm32f4.c, and
stm32h7.c.  Move that function to a new gpioperiph.c file to avoid
code duplication.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-23 22:15:25 -05:00
Kevin O'Connor 2b7d0bba42 stm32: Add option to disable SWD on GigaDevice STM32F103 clones
Tested by @FotoFieber.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-11-25 10:15:58 -05:00
adelyser 4eeb4620cd stm32: Add USBOTG support to stm32h7
Signed-off-by: Aaron DeLyser <bluwolf@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-11-21 08:12:32 -05:00
Kevin O'Connor 8b401382f6 stm32: Enable SPI on stm32h7
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-11-20 18:26:52 -05:00
adelyser 3ac354088a
stm32: Add stm32h7 SPI support (#4850)
Signed-off-by: Aaron DeLyser <bluwolf@gmail.com>
2021-11-20 18:23:23 -05:00
adelyser b480734c88 stm32: Add STM32H743 support
Signed-off-by: Aaron DeLyser <bluwolf@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-11-20 18:11:02 -05:00
Kevin O'Connor 7b69ef0750 stm32: Limit stm32h7 chips to 400Mhz
Don't go above 400Mhz as otherwise it causes 32bit rollover issues.
(Parts of the code expect a rollover will not occur faster than 10
seconds.)

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-11-20 18:11:02 -05:00
adelyser a5ec751406
stm32: Add UART4 to stm32h7 (#4848)
Signed-off-by: Aaron DeLyser <bluwolf@gmail.com>
2021-11-19 10:27:56 -05:00
Eric Callahan a0615e5e17 stm32f4: reset peripherals in enable_pcclock()
Reset peripherals to after enabling to clear stale
registers set by the bootloader.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-08 20:10:51 -05:00
Eric Callahan bf9d497ab0 stm32f4: reset peripheral clocks on init
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-08 20:10:51 -05:00
Kevin O'Connor 689231df3a stepper: Add support for stepping on both edges of a step pulse
Add an optimized step function for drivers that support stepping on
both rising and falling edges of the step pin.  Enable this
optimization on 32bit ARM micro-controllers.  Automatically detect
this capability in the host code and enable on TMC drivers running in
SPI/UART mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-11-04 12:06:27 -04:00
Kevin O'Connor 85d0ef974c stm32: Remove gcc -mfpu=fpv4-sp-d16 floating point option
The floating point unit must be enabled in order to use it and Klipper
does not currently implement that.  Newer versions of gcc may spill
registers to the floating point unit causing failures.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-30 01:10:50 -04:00
Kevin O'Connor 1e226a8893 stm32: Add a MACH_STM32F0x2 alias for F042 and F072 chips
The F042 and F072 chips are in the same series and the code should be
nearly identical for these chips.  Implement the alias and enable USB
for the F072 chips.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-13 11:25:41 -04:00
Kevin O'Connor 50f51d8aa2 stm32: Rework HAVE_GPIO_HARD_PWM in Kconfig
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-13 11:04:56 -04:00
Kevin O'Connor 97d36ac451 stm32: Change stm32f0 OSPEEDR to "medium" speed
The previous OSPEEDR value of 0x2 was copied from the stm32f4.c code,
but the stm32f0 interprets that value the same as 0x0 - which is "low"
speed.  Change the OSPEEDR value to "medium" speed so that it matches
the configuration of stm32f1 chips.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-12 13:43:31 -04:00
Kevin O'Connor 1b801508ba stm32: Add comments to configuration of OSPEEDR gpio speed
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-12 13:32:46 -04:00
Kevin O'Connor 9d9fe3cb1b stm32: Rework #if pin definition clauses in hard_pwm.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-11 21:43:56 -04:00
jrhelbert dbafeb8876
stm32: Adding Hardware PWM support for the STM32F4 processors (#4693)
This change has been expanded to include all STM32F4 processors, since they share a common TIMER mapping with some processors just not having all of the timers and pins.

Signed-off-by: Jerome Helbert <jerome@helbert.net>
2021-10-11 16:31:27 -04:00
Manuel Fichtner 5d52a3b19f
config: Anycubic Vyper (#4740)
This commit contains a configuration for the Anycubic Vyper printer from 2021.
It uses a clone of the STM32F103 chip named GD32F103.
There are 2 Mainboard versions out there v0.0.5 and v0.0.6, this config has
been tested with the v0.0.6 only. It should probably work for v0.0.5 as well
since there are no different changes in the Anycubic Marlin firmware.
The LCD is not supported yet (might work, but didn't try yet).

Signed-off-by: Marc Neuhaus <marc@neuhaus.nrw>
Signed-off-by: Manuel Fichtner <manuel.fichtner@me.com>
2021-10-11 16:26:14 -04:00
Kevin O'Connor e3905eb241 stm32: Add an MACH_STM32F4x5 alias for F405, F407, and F429 chips
The F405, F407, and F429 chips are in the same series and almost all
code definitions should apply to all chips in that series.  Implement
the alias and fix defintions in adc.c and Kconfig that were only
applying to a subset of that series.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-06 19:56:46 -04:00
D4SK c1136bef10 stm32: Add hardware pwm for stm32h7
Signed-off-by: Konstantin Vogel <konstantin.vogel@gmx.net>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-06 18:20:29 -04:00