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 <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2021-08-05 14:25:53 -04:00
parent a52a627893
commit 33dcb38297
6 changed files with 253 additions and 253 deletions

View File

@@ -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)