Separate out the high-level command processing logic from the
low-level transmission code. Place the high-level code in
src/generic/canbus.c .
This also removes the CAN dependency on serial_irq.c .
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't perform any heavy tasks in the CAN interrupt handler - just
notify a background task to handle anything pending.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The spec states that the TX fifo is transmitted in chronological order
if the TXFP bit is set, but it's unclear if the software needs to fill
the tx fifo in a particular order to obtain that result. Use the TSR
CODE bit field to fill the TX fifo in the order that the hardware
reports as next.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Prefer explicitly setting the hardware registers and avoid using C
read and modify instructions where possible. This avoids race
conditions where an interrupt or hardware change could cause subtle
corruption of the register state.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Initial commit of code to support 1-wire (Dallas) sensors such
as the DS18B20. Requires Linux kernel drivers to create a file
in /sysfs which is read by this module, and temperature
typically returned to a temperature_fan.
Signed-off-by: Alan Lord <alanslists@gmail.com>
Signed-off-by: Josh Headapohl <joshhead@gmail.com>
The digital output commands implement a subset of the software pwm
commands. Change the host code to just use the software pwm commands
and simplify the micro-controller code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The HSI48 clock on the stm32f042 isn't as accurate as the main HSI
clock. So, only use the HSI48 clock when using USB to synchronize
that clock.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The code isn't actually capable of altering the mux registers due to
hardware checks enforced by the chip. Disable that code to save a few
bytes in the final binary.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If the buffer pointer can't fit in a uint32_t then pass a relative
buffer offset instead. This fixes buffer handling on 64bit linux
mcus.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a helper function to convert from a string buffer passed in the
args[] parameter to an actual pointer. This avoids all the callers
needing to perfrom pointer manipulation.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Restore the default of an 8KiB bootloader for stm32f103 and a 32KiB
bootloader for stm32f207/stm32f407.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Improved CAM bus ID generation, there were issues with ID collisions.
Added a small fast hash library.
Signed-off-by: Pontus Borg <liquidpontus@yahoo.se>
Only write "1" to the "enable" file when a non-zero pwm width is
requested. Write "0" to the "enable" file when a zero pwm width is
requested.
This fixes a problem on the replicape servo lines that prevented them
from being fully disabled.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The lpc176x hardware spi initialization code was swapping the CPOL and
CPHA bits. This caused the MAX31865 and MAX31856 chips to not work
correctly.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Reworked the STM32F0 CAN bus implementation. It's more robust and higher performance.
Added support for function remapping to different pins. API is emulating an STM32F0.
Improved and ported CAN bus to STM32F0, F1 and F4.
Signed-off-by: Pontus Borg <glpontus@gmail.com>
Initial support for stm32f2 in general and STM32F207 in particular.
Boots up and communicates on STM32F207VC.
Signed-off-by: Boleslaw Ciesielski <combolek@users.noreply.github.com>
Use 2us in the linux timer dispatch code to unify linux timer dispatch
logic with the common timer_irq.c code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Change the product/vendor id to 0x1d50/0x614e, which has been reserved
for Klipper (thanks to the openmoko project).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
On the Linux mcu, toggling the pin after the time is read is not
valid. Make that optimization dependent on CONFIG_HAVE_STRICT_TIMING.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a new build definition to note micro-controllers that have strict
timing. The Linux mcu code does not have strict timing - all other
targets currently do.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Endpoint 0 OUT needs to NAK everything until the core signals that the
setup stage is complete.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
A setup packet is only valid after receiving the "setup complete"
notification.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The beagleboard TI kernel 4.14 and 4.19 contain a commit which change
the device names ("pwm: Create device class for pwm channels") from
pwmN to pwm-${chip}:N. This commit was never merged into the upstream
kernel.
Decrease the number of pwm channels to a more reasonable 16. Increase
the number of pwm chips to 8 since the replicape servo pwm outputs are
on pwmchip4.
Update replicape code to detect appropriate channel.
Signed-off-by: Janne Grunau <janne-gh@jannau.net>
There are reports that SKR mini boards have more stable ADC results
when running the ADC at a slower frequency.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Explicitly disable the SysTick interrupt and explicitly set the stack
pointer, as some bootloaders aren't handling this correctly.
Signed-off-by: Chris Lombardi <clearchris@hotmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This reverts commit a2c309a2b0.
The above commit is causing crashes on the stm32f103xb chip when spi
is in use. It's unclear what the cause of the regression is, but the
optimization isn't required so revert it until the root cause can be
determined.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit bd6c25c9 introduced a typo that caused the clock divisors to
not be set correctly on stm32f1.
Reported by @brianrjones69.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The host code always issues a get_config command immediately after
finalize_config, so there is no need to send the two config response
messages.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
In addition to spi3, spi1 and spi2 also have alternate pins. Add them as
spi1a and spi2a, similar to spi3.
Signed-off-by: Arne Jansen <arne@die-jansens.de>
The stm32 has a small queue for spi tx/rx. The current code only uses the
spi with a single byte buffer, effectively waiting for each byte to complete
before starting the next transfer.
This patch changes the structure of spi_transfer() to make use of the queue
and achieve back-to-back transfer of bytes on spi.
Signed-off-by: Arne Jansen <arne@die-jansens.de>
The current code accesses the DR as 32 bit. This enabled data packing mode,
effectively adding a 00 byte between each sent byte. The receive side had
similar problems.
To prevent this, all accesses are 8 bit now, even though this is not
necessary on stmf[14].
Signed-off-by: Arne Jansen <arne@die-jansens.de>
A fast micro-controller may update the gpio pins faster than the
hd44780 chip can handle. Add in the appropriate delays.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>