1 |
61 |
zero_gravi |
// #################################################################################################
|
2 |
|
|
// # << NEORV32: neorv32_slink.h - Stream Link Interface HW Driver >> #
|
3 |
|
|
// # ********************************************************************************************* #
|
4 |
|
|
// # BSD 3-Clause License #
|
5 |
|
|
// # #
|
6 |
|
|
// # Copyright (c) 2021, Stephan Nolting. All rights reserved. #
|
7 |
|
|
// # #
|
8 |
|
|
// # Redistribution and use in source and binary forms, with or without modification, are #
|
9 |
|
|
// # permitted provided that the following conditions are met: #
|
10 |
|
|
// # #
|
11 |
|
|
// # 1. Redistributions of source code must retain the above copyright notice, this list of #
|
12 |
|
|
// # conditions and the following disclaimer. #
|
13 |
|
|
// # #
|
14 |
|
|
// # 2. Redistributions in binary form must reproduce the above copyright notice, this list of #
|
15 |
|
|
// # conditions and the following disclaimer in the documentation and/or other materials #
|
16 |
|
|
// # provided with the distribution. #
|
17 |
|
|
// # #
|
18 |
|
|
// # 3. Neither the name of the copyright holder nor the names of its contributors may be used to #
|
19 |
|
|
// # endorse or promote products derived from this software without specific prior written #
|
20 |
|
|
// # permission. #
|
21 |
|
|
// # #
|
22 |
|
|
// # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS #
|
23 |
|
|
// # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF #
|
24 |
|
|
// # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE #
|
25 |
|
|
// # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #
|
26 |
|
|
// # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
|
27 |
|
|
// # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED #
|
28 |
|
|
// # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING #
|
29 |
|
|
// # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED #
|
30 |
|
|
// # OF THE POSSIBILITY OF SUCH DAMAGE. #
|
31 |
|
|
// # ********************************************************************************************* #
|
32 |
|
|
// # The NEORV32 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
33 |
|
|
// #################################################################################################
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
/**********************************************************************//**
|
37 |
|
|
* @file neorv32_slink.h
|
38 |
|
|
* @author Stephan Nolting
|
39 |
|
|
* @brief Stream Link Interface HW driver header file.
|
40 |
|
|
**************************************************************************/
|
41 |
|
|
|
42 |
|
|
#ifndef neorv32_slink_h
|
43 |
|
|
#define neorv32_slink_h
|
44 |
|
|
|
45 |
|
|
// prototypes
|
46 |
|
|
int neorv32_slink_available(void);
|
47 |
|
|
void neorv32_slink_enable(void);
|
48 |
|
|
void neorv32_slink_disable(void);
|
49 |
65 |
zero_gravi |
void neorv32_slink_rx_irq_config(int link_id, int irq_en, int irq_type);
|
50 |
|
|
void neorv32_slink_tx_irq_config(int link_id, int irq_en, int irq_type);
|
51 |
61 |
zero_gravi |
int neorv32_slink_get_rx_num(void);
|
52 |
|
|
int neorv32_slink_get_tx_num(void);
|
53 |
|
|
int neorv32_slink_get_rx_depth(void);
|
54 |
|
|
int neorv32_slink_get_tx_depth(void);
|
55 |
62 |
zero_gravi |
int neorv32_slink_check_rx_half_full(int link_id);
|
56 |
|
|
int neorv32_slink_check_tx_half_full(int link_id);
|
57 |
61 |
zero_gravi |
// non-blocking transmit
|
58 |
|
|
int neorv32_slink_tx0_nonblocking(uint32_t tx_data);
|
59 |
|
|
int neorv32_slink_tx1_nonblocking(uint32_t tx_data);
|
60 |
|
|
int neorv32_slink_tx2_nonblocking(uint32_t tx_data);
|
61 |
|
|
int neorv32_slink_tx3_nonblocking(uint32_t tx_data);
|
62 |
|
|
int neorv32_slink_tx4_nonblocking(uint32_t tx_data);
|
63 |
|
|
int neorv32_slink_tx5_nonblocking(uint32_t tx_data);
|
64 |
|
|
int neorv32_slink_tx6_nonblocking(uint32_t tx_data);
|
65 |
|
|
int neorv32_slink_tx7_nonblocking(uint32_t tx_data);
|
66 |
|
|
// non-blocking receive
|
67 |
|
|
int neorv32_slink_rx0_nonblocking(uint32_t *rx_data);
|
68 |
|
|
int neorv32_slink_rx1_nonblocking(uint32_t *rx_data);
|
69 |
|
|
int neorv32_slink_rx2_nonblocking(uint32_t *rx_data);
|
70 |
|
|
int neorv32_slink_rx3_nonblocking(uint32_t *rx_data);
|
71 |
|
|
int neorv32_slink_rx4_nonblocking(uint32_t *rx_data);
|
72 |
|
|
int neorv32_slink_rx5_nonblocking(uint32_t *rx_data);
|
73 |
|
|
int neorv32_slink_rx6_nonblocking(uint32_t *rx_data);
|
74 |
|
|
int neorv32_slink_rx7_nonblocking(uint32_t *rx_data);
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
/**********************************************************************//**
|
78 |
|
|
* Write data to TX stream link 0 (blocking!)
|
79 |
|
|
*
|
80 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
81 |
|
|
*
|
82 |
|
|
* @param[in] tx_data Data to send to link.
|
83 |
|
|
**************************************************************************/
|
84 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_tx0_blocking(uint32_t tx_data) {
|
85 |
64 |
zero_gravi |
NEORV32_SLINK.DATA[0] = tx_data;
|
86 |
61 |
zero_gravi |
}
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
/**********************************************************************//**
|
90 |
|
|
* Write data to TX stream link 1 (blocking!)
|
91 |
|
|
*
|
92 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
93 |
|
|
*
|
94 |
|
|
* @param[in] tx_data Data to send to link.
|
95 |
|
|
**************************************************************************/
|
96 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_tx1_blocking(uint32_t tx_data) {
|
97 |
64 |
zero_gravi |
NEORV32_SLINK.DATA[1] = tx_data;
|
98 |
61 |
zero_gravi |
}
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
/**********************************************************************//**
|
102 |
|
|
* Write data to TX stream link 2 (blocking!)
|
103 |
|
|
*
|
104 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
105 |
|
|
*
|
106 |
|
|
* @param[in] tx_data Data to send to link.
|
107 |
|
|
**************************************************************************/
|
108 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_tx2_blocking(uint32_t tx_data) {
|
109 |
64 |
zero_gravi |
NEORV32_SLINK.DATA[2] = tx_data;
|
110 |
61 |
zero_gravi |
}
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
/**********************************************************************//**
|
114 |
|
|
* Write data to TX stream link 3 (blocking!)
|
115 |
|
|
*
|
116 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
117 |
|
|
*
|
118 |
|
|
* @param[in] tx_data Data to send to link.
|
119 |
|
|
**************************************************************************/
|
120 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_tx3_blocking(uint32_t tx_data) {
|
121 |
64 |
zero_gravi |
NEORV32_SLINK.DATA[3] = tx_data;
|
122 |
61 |
zero_gravi |
}
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
/**********************************************************************//**
|
126 |
|
|
* Write data to TX stream link 4 (blocking!)
|
127 |
|
|
*
|
128 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
129 |
|
|
*
|
130 |
|
|
* @param[in] tx_data Data to send to link.
|
131 |
|
|
**************************************************************************/
|
132 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_tx4_blocking(uint32_t tx_data) {
|
133 |
64 |
zero_gravi |
NEORV32_SLINK.DATA[4] = tx_data;
|
134 |
61 |
zero_gravi |
}
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
/**********************************************************************//**
|
138 |
|
|
* Write data to TX stream link 5 (blocking!)
|
139 |
|
|
*
|
140 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
141 |
|
|
*
|
142 |
|
|
* @param[in] tx_data Data to send to link.
|
143 |
|
|
**************************************************************************/
|
144 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_tx5_blocking(uint32_t tx_data) {
|
145 |
64 |
zero_gravi |
NEORV32_SLINK.DATA[5] = tx_data;
|
146 |
61 |
zero_gravi |
}
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
/**********************************************************************//**
|
150 |
|
|
* Write data to TX stream link 6 (blocking!)
|
151 |
|
|
*
|
152 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
153 |
|
|
*
|
154 |
|
|
* @param[in] tx_data Data to send to link.
|
155 |
|
|
**************************************************************************/
|
156 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_tx6_blocking(uint32_t tx_data) {
|
157 |
64 |
zero_gravi |
NEORV32_SLINK.DATA[6] = tx_data;
|
158 |
61 |
zero_gravi |
}
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
/**********************************************************************//**
|
162 |
|
|
* Write data to TX stream link 7 (blocking!)
|
163 |
|
|
*
|
164 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
165 |
|
|
*
|
166 |
|
|
* @param[in] tx_data Data to send to link.
|
167 |
|
|
**************************************************************************/
|
168 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_tx7_blocking(uint32_t tx_data) {
|
169 |
64 |
zero_gravi |
NEORV32_SLINK.DATA[7] = tx_data;
|
170 |
61 |
zero_gravi |
}
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
/**********************************************************************//**
|
174 |
|
|
* Read data from RX stream link 0 (blocking!)
|
175 |
|
|
*
|
176 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
177 |
|
|
*
|
178 |
|
|
* @param[in,out] rx_data Pointer to return read data.
|
179 |
|
|
**************************************************************************/
|
180 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_rx0_blocking(uint32_t *rx_data) {
|
181 |
64 |
zero_gravi |
*rx_data = NEORV32_SLINK.DATA[0];
|
182 |
61 |
zero_gravi |
}
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
/**********************************************************************//**
|
186 |
|
|
* Read data from RX stream link 1 (blocking!)
|
187 |
|
|
*
|
188 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
189 |
|
|
*
|
190 |
|
|
* @param[in,out] rx_data Pointer to return read data.
|
191 |
|
|
**************************************************************************/
|
192 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_rx1_blocking(uint32_t *rx_data) {
|
193 |
64 |
zero_gravi |
*rx_data = NEORV32_SLINK.DATA[1];
|
194 |
61 |
zero_gravi |
}
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
/**********************************************************************//**
|
198 |
|
|
* Read data from RX stream link 2 (blocking!)
|
199 |
|
|
*
|
200 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
201 |
|
|
*
|
202 |
|
|
* @param[in,out] rx_data Pointer to return read data.
|
203 |
|
|
**************************************************************************/
|
204 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_rx2_blocking(uint32_t *rx_data) {
|
205 |
64 |
zero_gravi |
*rx_data = NEORV32_SLINK.DATA[2];
|
206 |
61 |
zero_gravi |
}
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
/**********************************************************************//**
|
210 |
|
|
* Read data from RX stream link 3 (blocking!)
|
211 |
|
|
*
|
212 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
213 |
|
|
*
|
214 |
|
|
* @param[in,out] rx_data Pointer to return read data.
|
215 |
|
|
**************************************************************************/
|
216 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_rx3_blocking(uint32_t *rx_data) {
|
217 |
64 |
zero_gravi |
*rx_data = NEORV32_SLINK.DATA[3];
|
218 |
61 |
zero_gravi |
}
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
/**********************************************************************//**
|
222 |
|
|
* Read data from RX stream link 4 (blocking!)
|
223 |
|
|
*
|
224 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
225 |
|
|
*
|
226 |
|
|
* @param[in,out] rx_data Pointer to return read data.
|
227 |
|
|
**************************************************************************/
|
228 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_rx4_blocking(uint32_t *rx_data) {
|
229 |
64 |
zero_gravi |
*rx_data = NEORV32_SLINK.DATA[4];
|
230 |
61 |
zero_gravi |
}
|
231 |
|
|
|
232 |
|
|
|
233 |
|
|
/**********************************************************************//**
|
234 |
|
|
* Read data from RX stream link 5 (blocking!)
|
235 |
|
|
*
|
236 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
237 |
|
|
*
|
238 |
|
|
* @param[in,out] rx_data Pointer to return read data.
|
239 |
|
|
**************************************************************************/
|
240 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_rx5_blocking(uint32_t *rx_data) {
|
241 |
64 |
zero_gravi |
*rx_data = NEORV32_SLINK.DATA[5];
|
242 |
61 |
zero_gravi |
}
|
243 |
|
|
|
244 |
|
|
|
245 |
|
|
/**********************************************************************//**
|
246 |
|
|
* Read data from RX stream link 6 (blocking!)
|
247 |
|
|
*
|
248 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
249 |
|
|
*
|
250 |
|
|
* @param[in,out] rx_data Pointer to return read data.
|
251 |
|
|
**************************************************************************/
|
252 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_rx6_blocking(uint32_t *rx_data) {
|
253 |
64 |
zero_gravi |
*rx_data = NEORV32_SLINK.DATA[6];
|
254 |
61 |
zero_gravi |
}
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
/**********************************************************************//**
|
258 |
|
|
* Read data from RX stream link 7 (blocking!)
|
259 |
|
|
*
|
260 |
|
|
* @warning This function will raise an exception when the bus access times out!
|
261 |
|
|
*
|
262 |
|
|
* @param[in,out] rx_data Pointer to return read data.
|
263 |
|
|
**************************************************************************/
|
264 |
|
|
inline void __attribute__ ((always_inline)) neorv32_slink_rx7_blocking(uint32_t *rx_data) {
|
265 |
64 |
zero_gravi |
*rx_data = NEORV32_SLINK.DATA[7];
|
266 |
61 |
zero_gravi |
}
|
267 |
|
|
|
268 |
|
|
|
269 |
|
|
#endif // neorv32_slink_h
|