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 "tsrb.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
48 #ifdef CONFIG_SLIPDEV_BUFSIZE_EXP
49 #define CONFIG_SLIPDEV_BUFSIZE (1<<CONFIG_SLIPDEV_BUFSIZE_EXP)
50 #endif
51 
52 #ifndef CONFIG_SLIPDEV_BUFSIZE
53 #define CONFIG_SLIPDEV_BUFSIZE (2048U)
54 #endif
55 
62 enum {
75 };
81 typedef struct {
83  uint32_t baudrate;
85 
91 typedef struct {
95  uint8_t rxmem[CONFIG_SLIPDEV_BUFSIZE];
100  uint8_t state;
101 } slipdev_t;
102 
109 void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params);
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif /* SLIPDEV_H */
116 
slipdev_t::netdev
netdev_t netdev
parent class
Definition: slipdev.h:92
slipdev_t::config
slipdev_params_t config
configuration parameters
Definition: slipdev.h:93
SLIPDEV_STATE_NET
@ SLIPDEV_STATE_NET
Device writes handles data as network device.
Definition: slipdev.h:70
SLIPDEV_STATE_NONE
@ SLIPDEV_STATE_NONE
Device is in no mode (currently did not receiving any data frame)
Definition: slipdev.h:66
slipdev_setup
void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params)
Setup a slipdev device state.
SLIPDEV_STATE_STDIN
@ SLIPDEV_STATE_STDIN
Device writes received data to stdin.
Definition: slipdev.h:74
slipdev_params_t::uart
uart_t uart
UART interface the device is connected to.
Definition: slipdev.h:82
slipdev_t::state
uint8_t state
Device state.
Definition: slipdev.h:100
uart_t
unsigned int uart_t
Define default UART type identifier.
Definition: uart.h:76
slipdev_params_t
Configuration parameters for a slipdev.
Definition: slipdev.h:81
uart.h
Low-level UART peripheral driver interface definition.
netdev.h
Definitions low-level network driver interface.
netdev
Structure to hold driver state.
Definition: netdev.h:302
slipdev_t::inbuf
tsrb_t inbuf
RX buffer.
Definition: slipdev.h:94
cib.h
Circular integer buffer interface.
slipdev_t
Device descriptor for slipdev.
Definition: slipdev.h:91
tsrb
thread-safe ringbuffer struct
Definition: tsrb.h:39
slipdev_params_t::baudrate
uint32_t baudrate
baudrate to use with slipdev_params_t::uart
Definition: slipdev.h:83
CONFIG_SLIPDEV_BUFSIZE
#define CONFIG_SLIPDEV_BUFSIZE
UART buffer size used for TX and RX buffers.
Definition: slipdev.h:53
tsrb.h
Thread-safe ringbuffer interface definition.