Beispiel #1
0
    "PWM_SCALE_SUM":       0xff,
    "PWM_SCALE_AUTO":      0x1ff << 16
}
Fields["PWM_AUTO"] = {
    "PWM_OFS_AUTO":        0xff,
    "PWM_GRAD_AUTO":       0xff << 16
}

FieldFormatters = {
    "I_scale_analog":   (lambda v: "1(ExtVREF)" if v else ""),
    "shaft":            (lambda v: "1(Reverse)" if v else ""),
    "drv_err":          (lambda v: "1(ErrorShutdown!)" if v else ""),
    "uv_cp":            (lambda v: "1(Undervoltage!)" if v else ""),
    "SEL_A":            (lambda v: "%d(%s)" % (v, ["TMC222x", "TMC220x"][v])),
    "VERSION":          (lambda v: "%#x" % v),
    "CUR_A":            (lambda v: str(tmc2130.decode_signed_int(v, 9))),
    "CUR_B":            (lambda v: str(tmc2130.decode_signed_int(v, 9))),
    "MRES":             (lambda v: "%d(%dusteps)" % (v, 0x100 >> v)),
    "otpw":             (lambda v: "1(OvertempWarning!)" if v else ""),
    "ot":               (lambda v: "1(OvertempError!)" if v else ""),
    "s2ga":             (lambda v: "1(ShortToGND_A!)" if v else ""),
    "s2gb":             (lambda v: "1(ShortToGND_B!)" if v else ""),
    "s2vsa":            (lambda v: "1(LowSideShort_A!)" if v else ""),
    "s2vsb":            (lambda v: "1(LowSideShort_B!)" if v else ""),
    "ola":              (lambda v: "1(OpenLoad_A!)" if v else ""),
    "olb":              (lambda v: "1(OpenLoad_B!)" if v else ""),
    "PWM_SCALE_AUTO":   (lambda v: str(tmc2130.decode_signed_int(v, 9)))
}


######################################################################
Beispiel #2
0
    "pwm_freq": 0x03 << 16,
    "pwm_autoscale": 0x01 << 18,
    "pwm_autograd": 0x01 << 19,
    "freewheel": 0x03 << 20,
    "PWM_REG": 0xf << 24,
    "PWM_LIM": 0xf << 28
}
Fields["PWM_SCALE"] = {"PWM_SCALE_SUM": 0xff, "PWM_SCALE_AUTO": 0x1ff << 16}
Fields["PWM_AUTO"] = {"PWM_OFS_AUTO": 0xff, "PWM_GRAD_AUTO": 0xff << 16}

FieldFormatters = dict(tmc2130.FieldFormatters)
FieldFormatters.update({
    "SEL_A": (lambda v: "%d(%s)" % (v, ["TMC222x", "TMC220x"][v])),
    "s2vsa": (lambda v: "1(LowSideShort_A!)" if v else ""),
    "s2vsb": (lambda v: "1(LowSideShort_B!)" if v else ""),
    "PWM_SCALE_AUTO": (lambda v: tmc2130.decode_signed_int(v, 9))
})

######################################################################
# TMC2208 communication
######################################################################


# Generate a CRC8-ATM value for a bytearray
def calc_crc8(data):
    crc = 0
    for b in data:
        for i in range(8):
            if (crc >> 7) ^ (b & 0x01):
                crc = (crc << 1) ^ 0x07
            else:
Beispiel #3
0
}
Fields["PWM_SCALE"] = {
    "PWM_SCALE_SUM":       0xff,
    "PWM_SCALE_AUTO":      0x1ff << 16
}
Fields["PWM_AUTO"] = {
    "PWM_OFS_AUTO":        0xff,
    "PWM_GRAD_AUTO":       0xff << 16
}

FieldFormatters = dict(tmc2130.FieldFormatters)
FieldFormatters.update({
    "SEL_A":            (lambda v: "%d(%s)" % (v, ["TMC222x", "TMC220x"][v])),
    "s2vsa":            (lambda v: "1(LowSideShort_A!)" if v else ""),
    "s2vsb":            (lambda v: "1(LowSideShort_B!)" if v else ""),
    "PWM_SCALE_AUTO":   (lambda v: tmc2130.decode_signed_int(v, 9))
})


######################################################################
# TMC2208 communication
######################################################################

# Generate a CRC8-ATM value for a bytearray
def calc_crc8(data):
    crc = 0
    for b in data:
        for i in range(8):
            if (crc >> 7) ^ (b & 0x01):
                crc = (crc << 1) ^ 0x07
            else: