RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
cpukit
include
linux
spi
spidev.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
10
11
/*
12
* Copyright (c) 2016 embedded brains GmbH & Co. KG
13
*
14
* Redistribution and use in source and binary forms, with or without
15
* modification, are permitted provided that the following conditions
16
* are met:
17
* 1. Redistributions of source code must retain the above copyright
18
* notice, this list of conditions and the following disclaimer.
19
* 2. Redistributions in binary form must reproduce the above copyright
20
* notice, this list of conditions and the following disclaimer in the
21
* documentation and/or other materials provided with the distribution.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
* POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
#ifndef _UAPI_LINUX_SPI_H
37
#define _UAPI_LINUX_SPI_H
38
39
#include <sys/ioccom.h>
40
#include <stddef.h>
41
#include <stdint.h>
42
56
62
66
#define SPI_CPHA 0x01
67
71
#define SPI_CPOL 0x02
72
77
#define SPI_MODE_0 0
78
83
#define SPI_MODE_1 SPI_CPHA
84
89
#define SPI_MODE_2 SPI_CPOL
90
95
#define SPI_MODE_3 (SPI_CPOL | SPI_CPHA)
96
101
#define SPI_CS_HIGH 0x04
102
107
#define SPI_LSB_FIRST 0x08
108
113
#define SPI_3WIRE 0x10
114
118
#define SPI_LOOP 0x20
119
124
#define SPI_NO_CS 0x40
125
129
#define SPI_READY 0x80
130
134
#define SPI_TX_DUAL 0x100
135
139
#define SPI_TX_QUAD 0x200
140
144
#define SPI_RX_DUAL 0x400
145
149
#define SPI_RX_QUAD 0x800
150
152
153
#define SPI_IOC_MAGIC 's'
154
158
struct
spi_ioc_transfer
{
162
void
*
rx_buf
;
163
167
const
void
*
tx_buf
;
168
172
size_t
len
;
173
177
uint32_t
speed_hz
;
178
183
uint16_t
delay_usecs
;
184
188
uint8_t
bits_per_word
;
189
194
uint8_t
cs_change
;
195
199
uint8_t
rx_nbits
;
200
204
uint8_t
tx_nbits
;
205
210
uint32_t
mode
;
211
215
uint8_t
cs
;
216
};
217
221
#define SPI_MSGSIZE(n) \
222
(((n) * sizeof(struct spi_ioc_transfer) < IOCPARM_MAX) ? \
223
(n) * sizeof(struct spi_ioc_transfer) : 0)
224
228
#define SPI_IOC_MESSAGE(n) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(n)])
229
233
#define SPI_IOC_RD_MODE _IOR(SPI_IOC_MAGIC, 1, uint8_t)
234
239
#define SPI_IOC_WR_MODE _IOW(SPI_IOC_MAGIC, 1, uint8_t)
240
244
#define SPI_IOC_RD_LSB_FIRST _IOR(SPI_IOC_MAGIC, 2, uint8_t)
245
249
#define SPI_IOC_WR_LSB_FIRST _IOW(SPI_IOC_MAGIC, 2, uint8_t)
250
254
#define SPI_IOC_RD_BITS_PER_WORD _IOR(SPI_IOC_MAGIC, 3, uint8_t)
255
259
#define SPI_IOC_WR_BITS_PER_WORD _IOW(SPI_IOC_MAGIC, 3, uint8_t)
260
264
#define SPI_IOC_RD_MAX_SPEED_HZ _IOR(SPI_IOC_MAGIC, 4, uint32_t)
265
269
#define SPI_IOC_WR_MAX_SPEED_HZ _IOW(SPI_IOC_MAGIC, 4, uint32_t)
270
274
#define SPI_IOC_RD_MODE32 _IOR(SPI_IOC_MAGIC, 5, uint32_t)
275
279
#define SPI_IOC_WR_MODE32 _IOW(SPI_IOC_MAGIC, 5, uint32_t)
280
281
#endif
/* _UAPI_LINUX_SPI_H */
spi_ioc_transfer::cs_change
uint8_t cs_change
If true, device is deselected after transfer ended and before a new transfer is started.
Definition
spidev.h:194
spi_ioc_transfer::speed_hz
uint32_t speed_hz
Sets the bit-rate of the device.
Definition
spidev.h:177
spi_ioc_transfer::rx_buf
void * rx_buf
Buffer for receive data.
Definition
spidev.h:162
spi_ioc_transfer::rx_nbits
uint8_t rx_nbits
Amount of bits that are used for reading.
Definition
spidev.h:199
spi_ioc_transfer::bits_per_word
uint8_t bits_per_word
Sets the device wordsize.
Definition
spidev.h:188
spi_ioc_transfer::delay_usecs
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:183
spi_ioc_transfer::tx_nbits
uint8_t tx_nbits
Amount of bits that are used for writing.
Definition
spidev.h:204
spi_ioc_transfer::cs
uint8_t cs
Indicates which device is currently used.
Definition
spidev.h:215
spi_ioc_transfer::len
size_t len
Length of receive and transmit buffers in bytes.
Definition
spidev.h:172
spi_ioc_transfer::tx_buf
const void * tx_buf
Buffer for transmit data.
Definition
spidev.h:167
spi_ioc_transfer::mode
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:210
spi_ioc_transfer
SPI transfer message.
Definition
spidev.h:158
Generated by
1.18.0