@@ -114,6 +114,7 @@ def verify_sig(self, chip, verbose=False):
114114 return False
115115 return True
116116
117+ # pylint: disable=too-many-branches
117118 def program_file (self , chip , file_name , verbose = False , verify = True ):
118119 """
119120 Perform a chip erase and program from a file that
@@ -243,25 +244,22 @@ def read_fuses(self, chip):
243244 self .end ()
244245 return (low , high , ext , lock )
245246
246- # pylint: disable=unused-argument,expression-not-assigned
247+ # pylint: disable=unused-argument,too-many-arguments
247248 def write_fuses (self , chip , low = None , high = None , ext = None , lock = None ):
248249 """
249250 Write any of the 4 fuses. If the kwarg low/high/ext/lock is not
250251 passed in or is None, that fuse is skipped
251252 """
253+ transaction_comp = (0xE0 , 0xA0 , 0xA8 , 0xA4 )
254+ fuses = (lock , low , high , ext )
252255 self .begin (clock = _SLOW_CLOCK )
253- lock and self ._transaction ((0xAC , 0xE0 , 0 , lock ))
254- self ._busy_wait ()
255- low and self ._transaction ((0xAC , 0xA0 , 0 , low ))
256- self ._busy_wait ()
257- high and self ._transaction ((0xAC , 0xA8 , 0 , high ))
258- self ._busy_wait ()
259- ext and self ._transaction ((0xAC , 0xA4 , 0 , ext ))
260- self ._busy_wait ()
256+ for fuse , comp in zip (fuses , transaction_comp ):
257+ if fuse :
258+ self ._transaction ((0xAC , comp , 0 , fuse ))
259+ self ._busy_wait ()
261260 self .end ()
262261
263- # pylint: enable=unused-argument,expression-not-assigned
264-
262+ # pylint: disable=too-many-arguments
265263 def verify_fuses (self , chip , low = None , high = None , ext = None , lock = None ):
266264 """
267265 Verify the 4 fuses. If the kwarg low/high/ext/lock is not
0 commit comments