If switching a pin from output low to input with pullup, there is an
intermediate state of either driven high or high impedance without a
pullup. Similarly, when switching from output high to input without a
pullup, there is an intermediate state of either driven low or high
impedence with a pullup. In both cases it is preferable for the
latter transition.
Also, calculate the final setting prior to making any changes to
reduce the time in that intermediate state.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't leave the wires in a high output state during setup - leave them
in a high-impedance with pullup state.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some devices can return a read NACK on host retries.
When the MCU receives the I2C CMD, reads out data,
but fails to deliver a response to the host.
The host retries, the device returns NACK,
and the MCU goes into the shutdown state.
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
The more.musl.cc site is blocking downloads from all github actions,
which makes it difficult to use that site for the ar100 cross build
toolchain. Convert to the openrisc or1k-elf toolchain as a
replacement.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The rp2040 uses a pll vco divider of 6. Prefer setting postdiv1=6 and
postdiv2=1 (instead of the previous postdiv1=3 and postdiv2=2).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Completely filling the spi transmit fifo could lead to a situation
where the rx fifo overflows. Make sure not to write past the rx fifo
size.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Completely filling the spi transmit fifo could lead to a situation
where the rx fifo overflows. Make sure not to write past the rx fifo
size.
Also, be sure to wait for the transmission to fully complete before
exiting spi_transfer().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Avoid unnecessary (HAVE_STM32_CANBUS && MACH_STM32xx) checks in
Kconfig. The HAVE_STM32_CANBUS is a helper symbol for all the chips
that support canbus, there's no need to mix it with a check for a chip
that is already known to have canbus.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Validate host provided index prior to accessing memory using that
index.
Also, consistently use a uint8_t for max_sections (to account for
integer overflow issues).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This is an implementation of the SOS fliltering algorithm that runs on the MCU.
The filter opperates on data in fixed point format to avoid use of the FPU as klipper does not support FPU usage.
This host object handles duties of initalizing and resetting the filter so client dont have to declare their own commands for these opperations. Clients can select how many integer bits they want to use for both the filter coefficients and the filters output value. An arbitrary number of filter sections can be configured. Filters can be designed on the fly with the SciPy library or loaded from another source.
Signed-off-by: Gareth Farrington <gareth@waves.ky>
Make it more clear that stepper_load_next() has three separate code
paths - one for each of the optimized stepper_event_X() functions.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
In practice the host will not schedule any steps immediately after a
direction change (due to acceleration limits and the host
"step+dir+step filter"). However, there is also no harm in enforcing
a minimum duration in the mcu.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 8faed8d9 made it possible to utilize stepper_event_full() while
utilizing tmc "step on both edges" optimation. That commit would
ensure a minimum step pulse duration, but it did not ensure a minimum
duration between step pin and dir pin changes. Commits 0d27195f and
554ae78d optimized the gpio handling on stm32h7 chips, which could
potentially cause a very small amount of time between step pin and dir
pin changes.
Enforce a minimum time after a step pin update before updating the dir
pin.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move up the freeing of the stepper_move struct and setting of
s->position in stepper_load_next(). This simplifies the code and
will make it easier to add more logic to this function.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
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>
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>
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>