ソースの整理中ですが、利用はできます。

Dependencies:   EthernetInterface HttpServer TextLCD mbed-rpc mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
yueee_yt
Date:
Wed Mar 12 04:39:15 2014 +0000
Revision:
2:14b689a85306
Parent:
0:7766f6712673
bug fix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yueee_yt 0:7766f6712673 1 /* mbed Microcontroller Library
yueee_yt 0:7766f6712673 2 * Copyright (c) 2006-2012 ARM Limited
yueee_yt 0:7766f6712673 3 *
yueee_yt 0:7766f6712673 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
yueee_yt 0:7766f6712673 5 * of this software and associated documentation files (the "Software"), to deal
yueee_yt 0:7766f6712673 6 * in the Software without restriction, including without limitation the rights
yueee_yt 0:7766f6712673 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
yueee_yt 0:7766f6712673 8 * copies of the Software, and to permit persons to whom the Software is
yueee_yt 0:7766f6712673 9 * furnished to do so, subject to the following conditions:
yueee_yt 0:7766f6712673 10 *
yueee_yt 0:7766f6712673 11 * The above copyright notice and this permission notice shall be included in
yueee_yt 0:7766f6712673 12 * all copies or substantial portions of the Software.
yueee_yt 0:7766f6712673 13 *
yueee_yt 0:7766f6712673 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
yueee_yt 0:7766f6712673 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
yueee_yt 0:7766f6712673 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
yueee_yt 0:7766f6712673 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
yueee_yt 0:7766f6712673 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
yueee_yt 0:7766f6712673 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
yueee_yt 0:7766f6712673 20 * SOFTWARE.
yueee_yt 0:7766f6712673 21 */
yueee_yt 0:7766f6712673 22 #ifndef THREAD_H
yueee_yt 0:7766f6712673 23 #define THREAD_H
yueee_yt 0:7766f6712673 24
yueee_yt 0:7766f6712673 25 #include <stdint.h>
yueee_yt 0:7766f6712673 26 #include "cmsis_os.h"
yueee_yt 0:7766f6712673 27
yueee_yt 0:7766f6712673 28 namespace rtos {
yueee_yt 0:7766f6712673 29
yueee_yt 0:7766f6712673 30 /** The Thread class allow defining, creating, and controlling thread functions in the system. */
yueee_yt 0:7766f6712673 31 class Thread {
yueee_yt 0:7766f6712673 32 public:
yueee_yt 0:7766f6712673 33 /** Create a new thread, and start it executing the specified function.
yueee_yt 0:7766f6712673 34 @param task function to be executed by this thread.
yueee_yt 0:7766f6712673 35 @param argument pointer that is passed to the thread function as start argument. (default: NULL).
yueee_yt 0:7766f6712673 36 @param priority initial priority of the thread function. (default: osPriorityNormal).
yueee_yt 0:7766f6712673 37 @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
yueee_yt 0:7766f6712673 38 @param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
yueee_yt 0:7766f6712673 39 */
yueee_yt 0:7766f6712673 40 Thread(void (*task)(void const *argument), void *argument=NULL,
yueee_yt 0:7766f6712673 41 osPriority priority=osPriorityNormal,
yueee_yt 0:7766f6712673 42 uint32_t stack_size=DEFAULT_STACK_SIZE,
yueee_yt 0:7766f6712673 43 unsigned char *stack_pointer=NULL);
yueee_yt 0:7766f6712673 44
yueee_yt 0:7766f6712673 45 /** Terminate execution of a thread and remove it from Active Threads
yueee_yt 0:7766f6712673 46 @return status code that indicates the execution status of the function.
yueee_yt 0:7766f6712673 47 */
yueee_yt 0:7766f6712673 48 osStatus terminate();
yueee_yt 0:7766f6712673 49
yueee_yt 0:7766f6712673 50 /** Set priority of an active thread
yueee_yt 0:7766f6712673 51 @param priority new priority value for the thread function.
yueee_yt 0:7766f6712673 52 @return status code that indicates the execution status of the function.
yueee_yt 0:7766f6712673 53 */
yueee_yt 0:7766f6712673 54 osStatus set_priority(osPriority priority);
yueee_yt 0:7766f6712673 55
yueee_yt 0:7766f6712673 56 /** Get priority of an active thread
yueee_yt 0:7766f6712673 57 @return current priority value of the thread function.
yueee_yt 0:7766f6712673 58 */
yueee_yt 0:7766f6712673 59 osPriority get_priority();
yueee_yt 0:7766f6712673 60
yueee_yt 0:7766f6712673 61 /** Set the specified Signal Flags of an active thread.
yueee_yt 0:7766f6712673 62 @param signals specifies the signal flags of the thread that should be set.
yueee_yt 0:7766f6712673 63 @return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
yueee_yt 0:7766f6712673 64 */
yueee_yt 0:7766f6712673 65 int32_t signal_set(int32_t signals);
yueee_yt 0:7766f6712673 66
yueee_yt 0:7766f6712673 67 /** State of the Thread */
yueee_yt 0:7766f6712673 68 enum State {
yueee_yt 0:7766f6712673 69 Inactive, /**< Not created or terminated */
yueee_yt 0:7766f6712673 70 Ready, /**< Ready to run */
yueee_yt 0:7766f6712673 71 Running, /**< Running */
yueee_yt 0:7766f6712673 72 WaitingDelay, /**< Waiting for a delay to occur */
yueee_yt 0:7766f6712673 73 WaitingInterval, /**< Waiting for an interval to occur */
yueee_yt 0:7766f6712673 74 WaitingOr, /**< Waiting for one event in a set to occur */
yueee_yt 0:7766f6712673 75 WaitingAnd, /**< Waiting for multiple events in a set to occur */
yueee_yt 0:7766f6712673 76 WaitingSemaphore, /**< Waiting for a semaphore event to occur */
yueee_yt 0:7766f6712673 77 WaitingMailbox, /**< Waiting for a mailbox event to occur */
yueee_yt 0:7766f6712673 78 WaitingMutex, /**< Waiting for a mutex event to occur */
yueee_yt 0:7766f6712673 79 };
yueee_yt 0:7766f6712673 80
yueee_yt 0:7766f6712673 81 /** State of this Thread
yueee_yt 0:7766f6712673 82 @return the State of this Thread
yueee_yt 0:7766f6712673 83 */
yueee_yt 0:7766f6712673 84 State get_state();
yueee_yt 0:7766f6712673 85
yueee_yt 0:7766f6712673 86 /** Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
yueee_yt 0:7766f6712673 87 @param signals wait until all specified signal flags set or 0 for any single signal flag.
yueee_yt 0:7766f6712673 88 @param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
yueee_yt 0:7766f6712673 89 @return event flag information or error code.
yueee_yt 0:7766f6712673 90 */
yueee_yt 0:7766f6712673 91 static osEvent signal_wait(int32_t signals, uint32_t millisec=osWaitForever);
yueee_yt 0:7766f6712673 92
yueee_yt 0:7766f6712673 93 /** Wait for a specified time period in millisec:
yueee_yt 0:7766f6712673 94 @param millisec time delay value
yueee_yt 0:7766f6712673 95 @return status code that indicates the execution status of the function.
yueee_yt 0:7766f6712673 96 */
yueee_yt 0:7766f6712673 97 static osStatus wait(uint32_t millisec);
yueee_yt 0:7766f6712673 98
yueee_yt 0:7766f6712673 99 /** Pass control to next thread that is in state READY.
yueee_yt 0:7766f6712673 100 @return status code that indicates the execution status of the function.
yueee_yt 0:7766f6712673 101 */
yueee_yt 0:7766f6712673 102 static osStatus yield();
yueee_yt 0:7766f6712673 103
yueee_yt 0:7766f6712673 104 /** Get the thread id of the current running thread.
yueee_yt 0:7766f6712673 105 @return thread ID for reference by other functions or NULL in case of error.
yueee_yt 0:7766f6712673 106 */
yueee_yt 0:7766f6712673 107 static osThreadId gettid();
yueee_yt 0:7766f6712673 108
yueee_yt 0:7766f6712673 109 virtual ~Thread();
yueee_yt 0:7766f6712673 110
yueee_yt 0:7766f6712673 111 private:
yueee_yt 0:7766f6712673 112 osThreadId _tid;
yueee_yt 0:7766f6712673 113 osThreadDef_t _thread_def;
yueee_yt 0:7766f6712673 114 bool _dynamic_stack;
yueee_yt 0:7766f6712673 115 };
yueee_yt 0:7766f6712673 116
yueee_yt 0:7766f6712673 117 }
yueee_yt 0:7766f6712673 118 #endif