From 513e5372155bed86285aa38ce828390c65d52761 Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Mon, 23 Apr 2018 17:06:40 +1000
Subject: [PATCH] stm32/uart: Allow ctrl-C to issue keyboard intr when REPL is
 over UART.

---
 ports/stm32/uart.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/ports/stm32/uart.c b/ports/stm32/uart.c
index a8b5d7dca..0621dc725 100644
--- a/ports/stm32/uart.c
+++ b/ports/stm32/uart.c
@@ -32,8 +32,10 @@
 #include "py/stream.h"
 #include "py/mperrno.h"
 #include "py/mphal.h"
+#include "lib/utils/interrupt_char.h"
 #include "uart.h"
 #include "irq.h"
+#include "pendsv.h"
 
 /// \moduleref pyb
 /// \class UART - duplex serial communication bus
@@ -506,6 +508,11 @@ void uart_irq_handler(mp_uint_t uart_id) {
                 int data = self->uart.Instance->DR; // clears UART_FLAG_RXNE
                 #endif
                 data &= self->char_mask;
+                // Handle interrupt coming in on a UART REPL
+                if (data == mp_interrupt_char && self == MP_STATE_PORT(pyb_stdio_uart)) {
+                    pendsv_kbd_intr();
+                    return;
+                }
                 if (self->char_width == CHAR_WIDTH_9BIT) {
                     ((uint16_t*)self->read_buf)[self->read_buf_head] = data;
                 } else {
-- 
GitLab