Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TimerEvent.h Source File

TimerEvent.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2019 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef MBED_TIMEREVENT_H
00018 #define MBED_TIMEREVENT_H
00019 
00020 #include "hal/ticker_api.h"
00021 #include "platform/NonCopyable.h"
00022 
00023 namespace mbed {
00024 /**
00025  * \defgroup drivers_TimerEvent TimerEvent class
00026  * \ingroup drivers-public-api-ticker
00027  * @{
00028  */
00029 
00030 /** Base abstraction for timer interrupts
00031  *
00032  * @note Synchronization level: Interrupt safe
00033  */
00034 class TimerEvent : private NonCopyable<TimerEvent> {
00035 public:
00036     TimerEvent();
00037     TimerEvent(const ticker_data_t *data);
00038 
00039     /** The handler registered with the underlying timer interrupt
00040      *
00041      *  @param id       Timer Event ID
00042      */
00043     static void irq(uint32_t id);
00044 
00045     /** Destruction removes it...
00046      */
00047     virtual ~TimerEvent();
00048 
00049 #if !defined(DOXYGEN_ONLY)
00050 protected:
00051     // The handler called to service the timer event of the derived class
00052     virtual void handler() = 0;
00053 
00054     /** Set relative timestamp of the internal event.
00055      * @param   timestamp   event's us timestamp
00056      *
00057      * @warning
00058      * Do not insert more than one timestamp.
00059      * The same @a event object is used for every @a insert/insert_absolute call.
00060      *
00061      * @warning
00062      * Ticker's present timestamp is used for reference. For timestamps
00063      * from the past the event is scheduled after ticker's overflow.
00064      * For reference @see convert_timestamp
00065      */
00066     void insert(timestamp_t timestamp);
00067 
00068     /** Set absolute timestamp of the internal event.
00069      * @param   timestamp   event's us timestamp
00070      *
00071      * @warning
00072      * Do not insert more than one timestamp.
00073      * The same @a event object is used for every @a insert/insert_absolute call.
00074      */
00075     void insert_absolute(us_timestamp_t timestamp);
00076 
00077     /** Remove timestamp.
00078      */
00079     void remove();
00080 
00081     ticker_event_t event;
00082 
00083     const ticker_data_t *_ticker_data;
00084 #endif
00085 };
00086 
00087 /** @}*/
00088 
00089 } // namespace mbed
00090 
00091 #endif