1 /*
2  * Copyright 2022, Cypress Semiconductor Corporation (an Infineon company)
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef INCLUDED_WHD_THREAD_INTERNAL_H
19 #define INCLUDED_WHD_THREAD_INTERNAL_H
20 
21 #ifdef __cplusplus
22 extern "C"
23 {
24 #endif
25 
26 #include "whd_debug.h"
27 #include "whd_int.h"
28 
29 /******************************************************
30 *                      Macros
31 ******************************************************/
32 
33 #define WHD_WLAN_KEEP_AWAKE(whd_driver) \
34     do { \
35         whd_result_t verify_result; \
36         whd_driver->internal_info.whd_wlan_status.keep_wlan_awake++; \
37         verify_result = whd_ensure_wlan_bus_is_up(whd_driver); \
38         whd_assert("Could not bring bus up", (verify_result == WHD_SUCCESS) ); \
39     } while (0)
40 #define WHD_WLAN_LET_SLEEP(whd_driver) \
41     do { \
42         whd_driver->internal_info.whd_wlan_status.keep_wlan_awake--; \
43         if (whd_driver->internal_info.whd_wlan_status.keep_wlan_awake == 0) \
44             whd_thread_notify(whd_driver); \
45     } while (0)
46 #define WHD_WLAN_MAY_SLEEP() \
47     ( (whd_driver->internal_info.whd_wlan_status.keep_wlan_awake == 0) && \
48       (whd_driver->internal_info.whd_wlan_status.state == WLAN_UP) )
49 
50 #ifdef __cplusplus
51 } /* extern "C" */
52 #endif
53 
54 #endif /* ifndef INCLUDED_WHD_THREAD_INTERNAL_H */
55