Merge pull request #4380 from Guozhanxin/raspberry-pico

[bsp][raspberry-pico] Fixed failure to start without connecting to UART
This commit is contained in:
Bernard Xiong 2021-02-24 11:22:58 +08:00 committed by GitHub
commit 06e01da1d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 12 deletions

View File

@ -60,6 +60,23 @@ static rt_err_t pico_uart_configure(struct rt_serial_device *serial, struct seri
static rt_err_t pico_uart_control(struct rt_serial_device *serial, int cmd, void *arg)
{
// Select correct interrupt for the UART we are using
int UART_IRQ = UART_ID == uart0 ? UART0_IRQ : UART1_IRQ;
switch (cmd)
{
/* enable interrupt */
case RT_DEVICE_CTRL_SET_INT:
// Set up a RX interrupt
// We need to set up the handler first
// And set up and enable the interrupt handlers
irq_set_exclusive_handler(UART_IRQ, pico_uart_isr);
irq_set_enabled(UART_IRQ, true);
// Now enable the UART to send interrupts - RX only
uart_set_irq_enables(UART_ID, true, false);
break;
}
return RT_EOK;
}
@ -125,18 +142,6 @@ int rt_hw_uart_init(void)
// Turn off FIFO's - we want to do this character by character
uart_set_fifo_enabled(UART_ID, false);
// Set up a RX interrupt
// We need to set up the handler first
// Select correct interrupt for the UART we are using
int UART_IRQ = UART_ID == uart0 ? UART0_IRQ : UART1_IRQ;
// And set up and enable the interrupt handlers
irq_set_exclusive_handler(UART_IRQ, pico_uart_isr);
irq_set_enabled(UART_IRQ, true);
// Now enable the UART to send interrupts - RX only
uart_set_irq_enables(UART_ID, true, false);
uart0_dev.parent.ops = &_uart_ops;
uart0_dev.parent.config = config;