nfa_sys_cback.c revision e9df6ba5a8fcccf306a80b1670b423be8fe7746a
1/******************************************************************************
2 *
3 *  Copyright (C) 2010-2012 Broadcom Corporation
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
19/******************************************************************************
20 *
21 *  Registration/deregistration functions for inter-module callbacks
22 *
23 ******************************************************************************/
24#include "nfa_sys.h"
25#include "nfa_sys_int.h"
26
27
28
29
30/*******************************************************************************
31**
32** Function         nfa_sys_cback_reg_enable_complete
33**
34** Description      Called to register an initialization complete callback function
35**
36** Returns          void
37**
38*******************************************************************************/
39void nfa_sys_cback_reg_enable_complete (tNFA_SYS_ENABLE_CBACK *p_cback)
40{
41    nfa_sys_cb.p_enable_cback = p_cback;
42    nfa_sys_cb.enable_cplt_flags = 0;
43}
44
45/*******************************************************************************
46**
47** Function         nfa_sys_cback_notify_enable_complete
48**
49** Description      Called by other NFA subsystems to notify initialization is
50**                  complete
51**
52** Returns          void
53**
54*******************************************************************************/
55void nfa_sys_cback_notify_enable_complete (UINT8 id)
56{
57    nfa_sys_cb.enable_cplt_flags |= (0x0001 << id);
58
59    NFA_TRACE_DEBUG2 ("nfa_sys_cback_notify_enable_complete () enable_cplt_flags=0x%x, enable_cplt_mask=0x%x",
60                       nfa_sys_cb.enable_cplt_flags, nfa_sys_cb.enable_cplt_mask);
61
62    if (  (nfa_sys_cb.enable_cplt_flags == nfa_sys_cb.enable_cplt_mask)
63        &&(nfa_sys_cb.p_enable_cback)  )
64    {
65        nfa_sys_cb.p_enable_cback ();
66        nfa_sys_cb.p_enable_cback = NULL;
67    }
68}
69
70/*******************************************************************************
71**
72** Function         nfa_sys_cback_reg_nfcc_power_mode_proc_complete
73**
74** Description      Called to register a callback function for complete of processing
75**                  NFCC power mode change from NFA sub-systems
76**
77** Returns          void
78**
79*******************************************************************************/
80void nfa_sys_cback_reg_nfcc_power_mode_proc_complete (tNFA_SYS_PROC_NFCC_PWR_MODE_CMPL *p_cback)
81{
82    nfa_sys_cb.p_proc_nfcc_pwr_mode_cmpl_cback = p_cback;
83    nfa_sys_cb.proc_nfcc_pwr_mode_cplt_flags   = 0;
84}
85
86/*******************************************************************************
87**
88** Function         nfa_sys_cback_notify_nfcc_power_mode_proc_complete
89**
90** Description      Called by other NFA subsystems to notify processing NFCC power
91**                  mode is complete
92**
93** Returns          void
94**
95*******************************************************************************/
96void nfa_sys_cback_notify_nfcc_power_mode_proc_complete (UINT8 id)
97{
98    nfa_sys_cb.proc_nfcc_pwr_mode_cplt_flags |= (0x0001 << id);
99
100    NFA_TRACE_DEBUG2 ("nfa_sys_cback_notify_nfcc_power_mode_proc_complete () flags=0x%x, mask=0x%x",
101                       nfa_sys_cb.proc_nfcc_pwr_mode_cplt_flags,
102                       nfa_sys_cb.proc_nfcc_pwr_mode_cplt_mask);
103
104    if (  (nfa_sys_cb.proc_nfcc_pwr_mode_cplt_flags == nfa_sys_cb.proc_nfcc_pwr_mode_cplt_mask) /* except SYS */
105        &&(nfa_sys_cb.p_proc_nfcc_pwr_mode_cmpl_cback)  )
106    {
107        nfa_sys_cb.p_proc_nfcc_pwr_mode_cmpl_cback ();
108        nfa_sys_cb.p_proc_nfcc_pwr_mode_cmpl_cback = NULL;
109    }
110}
111