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>
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>
Change the "product id" from the redundant "Klipper firmware" to the
CONFIG_MCU value. For now, only make this change on boards that have
CONFIG_HAVE_CHIPID set.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Derived from stm32/adc.c and stm32f0/adc.c with additional changes.
Tested on Monoprice Mini Delta (malyan) stm32f070xb board.
Signed-off-by: Chris Lombardi <clearchris@hotmail.com>
Move armcm_main() to stm32f0.c, stm32f1.c, and stm32f4.c. This gives
the arch specific code more control on the early boot setup.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The main() function has a special meaning to gcc and using it can
result in different code generation. Use armcm_main() to avoid that.
Also, invoke SystemInit() from the board specific armcm_main() code.
This gives the board code more control over board initialization.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The stm32f0 line uses 16bit packet memory reads/writes (as opposed to
the goofy 32bit accesses required on the stm32f103).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
When enabling "low level options" in Kconfig, selecting a chip that is
20Mhz capable would result in 20Mhz being the default. A 16Mhz speed
is the preferred default, so list that first in the menu.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The FIOSET and FIOCLR registers may not set an initial value if the
pin is not in an output mode. So, use FIOPIN to set the initial
value.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The usbfs receive buffers must also have space for the 2 byte crc at
the end of a transmission. This fixes an error that could lead to
lost messages from mcu to host (resulting in bytes_invalid increasing
in stats) on the stm32f103.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It appears the usbotg controller can get confused if the usb irq
handler runs while processing a usb request. Disable usb irqs during
usb processing to avoid this.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use the XFRC interrupt instead of TXFE. Don't mask/unmask the tx
interrupts during runtime. This fixes some race conditions where a tx
notification may have previously gotten lost.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The ADC pins (on at least the sam3x8e) need to be configured in input
mode with the internal pullups disabled in order to get accurate ADC
readings.
Reported by @bryanboettcher.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rename the linker script so the build does not have any conflicts with
the armcm_boot.d dependency file.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Replace the custom encoding with a hex encoding. This makes it a
little easier to inspect the CTR conversions.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Store the CTR requests in compile_time_request.txt with the null
characters removed. This makes it slightly easier to inspect the CTR
conversions.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add basic ARM Cortex-M C init code and build linker scripts to
src/generic/ code. This can be used to simplify the various ARM board
code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a general build rule to precompile *.lds.S files to *.ld files.
Remove the custom rules in src/atsamd/Makefile and src/stm32/Makefile.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
On fast MCUs (like the SAMD51) it is possible for the gpio to toggle
faster than the st7920 can accept. Add a small delay around the clock
rise signal.
Signed-off-by: Lars R. Hansen <popshansen@hotmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>