stm32f*: rename STDIO buffer and enable getchar with UART0

dev/timer
Thomas Eichinger 9 years ago
parent c83e4cb361
commit d0b0af6d81

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

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

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

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

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

@ -51,7 +51,7 @@ caddr_t heap_top = (caddr_t)&_end + 4;
* @brief use mutex for waiting on incoming UART chars
*/
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;
#endif
@ -81,7 +81,7 @@ void _init(void)
{
#ifndef MODULE_UART0
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
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);
#else
r->_errno = ENODEV;
return -1;
char *res = (char*)buffer;
res[0] = (char)uart0_readc();
return 1;
#endif
}

@ -51,7 +51,7 @@ caddr_t heap_top = (caddr_t)&_end + 4;
* @brief use mutex for waiting on incoming UART chars
*/
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;
#endif
@ -81,7 +81,7 @@ void _init(void)
{
#ifndef MODULE_UART0
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
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);
#else
r->_errno = ENODEV;
return -1;
char *res = (char*)buffer;
res[0] = (char)uart0_readc();
return 1;
#endif
}

@ -52,7 +52,7 @@ caddr_t heap_top = (caddr_t)&_end + 4;
* @brief use mutex for waiting on incoming UART chars
*/
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;
#endif
@ -82,7 +82,7 @@ void _init(void)
{
#ifndef MODULE_UART0
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
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);
#else
r->_errno = ENODEV;
return -1;
char *res = (char*)buffer;
res[0] = (char)uart0_readc();
return 1;
#endif
}

@ -51,7 +51,7 @@ caddr_t heap_top = (caddr_t)&_end + 4;
* @brief use mutex for waiting on incoming UART chars
*/
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;
#endif
@ -81,7 +81,7 @@ void _init(void)
{
#ifndef MODULE_UART0
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
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);
}
return ringbuffer_get(&rx_buf, (char*)buffer, rx_buf.avail);
#else
char *res = (char*)buffer;
res[0] = (char)uart0_readc();
return 1;
#endif
}

Loading…
Cancel
Save