aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/mcu.py
Commit message (Collapse)AuthorAgeFilesLines
* pins: Check if the same pin is referenced via different aliasesKevin O'Connor2018-01-101-9/+8
| | | | | | | | Change the update_command() call to use a new PinResolver class. In that new class, verify that the same pin isn't referenced in two different parts of the config using different aliases for the pin. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Setup static values via setup_start_value() callKevin O'Connor2018-01-081-24/+21
| | | | | | | Add an "is_static" setting to setup_start_value() and remove the setup_static() method. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Only report an MCU timeout onceKevin O'Connor2018-01-081-2/+4
| | | | | | Don't flood the log with timeout messages. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Add gcc and binutils version to mcu data dictionaryKevin O'Connor2017-12-211-2/+2
| | | | | | | | Store the gcc and binutils versions used in the compilation of the firmware in the firmware data dictionary. Forward that information to the log so it is available during debugging. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Allow both shutdown and startup values to be set for output pinsKevin O'Connor2017-12-181-13/+18
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Store MCU_stepper commanded_pos as a floatKevin O'Connor2017-12-071-7/+6
| | | | | | | It's valid to consider the stepper at a position that is not on a step interval - only the "mcu position" needs to be an integer. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Remove unneeded MCU_digital_out.get_last_setting() methodKevin O'Connor2017-12-061-4/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Reset the stepper step clock on init - not after each motor onKevin O'Connor2017-12-061-13/+8
| | | | | | | Reset the last step clock during the init phase and after each home - this simplifies the runtime code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Be sure all moves are completed before raising a home timeoutKevin O'Connor2017-12-061-7/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Make sure to clean up homing state even if homing failsKevin O'Connor2017-12-061-17/+18
| | | | | | | | | | | Make sure to always call MCU_endstop.home_wait() if MCU_endstop.home_start() is invoked. Rename MCU_stepper.note_homing_triggered() to note_homing_end() and make sure it is always called if MCU_stepper.note_homing_start() is invoked. With these changes, MCU_endstop.home_finalize() is no longer needed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Pass list of endstops (not steppers) to the homing codeKevin O'Connor2017-12-061-0/+2
| | | | | | | The homing code wants the list of endstops to enable during a homing operation - it's confusing to pass the steppers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Make sure steppers added to an endstop are on the same mcuKevin O'Connor2017-12-061-0/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Make sure all endstop objects are disabled on a reconnectKevin O'Connor2017-12-061-0/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Add get_endstops() / set_position wrappersKevin O'Connor2017-11-181-0/+2
| | | | | | | Add wrappers around mcu_endstop and mcu_stepper so that the kinematic classes do not need to directly access these low-level classes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Fix command restartKevin O'Connor2017-10-121-3/+3
| | | | | | | Fix omission in commit f8750b14 that broke restarts via Klipper command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Rework shutdown handlingKevin O'Connor2017-10-121-4/+6
| | | | | | | | | If an MCU signals a shutdown from the background thread, notify the main thread and handle the shutdown there. Dispatch shutdown handling from the main Printer() class instead of from the Toolhead class. This simplifies the shutdown logic. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Allow the start value for a pin to differ from the default_valueKevin O'Connor2017-10-121-11/+24
| | | | | | | | | Allow the start value to be different from the default/shutdown value for the pin. This will be useful for "heater fans" that should startup in the off state, and transition to full on in a shutdown state. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop: Eliminate end_stop_set_oversample commandKevin O'Connor2017-10-121-13/+6
| | | | | | | | | | Pass the sample_ticks and sample_count parameters directly in the end_stop_home command instead. This simplifies the code. Also, simplify calculation of next wakeup time in end_stop_oversample_event(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop: Support oversampling of the endstopKevin O'Connor2017-10-011-0/+9
| | | | | | | | Some printers can show occasional noise on the endstop pin. Support sampling the endstop pin multiple times to attempt to filter out this noise. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Add support for dumping internal state for debuggingKevin O'Connor2017-09-271-2/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Make dump_debug() output atomicKevin O'Connor2017-09-271-2/+2
| | | | | | | Build a single (very large) logging message with the debug state. This prevents the output from being fragmented. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Separate restart_microcontroller() into multiple functionsKevin O'Connor2017-09-201-38/+37
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* linux: Initial support for running Klipper in a Linux real-time processKevin O'Connor2017-09-201-1/+2
| | | | | | | Add support for compiling the Klipper micro-controller code as a real-time process capable of running on standard Linux systems. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Initial support for multiple micro-controllersKevin O'Connor2017-09-201-34/+73
| | | | | | | | | Add initial support for controlling multiple independent micro-controllers from a single Klippy host instance. Add basic support for synchronizing the clocks of the additional mcus to the main mcu's clock. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Move code around in MCU class to keep like code togetherKevin O'Connor2017-09-191-108/+107
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Move print_time to clock conversion code to clocksync.pyKevin O'Connor2017-09-191-9/+9
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Add mcu wrapper functions and avoid direct acccess to mcu variablesKevin O'Connor2017-09-191-37/+39
| | | | | | | | Don't directly access any of the mcu class variables externally from the class. Add wrapper functions for those external callers that need access to some internal state. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Implement print time to clock conversion in C codeKevin O'Connor2017-09-191-13/+8
| | | | | | | Implement the conversion from print_time to the local mcu's clock within the C code. This simplifies the python code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Don't export get_last_clock()Kevin O'Connor2017-09-191-32/+18
| | | | | | | Everywhere the data in get_last_clock() is used can be done just as easily with estimated_print_time(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Move clock synchronization code into new fileKevin O'Connor2017-09-191-12/+19
| | | | | | | Move the low-level clock synchronization code from serialhdl.py to a new file clocksync.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Update file purpose commentKevin O'Connor2017-09-191-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Pass print_time directly to MCU callsKevin O'Connor2017-09-191-48/+44
| | | | | | | | | Now that the print_time is always synchronized with the mcu_time, there is no longer a need to track mcu_time as a separate quantity. Eliminate references to mcu_time from the code and pass print_time directly in its place. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Synchronize print_time to main mcu's timeKevin O'Connor2017-09-191-29/+12
| | | | | | | | Instead of starting the print_time at zero, start it at the estimated time of the main mcu's clock. This simplifies the code and it ensures that print_time never goes backwards. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Return number of steps traveled from stepcompress_push()Kevin O'Connor2017-09-131-7/+4
| | | | | | | Return the same information from stepcompress_push() that is returned from stepcompress_push_const() and stpcompress_push_delta(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pins: Don't pass mcu_freq to update_command()Kevin O'Connor2017-09-131-2/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Limit value range of PWM and digital outputs prior to transmissionKevin O'Connor2017-09-061-10/+7
| | | | | | | Make sure schedule_digital_out and schedule_pwm_out commands always go out with a value that is in range for the particular command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Improve error descriptions in Common_MCU_errorsKevin O'Connor2017-09-061-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Provide some further help on common MCU shutdown errorsKevin O'Connor2017-09-051-2/+28
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Limit ADC min/max range to a 16bit integerKevin O'Connor2017-09-051-2/+3
| | | | | | | | | Make sure the ADC range sent to the MCU can be encoded into a 16bit integer. Otherwise, if the provided min_temp/max_temp was outside the range of possible values it could result in a spurious mcu shutdown. In particular, the AD595 could not properly encode a min_temp of zero. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Support config_reset command to manually reset mcuKevin O'Connor2017-09-031-10/+26
| | | | | | | Add support for resetting the MCU via a software only mechanism. This is useful on the PRU. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Add get_mcu() call to the mcu oid objectsKevin O'Connor2017-08-291-7/+10
| | | | | | | | | Allow external code to obtain the mcu object that controls a pin setup with setup_pin(). Also, don't bother defining print_to_mcu_time() and system_to_mcu_time() on each pin object as they can be obtained via the new get_mcu() method. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Fix bug causing corexy to not work (introduced in 9d75c3b0)Kevin O'Connor2017-08-291-2/+2
| | | | | | | | | Commit 9d75c3b0 changed the order of allocation for mcu oid integer ids. However, the stepper oids must always be allocated before endstop oids so that corexy can register multiple steppers on a single endstop. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Drop support for TICKS() expansion in mcu config commandsKevin O'Connor2017-08-261-10/+11
| | | | | | | It's no longer necessary to use the TICKS() hack as the config commands are now all generated after the mcu speed is known. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* chipmisc: Add support for statically configured output pinsKevin O'Connor2017-08-261-12/+40
| | | | | | | Allow digital and PWM output pins to be setup via new config sections. This makes it easier to setup pin configurations. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Track stepqueues separately from steppersKevin O'Connor2017-08-251-6/+6
| | | | | | | | The MCU() class needs to track the stepqueues so that it can initialize the steppersync object. Track the stepqueues directly instead of via the list of steppers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Track oids separately from objects requiring a build_config() callbackKevin O'Connor2017-08-251-13/+18
| | | | | | | | Track the oid count separately from the configurable object count - this way it is possible to have internal objects that don't require an oid in the mcu. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Eliminate "init callback" phase during connectKevin O'Connor2017-08-251-28/+21
| | | | | | | | It's not necessary to register and execute "init callbacks" when configuring the mcu. Instead, have each mcu object produce its init messages in the build_config() callback. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pins: Support registering arbitrary chips that supply configurable pinsKevin O'Connor2017-08-251-66/+76
| | | | | | | | | Allow multiple chips to provide pin mappings (not just the main mcu chip). Move the pin parsing from the mcu.py code to pins.py and support mapping from pin descriptions to their corresponding chips and parameters. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Store printer startup parameters in new "start_args" dictionaryKevin O'Connor2017-08-251-11/+22
| | | | | | | | | Store pertinent information from the software startup in a dictionary that the various printer components can access instead of in individual variables in the Printer() class. This makes it easier to add future command-line options. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* irq: Support sleeping when mcu is idleKevin O'Connor2017-07-171-2/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>