Commit Graph

927 Commits

Author SHA1 Message Date
Kevin O'Connor 790ff4d8d7 usb_canbus: Initial support for USB to CAN bridge mode
Support a USB interface that shows up as a canbus adapter to linux.
Route both local and real canbus packets over that interface.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-27 10:50:23 -04:00
Kevin O'Connor c8cc98ce5d canserial: Rename canbus.c to canserial.c
Rename the canbus.c code to canserial.c and introduce new wrapper
functions in canbus.c that connect the low-level canbus hardware code
to the high-level canserial.c code.

This is in preparation for adding "usb to canbus bridge mode".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-27 10:50:23 -04:00
Kevin O'Connor 11828387d9 usb_cdc_ep: Change default endpoint numbers
Change the default endpoint numbers to make it possible to implement
the "gs_usb" canbus protocol.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-27 10:50:23 -04:00
Kevin O'Connor f5d5f53914 stm32: Add support for disabling the canbus filter
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-27 10:50:23 -04:00
adelyser 84b2bfe313
stm32: Add MCU temp for Stm32h7 (#5606)
Added mcu temperature to the stm32h7 processor.

Signed-off-by: Aaron DeLyser <bluwolf@gmail.com>
2022-06-27 10:16:09 -04:00
Kevin O'Connor d3c4ba4839 rp2040: Add a Kconfig option for selecting "generic_03H" flash type
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-20 13:03:58 -04:00
Kevin O'Connor 9e52dc337f rp2040: Add options to Kconfig for "stage2" flash chip options
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-20 13:03:58 -04:00
Kevin O'Connor cf9d96434c stm32: Add Kconfig option for stm32f103x6 chip (with only 10KiB ram)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-20 12:37:23 -04:00
Kamil Trzciński 0256967def
stm32: support stm32f401 adc_temperature sensor (#5572)
> The temperature sensor is internally connected to the ADC_IN18

> The TSVREFE bit must be set to enable the conversion of both internal channels: the ADC1_IN16 or ADC1_IN18 (temperature sensor) and the ADC1_IN17 (VREFINT).

Ref.: https://www.st.com/resource/en/reference_manual/dm00096844-stm32f401xb-c-and-stm32f401xd-e-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf

Signed-off-by: Kamil Trzciński <ayufan@ayufan.eu>
2022-06-20 12:13:02 -04:00
Kevin O'Connor 3f3713ee97 Kconfig: Move SERIAL, USBSERIAL, and CANSERIAL definitions to src/Kconfig
There is no need to define these options in every board Kconfig file.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-16 14:59:03 -04:00
bluesforte f55b9d3e57 mpu9250: Adding support for MPU-9250 (and MPU-6050) accelerometer
Add support for mpu9250 accelerometer over I2C bus.

Signed-off-by: Harry Beyel <harry3b9@gmail.com>
2022-06-16 11:09:33 -04:00
Kevin O'Connor fc7838855f canbus: Move canbus uuid calculation to canbus.c
Move the uuid hash calculation to canbus.c and call canbus_set_uuid()
from src/stm32/chipid.c .  This simplifies the low-level canbus
hardware code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-16 11:03:48 -04:00
Kevin O'Connor 3f7d05dd18 stm32: Support passing through RTR and EFF canbus frames
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-16 11:03:48 -04:00
Kevin O'Connor 913c6a913d stm32: Support PA11/PA12 and PB8/PB9 on fdcan
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-16 11:03:48 -04:00
Kevin O'Connor ce186c6af6 stm32: Simplify fdcan tx irq handling
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-16 11:00:15 -04:00
Kevin O'Connor 84d798f516 canbus: Use single method for reading canbus messages
Previously the code had canbus_read() which was called from task
context (for admin messages), and canbus_process_data() which was
called from irq context (used for data messages).  Change that to a
single canbus_process_data() function that is called from irq context
(used for all messages).  This simplifies the low-level hardware
specific canbus code and should make it easier to support other
hardware implementations.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-16 11:00:15 -04:00
Kevin O'Connor da755c3c1b canbus: Move global variables into a struct
Create a single CanData global variable to track the canbus state.
ARM micro-controllers generally produce better code when global
variables are in a struct.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-16 11:00:15 -04:00
Kevin O'Connor ea4f6d6a77 rp2040: Implement workaround for USB errata "rp2040-e5"
The rp2040 USB may not connect after a reset.  Implementation the
recommended workaround.

Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-12 11:25:57 -04:00
Kevin O'Connor 7ffd01de4c stm32: Support 4KiB bootloader on stm32f1 and stm32f0
The CanBoot bootloader can often fit in 4KiB and that may be useful
for some devices with small flash sizes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-10 11:48:13 -04:00
Eric Callahan b6feda4eae lpc176x: add support for canboot usb
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-10 11:23:04 -04:00
functionpointer 2dc20c011d ds18b20: Allow some read errors
Allows a limited number of DS18B20 read failures
before stopping the printer. This is designed to
tolerate spurious read errors, while still stopping
for serious issues.

The printer will stop when the sensor

fails to report a value five times in a row.

Implementation works as follows:
The MCU reports any read errors using a new "fault"
parameter in its answers.
The Python code tracks the number of errors
and triggers the shutdown. This paves the way for
more sophisticated error handling in the future,
as well as an example for other sensors to follow.

Signed-off-by: Lorenzo Pfeifer <Lorenzo.Pfeifer+github@googlemail.com>
2022-06-08 12:39:12 -04:00
BIGTREETECH ada571ecb8
stm32: Enable Automatic retransmission feature to avoid data loss caused by bus conflict for STM32G0B1 fdcan (#5550)
Signed-off-by: Alan.Ma from BigTreeTech <tech@biqu3d.com>
2022-06-06 10:59:18 -04:00
Kevin O'Connor db5a4351a5 Kconfig: Move CANBUS_FREQUENCY definition from src/stm32/Kconfig to src/Kconfig
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-04 11:56:59 -04:00
Kevin O'Connor c1f4bdebf2 armcm_reset: Add a armcm_reset.h header file for try_request_canboot()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-04 11:52:39 -04:00
Eric Callahan 39535b15ba stm32: use TME bits to find the canbus tx mailbox
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-03 14:51:01 -04:00
Eric Callahan 3c7eea7336 stm32: call "try_request_canboot" for bootloader requests
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-03 14:51:01 -04:00
Eric Callahan 129091d811 canbus: use "try_request_canboot" method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-03 14:51:01 -04:00
Eric Callahan 8b1e3c3fb2 armcm_reset: support canboot detection
When CanBoot is detected set its bypass signature when a
reset is requested.

Add a "try_request_canboot()" method that may be called
from from USB and Canbus bootloader requests.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-03 14:51:01 -04:00
Kevin O'Connor 63affd7006 stm32: Rework kconfig to use CONFIG_CANSERIAL for both can.c and fdcan.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-06-01 10:59:10 -04:00
BIGTREETECH 1ff7261203
stm32: stm32g0b1 fdcan support (#5488)
Signed-off-by: Alan.Ma from BigTreeTech <tech@biqu3d.com>
2022-06-01 10:43:45 -04:00
Kevin O'Connor 19a478de37 stm32: Don't allow USB on internal clock for stm32f103/stm32f070
Reported by @kaidegit.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-05-23 15:35:05 -04:00
Kevin O'Connor c14118e9c6 misc: Import misc.h in all files defining console_sendf()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-05-13 11:22:47 -04:00
Kevin O'Connor a6b3d2f18f stm32: Remove unused header from can.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-05-10 15:03:55 -04:00
Kevin O'Connor 2c441b4502 canbus: Rename CANBUS_CMD_SET_NODEID to CANBUS_CMD_SET_KLIPPER_NODEID
Rename the command name for consistency with the canbus_query.py
script.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-05-10 11:55:06 -04:00
Eric Callahan 60625f4422 stm32: add 8 KiB bootloader option for F0x2 devices
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-05-10 11:48:06 -04:00
Eric Callahan 81ff8e125c canbus: send 8 bytes in the id response
The last byte contains the "node id" command, which is used to
identify the application.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-05-10 11:48:06 -04:00
Eric Callahan 3505f4cae5 canbus: add bootloader support
This adds a command which allows an external script to broadcast a
bootloader request, using a supplied UUID to match the request.
Included is a method to process requests to enter the canboot
bootloader.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-05-10 11:48:06 -04:00
Kevin O'Connor c263f76f9f stm32: Fix typo in i2c.c
Reported by @kaidegit.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-05-07 10:13:34 -04:00
JamesH1978 542486fba7
stm32: Add 64kib bootloader offset option to STM32F401 (#5457)
This is needed for the Creality Ender 3 S1 with the STM32F401 chips to enable a 64kib bootloader offset

Signed-off-by: James Hartley <james@hartleyns.com>
2022-04-25 12:07:48 -04:00
Martin Hierholzer 7793784640 spicmds: Allow inversion of CS pin for SPI busses
Signed-off-by: Martin Hierholzer <martin@hierholzer.info>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-04-22 13:25:03 -04:00
alstoepp 44567879f6
stm32: Add STM32F072 16KiB bootloader option (#5404)
Signed-off-by: Alexander Stöpperger <a.stoepperger@gmx-topmail.de>
2022-04-13 11:22:04 -04:00
Kevin O'Connor 38e82e8d8f stm32: Add support for additional i2c buses
Reported by @StoneColdCrazy.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-04-11 10:58:34 -04:00
Kevin O'Connor f9d505e376 sensor_angle: Support TLE5012b frame counter for timing
Use the tle5012b internal frame counter to calculate the time of each
measurement.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-03-29 20:34:46 -04:00
Kevin O'Connor 74937326d3 sensor_angle: Add support for bulk querying of spi angle sensors
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-03-29 20:34:46 -04:00
Alex Maclean 91ba9c00e3 atsam: Fix typo in sam4e_afec
Accidentally introduced in 8049243221,
renders the AFE non-functional on SAME70. Should have had little impact
on SAM4E.

Signed-off-by: Alex Maclean <monkeh@monkeh.net>
2022-03-28 10:19:58 -04:00
Alex Maclean 8049243221 atsam: Add support for SAM E70
Signed-off-by: Alex Maclean <monkeh@monkeh.net>
2022-03-26 11:59:27 -04:00
Blinker73 df79893dbc
linux: Update i2c.c (#5295)
Similarly to commit 8cf1b512 for SPI, the Rpi4 has more i2c busses to offer
This change allows klipper to use up to I2c bus 6
/boot/configtxt 
dtparam=i2c_arm=on
dtoverlay=i2c6

and 

pi@fluiddpi:~ $ ls -1 /dev/i2c*
/dev/i2c-1
/dev/i2c-6

Signed-off-by: Sylvain Dansereau <brutus_dansereau@hotmail.com>
2022-03-14 14:24:27 -04:00
Kevin O'Connor 7731c30422 stm32: Allow 32KiB bootloader to be specified for all STM32F4 builds
Reported by @GerogeFu.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-03-14 12:26:41 -04:00
Kevin O'Connor e3beafbdb4 stm32: Clarify CCIPR2 setting in stm32g0.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-03-11 14:12:11 -05:00
Kevin O'Connor 4ce2d379bb stm32: Simplify CCIPR2 register assignment on stm32g0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-03-09 13:28:00 -05:00