summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorJeff Epler <jeff@adafruit.com>2020-07-01 21:02:08 -0500
committerGitHub <noreply@github.com>2020-07-01 21:02:08 -0500
commitfcddfd0f3953b3633912f6aa963af8353075fc76 (patch)
treec729f7871fadcbae5dd7365a20dd01c20fa07755 /shared-bindings
parent0e5dfbaf8f6072a79189b198b512971e316b7639 (diff)
parent367d3800fc501bfe3ec05b4b517ed195cf8d07c4 (diff)
Merge pull request #3083 from tannewt/esp32s2_busio
Add busio support for the ESP32-S2
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/busio/SPI.h2
-rw-r--r--shared-bindings/busio/UART.c14
-rw-r--r--shared-bindings/busio/UART.h10
3 files changed, 13 insertions, 13 deletions
diff --git a/shared-bindings/busio/SPI.h b/shared-bindings/busio/SPI.h
index aa7d715b9..3a8b6dbc1 100644
--- a/shared-bindings/busio/SPI.h
+++ b/shared-bindings/busio/SPI.h
@@ -56,7 +56,7 @@ extern bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t *dat
extern bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_value);
// Reads and write len bytes simultaneously.
-extern bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uint8_t *data_in, size_t len);
+extern bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_out, uint8_t *data_in, size_t len);
// Return actual SPI bus frequency.
uint32_t common_hal_busio_spi_get_frequency(busio_spi_obj_t* self);
diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c
index 8c0811266..018ded182 100644
--- a/shared-bindings/busio/UART.c
+++ b/shared-bindings/busio/UART.c
@@ -52,8 +52,8 @@
//| :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 ~microcontroller.Pin rs485_dir: the output pin for rs485 direction setting, or ``None`` if rs485 not in use.
+//| :param bool rs485_invert: rs485_dir pin active high when set. Active low otherwise.
//| :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.
@@ -87,8 +87,8 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co
enum { ARG_tx, ARG_rx, ARG_baudrate, ARG_bits, ARG_parity, ARG_stop, ARG_timeout, ARG_receiver_buffer_size,
ARG_rts, ARG_cts, ARG_rs485_dir,ARG_rs485_invert};
static const mp_arg_t allowed_args[] = {
- { MP_QSTR_tx, MP_ARG_REQUIRED | MP_ARG_OBJ },
- { MP_QSTR_rx, MP_ARG_REQUIRED | MP_ARG_OBJ },
+ { MP_QSTR_tx, MP_ARG_OBJ, {.u_obj = mp_const_none} },
+ { MP_QSTR_rx, MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_baudrate, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 9600} },
{ MP_QSTR_bits, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 8} },
{ MP_QSTR_parity, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
@@ -115,11 +115,11 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co
mp_raise_ValueError(translate("bits must be 7, 8 or 9"));
}
- uart_parity_t parity = PARITY_NONE;
+ busio_uart_parity_t parity = BUSIO_UART_PARITY_NONE;
if (args[ARG_parity].u_obj == &busio_uart_parity_even_obj) {
- parity = PARITY_EVEN;
+ parity = BUSIO_UART_PARITY_EVEN;
} else if (args[ARG_parity].u_obj == &busio_uart_parity_odd_obj) {
- parity = PARITY_ODD;
+ parity = BUSIO_UART_PARITY_ODD;
}
uint8_t stop = args[ARG_stop].u_int;
diff --git a/shared-bindings/busio/UART.h b/shared-bindings/busio/UART.h
index 3aed4e534..ce8da1445 100644
--- a/shared-bindings/busio/UART.h
+++ b/shared-bindings/busio/UART.h
@@ -34,17 +34,17 @@
extern const mp_obj_type_t busio_uart_type;
typedef enum {
- PARITY_NONE,
- PARITY_EVEN,
- PARITY_ODD
-} uart_parity_t;
+ BUSIO_UART_PARITY_NONE,
+ BUSIO_UART_PARITY_EVEN,
+ BUSIO_UART_PARITY_ODD
+} busio_uart_parity_t;
// Construct an underlying UART object.
extern void common_hal_busio_uart_construct(busio_uart_obj_t *self,
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
- uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
+ uint32_t baudrate, uint8_t bits, busio_uart_parity_t parity, uint8_t stop,
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
bool sigint_enabled);