Merge from kseries.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Sun, 28 Jan 2007 09:18:06 +0000 (09:18 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Sun, 28 Jan 2007 09:18:06 +0000 (09:18 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@740 38d2e660-2303-0410-9eaa-f027e97ec537

drv/kdebug.c

index 04f6abc720ea3ad49a17be747517b4e2e32a6fed..61afa68b2b8b211b71054b0e6b67c5b6af6d07fc 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.30  2007/01/28 09:18:06  batt
+ *#* Merge from project_ks.
+ *#*
  *#* Revision 1.29  2006/11/23 13:19:39  batt
  *#* Add BitBanged serial debug console.
  *#*
                #define KDBG_RESTORE_IRQ(old)  do { IRQ_RESTORE((old)); } while(0)
                typedef cpuflags_t kdbg_irqsave_t;
 
-               #define KDBG_DELAY (((CLOCK_FREQ + CONFIG_KDEBUG_BAUDRATE / 2) / CONFIG_KDEBUG_BAUDRATE) + 12) / 24
+               #define KDBG_DELAY (((CLOCK_FREQ + CONFIG_KDEBUG_BAUDRATE / 2) / CONFIG_KDEBUG_BAUDRATE) + 7) / 14
 
                static void _kdebug_bitbang_delay(void)
                {
                                NOP;
                                NOP;
                                NOP;
-                               NOP;
-                               NOP;
-                               NOP;
-                               NOP;
-                               NOP;
                        }
                }
        #else
        /**
         * Putchar for BITBANG serial debug console.
         * Sometimes, we can't permit to use a whole serial for debugging purpose.
-        * Since debug console is in output only it is usefull to a single generic I/O pin for debug.
+        * Since debug console is in output only it is usefull to use a single generic I/O pin for debug.
         * This is achieved by this simple function, that shift out the data like a UART, but
         * in software :)
         * The only requirement is that SER_BITBANG_* macros will be defined somewhere (usually hw_ser.h)
        static void _kdebug_bitbang_putchar(char c)
        {
                int i;
+               uint16_t data = c;
 
-               /* Start bit */
-               SER_BITBANG_LOW;
-               _kdebug_bitbang_delay();
+               /* Add stop bit */
+               data |= 0x0100;
+
+               /* Add start bit*/
+               data <<= 1;
 
                /* Shift out data */
-               for (i = 0; i < 8; i++)
+               uint16_t shift = 1;
+               for (i = 0; i < 10; i++)
                {
-                       if (c & BV(i))
+                       if (data & shift)
                                SER_BITBANG_HIGH;
                        else
                                SER_BITBANG_LOW;
                        _kdebug_bitbang_delay();
+                       shift <<= 1;
                }
-
-               /* Stop bit */
-               SER_BITBANG_HIGH;
-               _kdebug_bitbang_delay();
        }
 #endif