mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
cmsis/BUILD/mbed/drivers/TimerEvent.h@189:f392fc9709a3, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 22:31:08 2019 +0000
- Revision:
- 189:f392fc9709a3
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 189:f392fc9709a3 | 1 | /* mbed Microcontroller Library |
AnnaBridge | 189:f392fc9709a3 | 2 | * Copyright (c) 2006-2013 ARM Limited |
AnnaBridge | 189:f392fc9709a3 | 3 | * SPDX-License-Identifier: Apache-2.0 |
AnnaBridge | 189:f392fc9709a3 | 4 | * |
AnnaBridge | 189:f392fc9709a3 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
AnnaBridge | 189:f392fc9709a3 | 6 | * you may not use this file except in compliance with the License. |
AnnaBridge | 189:f392fc9709a3 | 7 | * You may obtain a copy of the License at |
AnnaBridge | 189:f392fc9709a3 | 8 | * |
AnnaBridge | 189:f392fc9709a3 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
AnnaBridge | 189:f392fc9709a3 | 10 | * |
AnnaBridge | 189:f392fc9709a3 | 11 | * Unless required by applicable law or agreed to in writing, software |
AnnaBridge | 189:f392fc9709a3 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
AnnaBridge | 189:f392fc9709a3 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
AnnaBridge | 189:f392fc9709a3 | 14 | * See the License for the specific language governing permissions and |
AnnaBridge | 189:f392fc9709a3 | 15 | * limitations under the License. |
AnnaBridge | 189:f392fc9709a3 | 16 | */ |
AnnaBridge | 189:f392fc9709a3 | 17 | #ifndef MBED_TIMEREVENT_H |
AnnaBridge | 189:f392fc9709a3 | 18 | #define MBED_TIMEREVENT_H |
AnnaBridge | 189:f392fc9709a3 | 19 | |
AnnaBridge | 189:f392fc9709a3 | 20 | #include "hal/ticker_api.h" |
AnnaBridge | 189:f392fc9709a3 | 21 | #include "hal/us_ticker_api.h" |
AnnaBridge | 189:f392fc9709a3 | 22 | #include "platform/NonCopyable.h" |
AnnaBridge | 189:f392fc9709a3 | 23 | |
AnnaBridge | 189:f392fc9709a3 | 24 | namespace mbed { |
AnnaBridge | 189:f392fc9709a3 | 25 | /** \addtogroup drivers */ |
AnnaBridge | 189:f392fc9709a3 | 26 | |
AnnaBridge | 189:f392fc9709a3 | 27 | /** Base abstraction for timer interrupts |
AnnaBridge | 189:f392fc9709a3 | 28 | * |
AnnaBridge | 189:f392fc9709a3 | 29 | * @note Synchronization level: Interrupt safe |
AnnaBridge | 189:f392fc9709a3 | 30 | * @ingroup drivers |
AnnaBridge | 189:f392fc9709a3 | 31 | */ |
AnnaBridge | 189:f392fc9709a3 | 32 | class TimerEvent : private NonCopyable<TimerEvent> { |
AnnaBridge | 189:f392fc9709a3 | 33 | public: |
AnnaBridge | 189:f392fc9709a3 | 34 | TimerEvent(); |
AnnaBridge | 189:f392fc9709a3 | 35 | TimerEvent(const ticker_data_t *data); |
AnnaBridge | 189:f392fc9709a3 | 36 | |
AnnaBridge | 189:f392fc9709a3 | 37 | /** The handler registered with the underlying timer interrupt |
AnnaBridge | 189:f392fc9709a3 | 38 | * |
AnnaBridge | 189:f392fc9709a3 | 39 | * @param id Timer Event ID |
AnnaBridge | 189:f392fc9709a3 | 40 | */ |
AnnaBridge | 189:f392fc9709a3 | 41 | static void irq(uint32_t id); |
AnnaBridge | 189:f392fc9709a3 | 42 | |
AnnaBridge | 189:f392fc9709a3 | 43 | /** Destruction removes it... |
AnnaBridge | 189:f392fc9709a3 | 44 | */ |
AnnaBridge | 189:f392fc9709a3 | 45 | virtual ~TimerEvent(); |
AnnaBridge | 189:f392fc9709a3 | 46 | |
AnnaBridge | 189:f392fc9709a3 | 47 | #if !defined(DOXYGEN_ONLY) |
AnnaBridge | 189:f392fc9709a3 | 48 | protected: |
AnnaBridge | 189:f392fc9709a3 | 49 | // The handler called to service the timer event of the derived class |
AnnaBridge | 189:f392fc9709a3 | 50 | virtual void handler() = 0; |
AnnaBridge | 189:f392fc9709a3 | 51 | |
AnnaBridge | 189:f392fc9709a3 | 52 | /** Set relative timestamp of the internal event. |
AnnaBridge | 189:f392fc9709a3 | 53 | * @param timestamp event's us timestamp |
AnnaBridge | 189:f392fc9709a3 | 54 | * |
AnnaBridge | 189:f392fc9709a3 | 55 | * @warning |
AnnaBridge | 189:f392fc9709a3 | 56 | * Do not insert more than one timestamp. |
AnnaBridge | 189:f392fc9709a3 | 57 | * The same @a event object is used for every @a insert/insert_absolute call. |
AnnaBridge | 189:f392fc9709a3 | 58 | * |
AnnaBridge | 189:f392fc9709a3 | 59 | * @warning |
AnnaBridge | 189:f392fc9709a3 | 60 | * Ticker's present timestamp is used for reference. For timestamps |
AnnaBridge | 189:f392fc9709a3 | 61 | * from the past the event is scheduled after ticker's overflow. |
AnnaBridge | 189:f392fc9709a3 | 62 | * For reference @see convert_timestamp |
AnnaBridge | 189:f392fc9709a3 | 63 | */ |
AnnaBridge | 189:f392fc9709a3 | 64 | void insert(timestamp_t timestamp); |
AnnaBridge | 189:f392fc9709a3 | 65 | |
AnnaBridge | 189:f392fc9709a3 | 66 | /** Set absolute timestamp of the internal event. |
AnnaBridge | 189:f392fc9709a3 | 67 | * @param timestamp event's us timestamp |
AnnaBridge | 189:f392fc9709a3 | 68 | * |
AnnaBridge | 189:f392fc9709a3 | 69 | * @warning |
AnnaBridge | 189:f392fc9709a3 | 70 | * Do not insert more than one timestamp. |
AnnaBridge | 189:f392fc9709a3 | 71 | * The same @a event object is used for every @a insert/insert_absolute call. |
AnnaBridge | 189:f392fc9709a3 | 72 | */ |
AnnaBridge | 189:f392fc9709a3 | 73 | void insert_absolute(us_timestamp_t timestamp); |
AnnaBridge | 189:f392fc9709a3 | 74 | |
AnnaBridge | 189:f392fc9709a3 | 75 | /** Remove timestamp. |
AnnaBridge | 189:f392fc9709a3 | 76 | */ |
AnnaBridge | 189:f392fc9709a3 | 77 | void remove(); |
AnnaBridge | 189:f392fc9709a3 | 78 | |
AnnaBridge | 189:f392fc9709a3 | 79 | ticker_event_t event; |
AnnaBridge | 189:f392fc9709a3 | 80 | |
AnnaBridge | 189:f392fc9709a3 | 81 | const ticker_data_t *_ticker_data; |
AnnaBridge | 189:f392fc9709a3 | 82 | #endif |
AnnaBridge | 189:f392fc9709a3 | 83 | }; |
AnnaBridge | 189:f392fc9709a3 | 84 | |
AnnaBridge | 189:f392fc9709a3 | 85 | } // namespace mbed |
AnnaBridge | 189:f392fc9709a3 | 86 | |
AnnaBridge | 189:f392fc9709a3 | 87 | #endif |