RTEMS: cpukit/include/dev/spi/spi.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
spi.h
Go to the documentation of this file.
1
9/*
10 * Copyright (c) 2016, 2017 embedded brains GmbH. All rights reserved.
11 *
12 * embedded brains GmbH
13 * Dornierstr. 4
14 * 82178 Puchheim
15 * Germany
16 * <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#ifndef _DEV_SPI_SPI_H
24#define _DEV_SPI_SPI_H
25
26#include <linux/spi/spidev.h>
27
28#include <rtems.h>
29#include <rtems/seterr.h>
30#include <rtems/thread.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif /* __cplusplus */
35
36typedef struct spi_ioc_transfer spi_ioc_transfer;
37
38typedef struct spi_bus spi_bus;
39
55#define SPI_BUS_OBTAIN _IO(SPI_IOC_MAGIC, 13)
56
62#define SPI_BUS_RELEASE _IO(SPI_IOC_MAGIC, 23)
63
67 struct spi_bus {
79 int (*transfer)(spi_bus *bus, const spi_ioc_transfer *msgs, uint32_t msg_count);
80
90 int (*setup)(spi_bus *bus);
91
97 void (*destroy)(spi_bus *bus);
98
102 rtems_recursive_mutex mutex;
103
107 uint32_t max_speed_hz;
108
112 uint32_t speed_hz;
113
117 bool cs_change;
118
122 uint8_t cs;
123
127 uint8_t bits_per_word;
128
132 bool lsb_first;
133
137 uint32_t mode;
138
143 uint16_t delay_usecs;
144};
145
161int spi_bus_init(spi_bus *bus);
162
180 spi_bus *spi_bus_alloc_and_init(size_t size);
181
187void spi_bus_destroy(spi_bus *bus);
188
194void spi_bus_destroy_and_free(spi_bus *bus);
195
208int spi_bus_register(
209 spi_bus *bus,
210 const char *bus_path
211);
212
215#ifdef __cplusplus
216}
217#endif /* __cplusplus */
218
219#endif /* _DEV_SPI_SPI_H */
spi_bus_alloc_and_init
spi_bus * spi_bus_alloc_and_init(size_t size)
Allocates a bus control from the heap and initializes it.
Definition: spi-bus.c:326
spi_bus_init
int spi_bus_init(spi_bus *bus)
Initializes a bus control.
Definition: spi-bus.c:319
spi_bus_register
int spi_bus_register(spi_bus *bus, const char *bus_path)
Registers a bus control.
Definition: spi-bus.c:252
spi_bus_destroy_and_free
void spi_bus_destroy_and_free(spi_bus *bus)
Destroys a bus control and frees its memory.
Definition: spi-bus.c:313
spi_bus_destroy
void spi_bus_destroy(spi_bus *bus)
Destroys a bus control.
Definition: spi-bus.c:308
rtems.h
seterr.h
Data which Ease the Burden of Consistently Setting Errno.
spidev.h
RTEMS Port of Linux SPI API.
spi_bus
SPI bus control.
Definition: spi.h:67
spi_bus::destroy
void(* destroy)(spi_bus *bus)
Destroys the bus.
Definition: spi.h:97
spi_bus::cs
uint8_t cs
Indicates which device is selected by chip select.
Definition: spi.h:122
spi_bus::mode
uint32_t mode
Current mode.
Definition: spi.h:137
spi_bus::delay_usecs
uint16_t delay_usecs
Indicates the delay between transfers on different chip select devices.
Definition: spi.h:143
spi_bus::transfer
int(* transfer)(spi_bus *bus, const spi_ioc_transfer *msgs, uint32_t msg_count)
Transfers SPI messages.
Definition: spi.h:79
spi_bus::lsb_first
bool lsb_first
Indicates if LSB is supposed to be transmitted first.
Definition: spi.h:132
spi_bus::setup
int(* setup)(spi_bus *bus)
Checks if maximum speed and bits per word are in a valid range for the device.
Definition: spi.h:90
spi_bus::cs_change
bool cs_change
Indicates if chip select must be set high after transfer.
Definition: spi.h:117
spi_bus::speed_hz
uint32_t speed_hz
Indicates the speed of the current device message.
Definition: spi.h:112
spi_bus::mutex
rtems_recursive_mutex mutex
Mutex to protect the bus access.
Definition: spi.h:102
spi_bus::max_speed_hz
uint32_t max_speed_hz
Maximum Speed in Hz.
Definition: spi.h:107
spi_bus::bits_per_word
uint8_t bits_per_word
Indicates the bits per word used on the device.
Definition: spi.h:127
spi_ioc_transfer
SPI transfer message.
Definition: spidev.h:145