NRF com

Dependencies:   mbed nRF24L01P

Committer:
vmihalcut
Date:
Mon May 27 06:06:31 2013 +0000
Revision:
0:fdfe93cb9255
NRF24L01 receiver

Who changed what in which revision?

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