LPC2: add a UART driver testcase to the example.
authorarighi <arighi@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 27 Apr 2010 16:16:02 +0000 (16:16 +0000)
committerarighi <arighi@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 27 Apr 2010 16:16:02 +0000 (16:16 +0000)
Start a simple "echo" terminal on UART1 at the end of the startup tests.

git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3552 38d2e660-2303-0410-9eaa-f027e97ec537

examples/lpc2378/cfg/cfg_kfile.h
examples/lpc2378/lpc2378.mk
examples/lpc2378/main.c

index 0253f78c187ab30d5084540333634a3e82451d82..f795af084578bc3ef6bbc11e2a48dc46207d3f94 100644 (file)
@@ -57,6 +57,6 @@
  * Enable the gets function with echo.
  * $WIZ$ type = "boolean"
  */
-#define CONFIG_KFILE_GETS      0
+#define CONFIG_KFILE_GETS      1
 
 #endif /* CFG_KFILE_H */
index 59ec1cb647b7c490a49fe6c3c7a1b98a68ae1d01..45a25e9c620c7316ded0bca8b526a3c07f3c4a0f 100644 (file)
@@ -17,9 +17,12 @@ lpc2378_USER_CSRC = \
        examples/lpc2378/main.c \
        bertos/drv/timer.c \
        bertos/drv/timer_test.c \
+       bertos/drv/ser.c \
+       bertos/cpu/arm/drv/ser_lpc2.c \
        bertos/cpu/arm/drv/vic_lpc2.c \
        bertos/cpu/arm/drv/timer_lpc2.c \
        bertos/mware/event.c \
+       bertos/kern/kfile.c \
        bertos/kern/proc.c \
        bertos/kern/proc_test.c \
        bertos/kern/monitor.c \
index 213e96117f2c6c3294002cacc539b1781f126419..81be7c5b2fdd14aab4b561c6df9c5d242dabc6a1 100644 (file)
@@ -2,29 +2,55 @@
 #include <cpu/irq.h>
 #include <cfg/debug.h>
 #include <drv/timer.h>
+#include <drv/ser.h>
 #include <io/lpc23xx.h>
 
+#define PRIO_HIGH      1
+#define PRIO_LOW       0
+
 #define STATUS_LED (1<<19)
 #define LED_ON()  do { IOCLR1 =  STATUS_LED; } while (0)
 #define LED_OFF() do { IOSET1 =  STATUS_LED; } while (0)
 
+static Serial ser_port;
+
 static void init(void)
 {
        IRQ_ENABLE;
        kdbg_init();
        timer_init();
        proc_init();
+
        timer_delay(3000);
        kprintf("NXP LPC2378 BeRTOS port test\n");
        timer_delay(3000);
        /* Turn off boot led */
-       IODIR0 = (1<<21);       
-       IOCLR0 = (1<<21);       
+       IODIR0 = (1<<21);
+       IOCLR0 = (1<<21);
        /* Init status led */
        IODIR1 |= STATUS_LED;
        LED_OFF();
 }
 
+static void NORETURN ser_prompt(void)
+{
+       char buf[32];
+       int i;
+
+       ser_init(&ser_port, SER_UART1);
+       ser_setbaudrate(&ser_port, 115200);
+
+       /* BeRTOS "echo" terminal */
+       kfile_printf(&ser_port.fd, "\n\rBeRTOS echo terminal\n\r");
+       proc_setPri(proc_current(), PRIO_HIGH);
+       for (i = 0; ; i++)
+       {
+               kfile_printf(&ser_port.fd, "\n\r[%03d] BeRTOS:~$ ", i);
+               kfile_gets_echo(&ser_port.fd, buf, sizeof(buf), true);
+               kfile_printf(&ser_port.fd, "%s", buf);
+       }
+}
+
 static void NORETURN bertos_up(void)
 {
        char spinner[] = {'/', '-', '\\', '|'};
@@ -46,7 +72,7 @@ static void NORETURN status(void)
        {
                LED_ON();
                timer_delay(250);
-               
+
                LED_OFF();
                timer_delay(250);
        }
@@ -58,6 +84,7 @@ int main(void)
        init();
        proc_testRun();
        proc_new(bertos_up, NULL, KERN_MINSTACKSIZE * 3, NULL);
+       proc_new(ser_prompt, NULL, KERN_MINSTACKSIZE * 3, NULL);
        proc_new(status, NULL, 0, NULL);
        while (1)
        {
@@ -65,4 +92,3 @@ int main(void)
 
        return 0;
 }
-