Opencv 3.1 project on GR-PEACH board

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

Committer:
thedo
Date:
Tue Jul 04 06:23:13 2017 +0000
Revision:
170:54ff26da7eb6
Parent:
166:3a9487d57a5c
project opencv 3.1 on GR PEACH board, no use SD card.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thedo 166:3a9487d57a5c 1 /* mbed Microcontroller Library
thedo 166:3a9487d57a5c 2 * Copyright (c) 2006-2012 ARM Limited
thedo 166:3a9487d57a5c 3 *
thedo 166:3a9487d57a5c 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
thedo 166:3a9487d57a5c 5 * of this software and associated documentation files (the "Software"), to deal
thedo 166:3a9487d57a5c 6 * in the Software without restriction, including without limitation the rights
thedo 166:3a9487d57a5c 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
thedo 166:3a9487d57a5c 8 * copies of the Software, and to permit persons to whom the Software is
thedo 166:3a9487d57a5c 9 * furnished to do so, subject to the following conditions:
thedo 166:3a9487d57a5c 10 *
thedo 166:3a9487d57a5c 11 * The above copyright notice and this permission notice shall be included in
thedo 166:3a9487d57a5c 12 * all copies or substantial portions of the Software.
thedo 166:3a9487d57a5c 13 *
thedo 166:3a9487d57a5c 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
thedo 166:3a9487d57a5c 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
thedo 166:3a9487d57a5c 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
thedo 166:3a9487d57a5c 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
thedo 166:3a9487d57a5c 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
thedo 166:3a9487d57a5c 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
thedo 166:3a9487d57a5c 20 * SOFTWARE.
thedo 166:3a9487d57a5c 21 */
thedo 166:3a9487d57a5c 22 #ifndef THREAD_H
thedo 166:3a9487d57a5c 23 #define THREAD_H
thedo 166:3a9487d57a5c 24
thedo 166:3a9487d57a5c 25 #include <stdint.h>
thedo 166:3a9487d57a5c 26 #include "cmsis_os.h"
thedo 166:3a9487d57a5c 27 #include "platform/Callback.h"
thedo 166:3a9487d57a5c 28 #include "platform/toolchain.h"
thedo 166:3a9487d57a5c 29 #include "rtos/Semaphore.h"
thedo 166:3a9487d57a5c 30 #include "rtos/Mutex.h"
thedo 166:3a9487d57a5c 31
thedo 166:3a9487d57a5c 32 namespace rtos {
thedo 166:3a9487d57a5c 33 /** \addtogroup rtos */
thedo 166:3a9487d57a5c 34 /** @{*/
thedo 166:3a9487d57a5c 35
thedo 166:3a9487d57a5c 36 /** The Thread class allow defining, creating, and controlling thread functions in the system.
thedo 166:3a9487d57a5c 37 *
thedo 166:3a9487d57a5c 38 * Example:
thedo 166:3a9487d57a5c 39 * @code
thedo 166:3a9487d57a5c 40 * #include "mbed.h"
thedo 166:3a9487d57a5c 41 * #include "rtos.h"
thedo 166:3a9487d57a5c 42 *
thedo 166:3a9487d57a5c 43 * Thread thread;
thedo 166:3a9487d57a5c 44 * DigitalOut led1(LED1);
thedo 166:3a9487d57a5c 45 * volatile bool running = true;
thedo 166:3a9487d57a5c 46 *
thedo 166:3a9487d57a5c 47 * // Blink function toggles the led in a long running loop
thedo 166:3a9487d57a5c 48 * void blink(DigitalOut *led) {
thedo 166:3a9487d57a5c 49 * while (running) {
thedo 166:3a9487d57a5c 50 * *led = !*led;
thedo 166:3a9487d57a5c 51 * Thread::wait(1000);
thedo 166:3a9487d57a5c 52 * }
thedo 166:3a9487d57a5c 53 * }
thedo 166:3a9487d57a5c 54 *
thedo 166:3a9487d57a5c 55 * // Spawns a thread to run blink for 5 seconds
thedo 166:3a9487d57a5c 56 * int main() {
thedo 166:3a9487d57a5c 57 * thread.start(led1, blink);
thedo 166:3a9487d57a5c 58 * Thread::wait(5000);
thedo 166:3a9487d57a5c 59 * running = false;
thedo 166:3a9487d57a5c 60 * thread.join();
thedo 166:3a9487d57a5c 61 * }
thedo 166:3a9487d57a5c 62 * @endcode
thedo 166:3a9487d57a5c 63 */
thedo 166:3a9487d57a5c 64 class Thread {
thedo 166:3a9487d57a5c 65 public:
thedo 166:3a9487d57a5c 66 /** Allocate a new thread without starting execution
thedo 166:3a9487d57a5c 67 @param priority initial priority of the thread function. (default: osPriorityNormal).
thedo 166:3a9487d57a5c 68 @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
thedo 166:3a9487d57a5c 69 @param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
thedo 166:3a9487d57a5c 70 */
thedo 166:3a9487d57a5c 71 Thread(osPriority priority=osPriorityNormal,
thedo 166:3a9487d57a5c 72 uint32_t stack_size=DEFAULT_STACK_SIZE,
thedo 166:3a9487d57a5c 73 unsigned char *stack_pointer=NULL) {
thedo 166:3a9487d57a5c 74 constructor(priority, stack_size, stack_pointer);
thedo 166:3a9487d57a5c 75 }
thedo 166:3a9487d57a5c 76
thedo 166:3a9487d57a5c 77 /** Create a new thread, and start it executing the specified function.
thedo 166:3a9487d57a5c 78 @param task function to be executed by this thread.
thedo 166:3a9487d57a5c 79 @param argument pointer that is passed to the thread function as start argument. (default: NULL).
thedo 166:3a9487d57a5c 80 @param priority initial priority of the thread function. (default: osPriorityNormal).
thedo 166:3a9487d57a5c 81 @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
thedo 166:3a9487d57a5c 82 @param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
thedo 166:3a9487d57a5c 83 @deprecated
thedo 166:3a9487d57a5c 84 Thread-spawning constructors hide errors. Replaced by thread.start(task).
thedo 166:3a9487d57a5c 85
thedo 166:3a9487d57a5c 86 @code
thedo 166:3a9487d57a5c 87 Thread thread(priority, stack_size, stack_pointer);
thedo 166:3a9487d57a5c 88
thedo 166:3a9487d57a5c 89 osStatus status = thread.start(task);
thedo 166:3a9487d57a5c 90 if (status != osOK) {
thedo 166:3a9487d57a5c 91 error("oh no!");
thedo 166:3a9487d57a5c 92 }
thedo 166:3a9487d57a5c 93 @endcode
thedo 166:3a9487d57a5c 94 */
thedo 166:3a9487d57a5c 95 MBED_DEPRECATED_SINCE("mbed-os-5.1",
thedo 166:3a9487d57a5c 96 "Thread-spawning constructors hide errors. "
thedo 166:3a9487d57a5c 97 "Replaced by thread.start(task).")
thedo 166:3a9487d57a5c 98 Thread(mbed::Callback<void()> task,
thedo 166:3a9487d57a5c 99 osPriority priority=osPriorityNormal,
thedo 166:3a9487d57a5c 100 uint32_t stack_size=DEFAULT_STACK_SIZE,
thedo 166:3a9487d57a5c 101 unsigned char *stack_pointer=NULL) {
thedo 166:3a9487d57a5c 102 constructor(task, priority, stack_size, stack_pointer);
thedo 166:3a9487d57a5c 103 }
thedo 166:3a9487d57a5c 104
thedo 166:3a9487d57a5c 105 /** Create a new thread, and start it executing the specified function.
thedo 166:3a9487d57a5c 106 @param obj argument to task.
thedo 166:3a9487d57a5c 107 @param method function to be executed by this thread.
thedo 166:3a9487d57a5c 108 @param argument pointer that is passed to the thread function as start argument. (default: NULL).
thedo 166:3a9487d57a5c 109 @param priority initial priority of the thread function. (default: osPriorityNormal).
thedo 166:3a9487d57a5c 110 @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
thedo 166:3a9487d57a5c 111 @param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
thedo 166:3a9487d57a5c 112 @deprecated
thedo 166:3a9487d57a5c 113 Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
thedo 166:3a9487d57a5c 114
thedo 166:3a9487d57a5c 115 @code
thedo 166:3a9487d57a5c 116 Thread thread(priority, stack_size, stack_pointer);
thedo 166:3a9487d57a5c 117
thedo 166:3a9487d57a5c 118 osStatus status = thread.start(callback(task, argument));
thedo 166:3a9487d57a5c 119 if (status != osOK) {
thedo 166:3a9487d57a5c 120 error("oh no!");
thedo 166:3a9487d57a5c 121 }
thedo 166:3a9487d57a5c 122 @endcode
thedo 166:3a9487d57a5c 123 */
thedo 166:3a9487d57a5c 124 template <typename T>
thedo 166:3a9487d57a5c 125 MBED_DEPRECATED_SINCE("mbed-os-5.1",
thedo 166:3a9487d57a5c 126 "Thread-spawning constructors hide errors. "
thedo 166:3a9487d57a5c 127 "Replaced by thread.start(callback(task, argument)).")
thedo 166:3a9487d57a5c 128 Thread(T *argument, void (T::*task)(),
thedo 166:3a9487d57a5c 129 osPriority priority=osPriorityNormal,
thedo 166:3a9487d57a5c 130 uint32_t stack_size=DEFAULT_STACK_SIZE,
thedo 166:3a9487d57a5c 131 unsigned char *stack_pointer=NULL) {
thedo 166:3a9487d57a5c 132 constructor(mbed::callback(task, argument),
thedo 166:3a9487d57a5c 133 priority, stack_size, stack_pointer);
thedo 166:3a9487d57a5c 134 }
thedo 166:3a9487d57a5c 135
thedo 166:3a9487d57a5c 136 /** Create a new thread, and start it executing the specified function.
thedo 166:3a9487d57a5c 137 @param obj argument to task.
thedo 166:3a9487d57a5c 138 @param method function to be executed by this thread.
thedo 166:3a9487d57a5c 139 @param argument pointer that is passed to the thread function as start argument. (default: NULL).
thedo 166:3a9487d57a5c 140 @param priority initial priority of the thread function. (default: osPriorityNormal).
thedo 166:3a9487d57a5c 141 @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
thedo 166:3a9487d57a5c 142 @param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
thedo 166:3a9487d57a5c 143 @deprecated
thedo 166:3a9487d57a5c 144 Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
thedo 166:3a9487d57a5c 145
thedo 166:3a9487d57a5c 146 @code
thedo 166:3a9487d57a5c 147 Thread thread(priority, stack_size, stack_pointer);
thedo 166:3a9487d57a5c 148
thedo 166:3a9487d57a5c 149 osStatus status = thread.start(callback(task, argument));
thedo 166:3a9487d57a5c 150 if (status != osOK) {
thedo 166:3a9487d57a5c 151 error("oh no!");
thedo 166:3a9487d57a5c 152 }
thedo 166:3a9487d57a5c 153 @endcode
thedo 166:3a9487d57a5c 154 */
thedo 166:3a9487d57a5c 155 template <typename T>
thedo 166:3a9487d57a5c 156 MBED_DEPRECATED_SINCE("mbed-os-5.1",
thedo 166:3a9487d57a5c 157 "Thread-spawning constructors hide errors. "
thedo 166:3a9487d57a5c 158 "Replaced by thread.start(callback(task, argument)).")
thedo 166:3a9487d57a5c 159 Thread(T *argument, void (*task)(T *),
thedo 166:3a9487d57a5c 160 osPriority priority=osPriorityNormal,
thedo 166:3a9487d57a5c 161 uint32_t stack_size=DEFAULT_STACK_SIZE,
thedo 166:3a9487d57a5c 162 unsigned char *stack_pointer=NULL) {
thedo 166:3a9487d57a5c 163 constructor(mbed::callback(task, argument),
thedo 166:3a9487d57a5c 164 priority, stack_size, stack_pointer);
thedo 166:3a9487d57a5c 165 }
thedo 166:3a9487d57a5c 166
thedo 166:3a9487d57a5c 167 /** Create a new thread, and start it executing the specified function.
thedo 166:3a9487d57a5c 168 Provided for backwards compatibility
thedo 166:3a9487d57a5c 169 @param task function to be executed by this thread.
thedo 166:3a9487d57a5c 170 @param argument pointer that is passed to the thread function as start argument. (default: NULL).
thedo 166:3a9487d57a5c 171 @param priority initial priority of the thread function. (default: osPriorityNormal).
thedo 166:3a9487d57a5c 172 @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
thedo 166:3a9487d57a5c 173 @param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
thedo 166:3a9487d57a5c 174 @deprecated
thedo 166:3a9487d57a5c 175 Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
thedo 166:3a9487d57a5c 176
thedo 166:3a9487d57a5c 177 @code
thedo 166:3a9487d57a5c 178 Thread thread(priority, stack_size, stack_pointer);
thedo 166:3a9487d57a5c 179
thedo 166:3a9487d57a5c 180 osStatus status = thread.start(callback(task, argument));
thedo 166:3a9487d57a5c 181 if (status != osOK) {
thedo 166:3a9487d57a5c 182 error("oh no!");
thedo 166:3a9487d57a5c 183 }
thedo 166:3a9487d57a5c 184 @endcode
thedo 166:3a9487d57a5c 185 */
thedo 166:3a9487d57a5c 186 MBED_DEPRECATED_SINCE("mbed-os-5.1",
thedo 166:3a9487d57a5c 187 "Thread-spawning constructors hide errors. "
thedo 166:3a9487d57a5c 188 "Replaced by thread.start(callback(task, argument)).")
thedo 166:3a9487d57a5c 189 Thread(void (*task)(void const *argument), void *argument=NULL,
thedo 166:3a9487d57a5c 190 osPriority priority=osPriorityNormal,
thedo 166:3a9487d57a5c 191 uint32_t stack_size=DEFAULT_STACK_SIZE,
thedo 166:3a9487d57a5c 192 unsigned char *stack_pointer=NULL) {
thedo 166:3a9487d57a5c 193 constructor(mbed::callback((void (*)(void *))task, argument),
thedo 166:3a9487d57a5c 194 priority, stack_size, stack_pointer);
thedo 166:3a9487d57a5c 195 }
thedo 166:3a9487d57a5c 196
thedo 166:3a9487d57a5c 197 /** Starts a thread executing the specified function.
thedo 166:3a9487d57a5c 198 @param task function to be executed by this thread.
thedo 166:3a9487d57a5c 199 @return status code that indicates the execution status of the function.
thedo 166:3a9487d57a5c 200 */
thedo 166:3a9487d57a5c 201 osStatus start(mbed::Callback<void()> task);
thedo 166:3a9487d57a5c 202
thedo 166:3a9487d57a5c 203 /** Starts a thread executing the specified function.
thedo 166:3a9487d57a5c 204 @param obj argument to task
thedo 166:3a9487d57a5c 205 @param method function to be executed by this thread.
thedo 166:3a9487d57a5c 206 @return status code that indicates the execution status of the function.
thedo 166:3a9487d57a5c 207 @deprecated
thedo 166:3a9487d57a5c 208 The start function does not support cv-qualifiers. Replaced by start(callback(obj, method)).
thedo 166:3a9487d57a5c 209 */
thedo 166:3a9487d57a5c 210 template <typename T, typename M>
thedo 166:3a9487d57a5c 211 MBED_DEPRECATED_SINCE("mbed-os-5.1",
thedo 166:3a9487d57a5c 212 "The start function does not support cv-qualifiers. "
thedo 166:3a9487d57a5c 213 "Replaced by thread.start(callback(obj, method)).")
thedo 166:3a9487d57a5c 214 osStatus start(T *obj, M method) {
thedo 166:3a9487d57a5c 215 return start(mbed::callback(obj, method));
thedo 166:3a9487d57a5c 216 }
thedo 166:3a9487d57a5c 217
thedo 166:3a9487d57a5c 218 /** Wait for thread to terminate
thedo 166:3a9487d57a5c 219 @return status code that indicates the execution status of the function.
thedo 166:3a9487d57a5c 220 @note not callable from interrupt
thedo 166:3a9487d57a5c 221 */
thedo 166:3a9487d57a5c 222 osStatus join();
thedo 166:3a9487d57a5c 223
thedo 166:3a9487d57a5c 224 /** Terminate execution of a thread and remove it from Active Threads
thedo 166:3a9487d57a5c 225 @return status code that indicates the execution status of the function.
thedo 166:3a9487d57a5c 226 */
thedo 166:3a9487d57a5c 227 osStatus terminate();
thedo 166:3a9487d57a5c 228
thedo 166:3a9487d57a5c 229 /** Set priority of an active thread
thedo 166:3a9487d57a5c 230 @param priority new priority value for the thread function.
thedo 166:3a9487d57a5c 231 @return status code that indicates the execution status of the function.
thedo 166:3a9487d57a5c 232 */
thedo 166:3a9487d57a5c 233 osStatus set_priority(osPriority priority);
thedo 166:3a9487d57a5c 234
thedo 166:3a9487d57a5c 235 /** Get priority of an active thread
thedo 166:3a9487d57a5c 236 @return current priority value of the thread function.
thedo 166:3a9487d57a5c 237 */
thedo 166:3a9487d57a5c 238 osPriority get_priority();
thedo 166:3a9487d57a5c 239
thedo 166:3a9487d57a5c 240 /** Set the specified Signal Flags of an active thread.
thedo 166:3a9487d57a5c 241 @param signals specifies the signal flags of the thread that should be set.
thedo 166:3a9487d57a5c 242 @return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
thedo 166:3a9487d57a5c 243 */
thedo 166:3a9487d57a5c 244 int32_t signal_set(int32_t signals);
thedo 166:3a9487d57a5c 245
thedo 166:3a9487d57a5c 246 /** Clears the specified Signal Flags of an active thread.
thedo 166:3a9487d57a5c 247 @param signals specifies the signal flags of the thread that should be cleared.
thedo 166:3a9487d57a5c 248 @return resultant signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
thedo 166:3a9487d57a5c 249 */
thedo 166:3a9487d57a5c 250 int32_t signal_clr(int32_t signals);
thedo 166:3a9487d57a5c 251
thedo 166:3a9487d57a5c 252 /** State of the Thread */
thedo 166:3a9487d57a5c 253 enum State {
thedo 166:3a9487d57a5c 254 Inactive, /**< Not created or terminated */
thedo 166:3a9487d57a5c 255 Ready, /**< Ready to run */
thedo 166:3a9487d57a5c 256 Running, /**< Running */
thedo 166:3a9487d57a5c 257 WaitingDelay, /**< Waiting for a delay to occur */
thedo 166:3a9487d57a5c 258 WaitingInterval, /**< Waiting for an interval to occur */
thedo 166:3a9487d57a5c 259 WaitingOr, /**< Waiting for one event in a set to occur */
thedo 166:3a9487d57a5c 260 WaitingAnd, /**< Waiting for multiple events in a set to occur */
thedo 166:3a9487d57a5c 261 WaitingSemaphore, /**< Waiting for a semaphore event to occur */
thedo 166:3a9487d57a5c 262 WaitingMailbox, /**< Waiting for a mailbox event to occur */
thedo 166:3a9487d57a5c 263 WaitingMutex, /**< Waiting for a mutex event to occur */
thedo 166:3a9487d57a5c 264
thedo 166:3a9487d57a5c 265 /* Not in sync with RTX below here */
thedo 166:3a9487d57a5c 266 Deleted, /**< The task has been deleted */
thedo 166:3a9487d57a5c 267 };
thedo 166:3a9487d57a5c 268
thedo 166:3a9487d57a5c 269 /** State of this Thread
thedo 166:3a9487d57a5c 270 @return the State of this Thread
thedo 166:3a9487d57a5c 271 */
thedo 166:3a9487d57a5c 272 State get_state();
thedo 166:3a9487d57a5c 273
thedo 166:3a9487d57a5c 274 /** Get the total stack memory size for this Thread
thedo 166:3a9487d57a5c 275 @return the total stack memory size in bytes
thedo 166:3a9487d57a5c 276 */
thedo 166:3a9487d57a5c 277 uint32_t stack_size();
thedo 166:3a9487d57a5c 278
thedo 166:3a9487d57a5c 279 /** Get the currently unused stack memory for this Thread
thedo 166:3a9487d57a5c 280 @return the currently unused stack memory in bytes
thedo 166:3a9487d57a5c 281 */
thedo 166:3a9487d57a5c 282 uint32_t free_stack();
thedo 166:3a9487d57a5c 283
thedo 166:3a9487d57a5c 284 /** Get the currently used stack memory for this Thread
thedo 166:3a9487d57a5c 285 @return the currently used stack memory in bytes
thedo 166:3a9487d57a5c 286 */
thedo 166:3a9487d57a5c 287 uint32_t used_stack();
thedo 166:3a9487d57a5c 288
thedo 166:3a9487d57a5c 289 /** Get the maximum stack memory usage to date for this Thread
thedo 166:3a9487d57a5c 290 @return the maximum stack memory usage to date in bytes
thedo 166:3a9487d57a5c 291 */
thedo 166:3a9487d57a5c 292 uint32_t max_stack();
thedo 166:3a9487d57a5c 293
thedo 166:3a9487d57a5c 294 /** Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
thedo 166:3a9487d57a5c 295 @param signals wait until all specified signal flags set or 0 for any single signal flag.
thedo 166:3a9487d57a5c 296 @param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
thedo 166:3a9487d57a5c 297 @return event flag information or error code.
thedo 166:3a9487d57a5c 298 @note not callable from interrupt
thedo 166:3a9487d57a5c 299 */
thedo 166:3a9487d57a5c 300 static osEvent signal_wait(int32_t signals, uint32_t millisec=osWaitForever);
thedo 166:3a9487d57a5c 301
thedo 166:3a9487d57a5c 302 /** Wait for a specified time period in millisec:
thedo 166:3a9487d57a5c 303 @param millisec time delay value
thedo 166:3a9487d57a5c 304 @return status code that indicates the execution status of the function.
thedo 166:3a9487d57a5c 305 @note not callable from interrupt
thedo 166:3a9487d57a5c 306 */
thedo 166:3a9487d57a5c 307 static osStatus wait(uint32_t millisec);
thedo 166:3a9487d57a5c 308
thedo 166:3a9487d57a5c 309 /** Pass control to next thread that is in state READY.
thedo 166:3a9487d57a5c 310 @return status code that indicates the execution status of the function.
thedo 166:3a9487d57a5c 311 @note not callable from interrupt
thedo 166:3a9487d57a5c 312 */
thedo 166:3a9487d57a5c 313 static osStatus yield();
thedo 166:3a9487d57a5c 314
thedo 166:3a9487d57a5c 315 /** Get the thread id of the current running thread.
thedo 166:3a9487d57a5c 316 @return thread ID for reference by other functions or NULL in case of error.
thedo 166:3a9487d57a5c 317 */
thedo 166:3a9487d57a5c 318 static osThreadId gettid();
thedo 166:3a9487d57a5c 319
thedo 166:3a9487d57a5c 320 /** Attach a function to be called by the RTOS idle task
thedo 166:3a9487d57a5c 321 @param fptr pointer to the function to be called
thedo 166:3a9487d57a5c 322 */
thedo 166:3a9487d57a5c 323 static void attach_idle_hook(void (*fptr)(void));
thedo 166:3a9487d57a5c 324
thedo 166:3a9487d57a5c 325 /** Attach a function to be called when a task is killed
thedo 166:3a9487d57a5c 326 @param fptr pointer to the function to be called
thedo 166:3a9487d57a5c 327 */
thedo 166:3a9487d57a5c 328 static void attach_terminate_hook(void (*fptr)(osThreadId id));
thedo 166:3a9487d57a5c 329
thedo 166:3a9487d57a5c 330 virtual ~Thread();
thedo 166:3a9487d57a5c 331
thedo 166:3a9487d57a5c 332 private:
thedo 166:3a9487d57a5c 333 // Required to share definitions without
thedo 166:3a9487d57a5c 334 // delegated constructors
thedo 166:3a9487d57a5c 335 void constructor(osPriority priority=osPriorityNormal,
thedo 166:3a9487d57a5c 336 uint32_t stack_size=DEFAULT_STACK_SIZE,
thedo 166:3a9487d57a5c 337 unsigned char *stack_pointer=NULL);
thedo 166:3a9487d57a5c 338 void constructor(mbed::Callback<void()> task,
thedo 166:3a9487d57a5c 339 osPriority priority=osPriorityNormal,
thedo 166:3a9487d57a5c 340 uint32_t stack_size=DEFAULT_STACK_SIZE,
thedo 166:3a9487d57a5c 341 unsigned char *stack_pointer=NULL);
thedo 166:3a9487d57a5c 342 static void _thunk(const void * thread_ptr);
thedo 166:3a9487d57a5c 343
thedo 166:3a9487d57a5c 344 mbed::Callback<void()> _task;
thedo 166:3a9487d57a5c 345 osThreadId _tid;
thedo 166:3a9487d57a5c 346 osThreadDef_t _thread_def;
thedo 166:3a9487d57a5c 347 bool _dynamic_stack;
thedo 166:3a9487d57a5c 348 Semaphore _join_sem;
thedo 166:3a9487d57a5c 349 Mutex _mutex;
thedo 166:3a9487d57a5c 350 };
thedo 166:3a9487d57a5c 351
thedo 166:3a9487d57a5c 352 }
thedo 166:3a9487d57a5c 353 #endif
thedo 166:3a9487d57a5c 354
thedo 166:3a9487d57a5c 355 /** @}*/