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 uint8_t deact_reason; 49 50 } tNFA_WLC_EVT_DATA; 51 52 /* NFA WLC callback events */ 53 typedef enum { 54 NFA_WLC_ENABLE_RESULT_EVT, /* The status for NFA_WlcEnable () */ 55 NFA_WLC_START_RESULT_EVT, /* The status for NFA_WlcStart () */ 56 NFA_WLC_START_WPT_RESULT_EVT, /* The status for NFA_WlcStartWPT () */ 57 NFA_WLC_CHARGING_RESULT_EVT, /* Notification of WPT_START completion */ 58 } tNFA_WLC_EVT; 59 60 /* NFA WLC Callback */ 61 typedef void(tNFA_WLC_CBACK)(tNFA_WLC_EVT event, tNFA_WLC_EVT_DATA* p_data); 62 63 /***************************************************************************** 64 ** External Function Declarations 65 *****************************************************************************/ 66 67 /******************************************************************************* 68 ** 69 ** Function NFA_WlcEnable 70 ** 71 ** Description This function enables WLC module callback. Prior to calling 72 ** NFA_WlcEnable, WLC module must be enabled by NFA system 73 ** manager (done when NFA_Enable called). 74 ** 75 ** When the enabling is completed, an NFA_WLC_ENABLE_RESULT_EVT 76 ** is returned to the application using the tNFA_WLC_CBACK. 77 ** 78 ** p_wlc_cback: callback to notify later NFCC events 79 ** 80 ** Returns NFA_STATUS_OK if successfully initiated 81 ** NFA_STATUS_FAILED otherwise 82 ** 83 *******************************************************************************/ 84 extern tNFA_STATUS NFA_WlcEnable(tNFA_WLC_CBACK* p_wlc_cback); 85 86 /******************************************************************************* 87 ** 88 ** Function NFA_WlcStart 89 ** 90 ** Description Perform the WLC start procedure. 91 ** 92 ** Upon successful completion of RF Interface Extension start 93 ** (according to the NFC Forum NCI2.3 conditions) and upload 94 ** of WLC Poller parameters (Non-Autonomous mode only), 95 ** an NFA_WLC_START_RESULT_EVT is returned to the application 96 ** using the tNFA_WLC_CBACK. 97 ** 98 ** mode: WLC-P Non-Autonomous (0) or Semi-Autonomous mode 99 ** 100 ** Returns: 101 ** NFA_STATUS_OK if successfully started 102 ** NFA_STATUS_FAILED otherwise 103 ** 104 *******************************************************************************/ 105 extern tNFA_STATUS NFA_WlcStart(tNFA_WLC_MODE mode); 106 107 /******************************************************************************* 108 ** 109 ** Function NFA_WlcStartWPT 110 ** 111 ** Description Start a wireless power transfer cycle in Non-Autonomous 112 ** WLCP mode ([WLC2.0] Technical Specifications state 21 113 ** for negotiated or state 6 for static WLC mode). 114 ** 115 ** Upon successful completion of WPT start, 116 ** an NFA_WLC_START_WPT_RESULT_EVT is returned to the 117 *application 118 ** using the tNFA_WLC_CBACK. 119 ** 120 ** When the duration for the power transfer ends or 121 ** any error/completion condition occurred, NFCC notifies the 122 *DH 123 ** with an NFA_WLC_CHARGING_RESULT_EVT and end condition value. 124 ** 125 ** power_adj_req: POWER_ADUJUST_REQ as defined in [WLC] 126 ** wpt_time_int: WPT_INT_TIME as defined in [WLC] 127 ** 128 ** Returns: 129 ** NFA_STATUS_OK if successfully started 130 ** NFA_STATUS_FAILED otherwise 131 ** 132 *******************************************************************************/ 133 extern tNFA_STATUS NFA_WlcStartWPT(uint8_t power_adj_req, uint8_t wpt_time_int); 134 135 #endif /* NFA_WLC_API_H */ 136