SRK Version of mDot LoRa_Sensormode_SRK
Dependencies: libmDot mbed-rtos mbed
Fork of mDot_LoRa_Sensornode by
TaskLight.h
00001 /** 00002 * @file TaskLight.h 00003 * 00004 * @author Adrian 00005 * @date 27.05.2016 00006 * 00007 */ 00008 00009 #include <Thread.h> 00010 #include <Queue.h> 00011 #include <Mutex.h> 00012 #include "MAX44009.h " 00013 #include "MAX44009Message.h " 00014 #include "main.h" 00015 00016 #ifndef TASKLIGHT_H_ 00017 #define TASKLIGHT_H_ 00018 00019 /** 00020 * @class TaskLight 00021 * @brief This TaskLight Class handles the light measurement using the MAX44009. 00022 * Starting the task using the start() starts the measurement. 00023 * It can be used alongside with other measurement Tasks inside the mbed::rtos 00024 * environment. The Task Class basically wraps mbeds Thread functionality. 00025 */ 00026 class TaskLight{ 00027 public: 00028 TaskLight(MAX44009*,Mutex*, Queue<MAX44009Message,LIGHT_QUEUE_LENGHT>*); 00029 TaskLight(MAX44009*,Mutex*,Queue<MAX44009Message,LIGHT_QUEUE_LENGHT>*, 00030 osPriority, uint32_t, unsigned char*); 00031 virtual ~TaskLight(); 00032 00033 /** 00034 * Starts the task by building and its measurement 00035 * @return 00036 */ 00037 osStatus start(); 00038 00039 /** 00040 * Stops the task. Should only be used after start() was used 00041 * @return 00042 */ 00043 osStatus stop(); 00044 00045 00046 /** 00047 * Gets the actual state of the Task either RUNNING or SLEEPING 00048 * @return 00049 */ 00050 TASK_STATE getState(); 00051 00052 private: 00053 rtos::Thread* thread; 00054 rtos::Queue<MAX44009Message,LIGHT_QUEUE_LENGHT>* queue; 00055 rtos::Mutex* mutexI2C ; 00056 osPriority priority; 00057 uint32_t stack_size; 00058 unsigned char *stack_pointer; 00059 00060 TASK_STATE state; 00061 00062 MAX44009* max44009; 00063 00064 /** 00065 * @brief A Callback function thats called by the mbed::Thread of this TaskClass 00066 * @param 00067 */ 00068 static void callBack(void const *); 00069 00070 /** 00071 * @brief A thread safe method that measures the light. After measuring the light 00072 * it stores the value inside a MAX44009Message 00073 */ 00074 void measureLight(); 00075 00076 00077 /** 00078 * @brief Sets the message Queue of the Task where the measured values will be stored 00079 * after the measurement 00080 * @param queueLight the queue where the MAX44009Message will be stored 00081 */ 00082 void setQueue(Queue<MAX44009Message,LIGHT_QUEUE_LENGHT>* queueLight); 00083 00084 /** 00085 * @brief Sets the mutex thats used for a thread safe measurement 00086 * @param mutexI2C the I2C mutex 00087 */ 00088 void setMutex(Mutex* mutexI2C); 00089 00090 /** 00091 * @brief Sets the priority of the Task 00092 * @param priority priority of the Task 00093 */ 00094 void setPriority(osPriority priority); 00095 00096 /** 00097 * @brief Sets the size of the Task 00098 * @param stackSize the stack size in Bytes 00099 */ 00100 void setStackSize(uint32_t stackSize); 00101 00102 /** 00103 * @brief Sets the stack pointer of for the task stack 00104 * @param stackPointer 00105 */ 00106 void setStackPointer(unsigned char* stackPointer); 00107 00108 /** 00109 * @brief Sets the actual state of the Task. 00110 * @param taskState either RUNNING or SLEEPING 00111 */ 00112 void setState(TASK_STATE taskState); 00113 00114 }; 00115 #endif /* TASKLIGHT_H_ */
Generated on Wed Jul 13 2022 09:23:48 by 1.7.2