teste de publish

Dependencies:   DS1820 HighSpeedAnalogIn devices mbed

Committer:
brunofgc
Date:
Fri Jun 08 22:14:21 2018 +0000
Revision:
38:07d3907b74e5
Parent:
0:1c0a769988ee
teste de publish para compilar no mbed-cli

Who changed what in which revision?

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