All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
spidev_linux.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 Frank Hessel <frank@fhessel.de>
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
61#ifndef SPIDEV_LINUX_H
62#define SPIDEV_LINUX_H
63
64#if defined(__linux__) || defined(DOXYGEN) /* Linux-only */
65
66#include "periph/spi.h"
67
68#include "mutex.h"
69#include "periph_conf.h"
70
71#ifdef __cplusplus
72extern "C" {
73#endif
74
78enum {
81};
82
92
104
114int spidev_linux_setup(spi_t bus, unsigned cs_id, const char *name);
115
120
121#ifdef __cplusplus
122}
123#endif
124
125#else
126/* Create the error in the header file as spi.c will be compiled to late to show it */
127#ifdef MODULE_PERIPH_SPIDEV_LINUX
128#error "MODULE periph_spidev_linux is only available on Linux"
129#endif
130#endif /* defined(__linux__) || defined(DOXYGEN) */
131
132#endif /* SPIDEV_LINUX_H */
Native CPU peripheral configuration.
#define SPI_MAXCS
Maximum amount of chip select lines per bus.
int spidev_linux_setup(spi_t bus, unsigned cs_id, const char *name)
register /dev/spidev* device to be used for SPI
struct spidev_linux_state spidev_linux_state_t
Dynamic runtime state for SPI port + CS line.
struct spidev_linux_conf spidev_linux_conf_t
Static runtime configuration for SPI port + CS line.
void spidev_linux_teardown(void)
Close open SPI file descriptors.
@ SPI_SETUP_INVALID
invalid params or duplicate definition
@ SPI_SETUP_OK
parameters are sound
Mutex for thread synchronization.
Low-level SPI peripheral driver interface definition.
Mutex structure.
Definition mutex.h:40
Static runtime configuration for SPI port + CS line.
char * device_filename[SPI_MAXCS]
Filename for a specific SPI device + CS line (like /dev/spidev0.0)
Dynamic runtime state for SPI port + CS line.
int fd[SPI_MAXCS]
File descriptors for each CS line on the bus.
mutex_t lock
Mutex for the whole bus (all CS lines)