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