RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
bsps
m68k
gen68360
spi
m360_spi.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
10
11
/*
12
* Copyright (c) 2008 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
43
44
#ifndef _M360_SPIDRV_H
45
#define _M360_SPIDRV_H
46
47
#include <
rtems/m68k/m68360.h
>
48
#include <
rtems/libi2c.h
>
49
#include <
rtems/irq.h
>
50
51
#ifdef __cplusplus
52
extern
"C"
{
53
#endif
54
55
typedef
struct
m360_spi_softc
{
56
int
initialized;
57
rtems_id
irq_sema_id;
58
rtems_isr_entry
old_handler;
59
m360BufferDescriptor_t *rx_bd;
60
m360BufferDescriptor_t *tx_bd;
61
} m360_spi_softc_t ;
62
63
typedef
struct
{
64
rtems_libi2c_bus_t bus_desc;
65
m360_spi_softc_t softc;
66
}
m360_spi_desc_t
;
67
68
/*=========================================================================*\
69
| Function: |
70
\*-------------------------------------------------------------------------*/
71
rtems_status_code
m360_spi_init
72
(
73
/*-------------------------------------------------------------------------*\
74
| Purpose: |
75
| initialize the driver |
76
+---------------------------------------------------------------------------+
77
| Input Parameters: |
78
\*-------------------------------------------------------------------------*/
79
rtems_libi2c_bus_t *bh
/* bus specifier structure */
80
);
81
/*-------------------------------------------------------------------------*\
82
| Return Value: |
83
| o = ok or error code |
84
\*=========================================================================*/
85
86
/*=========================================================================*\
87
| Function: |
88
\*-------------------------------------------------------------------------*/
89
int
m360_spi_read_bytes
90
(
91
/*-------------------------------------------------------------------------*\
92
| Purpose: |
93
| receive some bytes from SPI device |
94
+---------------------------------------------------------------------------+
95
| Input Parameters: |
96
\*-------------------------------------------------------------------------*/
97
rtems_libi2c_bus_t *bh,
/* bus specifier structure */
98
unsigned
char
*buf,
/* buffer to store bytes */
99
int
len
/* number of bytes to receive */
100
);
101
/*-------------------------------------------------------------------------*\
102
| Return Value: |
103
| number of bytes received or (negative) error code |
104
\*=========================================================================*/
105
106
/*=========================================================================*\
107
| Function: |
108
\*-------------------------------------------------------------------------*/
109
int
m360_spi_write_bytes
110
(
111
/*-------------------------------------------------------------------------*\
112
| Purpose: |
113
| send some bytes to SPI device |
114
+---------------------------------------------------------------------------+
115
| Input Parameters: |
116
\*-------------------------------------------------------------------------*/
117
rtems_libi2c_bus_t *bh,
/* bus specifier structure */
118
unsigned
char
*buf,
/* buffer to send */
119
int
len
/* number of bytes to send */
120
121
);
122
/*-------------------------------------------------------------------------*\
123
| Return Value: |
124
| number of bytes sent or (negative) error code |
125
\*=========================================================================*/
126
127
/*=========================================================================*\
128
| Function: |
129
\*-------------------------------------------------------------------------*/
130
rtems_status_code
m360_spi_set_tfr_mode
131
(
132
/*-------------------------------------------------------------------------*\
133
| Purpose: |
134
| set SPI to desired baudrate/clock mode/character mode |
135
+---------------------------------------------------------------------------+
136
| Input Parameters: |
137
\*-------------------------------------------------------------------------*/
138
rtems_libi2c_bus_t *bh,
/* bus specifier structure */
139
const
rtems_libi2c_tfr_mode_t
*tfr_mode
/* transfer mode info */
140
);
141
/*-------------------------------------------------------------------------*\
142
| Return Value: |
143
| rtems_status_code |
144
\*=========================================================================*/
145
146
/*=========================================================================*\
147
| Function: |
148
\*-------------------------------------------------------------------------*/
149
int
m360_spi_ioctl
150
(
151
/*-------------------------------------------------------------------------*\
152
| Purpose: |
153
| perform selected ioctl function for SPI |
154
+---------------------------------------------------------------------------+
155
| Input Parameters: |
156
\*-------------------------------------------------------------------------*/
157
rtems_libi2c_bus_t *bh,
/* bus specifier structure */
158
int
cmd,
/* ioctl command code */
159
void
*arg
/* additional argument array */
160
);
161
/*-------------------------------------------------------------------------*\
162
| Return Value: |
163
| rtems_status_code |
164
\*=========================================================================*/
165
166
#ifdef __cplusplus
167
}
168
#endif
169
170
171
#endif
/* _M360_SPIDRV_H */
irq.h
rtems_isr_entry
ISR_Handler_entry rtems_isr_entry
Interrupt service routines installed by rtems_interrupt_catch() shall have this type.
Definition
intr.h:134
rtems_status_code
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition
status.h:85
rtems_id
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition
types.h:94
libi2c.h
Legacy I2C Library.
m68360.h
Definitions for Motorola MC68360 Processor.
m360_spi_desc_t
Definition
m360_spi.h:63
m360_spi_softc
Definition
m360_spi.h:55
rtems_libi2c_tfr_mode_t
Definition
libi2c.h:481
Generated by
1.18.0