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