This fork captures the mbed lib v125 for ease of integration into older projects.

Fork of mbed-dev by mbed official

Committer:
apluscw
Date:
Fri Jul 20 21:24:42 2018 +0000
Revision:
187:92cbb9eec47b
Mbed library with source code from mbed lib v125. Posted to ease integration with some older projects.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
apluscw 187:92cbb9eec47b 1 /* mbed Microcontroller Library
apluscw 187:92cbb9eec47b 2 * Copyright (c) 2006-2013 ARM Limited
apluscw 187:92cbb9eec47b 3 *
apluscw 187:92cbb9eec47b 4 * Licensed under the Apache License, Version 2.0 (the "License");
apluscw 187:92cbb9eec47b 5 * you may not use this file except in compliance with the License.
apluscw 187:92cbb9eec47b 6 * You may obtain a copy of the License at
apluscw 187:92cbb9eec47b 7 *
apluscw 187:92cbb9eec47b 8 * http://www.apache.org/licenses/LICENSE-2.0
apluscw 187:92cbb9eec47b 9 *
apluscw 187:92cbb9eec47b 10 * Unless required by applicable law or agreed to in writing, software
apluscw 187:92cbb9eec47b 11 * distributed under the License is distributed on an "AS IS" BASIS,
apluscw 187:92cbb9eec47b 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
apluscw 187:92cbb9eec47b 13 * See the License for the specific language governing permissions and
apluscw 187:92cbb9eec47b 14 * limitations under the License.
apluscw 187:92cbb9eec47b 15 */
apluscw 187:92cbb9eec47b 16 #include "TimerEvent.h"
apluscw 187:92cbb9eec47b 17 #include "cmsis.h"
apluscw 187:92cbb9eec47b 18
apluscw 187:92cbb9eec47b 19 #include <stddef.h>
apluscw 187:92cbb9eec47b 20 #include "ticker_api.h"
apluscw 187:92cbb9eec47b 21 #include "us_ticker_api.h"
apluscw 187:92cbb9eec47b 22
apluscw 187:92cbb9eec47b 23 namespace mbed {
apluscw 187:92cbb9eec47b 24
apluscw 187:92cbb9eec47b 25 TimerEvent::TimerEvent() : event(), _ticker_data(get_us_ticker_data()) {
apluscw 187:92cbb9eec47b 26 ticker_set_handler(_ticker_data, (&TimerEvent::irq));
apluscw 187:92cbb9eec47b 27 }
apluscw 187:92cbb9eec47b 28
apluscw 187:92cbb9eec47b 29 TimerEvent::TimerEvent(const ticker_data_t *data) : event(), _ticker_data(data) {
apluscw 187:92cbb9eec47b 30 ticker_set_handler(_ticker_data, (&TimerEvent::irq));
apluscw 187:92cbb9eec47b 31 }
apluscw 187:92cbb9eec47b 32
apluscw 187:92cbb9eec47b 33 void TimerEvent::irq(uint32_t id) {
apluscw 187:92cbb9eec47b 34 TimerEvent *timer_event = (TimerEvent*)id;
apluscw 187:92cbb9eec47b 35 timer_event->handler();
apluscw 187:92cbb9eec47b 36 }
apluscw 187:92cbb9eec47b 37
apluscw 187:92cbb9eec47b 38 TimerEvent::~TimerEvent() {
apluscw 187:92cbb9eec47b 39 remove();
apluscw 187:92cbb9eec47b 40 }
apluscw 187:92cbb9eec47b 41
apluscw 187:92cbb9eec47b 42 // insert in to linked list
apluscw 187:92cbb9eec47b 43 void TimerEvent::insert(timestamp_t timestamp) {
apluscw 187:92cbb9eec47b 44 ticker_insert_event(_ticker_data, &event, timestamp, (uint32_t)this);
apluscw 187:92cbb9eec47b 45 }
apluscw 187:92cbb9eec47b 46
apluscw 187:92cbb9eec47b 47 void TimerEvent::remove() {
apluscw 187:92cbb9eec47b 48 ticker_remove_event(_ticker_data, &event);
apluscw 187:92cbb9eec47b 49 }
apluscw 187:92cbb9eec47b 50
apluscw 187:92cbb9eec47b 51 } // namespace mbed