slipdev.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-17 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
21 #ifndef SLIPDEV_H
22 #define SLIPDEV_H
23 
24 #include <stdint.h>
25 
26 #include "cib.h"
27 #include "net/netdev.h"
28 #include "periph/uart.h"
29 #include "ringbuffer.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
41 #ifndef SLIPDEV_BUFSIZE
42 #define SLIPDEV_BUFSIZE (1500U)
43 #endif
44 
51 #ifndef SLIPDEV_PKTFIFO_SIZE
52 #define SLIPDEV_PKTFIFO_SIZE (8U)
53 #endif
54 
58 typedef struct {
60  uint32_t baudrate;
62 
68 typedef struct {
72  char rxmem[SLIPDEV_BUFSIZE];
73  uint16_t pktfifo[SLIPDEV_PKTFIFO_SIZE];
76  uint16_t inbytes;
78  uint16_t inesc;
80 } slipdev_t;
81 
88 void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif /* SLIPDEV_H */
95 
A utility for storing and retrieving byte data using a ring buffer.
Low-level UART peripheral driver interface definition.
Definitions low-level network driver interface.
netdev_t netdev
parent class
Definition: slipdev.h:69
uint16_t inesc
device previously received an escape byte
Definition: slipdev.h:78
circular integer buffer structure
Definition: cib.h:34
unsigned int uart_t
Define default UART type identifier.
Definition: uart.h:65
#define SLIPDEV_BUFSIZE
UART buffer size used for TX and RX buffers.
Definition: slipdev.h:42
#define SLIPDEV_PKTFIFO_SIZE
Packet FIFO size.
Definition: slipdev.h:52
Configuration parameters for a slipdev.
Definition: slipdev.h:58
uart_t uart
UART interface the device is connected to.
Definition: slipdev.h:59
Ringbuffer.
Definition: ringbuffer.h:36
uint32_t baudrate
baudrate to use with slipdev_params_t::uart
Definition: slipdev.h:60
Structure to hold driver state.
Definition: netdev.h:274
uint16_t inbytes
the number of bytes received of a currently incoming packet
Definition: slipdev.h:76
void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params)
Setup a slipdev device state.
cib_t pktfifo_idx
CIB for slipdev_t::pktfifo.
Definition: slipdev.h:75
Circular integer buffer interface.
ringbuffer_t inbuf
RX buffer.
Definition: slipdev.h:71
Device descriptor for slipdev.
Definition: slipdev.h:68
slipdev_params_t config
configuration parameters
Definition: slipdev.h:70