stm32f0: usart: set up array of consoles
This commit is contained in:
parent
d37f64dccb
commit
8af9ba9fa9
1 changed files with 13 additions and 7 deletions
|
@ -23,7 +23,7 @@ struct usart_console {
|
|||
uint32_t dev;
|
||||
};
|
||||
|
||||
struct usart_console *usart1 = NULL;
|
||||
static struct usart_console *usart[4];
|
||||
struct usart_console user_console;
|
||||
|
||||
static void usart_isr(struct usart_console *console)
|
||||
|
@ -42,17 +42,23 @@ static void usart_isr(struct usart_console *console)
|
|||
if (next != console->cur)
|
||||
console->next = next;
|
||||
|
||||
switch (console->recv_buf[idx]) {
|
||||
case '\003': scb_reset_system();
|
||||
case '\r': console->process_line();
|
||||
default: break;
|
||||
if (console->recv_buf[idx] == '\003')
|
||||
scb_reset_system();
|
||||
|
||||
if (console->recv_buf[idx] == '\r' && console->process_line) {
|
||||
console->process_line();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void usart1_isr(void)
|
||||
{
|
||||
usart_isr(usart1);
|
||||
usart_isr(usart[0]);
|
||||
}
|
||||
|
||||
void usart2_isr(void)
|
||||
{
|
||||
usart_isr(usart[1]);
|
||||
}
|
||||
|
||||
static char usart_getc(struct usart_console *console, int block)
|
||||
|
@ -180,7 +186,7 @@ void console_init(void)
|
|||
user_console.dev = USART1;
|
||||
user_console.cur = 0;
|
||||
user_console.next = 0;
|
||||
usart1 = &user_console;
|
||||
usart[0] = &user_console;
|
||||
usart_init(&user_console);
|
||||
|
||||
stdin = fopencookie(&user_console, "r", console_in);
|
||||
|
|
Loading…
Add table
Reference in a new issue