Rtos API example

Committer:
marcozecchini
Date:
Sat Feb 23 12:13:36 2019 +0000
Revision:
0:9fca2b23d0ba
final commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
marcozecchini 0:9fca2b23d0ba 1
marcozecchini 0:9fca2b23d0ba 2 /** \addtogroup events */
marcozecchini 0:9fca2b23d0ba 3 /** @{*/
marcozecchini 0:9fca2b23d0ba 4 /* events
marcozecchini 0:9fca2b23d0ba 5 * Copyright (c) 2017 ARM Limited
marcozecchini 0:9fca2b23d0ba 6 *
marcozecchini 0:9fca2b23d0ba 7 * Licensed under the Apache License, Version 2.0 (the "License");
marcozecchini 0:9fca2b23d0ba 8 * you may not use this file except in compliance with the License.
marcozecchini 0:9fca2b23d0ba 9 * You may obtain a copy of the License at
marcozecchini 0:9fca2b23d0ba 10 *
marcozecchini 0:9fca2b23d0ba 11 * http://www.apache.org/licenses/LICENSE-2.0
marcozecchini 0:9fca2b23d0ba 12 *
marcozecchini 0:9fca2b23d0ba 13 * Unless required by applicable law or agreed to in writing, software
marcozecchini 0:9fca2b23d0ba 14 * distributed under the License is distributed on an "AS IS" BASIS,
marcozecchini 0:9fca2b23d0ba 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
marcozecchini 0:9fca2b23d0ba 16 * See the License for the specific language governing permissions and
marcozecchini 0:9fca2b23d0ba 17 * limitations under the License.
marcozecchini 0:9fca2b23d0ba 18 */
marcozecchini 0:9fca2b23d0ba 19 #ifndef MBED_SHARED_QUEUES_H
marcozecchini 0:9fca2b23d0ba 20 #define MBED_SHARED_QUEUES_H
marcozecchini 0:9fca2b23d0ba 21
marcozecchini 0:9fca2b23d0ba 22 #include "events/EventQueue.h"
marcozecchini 0:9fca2b23d0ba 23
marcozecchini 0:9fca2b23d0ba 24 namespace mbed {
marcozecchini 0:9fca2b23d0ba 25
marcozecchini 0:9fca2b23d0ba 26 /**
marcozecchini 0:9fca2b23d0ba 27 * Return a pointer to an EventQueue, on which normal tasks can be queued.
marcozecchini 0:9fca2b23d0ba 28 *
marcozecchini 0:9fca2b23d0ba 29 * All calls to this return the same EventQueue - it and its dispatch thread
marcozecchini 0:9fca2b23d0ba 30 * are created on the first call to this function. The dispatch thread
marcozecchini 0:9fca2b23d0ba 31 * runs at default priority (currently osPriorityNormal).
marcozecchini 0:9fca2b23d0ba 32 *
marcozecchini 0:9fca2b23d0ba 33 * The EventQueue returned may be used to call() Events, or to chain() other
marcozecchini 0:9fca2b23d0ba 34 * EventQueues so that they are run in the same context.
marcozecchini 0:9fca2b23d0ba 35 *
marcozecchini 0:9fca2b23d0ba 36 * Events (or chained EventQueues) executing on the normal event queue should
marcozecchini 0:9fca2b23d0ba 37 * normally take less than 10ms to execute, to avoid starving other users. As
marcozecchini 0:9fca2b23d0ba 38 * such, users can expect that event latency will typically be 10ms or less,
marcozecchini 0:9fca2b23d0ba 39 * but could occasionally be significantly higher if many events are queued.
marcozecchini 0:9fca2b23d0ba 40 *
marcozecchini 0:9fca2b23d0ba 41 * If an RTOS is not present or the configuration option
marcozecchini 0:9fca2b23d0ba 42 * `events.shared-dispatch-from-application` is set to true, then this
marcozecchini 0:9fca2b23d0ba 43 * does not create a dedicated dispatch thread - instead the application is
marcozecchini 0:9fca2b23d0ba 44 * expected to run the EventQueue's dispatch, eg from main. This is necessary
marcozecchini 0:9fca2b23d0ba 45 * for the event loop to work without an RTOS, or an RTOS system can can save
marcozecchini 0:9fca2b23d0ba 46 * memory by reusing the main stack.
marcozecchini 0:9fca2b23d0ba 47 *
marcozecchini 0:9fca2b23d0ba 48 * @return pointer to event queue
marcozecchini 0:9fca2b23d0ba 49 */
marcozecchini 0:9fca2b23d0ba 50 events::EventQueue *mbed_event_queue();
marcozecchini 0:9fca2b23d0ba 51
marcozecchini 0:9fca2b23d0ba 52 #ifdef MBED_CONF_RTOS_PRESENT
marcozecchini 0:9fca2b23d0ba 53 /**
marcozecchini 0:9fca2b23d0ba 54 * Return a pointer to an EventQueue, on which small high-priority tasks can
marcozecchini 0:9fca2b23d0ba 55 * be queues, such as simple deferrals from interrupt.
marcozecchini 0:9fca2b23d0ba 56 *
marcozecchini 0:9fca2b23d0ba 57 * All calls to this return the same EventQueue - it and its thread are
marcozecchini 0:9fca2b23d0ba 58 * created on the first call to this function. The dispatch thread
marcozecchini 0:9fca2b23d0ba 59 * runs at a high priority (currently osPriorityHigh).
marcozecchini 0:9fca2b23d0ba 60 *
marcozecchini 0:9fca2b23d0ba 61 * The EventQueue returned may be used to call() Events, or to chain() other
marcozecchini 0:9fca2b23d0ba 62 * EventQueues so that they are run in the same context.
marcozecchini 0:9fca2b23d0ba 63 *
marcozecchini 0:9fca2b23d0ba 64 * Events (or chained EventQueues) executing on the high-priority event queue
marcozecchini 0:9fca2b23d0ba 65 * should normally take less than 100us to execute, to avoid starving other
marcozecchini 0:9fca2b23d0ba 66 * users. As such, users can expect that event latency will typically be 100us
marcozecchini 0:9fca2b23d0ba 67 * or less, but could occasionally be significantly higher if many events are
marcozecchini 0:9fca2b23d0ba 68 * queued.
marcozecchini 0:9fca2b23d0ba 69 *
marcozecchini 0:9fca2b23d0ba 70 * @return pointer to high-priority event queue
marcozecchini 0:9fca2b23d0ba 71 */
marcozecchini 0:9fca2b23d0ba 72
marcozecchini 0:9fca2b23d0ba 73 events::EventQueue *mbed_highprio_event_queue();
marcozecchini 0:9fca2b23d0ba 74
marcozecchini 0:9fca2b23d0ba 75 #endif // MBED_CONF_RTOS_PRESENT
marcozecchini 0:9fca2b23d0ba 76
marcozecchini 0:9fca2b23d0ba 77 };
marcozecchini 0:9fca2b23d0ba 78
marcozecchini 0:9fca2b23d0ba 79 #endif
marcozecchini 0:9fca2b23d0ba 80
marcozecchini 0:9fca2b23d0ba 81 /** @}*/