mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 01:40:14 +01:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user