Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/Pmods/Common/sw/spi_axi.h

raw symbols SCIP
1 /**************************************************************************//**
2 * @file spi.h
3 * @brief SPI header file.
4 * @author acozma ([email protected])
5 *
6 *******************************************************************************
7 * Copyright 2011(c) Analog Devices, Inc.
8 *
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
13 * - Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 * - Neither the name of Analog Devices, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 * - The use of this software may or may not infringe the patent rights
23 * of one or more patent holders. This license does not release you
24 * from the requirement that you obtain separate licenses from these
25 * patent holders to use this software.
26 * - Use of the software either in source or binary form, must be run
27 * on or directly connected to an Analog Devices Inc. component.
28 *
29 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED
30 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY
31 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
32 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34 * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 *******************************************************************************
41 * SVN Revision: $WCREV$
42 ******************************************************************************/
43
44 #ifndef __SPI__H__
45 #define __SPI_H__
46
47 /*****************************************************************************/
48 /***************************** Include Files *********************************/
49 /*****************************************************************************/
50 #include "system_config.h"
51 #include "xil_types.h"
52
53 #if(USE_PS7 == 0)
54 #define SPI_BASEADDR XPAR_AXI_SPI_0_BASEADDR
55
56 /*****************************************************************************/
57 /******************* SPI Registers Definitions *******************************/
58 /*****************************************************************************/
59 // Register address
60 #define SRR 0x40
61 #define SPICR 0x60
62 #define SPISR 0x64
63 #define SPIDTR 0x68
64 #define SPIDRR 0x6C
65 #define SPISSR 0x70
66 #define SPI_T_FIFO 0x74
67 #define SPI_R_FIFO 0x78
68 #define DGIER 0x1C
69 #define IPISR 0x20
70 #define IPIER 0x28
71
72 /*****************************************************************************/
73 /******************* SPI Registers Bits **************************************/
74 /*****************************************************************************/
75 // SPI Control Register (SPICR)
76 #define LSBFirst 9
77 #define MasterTranInh 8
78 #define ManualSlaveAssEn 7
79 #define RxFifoReset 6
80 #define TxFifoReset 5
81 #define CHPA 4
82 #define CPOL 3
83 #define Master 2
84 #define SPE 1
85 #define LOOP 0
86
87 // SPI Status Register (SPISR)
88 #define SlaveModeSel 5
89 #define MODF 4
90 #define TxFull 3
91 #define TxEmpty 2
92 #define RxFull 1
93 #define RxEmpty 0
94
95 // IP Interrupt Status Register
96 #define DDRNotEmpty 8
97 #define SlaveModeSel_int 7
98 #define TxFifoHalfEmpty 6
99 #define DDROverRun 5
100 #define DDRFull 4
101 #define DTRUnderRun 3
102 #define DTREmpty 2
103 #define SlaveMODF 1
104 #define MODF_int 0
105
106 /*****************************************************************************/
107 /************************ Functions Declarations *****************************/
108 /*****************************************************************************/
109 u32 SPI_Init_axi(u32 axiBaseAddr, char lsbFirst, char cpha, char cpol);
110 u32 SPI_TransferData_axi(u32 axiBaseAddr, char txSize, char* txBuf, char rxSize, char* rxBuf, char ssNo);
111 #endif
112 #endif /*__SPI_H__*/
113