SRK Version of mDot LoRa_Sensormode_SRK

Dependencies:   libmDot mbed-rtos mbed

Fork of mDot_LoRa_Sensornode by Adrian Mitevski

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TaskTesla.h Source File

TaskTesla.h

Go to the documentation of this file.
00001 /**
00002  * @file TaskTesla.h
00003  *
00004  * @author Adrian
00005  * @date 01.06.2016
00006  *
00007  */
00008 
00009 #include "MPU9250.h "
00010 #include "MPU9250TeslaMessage.h "
00011 #include "main.h"
00012 
00013 #ifndef APP_TASKTESLA_H_
00014 #define APP_TASKTESLA_H_
00015 
00016 /**
00017  * @class TaskTesla
00018  * @brief This TaskTesla Class handles the tesla measurement using the MPU9250.
00019  * Starting the task using the start() starts the measurement of all axis.
00020  * It can be used alongside with other measurement Tasks inside the mbed::rtos
00021  * environment. The Task Class basically wraps mbeds Thread functionality.
00022  */
00023 class TaskTesla {
00024 public:
00025     TaskTesla(MPU9250*,Mutex*, Queue<MPU9250TeslaMessage,TESLA_QUEUE_LENGHT>*);
00026     TaskTesla(MPU9250*,Mutex*,Queue<MPU9250TeslaMessage,TESLA_QUEUE_LENGHT>*,
00027             osPriority, uint32_t, unsigned char*);
00028     virtual ~TaskTesla();
00029 
00030 
00031     /**
00032      * @brief Starts the task by building it and connecting a callback function to
00033      * the mbed::Thread
00034      * @return
00035      */
00036     osStatus start();
00037 
00038     /**
00039      * @brief Stops the task. Should only be used after start() was used
00040      * @return
00041      */
00042     osStatus stop();
00043 
00044 
00045     /**
00046      * @brief Gets the actual state of the Task either RUNNING or SLEEPING
00047      * @return
00048      */
00049     TASK_STATE getState();
00050 
00051 private:
00052     rtos::Thread* thread;
00053     rtos::Queue<MPU9250TeslaMessage,TESLA_QUEUE_LENGHT>* queue;
00054     rtos::Mutex* mutexI2C ;
00055     osPriority priority;
00056     uint32_t stack_size;
00057     unsigned char *stack_pointer;
00058 
00059     TASK_STATE state;
00060 
00061     MPU9250* mpu9250;
00062 
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 Teslas of each axis. After the measurement
00072      * it stores the data inside a MPU9250TelsaMessage
00073      */
00074     void measureTesla();
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 queueTesla the queue where the MPU9250TeslaMessage will be stored
00081      */
00082     void setQueue(Queue<MPU9250TeslaMessage,TESLA_QUEUE_LENGHT>*queueTesla);
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 /* APP_TASKTESLA_H_ */