mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

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-2013 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 "hal/us_ticker_api.h"
00022 #include "platform/NonCopyable.h"
00023 
00024 namespace mbed {
00025 /** \addtogroup drivers */
00026 
00027 /** Base abstraction for timer interrupts
00028  *
00029  * @note Synchronization level: Interrupt safe
00030  * @ingroup drivers
00031  */
00032 class TimerEvent : private NonCopyable<TimerEvent> {
00033 public:
00034     TimerEvent();
00035     TimerEvent(const ticker_data_t *data);
00036 
00037     /** The handler registered with the underlying timer interrupt
00038      *
00039      *  @param id       Timer Event ID
00040      */
00041     static void irq(uint32_t id);
00042 
00043     /** Destruction removes it...
00044      */
00045     virtual ~TimerEvent();
00046 
00047 #if !defined(DOXYGEN_ONLY)
00048 protected:
00049     // The handler called to service the timer event of the derived class
00050     virtual void handler() = 0;
00051 
00052     /** Set relative timestamp of the internal event.
00053      * @param   timestamp   event's us timestamp
00054      *
00055      * @warning
00056      * Do not insert more than one timestamp.
00057      * The same @a event object is used for every @a insert/insert_absolute call.
00058      *
00059      * @warning
00060      * Ticker's present timestamp is used for reference. For timestamps
00061      * from the past the event is scheduled after ticker's overflow.
00062      * For reference @see convert_timestamp
00063      */
00064     void insert(timestamp_t timestamp);
00065 
00066     /** Set absolute timestamp of the internal event.
00067      * @param   timestamp   event's us timestamp
00068      *
00069      * @warning
00070      * Do not insert more than one timestamp.
00071      * The same @a event object is used for every @a insert/insert_absolute call.
00072      */
00073     void insert_absolute(us_timestamp_t timestamp);
00074 
00075     /** Remove timestamp.
00076      */
00077     void remove();
00078 
00079     ticker_event_t event;
00080 
00081     const ticker_data_t *_ticker_data;
00082 #endif
00083 };
00084 
00085 } // namespace mbed
00086 
00087 #endif