Transmit data from mcu to host using 5 bytes per sample and up to 10
samples per message block. This improves bandwidth efficiency.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Query the adxl345 message counter every 100ms so that accurate timing
can be obtained during measurements. This allows the adxl345 data to
be exported with timestamps while captures are running.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This fixes a PWM going to full scale output when a initial value != 0 was
given. The output was on 100% until another update occurred.
This change enables the PWM counter before setting the channel values.
FixesKevinOConnor/klipper#4559
Signed-off-by: Michael Kurz <michi.kurz@gmail.com>
The atmega328pb supports PORTE, but the current avr-libc toolchain
doesn't support the atmega328pb. So, for now, add support for PORTE
to atmega328p.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The atmega328pb has officially named these pins as PE2 and PE3, so use
that naming scheme instead of the previous Klipper invented names.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add support for USART1 on PB7/PB6.
Remove STM32_SERIAL_USART1_ALT_PA15_PA14 option and allow all serial
mappings to be used on stm32f031.
Reported by @Desuuuu.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The Eryone ER-20 is a STM32F103 based 3D printer which ships with a 16KiB bootloader. Their official version of Marlin starts at 0x08004000.
Signed-off-by: Simon Hawkenson <simon@hawkenson.ca>
This implements SPI for the rp2040 target. All output groupings of both
SPI blocks are available for use.
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
This implements hardware PWM support for the rp2040. The maximum
value(100% duty) is set to 255 to match the other controllers. Cycle
time is clamped automatically, and uses the full 8.4 fractional range of
the rp2040 PWM block. This allows a maximum PWM frequency of 490kHz and
a minimum frequency of 1915 Hz.
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
The rp2040 doesn't have a chip ID, but the flash chip connected does. We
can get this ID by asking the flash chip directly, but doing so requires
disengaging the XIP layer, performing the interrogation of the flash
chip, and then re-enabling the XIP layer. This gives us a 64-bit unique
ID that we can use as our USB serial number.
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
In binutils 2.36 and above the -nostartfiles option is no longer
ignored. -nostartfiles is actually a gcc option, and so isn't supported
by ld. Earlier versions of binutils however had less error checking, and
thus just ignored the option.
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
Support the rp2040 (as tested on a Raspberry Pi Pico board). This
adds basic uart, timer, gpio, and watchdog support.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use CONFIG_MACH_AVR instead of CONFIG_CLOCK_FREQ to check for slow
mcus. Some fast MCUs do not export a high clock frequency.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Add menuconfig option for stm32f072
* Add support for internal temp of stm32f072
* Share the temperature calculation logic between stm32f0x2 MCUs
Signed-off-by: Erik Henriksson <erikhenrikssn@gmail.com>
This reverts commit 70ea0806d9.
The above commit breaks software spi on linux hosts. Revert that
commit until an improved error check can be implemented.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 6a3c357a incorrectly disabled support for USART3 on stm32f1 and
stm32f2 - restore that support.
Also, add support for USART3 on PD9/PD8 on stm32f103.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
These commands were never used by the main code and are not
particularly helpful for debugging. Remove them to reduce code size -
in particular on the pru architecture.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit ae89a659 caused a regression in the lpc176x UART handling.
After that commit the UART clock divisor would need to be 6.25 on
lpc1768 or 7.5 on lpc1769, but the code only supports whole numbers.
Set the PCLKSELx registers at startup and return to using full speed
peripheral clocks.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
On architectures that poll for irqs, check for any pending irqs prior
to checking if tasks are idle.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The timer_read_time() call can be expensive - when the next timer is
definitely pending, avoid making that call.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Implement rescheduling math using the simple 32-bit timer instead of
the Unix timespec struct. This makes the code simpler and doesn't
adversely impact the overall performance.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some bootloaders do not disable peripherals in use before jumping to the application. Reset peripherals to assure correct operation.
SIgned-off-by: Eric Callahan <arksine.code@gmail.com>
This adds hardware PWM support for STM32F1 processors.
This should also work for STM32 F0/F2/F4 processors, but I
don't have one of those to test it.
Signed-off-by: Michael Kurz <michi.kurz@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The lpc176x has an errata that could cause updates to PCLKSELx to not
take effect. Rework the code to use the default peripheral clock
speed (25Mhz or 30Mhz) so that this register does not need to be
updated at runtime.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rework the micro-controller command protocol so that it supports
direct communication with the serialqueue.c code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This adds new config options for fans: 'tachometer_pin' to specify the
GPIO pin, and 'tachometer_ppr' (default 2) to specify the number of
signal pulses per revolution. The rpm is also exposed by get_status for
command templates and the API server. For fast fans (at least 10000
RPM), the polling interval can be shortened using the
'tachometer_poll_interval' option.
There is a new mcu object for a generic edge counter, which repeatedly
polls a GPIO pin and periodically reports the count to the host.
Signed-off-by: Adrian Keet <arkeet@gmail.com>
* Add F429 variant; add CAN on PD0,PD1; add 25Mhx clock; move CAN1_RX from PI8 to correct position (PI9)
* Add test for STM32F429
Signed-off-by: Arkadiusz Raj <arek.raj@gmail.com>
Writes over 496 bytes don't fit in a single "rpmsg" page. Request the
host limit the number of bytes outstanding to avoid getting "write:
(22)Invalid argument" errors.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>