2 * Copyright (C) 2010 NXP Semiconductors
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * \file phOsalNfc_Timer.h
19 * \brief Timer Implementation.
21 * Project: NFC-FRI 1.1
23 * $Date: Mon Mar 16 20:30:44 2009 $
26 * $Aliases: NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $
29 #ifndef PHOSALNFC_TIMER_H
30 #define PHOSALNFC_TIMER_H
32 /* -----------------Include files ---------------------------------------*/
33 #include <phNfcTypes.h>
34 #ifdef PH_NFC_CUSTOMINTEGRATION
35 #include <phNfcCustomInt.h>
38 #include <nfc_osal_deferred_call.h>
43 * \ingroup grp_osal_nfc
44 *\brief Deferred message specific info declaration.
45 * This type information packed as WPARAM when \ref PH_OSALNFC_MESSAGE_BASE type windows message
46 * is posted to message handler thread.
48 //typedef struct phOsalNfc_DeferedCalldInfo
50 // nfc_osal_def_call_t pDeferedCall;/**< pointer to Deferred callback */
51 // void *pParam;/**< contains timer message specific details*/
52 //}phOsalNfc_DeferedCalldInfo_t;
53 typedef phLibNfc_DeferredCall_t phOsalNfc_DeferedCalldInfo_t;
56 /* ---------------- Macros ----------------------------------------------*/
58 *\ingroup grp_osal_nfc
59 * OSAL timer message .This message type will be posted to calling application thread.
61 //#define PH_OSALNFC_TIMER_MSG (0x315)
62 #define PH_OSALNFC_TIMER_MSG PH_LIBNFC_DEFERREDCALL_MSG
65 * \ingroup grp_osal_nfc
66 * Invalid timer ID type.This ID used indicate timer creation is failed.
68 #define PH_OSALNFC_INVALID_TIMER_ID (0xFFFF)
71 * \ingroup grp_osal_nfc
72 * \brief Timer callback interface which will be called once registered timer
74 * \param[in] TimerId Timer Id for which callback is called.
77 typedef void (*ppCallBck_t)(uint32_t TimerId, void *pContext);
79 /* -----------------Structures and Enumerations -------------------------*/
81 * \ingroup grp_osal_nfc
82 **\brief Timer message structure definition.
83 * Timer Message Structure contains timer specific informations like timer identifier
87 typedef struct phOsalNfc_TimerMsg
89 uint32_t TimerId;/**< Timer ID*/
90 ppCallBck_t pCallBck;/**< pointer to Timer Callback*/
91 void* pContext; /**< Timer Callback context*/
92 }phOsalNfc_Timer_Msg_t,*pphOsalNfc_TimerMsg_t;
94 /* -----------------Exported Functions----------------------------------*/
96 * \ingroup grp_osal_nfc
97 * \brief Allows to create new timer.
99 * This API creates a cyclic timer. In case a valid timer is created returned
100 * timer ID will be other than \ref PH_OSALNFC_INVALID_TIMER_ID. In case returned
101 * timer id is \ref PH_OSALNFC_INVALID_TIMER_ID, this indicates timer creation
104 * When a timer is created, it is not started by default. The application has to
105 * explicitly start it using \ref phOsalNfc_Timer_Start().
108 * \retval Created timer ID.
109 * \note If timer ID value is PH_OSALNFC_INVALID_TIMER_ID, it indicates
110 * an error occured during timer creation.
113 * Application,phOsalNfc;
114 * Application=>phOsalNfc [label="phOsalNfc_Timer_Create()",URL="\ref phOsalNfc_Timer_Create"];
115 * Application<<phOsalNfc [label="Returns Valid timer ID"];
118 uint32_t phOsalNfc_Timer_Create (void);
121 * \ingroup grp_osal_nfc
122 * \brief Allows to start an already created timer.
124 * This function starts the requested timer. If the timer is already running,
125 * timer stops and restarts with the new timeout value and new callback function
128 * \note The old timeout and callback reference are not valid any more if timer
129 * is restarted. Notifications are periodic and stop only when timer is stopped.
131 * \param[in] TimerId valid timer ID obtained during timer creation.
132 * \param[in] RegTimeCnt Requested time out in Milliseconds.
133 * \note In windows environment timer resolution should be more than
134 * 50 mSec. In case time out value is below 50 mSec accuracy of timer
135 * behaviouer is not gauranteed.
136 * \param[in] Application_callback Application Callback interface to be called
137 * when timer expires.
140 * Application,phOsalNfc;
141 * Application=>phOsalNfc [label="phOsalNfc_Timer_Create()", URL="\ref phOsalNfc_Timer_Create"];
142 * Application<<phOsalNfc [label="TIMERID"];
143 * Application=>phOsalNfc [label="phOsalNfc_Timer_Start(TIMERID, TIMEOUT, CB)", URL="\ref phOsalNfc_Timer_Start"];
144 * --- [label=" : On timer time out expired "];
145 * phOsalNfc=>phOsalNfc [label="CB()"];
146 * Application<-phOsalNfc[label="PH_OSALNFC_TIMER_MSG"];
149 void phOsalNfc_Timer_Start(uint32_t TimerId,
151 ppCallBck_t Application_callback,
155 * \ingroup grp_osal_nfc
156 * \brief Stop an already started timer.
158 * This API allows to stop running timers. In case the timer is stopped, its callback will not be
161 * \param[in] TimerId valid timer ID obtained suring timer creation.
162 * \param[in] Application_callback Application Callback interface to be called when timer expires.
165 * Application,phOsalNfc;
166 * Application=>phOsalNfc [label="phOsalNfc_Timer_Create()",URL="\ref phOsalNfc_Timer_Create"];
167 * Application<<phOsalNfc [label="TIMERID"];
168 * Application=>phOsalNfc [label="phOsalNfc_Timer_Start(TIMERID, TIMEOUT, CB)",URL="\ref phOsalNfc_Timer_Start"];
169 * --- [label=" : On timer time out expired "];
170 * phOsalNfc=>phOsalNfc [label="CB()"];
171 * Application=>phOsalNfc [label="phOsalNfc_Timer_Stop(TIMERID)",URL="\ref phOsalNfc_Timer_Stop"];
174 void phOsalNfc_Timer_Stop(uint32_t TimerId);
177 * \ingroup grp_osal_nfc
178 * \brief Allows to delete the timer which is already created.
180 * This API allows to delete a timer. Incase timer is running
181 * it is stopped first and then deleted. if the given timer ID is invalid, this
182 * function doesn't return any error. Application has to explicitly ensure
183 * timer ID sent is valid.
185 * \param[in] TimerId timer identieir to delete the timer.
187 void phOsalNfc_Timer_Delete(uint32_t TimerId);
190 #endif /* PHOSALNFC_TIMER_H */