stm32f*: rename STDIO buffer and enable getchar with UART0

This commit is contained in:
Thomas Eichinger 2014-09-25 17:39:55 +02:00
parent c83e4cb361
commit d0b0af6d81
9 changed files with 26 additions and 19 deletions

View File

@ -39,7 +39,7 @@
*/ */
#define STDIO UART_0 #define STDIO UART_0
#define STDIO_BAUDRATE (115200U) #define STDIO_BAUDRATE (115200U)
#define STDIO_BUFSIZE (64U) #define STDIO_RX_BUFSIZE (64U)
/** @} */ /** @} */
/** /**

View File

@ -40,7 +40,7 @@
*/ */
#define STDIO UART_0 #define STDIO UART_0
#define STDIO_BAUDRATE (115200U) #define STDIO_BAUDRATE (115200U)
#define STDIO_BUFSIZE (64U) #define STDIO_RX_BUFSIZE (64U)
/** @} */ /** @} */
/** /**

View File

@ -39,7 +39,7 @@
*/ */
#define STDIO UART_0 #define STDIO UART_0
#define STDIO_BAUDRATE (115200U) #define STDIO_BAUDRATE (115200U)
#define STDIO_BUFSIZE (64U) #define STDIO_RX_BUFSIZE (64U)
/** /**
* @name LED pin definitions * @name LED pin definitions

View File

@ -39,7 +39,7 @@
*/ */
#define STDIO UART_0 #define STDIO UART_0
#define STDIO_BAUDRATE (115200U) #define STDIO_BAUDRATE (115200U)
#define STDIO_BUFSIZE (64U) #define STDIO_RX_BUFSIZE (64U)
/** @} */ /** @} */
/** /**

View File

@ -40,7 +40,7 @@
*/ */
#define STDIO UART_0 #define STDIO UART_0
#define STDIO_BAUDRATE (115200U) #define STDIO_BAUDRATE (115200U)
#define STDIO_BUFSIZE (64U) #define STDIO_RX_BUFSIZE (64U)
/** @} */ /** @} */
/** /**

View File

@ -51,7 +51,7 @@ caddr_t heap_top = (caddr_t)&_end + 4;
* @brief use mutex for waiting on incoming UART chars * @brief use mutex for waiting on incoming UART chars
*/ */
static mutex_t uart_rx_mutex; static mutex_t uart_rx_mutex;
static char rx_buf_mem[STDIO_BUFSIZE]; static char rx_buf_mem[STDIO_RX_BUFSIZE];
static ringbuffer_t rx_buf; static ringbuffer_t rx_buf;
#endif #endif
@ -81,7 +81,7 @@ void _init(void)
{ {
#ifndef MODULE_UART0 #ifndef MODULE_UART0
mutex_init(&uart_rx_mutex); mutex_init(&uart_rx_mutex);
ringbuffer_init(&rx_buf, rx_buf_mem, STDIO_BUFSIZE); ringbuffer_init(&rx_buf, rx_buf_mem, STDIO_RX_BUFSIZE);
#endif #endif
uart_init(STDIO, STDIO_BAUDRATE, rx_cb, 0, 0); uart_init(STDIO, STDIO_BAUDRATE, rx_cb, 0, 0);
} }
@ -195,8 +195,9 @@ int _read_r(struct _reent *r, int fd, void *buffer, unsigned int count)
} }
return ringbuffer_get(&rx_buf, (char*)buffer, rx_buf.avail); return ringbuffer_get(&rx_buf, (char*)buffer, rx_buf.avail);
#else #else
r->_errno = ENODEV; char *res = (char*)buffer;
return -1; res[0] = (char)uart0_readc();
return 1;
#endif #endif
} }

View File

