From 76c11533807a12571889b81136d710dfc9da2c56 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sun, 1 Nov 2020 08:57:31 -0600 Subject: [PATCH] Fixed stubs --- shared-bindings/busdevice/I2CDevice.c | 2 +- shared-bindings/busdevice/SPIDevice.c | 53 +++++++++++++++------------ 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/shared-bindings/busdevice/I2CDevice.c b/shared-bindings/busdevice/I2CDevice.c index e0e89e16ab..5f1fac3197 100644 --- a/shared-bindings/busdevice/I2CDevice.c +++ b/shared-bindings/busdevice/I2CDevice.c @@ -41,7 +41,7 @@ //| class I2CDevice: //| """I2C Device Manager""" //| -//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 100000, timeout: int = 255) -> None: +//| def __init__(self, i2c: busio.I2C, device_address: int, probe: bool = True) -> None: //| //| """Represents a single I2C device and manages locking the bus and the device //| address. diff --git a/shared-bindings/busdevice/SPIDevice.c b/shared-bindings/busdevice/SPIDevice.c index 7ef047349c..039cd842c9 100644 --- a/shared-bindings/busdevice/SPIDevice.c +++ b/shared-bindings/busdevice/SPIDevice.c @@ -24,9 +24,6 @@ * THE SOFTWARE. */ -// This file contains all of the Python API definitions for the -// busio.SPI class. - #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/busdevice/SPIDevice.h" #include "shared-bindings/util.h" @@ -42,27 +39,35 @@ //| class SPIDevice: -//| """ -//| Represents a single SPI device and manages locking the bus and the device -//| address. -//| :param ~busio.SPI spi: The SPI bus the device is on -//| :param int device_address: The 7 bit device address -//| :param bool probe: Probe for the device upon object creation, default is true -//| .. note:: This class is **NOT** built into CircuitPython. See -//| :ref:`here for install instructions `. -//| Example: -//| .. code-block:: python -//| import busio -//| from board import * -//| from adafruit_bus_device.spi_device import SPIDevice -//| with busio.SPI(SCL, SDA) as spi: -//| device = SPIDevice(spi, 0x70) -//| bytes_read = bytearray(4) -//| with device: -//| device.readinto(bytes_read) -//| # A second transaction -//| with device: -//| device.write(bytes_read)""" +//| """SPI Device Manager""" +//| +//| def __init__(self, spi: busio.SPI, chip_select: microcontroller.Pin, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, extra_clocks : int = 0) -> None: +//| +//| """ +//| Represents a single SPI device and manages locking the bus and the device address. +//| :param ~busio.SPI spi: The SPI bus the device is on +//| :param ~digitalio.DigitalInOut chip_select: The chip select pin object that implements the +//| DigitalInOut API. +//| :param int extra_clocks: The minimum number of clock cycles to cycle the bus after CS is high. +//| (Used for SD cards.) +//| Example: +//| .. code-block:: python +//| import busio +//| import digitalio +//| from board import * +//| from adafruit_bus_device.spi_device import SPIDevice +//| with busio.SPI(SCK, MOSI, MISO) as spi_bus: +//| cs = digitalio.DigitalInOut(D10) +//| device = SPIDevice(spi_bus, cs) +//| bytes_read = bytearray(4) +//| # The object assigned to spi in the with statements below +//| # is the original spi_bus object. We are using the busio.SPI +//| # operations busio.SPI.readinto() and busio.SPI.write(). +//| with device as spi: +//| spi.readinto(bytes_read) +//| # A second transaction +//| with device as spi: +//| spi.write(bytes_read)""" //| ... //| 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) {