You've already forked Core2forAWS-MicroPython
mirror of
https://github.com/m5stack/Core2forAWS-MicroPython.git
synced 2026-05-20 10:30:31 -07:00
stm32: Split out UART Python bindings from uart.c to machine_uart.c.
This commit is contained in:
@@ -243,6 +243,7 @@ SRC_C = \
|
||||
help.c \
|
||||
machine_i2c.c \
|
||||
machine_spi.c \
|
||||
machine_uart.c \
|
||||
modmachine.c \
|
||||
modpyb.c \
|
||||
modstm.c \
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -755,7 +755,7 @@ soft_reset_exit:
|
||||
mod_network_deinit();
|
||||
#endif
|
||||
timer_deinit();
|
||||
uart_deinit();
|
||||
uart_deinit_all();
|
||||
#if MICROPY_HW_ENABLE_CAN
|
||||
can_deinit();
|
||||
#endif
|
||||
|
||||
+92
-670
File diff suppressed because it is too large
Load Diff
+27
-2
@@ -38,16 +38,41 @@ typedef enum {
|
||||
PYB_UART_8 = 8,
|
||||
} pyb_uart_t;
|
||||
|
||||
typedef struct _pyb_uart_obj_t pyb_uart_obj_t;
|
||||
#define CHAR_WIDTH_8BIT (0)
|
||||
#define CHAR_WIDTH_9BIT (1)
|
||||
|
||||
typedef struct _pyb_uart_obj_t {
|
||||
mp_obj_base_t base;
|
||||
UART_HandleTypeDef uart; // this is 17 words big
|
||||
IRQn_Type irqn;
|
||||
pyb_uart_t uart_id : 8;
|
||||
bool is_enabled : 1;
|
||||
bool attached_to_repl; // whether the UART is attached to REPL
|
||||
byte char_width; // 0 for 7,8 bit chars, 1 for 9 bit chars
|
||||
uint16_t char_mask; // 0x7f for 7 bit, 0xff for 8 bit, 0x1ff for 9 bit
|
||||
uint16_t timeout; // timeout waiting for first char
|
||||
uint16_t timeout_char; // timeout waiting between chars
|
||||
uint16_t read_buf_len; // len in chars; buf can hold len-1 chars
|
||||
volatile uint16_t read_buf_head; // indexes first empty slot
|
||||
uint16_t read_buf_tail; // indexes first full slot (not full if equals head)
|
||||
byte *read_buf; // byte or uint16_t, depending on char size
|
||||
} pyb_uart_obj_t;
|
||||
|
||||
extern const mp_obj_type_t pyb_uart_type;
|
||||
|
||||
void uart_init0(void);
|
||||
void uart_deinit(void);
|
||||
void uart_deinit_all(void);
|
||||
bool uart_exists(int uart_id);
|
||||
bool uart_init2(pyb_uart_obj_t *uart_obj);
|
||||
void uart_deinit(pyb_uart_obj_t *uart_obj);
|
||||
void uart_irq_handler(mp_uint_t uart_id);
|
||||
|
||||
void uart_attach_to_repl(pyb_uart_obj_t *self, bool attached);
|
||||
mp_uint_t uart_rx_any(pyb_uart_obj_t *uart_obj);
|
||||
bool uart_rx_wait(pyb_uart_obj_t *self, uint32_t timeout);
|
||||
int uart_rx_char(pyb_uart_obj_t *uart_obj);
|
||||
bool uart_tx_wait(pyb_uart_obj_t *self, uint32_t timeout);
|
||||
size_t uart_tx_data(pyb_uart_obj_t *self, const void *src_in, size_t num_chars, int *errcode);
|
||||
void uart_tx_strn(pyb_uart_obj_t *uart_obj, const char *str, uint len);
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32_UART_H
|
||||
|
||||
Reference in New Issue
Block a user