54
54
55
55
56
56
def _convert_i2c_addr_to_atecc_addr (i2c_addr = 0x60 ):
57
- int (i2c_addr , 16 )
57
+ int (hex ( i2c_addr ) , 16 )
58
58
return i2c_addr << 1
59
59
60
60
@@ -119,7 +119,7 @@ def _convert_i2c_addr_to_atecc_addr(i2c_addr=0x60):
119
119
Byte 16: 6A 106 0110 1010 Default 7 bit I2C Address: 0x6A>>1: 0x35 ATECC608A-TNGTLS
120
120
Byte 16: 20 32 0010 0000 Default 7 bit I2C Address: 0x20>>1: 0x10 ATECC608A-UNKNOWN
121
121
"""
122
- CFG_TLS_HEX = bytes (
122
+ CFG_TLS = bytes (
123
123
bytearray .fromhex (
124
124
"01 23 00 00 00 00 50 00 00 00 00 00 00 c0 71 00"
125
125
"20 20 20 20 20 20 20 20 20 20 20 20 20 c0 00 55"
@@ -139,10 +139,10 @@ def _convert_i2c_addr_to_atecc_addr(i2c_addr=0x60):
139
139
)
140
140
141
141
# Convert I2C address to config byte 16 and update CFG_TLS
142
- _CFG_BYTES = bytearray (CFG_TLS )
143
- _CFG_BYTE_16 = hex (_I2C_ADDR << 1 )
144
- _CFG_BYTES [ 16 ] = ord (_CFG_BYTE_16 )
145
- CFG_TLS = bytes (_CFG_BYTES )
142
+ _CFG_BYTES_LIST = list ( bytearray (CFG_TLS ) )
143
+ _CFG_BYTE_16 = bytes ( bytearray . fromhex ( hex (_I2C_ADDR << 1 ). replace ( "0x" , "" )) )
144
+ _CFG_BYTES_LIST_MOD = _CFG_BYTES_LIST [ 0 : 16 ] + list (_CFG_BYTE_16 ) + _CFG_BYTES_LIST [ 17 :]
145
+ CFG_TLS = bytes (_CFG_BYTES_LIST_MOD )
146
146
147
147
148
148
class ATECC :
@@ -300,7 +300,7 @@ def nonce(self, data, mode=0, zero=0x0000):
300
300
time .sleep (1 / 1000 )
301
301
if mode == 0x03 :
302
302
assert (
303
- calculated_nonce [0 ] == 0x00
303
+ calculated_nonce [0 ] == 0x00
304
304
), "Incorrectly calculated nonce in pass-thru mode"
305
305
self .idle ()
306
306
return calculated_nonce
@@ -470,7 +470,7 @@ def write_config(self, data):
470
470
if i == 84 :
471
471
# can't write
472
472
continue
473
- self ._write (0 , i // 4 , data [i : i + 4 ])
473
+ self ._write (0 , i // 4 , data [i : i + 4 ])
474
474
475
475
def _write (self , zone , address , buffer ):
476
476
self .wakeup ()
0 commit comments