RTC auf true

Committer:
kevman
Date:
Wed Nov 28 15:10:15 2018 +0000
Revision:
0:38ceb79fef03
RTC modified

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kevman 0:38ceb79fef03 1 /* events
kevman 0:38ceb79fef03 2 * Copyright (c) 2016 ARM Limited
kevman 0:38ceb79fef03 3 *
kevman 0:38ceb79fef03 4 * Licensed under the Apache License, Version 2.0 (the "License");
kevman 0:38ceb79fef03 5 * you may not use this file except in compliance with the License.
kevman 0:38ceb79fef03 6 * You may obtain a copy of the License at
kevman 0:38ceb79fef03 7 *
kevman 0:38ceb79fef03 8 * http://www.apache.org/licenses/LICENSE-2.0
kevman 0:38ceb79fef03 9 *
kevman 0:38ceb79fef03 10 * Unless required by applicable law or agreed to in writing, software
kevman 0:38ceb79fef03 11 * distributed under the License is distributed on an "AS IS" BASIS,
kevman 0:38ceb79fef03 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kevman 0:38ceb79fef03 13 * See the License for the specific language governing permissions and
kevman 0:38ceb79fef03 14 * limitations under the License.
kevman 0:38ceb79fef03 15 */
kevman 0:38ceb79fef03 16 #include "events/EventQueue.h"
kevman 0:38ceb79fef03 17
kevman 0:38ceb79fef03 18 #include "events/mbed_events.h"
kevman 0:38ceb79fef03 19 #include "mbed.h"
kevman 0:38ceb79fef03 20
kevman 0:38ceb79fef03 21
kevman 0:38ceb79fef03 22 EventQueue::EventQueue(unsigned event_size, unsigned char *event_pointer)
kevman 0:38ceb79fef03 23 {
kevman 0:38ceb79fef03 24 if (!event_pointer) {
kevman 0:38ceb79fef03 25 equeue_create(&_equeue, event_size);
kevman 0:38ceb79fef03 26 } else {
kevman 0:38ceb79fef03 27 equeue_create_inplace(&_equeue, event_size, event_pointer);
kevman 0:38ceb79fef03 28 }
kevman 0:38ceb79fef03 29 }
kevman 0:38ceb79fef03 30
kevman 0:38ceb79fef03 31 EventQueue::~EventQueue()
kevman 0:38ceb79fef03 32 {
kevman 0:38ceb79fef03 33 equeue_destroy(&_equeue);
kevman 0:38ceb79fef03 34 }
kevman 0:38ceb79fef03 35
kevman 0:38ceb79fef03 36 void EventQueue::dispatch(int ms)
kevman 0:38ceb79fef03 37 {
kevman 0:38ceb79fef03 38 return equeue_dispatch(&_equeue, ms);
kevman 0:38ceb79fef03 39 }
kevman 0:38ceb79fef03 40
kevman 0:38ceb79fef03 41 void EventQueue::break_dispatch()
kevman 0:38ceb79fef03 42 {
kevman 0:38ceb79fef03 43 return equeue_break(&_equeue);
kevman 0:38ceb79fef03 44 }
kevman 0:38ceb79fef03 45
kevman 0:38ceb79fef03 46 unsigned EventQueue::tick()
kevman 0:38ceb79fef03 47 {
kevman 0:38ceb79fef03 48 return equeue_tick();
kevman 0:38ceb79fef03 49 }
kevman 0:38ceb79fef03 50
kevman 0:38ceb79fef03 51 void EventQueue::cancel(int id)
kevman 0:38ceb79fef03 52 {
kevman 0:38ceb79fef03 53 return equeue_cancel(&_equeue, id);
kevman 0:38ceb79fef03 54 }
kevman 0:38ceb79fef03 55
kevman 0:38ceb79fef03 56 int EventQueue::time_left(int id)
kevman 0:38ceb79fef03 57 {
kevman 0:38ceb79fef03 58 return equeue_timeleft(&_equeue, id);
kevman 0:38ceb79fef03 59 }
kevman 0:38ceb79fef03 60
kevman 0:38ceb79fef03 61 void EventQueue::background(Callback<void(int)> update)
kevman 0:38ceb79fef03 62 {
kevman 0:38ceb79fef03 63 _update = update;
kevman 0:38ceb79fef03 64
kevman 0:38ceb79fef03 65 if (_update) {
kevman 0:38ceb79fef03 66 equeue_background(&_equeue, &Callback<void(int)>::thunk, &_update);
kevman 0:38ceb79fef03 67 } else {
kevman 0:38ceb79fef03 68 equeue_background(&_equeue, 0, 0);
kevman 0:38ceb79fef03 69 }
kevman 0:38ceb79fef03 70 }
kevman 0:38ceb79fef03 71
kevman 0:38ceb79fef03 72 void EventQueue::chain(EventQueue *target)
kevman 0:38ceb79fef03 73 {
kevman 0:38ceb79fef03 74 if (target) {
kevman 0:38ceb79fef03 75 equeue_chain(&_equeue, &target->_equeue);
kevman 0:38ceb79fef03 76 } else {
kevman 0:38ceb79fef03 77 equeue_chain(&_equeue, 0);
kevman 0:38ceb79fef03 78 }
kevman 0:38ceb79fef03 79 }