Loading...
Searching...
No Matches
spidev_linux.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Frank Hessel <frank@fhessel.de>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
54
60
61#if defined(__linux__) || defined(DOXYGEN) /* Linux-only */
62
63#include "periph/spi.h"
64
65#include "mutex.h"
66#include "periph_conf.h"
67
68#ifdef __cplusplus
69extern "C" {
70#endif
71
75enum {
78};
79
89
101
111int spidev_linux_setup(spi_t bus, unsigned cs_id, const char *name);
112
117
118#ifdef __cplusplus
119}
120#endif
121
122#else
123/* Create the error in the header file as spi.c will be compiled to late to show it */
124#ifdef MODULE_PERIPH_SPIDEV_LINUX
125#error "MODULE periph_spidev_linux is only available on Linux"
126#endif
127#endif /* defined(__linux__) || defined(DOXYGEN) */
128
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:39
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)