1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-27 07:21:18 +01:00

Merge pull request #3415 from kaspar030/fix_uart0

sys: fix uart0
This commit is contained in:
BytesGalore 2015-07-15 15:25:45 +02:00
commit a4871c412f
3 changed files with 24 additions and 3 deletions

View File

@ -244,10 +244,12 @@ void auto_init(void)
DEBUG("Auto init vtimer module.\n");
vtimer_init();
#endif
#ifndef MODULE_UART_STDIO
#ifdef MODULE_UART0
DEBUG("Auto init uart0 module.\n");
board_uart0_init();
#endif
#endif
#ifdef MODULE_RTC
DEBUG("Auto init rtc module.\n");
rtc_init();

View File

@ -47,6 +47,9 @@ static int _posix_fileop_data(kernel_pid_t pid, int op, char *buffer, int nbytes
int posix_open(int pid, int flags)
{
if (pid == KERNEL_PID_UNDEF) {
return -1;
}
return _posix_fileop((kernel_pid_t) pid, OPEN, flags);
}

View File

@ -21,6 +21,24 @@
#include <stdio.h>
#include "kernel_types.h"
#include "board_uart0.h"
kernel_pid_t uart0_handler_pid = KERNEL_PID_UNDEF;
#ifdef MODULE_UART_STDIO
#include "uart_stdio.h"
void board_uart0_init(void){}
int uart0_readc(void)
{
char c = 0;
uart_stdio_read(&c, 1);
return c;
}
#else
#include "cpu_conf.h"
#include "chardev_thread.h"
#include "ringbuffer.h"
@ -29,8 +47,6 @@
#include "posix_io.h"
#include "irq.h"
#include "board_uart0.h"
#ifndef UART0_BUFSIZE
#define UART0_BUFSIZE (128)
#endif
@ -39,7 +55,6 @@
#define UART0_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
ringbuffer_t uart0_ringbuffer;
kernel_pid_t uart0_handler_pid = KERNEL_PID_UNDEF;
static char buffer[UART0_BUFSIZE];
@ -80,6 +95,7 @@ int uart0_readc(void)
posix_read(uart0_handler_pid, &c, 1);
return c;
}
#endif
int uart0_putc(int c)
{