Skip to content

Commit 1b76f88

Browse files
committed
zephyr/zephyr_getchar: Add support for Ctrl+C handling.
Patch on top of upstream Zephyr console helpers.
1 parent aa7828f commit 1b76f88

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

zephyr/src/zephyr_getchar.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#include <misc/printk.h>
2121
#include "zephyr_getchar.h"
2222

23+
extern int mp_interrupt_char;
24+
void mp_keyboard_interrupt(void);
25+
2326
static struct nano_sem uart_sem;
2427
#define UART_BUFSIZE 256
2528
static uint8_t uart_ringbuf[UART_BUFSIZE];
@@ -32,8 +35,13 @@ static int console_irq_input_hook(struct device *dev, uint8_t ch)
3235
printk("UART buffer overflow - char dropped\n");
3336
return 1;
3437
}
35-
uart_ringbuf[i_put] = ch;
36-
i_put = i_next;
38+
if (ch == mp_interrupt_char) {
39+
mp_keyboard_interrupt();
40+
return 1;
41+
} else {
42+
uart_ringbuf[i_put] = ch;
43+
i_put = i_next;
44+
}
3745
//printk("%x\n", ch);
3846
nano_isr_sem_give(&uart_sem);
3947
return 1;

0 commit comments

Comments
 (0)