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 #include "Thread.h"
brunofgc 0:1c0a769988ee 23
brunofgc 0:1c0a769988ee 24 #include "mbed_error.h"
brunofgc 0:1c0a769988ee 25
brunofgc 0:1c0a769988ee 26 namespace rtos {
brunofgc 0:1c0a769988ee 27
brunofgc 0:1c0a769988ee 28 Thread::Thread(void (*task)(void const *argument), void *argument,
brunofgc 0:1c0a769988ee 29 osPriority priority, uint32_t stack_size, unsigned char *stack_pointer) {
brunofgc 0:1c0a769988ee 30 #ifdef CMSIS_OS_RTX
brunofgc 0:1c0a769988ee 31 _thread_def.pthread = task;
brunofgc 0:1c0a769988ee 32 _thread_def.tpriority = priority;
brunofgc 0:1c0a769988ee 33 _thread_def.stacksize = stack_size;
brunofgc 0:1c0a769988ee 34 #ifndef __MBED_CMSIS_RTOS_CA9
brunofgc 0:1c0a769988ee 35 if (stack_pointer != NULL) {
brunofgc 0:1c0a769988ee 36 _thread_def.stack_pointer = stack_pointer;
brunofgc 0:1c0a769988ee 37 _dynamic_stack = false;
brunofgc 0:1c0a769988ee 38 } else {
brunofgc 0:1c0a769988ee 39 _thread_def.stack_pointer = new unsigned char[stack_size];
brunofgc 0:1c0a769988ee 40 if (_thread_def.stack_pointer == NULL)
brunofgc 0:1c0a769988ee 41 error("Error allocating the stack memory\n");
brunofgc 0:1c0a769988ee 42 _dynamic_stack = true;
brunofgc 0:1c0a769988ee 43 }
brunofgc 0:1c0a769988ee 44 #endif
brunofgc 0:1c0a769988ee 45 #endif
brunofgc 0:1c0a769988ee 46 _tid = osThreadCreate(&_thread_def, argument);
brunofgc 0:1c0a769988ee 47 }
brunofgc 0:1c0a769988ee 48
brunofgc 0:1c0a769988ee 49 osStatus Thread::terminate() {
brunofgc 0:1c0a769988ee 50 return osThreadTerminate(_tid);
brunofgc 0:1c0a769988ee 51 }
brunofgc 0:1c0a769988ee 52
brunofgc 0:1c0a769988ee 53 osStatus Thread::set_priority(osPriority priority) {
brunofgc 0:1c0a769988ee 54 return osThreadSetPriority(_tid, priority);
brunofgc 0:1c0a769988ee 55 }
brunofgc 0:1c0a769988ee 56
brunofgc 0:1c0a769988ee 57 osPriority Thread::get_priority() {
brunofgc 0:1c0a769988ee 58 return osThreadGetPriority(_tid);
brunofgc 0:1c0a769988ee 59 }
brunofgc 0:1c0a769988ee 60
brunofgc 0:1c0a769988ee 61 int32_t Thread::signal_set(int32_t signals) {
brunofgc 0:1c0a769988ee 62 return osSignalSet(_tid, signals);
brunofgc 0:1c0a769988ee 63 }
brunofgc 0:1c0a769988ee 64
brunofgc 0:1c0a769988ee 65 Thread::State Thread::get_state() {
brunofgc 0:1c0a769988ee 66 #ifndef __MBED_CMSIS_RTOS_CA9
brunofgc 0:1c0a769988ee 67 return ((State)_thread_def.tcb.state);
brunofgc 0:1c0a769988ee 68 #else
brunofgc 0:1c0a769988ee 69 uint8_t status;
brunofgc 0:1c0a769988ee 70 status = osThreadGetState(_tid);
brunofgc 0:1c0a769988ee 71 return ((State)status);
brunofgc 0:1c0a769988ee 72 #endif
brunofgc 0:1c0a769988ee 73 }
brunofgc 0:1c0a769988ee 74
brunofgc 0:1c0a769988ee 75 osEvent Thread::signal_wait(int32_t signals, uint32_t millisec) {
brunofgc 0:1c0a769988ee 76 return osSignalWait(signals, millisec);
brunofgc 0:1c0a769988ee 77 }
brunofgc 0:1c0a769988ee 78
brunofgc 0:1c0a769988ee 79 osStatus Thread::wait(uint32_t millisec) {
brunofgc 0:1c0a769988ee 80 return osDelay(millisec);
brunofgc 0:1c0a769988ee 81 }
brunofgc 0:1c0a769988ee 82
brunofgc 0:1c0a769988ee 83 osStatus Thread::yield() {
brunofgc 0:1c0a769988ee 84 return osThreadYield();
brunofgc 0:1c0a769988ee 85 }
brunofgc 0:1c0a769988ee 86
brunofgc 0:1c0a769988ee 87 osThreadId Thread::gettid() {
brunofgc 0:1c0a769988ee 88 return osThreadGetId();
brunofgc 0:1c0a769988ee 89 }
brunofgc 0:1c0a769988ee 90
brunofgc 0:1c0a769988ee 91 Thread::~Thread() {
brunofgc 0:1c0a769988ee 92 terminate();
brunofgc 0:1c0a769988ee 93 #ifndef __MBED_CMSIS_RTOS_CA9
brunofgc 0:1c0a769988ee 94 if (_dynamic_stack) {
brunofgc 0:1c0a769988ee 95 delete[] (_thread_def.stack_pointer);
brunofgc 0:1c0a769988ee 96 }
brunofgc 0:1c0a769988ee 97 #endif
brunofgc 0:1c0a769988ee 98 }
brunofgc 0:1c0a769988ee 99
brunofgc 0:1c0a769988ee 100 }