1 /* 2 * Copyright 2010-2021 NXP 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 #ifndef FW_LIB_ROOT_DIR 37 #if (defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)) 38 #define FW_LIB_ROOT_DIR "/vendor/lib64/" 39 #else 40 #define FW_LIB_ROOT_DIR "/vendor/lib/" 41 #endif 42 #endif 43 #define FW_BIN_ROOT_DIR "/vendor/firmware/" 44 #define FW_LIB_EXTENSION ".so" 45 #define FW_BIN_EXTENSION ".bin" 46 47 /* HAL Version number (Updated as per release) */ 48 #define NXP_MW_VERSION_MAJ (3U) 49 #define NXP_MW_VERSION_MIN (5U) 50 51 /* 52 ***************************************************************** 53 *********** System clock source selection configuration ******** 54 ***************************************************************** 55 */ 56 57 #define CLK_SRC_UNDEF 0 58 #define CLK_SRC_XTAL 1 59 #define CLK_SRC_PLL 2 60 #define CLK_SRC_PADDIRECT 3 61 62 /*Extern crystal clock source*/ 63 /* Use one of CLK_SRC_<value> */ 64 #define NXP_SYS_CLK_SRC_SEL CLK_SRC_PLL 65 /*Direct clock*/ 66 67 /* 68 ***************************************************************** 69 *********** System clock frequency selection configuration **************** 70 * If Clk_Src is set to PLL, make sure to set the Clk_Freq also* 71 ***************************************************************** 72 */ 73 #define CLK_FREQ_UNDEF 0 74 #define CLK_FREQ_13MHZ 1 75 #define CLK_FREQ_19_2MHZ 2 76 #define CLK_FREQ_24MHZ 3 77 #define CLK_FREQ_26MHZ 4 78 #define CLK_FREQ_38_4MHZ 5 79 #define CLK_FREQ_52MHZ 6 80 81 /* Set to one of CLK_FREQ_<value> */ 82 #define NXP_SYS_CLK_FREQ_SEL CLK_FREQ_19_2MHZ 83 84 #define CLK_TO_CFG_DEF 1 85 #define CLK_TO_CFG_MAX 6 86 /* 87 * information to configure OSAL 88 */ 89 typedef struct phOsalNfc_Config { 90 uint8_t* pLogFile; /* Log File Name*/ 91 uintptr_t dwCallbackThreadId; /* Client ID to which message is posted */ 92 } phOsalNfc_Config_t, *pphOsalNfc_Config_t /* Pointer to #phOsalNfc_Config_t */; 93 94 /* 95 * Deferred call declaration. 96 * This type of API is called from ClientApplication (main thread) to notify 97 * specific callback. 98 */ 99 typedef void (*pphOsalNfc_DeferFuncPointer_t)(void*); 100 101 /* 102 * Deferred message specific info declaration. 103 */ 104 typedef struct phOsalNfc_DeferedCallInfo { 105 pphOsalNfc_DeferFuncPointer_t pDeferedCall; /* pointer to Deferred callback */ 106 void* pParam; /* contains timer message specific details*/ 107 } phOsalNfc_DeferedCallInfo_t; 108 109 /* 110 * States in which a OSAL timer exist. 111 */ 112 typedef enum { 113 eTimerIdle = 0, /* Indicates Initial state of timer */ 114 eTimerRunning = 1, /* Indicate timer state when started */ 115 eTimerStopped = 2 /* Indicates timer state when stopped */ 116 } phOsalNfc_TimerStates_t; /* Variable representing State of timer */ 117 118 /* 119 **Timer Handle structure containing details of a timer. 120 */ 121 typedef struct phOsalNfc_TimerHandle { 122 uint32_t TimerId; /* ID of the timer */ 123 timer_t hTimerHandle; /* Handle of the timer */ 124 /* Timer callback function to be invoked */ 125 pphOsalNfc_TimerCallbck_t Application_callback; 126 void* pContext; /* Parameter to be passed to the callback function */ 127 phOsalNfc_TimerStates_t eState; /* Timer states */ 128 /* Osal Timer message posted on User Thread */ 129 phLibNfc_Message_t tOsalMessage; 130 /* Deferred Call structure to Invoke Callback function */ 131 phOsalNfc_DeferedCallInfo_t tDeferedCallInfo; 132 /* Variables for Structure Instance and Structure Ptr */ 133 } phOsalNfc_TimerHandle_t, *pphOsalNfc_TimerHandle_t; 134 135 #endif /* PHOSALNFC_H */ 136