SDCard version

Fork of gr-peach-opencv-project-sd-card by the do

Committer:
thedo
Date:
Fri Jul 21 01:26:54 2017 +0000
Revision:
167:2ee3e82cb6f5
gr-peach-opencv-project-sd-card

Who changed what in which revision?

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