2 \defgroup vio_interface_gr VIO
3 \brief API for Virtual I/O (VIO) (%cmsis_vio.h)
6 The VIO software component is a virtual I/O abstraction for peripherals that are typically used in example projects. It
7 enables developers to move from an evaluation kit to custom hardware and helps to scale project examples at large to many
10 \image html vioRationale.png "Virtual I/O provides a generic API for examples and testing"
14 The following header file defines the Application Programming Interface (API) for VIO:
15 - \b %cmsis_vio.h : API for VIO
17 <b>VIO User Code Templates</b>
19 The VIO software component contains two user code templates with different purposes:
20 - VIO:Custom: This file is an empty stub with all functions that are defined in the header file that can be used to
21 implement the VIO layer for the hardware that is used in the application.
22 - VIO:Virtual: This file uses a fixed memory location to emulate the VIO functionality and can be used off-the-shelf.
24 <b>VIO Memory Location Structure</b>
26 For testing purposes, it is required to have fixed memory locations that are used to read/store values. In the VIO:Virtual
27 template file (\b %vio.c), an exemplary implementation is shown:
30 // Input, output variables
31 __USED uint32_t vioSignalIn; // Memory for incoming signal
32 __USED uint32_t vioSignalOut; // Memory for outgoing signal
33 __USED int32_t vioValue[VIO_VALUE_NUM]; // Memory for value used in vioGetValue/vioSetValue
36 Use these memory locations to monitor or set the variables as required in the application.
38 Two defines are available that help to disconnect the actual peripherals and enable virtual I/Os: \c CMSIS_VIN and
39 \c CMSIS_VOUT. They help to write code that can be used in testing environments without real hardware access. The following
40 implementation example shows such code:
42 <b>Code Example (VIO Implementation)</b>
44 // Initialize test input, output.
46 #if !defined CMSIS_VIN
47 // Add user variables here:
50 #if !defined CMSIS_VOUT
51 // Add user variables here:
58 memset(vioValue, 0, sizeof(vioValue));
60 #if !defined CMSIS_VOUT
61 // Add user code here:
62 // <code vioInit output>
64 BSP_LED_Init(LED_BLUE);
65 BSP_LED_Init(LED_RED);
66 BSP_LED_Init(LED_GREEN);
70 #if !defined CMSIS_VIN
71 // Add user code here:
72 // <code vioInit input>
74 BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO);
82 <b>Memory display in IDEs</b>
84 Arm Keil MDK uses the provided SCVD file to display the VIO signals in Component Viewer:
86 \image html vioComponentViewer.png
92 \defgroup vioSignals_gr Signals
93 \ingroup vio_interface_gr
94 \brief Signal related defines.
121 \defgroup vioValueIDs_gr Value IDs
122 \ingroup vio_interface_gr
123 \brief Value Identifier related defines.
135 void vioInit (void) {};
137 \fn void vioInit (void)
139 The function \b vioInit initializes the VIO interface. Use it to initialize any connected hardware that is used to
144 #include "cmsis_vio.h" // ::CMSIS Driver:VIO
148 // System Initialization
149 SystemCoreClockUpdate();
155 ***************************************************************************************************************************/
157 void vioSetSignal (uint32_t mask, uint32_t signal) {};
159 \fn void vioSetSignal (uint32_t mask, uint32_t signal)
161 The function \b vioSetSignal set a \a signal to an output specified by \a mask. Use this function to map VIOs to actual
162 hardware for displaying signals on a target board.
164 Refer to \ref vioSignals_gr for information about the possible \a mask and \a signal values.
168 #include "cmsis_vio.h" // ::CMSIS Driver:VIO
173 vioSetSignal(vioLED0, vioLEDon);
175 vioSetSignal(vioLED0, vioLEDoff);
178 ***************************************************************************************************************************/
180 uint32_t vioGetSignal (uint32_t mask) {
184 \fn uint32_t vioGetSignal (uint32_t mask)
186 The function \b vioGetSignal retrieves a signal from an input identified by \a mask. Use this function to read data from any
187 input that is provided.
189 Refer to \ref vioSignals_gr for information about the possible \a mask values.
193 #include "cmsis_vio.h" // ::CMSIS Driver:VIO
201 state = (vioGetSignal (vioBUTTON0)); // Get pressed button state
203 if (state == vioBUTTON0){
211 ***************************************************************************************************************************/
213 void vioSetValue (uint32_t id, int32_t value) {};
215 \fn void vioSetValue (uint32_t id, int32_t value)
217 The function \b vioSetValue set the \a value to the output identified by \a id. Use this function to set states of I/Os for
220 Refer to \ref vioValueIDs_gr for information about \a id.
224 #include "cmsis_vio.h" // ::CMSIS Driver:VIO
229 vioSetValue(vioAOUT0, 1024);
232 ***************************************************************************************************************************/
234 int32_t vioGetValue (uint32_t id) {
238 \fn int32_t vioGetValue (uint32_t id)
240 The function \b vioGetValue retrieves a value from the input identified by \a id. Use this function to read data from inputs.
242 Refer to \ref vioValueIDs_gr for information about \a id.
246 #include "cmsis_vio.h" // ::CMSIS Driver:VIO
252 button = vioGetValue(vioBUTTON0);
255 ***************************************************************************************************************************/