@@ -105,12 +105,6 @@ def write_protected(self):
105
105
"""
106
106
return self ._wp if self ._wp_pin is None else self ._wp_pin .value
107
107
108
- @write_protected .setter
109
- def write_protected (self , value ):
110
- self ._wp = value
111
- if not self ._wp_pin is None :
112
- self ._wp_pin .value = value
113
-
114
108
def __len__ (self ):
115
109
""" The maximum size of the current FRAM chip. This is the highest
116
110
register location that can be read or written to.
@@ -261,6 +255,15 @@ def _write(self, start_register, data, wraparound=False):
261
255
buffer [2 ] = data [i ]
262
256
i2c .write (buffer )
263
257
258
+ # pylint: disable=no-member
259
+ @FRAM .write_protected .setter
260
+ def write_protected (self , value ):
261
+ if value not in (True , False ):
262
+ raise ValueError ("Write protected value must be 'True' or 'False'." )
263
+ self ._wp = value
264
+ if not self ._wp_pin is None :
265
+ self ._wp_pin .value = value
266
+
264
267
# the following pylint disables are related to the '_SPI_OPCODE' consts, the super
265
268
# class setter '@FRAM.write_protected.setter', and pylint not being able to see
266
269
# 'spi.write()' in SPIDevice. Travis run for reference:
@@ -346,6 +349,8 @@ def write_protected(self, value):
346
349
# While it is possible to protect block ranges on the SPI chip,
347
350
# it seems superfluous to do so. So, block protection always protects
348
351
# the entire memory (BP0 and BP1).
352
+ if value not in (True , False ):
353
+ raise ValueError ("Write protected value must be 'True' or 'False'." )
349
354
self ._wp = value
350
355
write_buffer = bytearray (2 )
351
356
write_buffer [0 ] = _SPI_OPCODE_WRSR
0 commit comments