![]() |
|
|||
File indexing completed on 2025-05-11 08:23:53
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /* 0004 * RTEMS support for MPC83xx 0005 * 0006 * This file contains the MPC83xx SPI driver declarations. 0007 * NOTE: This driver has the same API as a I2C driver. 0008 */ 0009 0010 /* 0011 * Copyright (c) 2007 embedded brains GmbH & Co. KG 0012 * 0013 * Redistribution and use in source and binary forms, with or without 0014 * modification, are permitted provided that the following conditions 0015 * are met: 0016 * 1. Redistributions of source code must retain the above copyright 0017 * notice, this list of conditions and the following disclaimer. 0018 * 2. Redistributions in binary form must reproduce the above copyright 0019 * notice, this list of conditions and the following disclaimer in the 0020 * documentation and/or other materials provided with the distribution. 0021 * 0022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0023 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0025 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0026 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0027 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0028 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0029 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0030 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0031 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0032 * POSSIBILITY OF SUCH DAMAGE. 0033 */ 0034 0035 #ifndef _MPC83XX_SPIDRV_H 0036 #define _MPC83XX_SPIDRV_H 0037 0038 #include <mpc83xx/mpc83xx.h> 0039 #include <rtems/libi2c.h> 0040 #include <rtems/irq.h> 0041 0042 #ifdef __cplusplus 0043 extern "C" { 0044 #endif 0045 0046 typedef struct mpc83xx_spi_softc { 0047 m83xxSPIRegisters_t *reg_ptr; 0048 int initialized; 0049 rtems_irq_number irq_number; 0050 uint32_t base_frq; /* input frq for baud rate divider */ 0051 rtems_id irq_sema_id; 0052 uint32_t curr_addr; /* current spi address */ 0053 uint32_t idle_char; 0054 uint8_t bytes_per_char; 0055 uint8_t bit_shift; 0056 } mpc83xx_spi_softc_t ; 0057 0058 typedef struct { 0059 rtems_libi2c_bus_t bus_desc; 0060 mpc83xx_spi_softc_t softc; 0061 } mpc83xx_spi_desc_t; 0062 0063 /*=========================================================================*\ 0064 | Function: | 0065 \*-------------------------------------------------------------------------*/ 0066 rtems_status_code mpc83xx_spi_init 0067 ( 0068 /*-------------------------------------------------------------------------*\ 0069 | Purpose: | 0070 | initialize the driver | 0071 +---------------------------------------------------------------------------+ 0072 | Input Parameters: | 0073 \*-------------------------------------------------------------------------*/ 0074 rtems_libi2c_bus_t *bh /* bus specifier structure */ 0075 ); 0076 /*-------------------------------------------------------------------------*\ 0077 | Return Value: | 0078 | o = ok or error code | 0079 \*=========================================================================*/ 0080 0081 /*=========================================================================*\ 0082 | Function: | 0083 \*-------------------------------------------------------------------------*/ 0084 int mpc83xx_spi_read_write_bytes 0085 ( 0086 /*-------------------------------------------------------------------------*\ 0087 | Purpose: | 0088 | transmit/receive some bytes from SPI device | 0089 +---------------------------------------------------------------------------+ 0090 | Input Parameters: | 0091 \*-------------------------------------------------------------------------*/ 0092 rtems_libi2c_bus_t *bh, /* bus specifier structure */ 0093 unsigned char *rbuf, /* buffer to store bytes */ 0094 const unsigned char *tbuf, /* buffer to send bytes */ 0095 int len /* number of bytes to transceive */ 0096 ); 0097 /*-------------------------------------------------------------------------*\ 0098 | Return Value: | 0099 | number of bytes received or (negative) error code | 0100 \*=========================================================================*/ 0101 0102 /*=========================================================================*\ 0103 | Function: | 0104 \*-------------------------------------------------------------------------*/ 0105 int mpc83xx_spi_read_bytes 0106 ( 0107 /*-------------------------------------------------------------------------*\ 0108 | Purpose: | 0109 | receive some bytes from SPI device | 0110 +---------------------------------------------------------------------------+ 0111 | Input Parameters: | 0112 \*-------------------------------------------------------------------------*/ 0113 rtems_libi2c_bus_t *bh, /* bus specifier structure */ 0114 unsigned char *buf, /* buffer to store bytes */ 0115 int len /* number of bytes to receive */ 0116 ); 0117 /*-------------------------------------------------------------------------*\ 0118 | Return Value: | 0119 | number of bytes received or (negative) error code | 0120 \*=========================================================================*/ 0121 0122 /*=========================================================================*\ 0123 | Function: | 0124 \*-------------------------------------------------------------------------*/ 0125 int mpc83xx_spi_write_bytes 0126 ( 0127 /*-------------------------------------------------------------------------*\ 0128 | Purpose: | 0129 | send some bytes to SPI device | 0130 +---------------------------------------------------------------------------+ 0131 | Input Parameters: | 0132 \*-------------------------------------------------------------------------*/ 0133 rtems_libi2c_bus_t *bh, /* bus specifier structure */ 0134 unsigned char *buf, /* buffer to send */ 0135 int len /* number of bytes to send */ 0136 0137 ); 0138 /*-------------------------------------------------------------------------*\ 0139 | Return Value: | 0140 | number of bytes sent or (negative) error code | 0141 \*=========================================================================*/ 0142 0143 /*=========================================================================*\ 0144 | Function: | 0145 \*-------------------------------------------------------------------------*/ 0146 rtems_status_code mpc83xx_spi_set_tfr_mode 0147 ( 0148 /*-------------------------------------------------------------------------*\ 0149 | Purpose: | 0150 | set SPI to desired baudrate/clock mode/character mode | 0151 +---------------------------------------------------------------------------+ 0152 | Input Parameters: | 0153 \*-------------------------------------------------------------------------*/ 0154 rtems_libi2c_bus_t *bh, /* bus specifier structure */ 0155 const rtems_libi2c_tfr_mode_t *tfr_mode /* transfer mode info */ 0156 ); 0157 /*-------------------------------------------------------------------------*\ 0158 | Return Value: | 0159 | rtems_status_code | 0160 \*=========================================================================*/ 0161 0162 /*=========================================================================*\ 0163 | Function: | 0164 \*-------------------------------------------------------------------------*/ 0165 int mpc83xx_spi_ioctl 0166 ( 0167 /*-------------------------------------------------------------------------*\ 0168 | Purpose: | 0169 | perform selected ioctl function for SPI | 0170 +---------------------------------------------------------------------------+ 0171 | Input Parameters: | 0172 \*-------------------------------------------------------------------------*/ 0173 rtems_libi2c_bus_t *bh, /* bus specifier structure */ 0174 int cmd, /* ioctl command code */ 0175 void *arg /* additional argument array */ 0176 ); 0177 /*-------------------------------------------------------------------------*\ 0178 | Return Value: | 0179 | rtems_status_code | 0180 \*=========================================================================*/ 0181 0182 #ifdef __cplusplus 0183 } 0184 #endif 0185 0186 0187 #endif /* _MPC83XX_I2CDRV_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |