IC Eurobot 2012 Program published from Shuto's account

Dependents:   Eurobot2012_Primary

Committer:
narshu
Date:
Tue Aug 07 10:25:51 2012 +0000
Revision:
0:62626fd22b30
[mbed] converted /Eurobot_2012_Primary/rtos

Who changed what in which revision?

UserRevisionLine numberNew contents of line
narshu 0:62626fd22b30 1 /* Copyright (c) 2012 mbed.org */
narshu 0:62626fd22b30 2 #ifndef THREAD_H
narshu 0:62626fd22b30 3 #define THREAD_H
narshu 0:62626fd22b30 4
narshu 0:62626fd22b30 5 #include <stdint.h>
narshu 0:62626fd22b30 6 #include "cmsis_os.h"
narshu 0:62626fd22b30 7
narshu 0:62626fd22b30 8 namespace rtos {
narshu 0:62626fd22b30 9
narshu 0:62626fd22b30 10 /*! The Thread class allow defining, creating, and controlling thread functions in the system. */
narshu 0:62626fd22b30 11 class Thread {
narshu 0:62626fd22b30 12 public:
narshu 0:62626fd22b30 13 /*! Create a new thread, and start it executing the specified function.
narshu 0:62626fd22b30 14 \param task function to be executed by this thread.
narshu 0:62626fd22b30 15 \param argument pointer that is passed to the thread function as start argument. (default: NULL).
narshu 0:62626fd22b30 16 \param priority initial priority of the thread function. (default: osPriorityNormal).
narshu 0:62626fd22b30 17 \param stacksz stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
narshu 0:62626fd22b30 18 */
narshu 0:62626fd22b30 19 Thread(void (*task)(void const *argument),
narshu 0:62626fd22b30 20 void *argument=NULL,
narshu 0:62626fd22b30 21 osPriority priority=osPriorityNormal,
narshu 0:62626fd22b30 22 uint32_t stacksize=DEFAULT_STACK_SIZE);
narshu 0:62626fd22b30 23
narshu 0:62626fd22b30 24 /*! Terminate execution of a thread and remove it from Active Threads
narshu 0:62626fd22b30 25 \return status code that indicates the execution status of the function.
narshu 0:62626fd22b30 26 */
narshu 0:62626fd22b30 27 osStatus terminate();
narshu 0:62626fd22b30 28
narshu 0:62626fd22b30 29 /*! Set priority of an active thread
narshu 0:62626fd22b30 30 \param priority new priority value for the thread function.
narshu 0:62626fd22b30 31 \return status code that indicates the execution status of the function.
narshu 0:62626fd22b30 32 */
narshu 0:62626fd22b30 33 osStatus set_priority(osPriority priority);
narshu 0:62626fd22b30 34
narshu 0:62626fd22b30 35 /*! Get priority of an active thread
narshu 0:62626fd22b30 36 \ return current priority value of the thread function.
narshu 0:62626fd22b30 37 */
narshu 0:62626fd22b30 38 osPriority get_priority();
narshu 0:62626fd22b30 39
narshu 0:62626fd22b30 40 /*! Set the specified Signal Flags of an active thread.
narshu 0:62626fd22b30 41 \param signals specifies the signal flags of the thread that should be set.
narshu 0:62626fd22b30 42 \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
narshu 0:62626fd22b30 43 */
narshu 0:62626fd22b30 44 int32_t signal_set(int32_t signals);
narshu 0:62626fd22b30 45
narshu 0:62626fd22b30 46 /*! Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
narshu 0:62626fd22b30 47 \param signals wait until all specified signal flags set or 0 for any single signal flag.
narshu 0:62626fd22b30 48 \param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
narshu 0:62626fd22b30 49 \return event flag information or error code.
narshu 0:62626fd22b30 50 */
narshu 0:62626fd22b30 51 static osEvent signal_wait(int32_t signals, uint32_t millisec=osWaitForever);
narshu 0:62626fd22b30 52
narshu 0:62626fd22b30 53
narshu 0:62626fd22b30 54 /*! Wait for a specified time period in millisec:
narshu 0:62626fd22b30 55 \param millisec time delay value
narshu 0:62626fd22b30 56 \return status code that indicates the execution status of the function.
narshu 0:62626fd22b30 57 */
narshu 0:62626fd22b30 58 static osStatus wait(uint32_t millisec);
narshu 0:62626fd22b30 59
narshu 0:62626fd22b30 60 /*! Pass control to next thread that is in state READY.
narshu 0:62626fd22b30 61 \return status code that indicates the execution status of the function.
narshu 0:62626fd22b30 62 */
narshu 0:62626fd22b30 63 static osStatus yield();
narshu 0:62626fd22b30 64
narshu 0:62626fd22b30 65 /*! Get the thread id of the current running thread.
narshu 0:62626fd22b30 66 \return thread ID for reference by other functions or NULL in case of error.
narshu 0:62626fd22b30 67 */
narshu 0:62626fd22b30 68 static osThreadId gettid();
narshu 0:62626fd22b30 69
narshu 0:62626fd22b30 70 private:
narshu 0:62626fd22b30 71 osThreadId _tid;
narshu 0:62626fd22b30 72 osThreadDef_t _thread_def;
narshu 0:62626fd22b30 73 };
narshu 0:62626fd22b30 74
narshu 0:62626fd22b30 75 }
narshu 0:62626fd22b30 76 #endif