From: arighi Date: Tue, 27 Apr 2010 16:16:02 +0000 (+0000) Subject: LPC2: add a UART driver testcase to the example. X-Git-Tag: 2.5.0~356 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=5036230969d485931b203e018b9f6cf0ee45996c;p=bertos.git LPC2: add a UART driver testcase to the example. 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 --- diff --git a/examples/lpc2378/cfg/cfg_kfile.h b/examples/lpc2378/cfg/cfg_kfile.h index 0253f78c..f795af08 100644 --- a/examples/lpc2378/cfg/cfg_kfile.h +++ b/examples/lpc2378/cfg/cfg_kfile.h @@ -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 */ diff --git a/examples/lpc2378/lpc2378.mk b/examples/lpc2378/lpc2378.mk index 59ec1cb6..45a25e9c 100644 --- a/examples/lpc2378/lpc2378.mk +++ b/examples/lpc2378/lpc2378.mk @@ -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 \ diff --git a/examples/lpc2378/main.c b/examples/lpc2378/main.c index 213e9611..81be7c5b 100644 --- a/examples/lpc2378/main.c +++ b/examples/lpc2378/main.c @@ -2,29 +2,55 @@ #include #include #include +#include #include +#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; } -