Home | History | Annotate | Download | only in common
      1 /*
      2  * Copyright (C) 2010-2014 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  *  OSAL header files related to memory, debug, random, semaphore and mutex
     19  * functions.
     20  */
     21 
     22 #ifndef PHNFCCOMMON_H
     23 #define PHNFCCOMMON_H
     24 
     25 /*
     26 ************************* Include Files ****************************************
     27 */
     28 
     29 #include <phDal4Nfc_messageQueueLib.h>
     30 #include <phNfcCompId.h>
     31 #include <phNfcStatus.h>
     32 #include <phOsalNfc_Timer.h>
     33 #include <pthread.h>
     34 #include <semaphore.h>
     35 
     36 #define FW_DLL_ROOT_DIR "/system/vendor/firmware/"
     37 #define FW_DLL_EXTENSION ".so"
     38 
     39 #if (NFC_NXP_CHIP_TYPE == PN548C2)
     40 
     41 /* Actual FW library name*/
     42 #define FW_LIB_PATH FW_DLL_ROOT_DIR "libpn548ad_fw" FW_DLL_EXTENSION
     43 /* Restore Corrupted PLL Setttings/etc */
     44 #define PLATFORM_LIB_PATH \
     45   FW_DLL_ROOT_DIR "libpn548ad_fw_platform" FW_DLL_EXTENSION
     46 /* Upgrade the public Key */
     47 #define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn548ad_fw_pku" FW_DLL_EXTENSION
     48 #elif (NFC_NXP_CHIP_TYPE == PN551)
     49 /* Actual FW library name*/
     50 #define FW_LIB_PATH FLASH_CONF_ROOT_DIR "libpn551_fw" FW_DLL_EXTENSION
     51 /* Restore Corrupted PLL Settings/etc */
     52 #define PLATFORM_LIB_PATH \
     53   FW_DLL_ROOT_DIR "libpn551_fw_platform" FW_DLL_EXTENSION
     54 /* Upgrade the public Key */
     55 #define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn551_fw_pku" FW_DLL_EXTENSION
     56 #elif (NFC_NXP_CHIP_TYPE == PN553)
     57 /* Actual FW library name*/
     58 #define FW_LIB_PATH FLASH_CONF_ROOT_DIR "libpn553_fw" FW_DLL_EXTENSION
     59 /* Restore Corrupted PLL Settings/etc */
     60 #define PLATFORM_LIB_PATH \
     61   FW_DLL_ROOT_DIR "libpn553_fw_platform" FW_DLL_EXTENSION
     62 /* Upgrade the public Key */
     63 #define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn553_fw_pku" FW_DLL_EXTENSION
     64 #else
     65 /* Actual FW library name*/
     66 #define FW_LIB_PATH FW_DLL_ROOT_DIR "libpn547_fw" FW_DLL_EXTENSION
     67 /* Restore Corrupted PLL Settings/etc */
     68 #define PLATFORM_LIB_PATH \
     69   FW_DLL_ROOT_DIR "libpn547_fw_platform" FW_DLL_EXTENSION
     70 /* Upgrade the public Key */
     71 #define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn547_fw_pku" FW_DLL_EXTENSION
     72 #endif
     73 
     74 #if (NFC_NXP_CHIP_TYPE == PN548C2)
     75 #define COMPILATION_MW "PN548C2"
     76 #elif (NFC_NXP_CHIP_TYPE == PN551)
     77 #define COMPILATION_MW "PN551"
     78 #elif (NFC_NXP_CHIP_TYPE == PN553)
     79 #define COMPILATION_MW "PN553"
     80 #else
     81 #define COMPILATION_MW "PN547C2"
     82 #endif
     83 
     84 /* HAL Version number (Updated as per release) */
     85 #define NXP_MW_VERSION_MAJ (3U)
     86 #define NXP_MW_VERSION_MIN (5U)
     87 
     88 /*
     89  *****************************************************************
     90  ***********  System clock source selection configuration ********
     91  *****************************************************************
     92  */
     93 
     94 #define CLK_SRC_UNDEF 0
     95 #define CLK_SRC_XTAL 1
     96 #define CLK_SRC_PLL 2
     97 #define CLK_SRC_PADDIRECT 3
     98 
     99 /*Extern crystal clock source*/
    100 /* Use one of CLK_SRC_<value> */
    101 #define NXP_SYS_CLK_SRC_SEL CLK_SRC_PLL
    102 /*Direct clock*/
    103 
    104 /*
    105  *****************************************************************
    106  ***********  System clock frequency selection configuration ****************
    107  * If Clk_Src is set to PLL, make sure to set the Clk_Freq also*
    108  *****************************************************************
    109  */
    110 #define CLK_FREQ_UNDEF 0
    111 #define CLK_FREQ_13MHZ 1
    112 #define CLK_FREQ_19_2MHZ 2
    113 #define CLK_FREQ_24MHZ 3
    114 #define CLK_FREQ_26MHZ 4
    115 #define CLK_FREQ_38_4MHZ 5
    116 #define CLK_FREQ_52MHZ 6
    117 
    118 /* Set to one of CLK_FREQ_<value> */
    119 #define NXP_SYS_CLK_FREQ_SEL CLK_FREQ_19_2MHZ
    120 
    121 #define CLK_TO_CFG_DEF 1
    122 #define CLK_TO_CFG_MAX 6
    123 /*
    124  *  information to configure OSAL
    125  */
    126 typedef struct phOsalNfc_Config {
    127   uint8_t* pLogFile;            /* Log File Name*/
    128   uintptr_t dwCallbackThreadId; /* Client ID to which message is posted */
    129 } phOsalNfc_Config_t, *pphOsalNfc_Config_t /* Pointer to #phOsalNfc_Config_t */;
    130 
    131 /*
    132  * Deferred call declaration.
    133  * This type of API is called from ClientApplication (main thread) to notify
    134  * specific callback.
    135  */
    136 typedef void (*pphOsalNfc_DeferFuncPointer_t)(void*);
    137 
    138 /*
    139  * Deferred message specific info declaration.
    140  */
    141 typedef struct phOsalNfc_DeferedCallInfo {
    142   pphOsalNfc_DeferFuncPointer_t pDeferedCall; /* pointer to Deferred callback */
    143   void* pParam; /* contains timer message specific details*/
    144 } phOsalNfc_DeferedCallInfo_t;
    145 
    146 /*
    147  * States in which a OSAL timer exist.
    148  */
    149 typedef enum {
    150   eTimerIdle = 0,          /* Indicates Initial state of timer */
    151   eTimerRunning = 1,       /* Indicate timer state when started */
    152   eTimerStopped = 2        /* Indicates timer state when stopped */
    153 } phOsalNfc_TimerStates_t; /* Variable representing State of timer */
    154 
    155 /*
    156  **Timer Handle structure containing details of a timer.
    157  */
    158 typedef struct phOsalNfc_TimerHandle {
    159   uint32_t TimerId;     /* ID of the timer */
    160   timer_t hTimerHandle; /* Handle of the timer */
    161   /* Timer callback function to be invoked */
    162   pphOsalNfc_TimerCallbck_t Application_callback;
    163   void* pContext; /* Parameter to be passed to the callback function */
    164   phOsalNfc_TimerStates_t eState; /* Timer states */
    165   /* Osal Timer message posted on User Thread */
    166   phLibNfc_Message_t tOsalMessage;
    167   /* Deferred Call structure to Invoke Callback function */
    168   phOsalNfc_DeferedCallInfo_t tDeferedCallInfo;
    169   /* Variables for Structure Instance and Structure Ptr */
    170 } phOsalNfc_TimerHandle_t, *pphOsalNfc_TimerHandle_t;
    171 
    172 #endif /*  PHOSALNFC_H  */
    173