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

Merge pull request #3841 from OlegHahm/slip_write_blocking

gnrc slip: use blocking uart writing
This commit is contained in:
Martine Lenders 2015-09-17 13:55:56 +02:00
commit 15e6e65b11
2 changed files with 2 additions and 16 deletions

View File

@ -52,7 +52,6 @@ typedef struct {
ringbuffer_t in_buf; /**< RX buffer */
ringbuffer_t out_buf; /**< TX buffer */
char rx_mem[GNRC_SLIP_BUFSIZE]; /**< memory used by RX buffer */
char tx_mem[GNRC_SLIP_BUFSIZE]; /**< memory used by TX buffer */
uint32_t in_bytes; /**< the number of bytes received of a
* currently incoming packet */
uint16_t in_esc; /**< receiver is in escape mode */

View File

@ -95,17 +95,6 @@ static void _slip_rx_cb(void *arg, char data)
}
}
int _slip_tx_cb(void *arg)
{
if (_SLIP_DEV(arg)->out_buf.avail > 0) {
char c = (char)ringbuffer_get_one(&_SLIP_DEV(arg)->out_buf);
uart_write((uart_t)(_SLIP_DEV(arg)->uart), c);
return 1;
}
return 0;
}
/* SLIP receive handler */
static void _slip_receive(gnrc_slip_dev_t *dev, size_t bytes)
{
@ -158,8 +147,7 @@ static void _slip_receive(gnrc_slip_dev_t *dev, size_t bytes)
static inline void _slip_send_char(gnrc_slip_dev_t *dev, char c)
{
ringbuffer_add_one(&dev->out_buf, c);
uart_tx_begin(dev->uart);
uart_write_blocking(dev->uart, c);
}
/* SLIP send handler */
@ -257,12 +245,11 @@ kernel_pid_t gnrc_slip_init(gnrc_slip_dev_t *dev, uart_t uart, uint32_t baudrate
/* initialize buffers */
ringbuffer_init(&dev->in_buf, dev->rx_mem, sizeof(dev->rx_mem));
ringbuffer_init(&dev->out_buf, dev->tx_mem, sizeof(dev->tx_mem));
/* initialize UART */
DEBUG("slip: initialize UART_%d with baudrate %" PRIu32 "\n", uart,
baudrate);
if (uart_init(uart, baudrate, _slip_rx_cb, _slip_tx_cb, dev) < 0) {
if (uart_init(uart, baudrate, _slip_rx_cb, NULL, dev) < 0) {
DEBUG("slip: error initializing UART_%i with baudrate %" PRIu32 "\n",
uart, baudrate);
return -ENODEV;