From 421a05575c2b56138947cb0e38187f6c6f3bf415 Mon Sep 17 00:00:00 2001
From: Per <Per Lindgren>
Date: Fri, 23 Feb 2018 10:52:06 +0100
Subject: [PATCH] loopback update

---
 examples/loopback.rs | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/examples/loopback.rs b/examples/loopback.rs
index 4a1e705..48872ee 100644
--- a/examples/loopback.rs
+++ b/examples/loopback.rs
@@ -50,6 +50,10 @@ app! {
             path: error_usart_overflow,
             priority: 1,
         },
+        EXTI4: {
+            path: rxne_not_set,
+            priority: 1,
+        },
     }
 }
 
@@ -104,16 +108,19 @@ fn usart2_handler(_t: &mut Threshold, r: USART2::Resources) {
                 r.USART2.dr.read(); // clear the error by reading the data register
             }
         }
-    }
-
-    match r.SEND.dequeue() {
-        Some(b) => {
-            // we (still) have something in the queue to send
-            let _ = serial.write(b);
-        }
-        _ => {
-            // the que was empty so the last item was already sent
-            serial.unlisten(Event::Txe);
+    } else {
+        // rxne not set
+        rtfm::set_pending(f4::stm32f40x::Interrupt::EXTI4);
+
+        match r.SEND.dequeue() {
+            Some(b) => {
+                // we (still) have something in the queue to send
+                let _ = serial.write(b);
+            }
+            _ => {
+                // the que was empty so the last item was already sent
+                serial.unlisten(Event::Txe);
+            }
         }
     }
 }
@@ -161,6 +168,10 @@ fn error_usart_overflow() {
     ipln!("error_usart_overflow");
 }
 
+fn rxne_not_set() {
+    ip!("-");
+}
+
 #[derive(Debug)]
 enum Command {
     Start,
-- 
GitLab