winIDEA SDK
Loading...
Searching...
No Matches
fnet_spi.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 example shows basic FNet SPI controller initialization and usage.
(c) iSYSTEM Labs, 2022
"""
import isystem.connect as ic
winidea_id = ''
try:
# connect to last winIDEA
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
# initialize FNet SPI Controller
SessionCtrl = ic.CSessionCtrl(connMgr)
FNetCtrl = ic.CFNetCtrl(connMgr)
SPICtrl = FNetCtrl.SPI('ADIO.SPI1')
optSPICfg = SPICtrl.cfg()
optSPICfg.reset()
# enable
optSPICfg.set_enabled(bEnabled = True)
# CS active when low, sample on Second edge, clock idle state is High
optSPICfg.set_operation(bCSActiveHigh = False, bSamplingOnSecondEdge = True, bClockIdleHigh = True)
# configure the network
optSPICfg.set_name('eMMC')
optSPICfg.add_description_file('eMMC.dbc')
SessionCtrl.end() #end first for cfg to take effect
SessionCtrl.begin_prepare()
# use FNetTrigger 5 in the example
FTrig = 5
optSPIOp = SPICtrl.op()
# qualifier - starts on FTrig, not enabled from start
SPICtrl.op_qualifier_enable(FTrig)
SPICtrl.op_qualifier_enable_on_start(False)
# don't record all messages
optSPIOp.set_record_all(False)
# configure comparator in one call
optSPIOp.set_comparator(
nComparator = 0,
bRecord = True,
nFTrig = FTrig,
nCS = 0,
nMOSI = False,
nOffset = 0,
nSize = 8,
bBigEndian = False,
nValue = 0x5,
nMask = 0x7
)
# apply new operation settings and restart operation
FNetCtrl.op_apply()
except Exception as ex:
print(ex)