diff options
| author | dherrada <dylan.herrada@gmail.com> | 2020-04-25 15:25:31 -0400 |
|---|---|---|
| committer | dherrada <dylan.herrada@gmail.com> | 2020-04-25 15:25:31 -0400 |
| commit | 7070fe1995f70e745699682bbc9776bb54a069a6 (patch) | |
| tree | fb1a89bdb44e6fefc3f4a78dbb66fd5c849cf6e1 /shared-bindings/busio | |
| parent | 28430a9919c511330c4fb833469497a346ad2288 (diff) | |
Added inline pyi to UART.c
Diffstat (limited to 'shared-bindings/busio')
| -rw-r--r-- | shared-bindings/busio/UART.c | 181 |
1 files changed, 88 insertions, 93 deletions
diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index f231924d5..59c95528d 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -40,33 +40,32 @@ #include "supervisor/shared/translate.h" -//| .. currentmodule:: busio -//| -//| :class:`UART` -- a bidirectional serial protocol -//| ================================================= -//| -//| -//| .. class:: UART(tx, rx, *, baudrate=9600, bits=8, parity=None, stop=1, timeout=1, receiver_buffer_size=64) -//| -//| A common bidirectional serial protocol that uses an an agreed upon speed -//| rather than a shared clock line. -//| -//| :param ~microcontroller.Pin tx: the pin to transmit with, or ``None`` if this ``UART`` is receive-only. -//| :param ~microcontroller.Pin rx: the pin to receive on, or ``None`` if this ``UART`` is transmit-only. -//| :param ~microcontroller.Pin rts: the pin for rts, or ``None`` if rts not in use. -//| :param ~microcontroller.Pin cts: the pin for cts, or ``None`` if cts not in use. -//| :param ~microcontroller.Pin rs485_dir: the pin for rs485 direction setting, or ``None`` if rs485 not in use. -//| :param bool rs485_invert: set to invert the sense of the rs485_dir pin. -//| :param int baudrate: the transmit and receive speed. -//| :param int bits: the number of bits per byte, 7, 8 or 9. -//| :param Parity parity: the parity used for error checking. -//| :param int stop: the number of stop bits, 1 or 2. -//| :param float timeout: the timeout in seconds to wait for the first character and between subsequent characters when reading. Raises ``ValueError`` if timeout >100 seconds. -//| :param int receiver_buffer_size: the character length of the read buffer (0 to disable). (When a character is 9 bits the buffer will be 2 * receiver_buffer_size bytes.) -//| -//| *New in CircuitPython 4.0:* ``timeout`` has incompatibly changed units from milliseconds to seconds. -//| The new upper limit on ``timeout`` is meant to catch mistaken use of milliseconds. -//| + +//|class UART: +//| """.. currentmodule:: busio +//| +//| :class:`UART` -- a bidirectional serial protocol +//| =================================================""" +//| def __init__(self, tx: microcontroller.Pin, rx: microcontroller.Pin, *, baudrate: int = 9600, bits: int = 8, parity: Parity = None, stop: int = 1, timeout: float = 1, receiver_buffer_size: int = 64): +//| """A common bidirectional serial protocol that uses an an agreed upon speed +//| rather than a shared clock line. +//| +//| :param ~microcontroller.Pin tx: the pin to transmit with, or ``None`` if this ``UART`` is receive-only. +//| :param ~microcontroller.Pin rx: the pin to receive on, or ``None`` if this ``UART`` is transmit-only. +//| :param ~microcontroller.Pin rts: the pin for rts, or ``None`` if rts not in use. +//| :param ~microcontroller.Pin cts: the pin for cts, or ``None`` if cts not in use. +//| :param ~microcontroller.Pin rs485_dir: the pin for rs485 direction setting, or ``None`` if rs485 not in use. +//| :param bool rs485_invert: set to invert the sense of the rs485_dir pin. +//| :param int baudrate: the transmit and receive speed. +//| :param int bits: the number of bits per byte, 7, 8 or 9. +//| :param Parity parity: the parity used for error checking. +//| :param int stop: the number of stop bits, 1 or 2. +//| :param float timeout: the timeout in seconds to wait for the first character and between subsequent characters when reading. Raises ``ValueError`` if timeout >100 seconds. +//| :param int receiver_buffer_size: the character length of the read buffer (0 to disable). (When a character is 9 bits the buffer will be 2 * receiver_buffer_size bytes.) +//| +//| *New in CircuitPython 4.0:* ``timeout`` has incompatibly changed units from milliseconds to seconds. +//| The new upper limit on ``timeout`` is meant to catch mistaken use of milliseconds.""" +//| ... typedef struct { mp_obj_base_t base; } busio_uart_parity_obj_t; @@ -144,10 +143,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; } -//| .. method:: deinit() -//| -//| 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); @@ -161,17 +159,15 @@ STATIC void check_for_deinit(busio_uart_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. -//| +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| 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]); @@ -181,41 +177,46 @@ 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. // -//| .. method:: read(nbytes=None) -//| -//| 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 -//| -//| .. method:: readinto(buf) +//| :return: Data read +//| :rtype: bytes or None""" +//| ... + +//| def readinto(self, buf: Any) -> Any: +//| """.. method:: readinto(buf) //| -//| Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. +//| 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.""" +//| ... -//| .. method:: readline() +//| def readline(self, ) -> Any: +//| """.. method:: readline() //| -//| Read a line, ending in a newline character. +//| Read a line, ending in a newline character. //| -//| :return: the line read -//| :rtype: int or None -//| -//| .. method:: write(buf) -//| -//| Write the buffer of bytes to the bus. +//| :return: the line read +//| :rtype: int or None""" +//| ... + +//| def write(self, buf: Any) -> Any: +//| """.. method:: write(buf) //| -//| *New in CircuitPython 4.0:* ``buf`` must be bytes, not a string. +//| Write the buffer of bytes to the bus. //| -//| :return: the number of bytes written -//| :rtype: int or None +//| *New in CircuitPython 4.0:* ``buf`` must be bytes, not a string. //| +//| :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) { @@ -259,10 +260,9 @@ STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t return ret; } -//| .. attribute:: baudrate -//| -//| 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); check_for_deinit(self); @@ -286,10 +286,9 @@ const mp_obj_property_t busio_uart_baudrate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: in_waiting -//| -//| 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); check_for_deinit(self); @@ -304,10 +303,9 @@ const mp_obj_property_t busio_uart_in_waiting_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: timeout -//| -//| 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); check_for_deinit(self); @@ -333,10 +331,9 @@ const mp_obj_property_t busio_uart_timeout_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: reset_input_buffer() -//| -//| 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); check_for_deinit(self); @@ -345,18 +342,16 @@ 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.UART.Parity() -//| -//| Enum-like class to define the parity used to verify correct data transfer. -//| -//| .. data:: ODD -//| -//| Total number of ones should be odd. -//| -//| .. data:: EVEN -//| -//| Total number of ones should be even. -//| +//|class busio: +//| def __init__(self, ): +//| """Enum-like class to define the parity used to verify correct data transfer.""" +//| ODD: Any = +//| """Total number of ones should be odd.""" +//| ... +//| EVEN: Any = +//| """Total number of ones should be even.""" +//| ... +//| ... const mp_obj_type_t busio_uart_parity_type; const busio_uart_parity_obj_t busio_uart_parity_odd_obj = { |
