@@ -28,25 +28,20 @@ frequency.
2828
2929 Set up and start the given PWM channel.
3030
31- :param channel: PWM channel. It can be specified in the form
31+ :param str channel: PWM channel. It can be specified in the form
3232 of of 'P8_10', or 'EHRPWM2A'.
33- :type channel: str
34- :param duty_cycle: PWM duty cycle. It must have a value from 0 to 100.
35- :type duty_cycle: int
36- :param frequency: PWM frequency, in Hz. It must be greater than 0.
37- :type frequency: int
38- :param polarity: defines whether the value for ``duty_cycle `` affects the
33+ :param int duty_cycle: PWM duty cycle. It must have a value from 0 to 100.
34+ :param int frequency: PWM frequency, in Hz. It must be greater than 0.
35+ :param int polarity: defines whether the value for ``duty_cycle `` affects the
3936 rising edge or the falling edge of the waveform. Allowed values -- 0
4037 (rising edge, default) or 1 (falling edge).
41- :type polarity: int
4238
4339.. function :: stop(channel)
4440
4541 Stop the given PWM channel.
4642
47- :param channel: PWM channel. It can be specified in the form
43+ :param str channel: PWM channel. It can be specified in the form
4844 of of 'P8_10', or 'EHRPWM2A'.
49- :type channel: str
5045
5146.. function :: set_duty_cycle(channel, duty_cycle)
5247
@@ -55,11 +50,9 @@ frequency.
5550 :note: You must have started the PWM channel with :func: `start() `
5651 once, before changing the duty cycle.
5752
58- :param channel: PWM channel. It can be specified in the form
53+ :param str channel: PWM channel. It can be specified in the form
5954 of of 'P8_10', or 'EHRPWM2A'.
60- :type channel: str
61- :param duty_cycle: PWM duty cycle. It must have a value from 0 to 100.
62- :type duty_cycle: int
55+ :param int duty_cycle: PWM duty cycle. It must have a value from 0 to 100.
6356
6457.. function :: set_frequency(channel, frequency)
6558
@@ -68,11 +61,9 @@ frequency.
6861 :note: You must have started the PWM channel with :func: `start() `
6962 once, before changing the frequency.
7063
71- :param channel: PWM channel. It can be specified in the form
64+ :param str channel: PWM channel. It can be specified in the form
7265 of of 'P8_10', or 'EHRPWM2A'.
73- :type channel: str
74- :param frequency: PWM frequency. It must be greater than 0.
75- :type frequency: int
66+ :param int frequency: PWM frequency. It must be greater than 0.
7667
7768.. function :: cleanup()
7869
@@ -151,6 +142,103 @@ Example::
151142
152143 Read the raw analog value for the channel.
153144
145+ :mod: `SPI ` --- Serial Peripheral Interface
146+ ------------------------------------------
147+
148+ This module defines an object type that allows Serial Peripheral Interface
149+ (SPI) bus transactions on hosts running the Linux kernel. The host kernel
150+ must have SPI support and SPI device interface support.
151+
152+ Because the SPI device interface is opened R/W, users of this module
153+ usually must have root permissions or be members of a group with granted
154+ access rights.
155+
156+ Example::
157+
158+ import Adafruit_BBIO.SPI as SPI
159+
160+ from Adafruit_BBIO.SPI import SPI
161+ # spi = SPI(bus, device) #/dev/spidev<bus>.<device>
162+
163+ # /dev/spidev0.0
164+ spi = SPI(1, 0)
165+ print(spi.xfer2([32, 11, 110, 22, 220]))
166+ spi.close()
167+
168+ # /dev/spidev0.1
169+ spi = SPI(1,1)
170+ print(spi.xfer2([32, 11, 110, 22, 220]))
171+ spi.close()
172+
173+ # /dev/spidev1.0
174+ spi = SPI(2,0)
175+ print(spi.xfer2([32, 11, 110, 22, 220]))
176+ spi.close()
177+
178+ # /dev/spidev1.1
179+ spi = SPI(2,1)
180+ print(spi.xfer2([32, 11, 110, 22, 220]))
181+ spi.close()
182+
183+ .. module :: Adafruit_BBIO.SPI
184+
185+ .. class :: SPI(bus, client)
186+
187+ :param bus: bus number
188+ :param client: client number
189+ :returns: a new SPI object, optionally connected to the specified SPI
190+ device interface.
191+ :rtype: :class: `SPI `
192+
193+ .. method :: open(bus, device)
194+
195+ Connects the object to the specified SPI device. `open(X, Y) ` will open
196+ `/dev/spidev-X.Y `
197+
198+ :param int bus: bus number
199+ :param str device: device number
200+
201+ .. method :: close()
202+
203+ Disconnects the object from the interface.
204+
205+ .. method :: readbytes(len)
206+
207+ Read the specified length of bytes from the SPI device.
208+
209+ :param int len: length of bytes to read, 1024 maximum.
210+ :returns: values read
211+ :rtype: list[int]
212+
213+ .. method :: writebytes(values)
214+
215+ Write bytes to the SPI device.
216+
217+ :param values: list of values to write, with a maximum length of 1024.
218+ :type values: list[int]
219+
220+ .. method :: xfer(values[,delay=0])
221+
222+ xfer([values]) -> [values]
223+ Perform an SPI transaction of values. Slave Select (SS or CS) will be
224+ released and reactivated between blocks.
225+
226+ :param values: list of values to transfer, with a maximum length of 1024.
227+ :type values: list[int]
228+ :param delay: delay in microseconds between blocks.
229+ :returns: values transferred
230+ :rtype: list[int]
231+
232+ .. method :: xfer2(values)
233+
234+ xfer2([values]) -> [values]
235+ Perform an SPI transaction of values. Slave Select (SS or CS) will be
236+ held active between blocks.
237+
238+ :param values: list of values to transfer, with a maximum length of 1024.
239+ :type values: list[int]
240+ :returns: values transferred
241+ :rtype: list[int]
154242
155243Indices and tables
156244==================
0 commit comments