]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo_bsp/ps7_cortexa9_0/include/xcanps_hw.h
Add back Zynq demo - this time using SDK V14.2.
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo_bsp / ps7_cortexa9_0 / include / xcanps_hw.h
1 /******************************************************************************
2 *
3 * (c) Copyright 2010-2013 Xilinx, Inc. All rights reserved.
4 *
5 * This file contains confidential and proprietary information of Xilinx, Inc.
6 * and is protected under U.S. and international copyright and other
7 * intellectual property laws.
8 *
9 * DISCLAIMER
10 * This disclaimer is not a license and does not grant any rights to the
11 * materials distributed herewith. Except as otherwise provided in a valid
12 * license issued to you by Xilinx, and to the maximum extent permitted by
13 * applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL
14 * FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,
15 * IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
16 * MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE;
17 * and (2) Xilinx shall not be liable (whether in contract or tort, including
18 * negligence, or under any other theory of liability) for any loss or damage
19 * of any kind or nature related to, arising under or in connection with these
20 * materials, including for any direct, or any indirect, special, incidental,
21 * or consequential loss or damage (including loss of data, profits, goodwill,
22 * or any type of loss or damage suffered as a result of any action brought by
23 * a third party) even if such damage or loss was reasonably foreseeable or
24 * Xilinx had been advised of the possibility of the same.
25 *
26 * CRITICAL APPLICATIONS
27 * Xilinx products are not designed or intended to be fail-safe, or for use in
28 * any application requiring fail-safe performance, such as life-support or
29 * safety devices or systems, Class III medical devices, nuclear facilities,
30 * applications related to the deployment of airbags, or any other applications
31 * that could lead to death, personal injury, or severe property or
32 * environmental damage (individually and collectively, "Critical
33 * Applications"). Customer assumes the sole risk and liability of any use of
34 * Xilinx products in Critical Applications, subject only to applicable laws
35 * and regulations governing limitations on product liability.
36 *
37 * THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE
38 * AT ALL TIMES.
39 *
40 ******************************************************************************/
41 /*****************************************************************************/
42 /**
43 *
44 * @file xcanps_hw.h
45 *
46 * This header file contains the identifiers and basic driver functions (or
47 * macros) that can be used to access the device. Other driver functions
48 * are defined in xcanps.h.
49 *
50 * <pre>
51 * MODIFICATION HISTORY:
52 *
53 * Ver   Who    Date     Changes
54 * ----- -----  -------- -----------------------------------------------
55 * 1.00a xd/sv  01/12/10 First release
56 * 1.01a sbs    12/27/11 Updated the Register/bit definitions
57 *                       Changed XCANPS_RXFWIR_RXFLL_MASK to XCANPS_WIR_FW_MASK
58 *                       Changed XCANPS_RXWIR_OFFSET to XCANPS_WIR_OFFSET
59 *                       Added XCANPS_IXR_TXFEMP_MASK for Tx Fifo Empty
60 *                       Changed XCANPS_IXR_RXFLL_MASK to
61 *                       XCANPS_IXR_RXFWMFLL_MASK
62 *                       Changed
63 *                       XCANPS_TXBUF_ID_OFFSET to XCANPS_TXHPB_ID_OFFSET
64 *                       XCANPS_TXBUF_DLC_OFFSET to XCANPS_TXHPB_DLC_OFFSET
65 *                       XCANPS_TXBUF_DW1_OFFSET  to XCANPS_TXHPB_DW1_OFFSET
66 *                       XCANPS_TXBUF_DW2_OFFSET  to XCANPS_TXHPB_DW2_OFFSET
67 * 1.02a adk   08/08/13  Updated for inclding the function prototype
68 * </pre>
69 *
70 ******************************************************************************/
71
72 #ifndef XCANPS_HW_H             /* prevent circular inclusions */
73 #define XCANPS_HW_H             /* by using protection macros */
74
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78
79
80 /***************************** Include Files *********************************/
81
82 #include "xil_types.h"
83 #include "xil_assert.h"
84 #include "xil_io.h"
85
86 /************************** Constant Definitions *****************************/
87
88 /** @name Register offsets for the CAN. Each register is 32 bits.
89  *  @{
90  */
91 #define XCANPS_SRR_OFFSET               0x00 /**< Software Reset Register */
92 #define XCANPS_MSR_OFFSET               0x04 /**< Mode Select Register */
93 #define XCANPS_BRPR_OFFSET              0x08 /**< Baud Rate Prescaler */
94 #define XCANPS_BTR_OFFSET               0x0C /**< Bit Timing Register */
95 #define XCANPS_ECR_OFFSET               0x10 /**< Error Counter Register */
96 #define XCANPS_ESR_OFFSET               0x14 /**< Error Status Register */
97 #define XCANPS_SR_OFFSET                0x18 /**< Status Register */
98
99 #define XCANPS_ISR_OFFSET               0x1C /**< Interrupt Status Register */
100 #define XCANPS_IER_OFFSET               0x20 /**< Interrupt Enable Register */
101 #define XCANPS_ICR_OFFSET               0x24 /**< Interrupt Clear Register */
102 #define XCANPS_TCR_OFFSET               0x28 /**< Timestamp Control Register */
103 #define XCANPS_WIR_OFFSET               0x2C /**< Watermark Interrupt Reg */
104
105 #define XCANPS_TXFIFO_ID_OFFSET         0x30 /**< TX FIFO ID */
106 #define XCANPS_TXFIFO_DLC_OFFSET        0x34 /**< TX FIFO DLC */
107 #define XCANPS_TXFIFO_DW1_OFFSET        0x38 /**< TX FIFO Data Word 1 */
108 #define XCANPS_TXFIFO_DW2_OFFSET        0x3C /**< TX FIFO Data Word 2 */
109
110 #define XCANPS_TXHPB_ID_OFFSET          0x40 /**< TX High Priority Buffer ID */
111 #define XCANPS_TXHPB_DLC_OFFSET         0x44 /**< TX High Priority Buffer DLC */
112 #define XCANPS_TXHPB_DW1_OFFSET         0x48 /**< TX High Priority Buf Data 1 */
113 #define XCANPS_TXHPB_DW2_OFFSET         0x4C /**< TX High Priority Buf Data Word 2 */
114
115 #define XCANPS_RXFIFO_ID_OFFSET         0x50 /**< RX FIFO ID */
116 #define XCANPS_RXFIFO_DLC_OFFSET        0x54 /**< RX FIFO DLC */
117 #define XCANPS_RXFIFO_DW1_OFFSET        0x58 /**< RX FIFO Data Word 1 */
118 #define XCANPS_RXFIFO_DW2_OFFSET        0x5C /**< RX FIFO Data Word 2 */
119
120 #define XCANPS_AFR_OFFSET               0x60 /**< Acceptance Filter Register */
121 #define XCANPS_AFMR1_OFFSET             0x64 /**< Acceptance Filter Mask 1 */
122 #define XCANPS_AFIR1_OFFSET             0x68 /**< Acceptance Filter ID  1 */
123 #define XCANPS_AFMR2_OFFSET             0x6C /**< Acceptance Filter Mask  2 */
124 #define XCANPS_AFIR2_OFFSET             0x70 /**< Acceptance Filter ID 2 */
125 #define XCANPS_AFMR3_OFFSET             0x74 /**< Acceptance Filter Mask 3 */
126 #define XCANPS_AFIR3_OFFSET             0x78 /**< Acceptance Filter ID 3 */
127 #define XCANPS_AFMR4_OFFSET             0x7C /**< Acceptance Filter Mask  4 */
128 #define XCANPS_AFIR4_OFFSET             0x80 /**< Acceptance Filter ID 4 */
129 /* @} */
130
131 /** @name Software Reset Register (SRR) Bit Definitions and Masks
132  *  @{
133  */
134 #define XCANPS_SRR_CEN_MASK     0x00000002  /**< Can Enable */
135 #define XCANPS_SRR_SRST_MASK    0x00000001  /**< Reset */
136 /* @} */
137
138 /** @name Mode Select Register (MSR) Bit Definitions and Masks
139  *  @{
140  */
141 #define XCANPS_MSR_SNOOP_MASK   0x00000004 /**< Snoop Mode Select */
142 #define XCANPS_MSR_LBACK_MASK   0x00000002 /**< Loop Back Mode Select */
143 #define XCANPS_MSR_SLEEP_MASK   0x00000001 /**< Sleep Mode Select */
144 /* @} */
145
146 /** @name Baud Rate Prescaler register (BRPR) Bit Definitions and Masks
147  *  @{
148  */
149 #define XCANPS_BRPR_BRP_MASK    0x000000FF /**< Baud Rate Prescaler */
150 /* @} */
151
152 /** @name Bit Timing Register (BTR) Bit Definitions and Masks
153  *  @{
154  */
155 #define XCANPS_BTR_SJW_MASK     0x00000180 /**< Synchronization Jump Width */
156 #define XCANPS_BTR_SJW_SHIFT    7
157 #define XCANPS_BTR_TS2_MASK     0x00000070 /**< Time Segment 2 */
158 #define XCANPS_BTR_TS2_SHIFT    4
159 #define XCANPS_BTR_TS1_MASK     0x0000000F /**< Time Segment 1 */
160 /* @} */
161
162 /** @name Error Counter Register (ECR) Bit Definitions and Masks
163  *  @{
164  */
165 #define XCANPS_ECR_REC_MASK     0x0000FF00 /**< Receive Error Counter */
166 #define XCANPS_ECR_REC_SHIFT    8
167 #define XCANPS_ECR_TEC_MASK     0x000000FF /**< Transmit Error Counter */
168 /* @} */
169
170 /** @name Error Status Register (ESR) Bit Definitions and Masks
171  *  @{
172  */
173 #define XCANPS_ESR_ACKER_MASK   0x00000010 /**< ACK Error */
174 #define XCANPS_ESR_BERR_MASK    0x00000008 /**< Bit Error */
175 #define XCANPS_ESR_STER_MASK    0x00000004 /**< Stuff Error */
176 #define XCANPS_ESR_FMER_MASK    0x00000002 /**< Form Error */
177 #define XCANPS_ESR_CRCER_MASK   0x00000001 /**< CRC Error */
178 /* @} */
179
180 /** @name Status Register (SR) Bit Definitions and Masks
181  *  @{
182  */
183 #define XCANPS_SR_SNOOP_MASK    0x00001000 /**< Snoop Mask */
184 #define XCANPS_SR_ACFBSY_MASK   0x00000800 /**< Acceptance Filter busy */
185 #define XCANPS_SR_TXFLL_MASK    0x00000400 /**< TX FIFO is full */
186 #define XCANPS_SR_TXBFLL_MASK   0x00000200 /**< TX High Priority Buffer full */
187 #define XCANPS_SR_ESTAT_MASK    0x00000180 /**< Error Status */
188 #define XCANPS_SR_ESTAT_SHIFT   7
189 #define XCANPS_SR_ERRWRN_MASK   0x00000040 /**< Error Warning */
190 #define XCANPS_SR_BBSY_MASK     0x00000020 /**< Bus Busy */
191 #define XCANPS_SR_BIDLE_MASK    0x00000010 /**< Bus Idle */
192 #define XCANPS_SR_NORMAL_MASK   0x00000008 /**< Normal Mode */
193 #define XCANPS_SR_SLEEP_MASK    0x00000004 /**< Sleep Mode */
194 #define XCANPS_SR_LBACK_MASK    0x00000002 /**< Loop Back Mode */
195 #define XCANPS_SR_CONFIG_MASK   0x00000001 /**< Configuration Mode */
196 /* @} */
197
198 /** @name Interrupt Status/Enable/Clear Register Bit Definitions and Masks
199  *  @{
200  */
201 #define XCANPS_IXR_TXFEMP_MASK   0x00004000 /**< Tx Fifo Empty Interrupt */
202 #define XCANPS_IXR_TXFWMEMP_MASK 0x00002000 /**< Tx Fifo Watermark Empty */
203 #define XCANPS_IXR_RXFWMFLL_MASK 0x00001000 /**< Rx FIFO Watermark Full */
204 #define XCANPS_IXR_WKUP_MASK    0x00000800 /**< Wake up Interrupt */
205 #define XCANPS_IXR_SLP_MASK     0x00000400 /**< Sleep Interrupt */
206 #define XCANPS_IXR_BSOFF_MASK   0x00000200 /**< Bus Off Interrupt */
207 #define XCANPS_IXR_ERROR_MASK   0x00000100 /**< Error Interrupt */
208 #define XCANPS_IXR_RXNEMP_MASK  0x00000080 /**< RX FIFO Not Empty Interrupt */
209 #define XCANPS_IXR_RXOFLW_MASK  0x00000040 /**< RX FIFO Overflow Interrupt */
210 #define XCANPS_IXR_RXUFLW_MASK  0x00000020 /**< RX FIFO Underflow Interrupt */
211 #define XCANPS_IXR_RXOK_MASK    0x00000010 /**< New Message Received Intr */
212 #define XCANPS_IXR_TXBFLL_MASK  0x00000008 /**< TX High Priority Buf Full */
213 #define XCANPS_IXR_TXFLL_MASK   0x00000004 /**< TX FIFO Full Interrupt */
214 #define XCANPS_IXR_TXOK_MASK    0x00000002 /**< TX Successful Interrupt */
215 #define XCANPS_IXR_ARBLST_MASK  0x00000001 /**< Arbitration Lost Interrupt */
216 #define XCANPS_IXR_ALL          (XCANPS_IXR_RXFWMFLL_MASK | \
217                                 XCANPS_IXR_WKUP_MASK   | \
218                                 XCANPS_IXR_SLP_MASK     | \
219                                 XCANPS_IXR_BSOFF_MASK  | \
220                                 XCANPS_IXR_ERROR_MASK  | \
221                                 XCANPS_IXR_RXNEMP_MASK | \
222                                 XCANPS_IXR_RXOFLW_MASK | \
223                                 XCANPS_IXR_RXUFLW_MASK | \
224                                 XCANPS_IXR_RXOK_MASK   | \
225                                 XCANPS_IXR_TXBFLL_MASK | \
226                                 XCANPS_IXR_TXFLL_MASK  | \
227                                 XCANPS_IXR_TXOK_MASK   | \
228                                 XCANPS_IXR_ARBLST_MASK)
229 /* @} */
230
231 /** @name CAN Timestamp Control Register (TCR) Bit Definitions and Masks
232  *  @{
233  */
234 #define XCANPS_TCR_CTS_MASK     0x00000001 /**< Clear Timestamp counter mask */
235 /* @} */
236
237 /** @name CAN Watermark Register (WIR) Bit Definitions and Masks
238  *  @{
239  */
240 #define XCANPS_WIR_FW_MASK      0x0000003F /**< Rx Full Threshold mask */
241 #define XCANPS_WIR_EW_MASK      0x00003F00 /**< Tx Empty Threshold mask */
242 #define XCANPS_WIR_EW_SHIFT     0x00000008 /**< Tx Empty Threshold shift */
243
244 /* @} */
245
246 /** @name CAN Frame Identifier (TX High Priority Buffer/TX/RX/Acceptance Filter
247                                 Mask/Acceptance Filter ID)
248  *  @{
249  */
250 #define XCANPS_IDR_ID1_MASK     0xFFE00000 /**< Standard Messg Identifier */
251 #define XCANPS_IDR_ID1_SHIFT    21
252 #define XCANPS_IDR_SRR_MASK     0x00100000 /**< Substitute Remote TX Req */
253 #define XCANPS_IDR_SRR_SHIFT    20
254 #define XCANPS_IDR_IDE_MASK     0x00080000 /**< Identifier Extension */
255 #define XCANPS_IDR_IDE_SHIFT    19
256 #define XCANPS_IDR_ID2_MASK     0x0007FFFE /**< Extended Message Ident */
257 #define XCANPS_IDR_ID2_SHIFT    1
258 #define XCANPS_IDR_RTR_MASK     0x00000001 /**< Remote TX Request */
259 /* @} */
260
261 /** @name CAN Frame Data Length Code (TX High Priority Buffer/TX/RX)
262  *  @{
263  */
264 #define XCANPS_DLCR_DLC_MASK     0xF0000000     /**< Data Length Code */
265 #define XCANPS_DLCR_DLC_SHIFT    28
266 #define XCANPS_DLCR_TIMESTAMP_MASK 0x0000FFFF   /**< Timestamp Mask (Rx only) */
267
268 /* @} */
269
270 /** @name CAN Frame Data Word 1 (TX High Priority Buffer/TX/RX)
271  *  @{
272  */
273 #define XCANPS_DW1R_DB0_MASK    0xFF000000 /**< Data Byte 0 */
274 #define XCANPS_DW1R_DB0_SHIFT   24
275 #define XCANPS_DW1R_DB1_MASK    0x00FF0000 /**< Data Byte 1 */
276 #define XCANPS_DW1R_DB1_SHIFT   16
277 #define XCANPS_DW1R_DB2_MASK    0x0000FF00 /**< Data Byte 2 */
278 #define XCANPS_DW1R_DB2_SHIFT   8
279 #define XCANPS_DW1R_DB3_MASK    0x000000FF /**< Data Byte 3 */
280 /* @} */
281
282 /** @name CAN Frame Data Word 2 (TX High Priority Buffer/TX/RX)
283  *  @{
284  */
285 #define XCANPS_DW2R_DB4_MASK    0xFF000000 /**< Data Byte 4 */
286 #define XCANPS_DW2R_DB4_SHIFT   24
287 #define XCANPS_DW2R_DB5_MASK    0x00FF0000 /**< Data Byte 5 */
288 #define XCANPS_DW2R_DB5_SHIFT   16
289 #define XCANPS_DW2R_DB6_MASK    0x0000FF00 /**< Data Byte 6 */
290 #define XCANPS_DW2R_DB6_SHIFT   8
291 #define XCANPS_DW2R_DB7_MASK    0x000000FF /**< Data Byte 7 */
292 /* @} */
293
294 /** @name Acceptance Filter Register (AFR) Bit Definitions and Masks
295  *  @{
296  */
297 #define XCANPS_AFR_UAF4_MASK    0x00000008 /**< Use Acceptance Filter No.4 */
298 #define XCANPS_AFR_UAF3_MASK    0x00000004 /**< Use Acceptance Filter No.3 */
299 #define XCANPS_AFR_UAF2_MASK    0x00000002 /**< Use Acceptance Filter No.2 */
300 #define XCANPS_AFR_UAF1_MASK    0x00000001 /**< Use Acceptance Filter No.1 */
301 #define XCANPS_AFR_UAF_ALL_MASK (XCANPS_AFR_UAF4_MASK | \
302                                         XCANPS_AFR_UAF3_MASK | \
303                                         XCANPS_AFR_UAF2_MASK | \
304                                         XCANPS_AFR_UAF1_MASK)
305 /* @} */
306
307 /** @name CAN frame length constants
308  *  @{
309  */
310 #define XCANPS_MAX_FRAME_SIZE 16 /**< Maximum CAN frame length in bytes */
311 /* @} */
312
313 /* For backwards compatibilty */
314 #define XCANPS_TXBUF_ID_OFFSET   XCANPS_TXHPB_ID_OFFSET
315 #define XCANPS_TXBUF_DLC_OFFSET  XCANPS_TXHPB_DLC_OFFSET
316 #define XCANPS_TXBUF_DW1_OFFSET  XCANPS_TXHPB_DW1_OFFSET
317 #define XCANPS_TXBUF_DW2_OFFSET  XCANPS_TXHPB_DW2_OFFSET
318
319 #define XCANPS_RXFWIR_RXFLL_MASK XCANPS_WIR_FW_MASK
320 #define XCANPS_RXWIR_OFFSET      XCANPS_WIR_OFFSET
321 #define XCANPS_IXR_RXFLL_MASK    XCANPS_IXR_RXFWMFLL_MASK
322
323
324
325
326 /**************************** Type Definitions *******************************/
327
328 /***************** Macros (Inline Functions) Definitions *********************/
329
330 /****************************************************************************/
331 /**
332 *
333 * This macro reads the given register.
334 *
335 * @param        BaseAddr is the base address of the device.
336 * @param        RegOffset is the register offset to be read.
337 *
338 * @return       The 32-bit value of the register
339 *
340 * @note         None.
341 *
342 *****************************************************************************/
343 #define XCanPs_ReadReg(BaseAddr, RegOffset) \
344                 Xil_In32((BaseAddr) + (RegOffset))
345
346
347 /****************************************************************************/
348 /**
349 *
350 * This macro writes the given register.
351 *
352 * @param        BaseAddr is the base address of the device.
353 * @param        RegOffset is the register offset to be written.
354 * @param        Data is the 32-bit value to write to the register.
355 *
356 * @return       None.
357 *
358 * @note         None.
359 *
360 *****************************************************************************/
361 #define XCanPs_WriteReg(BaseAddr, RegOffset, Data) \
362                 Xil_Out32((BaseAddr) + (RegOffset), (Data))
363
364 /************************** Function Prototypes ******************************/
365 /*
366  * Perform reset operation to the CanPs interface
367  */
368 void XCanPs_ResetHw(u32 BaseAddr);
369
370 #ifdef __cplusplus
371 }
372 #endif
373
374 #endif /* end of protection macro */
375