1 /****************************************************************************** 2 * 3 * Copyright (C) 1999-2012 Broadcom Corporation 4 * Copyright 2018-2019 NXP 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at: 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * 18 ******************************************************************************/ 19 20 #ifndef UWA_SYS_H 21 #define UWA_SYS_H 22 23 #include "uwa_api.h" 24 #include "uwb_gki.h" 25 #include "uwb_target.h" 26 27 /***************************************************************************** 28 ** Constants and data types 29 *****************************************************************************/ 30 31 /* SW sub-systems */ 32 enum { 33 UWA_ID_SYS, /* system manager */ 34 UWA_ID_DM, /* device manager */ 35 UWA_ID_MAX 36 }; 37 typedef uint8_t tUWA_SYS_ID; 38 39 /* enable function type */ 40 typedef void(tUWA_SYS_ENABLE)(void); 41 42 /* event handler function type */ 43 typedef bool(tUWA_SYS_EVT_HDLR)(UWB_HDR* p_msg); 44 45 /* disable function type */ 46 typedef void(tUWA_SYS_DISABLE)(void); 47 48 typedef void(tUWA_SYS_ENABLE_CBACK)(void); 49 50 /* registration structure */ 51 typedef struct { 52 tUWA_SYS_ENABLE* enable; 53 tUWA_SYS_EVT_HDLR* evt_hdlr; 54 tUWA_SYS_DISABLE* disable; 55 } tUWA_SYS_REG; 56 57 /* system manager configuration structure */ 58 typedef struct { 59 uint16_t mbox_evt; /* GKI mailbox event */ 60 uint8_t mbox; /* GKI mailbox id */ 61 uint8_t timer; /* GKI timer id */ 62 } tUWA_SYS_CFG; 63 64 /***************************************************************************** 65 ** Global data 66 *****************************************************************************/ 67 68 /***************************************************************************** 69 ** Macros 70 *****************************************************************************/ 71 72 /* Calculate start of event enumeration; id is top 8 bits of event */ 73 #define UWA_SYS_EVT_START(id) ((id) << 8) 74 75 /***************************************************************************** 76 ** Function declarations 77 *****************************************************************************/ 78 extern void uwa_sys_init(void); 79 extern void uwa_sys_event(UWB_HDR* p_msg); 80 extern void uwa_sys_timer_update(void); 81 extern void uwa_sys_disable_timers(void); 82 83 extern void uwa_sys_register(uint8_t id, const tUWA_SYS_REG* p_reg); 84 extern void uwa_sys_deregister(uint8_t id); 85 extern void uwa_sys_check_disabled(void); 86 extern bool uwa_sys_is_register(uint8_t id); 87 extern void uwa_sys_disable_subsystems(bool graceful); 88 extern void uwa_sys_enable_subsystems(void); 89 90 extern bool uwa_sys_is_graceful_disable(void); 91 extern void uwa_sys_sendmsg(void* p_msg); 92 extern void uwa_sys_start_timer(TIMER_LIST_ENT* p_tle, uint16_t type, 93 uint32_t timeout); 94 extern void uwa_sys_stop_timer(TIMER_LIST_ENT* p_tle); 95 96 extern void uwa_sys_cback_reg_enable_complete(tUWA_SYS_ENABLE_CBACK* p_cback); 97 extern void uwa_sys_cback_notify_enable_complete(uint8_t id); 98 99 #endif /* UWA_SYS_H */ 100