Treehouse Mbed Team / Mbed 2 deprecated APS_DCM1SL2

Dependencies:   mbed

Revision:
1:9f8583ba2431
Parent:
0:44a3005d4f20
Child:
2:46faae84b8b0
--- a/src/serial.cpp	Sat Nov 24 18:22:31 2018 +0000
+++ b/src/serial.cpp	Sun Nov 25 00:36:35 2018 +0000
@@ -3,7 +3,7 @@
 #include "stdio.h"
 #include "string.h"
 #include "globals.h"
-#include "dio.h"
+#include "all_io.h"
 
 /************* GLOBAL VARIABLES *****************************/
 struct serialStatusBits serialStatus;
@@ -37,7 +37,7 @@
    // check if the USART1 receive interrupt flag was set
    while (pc.readable())
    {
-      led_usb = 0;
+      //led_usb = 0;
       rxbuf[bufloc] = pc.getc();
 
       if (rxbuf[bufloc] == CR)        // check for end of command
@@ -88,7 +88,7 @@
          rxbuf[0] = 0;
       }
       
-      led_usb = 1;
+      //led_usb = 1;
    }
 }
 
@@ -128,12 +128,28 @@
      }
 }
 
-// send buffter to the serial port
+// send buffer to the serial port
 void sendSerial(char *buf)
 {
-    led_usb = 0;
+    //led_usb = 0;
     pc.printf(buf);
-    led_usb = 1;
+    //led_usb = 1;
 }
 
+/************************************************************
+* Routine: showRangeError
+* Input:   error -- 0 = in range, 1 = out of range
+* Output:  none
+* Description:
+* Sends a floating point number (value) over the serial port
+* if it is being retrieved (GET)
+*
+**************************************************************/
+void showRangeError(int intValue, int iBadValue, float fBadValue)
+{
+   if (intValue) sprintf(strbuf, "Out of Range: %d",    iBadValue);
+   else          sprintf(strbuf, "Out of Range: %0.3f", fBadValue);
+
+   sendSerial(strbuf);
+}
  
\ No newline at end of file