mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
385569c7bf
17810: drivers/slipdev: implement sleep states r=benpicco a=benpicco 18348: sys/net/gnrc/pktbuf_static: make use of alignas() r=maribu a=maribu ### Contribution description Since we are now using C11, we can make use of `alignas()` provided by `<stdalign.h>` to make the alignment code easier to read. ### Testing procedure I didn't expect this to change binaries, but is safes 4 bytes. `elf_diff` shows that the compiler (at least GCC 11.3.0) was not able to detect that `gnrc_pktbuf_static_buf` was just an alias for `_pktbuf_buf`. That makes sense since it would be hard without LTO to rule out external writes to `gnrc_pktbuf_static_buf`, unless one would have added a `const` (to the pointer, not to the data the pointer points to). The [output of `elf_diff`](https://mari-bu.de/pr_18348_gnrc_pktbuf_static_elf_diff.html) looks otherwise quite unscary. Also: ``` $ make BOARD=nucleo-f767zi -C tests/unittests/ tests-pktbuf flash test make: Entering directory '/home/maribu/Repos/software/RIOT/tests/unittests' Building application "tests_unittests" for "nucleo-f767zi" with MCU "stm32". [...] Welcome to pyterm! Type '/exit' to exit. READY s START ............................................. OK (45 tests) make: Leaving directory '/home/maribu/Repos/software/RIOT/tests/unittests' ``` ### Issues/PRs references None 19120: CI: seperate check-labels and check-commits workflows r=maribu a=kaspar030 Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com> Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de> Co-authored-by: Kaspar Schleiser <kaspar@schleiser.de>
129 lines
3.2 KiB
C
129 lines
3.2 KiB
C
/*
|
|
* Copyright (C) 2015-17 Freie Universität Berlin
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
* directory for more details.
|
|
*/
|
|
|
|
/**
|
|
* @defgroup drivers_slipdev SLIP network device
|
|
* @ingroup drivers_netdev
|
|
* @brief SLIP network device over @ref drivers_periph_uart
|
|
* @see [RFC 1055](https://github.com/RIOT-OS/RIOT/pull/6487)
|
|
* @{
|
|
*
|
|
* @file
|
|
* @brief SLIP device definitions
|
|
*
|
|
* @author Martine Lenders <m.lenders@fu-berlin.de>
|
|
*/
|
|
#ifndef SLIPDEV_H
|
|
#define SLIPDEV_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "cib.h"
|
|
#include "net/netdev.h"
|
|
#include "periph/uart.h"
|
|
#include "tsrb.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* @defgroup drivers_slipdev_config SLIP Network driver compile configuration
|
|
* @ingroup config_drivers_netdev
|
|
* @{
|
|
*/
|
|
/**
|
|
* @brief UART buffer size used for TX and RX buffers
|
|
*
|
|
* Reduce this value if your expected traffic does not include full IPv6 MTU
|
|
* sized packets.
|
|
*
|
|
* @pre Needs to be power of two and `<= INT_MAX`
|
|
*/
|
|
#ifdef CONFIG_SLIPDEV_BUFSIZE_EXP
|
|
#define CONFIG_SLIPDEV_BUFSIZE (1<<CONFIG_SLIPDEV_BUFSIZE_EXP)
|
|
#endif
|
|
|
|
#ifndef CONFIG_SLIPDEV_BUFSIZE
|
|
#define CONFIG_SLIPDEV_BUFSIZE (2048U)
|
|
#endif
|
|
/** @} */
|
|
|
|
/**
|
|
* @name Device state definitions
|
|
* @anchor drivers_slipdev_states
|
|
* @{
|
|
*/
|
|
enum {
|
|
/**
|
|
* @brief Device is in no mode (currently did not receiving any data frame)
|
|
*/
|
|
SLIPDEV_STATE_NONE = 0,
|
|
/**
|
|
* @brief Device writes handles data as network device
|
|
*/
|
|
SLIPDEV_STATE_NET,
|
|
/**
|
|
* @brief Device writes received data to stdin
|
|
*/
|
|
SLIPDEV_STATE_STDIN,
|
|
/**
|
|
* @brief Device is in standby, will wake up when sending data
|
|
*/
|
|
SLIPDEV_STATE_STANDBY,
|
|
/**
|
|
* @brief Device is in sleep mode
|
|
*/
|
|
SLIPDEV_STATE_SLEEP,
|
|
};
|
|
/** @} */
|
|
|
|
/**
|
|
* @brief Configuration parameters for a slipdev
|
|
*/
|
|
typedef struct {
|
|
uart_t uart; /**< UART interface the device is connected to */
|
|
uint32_t baudrate; /**< baudrate to use with slipdev_params_t::uart */
|
|
} slipdev_params_t;
|
|
|
|
/**
|
|
* @brief Device descriptor for slipdev
|
|
*
|
|
* @extends netdev_t
|
|
*/
|
|
typedef struct {
|
|
netdev_t netdev; /**< parent class */
|
|
slipdev_params_t config; /**< configuration parameters */
|
|
tsrb_t inbuf; /**< RX buffer */
|
|
uint8_t rxmem[CONFIG_SLIPDEV_BUFSIZE]; /**< memory used by RX buffer */
|
|
/**
|
|
* @brief Device state
|
|
* @see [Device state definitions](@ref drivers_slipdev_states)
|
|
*/
|
|
uint8_t state;
|
|
uint8_t rx_queued; /**< pkt queued in inbuf */
|
|
uint8_t rx_done; /**< pkt processed */
|
|
} slipdev_t;
|
|
|
|
/**
|
|
* @brief Setup a slipdev device state
|
|
*
|
|
* @param[in] dev device descriptor
|
|
* @param[in] params parameters for device initialization
|
|
* @param[in] index index of @p params in a global parameter struct array.
|
|
* If initialized manually, pass a unique identifier instead.
|
|
*/
|
|
void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params, uint8_t index);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* SLIPDEV_H */
|
|
/** @} */
|