Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2010 NXP Semiconductors
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 
     18 /**
     19 * \file phHal4Nfc_Internal.h
     20 * \brief HAL callback Function Prototypes
     21 *
     22 *  The HAL4.0 Internal header file
     23 *
     24 * Project: NFC-FRI-1.1 / HAL4.0
     25 *
     26 * $Date: Mon May 31 11:43:42 2010 $
     27 * $Author: ing07385 $
     28 * $Revision: 1.40 $
     29 * $Aliases: NFC_FRI1.1_WK1023_R35_1 $
     30 *
     31 */
     32 
     33 /*@{*/
     34 #ifndef PHHAL4NFC_INTERNAL_H
     35 #define PHHAL4NFC_INTERNAL_H
     36 /*@}*/
     37 
     38 #include <phHciNfc.h>
     39 
     40 /**
     41 *  \name HAL4
     42 *
     43 * File: \ref phHal4Nfc_Internal.h
     44 *
     45 */
     46 
     47 /*@{*/
     48 #define PH_HAL4NFC_INTERNAL_FILEREVISION "$Revision: 1.40 $" /**< \ingroup grp_file_attributes */
     49 #define PH_HAL4NFC_INTERNAL_FILEALIASES  "$Aliases: NFC_FRI1.1_WK1023_R35_1 $"     /**< \ingroup grp_file_attributes */
     50 /*@}*/
     51 
     52 /* -----------------Include files ---------------------------------------*/
     53 
     54 /* ---------------- Macros ----------------------------------------------*/
     55 #define LLCP_DISCON_CHANGES
     56 #define PH_HAL4NFC_TRANSCEIVE_TIMEOUT        30000  /**<Transceive operation
     57                                                         on any target should be
     58                                                         completed within this
     59                                                         interval.Else the
     60                                                         operation is timed out*/
     61 
     62 #define   PH_HAL4NFC_TGT_MERGE_ADDRESS          0x988BU
     63 #define   PH_HAL4NFC_TGT_MERGE_SAK                0x00U
     64 
     65 
     66 /*---------------- Hal4 Internal Data Structures -------------------------*/
     67 /**HAL4 states*/
     68 typedef enum{
     69     eHal4StateClosed = 0x00,  /**<closed state*/
     70     eHal4StateSelfTestMode, /**<Self test mode*/
     71     eHal4StateOpenAndReady ,/**<Fully initialised*/
     72     eHal4StateConfiguring ,  /**<configuration ongoing,transient state*/
     73     eHal4StateTargetDiscovered,/**<target discovered*/
     74     eHal4StateTargetActivate,/**<state during a select or reactivate*/
     75     eHal4StateEmulation,/**<Emulation state*/
     76     eHal4StateTargetConnected,/**<Connected state*/
     77     eHal4StateTransaction,/**<configuration ongoing,transient state*/
     78     eHal4StatePresenceCheck,/**<Presence Check state*/
     79     eHal4StateInvalid
     80 } phHal4Nfc_Hal4state_t;
     81 
     82 
     83 /**Global Pointer to hardware reference used in timer callbacks to get the
     84    context pointer*/
     85 extern phHal_sHwReference_t *gpphHal4Nfc_Hwref;
     86 
     87 /**Context info for HAL4 transceive*/
     88 typedef struct phHal4Nfc_TrcvCtxtInfo{
     89     /*Upper layer's Transceive callback*/
     90     pphHal4Nfc_TransceiveCallback_t  pUpperTranceiveCb;
     91      /*Upper layer's Send callback*/
     92     pphHal4Nfc_SendCallback_t        pP2PSendCb;
     93      /*Upper layer's receive callback*/
     94     pphHal4Nfc_ReceiveCallback_t     pP2PRecvCb;
     95     /**Flag to check if a P2P Send is ongoing when target release is issued by
     96        the upper layer.If this flag is set ,then a remote device disconnect call
     97        will be deferred*/
     98     uint8_t                          P2P_Send_In_Progress;
     99     /*Data structure to provide transceive info to Hci*/
    100     phHciNfc_XchgInfo_t              XchangeInfo;
    101     /*sData pointer to point to upper layer's send data*/
    102     phNfc_sData_t                   *psUpperSendData;
    103     /*Maintains the offset of number of bytes sent in one go ,so that the
    104       remaining bytes can be sent during the next transceive*/
    105     uint32_t                         NumberOfBytesSent;
    106     /*Number of bytes received during a P2p receive*/
    107     uint32_t                         P2PRecvLength;
    108     /*sData pointer to point to upper layer's recv data*/
    109     phNfc_sData_t                   *psUpperRecvData;
    110     /*structure to hold data received from lower layer*/
    111     phNfc_sData_t                    sLowerRecvData;
    112     /*Offset for Lower Recv Data buffer*/
    113     uint32_t                         LowerRecvBufferOffset;
    114     /*Holds the status of the RecvDataBuffer:
    115     NFCSTATUS_SUCCESS:Receive data buffer is complete with data & P2P receive has
    116                       not yet been called
    117     NFCSTATUS_PENDING:RecvDataBuffer is yet to receive the data from lower layer
    118     */
    119     NFCSTATUS                        RecvDataBufferStatus;
    120     /*Transaction timer ,currently used only for P2P receive on target*/
    121     uint32_t                         TransactionTimerId;
    122 }phHal4Nfc_TrcvCtxtInfo_t,*pphHal4Nfc_TrcvCtxtInfo_t;
    123 
    124 
    125 /**Context info for HAL4 Device discovery feature*/
    126 typedef struct phHal4Nfc_ADDCtxtInfo{
    127     /*total number of devices discovered*/
    128     uint8_t                          nbr_of_devices;
    129     /*smx_discovery*/
    130     uint8_t                          smx_discovery;
    131     /*Most recently used ADD configuration*/
    132     phHal_sADD_Cfg_t                 sADDCfg;
    133     /*Most recently used Poll configuration*/
    134     phHal_sPollDevInfo_t             sCurrentPollConfig;
    135     /*Set when Poll Configured and reset when polling is disabled.*/
    136     uint8_t                          IsPollConfigured;
    137 }phHal4Nfc_ADDCtxtInfo_t,*pphHal4Nfc_ADDCtxtInfo_t;
    138 
    139 /**Context info for HAL4 connect/disconnect*/
    140 typedef struct phHal4Nfc_TargetConnectInfo{
    141     /*connect callback*/
    142     pphHal4Nfc_ConnectCallback_t     pUpperConnectCb;
    143     /*Disconnect callback*/
    144     pphHal4Nfc_DiscntCallback_t      pUpperDisconnectCb;
    145     /*used when a release call is pending in HAL*/
    146     phHal_eReleaseType_t             ReleaseType;
    147     /*Points to Remote device info of a connected device*/
    148     phHal_sRemoteDevInformation_t   *psConnectedDevice;
    149     /*Emulation state Activated/Deactivated*/
    150     phHal_Event_t                    EmulationState;
    151     /*Presence check callback*/
    152     pphHal4Nfc_GenCallback_t         pPresenceChkCb;
    153 }phHal4Nfc_TargetConnectInfo_t,*pphHal4Nfc_TargetConnectInfo_t;
    154 
    155 /**Context info for HAL4 connect & disconnect*/
    156 typedef struct phHal4Nfc_UpperLayerInfo{
    157     /*Upper layer Context for discovery call*/
    158     void                            *DiscoveryCtxt;
    159     /*Upper layer Context for P2P discovery call*/
    160     void                            *P2PDiscoveryCtxt;
    161     /**Context and function pointer for default event handler registered
    162       by upper layer during initialization*/
    163     void                            *DefaultListenerCtxt;
    164     /*Default event handler*/
    165     pphHal4Nfc_Notification_t        pDefaultEventHandler;
    166     /**Upper layer has to register this listener for receiving info about
    167         discovered tags*/
    168     pphHal4Nfc_Notification_t        pTagDiscoveryNotification;
    169     /**Upper layer has to register this  listener for receiving info about
    170         discovered P2P devices*/
    171     pphHal4Nfc_Notification_t        pP2PNotification;
    172     /*Event Notification Context*/
    173     void                            *EventNotificationCtxt;
    174     /**Notification handler for emulation and other events*/
    175     pphHal4Nfc_Notification_t        pEventNotification;
    176     /**Upper layer's Config discovery/Emulation callback registry*/
    177     pphHal4Nfc_GenCallback_t         pConfigCallback;
    178     void                            *psUpperLayerCtxt;
    179     void                            *psUpperLayerDisconnectCtxt;
    180 #ifdef LLCP_DISCON_CHANGES
    181     void                            *psUpperLayerCfgDiscCtxt;
    182 #endif /* #ifdef LLCP_DISCON_CHANGES */
    183      /**Upper layer's Open Callback registry*/
    184     pphHal4Nfc_GenCallback_t         pUpperOpenCb;
    185     /**Upper layer's Close Callback registry */
    186     pphHal4Nfc_GenCallback_t         pUpperCloseCb;
    187     /*Ioctl out param pointer ,points to buffer provided by upper layer during
    188       a ioctl call*/
    189     phNfc_sData_t                   *pIoctlOutParam;
    190     /*Ioctl callback*/
    191     pphHal4Nfc_IoctlCallback_t       pUpperIoctlCb;
    192 }phHal4Nfc_UpperLayerInfo_t;
    193 
    194 /**Context structure for HAL4.0*/
    195 typedef struct phHal4Nfc_Hal4Ctxt{
    196     /**Hci handle obtained in Hci_Init*/
    197     void                            *psHciHandle;
    198     /**Layer configuration*/
    199     pphNfcLayer_sCfg_t               pHal4Nfc_LayerCfg;
    200     /**Device capabilities*/
    201     phHal_sDeviceCapabilities_t      Hal4Nfc_DevCaps;
    202     /*Current state of HAL4.Updated generally in callbacks*/
    203     phHal4Nfc_Hal4state_t            Hal4CurrentState;
    204     /*Next state of HAL.Updated during calls*/
    205     phHal4Nfc_Hal4state_t            Hal4NextState;
    206     /**Info related to upper layer*/
    207     phHal4Nfc_UpperLayerInfo_t       sUpperLayerInfo;
    208      /*ADD context info*/
    209     pphHal4Nfc_ADDCtxtInfo_t         psADDCtxtInfo;
    210     /*union for different configurations ,used in a config_parameters()call*/
    211     phHal_uConfig_t                  uConfig;
    212      /*Event info*/
    213     phHal_sEventInfo_t              *psEventInfo;
    214     /*Select sector flag*/
    215     uint8_t                          SelectSectorFlag;
    216     /**List of pointers to remote device information for all discovered
    217        targets*/
    218     phHal_sRemoteDevInformation_t   *rem_dev_list[MAX_REMOTE_DEVICES];
    219     /*Transceive context info*/
    220     pphHal4Nfc_TrcvCtxtInfo_t        psTrcvCtxtInfo;
    221     /*Connect context info*/
    222     phHal4Nfc_TargetConnectInfo_t    sTgtConnectInfo;
    223     /*Last called Ioctl_type*/
    224     uint32_t                         Ioctl_Type;
    225 #ifdef IGNORE_EVT_PROTECTED
    226     /*used to ignore multiple Protected events*/
    227     uint8_t                          Ignore_Event_Protected;
    228 #endif/*#ifdef IGNORE_EVT_PROTECTED*/
    229     uint8_t                          FelicaIDm[(PHHAL_FEL_ID_LEN + 2)];
    230 }phHal4Nfc_Hal4Ctxt_t;
    231 
    232 
    233 /*---------------- Function Prototypes ----------------------------------------------*/
    234 
    235 /*Callback completion routine for Connect*/
    236 extern void phHal4Nfc_ConnectComplete(
    237                                       phHal4Nfc_Hal4Ctxt_t  *Hal4Ctxt,
    238                                       void *pInfo
    239                                       );
    240 
    241 /*Callback completion routine for Disconnect*/
    242 extern void phHal4Nfc_DisconnectComplete(
    243                             phHal4Nfc_Hal4Ctxt_t  *Hal4Ctxt,
    244                             void *pInfo
    245                             );
    246 
    247 /*Callback completion routine for Transceive*/
    248 extern void phHal4Nfc_TransceiveComplete(
    249                         phHal4Nfc_Hal4Ctxt_t  *Hal4Ctxt,
    250                         void *pInfo
    251                         );
    252 
    253 /*Callback completion routine for Presence check*/
    254 extern void phHal4Nfc_PresenceChkComplete(
    255                         phHal4Nfc_Hal4Ctxt_t  *Hal4Ctxt,
    256                         void *pInfo
    257                         );
    258 
    259 /*Configuration completion routine*/
    260 extern void phHal4Nfc_ConfigureComplete(
    261                                         phHal4Nfc_Hal4Ctxt_t  *Hal4Ctxt,
    262                                         void *pInfo,
    263                                         uint8_t type
    264                                         );
    265 
    266 
    267 /*Callback completion routine for ADD*/
    268 extern void phHal4Nfc_TargetDiscoveryComplete(
    269                             phHal4Nfc_Hal4Ctxt_t  *Hal4Ctxt,
    270                             void *pInfo
    271                             );
    272 
    273 /*Event handler routine for Emulation*/
    274 extern void phHal4Nfc_HandleEmulationEvent(
    275                         phHal4Nfc_Hal4Ctxt_t  *Hal4Ctxt,
    276                         void *pInfo
    277                         );
    278 
    279 /*Callback completion routine for NFCIP1 Receive*/
    280 extern void phHal4Nfc_RecvCompleteHandler(phHal4Nfc_Hal4Ctxt_t  *Hal4Ctxt,void *pInfo);
    281 
    282 /*Callback completion routine for Send*/
    283 extern void phHal4Nfc_SendCompleteHandler(phHal4Nfc_Hal4Ctxt_t  *Hal4Ctxt,void *pInfo);
    284 
    285 /*Callback completion routine for P2P Activate Event received from HCI*/
    286 extern void phHal4Nfc_P2PActivateComplete(
    287                     phHal4Nfc_Hal4Ctxt_t  *Hal4Ctxt,
    288                     void *pInfo
    289                     );
    290 /*Callback completion routine for P2P Deactivate Event received from HCI*/
    291 extern void phHal4Nfc_HandleP2PDeActivate(
    292                         phHal4Nfc_Hal4Ctxt_t  *Hal4Ctxt,
    293                         void *pInfo
    294                         );
    295 
    296 /*Callback completion routine for reactivate target*/
    297 extern void phHal4Nfc_ReactivationComplete(
    298                         phHal4Nfc_Hal4Ctxt_t  *Hal4Ctxt,
    299                         void *pInfo
    300                         );
    301 
    302 /**Execute Hal4 Disconnect*/
    303 extern NFCSTATUS phHal4Nfc_Disconnect_Execute(
    304                             phHal_sHwReference_t  *psHwReference
    305                             );
    306 
    307 /**Handle transceive timeout*/
    308 #ifdef TRANSACTION_TIMER
    309 extern void phHal4Nfc_TrcvTimeoutHandler(uint32_t TrcvTimerId);
    310 #endif /*TRANSACTION_TIMER*/
    311 
    312 #endif/*PHHAL4NFC_INTERNAL_H*/
    313 
    314 
    315