1- # The MIT License (MIT)
1+ # SPDX-FileCopyrightText: 2018 Michael Schroeder for Adafruit Industries
22#
3- # Copyright (c) 2018 Michael Schroeder
4- #
5- # Permission is hereby granted, free of charge, to any person obtaining a copy
6- # of this software and associated documentation files (the "Software"), to deal
7- # in the Software without restriction, including without limitation the rights
8- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9- # copies of the Software, and to permit persons to whom the Software is
10- # furnished to do so, subject to the following conditions:
11- #
12- # The above copyright notice and this permission notice shall be included in
13- # all copies or substantial portions of the Software.
14- #
15- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21- # THE SOFTWARE.
3+ # SPDX-License-Identifier: MIT
4+
225"""
236`adafruit_fram`
247====================================================
@@ -88,9 +71,9 @@ def __init__(self, max_size, write_protect=False, wp_pin=None):
8871
8972 @property
9073 def write_wraparound (self ):
91- """ Determines if sequential writes will wrapaound highest memory address
92- (``len(FRAM) - 1``) address. If ``False``, and a requested write will
93- extend beyond the maximum size, an exception is raised.
74+ """Determines if sequential writes will wrapaound highest memory address
75+ (``len(FRAM) - 1``) address. If ``False``, and a requested write will
76+ extend beyond the maximum size, an exception is raised.
9477 """
9578 return self ._wraparound
9679
@@ -102,44 +85,44 @@ def write_wraparound(self, value):
10285
10386 @property
10487 def write_protected (self ):
105- """ The status of write protection. Default value on initialization is
106- ``False``.
88+ """The status of write protection. Default value on initialization is
89+ ``False``.
10790
108- When a ``WP`` pin is supplied during initialization, or using
109- ``write_protect_pin``, the status is tied to that pin and enables
110- hardware-level protection.
91+ When a ``WP`` pin is supplied during initialization, or using
92+ ``write_protect_pin``, the status is tied to that pin and enables
93+ hardware-level protection.
11194
112- When no ``WP`` pin is supplied, protection is only at the software
113- level in this library.
95+ When no ``WP`` pin is supplied, protection is only at the software
96+ level in this library.
11497 """
11598 return self ._wp if self ._wp_pin is None else self ._wp_pin .value
11699
117100 def __len__ (self ):
118- """ The size of the current FRAM chip. This is one more than the highest
119- address location that can be read or written to.
101+ """The size of the current FRAM chip. This is one more than the highest
102+ address location that can be read or written to.
120103
121- .. code-block:: python
104+ .. code-block:: python
122105
123- fram = adafruit_fram.FRAM_xxx() # xxx = 'I2C' or 'SPI'
106+ fram = adafruit_fram.FRAM_xxx() # xxx = 'I2C' or 'SPI'
124107
125- # size returned by len()
126- len(fram)
108+ # size returned by len()
109+ len(fram)
127110
128- # can be used with range
129- for i in range(0, len(fram))
111+ # can be used with range
112+ for i in range(0, len(fram))
130113 """
131114 return self ._max_size
132115
133116 def __getitem__ (self , address ):
134- """ Read the value at the given index, or values in a slice.
117+ """Read the value at the given index, or values in a slice.
135118
136- .. code-block:: python
119+ .. code-block:: python
137120
138- # read single index
139- fram[0]
121+ # read single index
122+ fram[0]
140123
141- # read values 0 thru 9 with a slice
142- fram[0:9]
124+ # read values 0 thru 9 with a slice
125+ fram[0:9]
143126 """
144127 if isinstance (address , int ):
145128 if not 0 <= address < self ._max_size :
@@ -172,15 +155,15 @@ def __getitem__(self, address):
172155 return read_buffer
173156
174157 def __setitem__ (self , address , value ):
175- """ Write the value at the given starting index.
158+ """Write the value at the given starting index.
176159
177- .. code-block:: python
160+ .. code-block:: python
178161
179- # write single index
180- fram[0] = 1
162+ # write single index
163+ fram[0] = 1
181164
182- # write values 0 thru 4 with a list
183- fram[0] = [0,1,2,3]
165+ # write values 0 thru 4 with a list
166+ fram[0] = [0,1,2,3]
184167 """
185168 if self .write_protected :
186169 raise RuntimeError ("FRAM currently write protected." )
@@ -212,7 +195,7 @@ def _write(self, start_address, data, wraparound):
212195
213196
214197class FRAM_I2C (FRAM ):
215- """ I2C class for FRAM.
198+ """I2C class for FRAM.
216199
217200 :param: ~busio.I2C i2c_bus: The I2C bus the FRAM is connected to.
218201 :param: int address: I2C address of FRAM. Default address is ``0x50``.
@@ -291,7 +274,7 @@ def write_protected(self, value):
291274
292275
293276class FRAM_SPI (FRAM ):
294- """ SPI class for FRAM.
277+ """SPI class for FRAM.
295278
296279 :param: ~busio.SPI spi_bus: The SPI bus the FRAM is connected to.
297280 :param: ~digitalio.DigitalInOut spi_cs: The SPI CS pin.
0 commit comments