winIDEA SDK
Loading...
Searching...
No Matches
read_uint64.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
"""
This script demonstrates reading of GPRs using readRegister() and
SFRs with bitfields using method evaluate().
It reads from a register specified in command line and prints its value.
"""
import isystem.connect as ic
import sys
def unsigned64(x: int) -> int:
"""
This function performs a kind of cast from signed 64-bint int to unsigned one.
"""
return x & 0xffffffffffffffff
if __name__ == '__main__':
winidea_id = ''
# First we obtain connection and controller objects
cmgr = ic.ConnectionMgr()
cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
debugCtrl = ic.CDebugFacade(cmgr)
if len(sys.argv) != 2:
print("Usage : ", sys.argv[0], "<general purpose register name>")
print("Example: ", sys.argv[0], "R0")
exit(-1)
registerName = sys.argv[1]
value = debugCtrl.readRegister(ic.IConnectDebug.fRealTime, registerName)
print(registerName, '=', hex(unsigned64(value.getLong())))
# For SFRs we have to use method evaluate()
registerName = '@GPIOA\\ODR'
value = debugCtrl.evaluate(ic.IConnectDebug.fRealTime, registerName)
print(registerName, '=', hex(unsigned64(value.getLong())))
# We can also specify bitfields (STM32F103 specific)
registerName = '@GPIOA\\LCKR\\LCKK'
value = debugCtrl.evaluate(ic.IConnectDebug.fRealTime, registerName)
print(registerName, '=', hex(unsigned64(value.getLong())))