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