1 /* 2 * Copyright (C) 2010-2018 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/" 37 #define FW_DLL_EXTENSION ".so" 38 #define FW_LIB_ROOT_DIR "/vendor/lib64/" 39 #define FW_BIN_ROOT_DIR "/vendor/firmware/" 40 #define FW_LIB_EXTENSION ".so" 41 #define FW_BIN_EXTENSION ".bin" 42 43 /* Actual FW library name*/ 44 /* Restore Corrupted PLL Settings/etc */ 45 #define PLATFORM_LIB_PATH \ 46 FW_DLL_ROOT_DIR "libsn100u_fw_platform" FW_DLL_EXTENSION 47 /* Upgrade the public Key */ 48 #define PKU_LIB_PATH FW_DLL_ROOT_DIR "libsn100u_fw_pku" FW_DLL_EXTENSION 49 50 /* HAL Version number (Updated as per release) */ 51 #define NXP_MW_VERSION_MAJ (0x03) 52 #define NXP_MW_VERSION_MIN (0x02) 53 54 #define GET_EEPROM_DATA (1U) 55 #define SET_EEPROM_DATA (2U) 56 57 #define BITWISE (1U) 58 #define BYTEWISE (2U) 59 60 #define GET_FW_DWNLD_FLAG (1U) 61 #define RESET_FW_DWNLD_FLAG (2U) 62 63 #define FLASH_UPPER_VERSION (1) 64 #define FLASH_DIFFERENT_VERSION (2) 65 #define FLASH_ALWAYS (3) 66 /* 67 ***************************************************************** 68 *********** System clock source selection configuration ******** 69 ***************************************************************** 70 */ 71 72 #define CLK_SRC_UNDEF 0 73 #define CLK_SRC_XTAL 1 74 #define CLK_SRC_PLL 2 75 #define CLK_SRC_PADDIRECT 3 76 #define CLK_CFG_XTAL 8 77 78 /*Extern crystal clock source*/ 79 /* Use one of CLK_SRC_<value> */ 80 #define NXP_SYS_CLK_SRC_SEL CLK_SRC_PLL 81 /*Direct clock*/ 82 83 /* 84 ***************************************************************** 85 *********** System clock frequency selection configuration **************** 86 * If Clk_Src is set to PLL, make sure to set the Clk_Freq also* 87 ***************************************************************** 88 */ 89 #define CLK_FREQ_UNDEF 0 90 #define CLK_FREQ_13MHZ 1 91 #define CLK_FREQ_19_2MHZ 2 92 #define CLK_FREQ_24MHZ 3 93 #define CLK_FREQ_26MHZ 4 94 #define CLK_FREQ_32MHZ 5 95 #define CLK_FREQ_38_4MHZ 6 96 #define CLK_FREQ_52MHZ 7 97 98 /* Set to one of CLK_FREQ_<value> */ 99 #define NXP_SYS_CLK_FREQ_SEL CLK_FREQ_19_2MHZ 100 101 #define CLK_TO_CFG_DEF 1 102 #define CLK_TO_CFG_MAX 6 103 104 #define CLK_REQ_DELAY_MIN 1 105 #define CLK_REQ_DELAY_MAX 31 106 #define CLK_REQ_DELAY_DEF 22 107 #define CLK_REQ_DELAY_MASK 0x1F 108 #define CLK_REQ_DELAY_PLL_OFFSET 13 109 #define CLK_REQ_DELAY_XTAL_OFFSET 14 110 /* 111 * information to configure OSAL 112 */ 113 typedef struct phOsalNfc_Config { 114 uint8_t* pLogFile; /* Log File Name*/ 115 uintptr_t dwCallbackThreadId; /* Client ID to which message is posted */ 116 } phOsalNfc_Config_t, *pphOsalNfc_Config_t /* Pointer to #phOsalNfc_Config_t */; 117 118 /* 119 * Deferred call declaration. 120 * This type of API is called from ClientApplication (main thread) to notify 121 * specific callback. 122 */ 123 typedef void (*pphOsalNfc_DeferFuncPointer_t)(void*); 124 125 /* 126 * Deferred message specific info declaration. 127 */ 128 typedef struct phOsalNfc_DeferedCallInfo { 129 pphOsalNfc_DeferFuncPointer_t pDeferedCall; /* pointer to Deferred callback */ 130 void* pParam; /* contains timer message specific details*/ 131 } phOsalNfc_DeferedCallInfo_t; 132 133 /* 134 * States in which a OSAL timer exist. 135 */ 136 typedef enum { 137 eTimerIdle = 0, /* Indicates Initial state of timer */ 138 eTimerRunning = 1, /* Indicate timer state when started */ 139 eTimerStopped = 2 /* Indicates timer state when stopped */ 140 } phOsalNfc_TimerStates_t; /* Variable representing State of timer */ 141 142 /* 143 **Timer Handle structure containing details of a timer. 144 */ 145 typedef struct phOsalNfc_TimerHandle { 146 uint32_t TimerId; /* ID of the timer */ 147 timer_t hTimerHandle; /* Handle of the timer */ 148 /* Timer callback function to be invoked */ 149 pphOsalNfc_TimerCallbck_t Application_callback; 150 void* pContext; /* Parameter to be passed to the callback function */ 151 phOsalNfc_TimerStates_t eState; /* Timer states */ 152 /* Osal Timer message posted on User Thread */ 153 phLibNfc_Message_t tOsalMessage; 154 /* Deferred Call structure to Invoke Callback function */ 155 phOsalNfc_DeferedCallInfo_t tDeferedCallInfo; 156 /* Variables for Structure Instance and Structure Ptr */ 157 } phOsalNfc_TimerHandle_t, *pphOsalNfc_TimerHandle_t; 158 159 #endif /* PHOSALNFC_H */ 160