diff --git a/board/msba2/drivers/msba2-uart0.c b/board/msba2/drivers/msba2-uart0.c index fcd21fcd82..9198f50bb2 100644 --- a/board/msba2/drivers/msba2-uart0.c +++ b/board/msba2/drivers/msba2-uart0.c @@ -36,9 +36,7 @@ and the mailinglist (subscription via web site) #include "lpc23xx.h" #include "VIC.h" -#include -#include -#include "uart0.h" +#include /** * @file @@ -67,9 +65,6 @@ static volatile unsigned int fifo = 0; static volatile toprint* actual = NULL; -int uart0_handler_pid = 0; -extern ringbuffer uart0_ringbuffer; - static inline void enqueue(void) { queue_items++; queue_tail++; @@ -109,12 +104,6 @@ int uart_active(void){ return (running || fifo); } -static void notify_handler() { - msg m; - m.type = 0; - msg_send_int(&m, uart0_handler_pid); -} - void stdio_flush(void) { U0IER &= ~BIT1; // disable THRE interrupt @@ -140,15 +129,16 @@ void UART0_IRQHandler(void) case UIIR_CTI_INT: // Character Timeout Indicator case UIIR_RDA_INT: // Receive Data Available +#ifdef MODULE_UART0 if (uart0_handler_pid) { do { int c = U0RBR; - rb_add_element(&uart0_ringbuffer, c); + uart0_handle_incoming(c); } while (U0LSR & ULSR_RDR); - - notify_handler(); - break; + uart0_notify_thread(); } +#endif + break; default: U0LSR; U0RBR; diff --git a/board/msba2/drivers/msba2-uart0_thread.c b/board/msba2/drivers/msba2-uart0_thread.c deleted file mode 100644 index f343e32401..0000000000 --- a/board/msba2/drivers/msba2-uart0_thread.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include -#include - -#include - -#define UART0_BUFSIZE 32 - -extern ringbuffer uart0_ringbuffer; -extern int uart0_handler_pid; - -static char buffer[UART0_BUFSIZE]; - -static void uart0_loop() { - chardev_loop(&uart0_ringbuffer); -} - -void board_uart0_init() { - ringbuffer_init(&uart0_ringbuffer, buffer, UART0_BUFSIZE); - int pid = thread_create(KERNEL_CONF_STACKSIZE_MAIN, PRIORITY_MAIN-1, CREATE_STACKTEST, uart0_loop, "uart0"); - uart0_handler_pid = pid; - puts("uart0_init() [OK]"); -} - diff --git a/projects/test_shell/Jamfile b/projects/test_shell/Jamfile index b4dcc8f976..d4f1e9c00d 100644 --- a/projects/test_shell/Jamfile +++ b/projects/test_shell/Jamfile @@ -6,6 +6,6 @@ SubDir TOP projects test_shell ; -Module test_shell : test_shell.c : shell posix_io shell_auto_init ps board_uart ; +Module test_shell : test_shell.c : shell posix_io shell_auto_init ps uart0 ; UseModule test_shell ; diff --git a/sys/Jamfile b/sys/Jamfile index 72a7429131..0ae65f81c8 100644 --- a/sys/Jamfile +++ b/sys/Jamfile @@ -33,6 +33,7 @@ Module posix_io : posix_io.c ; Module auto_init : auto_init.c ; Module chardev_thread : chardev_thread.c : ringbuffer ; +Module uart0 : uart0.c : ringbuffer chardev_thread ; SubInclude TOP sys net ; SubInclude TOP sys lib ; diff --git a/sys/include/board_uart0.h b/sys/include/board_uart0.h index 74a5295317..2819ef61b0 100644 --- a/sys/include/board_uart0.h +++ b/sys/include/board_uart0.h @@ -4,5 +4,7 @@ extern int uart0_handler_pid; void board_uart0_init(); +void uart0_handle_incoming(int c); +void uart0_notify_thread(); #endif /* __BOARD_UART0_H */