1 /****************************************************************************** 2 * @file cmsis_vio.h 3 * @brief CMSIS Virtual I/O header file 4 * @version V1.0.0 5 * @date 24. May 2023 6 ******************************************************************************/ 7 /* 8 * Copyright (c) 2019-2023 Arm Limited. All rights reserved. 9 * 10 * SPDX-License-Identifier: Apache-2.0 11 * 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 15 * 16 * www.apache.org/licenses/LICENSE-2.0 17 * 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. 23 */ 24 25 #ifndef __CMSIS_VIO_H 26 #define __CMSIS_VIO_H 27 28 #include <stdint.h> 29 30 /******************************************************************************* 31 * Generic I/O mapping recommended for CMSIS-VIO 32 * Note: not every I/O must be physically available 33 */ 34 35 // vioSetSignal: mask values 36 #define vioLED0 (1U << 0) ///< \ref vioSetSignal \a mask parameter: LED 0 (for 3-color: red) 37 #define vioLED1 (1U << 1) ///< \ref vioSetSignal \a mask parameter: LED 1 (for 3-color: green) 38 #define vioLED2 (1U << 2) ///< \ref vioSetSignal \a mask parameter: LED 2 (for 3-color: blue) 39 #define vioLED3 (1U << 3) ///< \ref vioSetSignal \a mask parameter: LED 3 40 #define vioLED4 (1U << 4) ///< \ref vioSetSignal \a mask parameter: LED 4 41 #define vioLED5 (1U << 5) ///< \ref vioSetSignal \a mask parameter: LED 5 42 #define vioLED6 (1U << 6) ///< \ref vioSetSignal \a mask parameter: LED 6 43 #define vioLED7 (1U << 7) ///< \ref vioSetSignal \a mask parameter: LED 7 44 45 // vioSetSignal: signal values 46 #define vioLEDon (0xFFU) ///< \ref vioSetSignal \a signal parameter: pattern to turn any LED on 47 #define vioLEDoff (0x00U) ///< \ref vioSetSignal \a signal parameter: pattern to turn any LED off 48 49 // vioGetSignal: mask values and return values 50 #define vioBUTTON0 (1U << 0) ///< \ref vioGetSignal \a mask parameter: Push button 0 51 #define vioBUTTON1 (1U << 1) ///< \ref vioGetSignal \a mask parameter: Push button 1 52 #define vioBUTTON2 (1U << 2) ///< \ref vioGetSignal \a mask parameter: Push button 2 53 #define vioBUTTON3 (1U << 3) ///< \ref vioGetSignal \a mask parameter: Push button 3 54 #define vioJOYup (1U << 4) ///< \ref vioGetSignal \a mask parameter: Joystick button: up 55 #define vioJOYdown (1U << 5) ///< \ref vioGetSignal \a mask parameter: Joystick button: down 56 #define vioJOYleft (1U << 6) ///< \ref vioGetSignal \a mask parameter: Joystick button: left 57 #define vioJOYright (1U << 7) ///< \ref vioGetSignal \a mask parameter: Joystick button: right 58 #define vioJOYselect (1U << 8) ///< \ref vioGetSignal \a mask parameter: Joystick button: select 59 #define vioJOYall (vioJOYup | \ 60 vioJOYdown | \ 61 vioJOYleft | \ 62 vioJOYright | \ 63 vioJOYselect) ///< \ref vioGetSignal \a mask Joystick button: all 64 65 // vioSetValue / vioGetValue: id values 66 #define vioAIN0 (0U) ///< \ref vioSetValue / \ref vioGetValue \a id parameter: Analog input value 0 67 #define vioAIN1 (1U) ///< \ref vioSetValue / \ref vioGetValue \a id parameter: Analog input value 1 68 #define vioAIN2 (2U) ///< \ref vioSetValue / \ref vioGetValue \a id parameter: Analog input value 2 69 #define vioAIN3 (3U) ///< \ref vioSetValue / \ref vioGetValue \a id parameter: Analog input value 3 70 #define vioAOUT0 (4U) ///< \ref vioSetValue / \ref vioGetValue \a id parameter: Analog output value 0 71 72 #ifdef __cplusplus 73 extern "C" 74 { 75 #endif 76 77 /// Initialize test input, output. 78 void vioInit (void); 79 80 /// Set signal output. 81 /// \param[in] mask bit mask of signals to set. 82 /// \param[in] signal signal value to set. 83 void vioSetSignal (uint32_t mask, uint32_t signal); 84 85 /// Get signal input. 86 /// \param[in] mask bit mask of signals to read. 87 /// \return signal value. 88 uint32_t vioGetSignal (uint32_t mask); 89 90 /// Set value output. 91 /// \param[in] id output identifier. 92 /// \param[in] value value to set. 93 void vioSetValue (uint32_t id, int32_t value); 94 95 /// Get value input. 96 /// \param[in] id input identifier. 97 /// \return value retrieved from input. 98 int32_t vioGetValue (uint32_t id); 99 100 #ifdef __cplusplus 101 } 102 #endif 103 104 #endif /* __CMSIS_VIO_H */ 105