Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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