Entrega 3er corte - sistemas embebidos

Committer:
Bethory
Date:
Wed May 30 04:46:28 2018 +0000
Revision:
1:fcdb45ee95b9
Parent:
0:6ad07c9019fd
Entrega Final

Who changed what in which revision?

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