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 #else 77 #define COMPILATION_MW "PN547C2" 78 #endif 79 80 /* HAL Version number (Updated as per release) */ 81 #define NXP_MW_VERSION_MAJ (3U) 82 #define NXP_MW_VERSION_MIN (5U) 83 84 /* 85 ***************************************************************** 86 *********** System clock source selection configuration ******** 87 ***************************************************************** 88 */ 89 90 #define CLK_SRC_UNDEF 0 91 #define CLK_SRC_XTAL 1 92 #define CLK_SRC_PLL 2 93 #define CLK_SRC_PADDIRECT 3 94 95 /*Extern crystal clock source*/ 96 /* Use one of CLK_SRC_<value> */ 97 #define NXP_SYS_CLK_SRC_SEL CLK_SRC_PLL 98 /*Direct clock*/ 99 100 /* 101 ***************************************************************** 102 *********** System clock frequency selection configuration **************** 103 * If Clk_Src is set to PLL, make sure to set the Clk_Freq also* 104 ***************************************************************** 105 */ 106 #define CLK_FREQ_UNDEF 0 107 #define CLK_FREQ_13MHZ 1 108 #define CLK_FREQ_19_2MHZ 2 109 #define CLK_FREQ_24MHZ 3 110 #define CLK_FREQ_26MHZ 4 111 #define CLK_FREQ_38_4MHZ 5 112 #define CLK_FREQ_52MHZ 6 113 114 /* Set to one of CLK_FREQ_<value> */ 115 #define NXP_SYS_CLK_FREQ_SEL CLK_FREQ_19_2MHZ 116 117 #define CLK_TO_CFG_DEF 1 118 #define CLK_TO_CFG_MAX 6 119 /* 120 * information to configure OSAL 121 */ 122 typedef struct phOsalNfc_Config { 123 uint8_t* pLogFile; /* Log File Name*/ 124 uintptr_t dwCallbackThreadId; /* Client ID to which message is posted */ 125 } phOsalNfc_Config_t, *pphOsalNfc_Config_t /* Pointer to #phOsalNfc_Config_t */; 126 127 /* 128 * Deferred call declaration. 129 * This type of API is called from ClientApplication (main thread) to notify 130 * specific callback. 131 */ 132 typedef void (*pphOsalNfc_DeferFuncPointer_t)(void*); 133 134 /* 135 * Deferred message specific info declaration. 136 */ 137 typedef struct phOsalNfc_DeferedCallInfo { 138 pphOsalNfc_DeferFuncPointer_t pDeferedCall; /* pointer to Deferred callback */ 139 void* pParam; /* contains timer message specific details*/ 140 } phOsalNfc_DeferedCallInfo_t; 141 142 /* 143 * States in which a OSAL timer exist. 144 */ 145 typedef enum { 146 eTimerIdle = 0, /* Indicates Initial state of timer */ 147 eTimerRunning = 1, /* Indicate timer state when started */ 148 eTimerStopped = 2 /* Indicates timer state when stopped */ 149 } phOsalNfc_TimerStates_t; /* Variable representing State of timer */ 150 151 /* 152 **Timer Handle structure containing details of a timer. 153 */ 154 typedef struct phOsalNfc_TimerHandle { 155 uint32_t TimerId; /* ID of the timer */ 156 timer_t hTimerHandle; /* Handle of the timer */ 157 /* Timer callback function to be invoked */ 158 pphOsalNfc_TimerCallbck_t Application_callback; 159 void* pContext; /* Parameter to be passed to the callback function */ 160 phOsalNfc_TimerStates_t eState; /* Timer states */ 161 /* Osal Timer message posted on User Thread */ 162 phLibNfc_Message_t tOsalMessage; 163 /* Deferred Call structure to Invoke Callback function */ 164 phOsalNfc_DeferedCallInfo_t tDeferedCallInfo; 165 /* Variables for Structure Instance and Structure Ptr */ 166 } phOsalNfc_TimerHandle_t, *pphOsalNfc_TimerHandle_t; 167 168 #endif /* PHOSALNFC_H */ 169