RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
cpukit
include
dev
spi
spi.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
10
11
/*
12
* Copyright (C) 2016, 2017 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 _DEV_SPI_SPI_H
37
#define _DEV_SPI_SPI_H
38
39
#include <
linux/spi/spidev.h
>
40
41
#include <
rtems.h
>
42
#include <
rtems/seterr.h
>
43
#include <
rtems/thread.h
>
44
45
#ifdef __cplusplus
46
extern
"C"
{
47
#endif
/* __cplusplus */
48
49
typedef
struct
spi_ioc_transfer
spi_ioc_transfer
;
50
51
typedef
struct
spi_bus
spi_bus
;
52
62
68
#define SPI_BUS_OBTAIN _IO(SPI_IOC_MAGIC, 13)
69
75
#define SPI_BUS_RELEASE _IO(SPI_IOC_MAGIC, 23)
76
80
struct
spi_bus
{
92
int (*
transfer
)(
spi_bus
*bus,
const
spi_ioc_transfer *msgs, uint32_t msg_count);
93
103
int (*
setup
)(
spi_bus
*bus);
104
110
void (*
destroy
)(
spi_bus
*bus);
111
115
rtems_recursive_mutex
mutex
;
116
120
uint32_t
max_speed_hz
;
121
125
uint32_t
speed_hz
;
126
130
bool
cs_change
;
131
135
uint8_t
cs
;
136
140
uint8_t
bits_per_word
;
141
145
bool
lsb_first
;
146
150
uint32_t
mode
;
151
156
uint16_t
delay_usecs
;
157
163
int (*
ioctl
)(
spi_bus
*bus, ioctl_command_t command,
void
*arg);
164
};
165
181
int
spi_bus_init
(
spi_bus
*bus);
182
200
spi_bus
*
spi_bus_alloc_and_init
(
size_t
size);
201
207
void
spi_bus_destroy
(
spi_bus
*bus);
208
214
void
spi_bus_destroy_and_free
(
spi_bus
*bus);
215
228
int
spi_bus_register
(
229
spi_bus
*bus,
230
const
char
*bus_path
231
);
232
234
235
#ifdef __cplusplus
236
}
237
#endif
/* __cplusplus */
238
239
#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:323
spi_bus_init
int spi_bus_init(spi_bus *bus)
Initializes a bus control.
Definition
spi-bus.c:316
spi_bus_register
int spi_bus_register(spi_bus *bus, const char *bus_path)
Registers a bus control.
Definition
spi-bus.c:248
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:310
spi_bus_destroy
void spi_bus_destroy(spi_bus *bus)
Destroys a bus control.
Definition
spi-bus.c:305
rtems.h
This header file defines the RTEMS Classic API.
seterr.h
This header file defines macros to set errno and return minus one.
spidev.h
RTEMS Port of Linux SPI API.
spi_bus
SPI bus control.
Definition
spi.h:80
spi_bus::ioctl
int(*) ioctl(spi_bus *bus, ioctl_command_t command, void *arg)
Driver specific ioctl.
Definition
spi.h:163
spi_bus::cs
uint8_t cs
Indicates which device is selected by chip select.
Definition
spi.h:135
spi_bus::mode
uint32_t mode
Current mode.
Definition
spi.h:150
spi_bus::delay_usecs
uint16_t delay_usecs
Indicates the delay between transfers on different chip select devices.
Definition
spi.h:156
spi_bus::lsb_first
bool lsb_first
Indicates if LSB is supposed to be transmitted first.
Definition
spi.h:145
spi_bus::destroy
void(*) destroy(spi_bus *bus)
Destroys the bus.
Definition
spi.h:110
spi_bus::cs_change
bool cs_change
Indicates if chip select must be set high after transfer.
Definition
spi.h:130
spi_bus::speed_hz
uint32_t speed_hz
Indicates the speed of the current device message.
Definition
spi.h:125
spi_bus::transfer
int(*) transfer(spi_bus *bus, const spi_ioc_transfer *msgs, uint32_t msg_count)
Transfers SPI messages.
Definition
spi.h:92
spi_bus::mutex
rtems_recursive_mutex mutex
Mutex to protect the bus access.
Definition
spi.h:115
spi_bus::max_speed_hz
uint32_t max_speed_hz
Maximum Speed in Hz.
Definition
spi.h:120
spi_bus::bits_per_word
uint8_t bits_per_word
Indicates the bits per word used on the device.
Definition
spi.h:140
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:103
spi_ioc_transfer
SPI transfer message.
Definition
spidev.h:158
thread.h
This header file provides the API of Self-Contained Objects.
Generated by
1.18.0