1 /****************************************************************************** 2 * 3 * Copyright (C) 2023 The Android Open Source Project. 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 * NFA wireless charging API functions 22 * 23 ******************************************************************************/ 24 #ifndef NFA_WLC_API_H 25 #define NFA_WLC_API_H 26 27 #include "nfa_api.h" 28 #include "nfc_target.h" 29 30 /***************************************************************************** 31 ** Constants and data types 32 *****************************************************************************/ 33 enum { 34 NFA_WLC_NON_AUTONOMOUS = 0, /* Default behavior: DH handles WLC protocol */ 35 NFA_WLC_SEMI_AUTONOMOUS, /* WLC protocol split between DH and NFCC */ 36 NFA_WLC_AUTONOMOUS /* NFCC handles WLC protocol */ 37 }; 38 typedef uint8_t tNFA_WLC_MODE; 39 40 /***************************************************************************** 41 ** NFA WLC Constants and definitions 42 *****************************************************************************/ 43 44 /* Union of all WLC callback structures */ 45 typedef union { 46 tNFA_STATUS status; /* NFA_WLC_..._EVT */ 47 uint8_t wpt_end_cdt; 48 49 } tNFA_WLC_EVT_DATA; 50 51 /* NFA WLC callback events */ 52 typedef enum { 53 NFA_WLC_ENABLE_RESULT_EVT, /* The status for NFA_WlcEnable () */ 54 NFA_WLC_START_RESULT_EVT, /* The status for NFA_WlcStart () */ 55 NFA_WLC_START_WPT_RESULT_EVT, /* The status for NFA_WlcStartWPT () */ 56 NFA_WLC_CHARGING_RESULT_EVT, /* Notification of WPT_START completion */ 57 } tNFA_WLC_EVT; 58 59 /* NFA WLC Callback */ 60 typedef void(tNFA_WLC_CBACK)(tNFA_WLC_EVT event, tNFA_WLC_EVT_DATA* p_data); 61 62 /***************************************************************************** 63 ** External Function Declarations 64 *****************************************************************************/ 65 66 /******************************************************************************* 67 ** 68 ** Function NFA_WlcEnable 69 ** 70 ** Description This function enables WLC module callback. Prior to calling 71 ** NFA_WlcEnable, WLC module must be enabled by NFA system 72 ** manager (done when NFA_Enable called). 73 ** 74 ** When the enabling is completed, an NFA_WLC_ENABLE_RESULT_EVT 75 ** is returned to the application using the tNFA_WLC_CBACK. 76 ** 77 ** p_wlc_cback: callback to notify later NFCC events 78 ** 79 ** Returns NFA_STATUS_OK if successfully initiated 80 ** NFA_STATUS_FAILED otherwise 81 ** 82 *******************************************************************************/ 83 extern tNFA_STATUS NFA_WlcEnable(tNFA_WLC_CBACK* p_wlc_cback); 84 85 /******************************************************************************* 86 ** 87 ** Function NFA_WlcStart 88 ** 89 ** Description Perform the WLC start procedure. 90 ** 91 ** Upon successful completion of RF Interface Extension start 92 ** (according to the NFC Forum NCI2.3 conditions) and upload 93 ** of WLC Poller parameters (Non-Autonomous mode only), 94 ** an NFA_WLC_START_RESULT_EVT is returned to the application 95 ** using the tNFA_WLC_CBACK. 96 ** 97 ** mode: WLC-P Non-Autonomous (0) or Semi-Autonomous mode 98 ** 99 ** Returns: 100 ** NFA_STATUS_OK if successfully started 101 ** NFA_STATUS_FAILED otherwise 102 ** 103 *******************************************************************************/ 104 extern tNFA_STATUS NFA_WlcStart(tNFA_WLC_MODE mode); 105 106 /******************************************************************************* 107 ** 108 ** Function NFA_WlcStartWPT 109 ** 110 ** Description Start a wireless power transfer cycle in Non-Autonomous 111 ** WLCP mode ([WLC2.0] Technical Specifications state 21 112 ** for negotiated or state 6 for static WLC mode). 113 ** 114 ** Upon successful completion of WPT start, 115 ** an NFA_WLC_START_WPT_RESULT_EVT is returned to the 116 *application 117 ** using the tNFA_WLC_CBACK. 118 ** 119 ** When the duration for the power transfer ends or 120 ** any error/completion condition occurred, NFCC notifies the 121 *DH 122 ** with an NFA_WLC_CHARGING_RESULT_EVT and end condition value. 123 ** 124 ** power_adj_req: POWER_ADUJUST_REQ as defined in [WLC] 125 ** wpt_time_int: WPT_INT_TIME as defined in [WLC] 126 ** 127 ** Returns: 128 ** NFA_STATUS_OK if successfully started 129 ** NFA_STATUS_FAILED otherwise 130 ** 131 *******************************************************************************/ 132 extern tNFA_STATUS NFA_WlcStartWPT(uint8_t power_adj_req, uint8_t wpt_time_int); 133 134 #endif /* NFA_WLC_API_H */ 135