Fixed indentation
This commit is contained in:
parent
deccdcc1d6
commit
093461e816
@ -85,9 +85,9 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, con
|
||||
return (mp_obj_t)self;
|
||||
}
|
||||
|
||||
//| def deinit(self, ) -> Any:
|
||||
//| """Releases control of the underlying hardware so other classes can use it."""
|
||||
//| ...
|
||||
//| def deinit(self, ) -> Any:
|
||||
//| """Releases control of the underlying hardware so other classes can use it."""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_i2c_obj_deinit(mp_obj_t self_in) {
|
||||
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
common_hal_busio_i2c_deinit(self);
|
||||
@ -101,15 +101,15 @@ STATIC void check_for_deinit(busio_i2c_obj_t *self) {
|
||||
}
|
||||
}
|
||||
|
||||
//| def __enter__(self, ) -> Any:
|
||||
//| """No-op used in Context Managers."""
|
||||
//| ...
|
||||
//| def __enter__(self, ) -> Any:
|
||||
//| """No-op used in Context Managers."""
|
||||
//| ...
|
||||
// Provided by context manager helper.
|
||||
|
||||
//| def __exit__(self, ) -> Any:
|
||||
//| """Automatically deinitializes the hardware on context exit. See
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//| ...
|
||||
//| def __exit__(self, ) -> Any:
|
||||
//| """Automatically deinitializes the hardware on context exit. See
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_i2c_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
common_hal_busio_i2c_deinit(args[0]);
|
||||
@ -124,14 +124,14 @@ static void check_lock(busio_i2c_obj_t *self) {
|
||||
}
|
||||
}
|
||||
|
||||
//| def scan(self, ) -> Any:
|
||||
//| def scan(self, ) -> Any:
|
||||
//|
|
||||
//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a
|
||||
//| list of those that respond.
|
||||
//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a
|
||||
//| list of those that respond.
|
||||
//|
|
||||
//| :return: List of device ids on the I2C bus
|
||||
//| :rtype: list"""
|
||||
//| ...
|
||||
//| :return: List of device ids on the I2C bus
|
||||
//| :rtype: list"""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) {
|
||||
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
@ -148,12 +148,12 @@ STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_scan_obj, busio_i2c_scan);
|
||||
|
||||
//| def try_lock(self, ) -> Any:
|
||||
//| """Attempts to grab the I2C lock. Returns True on success.
|
||||
//| def try_lock(self, ) -> Any:
|
||||
//| """Attempts to grab the I2C lock. Returns True on success.
|
||||
//|
|
||||
//| :return: True when lock has been grabbed
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
//| :return: True when lock has been grabbed
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_i2c_obj_try_lock(mp_obj_t self_in) {
|
||||
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
@ -161,9 +161,9 @@ STATIC mp_obj_t busio_i2c_obj_try_lock(mp_obj_t self_in) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_try_lock_obj, busio_i2c_obj_try_lock);
|
||||
|
||||
//| def unlock(self, ) -> Any:
|
||||
//| """Releases the I2C lock."""
|
||||
//| ...
|
||||
//| def unlock(self, ) -> Any:
|
||||
//| """Releases the I2C lock."""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) {
|
||||
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
@ -172,20 +172,20 @@ STATIC mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock);
|
||||
|
||||
//| def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> Any:
|
||||
//| """Read into ``buffer`` from the slave specified by ``address``.
|
||||
//| The number of bytes read will be the length of ``buffer``.
|
||||
//| At least one byte must be read.
|
||||
//| def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> Any:
|
||||
//| """Read into ``buffer`` from the slave specified by ``address``.
|
||||
//| The number of bytes read will be the length of ``buffer``.
|
||||
//| At least one byte must be read.
|
||||
//|
|
||||
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
|
||||
//| as if ``buffer[start:end]``. This will not cause an allocation like
|
||||
//| ``buf[start:end]`` will so it saves memory.
|
||||
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
|
||||
//| as if ``buffer[start:end]``. This will not cause an allocation like
|
||||
//| ``buf[start:end]`` will so it saves memory.
|
||||
//|
|
||||
//| :param int address: 7-bit device address
|
||||
//| :param bytearray buffer: buffer to write into
|
||||
//| :param int start: Index to start writing at
|
||||
//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``"""
|
||||
//| ...
|
||||
//| :param int address: 7-bit device address
|
||||
//| :param bytearray buffer: buffer to write into
|
||||
//| :param int start: Index to start writing at
|
||||
//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``"""
|
||||
//| ...
|
||||
// Shared arg parsing for readfrom_into and writeto_then_readfrom.
|
||||
STATIC void readfrom(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end) {
|
||||
mp_buffer_info_t bufinfo;
|
||||
@ -223,26 +223,26 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args,
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_into);
|
||||
|
||||
//| def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any:
|
||||
//| """Write the bytes from ``buffer`` to the slave specified by ``address``.
|
||||
//| Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be
|
||||
//| removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and
|
||||
//| repeated start before a read.
|
||||
//| def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any:
|
||||
//| """Write the bytes from ``buffer`` to the slave specified by ``address``.
|
||||
//| Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be
|
||||
//| removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and
|
||||
//| repeated start before a read.
|
||||
//|
|
||||
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
|
||||
//| as if ``buffer[start:end]``. This will not cause an allocation like
|
||||
//| ``buffer[start:end]`` will so it saves memory.
|
||||
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
|
||||
//| as if ``buffer[start:end]``. This will not cause an allocation like
|
||||
//| ``buffer[start:end]`` will so it saves memory.
|
||||
//|
|
||||
//| Writing a buffer or slice of length zero is permitted, as it can be used
|
||||
//| to poll for the existence of a device.
|
||||
//| Writing a buffer or slice of length zero is permitted, as it can be used
|
||||
//| to poll for the existence of a device.
|
||||
//|
|
||||
//| :param int address: 7-bit device address
|
||||
//| :param bytearray buffer: buffer containing the bytes to write
|
||||
//| :param int start: Index to start writing from
|
||||
//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)``
|
||||
//| :param bool stop: If true, output an I2C stop condition after the buffer is written.
|
||||
//| Deprecated. Will be removed in 6.x and act as stop=True."""
|
||||
//| ...
|
||||
//| :param int address: 7-bit device address
|
||||
//| :param bytearray buffer: buffer containing the bytes to write
|
||||
//| :param int start: Index to start writing from
|
||||
//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)``
|
||||
//| :param bool stop: If true, output an I2C stop condition after the buffer is written.
|
||||
//| Deprecated. Will be removed in 6.x and act as stop=True."""
|
||||
//| ...
|
||||
// Shared arg parsing for writeto and writeto_then_readfrom.
|
||||
STATIC void writeto(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end, bool stop) {
|
||||
// get the buffer to write the data from
|
||||
@ -281,23 +281,23 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto);
|
||||
|
||||
//| def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any:
|
||||
//| """Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop
|
||||
//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and
|
||||
//| ``in_buffer`` can be the same buffer because they are used sequentially.
|
||||
//| def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any:
|
||||
//| """Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop
|
||||
//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and
|
||||
//| ``in_buffer`` can be the same buffer because they are used sequentially.
|
||||
//|
|
||||
//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced
|
||||
//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]``
|
||||
//| will so it saves memory.
|
||||
//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced
|
||||
//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]``
|
||||
//| will so it saves memory.
|
||||
//|
|
||||
//| :param int address: 7-bit device address
|
||||
//| :param bytearray out_buffer: buffer containing the bytes to write
|
||||
//| :param bytearray in_buffer: buffer to write into
|
||||
//| :param int out_start: Index to start writing from
|
||||
//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)``
|
||||
//| :param int in_start: Index to start writing at
|
||||
//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``"""
|
||||
//| ...
|
||||
//| :param int address: 7-bit device address
|
||||
//| :param bytearray out_buffer: buffer containing the bytes to write
|
||||
//| :param bytearray in_buffer: buffer to write into
|
||||
//| :param int out_start: Index to start writing from
|
||||
//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)``
|
||||
//| :param int in_start: Index to start writing at
|
||||
//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``"""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
|
@ -79,9 +79,9 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
//| def deinit(self, ) -> Any:
|
||||
//| """Deinitialize the OneWire bus and release any hardware resources for reuse."""
|
||||
//| ...
|
||||
//| def deinit(self, ) -> Any:
|
||||
//| """Deinitialize the OneWire bus and release any hardware resources for reuse."""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_onewire_deinit(mp_obj_t self_in) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
common_hal_busio_onewire_deinit(self);
|
||||
@ -95,15 +95,15 @@ STATIC void check_for_deinit(busio_onewire_obj_t *self) {
|
||||
}
|
||||
}
|
||||
|
||||
//| def __enter__(self, ) -> Any:
|
||||
//| """No-op used by Context Managers."""
|
||||
//| ...
|
||||
//| def __enter__(self, ) -> Any:
|
||||
//| """No-op used by Context Managers."""
|
||||
//| ...
|
||||
// Provided by context manager helper.
|
||||
|
||||
//| def __exit__(self, ) -> Any:
|
||||
//| """Automatically deinitializes the hardware when exiting a context. See
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//| ...
|
||||
//| def __exit__(self, ) -> Any:
|
||||
//| """Automatically deinitializes the hardware when exiting a context. See
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
common_hal_busio_onewire_deinit(args[0]);
|
||||
@ -111,12 +111,12 @@ STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args)
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, busio_onewire_obj___exit__);
|
||||
|
||||
//| def reset(self, ) -> Any:
|
||||
//| """Reset the OneWire bus and read presence
|
||||
//| def reset(self, ) -> Any:
|
||||
//| """Reset the OneWire bus and read presence
|
||||
//|
|
||||
//| :returns: False when at least one device is present
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
//| :returns: False when at least one device is present
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
@ -125,12 +125,12 @@ STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset);
|
||||
|
||||
//| def read_bit(self, ) -> Any:
|
||||
//| """Read in a bit
|
||||
//| def read_bit(self, ) -> Any:
|
||||
//| """Read in a bit
|
||||
//|
|
||||
//| :returns: bit state read
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
//| :returns: bit state read
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
@ -139,9 +139,9 @@ STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_read_bit_obj, busio_onewire_obj_read_bit);
|
||||
|
||||
//| def write_bit(self, value: Any) -> Any:
|
||||
//| """Write out a bit based on value."""
|
||||
//| ...
|
||||
//| def write_bit(self, value: Any) -> Any:
|
||||
//| """Write out a bit based on value."""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_onewire_obj_write_bit(mp_obj_t self_in, mp_obj_t bool_obj) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
|
@ -101,9 +101,9 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
//| def deinit(self, ) -> Any:
|
||||
//| """Turn off the SPI bus."""
|
||||
//| ...
|
||||
//| def deinit(self, ) -> Any:
|
||||
//| """Turn off the SPI bus."""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) {
|
||||
busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
common_hal_busio_spi_deinit(self);
|
||||
@ -111,15 +111,15 @@ STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_deinit_obj, busio_spi_obj_deinit);
|
||||
|
||||
//| def __enter__(self, ) -> Any:
|
||||
//| """No-op used by Context Managers.
|
||||
//| Provided by context manager helper."""
|
||||
//| ...
|
||||
//| def __enter__(self, ) -> Any:
|
||||
//| """No-op used by Context Managers.
|
||||
//| Provided by context manager helper."""
|
||||
//| ...
|
||||
|
||||
//| def __exit__(self, ) -> Any:
|
||||
//| """Automatically deinitializes the hardware when exiting a context. See
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//| ...
|
||||
//| def __exit__(self, ) -> Any:
|
||||
//| """Automatically deinitializes the hardware when exiting a context. See
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_spi_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
common_hal_busio_spi_deinit(args[0]);
|
||||
@ -140,28 +140,28 @@ STATIC void check_for_deinit(busio_spi_obj_t *self) {
|
||||
}
|
||||
}
|
||||
|
||||
//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any:
|
||||
//| """Configures the SPI bus. The SPI object must be locked.
|
||||
//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any:
|
||||
//| """Configures the SPI bus. The SPI object must be locked.
|
||||
//|
|
||||
//| :param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower
|
||||
//| due to the granularity of available clock settings.
|
||||
//| Check the `frequency` attribute for the actual clock rate.
|
||||
//| :param int polarity: the base state of the clock line (0 or 1)
|
||||
//| :param int phase: the edge of the clock that data is captured. First (0)
|
||||
//| or second (1). Rising or falling depends on clock polarity.
|
||||
//| :param int bits: the number of bits per word
|
||||
//| :param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower
|
||||
//| due to the granularity of available clock settings.
|
||||
//| Check the `frequency` attribute for the actual clock rate.
|
||||
//| :param int polarity: the base state of the clock line (0 or 1)
|
||||
//| :param int phase: the edge of the clock that data is captured. First (0)
|
||||
//| or second (1). Rising or falling depends on clock polarity.
|
||||
//| :param int bits: the number of bits per word
|
||||
//|
|
||||
//| .. note:: On the SAMD21, it is possible to set the baudrate to 24 MHz, but that
|
||||
//| speed is not guaranteed to work. 12 MHz is the next available lower speed, and is
|
||||
//| within spec for the SAMD21.
|
||||
//| .. note:: On the SAMD21, it is possible to set the baudrate to 24 MHz, but that
|
||||
//| speed is not guaranteed to work. 12 MHz is the next available lower speed, and is
|
||||
//| within spec for the SAMD21.
|
||||
//|
|
||||
//| .. note:: On the nRF52840, these baudrates are available: 125kHz, 250kHz, 1MHz, 2MHz, 4MHz,
|
||||
//| and 8MHz.
|
||||
//| If you pick a a baudrate other than one of these, the nearest lower
|
||||
//| baudrate will be chosen, with a minimum of 125kHz.
|
||||
//| Two SPI objects may be created, except on the Circuit Playground Bluefruit,
|
||||
//| which allows only one (to allow for an additional I2C object)."""
|
||||
//| ...
|
||||
//| .. note:: On the nRF52840, these baudrates are available: 125kHz, 250kHz, 1MHz, 2MHz, 4MHz,
|
||||
//| and 8MHz.
|
||||
//| If you pick a a baudrate other than one of these, the nearest lower
|
||||
//| baudrate will be chosen, with a minimum of 125kHz.
|
||||
//| Two SPI objects may be created, except on the Circuit Playground Bluefruit,
|
||||
//| which allows only one (to allow for an additional I2C object)."""
|
||||
//| ...
|
||||
|
||||
STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits };
|
||||
@ -198,12 +198,12 @@ STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_configure_obj, 1, busio_spi_configure);
|
||||
|
||||
//| def try_lock(self, ) -> Any:
|
||||
//| """Attempts to grab the SPI lock. Returns True on success.
|
||||
//| def try_lock(self, ) -> Any:
|
||||
//| """Attempts to grab the SPI lock. Returns True on success.
|
||||
//|
|
||||
//| :return: True when lock has been grabbed
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
//| :return: True when lock has been grabbed
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
|
||||
STATIC mp_obj_t busio_spi_obj_try_lock(mp_obj_t self_in) {
|
||||
busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
@ -211,9 +211,9 @@ STATIC mp_obj_t busio_spi_obj_try_lock(mp_obj_t self_in) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_try_lock_obj, busio_spi_obj_try_lock);
|
||||
|
||||
//| def unlock(self, ) -> Any:
|
||||
//| """Releases the SPI lock."""
|
||||
//| ...
|
||||
//| def unlock(self, ) -> Any:
|
||||
//| """Releases the SPI lock."""
|
||||
//| ...
|
||||
|
||||
STATIC mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) {
|
||||
busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
@ -223,14 +223,14 @@ STATIC mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock);
|
||||
|
||||
//| def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any:
|
||||
//| """Write the data contained in ``buffer``. The SPI object must be locked.
|
||||
//| If the buffer is empty, nothing happens.
|
||||
//| def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any:
|
||||
//| """Write the data contained in ``buffer``. The SPI object must be locked.
|
||||
//| If the buffer is empty, nothing happens.
|
||||
//|
|
||||
//| :param bytearray buffer: Write out the data in this buffer
|
||||
//| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]``
|
||||
//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``"""
|
||||
//| ...
|
||||
//| :param bytearray buffer: Write out the data in this buffer
|
||||
//| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]``
|
||||
//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``"""
|
||||
//| ...
|
||||
|
||||
STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_buffer, ARG_start, ARG_end };
|
||||
@ -264,16 +264,16 @@ STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 2, busio_spi_write);
|
||||
|
||||
|
||||
//| def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any:
|
||||
//| """Read into ``buffer`` while writing ``write_value`` for each byte read.
|
||||
//| The SPI object must be locked.
|
||||
//| If the number of bytes to read is 0, nothing happens.
|
||||
//| def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any:
|
||||
//| """Read into ``buffer`` while writing ``write_value`` for each byte read.
|
||||
//| The SPI object must be locked.
|
||||
//| If the number of bytes to read is 0, nothing happens.
|
||||
//|
|
||||
//| :param bytearray buffer: Read data into this buffer
|
||||
//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]``
|
||||
//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``
|
||||
//| :param int write_value: Value to write while reading. (Usually ignored.)"""
|
||||
//| ...
|
||||
//| :param bytearray buffer: Read data into this buffer
|
||||
//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]``
|
||||
//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``
|
||||
//| :param int write_value: Value to write while reading. (Usually ignored.)"""
|
||||
//| ...
|
||||
|
||||
STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_buffer, ARG_start, ARG_end, ARG_write_value };
|
||||
@ -307,20 +307,20 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 2, busio_spi_readinto);
|
||||
|
||||
//| def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any:
|
||||
//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``.
|
||||
//| The SPI object must be locked.
|
||||
//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]``
|
||||
//| must be equal.
|
||||
//| If buffer slice lengths are both 0, nothing happens.
|
||||
//| def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any:
|
||||
//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``.
|
||||
//| The SPI object must be locked.
|
||||
//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]``
|
||||
//| must be equal.
|
||||
//| If buffer slice lengths are both 0, nothing happens.
|
||||
//|
|
||||
//| :param bytearray buffer_out: Write out the data in this buffer
|
||||
//| :param bytearray buffer_in: Read data into this buffer
|
||||
//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]``
|
||||
//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)``
|
||||
//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]``
|
||||
//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``"""
|
||||
//| ...
|
||||
//| :param bytearray buffer_out: Write out the data in this buffer
|
||||
//| :param bytearray buffer_in: Read data into this buffer
|
||||
//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]``
|
||||
//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)``
|
||||
//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]``
|
||||
//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``"""
|
||||
//| ...
|
||||
|
||||
STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end };
|
||||
@ -369,9 +369,9 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 2, busio_spi_write_readinto);
|
||||
|
||||
//| frequency: Any = ...
|
||||
//| """The actual SPI bus frequency. This may not match the frequency requested
|
||||
//| due to internal limitations."""
|
||||
//| frequency: Any = ...
|
||||
//| """The actual SPI bus frequency. This may not match the frequency requested
|
||||
//| due to internal limitations."""
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t busio_spi_obj_get_frequency(mp_obj_t self_in) {
|
||||
|
@ -141,9 +141,9 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co
|
||||
return (mp_obj_t)self;
|
||||
}
|
||||
|
||||
//| def deinit(self, ) -> Any:
|
||||
//| """Deinitialises the UART and releases any hardware resources for reuse."""
|
||||
//| ...
|
||||
//| def deinit(self, ) -> Any:
|
||||
//| """Deinitialises the UART and releases any hardware resources for reuse."""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_uart_obj_deinit(mp_obj_t self_in) {
|
||||
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
common_hal_busio_uart_deinit(self);
|
||||
@ -157,15 +157,15 @@ STATIC void check_for_deinit(busio_uart_obj_t *self) {
|
||||
}
|
||||
}
|
||||
|
||||
//| def __enter__(self, ) -> Any:
|
||||
//| """No-op used by Context Managers."""
|
||||
//| ...
|
||||
//| def __enter__(self, ) -> Any:
|
||||
//| """No-op used by Context Managers."""
|
||||
//| ...
|
||||
// Provided by context manager helper.
|
||||
|
||||
//| def __exit__(self, ) -> Any:
|
||||
//| """Automatically deinitializes the hardware when exiting a context. See
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//| ...
|
||||
//| def __exit__(self, ) -> Any:
|
||||
//| """Automatically deinitializes the hardware when exiting a context. See
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_uart_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
common_hal_busio_uart_deinit(args[0]);
|
||||
@ -175,40 +175,40 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
|
||||
|
||||
// These are standard stream methods. Code is in py/stream.c.
|
||||
//
|
||||
//| def read(self, nbytes: Any = None) -> Any:
|
||||
//| """Read characters. If ``nbytes`` is specified then read at most that many
|
||||
//| bytes. Otherwise, read everything that arrives until the connection
|
||||
//| times out. Providing the number of bytes expected is highly recommended
|
||||
//| because it will be faster.
|
||||
//| def read(self, nbytes: Any = None) -> Any:
|
||||
//| """Read characters. If ``nbytes`` is specified then read at most that many
|
||||
//| bytes. Otherwise, read everything that arrives until the connection
|
||||
//| times out. Providing the number of bytes expected is highly recommended
|
||||
//| because it will be faster.
|
||||
//|
|
||||
//| :return: Data read
|
||||
//| :rtype: bytes or None"""
|
||||
//| ...
|
||||
//| :return: Data read
|
||||
//| :rtype: bytes or None"""
|
||||
//| ...
|
||||
|
||||
//| def readinto(self, buf: Any) -> Any:
|
||||
//| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes.
|
||||
//| def readinto(self, buf: Any) -> Any:
|
||||
//| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes.
|
||||
//|
|
||||
//| :return: number of bytes read and stored into ``buf``
|
||||
//| :rtype: int or None (on a non-blocking error)
|
||||
//| :return: number of bytes read and stored into ``buf``
|
||||
//| :rtype: int or None (on a non-blocking error)
|
||||
//|
|
||||
//| *New in CircuitPython 4.0:* No length parameter is permitted."""
|
||||
//| ...
|
||||
//| *New in CircuitPython 4.0:* No length parameter is permitted."""
|
||||
//| ...
|
||||
|
||||
//| def readline(self, ) -> Any:
|
||||
//| """Read a line, ending in a newline character.
|
||||
//| def readline(self, ) -> Any:
|
||||
//| """Read a line, ending in a newline character.
|
||||
//|
|
||||
//| :return: the line read
|
||||
//| :rtype: int or None"""
|
||||
//| ...
|
||||
//| :return: the line read
|
||||
//| :rtype: int or None"""
|
||||
//| ...
|
||||
|
||||
//| def write(self, buf: Any) -> Any:
|
||||
//| """Write the buffer of bytes to the bus.
|
||||
//| def write(self, buf: Any) -> Any:
|
||||
//| """Write the buffer of bytes to the bus.
|
||||
//|
|
||||
//| *New in CircuitPython 4.0:* ``buf`` must be bytes, not a string.
|
||||
//| *New in CircuitPython 4.0:* ``buf`` must be bytes, not a string.
|
||||
//|
|
||||
//| :return: the number of bytes written
|
||||
//| :rtype: int or None"""
|
||||
//| ...
|
||||
//| :return: the number of bytes written
|
||||
//| :rtype: int or None"""
|
||||
//| ...
|
||||
|
||||
// These three methods are used by the shared stream methods.
|
||||
STATIC mp_uint_t busio_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) {
|
||||
@ -252,8 +252,8 @@ STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t
|
||||
return ret;
|
||||
}
|
||||
|
||||
//| baudrate: Any = ...
|
||||
//| """The current baudrate."""
|
||||
//| baudrate: Any = ...
|
||||
//| """The current baudrate."""
|
||||
//|
|
||||
STATIC mp_obj_t busio_uart_obj_get_baudrate(mp_obj_t self_in) {
|
||||
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
@ -278,8 +278,8 @@ const mp_obj_property_t busio_uart_baudrate_obj = {
|
||||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
//| in_waiting: Any = ...
|
||||
//| """The number of bytes in the input buffer, available to be read"""
|
||||
//| in_waiting: Any = ...
|
||||
//| """The number of bytes in the input buffer, available to be read"""
|
||||
//|
|
||||
STATIC mp_obj_t busio_uart_obj_get_in_waiting(mp_obj_t self_in) {
|
||||
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
@ -295,8 +295,8 @@ const mp_obj_property_t busio_uart_in_waiting_obj = {
|
||||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
//| timeout: Any = ...
|
||||
//| """The current timeout, in seconds (float)."""
|
||||
//| timeout: Any = ...
|
||||
//| """The current timeout, in seconds (float)."""
|
||||
//|
|
||||
STATIC mp_obj_t busio_uart_obj_get_timeout(mp_obj_t self_in) {
|
||||
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
@ -323,8 +323,8 @@ const mp_obj_property_t busio_uart_timeout_obj = {
|
||||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
//| def reset_input_buffer(self, ) -> Any: ...
|
||||
//| """Discard any unread characters in the input buffer."""
|
||||
//| def reset_input_buffer(self, ) -> Any: ...
|
||||
//| """Discard any unread characters in the input buffer."""
|
||||
//|
|
||||
STATIC mp_obj_t busio_uart_obj_reset_input_buffer(mp_obj_t self_in) {
|
||||
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
@ -334,7 +334,7 @@ STATIC mp_obj_t busio_uart_obj_reset_input_buffer(mp_obj_t self_in) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_reset_input_buffer_obj, busio_uart_obj_reset_input_buffer);
|
||||
|
||||
//| class busio:
|
||||
//| class Parity:
|
||||
//| """Enum-like class to define the parity used to verify correct data transfer."""
|
||||
//|
|
||||
//| def __init__(self, ):
|
||||
|
Loading…
x
Reference in New Issue
Block a user