RTEMS 6.1-rc7
Loading...
Searching...
No Matches
spi.h
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 * RTEMS support for MPC8xx
5 *
6 * This file contains the MPC8xx SPI driver declarations.
7 */
8
9/*
10 * Copyright (c) 2009 embedded brains GmbH & Co. KG
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef _M8XX_SPIDRV_H
35#define _M8XX_SPIDRV_H
36
37#include <mpc8xx.h>
38#include <rtems/libi2c.h>
39#include <rtems/irq.h>
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45typedef struct m8xx_spi_softc {
46 int initialized;
47 rtems_id irq_sema_id;
48 rtems_isr_entry old_handler;
52
53typedef struct {
54 rtems_libi2c_bus_t bus_desc;
55 m8xx_spi_softc_t softc;
57
58/*=========================================================================*\
59| Function: |
60\*-------------------------------------------------------------------------*/
61rtems_status_code m8xx_spi_init
62(
63/*-------------------------------------------------------------------------*\
64| Purpose: |
65| initialize the driver |
66+---------------------------------------------------------------------------+
67| Input Parameters: |
68\*-------------------------------------------------------------------------*/
69 rtems_libi2c_bus_t *bh /* bus specifier structure */
70 );
71/*-------------------------------------------------------------------------*\
72| Return Value: |
73| o = ok or error code |
74\*=========================================================================*/
75
76/*=========================================================================*\
77| Function: |
78\*-------------------------------------------------------------------------*/
79int m8xx_spi_read_bytes
80(
81/*-------------------------------------------------------------------------*\
82| Purpose: |
83| receive some bytes from SPI device |
84+---------------------------------------------------------------------------+
85| Input Parameters: |
86\*-------------------------------------------------------------------------*/
87 rtems_libi2c_bus_t *bh, /* bus specifier structure */
88 unsigned char *buf, /* buffer to store bytes */
89 int len /* number of bytes to receive */
90 );
91/*-------------------------------------------------------------------------*\
92| Return Value: |
93| number of bytes received or (negative) error code |
94\*=========================================================================*/
95
96/*=========================================================================*\
97| Function: |
98\*-------------------------------------------------------------------------*/
99int m8xx_spi_write_bytes
100(
101/*-------------------------------------------------------------------------*\
102| Purpose: |
103| send some bytes to SPI device |
104+---------------------------------------------------------------------------+
105| Input Parameters: |
106\*-------------------------------------------------------------------------*/
107 rtems_libi2c_bus_t *bh, /* bus specifier structure */
108 unsigned char *buf, /* buffer to send */
109 int len /* number of bytes to send */
110
111 );
112/*-------------------------------------------------------------------------*\
113| Return Value: |
114| number of bytes sent or (negative) error code |
115\*=========================================================================*/
116
117/*=========================================================================*\
118| Function: |
119\*-------------------------------------------------------------------------*/
120rtems_status_code m8xx_spi_set_tfr_mode
121(
122/*-------------------------------------------------------------------------*\
123| Purpose: |
124| set SPI to desired baudrate/clock mode/character mode |
125+---------------------------------------------------------------------------+
126| Input Parameters: |
127\*-------------------------------------------------------------------------*/
128 rtems_libi2c_bus_t *bh, /* bus specifier structure */
129 const rtems_libi2c_tfr_mode_t *tfr_mode /* transfer mode info */
130 );
131/*-------------------------------------------------------------------------*\
132| Return Value: |
133| rtems_status_code |
134\*=========================================================================*/
135
136/*=========================================================================*\
137| Function: |
138\*-------------------------------------------------------------------------*/
139int m8xx_spi_ioctl
140(
141/*-------------------------------------------------------------------------*\
142| Purpose: |
143| perform selected ioctl function for SPI |
144+---------------------------------------------------------------------------+
145| Input Parameters: |
146\*-------------------------------------------------------------------------*/
147 rtems_libi2c_bus_t *bh, /* bus specifier structure */
148 int cmd, /* ioctl command code */
149 void *arg /* additional argument array */
150 );
151/*-------------------------------------------------------------------------*\
152| Return Value: |
153| rtems_status_code |
154\*=========================================================================*/
155
156#ifdef __cplusplus
157}
158#endif
159
160
161#endif /* _M8XX_SPIDRV_H */
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
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition: types.h:94
Legacy I2C Library.
Definition: mpc8xx.h:676
Definition: spi.h:53
Definition: spi.h:45
Definition: libi2c.h:163
Definition: libi2c.h:462