Mistake on this page?
Report an issue in GitHub or email us
nfc_scheduler.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2018, ARM Limited, All Rights Reserved
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may
6  * not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 /**
18  * \file nfc_scheduler.h
19  * \copyright Copyright (c) ARM Ltd 2014
20  * \author Donatien Garnier
21  */
22 /** \addtogroup Core
23  * @{
24  * \name Scheduler
25  * @{
26  */
27 
28 #ifndef NFC_SCHEDULER_H_
29 #define NFC_SCHEDULER_H_
30 
31 #include "stack/nfc_common.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #define EVENT_NONE 0
38 #define EVENT_TIMEOUT 1
39 #define EVENT_ABORTED 2
40 #define EVENT_HW_INTERRUPT 4
41 
42 struct __nfc_timer;
43 typedef struct __nfc_timer nfc_scheduler_timer_t;
44 
45 struct __nfc_task;
46 typedef struct __nfc_task nfc_task_t;
47 
48 typedef struct __scheduler {
49  nfc_task_t *pNext;
50  nfc_scheduler_timer_t *pTimer;
52 
53 typedef void (*nfc_task_fn)(uint32_t events, void *pUserData);
54 
55 struct __nfc_task {
56  uint32_t events;
57  int64_t timeout; //millisecs
58  int64_t timeoutInitial;
59 
60  nfc_task_fn fn;
61  void *pUserData;
62 
63  nfc_task_t *pNext;
64 };
65 
66 void nfc_scheduler_timer_init(nfc_scheduler_timer_t *timer);
67 
68 void nfc_scheduler_timer_start(nfc_scheduler_timer_t *timer);
69 
70 uint32_t nfc_scheduler_timer_get(nfc_scheduler_timer_t *timer);
71 
72 void nfc_scheduler_timer_stop(nfc_scheduler_timer_t *timer);
73 
74 void nfc_scheduler_timer_reset(nfc_scheduler_timer_t *timer);
75 
76 /** Init scheduler
77  * \param pScheduler scheduler instance to init
78  * \param pTimer timer instance
79  */
80 void nfc_scheduler_init(nfc_scheduler_t *pScheduler, nfc_scheduler_timer_t *pTimer);
81 
82 /** Iterate through all tasks
83  * \param pScheduler scheduler instance
84  * \param events mask of events (except EVENT_TIMEOUT) that have been raised since this function last returned (0 on first call)
85  * \return time after which this function must be called again if no other event arises
86  */
87 uint32_t nfc_scheduler_iteration(nfc_scheduler_t *pScheduler, uint32_t events);
88 
89 /** Queue a task to execute
90  * \param pScheduler scheduler instance
91  * \param pTask task to queue
92  *
93  */
94 void nfc_scheduler_queue_task(nfc_scheduler_t *pScheduler, nfc_task_t *pTask);
95 
96 /** Remove a task to execute
97  * \param pScheduler scheduler instance
98  * \param pTask task to remove
99  * \param abort abort task if queued
100  */
101 void nfc_scheduler_dequeue_task(nfc_scheduler_t *pScheduler, bool abort, nfc_task_t *pTask);
102 
103 /** Initialize task with the following parameters
104  * \param pTask task to initialize
105  * \param events events on which to call task
106  * \param timeout if relevant
107  * \param fn function to be called
108  * \param pUserData data that will be passed to function
109  */
110 void task_init(nfc_task_t *pTask, uint32_t events, uint32_t timeout, nfc_task_fn fn, void *pUserData);
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif /* NFC_SCHEDULER_H_ */
117 
118 /**
119  * @}
120  * @}
121  * */
122 
void nfc_scheduler_init(nfc_scheduler_t *pScheduler, nfc_scheduler_timer_t *pTimer)
Init scheduler.
void task_init(nfc_task_t *pTask, uint32_t events, uint32_t timeout, nfc_task_fn fn, void *pUserData)
Initialize task with the following parameters.
void nfc_scheduler_queue_task(nfc_scheduler_t *pScheduler, nfc_task_t *pTask)
Queue a task to execute.
void nfc_scheduler_dequeue_task(nfc_scheduler_t *pScheduler, bool abort, nfc_task_t *pTask)
Remove a task to execute.
uint32_t nfc_scheduler_iteration(nfc_scheduler_t *pScheduler, uint32_t events)
Iterate through all tasks.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.