winIDEA SDK
Loading...
Searching...
No Matches
test_get_cpusfrs.py
# This script is licensed under BSD License, see file LICENSE.txt, or search for `License` in the SDK online help.
#
# (c) TASKING Germany GmbH, 2023
import isystem.connect as ic
winidea_id = ''
def test_getCPUSFRs():
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
dataCtrl2 = ic.CDataController2(connMgr)
cpuSfrs = dataCtrl2.getCPUSFRs(ic.IConnectEclipse.gcsSFRs)
try:
print(f"CPU name: {cpuSfrs.CPUName()}")
# `cpuSfrs` data is a nested structure of SFRs, as in GUI view, for example:
# -> DAM
# -> DAM0_CLC 0x00000000 DISR ....
# -> ASCLIN
# -> ASCLIN0_CLC ...
# ...
# for an example we will print out only first SFR group and 3 of its registers + bitfields
sfrs = cpuSfrs.SFRs()
sfrs: ic.IVectorSFRs
for index in range(1): # to show all: sfrs.size()
sfrGroup = sfrs.at(index)
print(f"SFR group: {sfrGroup.Name()}")
sfrsInGroup = sfrGroup.SFRs()
for gIndex in range(sfrsInGroup.size()): # to show all: sfrsInGroup.size()
sfr: ic.ISFR = sfrsInGroup.at(gIndex)
print(f"\tName: {sfr.Name()}")
print(f"\tHas value: {sfr.HasValue()}")
print(f"\tHandle: {sfr.Handle()}")
print(f"\tBit size: {sfr.BitSize()}")
print(f"\tDescription: {sfr.Description()}")
print(f"\tAddress: {sfr.Address()}")
print(f"\tBit offset: {sfr.BitOffset()}")
print(f"\tProperties: {sfr.Properties()}")
bitFields = sfr.SFRs()
for bIndex in range(bitFields.size()):
bitField = bitFields.at(bIndex)
valMaps = bitField.ValueMaps()
valMaps: ic.IVectorValueMap
for vIndex in range(valMaps.size()):
valMap = valMaps.at(vIndex)
valMap: ic.ISFRValueMap
print(f"\t\tString: {valMap.String()}")
print(f"\t\tDescription: {valMap.Description()}")
print(f"\t\tValue: {valMap.Value()}\n")
print()
finally:
dataCtrl2.release(cpuSfrs)
if __name__ == "__main__":
test_getCPUSFRs()