alif/mpuart: Enhance UART to support bits/parity/stop and more IRQs.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-03-17 13:19:07 +11:00
parent 19a4689c6b
commit 293e8db9d7
3 changed files with 92 additions and 17 deletions

View File

@@ -89,14 +89,20 @@ static ringbuf_t hci_rx_ringbuf = {
.iput = 0,
};
static void mp_bluetooth_hci_uart_irq_callback(unsigned int uart_id, unsigned int trigger) {
if (trigger == MP_UART_IRQ_RXIDLE) {
mp_bluetooth_hci_poll_now();
}
}
int mp_bluetooth_hci_uart_init(uint32_t port, uint32_t baudrate) {
hci_uart_id = port;
hci_uart_first_char = true;
// Initialise the UART.
mp_uart_init(hci_uart_id, baudrate, pin_BT_UART_TX, pin_BT_UART_RX, &hci_rx_ringbuf);
mp_uart_init(hci_uart_id, baudrate, UART_DATA_BITS_8, UART_PARITY_NONE, UART_STOP_BITS_1, pin_BT_UART_TX, pin_BT_UART_RX, &hci_rx_ringbuf);
mp_uart_set_flow(hci_uart_id, pin_BT_UART_RTS, pin_BT_UART_CTS);
mp_uart_set_irq_callback(hci_uart_id, mp_bluetooth_hci_poll_now);
mp_uart_set_irq_callback(hci_uart_id, MP_UART_IRQ_RXIDLE, mp_bluetooth_hci_uart_irq_callback);
// Start the HCI polling to process any initial events/packets.
mp_bluetooth_hci_start_polling();