1234 Commits

Author SHA1 Message Date
Kevin O'Connor
554ae78d8c stm32: Run stm32h723 at 520Mhz
Increase speed of stm32h723 chips from 400Mhz to 520Mhz.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-05-02 11:44:31 -04:00
Kevin O'Connor
ee79d0e307 stm32: Support over 400Mhz main clock in stm32h7_adc.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-05-02 11:44:31 -04:00
Kevin O'Connor
7b697105b3 stm32: Use 12Mhz nominal internal clock in stm32f0_i2c.c
Increase the internal nominal clock from 8Mhz to 12Mhz - this improves
support for higher chip frequencies.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-05-02 11:44:31 -04:00
Kevin O'Connor
5b2f8104c7 neopixel: Round up in nsecs_to_ticks()
The rp2040 operates at a fast internal clock with a relatively slow
external timer and dividing down could result in a too small delay.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-28 19:55:30 -04:00
Kevin O'Connor
cf3bedfbdc stm32: Enable VOS0 power mode on stm32h723 if frequency above 400Mhz
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-28 19:36:55 -04:00
Kevin O'Connor
7f4f696f10 stm32: Don't try to set incorrect PWR->CR3 register on stm32h7
It's not valid to set BYPASS and LDOEN at the same time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-28 19:36:55 -04:00
Kevin O'Connor
9c37a918db stm32: Set the PLL frequency equal to CONFIG_CLOCK_FREQ on stm32h723
There is no reason to use a higher internal PLL frequency.  This
change also makes it possible to enable higher clock frequencies on
the stm32h723.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-28 19:36:55 -04:00
Kevin O'Connor
f2b68fef73 stm32: Avoid read-modify-write register updates in stm32h7 clock_setup()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-28 19:36:55 -04:00
Kevin O'Connor
c352617c30 stm32: Use enable_pclock() in stm32h7 clock_setup()
Use the helper functions to enable the peripheral clock instead of
directly manipulating the clock enable bits.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-28 19:36:55 -04:00
Kevin O'Connor
5d1f773ffb stm32h7: Always clear AHB1ENR at startup on stm32h7
Entirely clear the AHB1ENR register.  There is no need to modify
AHB1LPENR.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-28 19:36:55 -04:00
Kevin O'Connor
8e107b2280 basecmd: Update stats timing check to support 32bit duration
Use a 32bit duration check instead of the previous 31bit check.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-28 19:28:52 -04:00
Russell Cloran
f2b27d17b7 stm32: Add support for spi6 on stm32f42x chips
Signed-off-by: Russell Cloran <rcloran@gmail.com>
2025-04-19 12:12:55 -04:00
Kevin O'Connor
5001983d34 stm32: Fix pll_base on stm32h7 when using a clock other than 25Mhz
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-19 12:09:58 -04:00
Kevin O'Connor
0d27195fd4 stm32: Add optimized stm32h7_gpio.c
Add optimized gpio functions for stm32h7 - caching the ODR register
can notably improve the performance of the gpio_out_toggle() code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-19 11:48:58 -04:00
Kevin O'Connor
413ff19ea8 neopixel: Add comments on timing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-17 13:06:22 -04:00
Kevin O'Connor
871637d3f2 Kconfig: Note which chips require software divide operations
Add a new HAVE_SOFTWARE_DIVIDE_REQUIRED that indicates which chips
require software divide.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-17 12:09:19 -04:00
Kevin O'Connor
0fbcc156c5 neopixel: Make sure nsecs_to_ticks() is always inlined
It is a compile-time calculation that needs to be inlined to work.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-17 12:09:19 -04:00
Kevin O'Connor
56d3f4e64c lcd_st7920: Make sure nsecs_to_ticks() is always inlined
It is a compile-time calculation that needs to be inlined to work.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-17 12:09:19 -04:00
Kevin O'Connor
cb6828ec34 lcd_hd44780: Make sure nsecs_to_ticks() is always inlined
It is a compile-time calculation that needs to be inlined to work.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-17 12:09:19 -04:00
Kevin O'Connor
3656006a30 stm32: Change hard_pwm.c MAX_PWM to 257
Choose a value for MAX_PWM that avoids an expensive run-time division.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-17 12:07:44 -04:00
Kevin O'Connor
7a9b06ad86 stm32: Fix prescaler overflow check in hard_pwm.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-17 12:07:44 -04:00
Timofey Titovets
a9b04e8536 i2c_software: pass pulse ticks from host
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-04-17 11:41:49 -04:00
Timofey Titovets
841adcfff7 i2c_software: reduce gpio calls count
gpio reset calls are heavy.
gpio state are persistent between calls.
Drop useless calls.
Avoid calls if SDA does not changed.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-04-17 11:41:49 -04:00
Timofey Titovets
8ab12c86bf i2c_software: allow freq adjust
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-04-17 11:41:49 -04:00
Timofey Titovets
abc76ee963 software_spi: set rate limiting ticks from the host
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-04-17 11:37:12 -04:00
Timofey Titovets
b826844b34 spi_software: respect expected rate
On fast MCU software spi may violate maximally supported by TMC driver rate.

Add dynamic limits to overcome that.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-04-17 11:37:12 -04:00
Kevin O'Connor
017371b744 Revert "Makefile: Don't disable gcc's use-linker-plugin option"
This reverts commit 8087200ffe2fbbe62265dd480ce8be67db8349eb.

