1
1
/******************************************************************************
2
2
* @file vio.c
3
3
* @brief Virtual I/O implementation template
4
- * @version V1 .0.0
5
- * @date 23. March 2020
4
+ * @version V2 .0.0
5
+ * @date 18. October 2023
6
6
******************************************************************************/
7
7
/*
8
- * Copyright (c) 2019-2020 Arm Limited. All rights reserved.
8
+ * Copyright (c) 2019-2023 Arm Limited (or its affiliates).
9
+ * All rights reserved.
9
10
*
10
11
* SPDX-License-Identifier: Apache-2.0
11
12
*
@@ -38,12 +39,17 @@ vioLED6 | vioSignalOut.6 | User LED UL6
38
39
vioLED7 | vioSignalOut.7 | User LED UL7 |
39
40
*/
40
41
41
- #include <stdio.h>
42
+ /* History:
43
+ * Version 2.0.0
44
+ * Updated to API 1.0.0
45
+ * Version 1.0.0
46
+ * Initial release
47
+ */
48
+
42
49
#include <string.h>
43
- #include <stdarg.h>
44
50
#include "cmsis_vio.h"
45
51
46
- #include "RTE_Components.h" // Component selection
52
+ #include "RTE_Components.h" // Component selection
47
53
#include CMSIS_device_header
48
54
49
55
#if !defined CMSIS_VOUT || !defined CMSIS_VIN
@@ -53,21 +59,12 @@ vioLED7 | vioSignalOut.7 | User LED UL7
53
59
#endif
54
60
55
61
// VIO input, output definitions
56
- #define VIO_PRINT_MAX_SIZE 64U // maximum size of print memory
57
- #define VIO_PRINTMEM_NUM 4U // number of print memories
58
- #define VIO_VALUE_NUM 3U // number of values
59
- #define VIO_VALUEXYZ_NUM 3U // number of XYZ values
60
- #define VIO_IPV4_ADDRESS_NUM 2U // number of IPv4 addresses
61
- #define VIO_IPV6_ADDRESS_NUM 2U // number of IPv6 addresses
62
+ #define VIO_VALUE_NUM 3U // Number of values
62
63
63
64
// VIO input, output variables
64
- __USED uint32_t vioSignalIn ; // Memory for incoming signal
65
- __USED uint32_t vioSignalOut ; // Memory for outgoing signal
66
- __USED char vioPrintMem [VIO_PRINTMEM_NUM ][VIO_PRINT_MAX_SIZE ]; // Memory for the last value for each level
67
- __USED int32_t vioValue [VIO_VALUE_NUM ]; // Memory for value used in vioGetValue/vioSetValue
68
- __USED vioValueXYZ_t vioValueXYZ [VIO_VALUEXYZ_NUM ]; // Memory for XYZ value for 3-D vector
69
- __USED vioAddrIPv4_t vioAddrIPv4 [VIO_IPV4_ADDRESS_NUM ]; // Memory for IPv4 address value used in vioSetIPv4/vioGetIPv4
70
- __USED vioAddrIPv6_t vioAddrIPv6 [VIO_IPV6_ADDRESS_NUM ]; // Memory for IPv6 address value used in vioSetIPv6/vioGetIPv6
65
+ __USED uint32_t vioSignalIn ; // Memory for incoming signal
66
+ __USED uint32_t vioSignalOut ; // Memory for outgoing signal
67
+ __USED int32_t vioValue [VIO_VALUE_NUM ]; // Memory for value used in vioGetValue/vioSetValue
71
68
72
69
#if !defined CMSIS_VOUT
73
70
// Add global user types, variables, functions here:
@@ -93,11 +90,7 @@ void vioInit (void) {
93
90
vioSignalIn = 0U ;
94
91
vioSignalOut = 0U ;
95
92
96
- memset (vioPrintMem , 0 , sizeof (vioPrintMem ));
97
- memset (vioValue , 0 , sizeof (vioValue ));
98
- memset (vioValueXYZ , 0 , sizeof (vioValueXYZ ));
99
- memset (vioAddrIPv4 , 0 , sizeof (vioAddrIPv4 ));
100
- memset (vioAddrIPv6 , 0 , sizeof (vioAddrIPv6 ));
93
+ memset (vioValue , 0 , sizeof (vioValue ));
101
94
102
95
#if !defined CMSIS_VOUT
103
96
// Turn off all LEDs
@@ -110,37 +103,6 @@ void vioInit (void) {
110
103
#endif
111
104
}
112
105
113
- // Print formated string to test terminal.
114
- int32_t vioPrint (uint32_t level , const char * format , ...) {
115
- va_list args ;
116
- int32_t ret ;
117
- #if !defined CMSIS_VOUT
118
- // Add user variables here:
119
-
120
- #endif
121
-
122
- if (level > vioLevelError ) {
123
- return (-1 );
124
- }
125
-
126
- if (level > VIO_PRINTMEM_NUM ) {
127
- return (-1 );
128
- }
129
-
130
- va_start (args , format );
131
-
132
- ret = vsnprintf ((char * )vioPrintMem [level ], sizeof (vioPrintMem [level ]), format , args );
133
-
134
- va_end (args );
135
-
136
- #if !defined CMSIS_VOUT
137
- // Add user code here:
138
-
139
- #endif
140
-
141
- return (ret );
142
- }
143
-
144
106
// Set signal output.
145
107
void vioSetSignal (uint32_t mask , uint32_t signal ) {
146
108
#if !defined CMSIS_VOUT
@@ -171,9 +133,9 @@ uint32_t vioGetSignal (uint32_t mask) {
171
133
vioSignalIn = arm_mps3_io_read_buttons (& MPS3_IO_DEV , ARM_MPS3_IO_ACCESS_PORT , 0 );
172
134
#endif
173
135
174
- signal = vioSignalIn ;
136
+ signal = vioSignalIn & mask ;
175
137
176
- return ( signal & mask ) ;
138
+ return signal ;
177
139
}
178
140
179
141
// Set value output.
@@ -219,136 +181,3 @@ int32_t vioGetValue (uint32_t id) {
219
181
220
182
return value ;
221
183
}
222
-
223
- // Set XYZ value output.
224
- void vioSetXYZ (uint32_t id , vioValueXYZ_t valueXYZ ) {
225
- uint32_t index = id ;
226
- #if !defined CMSIS_VOUT
227
- // Add user variables here:
228
-
229
- #endif
230
-
231
- if (index >= VIO_VALUEXYZ_NUM ) {
232
- return ; /* return in case of out-of-range index */
233
- }
234
-
235
- vioValueXYZ [index ] = valueXYZ ;
236
-
237
- #if !defined CMSIS_VOUT
238
- // Add user code here:
239
-
240
- #endif
241
- }
242
-
243
- // Get XYZ value input.
244
- vioValueXYZ_t vioGetXYZ (uint32_t id ) {
245
- uint32_t index = id ;
246
- vioValueXYZ_t valueXYZ = {0 , 0 , 0 };
247
- #if !defined CMSIS_VIN
248
- // Add user variables here:
249
-
250
- #endif
251
-
252
- if (index >= VIO_VALUEXYZ_NUM ) {
253
- return valueXYZ ; /* return default in case of out-of-range index */
254
- }
255
-
256
- #if !defined CMSIS_VIN
257
- // Add user code here:
258
-
259
- // vioValueXYZ[index] = ...;
260
- #endif
261
-
262
- valueXYZ = vioValueXYZ [index ];
263
-
264
- return valueXYZ ;
265
- }
266
-
267
- // Set IPv4 address output.
268
- void vioSetIPv4 (uint32_t id , vioAddrIPv4_t addrIPv4 ) {
269
- uint32_t index = id ;
270
- #if !defined CMSIS_VOUT
271
- // Add user variables here:
272
-
273
- #endif
274
-
275
- if (index >= VIO_IPV4_ADDRESS_NUM ) {
276
- return ; /* return in case of out-of-range index */
277
- }
278
-
279
- vioAddrIPv4 [index ] = addrIPv4 ;
280
-
281
- #if !defined CMSIS_VOUT
282
- // Add user code here:
283
-
284
- #endif
285
- }
286
-
287
- // Get IPv4 address input.
288
- vioAddrIPv4_t vioGetIPv4 (uint32_t id ) {
289
- uint32_t index = id ;
290
- vioAddrIPv4_t addrIPv4 = {0U , 0U , 0U , 0U };
291
- #if !defined CMSIS_VIN
292
- // Add user variables here:
293
-
294
- #endif
295
-
296
- if (index >= VIO_IPV4_ADDRESS_NUM ) {
297
- return addrIPv4 ; /* return default in case of out-of-range index */
298
- }
299
-
300
- #if !defined CMSIS_VIN
301
- // Add user code here:
302
-
303
- // vioAddrIPv4[index] = ...;
304
- #endif
305
-
306
- addrIPv4 = vioAddrIPv4 [index ];
307
-
308
- return addrIPv4 ;
309
- }
310
-
311
- // Set IPv6 address output.
312
- void vioSetIPv6 (uint32_t id , vioAddrIPv6_t addrIPv6 ) {
313
- uint32_t index = id ;
314
- #if !defined CMSIS_VOUT
315
- // Add user variables here:
316
-
317
- #endif
318
-
319
- if (index >= VIO_IPV6_ADDRESS_NUM ) {
320
- return ; /* return in case of out-of-range index */
321
- }
322
-
323
- vioAddrIPv6 [index ] = addrIPv6 ;
324
-
325
- #if !defined CMSIS_VOUT
326
- // Add user code here:
327
-
328
- #endif
329
- }
330
-
331
- // Get IPv6 address input.
332
- vioAddrIPv6_t vioGetIPv6 (uint32_t id ) {
333
- uint32_t index = id ;
334
- vioAddrIPv6_t addrIPv6 = {0U , 0U , 0U , 0U , 0U , 0U , 0U , 0U ,
335
- 0U , 0U , 0U , 0U , 0U , 0U , 0U , 0U };
336
- #if !defined CMSIS_VIN
337
- // Add user variables here:
338
-
339
- #endif
340
-
341
- if (index >= VIO_IPV6_ADDRESS_NUM ) {
342
- return addrIPv6 ; /* return default in case of out-of-range index */
343
- }
344
-
345
- #if !defined CMSIS_VIN
346
- // Add user code here:
347
-
348
- // vioAddrIPv6[index] = ...;
349
- #endif
350
-
351
- addrIPv6 = vioAddrIPv6 [index ];
352
-
353
- return addrIPv6 ;
354
- }
0 commit comments