Skip to content

Commit

Permalink
Examples/TMC9660: Add a demo that reads all registers and fields of T…
Browse files Browse the repository at this point in the history
…MC9660.MCC
  • Loading branch information
trinamic-bp committed Jan 27, 2025
1 parent ffe0c4c commit 9399c20
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
################################################################################
# Copyright © 2025 Analog Devices Inc. All Rights Reserved.
# This software is proprietary to Analog Devices, Inc. and its licensors.
################################################################################
"""Example on how to use TMC9660-3PH-EVKIT.
Note: To run this script the TMC9660-3PH-EVAL first needs an uploaded/burned configuration
and the register app must have been started.
+-----+ +-------------------+
USB | |==| |
-------| |==| |
Connected to the machine | |==| |
running this script. |LB |==|TMC9660-3PH-EVAL |
+-----+ +-------------------+
"""

import time

from pytrinamic.connections import ConnectionManager

from pytrinamic.ic import TMC9660
from pytrinamic.evalboards import TMC9660_3PH_eval


with ConnectionManager().connect() as my_interface:

tmc9660_eval = TMC9660_3PH_eval(my_interface)

for register in TMC9660.MCC.registers():
register_value = tmc9660_eval.read(register)
print(f"{register.name:17}: 0x{register_value:08X}")
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}")
else:
print(f" {field.name:22}: {field_value}")

0 comments on commit 9399c20

Please sign in to comment.