From 33dcb3829717102f5243ad805f3ee09d52c0c9cf Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 5 Aug 2021 14:25:53 -0400 Subject: tmc: Consistently use lower case for all TMC field names The Trinamic specs aren't consistent with upper vs lower case, which can be confusing. Improve clarity by using lower case names consistently in the code. Register names will continue to use all upper case naming in the code. Update the SET_TMC_FIELD command to automatically convert field names to lower case. Signed-off-by: Kevin O'Connor --- klippy/extras/tmc2209.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'klippy/extras/tmc2209.py') diff --git a/klippy/extras/tmc2209.py b/klippy/extras/tmc2209.py index c95ade34..7856334b 100644 --- a/klippy/extras/tmc2209.py +++ b/klippy/extras/tmc2209.py @@ -26,24 +26,24 @@ Fields["COOLCONF"] = { "seimin": 0x01 << 15 } Fields["IOIN"] = { - "ENN": 0x01 << 0, - "MS1": 0x01 << 2, - "MS2": 0x01 << 3, - "DIAG": 0x01 << 4, - "PDN_UART": 0x01 << 6, - "STEP": 0x01 << 7, - "SPREAD_EN": 0x01 << 8, - "DIR": 0x01 << 9, - "VERSION": 0xff << 24 + "enn": 0x01 << 0, + "ms1": 0x01 << 2, + "ms2": 0x01 << 3, + "diag": 0x01 << 4, + "pdn_uart": 0x01 << 6, + "step": 0x01 << 7, + "spread_en": 0x01 << 8, + "dir": 0x01 << 9, + "version": 0xff << 24 } Fields["SGTHRS"] = { - "SGTHRS": 0xFF << 0 + "sgthrs": 0xFF << 0 } Fields["SG_RESULT"] = { - "SG_RESULT": 0x3FF << 0 + "sg_result": 0x3FF << 0 } Fields["TCOOLTHRS"] = { - "TCOOLTHRS": 0xfffff + "tcoolthrs": 0xfffff } FieldFormatters = dict(tmc2208.FieldFormatters) @@ -61,7 +61,7 @@ class TMC2209: self.mcu_tmc = tmc_uart.MCU_TMC_uart(config, Registers, self.fields, 3) # Setup fields for UART self.fields.set_field("pdn_disable", True) - self.fields.set_field("SENDDELAY", 2) # Avoid tx errors on shared uart + self.fields.set_field("senddelay", 2) # Avoid tx errors on shared uart # Allow virtual pins to be created tmc.TMCVirtualPinHelper(config, self.mcu_tmc) # Register commands @@ -81,17 +81,17 @@ class TMC2209: set_config_field(config, "toff", 3) set_config_field(config, "hstrt", 5) set_config_field(config, "hend", 0) - set_config_field(config, "TBL", 2) - set_config_field(config, "IHOLDDELAY", 8) - set_config_field(config, "TPOWERDOWN", 20) - set_config_field(config, "PWM_OFS", 36) - set_config_field(config, "PWM_GRAD", 14) + set_config_field(config, "tbl", 2) + set_config_field(config, "iholddelay", 8) + set_config_field(config, "tpowerdown", 20) + set_config_field(config, "pwm_ofs", 36) + set_config_field(config, "pwm_grad", 14) set_config_field(config, "pwm_freq", 1) set_config_field(config, "pwm_autoscale", True) set_config_field(config, "pwm_autograd", True) - set_config_field(config, "PWM_REG", 8) - set_config_field(config, "PWM_LIM", 12) - set_config_field(config, "SGTHRS", 0) + set_config_field(config, "pwm_reg", 8) + set_config_field(config, "pwm_lim", 12) + set_config_field(config, "sgthrs", 0) def load_config_prefix(config): return TMC2209(config) -- cgit v1.2.3-70-g09d2