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