2323*****************************************************************************"""
2424
2525_DEFAULT_I2C_ADDRESS = {'ecc' : 0xC0 , 'sha' : 0xC8 , 'ta100' : 0x2e }
26- _SWI_DEVICES = ['ATSHA204A' , 'ATSHA206A' , 'ATECC108A' , 'ATECC508A' , 'ATECC608' ]
27- _I2C_DEVICES = ['ATSHA204A' , 'ATECC108A' , 'ATECC508A' , 'ATECC608' , 'TA100' ]
26+ _SWI_DEVICES = ['ATSHA204A' , 'ATSHA206A' , 'ATECC108A' , 'ATECC508A' , 'ATECC608' , 'ECC204' ]
27+ _I2C_DEVICES = ['ATSHA204A' , 'ATECC108A' , 'ATECC508A' , 'ATECC608' , 'TA100' , 'ECC204' ]
2828_SPI_DEVICES = ['TA100' ]
2929
3030
@@ -36,29 +36,56 @@ def updateTngCapability(id, src):
3636 Database .sendMessage ('cryptoauthlib_tng' , 'UPDATE_TNG_TYPE' , {'id' : id , 'src' : src })
3737
3838
39+ def updateSwiBbInterfaceSettings (symbol , swi_bb_iface ):
40+ if swi_bb_iface :
41+ symbol .getComponent ().getSymbolByID ('HAL_INTERFACE' ).setValue ("GPIO" )
42+ updateSercomPlibList ("GPIO_SWI_BB" , swi_bb_iface )
43+ else :
44+ if symbol .getComponent ().getSymbolByID ('INTERFACE' ).getReadOnly ():
45+ pass
46+ else :
47+ try :
48+ symbol .getComponent ().getSymbolByID ('HAL_INTERFACE' ).clearValue ()
49+ except AttributeError :
50+ pass
51+ updateSercomPlibList ("GPIO_SWI_BB" , swi_bb_iface )
52+
53+
3954def updatePartInterfaceSettings (symbol , event ):
4055 symObj = event ['symbol' ]
4156 updateId = event ['id' ].upper ()
4257 selected_key = symObj .getSelectedKey ()
58+ SWI_BB_IFACE = False
4359
4460 if updateId == 'INTERFACE' :
4561 if selected_key == 'ATCA_SPI_IFACE' :
4662 symbol .setVisible ('SPI' in symbol .getID ())
63+ symbol .getComponent ().getSymbolByID ('I2C_ADDR' ).setVisible (False )
4764 elif selected_key == 'ATCA_I2C_IFACE' :
4865 symbol .setVisible ('I2C' in symbol .getID ())
66+ elif selected_key == 'ATCA_SWI_IFACE' :
67+ symbol .setVisible ('SWI_UART' in symbol .getID ())
68+ symbol .getComponent ().getSymbolByID ('I2C_ADDR' ).setVisible (False )
69+ elif selected_key == 'ATCA_SWI_BB_IFACE' :
70+ SWI_BB_IFACE = True
71+ symbol .setVisible ('SWIBB' in symbol .getID ())
72+ symbol .getComponent ().getSymbolByID ('I2C_ADDR' ).setVisible (False )
73+
74+ updateSwiBbInterfaceSettings (symbol , SWI_BB_IFACE )
4975 elif updateId == 'PART_TYPE' :
5076 if selected_key == "TNGTLS" :
5177 Database .activateComponents (['cryptoauthlib_tng' ])
52- symbol . setValue ( 0x6A )
78+ i2c_addr = 0x6A
5379 elif selected_key == "TFLEX" :
5480 Database .activateComponents (['cryptoauthlib_tng' ])
55- symbol . setValue ( 0x6C )
81+ i2c_addr = 0x6C
5682 elif selected_key == "TNGLORA" :
5783 Database .activateComponents (['cryptoauthlib_tng' ])
58- symbol . setValue ( 0xB2 )
84+ i2c_addr = 0xB2
5985 else :
60- symbol . setValue ( 0xC0 )
86+ i2c_addr = 0xC0
6187
88+ symbol .getComponent ().getSymbolByID ('I2C_ADDR' ).setValue (i2c_addr )
6289 updateTngCapability (selected_key , event ['namespace' ])
6390
6491
@@ -84,10 +111,11 @@ def instantiateComponent(deviceComponent, index):
84111 interfaceType .setLabel ('Interface Type' )
85112 if deviceType in _I2C_DEVICES :
86113 interfaceType .addKey ("ATCA_I2C_IFACE" , "0" , "I2C" )
87- # if deviceType in _SWI_DEVICES:
88- # interfaceType.addKey("ATCA_SWI_IFACE", "1", "SWI")
114+ if deviceType in _SWI_DEVICES :
115+ interfaceType .addKey ("ATCA_SWI_IFACE" , "1" , "SWI" )
116+ interfaceType .addKey ("ATCA_SWI_BB_IFACE" , "2" , "SWI_BB" )
89117 if deviceType in _SPI_DEVICES :
90- interfaceType .addKey ("ATCA_SPI_IFACE" , "2 " , "SPI" )
118+ interfaceType .addKey ("ATCA_SPI_IFACE" , "3 " , "SPI" )
91119 interfaceType .setDefaultValue (0 )
92120 interfaceType .setOutputMode ("Key" )
93121 interfaceType .setDisplayMode ("Description" )
@@ -102,22 +130,25 @@ def instantiateComponent(deviceComponent, index):
102130 devicePartType .setDefaultValue (0 )
103131 devicePartType .setOutputMode ("Key" )
104132 devicePartType .setDisplayMode ("Description" )
105-
106- deviceAddress = deviceComponent .createHexSymbol ("I2C_ADDR" , devicePartType )
107- deviceAddress .setLabel ("I2C Address" )
108- deviceAddress .setDefaultValue (0xC0 )
109- else :
110- deviceAddress = deviceComponent .createHexSymbol ("I2C_ADDR" , interfaceType )
111- deviceAddress .setLabel ("I2C Address" )
112-
113- if 'ECC' in deviceID :
114- deviceAddress .setDefaultValue (_DEFAULT_I2C_ADDRESS ['ecc' ])
115- elif 'SHA' in deviceID :
116- deviceAddress .setDefaultValue (_DEFAULT_I2C_ADDRESS ['sha' ])
117- elif 'TA' in deviceID :
118- deviceAddress .setDefaultValue (_DEFAULT_I2C_ADDRESS ['ta100' ])
119-
120- deviceAddress .setDependencies (updatePartInterfaceSettings , ["PART_TYPE" ])
133+ devicePartType .setDependencies (updatePartInterfaceSettings , ["PART_TYPE" ])
134+
135+ deviceAddress = deviceComponent .createHexSymbol ("I2C_ADDR" , interfaceType )
136+ deviceAddress .setLabel ("I2C Address" )
137+
138+ if 'ECC' in deviceID :
139+ deviceAddress .setDefaultValue (_DEFAULT_I2C_ADDRESS ['ecc' ])
140+ elif 'SHA' in deviceID :
141+ deviceAddress .setDefaultValue (_DEFAULT_I2C_ADDRESS ['sha' ])
142+ elif 'TA' in deviceID :
143+ deviceAddress .setDefaultValue (_DEFAULT_I2C_ADDRESS ['ta100' ])
144+
145+ deviceAddress .setDependencies (updatePartInterfaceSettings , ["INTERFACE" ])
146+ deviceAddress .setVisible (True )
147+
148+ swiUartComment = deviceComponent .createCommentSymbol ("SWI_UART_COMMENT" , interfaceType )
149+ swiUartComment .setLabel ("!!! Select UART Ring buffer mode in UART configuration.!!! " )
150+ swiUartComment .setDependencies (updatePartInterfaceSettings , ["INTERFACE" ])
151+ swiUartComment .setVisible (False )
121152
122153 spiCsComment = deviceComponent .createCommentSymbol ("SPI_CS_PINS_COMMENT" , interfaceType )
123154 spiCsComment .setLabel ("!!! Configure the Chip Select pin as GPIO OUTPUT in Pin Settings.!!! " )
@@ -132,6 +163,20 @@ def instantiateComponent(deviceComponent, index):
132163 spiChipSelectPin .setDependencies (updatePartInterfaceSettings , ["INTERFACE" ])
133164 spiChipSelectPin .setVisible (False )
134165
166+ swibbPinComment = deviceComponent .createCommentSymbol ("SWIBB_PIN_COMMENT" , interfaceType )
167+ swibbPinComment .setLabel ("!!! Configure the SWI Crypto pin as GPIO INPUT.!!! " )
168+ swibbPinComment .setDependencies (updatePartInterfaceSettings , ["INTERFACE" ])
169+ swibbPinComment .setVisible (False )
170+
171+ # Gpio pin configuration for swi bitbang
172+ swibbCryptoPin = deviceComponent .createKeyValueSetSymbol ("SWIBB_CRYPTO_PIN" , interfaceType )
173+ swibbCryptoPin .setLabel ("SWIBB Crypto Pin" )
174+ swibbCryptoPin .setDefaultValue (0 )
175+ swibbCryptoPin .setOutputMode ("Key" )
176+ swibbCryptoPin .setDisplayMode ("Description" )
177+ swibbCryptoPin .setDependencies (updatePartInterfaceSettings , ["INTERFACE" ])
178+ swibbCryptoPin .setVisible (False )
179+
135180 availablePinDictionary = {}
136181 availablePinDictionary = Database .sendMessage ("core" , "PIN_LIST" , availablePinDictionary )
137182
@@ -140,6 +185,7 @@ def instantiateComponent(deviceComponent, index):
140185 value = list (availablePinDictionary .keys ())[list (availablePinDictionary .values ()).index (pad )]
141186 description = pad
142187 spiChipSelectPin .addKey (key , value , description )
188+ swibbCryptoPin .addKey (key , value , description )
143189
144190 wakeupDelay = deviceComponent .createIntegerSymbol ("WAKEUP_DELAY" , None )
145191 wakeupDelay .setLabel ("Wakeup Delay (us)" )
@@ -179,7 +225,14 @@ def onAttachmentConnected(source, target):
179225 elif 'SPI' in sourceID :
180226 source ['component' ].getSymbolByID ('HAL_INTERFACE' ).setValue (targetID )
181227 source ['component' ].getSymbolByID ('INTERFACE' ).setReadOnly (True )
182- source ['component' ].getSymbolByID ('INTERFACE' ).setSelectedKey ('ATCA_SPI_IFACE' , 1 )
228+ source ['component' ].getSymbolByID ('INTERFACE' ).setSelectedKey ('ATCA_SPI_IFACE' , 3 )
229+ updateSercomPlibList (target ['id' ], True )
230+ elif 'SWI' in sourceID :
231+ source ['component' ].getSymbolByID ('HAL_INTERFACE' ).setValue (targetID )
232+ source ['component' ].getSymbolByID ('INTERFACE' ).setReadOnly (True )
233+ source ['component' ].getSymbolByID ('INTERFACE' ).setSelectedKey ('ATCA_SWI_IFACE' , 1 )
234+ if "uart" in target ['id' ].lower ():
235+ target ['id' ] = target ['id' ].replace ("UART" , "SWI_UART" )
183236 updateSercomPlibList (target ['id' ], True )
184237
185238
@@ -205,5 +258,16 @@ def onAttachmentDisconnected(source, target):
205258 # Happens when the instance is deleted while attached
206259 pass
207260 updateSercomPlibList (target ['id' ], False )
261+ elif 'SWI' in sourceID :
262+ try :
263+ source ['component' ].getSymbolByID ('HAL_INTERFACE' ).clearValue ()
264+ source ['component' ].getSymbolByID ('INTERFACE' ).clearValue ()
265+ source ['component' ].getSymbolByID ('INTERFACE' ).setReadOnly (False )
266+ except AttributeError :
267+ # Happens when the instance is deleted while attached
268+ pass
269+ if "uart" in target ['id' ].lower ():
270+ target ['id' ] = target ['id' ].replace ("UART" , "SWI_UART" )
271+ updateSercomPlibList (target ['id' ], False )
208272
209273
0 commit comments