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  phFriNfc_LlcpMac.h
     20  * \brief NFC LLCP MAC Mappings For Different RF Technologies.
     21  *
     22  * Project: NFC-FRI
     23  *
     24  */
     25 
     26 #ifndef PHFRINFC_LLCPMAC_H
     27 #define PHFRINFC_LLCPMAC_H
     28 
     29 
     30 /*include files*/
     31 #include <phNfcTypes.h>
     32 #include <phNfcLlcpTypes.h>
     33 #include <phNfcStatus.h>
     34 #include <phFriNfc.h>
     35 
     36 #include <phFriNfc_OvrHal.h>
     37 
     38 /**
     39  * \name LLCP MAC Mapping
     40  *
     41  * File: \ref phFriNfc_LlcpMac.h
     42  *
     43  */
     44 
     45 
     46 /** \defgroup grp_fri_nfc_llcp_mac LLCP MAC Mapping Component
     47  *
     48  *  This component implements the different MAC mapping for a Logical Link Control Protocol communication,
     49  *  as defined by the NFC Forum LLCP specifications.\n
     50  *  The MAC component handles the mapping for the different technologies supported by LLCP
     51  *..This component provides an API to the upper layer with the following features:\n\n
     52  *  - Reset the MAC mapping component
     53  *      - \ref phFriNfc_LlcpMac_ChkLlcp
     54  *      .
     55  *  - Check the LLCP Compliancy
     56  *      - \ref phFriNfc_LlcpMac_ChkLlcp
     57  *      .
     58  *  - Activate the LLCP link
     59  *      - \ref phFriNfc_LlcpMac_Activate
     60  *      .
     61  *  - Deactivate the LLCP link
     62  *      - \ref phFriNfc_LlcpMac_Deactivate
     63  *      .
     64  *  - Register the MAC component Interface with a specific technologie (NFCIP/ISO14443)
     65  *      - \ref phFriNfc_LlcpMac_Register
     66  *      .
     67  *  - Send packets through the LLCP link
     68  *      - \ref phFriNfc_LlcpMac_Send
     69  *      .
     70   *  - Receive packets through the LLCP link
     71  *      - \ref phFriNfc_LlcpMac_Receive
     72  *
     73  */
     74 
     75 /**
     76  * \ingroup grp_fri_nfc_llcp_mac
     77  * \brief Declaration of a MAC type
     78  */
     79 struct phFriNfc_LlcpMac;
     80 typedef struct phFriNfc_LlcpMac phFriNfc_LlcpMac_t;
     81 
     82 /**
     83  *  \ingroup grp_fri_nfc_llcp_mac
     84  *
     85  */
     86 /*========== ENUMERATES ===========*/
     87 
     88 /* Enum reperesents the different MAC mapping*/
     89 typedef enum phFriNfc_LlcpMac_eType
     90 {
     91    phFriNfc_LlcpMac_eTypeNfcip,
     92    phFriNfc_LlcpMac_eTypeIso14443
     93 }phFriNfc_LlcpMac_eType_t;
     94 
     95 /* Enum reperesents the different Peer type for a LLCP communication*/
     96 typedef enum phFriNfc_LlcpMac_ePeerType
     97 {
     98    phFriNfc_LlcpMac_ePeerTypeInitiator,
     99    phFriNfc_LlcpMac_ePeerTypeTarget
    100 }phFriNfc_LlcpMac_ePeerType_t;
    101 
    102 
    103 
    104 
    105 
    106 
    107 /*========== CALLBACKS ===========*/
    108 
    109 typedef void (*phFriNfc_LlcpMac_Chk_CB_t) (void        *pContext,
    110                                            NFCSTATUS   status);
    111 
    112 typedef void (*phFriNfc_LlcpMac_LinkStatus_CB_t) (void                             *pContext,
    113                                                   phFriNfc_LlcpMac_eLinkStatus_t   eLinkStatus,
    114                                                   phNfc_sData_t                    *psData,
    115                                                   phFriNfc_LlcpMac_ePeerType_t     PeerRemoteDevType);
    116 
    117 typedef void (*phFriNfc_LlcpMac_Send_CB_t) (void            *pContext,
    118                                             NFCSTATUS       status);
    119 
    120 
    121 typedef void (*phFriNfc_LlcpMac_Reveive_CB_t) (void               *pContext,
    122                                                NFCSTATUS          status,
    123                                                phNfc_sData_t      *psData);
    124 
    125 
    126 /*========== FUNCTIONS TYPES ===========*/
    127 
    128 typedef NFCSTATUS (*pphFriNfcLlpcMac_Chk_t) ( phFriNfc_LlcpMac_t               *LlcpMac,
    129                                               phFriNfc_LlcpMac_Chk_CB_t        ChkLlcpMac_Cb,
    130                                               void                             *pContext);
    131 
    132 typedef NFCSTATUS (*pphFriNfcLlpcMac_Activate_t) (phFriNfc_LlcpMac_t                   *LlcpMac);
    133 
    134 typedef NFCSTATUS (*pphFriNfcLlpcMac_Deactivate_t) (phFriNfc_LlcpMac_t                 *LlcpMac);
    135 
    136 typedef NFCSTATUS (*pphFriNfcLlpcMac_Send_t) (phFriNfc_LlcpMac_t               *LlcpMac,
    137                                               phNfc_sData_t                    *psData,
    138                                               phFriNfc_LlcpMac_Send_CB_t       LlcpMacSend_Cb,
    139                                               void                             *pContext);
    140 
    141 typedef NFCSTATUS (*pphFriNfcLlpcMac_Receive_t) (phFriNfc_LlcpMac_t               *LlcpMac,
    142                                                  phNfc_sData_t                    *psData,
    143                                                  phFriNfc_LlcpMac_Reveive_CB_t    LlcpMacReceive_Cb,
    144                                                  void                             *pContext);
    145 
    146 /*========== STRUCTURES ===========*/
    147 
    148 /**
    149  * \ingroup grp_fri_nfc_llcp_mac
    150  * \brief Generic Interface structure with the Lower Layer
    151  */
    152 typedef struct phFriNfc_LlcpMac_Interface
    153 {
    154    pphFriNfcLlpcMac_Chk_t              chk;
    155    pphFriNfcLlpcMac_Activate_t         activate;
    156    pphFriNfcLlpcMac_Deactivate_t       deactivate;
    157    pphFriNfcLlpcMac_Send_t             send;
    158    pphFriNfcLlpcMac_Receive_t          receive;
    159 } phFriNfc_LlcpMac_Interface_t;
    160 
    161 /**
    162  * \ingroup grp_fri_nfc_llcp_mac
    163  * \brief Definition of the MAC type
    164  */
    165 struct phFriNfc_LlcpMac
    166 {
    167    phFriNfc_LlcpMac_eLinkStatus_t      LinkState;
    168    phHal_sRemoteDevInformation_t       *psRemoteDevInfo;
    169    phFriNfc_LlcpMac_LinkStatus_CB_t    LinkStatus_Cb;
    170    void                                *LinkStatus_Context;
    171    phFriNfc_LlcpMac_Interface_t        LlcpMacInterface;
    172    phFriNfc_LlcpMac_ePeerType_t        PeerRemoteDevType;
    173    phFriNfc_LlcpMac_eType_t            MacType;
    174 
    175    /**<\internal Holds the completion routine informations of the Map Layer*/
    176    phFriNfc_CplRt_t                   MacCompletionInfo;
    177    void                               *LowerDevice;
    178    phFriNfc_LlcpMac_Send_CB_t         MacSend_Cb;
    179    void                               *MacSend_Context;
    180    phFriNfc_LlcpMac_Reveive_CB_t      MacReceive_Cb;
    181    void                               *MacReceive_Context;
    182    phNfc_sData_t                      *psReceiveBuffer;
    183    phNfc_sData_t                      *psSendBuffer;
    184    phNfc_sData_t                      sConfigParam;
    185    uint8_t                            RecvPending;
    186    uint8_t                            SendPending;
    187    uint8_t                            RecvStatus;
    188    phHal_uCmdList_t                   Cmd;
    189    phHal_sDepAdditionalInfo_t         psDepAdditionalInfo;
    190 } ;
    191 
    192 
    193 /*
    194 ################################################################################
    195 ********************** MAC Interface Function Prototype  ***********************
    196 ################################################################################
    197 */
    198 
    199 /**
    200  * \ingroup grp_fri_nfc_llcp_mac
    201  * \brief
    202  */
    203 NFCSTATUS phFriNfc_LlcpMac_Reset (phFriNfc_LlcpMac_t                 *LlcpMac,
    204                                   void                               *LowerDevice,
    205                                   phFriNfc_LlcpMac_LinkStatus_CB_t   LinkStatus_Cb,
    206                                   void                               *pContext);
    207 /**
    208  * \ingroup grp_fri_nfc_llcp_mac
    209  * \brief
    210  */
    211 NFCSTATUS phFriNfc_LlcpMac_ChkLlcp (phFriNfc_LlcpMac_t                  *LlcpMac,
    212                                     phHal_sRemoteDevInformation_t       *psRemoteDevInfo,
    213                                     phFriNfc_LlcpMac_Chk_CB_t           ChkLlcpMac_Cb,
    214                                     void                                *pContext);
    215 
    216 /**
    217  * \ingroup grp_fri_nfc_llcp_mac
    218  * \brief
    219  */
    220 NFCSTATUS phFriNfc_LlcpMac_Activate (phFriNfc_LlcpMac_t                   *LlcpMac);
    221 
    222 /**
    223  * \ingroup grp_fri_nfc_llcp_mac
    224  * \brief
    225  */
    226 NFCSTATUS phFriNfc_LlcpMac_Deactivate (phFriNfc_LlcpMac_t                 *LlcpMac);
    227 
    228 /**
    229  * \ingroup grp_fri_nfc_llcp_mac
    230  * \brief
    231  */
    232 NFCSTATUS phFriNfc_LlcpMac_Send (phFriNfc_LlcpMac_t               *LlcpMac,
    233                                  phNfc_sData_t                    *psData,
    234                                  phFriNfc_LlcpMac_Send_CB_t       LlcpMacSend_Cb,
    235                                  void                             *pContext);
    236 
    237 /**
    238  * \ingroup grp_fri_nfc_llcp_mac
    239  * \brief
    240  */
    241 NFCSTATUS phFriNfc_LlcpMac_Receive (phFriNfc_LlcpMac_t               *LlcpMac,
    242                                     phNfc_sData_t                    *psData,
    243                                     phFriNfc_LlcpMac_Reveive_CB_t    ReceiveLlcpMac_Cb,
    244                                     void                             *pContext);
    245 
    246 #endif /* PHFRINFC_LLCPMAC_H */
    247