Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: handlers.cpp
- Revision:
- 26:5c264e20402f
- Parent:
- 25:57de395d89aa
- Child:
- 27:231333972023
--- a/handlers.cpp	Tue Jul 23 06:03:27 2013 +0000
+++ b/handlers.cpp	Tue Jul 23 17:55:40 2013 +0000
@@ -12,6 +12,24 @@
 Function description:
 This function checks data in the line buffer. If it's good then write the converted value into address adam_amp 
 otherwise it returns error code
+
+
+Function: static char char2hex_4bits(char c)
+Function description:
+This function converts a character input into 4 bit hex. For example, '1'->1, '9'->9, 'A'->10, 'a'->10
+
+Function: static char char2hex_3bits(char c)
+Function description:
+This function converts a character input into 3 bit hex. For example, '8'->0, '7'->7,'f'->7
+
+Function: int parse_spi_raw(char* buf, int length, char* cha1_pha, char* cha2_pha, char* cha1_amp, char* cha2_amp)
+Function description:
+This function converts characters in buf and put the data in cha1_pha, cha2_pha, cha1_amp, cha2_amp. 
+If length is incorrect, return the error code.
+
+Function: char hex2char(char hex)
+Function description:
+This function converts a hex number to character. For example, 1->'1', 10->'A'
 *********************************************/
 
 #include "parameters.h"
@@ -83,23 +101,6 @@
         return PARSE_EMPTY;
     if(line_buf[3] == LINEBUF_TOOLONG)
         return PARSE_LONG;
-
-    /*if(line_buf[0] == '0') //Input value is 0, or 0.0, or 0.5
-    {
-        if((line_buf[1] == 255 && line_buf[2] == 255) ||(line_buf[1] == '.' && line_buf[2] == '0'))  //Input is 0 or 0.0
-        {
-            *adam_amp = 0;
-            return PARSE_OK;
-        }
-        else if(line_buf[1] == '.' && line_buf[2] == '5')    //Input is 0.5
-        {
-            *adam_amp = 1;
-            return PARSE_OK;
-        }
-        else
-            return PARSE_ERR;
-    } 
-    */ 
     //Single digit input. single digit is 0,1,2,3,4,5,6,7
     if(line_buf[0]>='0' && line_buf[0]<='7' && line_buf[1] == 255 && line_buf[2] == 255)
     {
@@ -141,7 +142,7 @@
         return c-'0';
     else if(c == '8')
         return 0;
-    else if(c == 9)
+    else if(c == '9')
         return 1;
     else if(c >= 'a' && c <= 'f')
         return c-'a'+2;