]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_R5_UltraScale_MPSoC/RTOSDemo_R5_bsp/psu_cortexr5_0/libsrc/standalone_v6_6/src/sleep.h
Update Zynq, MPSoc Cortex-A53 and MPSoc Cortex-R5 demo projects to build with the...
[freertos] / FreeRTOS / Demo / CORTEX_R5_UltraScale_MPSoC / RTOSDemo_R5_bsp / psu_cortexr5_0 / libsrc / standalone_v6_6 / src / sleep.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2014 - 2017 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
22 * XILINX  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 sleep.h
36 *
37 *  This header file contains ARM Cortex A53,A9,R5,Microblaze specific sleep
38 *  related APIs.
39 *
40 * <pre>
41 * MODIFICATION HISTORY :
42 *
43 * Ver   Who  Date        Changes
44 * ----- ---- -------- -------------------------------------------------------
45 * 6.6   srm  11/02/17 Added processor specific sleep rountines
46 *                                                                function prototypes.
47 *
48 * </pre>
49 *
50 ******************************************************************************/
51
52 #ifndef SLEEP_H
53 #define SLEEP_H
54
55 #include "xil_types.h"
56 #include "xil_io.h"
57
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61
62 /*****************************************************************************/
63 /**
64 *
65 * This macro polls an address periodically until a condition is met or till the
66 * timeout occurs.
67 * The minimum timeout for calling this macro is 100us. If the timeout is less
68 * than 100us, it still waits for 100us. Also the unit for the timeout is 100us.
69 * If the timeout is not a multiple of 100us, it waits for a timeout of
70 * the next usec value which is a multiple of 100us.
71 *
72 * @param            IO_func - accessor function to read the register contents.
73 *                   Depends on the register width.
74 * @param            ADDR - Address to be polled
75 * @param            VALUE - variable to read the value
76 * @param            COND - Condition to checked (usually involves VALUE)
77 * @param            TIMEOUT_US - timeout in micro seconds
78 *
79 * @return           0 - when the condition is met
80 *                   -1 - when the condition is not met till the timeout period
81 *
82 * @note             none
83 *
84 *****************************************************************************/
85 #define Xil_poll_timeout(IO_func, ADDR, VALUE, COND, TIMEOUT_US) \
86  ( {      \
87         u64 timeout = TIMEOUT_US/100;    \
88         if(TIMEOUT_US%100!=0)   \
89                 timeout++;   \
90         for(;;) { \
91                 VALUE = IO_func(ADDR); \
92                 if(COND) \
93                         break; \
94                 else {    \
95                         usleep(100);  \
96                         timeout--; \
97                         if(timeout==0) \
98                         break;  \
99                 }  \
100         }    \
101         (timeout>0) ? 0 : -1;  \
102  }  )
103
104 void usleep(unsigned long useconds);
105 void sleep(unsigned int seconds);
106 int usleep_R5(unsigned long useconds);
107 unsigned sleep_R5(unsigned int seconds);
108 int usleep_MB(unsigned long useconds);
109 unsigned sleep_MB(unsigned int seconds);
110 int usleep_A53(unsigned long useconds);
111 unsigned sleep_A53(unsigned int seconds);
112 int usleep_A9(unsigned long useconds);
113 unsigned sleep_A9(unsigned int seconds);
114
115 #ifdef __cplusplus
116 }
117 #endif
118
119 #endif