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