source: EcnlProtoTool/trunk/asp3_dcre/mbed/hal/ticker_api.h@ 270

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

mruby版ECNLプロトタイピング・ツールを追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr
File size: 3.3 KB
Line 
1/* mbed Microcontroller Library
2 * Copyright (c) 2015 ARM Limited
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#ifndef MBED_TICKER_API_H
17#define MBED_TICKER_API_H
18
19#include "device.h"
20
21typedef uint32_t timestamp_t;
22
23/** Ticker's event structure
24 */
25typedef struct ticker_event_s {
26 timestamp_t timestamp; /**< Event's timestamp */
27 uint32_t id; /**< TimerEvent object */
28 struct ticker_event_s *next; /**< Next event in the queue */
29} ticker_event_t;
30
31typedef void (*ticker_event_handler)(uint32_t id);
32
33/** Ticker's interface structure - required API for a ticker
34 */
35typedef struct {
36 void (*init)(void); /**< Init function */
37 uint32_t (*read)(void); /**< Read function */
38 void (*disable_interrupt)(void); /**< Disable interrupt function */
39 void (*clear_interrupt)(void); /**< Clear interrupt function */
40 void (*set_interrupt)(timestamp_t timestamp); /**< Set interrupt function */
41} ticker_interface_t;
42
43/** Tickers events queue structure
44 */
45typedef struct {
46 ticker_event_handler event_handler; /**< Event handler */
47 ticker_event_t *head; /**< A pointer to head */
48} ticker_event_queue_t;
49
50/** Tickers data structure
51 */
52typedef struct {
53 const ticker_interface_t *interface; /**< Ticker's interface */
54 ticker_event_queue_t *queue; /**< Ticker's events queue */
55} ticker_data_t;
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
61/** Initialize a ticker and sets the event handler
62 *
63 * @param data The ticker's data
64 * @param handler A handler to be set
65 */
66void ticker_set_handler(const ticker_data_t *const data, ticker_event_handler handler);
67
68/** Irq handler which goes through the events to trigger events in the past.
69 *
70 * @param data The ticker's data
71 */
72void ticker_irq_handler(const ticker_data_t *const data);
73
74/** Remove an event from the queue
75 *
76 * @param data The ticker's data
77 * @param obj The event's queue to be removed
78 */
79void ticker_remove_event(const ticker_data_t *const data, ticker_event_t *obj);
80
81/** Insert an event from the queue
82 *
83 * @param data The ticker's data
84 * @param obj The event's queue to be removed
85 * @param timestamp The event's timestamp
86 * @param id The event object
87 */
88void ticker_insert_event(const ticker_data_t *const data, ticker_event_t *obj, timestamp_t timestamp, uint32_t id);
89
90/** Read the current ticker's timestamp
91 *
92 * @param data The ticker's data
93 * @return The current timestamp
94 */
95timestamp_t ticker_read(const ticker_data_t *const data);
96
97/** Read the next event's timestamp
98 *
99 * @param data The ticker's data
100 * @return 1 if timestamp is pending event, 0 if there's no event pending
101 */
102int ticker_get_next_timestamp(const ticker_data_t *const data, timestamp_t *timestamp);
103
104#ifdef __cplusplus
105}
106#endif
107
108#endif
Note: See TracBrowser for help on using the repository browser.