Commit Graph

939 Commits

Author SHA1 Message Date
Kevin O'Connor 2357221bb4 atsamd: Use CONFIG_USB instead of CONFIG_USBSERIAL during clock init
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-08-16 21:21:45 -04:00
Kevin O'Connor 6aec6efcc9 stm32: Use new CONFIG_USB to determine if USB needs to be configured
Introduce a CONFIG_USB build symbol that is set whenever
CONFIG_USBSERIAL or CONFIG_USBCANBUS is set.  Use that symbol during
setup so that the USB controller is properly initialized for both usb
serial and usb canbus bridge configurations.

This fixes the clock configuration for usb canbus bridge mode on
stm32f446.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-08-16 21:21:45 -04:00
Kevin O'Connor b026f1d2c9 canserial: Fix typo in canserial.h
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-07-29 11:40:54 -04:00
Kevin O'Connor 9e3feab0b4 stm32: Remove stm32f4 canbus warning
The canbus code has been successfully tested on stm32f4.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-07-29 11:40:54 -04:00
Kevin O'Connor 751bff7d38 mcu: Delay reset signaling for usb to canbus bridge nodes
An mcu device acting as an "mcu bridge" should only be reset after
other normal devices are reset - otherwise the bridge wont be able to
pass along the reset message to the downstream mcus.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-07-29 11:40:54 -04:00
Kevin O'Connor 2d74b3d358 canserial: Request bootloader via bootloader_request()
Use bootloader_request() instead of try_request_canboot().  This
allows the bootloader machanism to work for more bootloaders.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-07-29 11:40:54 -04:00
Kevin O'Connor 18ff84aa04 usb_cdc: Rename usb_request_bootloader() to bootloader_request()
Rename this board API function to a more generic name.  This is in
preparation for calling the function from the canbus code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-07-29 11:40:54 -04:00
Kevin O'Connor db6346e7e5 serialqueue: Improve canbus timing
Adjust timing based on the minimum transmission time of canbus
messages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-07-29 11:40:54 -04:00
Kevin O'Connor 3796a31959 stm32: Add CCRDY check to stm32g0 adc
The stm32g0 specification states that it is required to wait for the
CCRDY flag to be raised after changing the channel configuration.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-07-25 10:21:29 -04:00
Kevin O'Connor be503b2b9b rp2040: Add support for USB to CANbus bridge mode
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-07-06 00:28:48 -04:00
Kevin O'Connor a831254e83 rp2040: Initial support for CANbus
Add support for CANbus on the rp2040 using the can2040 "software
canbus" implementation.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-07-06 00:28:48 -04:00
BIGTREETECH 1636a9759b
stm32: stm32g0/h7 usb_dfu_bootloader support (#5596)
Signed-off-by: Alan.Ma from BigTreeTech <tech@biqu3d.com>
2022-06-30 13:58:00 -04:00
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