RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
spidev.h
Go to the documentation of this file.
1
9/*
10 * Copyright (c) 2016 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 _UAPI_LINUX_SPI_H
24#define _UAPI_LINUX_SPI_H
25
26#include <sys/ioccom.h>
27#include <stddef.h>
28#include <stdint.h>
29
53#define SPI_CPHA 0x01
54
58#define SPI_CPOL 0x02
59
64#define SPI_MODE_0 0
65
70#define SPI_MODE_1 SPI_CPHA
71
76#define SPI_MODE_2 SPI_CPOL
77
82#define SPI_MODE_3 (SPI_CPOL | SPI_CPHA)
83
88#define SPI_CS_HIGH 0x04
89
94#define SPI_LSB_FIRST 0x08
95
100#define SPI_3WIRE 0x10
101
105#define SPI_LOOP 0x20
106
111#define SPI_NO_CS 0x40
112
116#define SPI_READY 0x80
117
121#define SPI_TX_DUAL 0x100
122
126#define SPI_TX_QUAD 0x200
127
131#define SPI_RX_DUAL 0x400
132
136#define SPI_RX_QUAD 0x800
137
140#define SPI_IOC_MAGIC 's'
141
149 void *rx_buf;
150
154 const void *tx_buf;
155
159 size_t len;
160
164 uint32_t speed_hz;
165
170 uint16_t delay_usecs;
171
176
181 uint8_t cs_change;
182
186 uint8_t rx_nbits;
187
191 uint8_t tx_nbits;
192
197 uint32_t mode;
198
202 uint8_t cs;
203};
204
208#define SPI_MSGSIZE(n) \
209 (((n) * sizeof(struct spi_ioc_transfer) < IOCPARM_MAX) ? \
210 (n) * sizeof(struct spi_ioc_transfer) : 0)
211
215#define SPI_IOC_MESSAGE(n) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(n)])
216
220#define SPI_IOC_RD_MODE _IOR(SPI_IOC_MAGIC, 1, uint8_t)
221
226#define SPI_IOC_WR_MODE _IOW(SPI_IOC_MAGIC, 1, uint8_t)
227
231#define SPI_IOC_RD_LSB_FIRST _IOR(SPI_IOC_MAGIC, 2, uint8_t)
232
236#define SPI_IOC_WR_LSB_FIRST _IOW(SPI_IOC_MAGIC, 2, uint8_t)
237
241#define SPI_IOC_RD_BITS_PER_WORD _IOR(SPI_IOC_MAGIC, 3, uint8_t)
242
246#define SPI_IOC_WR_BITS_PER_WORD _IOW(SPI_IOC_MAGIC, 3, uint8_t)
247
251#define SPI_IOC_RD_MAX_SPEED_HZ _IOR(SPI_IOC_MAGIC, 4, uint32_t)
252
256#define SPI_IOC_WR_MAX_SPEED_HZ _IOW(SPI_IOC_MAGIC, 4, uint32_t)
257
261#define SPI_IOC_RD_MODE32 _IOR(SPI_IOC_MAGIC, 5, uint32_t)
262
266#define SPI_IOC_WR_MODE32 _IOW(SPI_IOC_MAGIC, 5, uint32_t)
267
268#endif /* _UAPI_LINUX_SPI_H */
uint8_t cs_change
If true, device is deselected after transfer ended and before a new transfer is started.
Definition: spidev.h:181
uint32_t speed_hz
Sets the bit-rate of the device.
Definition: spidev.h:164
void * rx_buf
Buffer for receive data.
Definition: spidev.h:149
uint8_t rx_nbits
Amount of bits that are used for reading.
Definition: spidev.h:186
uint8_t bits_per_word
Sets the device wordsize.
Definition: spidev.h:175
uint16_t delay_usecs
Sets the delay after a transfer before the chip select status is changed and the next transfer is tri...
Definition: spidev.h:170
uint8_t tx_nbits
Amount of bits that are used for writing.
Definition: spidev.h:191
uint8_t cs
Indicates which device is currently used.
Definition: spidev.h:202
size_t len
Length of receive and transmit buffers in bytes.
Definition: spidev.h:159
const void * tx_buf
Buffer for transmit data.
Definition: spidev.h:154
uint32_t mode
Sets one of the possible modes that can be used for SPI transfers (dependent on clock phase and polar...
Definition: spidev.h:197
SPI transfer message.
Definition: spidev.h:145