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