]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_R5_UltraScale_MPSoC/RTOSDemo_R5_bsp/psu_cortexr5_0/libsrc/sysmonpsu_v2_0/src/xsysmonpsu_selftest.c
xTaskGenericNotify() now sets xYieldPending to pdTRUE even when the 'higher priority...
[freertos] / FreeRTOS / Demo / CORTEX_R5_UltraScale_MPSoC / RTOSDemo_R5_bsp / psu_cortexr5_0 / libsrc / sysmonpsu_v2_0 / src / xsysmonpsu_selftest.c
1 /******************************************************************************
2 *
3 * Copyright (C) 2016 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34 *
35 * @file xsysmon_selftest.c
36 *
37 * This file contains a diagnostic self test function for the XSysMon driver.
38 * The self test function does a simple read/write test of the Alarm Threshold
39 * Register.
40 *
41 * See xsysmonpsu.h for more information.
42 *
43 * @note None.
44 *
45 * <pre>
46 *
47 * MODIFICATION HISTORY:
48 *
49 * Ver   Who    Date     Changes
50 * ----- -----  -------- -----------------------------------------------------
51 * 1.0   kvn   12/15/15  First release
52 *
53 * </pre>
54 *
55 *****************************************************************************/
56
57 /***************************** Include Files ********************************/
58
59 #include "xsysmonpsu.h"
60
61 /************************** Constant Definitions ****************************/
62
63 /*
64  * The following constant defines the test value to be written
65  * to the Alarm Threshold Register
66  */
67 #define XSM_ATR_TEST_VALUE              0x55U
68
69 /**************************** Type Definitions ******************************/
70
71 /***************** Macros (Inline Functions) Definitions ********************/
72
73 /************************** Variable Definitions ****************************/
74
75 /************************** Function Prototypes *****************************/
76
77 /*****************************************************************************/
78 /**
79 *
80 * Run a self-test on the driver/device. The test
81 *       - Resets the device,
82 *       - Writes a value into the Alarm Threshold register and reads it back
83 *       for comparison.
84 *       - Resets the device again.
85 *
86 *
87 * @param        InstancePtr is a pointer to the XSysMonPsu instance.
88 *
89 * @return
90 *               - XST_SUCCESS if the value read from the Alarm Threshold
91 *               register is the same as the value written.
92 *               - XST_FAILURE Otherwise
93 *
94 * @note         This is a destructive test in that resets of the device are
95 *               performed. Refer to the device specification for the
96 *               device status after the reset operation.
97 *
98 ******************************************************************************/
99 s32 XSysMonPsu_SelfTest(XSysMonPsu *InstancePtr)
100 {
101         s32 Status;
102         u32 RegValue;
103
104         /* Assert the argument */
105         Xil_AssertNonvoid(InstancePtr != NULL);
106         Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
107
108         /* Reset the device to get it back to its default state */
109         XSysMonPsu_Reset(InstancePtr);
110
111         /*
112          * Write a value into the Alarm Threshold registers, read it back, and
113          * do the comparison
114          */
115         XSysMonPsu_SetAlarmThreshold(InstancePtr, XSM_ATR_SUP1_UPPER,
116                                   XSM_ATR_TEST_VALUE, XSYSMON_PS);
117         RegValue = (u32)XSysMonPsu_GetAlarmThreshold(InstancePtr,
118                                         XSM_ATR_SUP1_UPPER, XSYSMON_PS);
119
120         if (RegValue == XSM_ATR_TEST_VALUE) {
121                 Status = XST_SUCCESS;
122         } else {
123                 Status = XST_FAILURE;
124         }
125
126         /* Reset the device again to its default state. */
127         XSysMonPsu_Reset(InstancePtr);
128
129         /* Return the test result. */
130         return Status;
131 }
132 /** @} */