Ethernetwebsoc

Dependencies:   C12832_lcd LM75B WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
GordonSin
Date:
Fri May 31 04:09:54 2013 +0000
Revision:
0:0ed2a7c7190c
31/5/2013;

Who changed what in which revision?

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