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