1 /******************************************************************************
3 * @brief Virtual I/O implementation using memory only
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 // VIO input, output definitions
33 #define VIO_VALUE_NUM 5U // Number of values
36 // VIO input, output variables
37 __USED uint32_t vioSignalIn; // Memory for incoming signal
38 __USED uint32_t vioSignalOut; // Memory for outgoing signal
39 __USED int32_t vioValue[VIO_VALUE_NUM]; // Memory for value used in vioGetValue/vioSetValue
41 // Initialize test input, output.
47 memset(vioValue, 0, sizeof(vioValue));
51 void vioSetSignal (uint32_t mask, uint32_t signal) {
53 vioSignalOut &= ~mask;
54 vioSignalOut |= mask & signal;
58 uint32_t vioGetSignal (uint32_t mask) {
61 signal = vioSignalIn & mask;
67 void vioSetValue (uint32_t id, int32_t value) {
70 if (index >= VIO_VALUE_NUM) {
71 return; /* return in case of out-of-range index */
74 vioValue[index] = value;
78 int32_t vioGetValue (uint32_t id) {
82 if (index >= VIO_VALUE_NUM) {
83 return value; /* return default in case of out-of-range index */
86 value = vioValue[index];