Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
stm32f*: rename STDIO buffer and enable getchar with UART0
  • Loading branch information
thomaseichinger committed Sep 26, 2014
1 parent c83e4cb commit d0b0af6
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion boards/iot-lab_M3/include/board.h
Expand Up @@ -39,7 +39,7 @@
*/
#define STDIO UART_0
#define STDIO_BAUDRATE (115200U)
#define STDIO_BUFSIZE (64U)
#define STDIO_RX_BUFSIZE (64U)
/** @} */

/**
Expand Down
2 changes: 1 addition & 1 deletion boards/msbiot/include/board.h
Expand Up @@ -40,7 +40,7 @@
*/
#define STDIO UART_0
#define STDIO_BAUDRATE (115200U)
#define STDIO_BUFSIZE (64U)
#define STDIO_RX_BUFSIZE (64U)
/** @} */

/**
Expand Down
2 changes: 1 addition & 1 deletion boards/stm32f0discovery/include/board.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion boards/stm32f3discovery/include/board.h
Expand Up @@ -39,7 +39,7 @@
*/
#define STDIO UART_0
#define STDIO_BAUDRATE (115200U)
#define STDIO_BUFSIZE (64U)
#define STDIO_RX_BUFSIZE (64U)
/** @} */

/**
Expand Down
2 changes: 1 addition & 1 deletion boards/stm32f4discovery/include/board.h
Expand Up @@ -40,7 +40,7 @@
*/
#define STDIO UART_0
#define STDIO_BAUDRATE (115200U)
#define STDIO_BUFSIZE (64U)
#define STDIO_RX_BUFSIZE (64U)
/** @} */

/**
Expand Down
9 changes: 5 additions & 4 deletions cpu/stm32f0/syscalls.c
Expand Up @@ -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

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
}

Expand Down
9 changes: 5 additions & 4 deletions cpu/stm32f1/syscalls.c
Expand Up @@ -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

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
}

Expand Down
9 changes: 5 additions & 4 deletions cpu/stm32f3/syscalls.c
Expand Up @@ -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

Expand Down Expand Up @@ -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);}

Expand Down Expand Up @@ -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
}

Expand Down
8 changes: 6 additions & 2 deletions cpu/stm32f4/syscalls.c
Expand Up @@ -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

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit d0b0af6

Please sign in to comment.