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