RTEMS 6.1-rc6
Loading...
Searching...
No Matches
mpc83xx_spidrv.h
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 * RTEMS support for MPC83xx
5 *
6 * This file contains the MPC83xx SPI driver declarations.
7 * NOTE: This driver has the same API as a I2C driver.
8 */
9
10/*
11 * Copyright (c) 2007 embedded brains GmbH & Co. KG
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#ifndef _MPC83XX_SPIDRV_H
36#define _MPC83XX_SPIDRV_H
37
38#include <mpc83xx/mpc83xx.h>
39#include <rtems/libi2c.h>
40#include <rtems/irq.h>
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46typedef struct mpc83xx_spi_softc {
47 m83xxSPIRegisters_t *reg_ptr;
48 int initialized;
49 rtems_irq_number irq_number;
50 uint32_t base_frq; /* input frq for baud rate divider */
51 rtems_id irq_sema_id;
52 uint32_t curr_addr; /* current spi address */
53 uint32_t idle_char;
54 uint8_t bytes_per_char;
55 uint8_t bit_shift;
57
58typedef struct {
59 rtems_libi2c_bus_t bus_desc;
62
63/*=========================================================================*\
64| Function: |
65\*-------------------------------------------------------------------------*/
66rtems_status_code mpc83xx_spi_init
67(
68/*-------------------------------------------------------------------------*\
69| Purpose: |
70| initialize the driver |
71+---------------------------------------------------------------------------+
72| Input Parameters: |
73\*-------------------------------------------------------------------------*/
74 rtems_libi2c_bus_t *bh /* bus specifier structure */
75 );
76/*-------------------------------------------------------------------------*\
77| Return Value: |
78| o = ok or error code |
79\*=========================================================================*/
80
81/*=========================================================================*\
82| Function: |
83\*-------------------------------------------------------------------------*/
84int mpc83xx_spi_read_write_bytes
85(
86/*-------------------------------------------------------------------------*\
87| Purpose: |
88| transmit/receive some bytes from SPI device |
89+---------------------------------------------------------------------------+
90| Input Parameters: |
91\*-------------------------------------------------------------------------*/
92 rtems_libi2c_bus_t *bh, /* bus specifier structure */
93 unsigned char *rbuf, /* buffer to store bytes */
94 const unsigned char *tbuf, /* buffer to send bytes */
95 int len /* number of bytes to transceive */
96 );
97/*-------------------------------------------------------------------------*\
98| Return Value: |
99| number of bytes received or (negative) error code |
100\*=========================================================================*/
101
102/*=========================================================================*\
103| Function: |
104\*-------------------------------------------------------------------------*/
105int mpc83xx_spi_read_bytes
106(
107/*-------------------------------------------------------------------------*\
108| Purpose: |
109| receive some bytes from SPI device |
110+---------------------------------------------------------------------------+
111| Input Parameters: |
112\*-------------------------------------------------------------------------*/
113 rtems_libi2c_bus_t *bh, /* bus specifier structure */
114 unsigned char *buf, /* buffer to store bytes */
115 int len /* number of bytes to receive */
116 );
117/*-------------------------------------------------------------------------*\
118| Return Value: |
119| number of bytes received or (negative) error code |
120\*=========================================================================*/
121
122/*=========================================================================*\
123| Function: |
124\*-------------------------------------------------------------------------*/
125int mpc83xx_spi_write_bytes
126(
127/*-------------------------------------------------------------------------*\
128| Purpose: |
129| send some bytes to SPI device |
130+---------------------------------------------------------------------------+
131| Input Parameters: |
132\*-------------------------------------------------------------------------*/
133 rtems_libi2c_bus_t *bh, /* bus specifier structure */
134 unsigned char *buf, /* buffer to send */
135 int len /* number of bytes to send */
136
137 );
138/*-------------------------------------------------------------------------*\
139| Return Value: |
140| number of bytes sent or (negative) error code |
141\*=========================================================================*/
142
143/*=========================================================================*\
144| Function: |
145\*-------------------------------------------------------------------------*/
146rtems_status_code mpc83xx_spi_set_tfr_mode
147(
148/*-------------------------------------------------------------------------*\
149| Purpose: |
150| set SPI to desired baudrate/clock mode/character mode |
151+---------------------------------------------------------------------------+
152| Input Parameters: |
153\*-------------------------------------------------------------------------*/
154 rtems_libi2c_bus_t *bh, /* bus specifier structure */
155 const rtems_libi2c_tfr_mode_t *tfr_mode /* transfer mode info */
156 );
157/*-------------------------------------------------------------------------*\
158| Return Value: |
159| rtems_status_code |
160\*=========================================================================*/
161
162/*=========================================================================*\
163| Function: |
164\*-------------------------------------------------------------------------*/
165int mpc83xx_spi_ioctl
166(
167/*-------------------------------------------------------------------------*\
168| Purpose: |
169| perform selected ioctl function for SPI |
170+---------------------------------------------------------------------------+
171| Input Parameters: |
172\*-------------------------------------------------------------------------*/
173 rtems_libi2c_bus_t *bh, /* bus specifier structure */
174 int cmd, /* ioctl command code */
175 void *arg /* additional argument array */
176 );
177/*-------------------------------------------------------------------------*\
178| Return Value: |
179| rtems_status_code |
180\*=========================================================================*/
181
182#ifdef __cplusplus
183}
184#endif
185
186
187#endif /* _MPC83XX_I2CDRV_H */
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: mpc83xx.h:349
Definition: mpc83xx_spidrv.h:58
Definition: mpc83xx_spidrv.h:46
Definition: libi2c.h:163
Definition: libi2c.h:462