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;
|
uint32_t dev;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct usart_console *usart1 = NULL;
|
static struct usart_console *usart[4];
|
||||||
struct usart_console user_console;
|
struct usart_console user_console;
|
||||||
|
|
||||||
static void usart_isr(struct usart_console *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)
|
if (next != console->cur)
|
||||||
console->next = next;
|
console->next = next;
|
||||||
|
|
||||||
switch (console->recv_buf[idx]) {
|
if (console->recv_buf[idx] == '\003')
|
||||||
case '\003': scb_reset_system();
|
scb_reset_system();
|
||||||
case '\r': console->process_line();
|
|
||||||
default: break;
|
if (console->recv_buf[idx] == '\r' && console->process_line) {
|
||||||
|
console->process_line();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void usart1_isr(void)
|
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)
|
static char usart_getc(struct usart_console *console, int block)
|
||||||
|
@ -180,7 +186,7 @@ void console_init(void)
|
||||||
user_console.dev = USART1;
|
user_console.dev = USART1;
|
||||||
user_console.cur = 0;
|
user_console.cur = 0;
|
||||||
user_console.next = 0;
|
user_console.next = 0;
|
||||||
usart1 = &user_console;
|
usart[0] = &user_console;
|
||||||
usart_init(&user_console);
|
usart_init(&user_console);
|
||||||
|
|
||||||
stdin = fopencookie(&user_console, "r", console_in);
|
stdin = fopencookie(&user_console, "r", console_in);
|
||||||
|
|
Loading…
Add table
Reference in a new issue