|
24 | 24 | * THE SOFTWARE.
|
25 | 25 | */
|
26 | 26 |
|
27 |
| -// This file contains all of the Python API definitions for the |
28 |
| -// busio.SPI class. |
29 |
| - |
30 | 27 | #include "shared-bindings/microcontroller/Pin.h"
|
31 | 28 | #include "shared-bindings/busdevice/SPIDevice.h"
|
32 | 29 | #include "shared-bindings/util.h"
|
|
42 | 39 |
|
43 | 40 |
|
44 | 41 | //| class SPIDevice:
|
45 |
| -//| """ |
46 |
| -//| Represents a single SPI device and manages locking the bus and the device |
47 |
| -//| address. |
48 |
| -//| :param ~busio.SPI spi: The SPI bus the device is on |
49 |
| -//| :param int device_address: The 7 bit device address |
50 |
| -//| :param bool probe: Probe for the device upon object creation, default is true |
51 |
| -//| .. note:: This class is **NOT** built into CircuitPython. See |
52 |
| -//| :ref:`here for install instructions <bus_device_installation>`. |
53 |
| -//| Example: |
54 |
| -//| .. code-block:: python |
55 |
| -//| import busio |
56 |
| -//| from board import * |
57 |
| -//| from adafruit_bus_device.spi_device import SPIDevice |
58 |
| -//| with busio.SPI(SCL, SDA) as spi: |
59 |
| -//| device = SPIDevice(spi, 0x70) |
60 |
| -//| bytes_read = bytearray(4) |
61 |
| -//| with device: |
62 |
| -//| device.readinto(bytes_read) |
63 |
| -//| # A second transaction |
64 |
| -//| with device: |
65 |
| -//| device.write(bytes_read)""" |
| 42 | +//| """SPI Device Manager""" |
| 43 | +//| |
| 44 | +//| def __init__(self, spi: busio.SPI, chip_select: microcontroller.Pin, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, extra_clocks : int = 0) -> None: |
| 45 | +//| |
| 46 | +//| """ |
| 47 | +//| Represents a single SPI device and manages locking the bus and the device address. |
| 48 | +//| :param ~busio.SPI spi: The SPI bus the device is on |
| 49 | +//| :param ~digitalio.DigitalInOut chip_select: The chip select pin object that implements the |
| 50 | +//| DigitalInOut API. |
| 51 | +//| :param int extra_clocks: The minimum number of clock cycles to cycle the bus after CS is high. |
| 52 | +//| (Used for SD cards.) |
| 53 | +//| Example: |
| 54 | +//| .. code-block:: python |
| 55 | +//| import busio |
| 56 | +//| import digitalio |
| 57 | +//| from board import * |
| 58 | +//| from adafruit_bus_device.spi_device import SPIDevice |
| 59 | +//| with busio.SPI(SCK, MOSI, MISO) as spi_bus: |
| 60 | +//| cs = digitalio.DigitalInOut(D10) |
| 61 | +//| device = SPIDevice(spi_bus, cs) |
| 62 | +//| bytes_read = bytearray(4) |
| 63 | +//| # The object assigned to spi in the with statements below |
| 64 | +//| # is the original spi_bus object. We are using the busio.SPI |
| 65 | +//| # operations busio.SPI.readinto() and busio.SPI.write(). |
| 66 | +//| with device as spi: |
| 67 | +//| spi.readinto(bytes_read) |
| 68 | +//| # A second transaction |
| 69 | +//| with device as spi: |
| 70 | +//| spi.write(bytes_read)""" |
66 | 71 | //| ...
|
67 | 72 | //|
|
68 | 73 | STATIC mp_obj_t busdevice_spidevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
|
0 commit comments