The change can break the build on some versions of gcc.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-16 15:24:05 -04:00
Kevin O'Connor
51311948be atsamd: Enable HAVE_LIMITED_CODE_SIZE on small atsamd chips
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-16 13:54:44 -04:00
Kevin O'Connor
61bbd455cf Kconfig: Add some user visible comments to the optional features menu
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-16 13:54:44 -04:00
Kevin O'Connor
d93645a750 stm32: Simplify Makefile
Breakout selection of timer and gpioperiph objects.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-16 13:54:44 -04:00
Kevin O'Connor
8c67adc164 Kconfig: Add new WANT_ADC option to reduce code size
Make it possible to not compile in support for ADC on chips with small
flash sizes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-16 13:54:44 -04:00
Kevin O'Connor
04e7eb20fd Kconfig: Add new WANT_I2C option to reduce code size
Make it possible to not compile in support for I2C on chips with small
flash sizes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-16 13:54:44 -04:00
Kevin O'Connor
868760f5b1 Kconfig: Add new WANT_SPI option to reduce code size
Make it possible to not compile in support for SPI on chips with small
flash sizes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-16 13:54:44 -04:00
Kevin O'Connor
b0fa36e221 Kconfig: Add new WANT_HARD_PWM option to reduce code size
Make it possible to not compile in support for hardware pwm on chips
with small flash sizes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-16 13:54:44 -04:00
Kevin O'Connor
6356e3d35c stm32: Enable gcc -Os option on CONFIG_HAVE_LIMITED_CODE_SIZE
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-16 13:54:44 -04:00
Kevin O'Connor
6e9b5b309c avr: Enable gcc -Os option on CONFIG_HAVE_LIMITED_CODE_SIZE
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-16 13:54:44 -04:00
Kevin O'Connor
d98abfc5db Kconfig: Replace WANT_DISPLAYS with individual options
Support setting WANT_ST7920 and WANT_HD44780 individually.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-16 13:54:39 -04:00
Kevin O'Connor
c3c64adc32 Kconfig: Replace WANT_GPIO_BITBANGING with individual options
Support setting individual options instead of one global option (
WANT_BUTTONS, WANT_TMCUART, WANT_NEOPIXEL, WANT_PULSE_COUNTER,
WANT_HX71X).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-16 13:54:27 -04:00
Kevin O'Connor
8087200ffe Makefile: Don't disable gcc's use-linker-plugin option
This option seems to be confusing ld's region usage checks (builds
that could fit in small chips are being reported as not fitting).  The
option was disabled back in commit 4e8674d5 because it showed worse
results.  However, recent versions of gcc seem to produce the same
results even if this option is enabled, so change the build to avoid
disabling that option on newer versions of gcc (those that have the
-ffat-lto-objects option - which is needed to ensure
compile_time_requests sections can be extracted with objcopy).

The PRU build is dependent on -fuse-linker-plugin, so enable that
option explicitly in its build.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-16 13:17:19 -04:00
Kevin O'Connor
655861cf12 i2c_software: Fix i2c_delay()
The i2c_delay() function did not properly handle counter rollovers.
It also performed an expensive run-time divide.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-08 10:10:25 -04:00
Kevin O'Connor
8176ba22aa stm32: Turn on can.c error interrupts
It seems both ERRIE and LECIE must be enabled to get hardware error
interrupts.  Without this, the rx_error and tx_error reports are
likely to always be zero.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-03 13:32:23 -04:00
Russell Cloran
4b9add2fc3 stm32: Add support for additional i2c bus
Signed-off-by: Russell Cloran <rcloran@gmail.com>
2025-04-02 10:07:52 -04:00
Kevin O'Connor
55f60601ca stm32: Fix RESERVE_PINS_CAN pin ordering in fdcan.c
Always report the reserved pins in the same order (rx,tx).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-04-01 21:25:34 -04:00
FrY Sennberg
d679f711eb
stm32: Added PH13/14 CAN pin option for stm32h743 (#6857)
Added the option to select PH13/PH14 as CAN pins.

Signed-off-by:  Christoph Frei <fryakatkop@gmail.com>
2025-03-27 19:25:26 -04:00
Timofey Titovets
68dbbc8d41 rp2040: define spi bus on pins 12,11,10
Mellow FLY SHT36 Pro toolboard uses those pins

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-03-25 18:53:46 -04:00
Kevin O'Connor
825d4baf90 stepper: Support disabling optimized "step on both edges" in "make menuconfig"
Add a new "low level option" to allow users to configure if they want
to optimize for Trinamic drivers or traditional stepper motor drivers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-03-20 19:56:55 -04:00
Kevin O'Connor
8faed8d9fe stepper: Support step on both edges with custom minimum pulse duration
Add support for "step on both edges" to the main stepper_event_full()
code.  This makes that mode of operation available even when the
micro-controller is not compiled for "optimized step on both edges".
It also enables the custom pulse duration support (step_pulse_ticks)
when in "step on both edges" mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-03-20 19:56:55 -04:00
Marius Petcu
3e7efe5ef1 stm32: Add support for USART6 on STM32F401
STM32F401 has USART6 on PA12/PA11 and PC7/PC6 with alternate
function mapping AF08. This can be used, for example, to connect
to the Elegoo Neptune 3, where PA12/PA11 are wired to an RJ10 plug
going to the stock screen.

Signed-off-by: Marius Petcu <marius@petcu.me>
2025-03-07 17:52:46 -05:00
Paul Hansel
75a10bfcaf
icm20948: Add support for ICM20948 accelerometer (#6756)
Signed-off-by: Paul Hansel <github@paulhansel.com>
2025-03-04 17:12:26 -05:00
Kevin O'Connor
941fb5a367 usb_canbus: Send echo frame before processing the frame
The Linux kernel reports a canbus message as transmitted when it gets
the echo frame back.  Processing the message prior to sending the echo
frame can lead to odd looking debugging logs (as the response messages
may appear to predate the request messages).  This doesn't impact the
Klipper code, but it does make analyzing logs harder.  Fix by sending
the echo frame prior to processing the frame.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-02-27 13:24:19 -05:00