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
62#ifndef SPIDEV_LINUX_H
63#define SPIDEV_LINUX_H
64
65#if defined(__linux__) || defined(DOXYGEN) /* Linux-only */
66
67#include "periph/spi.h"
68
69#include "mutex.h"
70#include "periph_conf.h"
71
72#ifdef __cplusplus
73extern "C" {
74#endif
75
79enum {
82};
83
89typedef struct spidev_linux_conf {
93
99typedef struct spidev_linux_state {
105
115int spidev_linux_setup(spi_t bus, unsigned cs_id, const char *name);
116
121
122#ifdef __cplusplus
123}
124#endif
125
126#else
127/* Create the error in the header file as spi.c will be compiled to late to show it */
128#ifdef MODULE_PERIPH_SPIDEV_LINUX
129#error "MODULE periph_spidev_linux is only available on Linux"
130#endif
131#endif /* defined(__linux__) || defined(DOXYGEN) */
132
133#endif /* SPIDEV_LINUX_H */
Native CPU peripheral configuration.
#define SPI_MAXCS
Maximum amount of chip select lines per bus.
Definition: periph_conf.h:114
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
Definition: spidev_linux.h:81
@ SPI_SETUP_OK
parameters are sound
Definition: spidev_linux.h:80
Mutex for thread synchronization.
Low-level SPI peripheral driver interface definition.
Mutex structure.
Definition: mutex.h:146
Static runtime configuration for SPI port + CS line.
Definition: spidev_linux.h:89
char * device_filename[SPI_MAXCS]
Filename for a specific SPI device + CS line (like /dev/spidev0.0)
Definition: spidev_linux.h:91
Dynamic runtime state for SPI port + CS line.
Definition: spidev_linux.h:99
int fd[SPI_MAXCS]
File descriptors for each CS line on the bus.
Definition: spidev_linux.h:103
mutex_t lock
Mutex for the whole bus (all CS lines)
Definition: spidev_linux.h:101