@ -51,7 +51,7 @@ caddr_t heap_top = (caddr_t)&_end + 4;
* @brief use mutex for waiting on incoming UART chars * @brief use mutex for waiting on incoming UART chars
*/ */
static mutex_t uart_rx_mutex; static mutex_t uart_rx_mutex;
static char rx_buf_mem[STDIO_BUFSIZE]; static char rx_buf_mem[STDIO_RX_BUFSIZE];
static ringbuffer_t rx_buf; static ringbuffer_t rx_buf;
#endif #endif
@ -81,7 +81,7 @@ void _init(void)
{ {
#ifndef MODULE_UART0 #ifndef MODULE_UART0
mutex_init(&uart_rx_mutex); mutex_init(&uart_rx_mutex);
ringbuffer_init(&rx_buf, rx_buf_mem, STDIO_BUFSIZE); ringbuffer_init(&rx_buf, rx_buf_mem, STDIO_RX_BUFSIZE);
#endif #endif
uart_init(STDIO, STDIO_BAUDRATE, rx_cb, 0, 0); uart_init(STDIO, STDIO_BAUDRATE, rx_cb, 0, 0);
} }
@ -195,8 +195,9 @@ int _read_r(struct _reent *r, int fd, void *buffer, unsigned int count)
} }
return ringbuffer_get(&rx_buf, (char*)buffer, rx_buf.avail); return ringbuffer_get(&rx_buf, (char*)buffer, rx_buf.avail);
#else #else
r->_errno = ENODEV; char *res = (char*)buffer;
return -1; res[0] = (char)uart0_readc();
return 1;
#endif #endif
} }

View File

@ -52,7 +52,7 @@ caddr_t heap_top = (caddr_t)&_end + 4;
* @brief use mutex for waiting on incoming UART chars * @brief use mutex for waiting on incoming UART chars
*/ */
static mutex_t uart_rx_mutex; static mutex_t uart_rx_mutex;
static char rx_buf_mem[STDIO_BUFSIZE]; static char rx_buf_mem[STDIO_RX_BUFSIZE];
static ringbuffer_t rx_buf; static ringbuffer_t rx_buf;
#endif #endif
@ -82,7 +82,7 @@ void _init(void)
{ {
#ifndef MODULE_UART0 #ifndef MODULE_UART0
mutex_init(&uart_rx_mutex); mutex_init(&uart_rx_mutex);
ringbuffer_init(&rx_buf, rx_buf_mem, STDIO_BUFSIZE); ringbuffer_init(&rx_buf, rx_buf_mem, STDIO_RX_BUFSIZE);
#endif #endif
uart_init(STDIO, STDIO_BAUDRATE, rx_cb, 0, 0);} uart_init(STDIO, STDIO_BAUDRATE, rx_cb, 0, 0);}
@ -195,8 +195,9 @@ int _read_r(struct _reent *r, int fd, void *buffer, unsigned int count)
} }
return ringbuffer_get(&rx_buf, (char*)buffer, rx_buf.avail); return ringbuffer_get(&rx_buf, (char*)buffer, rx_buf.avail);
#else #else
r->_errno = ENODEV; char *res = (char*)buffer;
return -1; res[0] = (char)uart0_readc();
return 1;
#endif #endif
} }

View File

@ -51,7 +51,7 @@ caddr_t heap_top = (caddr_t)&_end + 4;
* @brief use mutex for waiting on incoming UART chars * @brief use mutex for waiting on incoming UART chars
*/ */
static mutex_t uart_rx_mutex; static mutex_t uart_rx_mutex;
static char rx_buf_mem[STDIO_BUFSIZE]; static char rx_buf_mem[STDIO_RX_BUFSIZE];
static ringbuffer_t rx_buf; static ringbuffer_t rx_buf;
#endif #endif
@ -81,7 +81,7 @@ void _init(void)
{ {
#ifndef MODULE_UART0 #ifndef MODULE_UART0
mutex_init(&uart_rx_mutex); mutex_init(&uart_rx_mutex);
ringbuffer_init(&rx_buf, rx_buf_mem, STDIO_BUFSIZE); ringbuffer_init(&rx_buf, rx_buf_mem, STDIO_RX_BUFSIZE);
#endif #endif
uart_init(STDIO, STDIO_BAUDRATE, rx_cb, 0, 0); uart_init(STDIO, STDIO_BAUDRATE, rx_cb, 0, 0);
} }
@ -194,6 +194,10 @@ int _read_r(struct _reent *r, int fd, void *buffer, unsigned int count)
mutex_lock(&uart_rx_mutex); mutex_lock(&uart_rx_mutex);
} }
return ringbuffer_get(&rx_buf, (char*)buffer, rx_buf.avail); return ringbuffer_get(&rx_buf, (char*)buffer, rx_buf.avail);
#else
char *res = (char*)buffer;
res[0] = (char)uart0_readc();
return 1;
#endif #endif
} }