mbed library sources

Fork of mbed-src by mbed official

Committer:
rllamado
Date:
Sun Feb 21 07:27:08 2016 +0000
Revision:
636:21ce76d41a4f
Parent:
525:c320967f86b9
something

Who changed what in which revision?

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