source: svn/trunk/newcon3bcm2_21bu/magnum/basemodules/reg/breg_spi.h @ 32

Last change on this file since 32 was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 6.0 KB
Line 
1/***************************************************************************
2 *         Copyright (c) 2003-2011, Broadcom Corporation
3 *         All Rights Reserved
4 *         Confidential Property of Broadcom Corporation
5 *
6 *      THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *      AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *      EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: breg_spi.h $
11 * $brcm_Revision: Hydra_Software_Devel/10 $
12 * $brcm_Date: 1/11/11 7:01p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/basemodules/reg/breg_spi.h $
19 *
20 * Hydra_Software_Devel/10   1/11/11 7:01p mbatchel
21 * SW35230-2053, SW35230-2702: Integrate SPI isr support for DTV.
22 *
23 * Hydra_Software_Devel/SW35230-2053/1   11/11/10 1:55p mbatchel
24 * SW35230-2053: Integrate SPI isr support for DTV.
25 *
26 * Hydra_Software_Devel/9   1/13/04 5:02p brianlee
27 * PR9268: Make write structures constant.
28 *
29 * Hydra_Software_Devel/8   9/11/03 5:06p brianlee
30 * Fixed SPI register interface function definitions.
31 *
32 * Hydra_Software_Devel/7   9/11/03 10:51a brianlee
33 * Fixed BREG_SPI_Read definition.
34 *
35 * Hydra_Software_Devel/6   8/29/03 10:30a marcusk
36 * Fixed BREG_SPI_Read definition.
37 *
38 * Hydra_Software_Devel/5   8/22/03 2:52p marcusk
39 * Updated with latest changes discussed in the UPG design review.
40 *
41 * Hydra_Software_Devel/4   3/31/03 1:20p marcusk
42 * Updated with comments on threadsafety
43 *
44 * Hydra_Software_Devel/3   3/31/03 10:32a marcusk
45 * Updated comments.
46 *
47 * Hydra_Software_Devel/2   3/10/03 2:39p marcusk
48 * Removed const keyword from read routines (copy paste error).
49 *
50 * Hydra_Software_Devel/1   3/5/03 5:13p marcusk
51 * Initial version.
52 *
53 ***************************************************************************/
54
55/*= Module Overview ********************************************************
56This module provides a standard abstraction API for accessing SPI registers.
57Several SPI busses may exist on a single platform. Some may be hardware based,
58while others software based (using GPIO pins). In order to hide the
59specific implementation of the SPI bus from a PortingInterface this SPI
60register access abstraction is used.
61
62---++++ SPI Register Handles
63Hardware and software SPI implementations must follow the defined function
64prototype definitions. All SPI PortingInterfaces supply the a function
65that initializes a standard BREG_SPI_Handle (and fills it with function
66pointers provided by the specific SPI PortingInterfaces implementation).
67Please refer to the specific SPI PortingInterface implementations for more
68details.
69
70An example of this type of function would be:
71
72<verbatim>
73BERR_Code BSPI_CreateSpiRegHandle( BSPI_Handle SpiHandle, BREG_SPI_Handle *pSpiRegHandle );
74</verbatim>
75
76This handle should be created during initialization and passed to the
77appropriate porting interfaces.  The porting interfaces in turn pass
78this handle to the abstract SPI functions when then call the appropriate
79SPI implementation though function pointers contained in the BREG_SPI_Handle.
80
81---++++ Handling ThreadSafe with SPI
82Since multiple modules (PortingInterface and otherwise) may be sharing the
83same SPI bus, any function calls to the modules in question must be serialized
84to prevent thread collisions.
85
86        1 All calls to the modules sharing the same SPI handle must be protected
87          through the use of a mutex.  This protection must be handled by the
88          upper level software (driver, middleware, etc).
89        2 Upper level software can create an additional layer between the SPI
90          RegisterInterface and the corresponding SPI PortingInterface instance
91          that implements the SPI register access.  In this layer a mutex is
92          used to protect all SPI accesses.  This could easily be done
93          using the BREG_SPI_Impl structure.
94***************************************************************************/
95
96#ifndef BREG_SPI_H
97#define BREG_SPI_H
98
99#ifdef __cplusplus
100extern "C" {
101#endif
102
103/*
104Summary:
105This is an opaque handle that is used for SPI read and write functions.
106*/
107typedef struct BREG_SPI_Impl *BREG_SPI_Handle;
108
109/*
110Summary:
111This function writes a programmable number of SPI registers.
112*/
113BERR_Code BREG_SPI_Write(
114                                        BREG_SPI_Handle spiHandle,              /* Device channel handle */
115                                        const uint8_t *pWriteData,              /* pointer to write memory location */
116                                        size_t length                                   /* size of *pWriteData  buffers (number of bytes to write ) */
117                                        );
118
119/*
120Summary:
121This function reads a programmable number of SPI registers.
122
123The SPI protocol always writes data out as it is reading data in.
124The incoming data is stored in pReadData while the data
125going out is sourced from pWriteData.
126*/
127BERR_Code BREG_SPI_Read(
128                                        BREG_SPI_Handle spiHandle,              /* Device channel handle */
129                                        const uint8_t *pWriteData,              /* pointer to memory location where data is to sent  */
130                                        uint8_t *pReadData,             /* pointer to memory location to store read data  */
131                                        size_t length                                   /* size of *pWriteData and *pReadData buffers (number of bytes to read + number of bytes to write) */
132                                        );
133
134/*
135Summary:
136This function writes a programmable number of SPI registers in isr.
137*/
138BERR_Code BREG_SPI_Write_isr(
139                                        BREG_SPI_Handle spiHandle,              /* Device channel handle */
140                                        const uint8_t *pWriteData,              /* pointer to write memory location */
141                                        size_t length                                   /* size of *pWriteData  buffers (number of bytes to write ) */
142                                        );
143
144/*
145Summary:
146This function reads a programmable number of SPI registers in isr.
147
148The SPI protocol always writes data out as it is reading data in.
149The incoming data is stored in pReadData while the data
150going out is sourced from pWriteData.
151*/
152BERR_Code BREG_SPI_Read_isr(
153                                        BREG_SPI_Handle spiHandle,              /* Device channel handle */
154                                        const uint8_t *pWriteData,              /* pointer to memory location where data is to sent  */
155                                        uint8_t *pReadData,             /* pointer to memory location to store read data  */
156                                        size_t length                                   /* size of *pWriteData and *pReadData buffers (number of bytes to read + number of bytes to write) */
157                                        );
158
159
160#ifdef __cplusplus
161}
162#endif
163 
164#endif
165/* End of File */
166
167
168
Note: See TracBrowser for help on using the repository browser.