Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Dec 16 16:27:57 2016 +0000
Revision:
3:1198227e6421
Parent:
0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms

Who changed what in which revision?

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