diff --git a/examples/evalboards/TMC9660/reg/with_landungsbruecke/read_all_mcc_register_and_fields.py b/examples/evalboards/TMC9660/reg/with_landungsbruecke/read_all_mcc_register_and_fields.py index e636669..255bb05 100644 --- a/examples/evalboards/TMC9660/reg/with_landungsbruecke/read_all_mcc_register_and_fields.py +++ b/examples/evalboards/TMC9660/reg/with_landungsbruecke/read_all_mcc_register_and_fields.py @@ -15,8 +15,7 @@ +-----+ +-------------------+ """ - -import time +import ctypes from pytrinamic.connections import ConnectionManager @@ -30,11 +29,18 @@ for register in TMC9660.MCC.registers(): register_value = tmc9660_eval.read(register) + # Convert to unsigned for the hex print not to be negative + register_value = ctypes.c_uint32(register_value).value print(f"{register.name:17}: 0x{register_value:08X}") + if len(register.fields()) == 1 and register.fields()[0].name == register.name: + # Do not print the field value if the field is the same as the register + continue for field in register.fields(): field_value = field.get(register_value) if field.choice: - print(f" {field.name:22}: {field.choice.get(field_value).name}") + # Print text representation of the field value if its an enumeration + print(f" {field.name:24}: {field.choice.get(field_value).name}") else: - print(f" {field.name:22}: {field_value}") + # Just print the field value decimal + print(f" {field.name:24}: {field_value}")