Lab2_web / Mbed 2 deprecated webserverBlinky

Dependencies:   mbed

Fork of webserverBlinky by RealTimeCompLab2

Revision:
21:66459cb32ce0
Parent:
20:5db9b77b38a6
Child:
22:00df34cd4d7e
--- a/main.cpp	Mon Jan 02 17:32:47 2017 +0000
+++ b/main.cpp	Mon Jan 02 17:38:08 2017 +0000
@@ -71,18 +71,15 @@
 
 int pc_readable() // check if buffer has data
 {
-    __disable_irq(); // critical section start
-        int readable = (ppp.rx.head==ppp.rx.tail) ? 0 : 1 ; 
-    __enable_irq(); // critical section end
-    return readable;
+    return (ppp.rx.head==ppp.rx.tail) ? 0 : 1 ; 
 }
 
 int pc_getBuf() // get one character from the buffer
 {
-    if (pc_readable) {
+    if (ppp.rx.head!=ppp.rx.tail) {
         int x = ppp.rx.buf[ ppp.rx.tail ];
         __disable_irq(); // critical section start
-            ppp.rx.tail=(ppp.rx.tail+1)&(BUFLEN-1);
+            ppp.rx.tail=(ppp.rx.tail+1)&(BUFLEN-1); // atomic operation
         __enable_irq(); // critical section end
         return x;
     } else return -1;