winIDEA SDK
fnet_spi.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5"""
6This example shows basic FNet SPI controller initialization and usage.
7
8(c) iSYSTEM Labs, 2022
9"""
10import isystem.connect as ic
11
12winidea_id = ''
13
14
15try:
16 # connect to last winIDEA
17 connMgr = ic.ConnectionMgr()
18 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
19
20 # initialize FNet SPI Controller
21 SessionCtrl = ic.CSessionCtrl(connMgr)
22 FNetCtrl = ic.CFNetCtrl(connMgr)
23 SPICtrl = FNetCtrl.SPI('ADIO.SPI1')
24
25
26
27 optSPICfg = SPICtrl.cfg()
28 optSPICfg.reset()
29
30 # enable
31 optSPICfg.set_enabled(bEnabled = True)
32 # CS active when low, sample on Second edge, clock idle state is High
33 optSPICfg.set_operation(bCSActiveHigh = False, bSamplingOnSecondEdge = True, bClockIdleHigh = True)
34
35 # configure the network
36 optSPICfg.set_name('eMMC')
37 optSPICfg.add_description_file('eMMC.dbc')
38
39
40
41 SessionCtrl.end() #end first for cfg to take effect
42 SessionCtrl.begin_prepare()
43
44
45
46 # use FNetTrigger 5 in the example
47 FTrig = 5
48
49 optSPIOp = SPICtrl.op()
50 # qualifier - starts on FTrig, not enabled from start
51 SPICtrl.op_qualifier_enable(FTrig)
52 SPICtrl.op_qualifier_enable_on_start(False)
53
54 # don't record all messages
55 optSPIOp.set_record_all(False)
56 # configure comparator in one call
57 optSPIOp.set_comparator(
58 nComparator = 0,
59 bRecord = True,
60 nFTrig = FTrig,
61 nCS = 0,
62 nMOSI = False,
63 nOffset = 0,
64 nSize = 8,
65 bBigEndian = False,
66 nValue = 0x5,
67 nMask = 0x7
68 )
69
70 # apply new operation settings and restart operation
71 FNetCtrl.op_apply()
72
73except Exception as ex:
74 print(ex)