1 | /****************************************************************************** |
---|
2 | * |
---|
3 | * Copyright 2013 Altera Corporation. All Rights Reserved. |
---|
4 | * |
---|
5 | * Redistribution and use in source and binary forms, with or without |
---|
6 | * modification, are permitted provided that the following conditions are met: |
---|
7 | * |
---|
8 | * 1. Redistributions of source code must retain the above copyright notice, |
---|
9 | * this list of conditions and the following disclaimer. |
---|
10 | * |
---|
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
---|
12 | * this list of conditions and the following disclaimer in the documentation |
---|
13 | * and/or other materials provided with the distribution. |
---|
14 | * |
---|
15 | * 3. The name of the author may not be used to endorse or promote products |
---|
16 | * derived from this software without specific prior written permission. |
---|
17 | * |
---|
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR |
---|
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO |
---|
21 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
---|
23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
---|
26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
---|
27 | * OF SUCH DAMAGE. |
---|
28 | * |
---|
29 | ******************************************************************************/ |
---|
30 | |
---|
31 | #ifndef __HWLIB_H__ |
---|
32 | #define __HWLIB_H__ |
---|
33 | |
---|
34 | #ifdef __cplusplus |
---|
35 | #include <cstddef> |
---|
36 | #include <cstdbool> |
---|
37 | #include <cstdint> |
---|
38 | #else /* __cplusplus */ |
---|
39 | #include <stddef.h> |
---|
40 | #include <stdbool.h> |
---|
41 | #include <stdint.h> |
---|
42 | #endif /* __cplusplus */ |
---|
43 | |
---|
44 | #include "alt_hwlibs_ver.h" |
---|
45 | |
---|
46 | #ifdef __cplusplus |
---|
47 | extern "C" |
---|
48 | { |
---|
49 | #endif /* __cplusplus */ |
---|
50 | |
---|
51 | /*! |
---|
52 | * The type definition for status codes returned by the HWLIB. |
---|
53 | */ |
---|
54 | typedef int32_t ALT_STATUS_CODE; |
---|
55 | |
---|
56 | /*! Definitions of status codes returned by the HWLIB. */ |
---|
57 | |
---|
58 | /*! The operation was successful. */ |
---|
59 | #define ALT_E_SUCCESS 0 |
---|
60 | |
---|
61 | /*! The operation failed. */ |
---|
62 | #define ALT_E_ERROR (-1) |
---|
63 | /*! FPGA configuration error detected.*/ |
---|
64 | #define ALT_E_FPGA_CFG (-2) |
---|
65 | /*! FPGA CRC error detected. */ |
---|
66 | #define ALT_E_FPGA_CRC (-3) |
---|
67 | /*! An error occurred on the FPGA configuration bitstream input source. */ |
---|
68 | #define ALT_E_FPGA_CFG_STM (-4) |
---|
69 | /*! The FPGA is powered off. */ |
---|
70 | #define ALT_E_FPGA_PWR_OFF (-5) |
---|
71 | /*! The SoC does not currently control the FPGA. */ |
---|
72 | #define ALT_E_FPGA_NO_SOC_CTRL (-6) |
---|
73 | /*! The FPGA is not in USER mode. */ |
---|
74 | #define ALT_E_FPGA_NOT_USER_MODE (-7) |
---|
75 | /*! An argument violates a range constraint. */ |
---|
76 | #define ALT_E_ARG_RANGE (-8) |
---|
77 | /*! A bad argument value was passed. */ |
---|
78 | #define ALT_E_BAD_ARG (-9) |
---|
79 | /*! The operation is invalid or illegal. */ |
---|
80 | #define ALT_E_BAD_OPERATION (-10) |
---|
81 | /*! An invalid option was selected. */ |
---|
82 | #define ALT_E_INV_OPTION (-11) |
---|
83 | /*! An operation or response timeout period expired. */ |
---|
84 | #define ALT_E_TMO (-12) |
---|
85 | /*! The argument value is reserved or unavailable. */ |
---|
86 | #define ALT_E_RESERVED (-13) |
---|
87 | /*! A clock is not enabled or violates an operational constraint. */ |
---|
88 | #define ALT_E_BAD_CLK (-14) |
---|
89 | /*! The version ID is invalid. */ |
---|
90 | #define ALT_E_BAD_VERSION (-15) |
---|
91 | /*! The buffer does not contain enough free space for the operation. */ |
---|
92 | #define ALT_E_BUF_OVF (-20) |
---|
93 | |
---|
94 | /*! |
---|
95 | * Indicates a FALSE condition. |
---|
96 | */ |
---|
97 | #define ALT_E_FALSE (0) |
---|
98 | /*! |
---|
99 | * Indicates a TRUE condition. |
---|
100 | */ |
---|
101 | #define ALT_E_TRUE (1) |
---|
102 | |
---|
103 | /* Note, additional positive status codes may be defined to return |
---|
104 | * a TRUE condition with additional information */ |
---|
105 | |
---|
106 | |
---|
107 | /* Some other useful definitions */ |
---|
108 | |
---|
109 | /*! |
---|
110 | * Specifies the current major and minor revision of the HWLibs. The |
---|
111 | * MS four decimal digits specify the Altera ACDS release number, the |
---|
112 | * LS two decimal digits specify minor revisions of the HWLibs, if any. |
---|
113 | * |
---|
114 | * A typical use is: |
---|
115 | * \code |
---|
116 | * #if ALTERA_HWLIBS_VERSION_CODE >= ALT_HWLIBS_VERSION(13, 1, 0) |
---|
117 | * \endcode |
---|
118 | * for a dependency on the major or minor ACDS revision |
---|
119 | * or |
---|
120 | * \code |
---|
121 | * #if ALTERA_HWLIBS_VERSION_CODE == ALT_HWLIBS_VERSION(13, 0, 12) |
---|
122 | * \endcode |
---|
123 | * for a dependency on the hwlibs revision |
---|
124 | * |
---|
125 | */ |
---|
126 | #define ALT_HWLIBS_VERSION(a,b,c) (((a)*10000)+((b)*100)+(c)) |
---|
127 | |
---|
128 | #define ALTERA_HWLIBS_VERSION_CODE ALT_HWLIBS_VERSION(ALTERA_ACDS_MAJOR_REV, \ |
---|
129 | ALTERA_ACDS_MINOR_REV, ALTERA_HWLIBS_REV) |
---|
130 | |
---|
131 | /*! |
---|
132 | * Allow some parts of the documentation to be hidden by setting to zero |
---|
133 | */ |
---|
134 | #define ALTERA_INTERNAL_ONLY_DOCS 1 |
---|
135 | |
---|
136 | |
---|
137 | /*! |
---|
138 | * Provide base address of MPU address space |
---|
139 | */ |
---|
140 | |
---|
141 | #ifndef ALT_HPS_ADDR |
---|
142 | #define ALT_HPS_ADDR 0 |
---|
143 | #endif |
---|
144 | |
---|
145 | /*! |
---|
146 | * These constants are sometimes useful: |
---|
147 | */ |
---|
148 | #define ALT_MILLISECS_IN_A_SEC 1000 |
---|
149 | #define ALT_MICROSECS_IN_A_SEC 1000000 |
---|
150 | #define ALT_NANOSECS_IN_A_SEC 1000000000 |
---|
151 | |
---|
152 | #define ALT_TWO_TO_POW0 (1) |
---|
153 | #define ALT_TWO_TO_POW1 (1<<1) |
---|
154 | #define ALT_TWO_TO_POW2 (1<<2) |
---|
155 | #define ALT_TWO_TO_POW3 (1<<3) |
---|
156 | #define ALT_TWO_TO_POW4 (1<<4) |
---|
157 | #define ALT_TWO_TO_POW5 (1<<5) |
---|
158 | #define ALT_TWO_TO_POW6 (1<<6) |
---|
159 | #define ALT_TWO_TO_POW7 (1<<7) |
---|
160 | #define ALT_TWO_TO_POW8 (1<<8) |
---|
161 | #define ALT_TWO_TO_POW9 (1<<9) |
---|
162 | #define ALT_TWO_TO_POW10 (1<<10) |
---|
163 | #define ALT_TWO_TO_POW11 (1<<11) |
---|
164 | #define ALT_TWO_TO_POW12 (1<<12) |
---|
165 | #define ALT_TWO_TO_POW13 (1<<13) |
---|
166 | #define ALT_TWO_TO_POW14 (1<<14) |
---|
167 | #define ALT_TWO_TO_POW15 (1<<15) |
---|
168 | #define ALT_TWO_TO_POW16 (1<<16) |
---|
169 | #define ALT_TWO_TO_POW17 (1<<17) |
---|
170 | #define ALT_TWO_TO_POW18 (1<<18) |
---|
171 | #define ALT_TWO_TO_POW19 (1<<19) |
---|
172 | #define ALT_TWO_TO_POW20 (1<<20) |
---|
173 | #define ALT_TWO_TO_POW21 (1<<21) |
---|
174 | #define ALT_TWO_TO_POW22 (1<<22) |
---|
175 | #define ALT_TWO_TO_POW23 (1<<23) |
---|
176 | #define ALT_TWO_TO_POW24 (1<<24) |
---|
177 | #define ALT_TWO_TO_POW25 (1<<25) |
---|
178 | #define ALT_TWO_TO_POW26 (1<<26) |
---|
179 | #define ALT_TWO_TO_POW27 (1<<27) |
---|
180 | #define ALT_TWO_TO_POW28 (1<<28) |
---|
181 | #define ALT_TWO_TO_POW29 (1<<29) |
---|
182 | #define ALT_TWO_TO_POW30 (1<<30) |
---|
183 | #define ALT_TWO_TO_POW31 (1<<31) |
---|
184 | |
---|
185 | #ifdef __cplusplus |
---|
186 | } |
---|
187 | #endif /* __cplusplus */ |
---|
188 | #endif /* __HWLIB_H__ */ |
---|
189 | |
---|