Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeanon committed Oct 20, 2023
2 parents 81e606d + 6749985 commit 3422e27
Show file tree
Hide file tree
Showing 11 changed files with 377 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/Bootloader_Entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ releasing `Ctrl`

If a physical serial port is being used on the MCU (even if a USB serial adapter
is being used to connect to it), sending the string
`<SPACE><FS><SPACE>Request Serial Bootloader!!<SPACE>~`.
`<SPACE><FS><SPACE>Request Serial Bootloader!!<SPACE>~` requests the bootloader.

`<SPACE>` is an ASCII literal space, 0x20.

Expand Down
2 changes: 1 addition & 1 deletion docs/Config_checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The QUERY_ENDSTOPS command should report the endstop as "TRIGGERED".

If the endstop appears inverted (it reports "open" when triggered and
vice-versa) then add a "!" to the pin definition (for example,
"endstop_pin: ^PA2"), or remove the "!" if there is already one
"endstop_pin: ^!PA2"), or remove the "!" if there is already one
present.

If the endstop does not change at all then it generally indicates that
Expand Down
5 changes: 1 addition & 4 deletions klippy/extras/input_shaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,13 @@ def _update_input_shaping(self, error=None):
is_sk = self._get_input_shaper_stepper_kinematics(s)
if is_sk is None:
continue
old_delay = ffi_lib.input_shaper_get_step_generation_window(is_sk)
for shaper in self.shapers:
if shaper in failed_shapers:
continue
if not shaper.set_shaper_kinematics(is_sk):
failed_shapers.append(shaper)
new_delay = ffi_lib.input_shaper_get_step_generation_window(is_sk)
if old_delay != new_delay:
self.toolhead.note_step_generation_scan_time(new_delay,
old_delay)
self.toolhead.note_step_generation_scan_time(self, new_delay)
if failed_shapers:
error = error or self.printer.command_error
raise error("Failed to configure shaper(s) %s with given parameters"
Expand Down
9 changes: 6 additions & 3 deletions klippy/kinematics/extruder.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,15 @@ def cmd_default_SET_PRESSURE_ADVANCE(self, gcmd):
extruder.extruder_stepper.cmd_SET_PRESSURE_ADVANCE(gcmd)
def cmd_SET_PRESSURE_ADVANCE(self, gcmd):
verbose = gcmd.get('VERBOSE', 'high').lower()
self.pressure_advance = gcmd.get_float(
pressure_advance = gcmd.get_float(
'ADVANCE', self.pressure_advance, minval=0.)
self.pa_smooth_time = gcmd.get_float(
pa_smooth_time = gcmd.get_float(
'SMOOTH_TIME', self.active_pa_smooth_time, minval=0., maxval=.200)
self.pa_enabled = gcmd.get_int(
pa_enabled = gcmd.get_int(
'ENABLE', self.pa_enabled, minval=0, maxval=1)
self.pressure_advance = pressure_advance
self.pa_smooth_time = pa_smooth_time
self.pa_enabled = pa_enabled
self._update_pressure_advance()
msg = ("pressure_advance: %.6f\n"
"pressure_advance_smooth_time: %.6f\n"
Expand Down
17 changes: 9 additions & 8 deletions klippy/toolhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ def __init__(self, config):
self.drip_completion = None
# Kinematic step generation scan window time tracking
self.kin_flush_delay = SDS_CHECK_TIME
self.kin_flush_times = []
# Map from requester to requested time
self.kin_flush_times = {self: SDS_CHECK_TIME}
self.force_flush_time = self.last_kin_move_time = 0.
# Setup iterative solver
ffi_main, ffi_lib = chelper.get_ffi()
Expand Down Expand Up @@ -526,15 +527,15 @@ def get_trapq(self):
return self.trapq
def register_step_generator(self, handler):
self.step_generators.append(handler)
def note_step_generation_scan_time(self, delay, old_delay=0.):
def note_step_generation_scan_time(self, requester, delay):
self.flush_step_generation()
cur_delay = self.kin_flush_delay
if old_delay:
self.kin_flush_times.pop(self.kin_flush_times.index(old_delay))
if delay == self.kin_flush_times.get(requester, None):
return
if delay:
self.kin_flush_times.append(delay)
new_delay = max(self.kin_flush_times + [SDS_CHECK_TIME])
self.kin_flush_delay = new_delay
self.kin_flush_times[requester] = delay
elif requester in self.kin_flush_times:
del self.kin_flush_times[requester]
self.kin_flush_delay = max(self.kin_flush_times.values())
def register_lookahead_callback(self, callback):
last_move = self.move_queue.get_last()
if last_move is None:
Expand Down
29 changes: 29 additions & 0 deletions src/atsam/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ config MACH_SAM4E
select MACH_SAM4
config MACH_SAME70
bool
config HAVE_SAM_CANBUS
bool
default y if MACH_SAME70

config MCU
string
Expand Down Expand Up @@ -101,6 +104,32 @@ choice
config ATSAM_SERIAL
bool "Serial"
select SERIAL
config ATSAM_MMENU_CANBUS_PC12_PD12
bool "CAN bus (on PC12/PD12)"
depends on HAVE_SAM_CANBUS
select CANSERIAL
config ATSAM_MMENU_CANBUS_PB3_PB2
bool "CAN bus (on PB3/PB2)"
depends on HAVE_SAM_CANBUS
select CANSERIAL
config ATSAM_USBCANBUS
bool "USB to CAN bus bridge"
depends on HAVE_SAM_CANBUS
select USBCANBUS
endchoice
choice
prompt "CAN bus interface" if USBCANBUS
config ATSAM_CMENU_CANBUS_PC12_PD12
bool "CAN bus (on PC12/PD12)"
config ATSAM_CMENU_CANBUS_PB3_PB2
bool "CAN bus (on PB3/PB2)"
endchoice

config ATSAM_CANBUS_PC12_PD12
bool
default y if ATSAM_MMENU_CANBUS_PC12_PD12 || ATSAM_CMENU_CANBUS_PC12_PD12
config ATSAM_CANBUS_PB3_PB2
bool
default y if ATSAM_MMENU_CANBUS_PB3_PB2 || ATSAM_CMENU_CANBUS_PB3_PB2

endif
8 changes: 6 additions & 2 deletions src/atsam/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Setup the toolchain
CROSS_PREFIX=arm-none-eabi-

dirs-y += src/atsam src/generic
dirs-y += src/atsam src/generic lib/fast-hash
dirs-$(CONFIG_MACH_SAM3X) += lib/sam3x/gcc
dirs-$(CONFIG_MACH_SAM4S) += lib/sam4s/gcc
dirs-$(CONFIG_MACH_SAM4E) += lib/sam4e/gcc
Expand All @@ -18,7 +18,7 @@ CFLAGS-$(CONFIG_MACH_SAM3X) += -Ilib/sam3x/include
CFLAGS-$(CONFIG_MACH_SAM4S) += -Ilib/sam4s/include
CFLAGS-$(CONFIG_MACH_SAM4E) += -Ilib/sam4e/include
CFLAGS-$(CONFIG_MACH_SAME70) += -Ilib/same70b/include
CFLAGS += $(CFLAGS-y) -D__$(MCU)__ -mthumb -Ilib/cmsis-core
CFLAGS += $(CFLAGS-y) -D__$(MCU)__ -mthumb -Ilib/cmsis-core -Ilib/fast-hash

CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs
CFLAGS_klipper.elf += -T $(OUT)src/generic/armcm_link.ld
Expand All @@ -33,6 +33,10 @@ usb-src-$(CONFIG_MACH_SAM4) := atsam/sam4_usb.c
usb-src-$(CONFIG_MACH_SAME70) := atsam/sam3_usb.c
src-$(CONFIG_USBSERIAL) += $(usb-src-y) atsam/chipid.c generic/usb_cdc.c
src-$(CONFIG_SERIAL) += atsam/serial.c generic/serial_irq.c
canbus-src-y := generic/canserial.c ../lib/fast-hash/fasthash.c
canbus-src-y += atsam/fdcan.c atsam/chipid.c
src-$(CONFIG_USBCANBUS) += $(canbus-src-y) $(usb-src-y) generic/usb_canbus.c
src-$(CONFIG_CANSERIAL) += $(canbus-src-y) generic/canbus.c
src-$(CONFIG_MACH_SAM3X) += atsam/adc.c atsam/hard_pwm.c
src-$(CONFIG_MACH_SAM4) += atsam/hard_pwm.c
src-$(CONFIG_MACH_SAM4S) += atsam/adc.c
Expand Down
9 changes: 7 additions & 2 deletions src/atsam/chipid.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// This file may be distributed under the terms of the GNU GPLv3 license.

#include "generic/irq.h" // irq_disable
#include "generic/canserial.h" // canserial_set_uuid
#include "generic/usb_cdc.h" // usb_fill_serial
#include "generic/usbstd.h" // usb_string_descriptor
#include "internal.h" // EFC0
Expand Down Expand Up @@ -61,14 +62,18 @@ read_chip_id(uint32_t *id)
void
chipid_init(void)
{
if (!CONFIG_USB_SERIAL_NUMBER_CHIPID)
if (!CONFIG_USB_SERIAL_NUMBER_CHIPID && !CONFIG_CANBUS)
return;

uint32_t id[4];
irq_disable();
read_chip_id(id);
irq_enable();

usb_fill_serial(&cdc_chipid.desc, ARRAY_SIZE(cdc_chipid.data), id);
if (CONFIG_USB_SERIAL_NUMBER_CHIPID)
usb_fill_serial(&cdc_chipid.desc, ARRAY_SIZE(cdc_chipid.data), id);

if (CONFIG_CANBUS)
canserial_set_uuid((void*)id, CHIP_UID_LEN);
}
DECL_INIT(chipid_init);
Loading

0 comments on commit 3422e27

Please sign in to comment.