summaryrefslogtreecommitdiff
path: root/nuttx/libc
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-05-26 09:28:57 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-05-26 09:28:57 -0600
commit5e23e42a0d5f7256bb284bdd8ffbe7b52eef0cef (patch)
treea3c05dfc1cb9ece8d2559fdef6c029380f851153 /nuttx/libc
parentf7102cb478678502cd7b6a3ff60e27025f52281e (diff)
downloadpx4-nuttx-5e23e42a0d5f7256bb284bdd8ffbe7b52eef0cef.tar.gz
px4-nuttx-5e23e42a0d5f7256bb284bdd8ffbe7b52eef0cef.tar.bz2
px4-nuttx-5e23e42a0d5f7256bb284bdd8ffbe7b52eef0cef.zip
Extentions SCLD test; SCLD CODEC and LCD1602 driver bug fixes
Diffstat (limited to 'nuttx/libc')
-rw-r--r--nuttx/libc/misc/lib_slcddecode.c36
-rw-r--r--nuttx/libc/misc/lib_slcdencode.c2
2 files changed, 36 insertions, 2 deletions
diff --git a/nuttx/libc/misc/lib_slcddecode.c b/nuttx/libc/misc/lib_slcddecode.c
index 97fa951c8..79c549b39 100644
--- a/nuttx/libc/misc/lib_slcddecode.c
+++ b/nuttx/libc/misc/lib_slcddecode.c
@@ -52,6 +52,21 @@
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
+/* Configuration ************************************************************/
+/* Define CONFIG_DEBUG_LCD to enable detailed LCD debug output. Verbose
+ * debug must also be enabled.
+ */
+
+#ifndef CONFIG_DEBUG
+# undef CONFIG_DEBUG_VERBOSE
+# undef CONFIG_DEBUG_LCD
+#endif
+
+#ifndef CONFIG_DEBUG_VERBOSE
+# undef CONFIG_DEBUG_LCD
+#endif
+
+/* Indices, counts, helper macros ******************************************/
#define NDX_ESC 0
#define NDX_BRACKET 1
@@ -74,6 +89,16 @@
#define IS_CODE(a) (((a) >= CODE_MIN) && ((a) <= CODE_MAX))
#define CODE_RETURN(a) (enum slcdcode_e)((a) - 'A')
+/* Debug ********************************************************************/
+
+#ifdef CONFIG_DEBUG_LCD
+# define lcddbg dbg
+# define lcdvdbg vdbg
+#else
+# define lcddbg(x...)
+# define lcdvdbg(x...)
+#endif
+
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -239,6 +264,7 @@ enum slcdret_e slcd_decode(FAR struct lib_instream_s *stream,
* return the following characters later.
*/
+ lcddbg("Parsing failed: ESC followed by %02x\n", ch);
return slcd_reget(state, pch, parg);
}
@@ -269,6 +295,8 @@ enum slcdret_e slcd_decode(FAR struct lib_instream_s *stream,
if (code < (int)FIRST_SLCDCODE || code > (int)LAST_SLCDCODE)
{
+ lcddbg("Parsing failed: ESC-L followed by %02x\n", ch);
+
/* Not a special command code.. put the character in the reget
* buffer.
*/
@@ -310,6 +338,9 @@ enum slcdret_e slcd_decode(FAR struct lib_instream_s *stream,
* following characters later.
*/
+ lcddbg("Parsing failed: ESC-L-%c followed by %02x\n",
+ state->buf[NDX_COUNTH], ch);
+
return slcd_reget(state, pch, parg);
}
@@ -342,7 +373,7 @@ enum slcdret_e slcd_decode(FAR struct lib_instream_s *stream,
*/
code = CODE_RETURN(ch);
- count = slcd_nibble(state->buf[NDX_COUNTH]) << 4;
+ count = slcd_nibble(state->buf[NDX_COUNTH]) << 4 |
slcd_nibble(state->buf[NDX_COUNTL]);
/* Verify the special CLCD action code */
@@ -353,6 +384,9 @@ enum slcdret_e slcd_decode(FAR struct lib_instream_s *stream,
* of the characters later.
*/
+ lcddbg("Parsing failed: ESC-L-%c-%c followed by %02x, count=%d\n",
+ state->buf[NDX_COUNTH], state->buf[NDX_COUNTL], ch, count);
+
return slcd_reget(state, pch, parg);
}
}
diff --git a/nuttx/libc/misc/lib_slcdencode.c b/nuttx/libc/misc/lib_slcdencode.c
index 148cb3a99..12454ca8e 100644
--- a/nuttx/libc/misc/lib_slcdencode.c
+++ b/nuttx/libc/misc/lib_slcdencode.c
@@ -70,7 +70,7 @@ static uint8_t slcd_nibble(uint8_t binary)
{
binary &= 0x0f;
- if (binary > 9)
+ if (binary <= 9)
{
return '0' + binary;
}