1 /******************************************************************************
3 * @brief Virtual I/O implementation template
6 ******************************************************************************/
8 * Copyright (c) 2019-2023 Arm Limited. All rights reserved.
10 * SPDX-License-Identifier: Apache-2.0
12 * Licensed under the Apache License, Version 2.0 (the License); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
16 * www.apache.org/licenses/LICENSE-2.0
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
26 #include "cmsis_vio.h"
28 #include "RTE_Components.h" // Component selection
29 #include CMSIS_device_header
31 #if !defined CMSIS_VOUT || !defined CMSIS_VIN
32 // Add user includes here:
36 // VIO input, output definitions
37 #define VIO_VALUE_NUM 5U // Number of values
39 // VIO input, output variables
40 __USED uint32_t vioSignalIn; // Memory for incoming signal
41 __USED uint32_t vioSignalOut; // Memory for outgoing signal
42 __USED int32_t vioValue[VIO_VALUE_NUM]; // Memory for value used in vioGetValue/vioSetValue
44 #if !defined CMSIS_VOUT
45 // Add global user types, variables, functions here:
49 #if !defined CMSIS_VIN
50 // Add global user types, variables, functions here:
54 // Initialize test input, output.
56 #if !defined CMSIS_VOUT
57 // Add user variables here:
60 #if !defined CMSIS_VIN
61 // Add user variables here:
68 memset(vioValue, 0, sizeof(vioValue));
70 #if !defined CMSIS_VOUT
71 // Add user code here:
75 #if !defined CMSIS_VIN
76 // Add user code here:
82 void vioSetSignal (uint32_t mask, uint32_t signal) {
83 #if !defined CMSIS_VOUT
84 // Add user variables here:
88 vioSignalOut &= ~mask;
89 vioSignalOut |= mask & signal;
91 #if !defined CMSIS_VOUT
92 // Add user code here:
98 uint32_t vioGetSignal (uint32_t mask) {
100 #if !defined CMSIS_VIN
101 // Add user variables here:
105 #if !defined CMSIS_VIN
106 // Add user code here:
108 // vioSignalIn = ...;
111 signal = vioSignalIn & mask;
117 void vioSetValue (uint32_t id, int32_t value) {
119 #if !defined CMSIS_VOUT
120 // Add user variables here:
124 if (index >= VIO_VALUE_NUM) {
125 return; /* return in case of out-of-range index */
128 vioValue[index] = value;
130 #if !defined CMSIS_VOUT
131 // Add user code here:
137 int32_t vioGetValue (uint32_t id) {
140 #if !defined CMSIS_VIN
141 // Add user variables here:
145 if (index >= VIO_VALUE_NUM) {
146 return value; /* return default in case of out-of-range index */
149 #if !defined CMSIS_VIN
150 // Add user code here:
152 // vioValue[index] = ...;
155 value = vioValue[index];