RTEMS  5.1
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
spi.h
1 /*===============================================================*\
2 | Project: RTEMS support for MPC8xx |
3 +-----------------------------------------------------------------+
4 | Copyright (c) 2009 |
5 | Embedded Brains GmbH |
6 | Obere Lagerstr. 30 |
7 | D-82178 Puchheim |
8 | Germany |
9 | rtems@embedded-brains.de |
10 +-----------------------------------------------------------------+
11 | The license and distribution terms for this file may be |
12 | found in the file LICENSE in this distribution or at |
13 | |
14 | http://www.rtems.org/license/LICENSE. |
15 | |
16 +-----------------------------------------------------------------+
17 | this file contains the MPC8xx SPI driver declarations |
18 \*===============================================================*/
19 #ifndef _M8XX_SPIDRV_H
20 #define _M8XX_SPIDRV_H
21 
22 #include <mpc8xx.h>
23 #include <rtems/libi2c.h>
24 #include <rtems/irq.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 typedef struct m8xx_spi_softc {
31  int initialized;
32  rtems_id irq_sema_id;
33  rtems_isr_entry old_handler;
37 
38 typedef struct {
39  rtems_libi2c_bus_t bus_desc;
40  m8xx_spi_softc_t softc;
42 
43 /*=========================================================================*\
44 | Function: |
45 \*-------------------------------------------------------------------------*/
46 rtems_status_code m8xx_spi_init
47 (
48 /*-------------------------------------------------------------------------*\
49 | Purpose: |
50 | initialize the driver |
51 +---------------------------------------------------------------------------+
52 | Input Parameters: |
53 \*-------------------------------------------------------------------------*/
54  rtems_libi2c_bus_t *bh /* bus specifier structure */
55  );
56 /*-------------------------------------------------------------------------*\
57 | Return Value: |
58 | o = ok or error code |
59 \*=========================================================================*/
60 
61 /*=========================================================================*\
62 | Function: |
63 \*-------------------------------------------------------------------------*/
64 int m8xx_spi_read_bytes
65 (
66 /*-------------------------------------------------------------------------*\
67 | Purpose: |
68 | receive some bytes from SPI device |
69 +---------------------------------------------------------------------------+
70 | Input Parameters: |
71 \*-------------------------------------------------------------------------*/
72  rtems_libi2c_bus_t *bh, /* bus specifier structure */
73  unsigned char *buf, /* buffer to store bytes */
74  int len /* number of bytes to receive */
75  );
76 /*-------------------------------------------------------------------------*\
77 | Return Value: |
78 | number of bytes received or (negative) error code |
79 \*=========================================================================*/
80 
81 /*=========================================================================*\
82 | Function: |
83 \*-------------------------------------------------------------------------*/
84 int m8xx_spi_write_bytes
85 (
86 /*-------------------------------------------------------------------------*\
87 | Purpose: |
88 | send some bytes to SPI device |
89 +---------------------------------------------------------------------------+
90 | Input Parameters: |
91 \*-------------------------------------------------------------------------*/
92  rtems_libi2c_bus_t *bh, /* bus specifier structure */
93  unsigned char *buf, /* buffer to send */
94  int len /* number of bytes to send */
95 
96  );
97 /*-------------------------------------------------------------------------*\
98 | Return Value: |
99 | number of bytes sent or (negative) error code |
100 \*=========================================================================*/
101 
102 /*=========================================================================*\
103 | Function: |
104 \*-------------------------------------------------------------------------*/
105 rtems_status_code m8xx_spi_set_tfr_mode
106 (
107 /*-------------------------------------------------------------------------*\
108 | Purpose: |
109 | set SPI to desired baudrate/clock mode/character mode |
110 +---------------------------------------------------------------------------+
111 | Input Parameters: |
112 \*-------------------------------------------------------------------------*/
113  rtems_libi2c_bus_t *bh, /* bus specifier structure */
114  const rtems_libi2c_tfr_mode_t *tfr_mode /* transfer mode info */
115  );
116 /*-------------------------------------------------------------------------*\
117 | Return Value: |
118 | rtems_status_code |
119 \*=========================================================================*/
120 
121 /*=========================================================================*\
122 | Function: |
123 \*-------------------------------------------------------------------------*/
124 int m8xx_spi_ioctl
125 (
126 /*-------------------------------------------------------------------------*\
127 | Purpose: |
128 | perform selected ioctl function for SPI |
129 +---------------------------------------------------------------------------+
130 | Input Parameters: |
131 \*-------------------------------------------------------------------------*/
132  rtems_libi2c_bus_t *bh, /* bus specifier structure */
133  int cmd, /* ioctl command code */
134  void *arg /* additional argument array */
135  );
136 /*-------------------------------------------------------------------------*\
137 | Return Value: |
138 | rtems_status_code |
139 \*=========================================================================*/
140 
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 
146 #endif /* _M8XX_SPIDRV_H */
Definition: spi.h:30
Definition: libi2c.h:162
rtems_status_code
Classic API Status.
Definition: status.h:43
Definition: libi2c.h:462
Definition: mpc8xx.h:683
Definition: spi.h:38
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:83
Legacy I2C Library.