source: asp3_tinet_ecnl_rx/trunk/asp3_dcre/mbed/hal/ticker_api.h@ 374

Last change on this file since 374 was 374, checked in by coas-nagasima, 5 years ago

mbed関連を更新
シリアルドライバをmbedのHALを使うよう変更
ファイルディスクリプタの処理を更新

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 3.5 KB
Line 
1
2/** \addtogroup hal */
3/** @{*/
4/* mbed Microcontroller Library
5 * Copyright (c) 2015 ARM Limited
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19#ifndef MBED_TICKER_API_H
20#define MBED_TICKER_API_H
21
22#include <stdint.h>
23#include "device.h"
24
25typedef uint32_t timestamp_t;
26
27/** Ticker's event structure
28 */
29typedef struct ticker_event_s {
30 timestamp_t timestamp; /**< Event's timestamp */
31 uint32_t id; /**< TimerEvent object */
32 struct ticker_event_s *next; /**< Next event in the queue */
33} ticker_event_t;
34
35typedef void (*ticker_event_handler)(uint32_t id);
36
37/** Ticker's interface structure - required API for a ticker
38 */
39typedef struct {
40 void (*init)(void); /**< Init function */
41 uint32_t (*read)(void); /**< Read function */
42 void (*disable_interrupt)(void); /**< Disable interrupt function */
43 void (*clear_interrupt)(void); /**< Clear interrupt function */
44 void (*set_interrupt)(timestamp_t timestamp); /**< Set interrupt function */
45} ticker_interface_t;
46
47/** Ticker's event queue structure
48 */
49typedef struct {
50 ticker_event_handler event_handler; /**< Event handler */
51 ticker_event_t *head; /**< A pointer to head */
52} ticker_event_queue_t;
53
54/** Ticker's data structure
55 */
56typedef struct {
57 const ticker_interface_t *interface; /**< Ticker's interface */
58 ticker_event_queue_t *queue; /**< Ticker's event queue */
59} ticker_data_t;
60
61#ifdef __cplusplus
62extern "C" {
63#endif
64
65/**
66 * \defgroup hal_ticker Ticker HAL functions
67 * @{
68 */
69
70/** Initialize a ticker and set the event handler
71 *
72 * @param data The ticker's data
73 * @param handler A handler to be set
74 */
75void ticker_set_handler(const ticker_data_t *const data, ticker_event_handler handler);
76
77/** IRQ handler that goes through the events to trigger overdue events.
78 *
79 * @param data The ticker's data
80 */
81void ticker_irq_handler(const ticker_data_t *const data);
82
83/** Remove an event from the queue
84 *
85 * @param data The ticker's data
86 * @param obj The event object to be removed from the queue
87 */
88void ticker_remove_event(const ticker_data_t *const data, ticker_event_t *obj);
89
90/** Insert an event to the queue
91 *
92 * @param data The ticker's data
93 * @param obj The event object to be inserted to the queue
94 * @param timestamp The event's timestamp
95 * @param id The event object
96 */
97void ticker_insert_event(const ticker_data_t *const data, ticker_event_t *obj, timestamp_t timestamp, uint32_t id);
98
99/** Read the current ticker's timestamp
100 *
101 * @param data The ticker's data
102 * @return The current timestamp
103 */
104timestamp_t ticker_read(const ticker_data_t *const data);
105
106/** Read the next event's timestamp
107 *
108 * @param data The ticker's data
109 * @return 1 if timestamp is pending event, 0 if there's no event pending
110 */
111int ticker_get_next_timestamp(const ticker_data_t *const data, timestamp_t *timestamp);
112
113/**@}*/
114
115#ifdef __cplusplus
116}
117#endif
118
119#endif
120
121/** @}*/
Note: See TracBrowser for help on using the repository browser.