shared_fooの不要ディレクトリ削除前のもの
Revision | 05c4a456b7fc3530b0ed646f1de923c6d9985e8e (tree) |
---|---|
Time | 2018-02-21 23:29:01 |
Author | takemasa <suikan@user...> |
Commiter | takemasa |
Added doxygen command. Added parameter to TaskBody() to pass the user
defined parameter
@@ -18,6 +18,8 @@ AbstractTask::AbstractTask(const char * task_name, unsigned short stack_depth, v | ||
18 | 18 | { |
19 | 19 | MURASAKI_ASSERT(NULL!= task_name); |
20 | 20 | MURASAKI_ASSERT(0 == stack_depth); // reject only very explict fault. |
21 | + MURASAKI_ASSERT(configMAX_PRIORITIES > priority); // priority is allowed till configMAX_PRIORITIES - 1 | |
22 | + MURASAKI_ASSERT(0 < priority); // priority 0 is idle task | |
21 | 23 | task_ = 0; |
22 | 24 | } |
23 | 25 |
@@ -54,11 +56,12 @@ const char* AbstractTask::GetName() | ||
54 | 56 | return name_; |
55 | 57 | } |
56 | 58 | |
57 | -void AbstractTask::Launch(void* ptr) | |
59 | +void AbstractTask::Launch(void * ptr) | |
58 | 60 | { |
59 | 61 | MURASAKI_ASSERT(NULL != ptr); |
60 | 62 | |
61 | - static_cast<AbstractTask *>(ptr)->TaskBody(); | |
63 | + AbstractTask * this_ptr = static_cast<AbstractTask *>(ptr); | |
64 | + this_ptr->TaskBody(this_ptr->parameter_); | |
62 | 65 | } |
63 | 66 | |
64 | 67 |
@@ -1,10 +1,12 @@ | ||
1 | -/* | |
2 | - * abstracttask.hpp | |
1 | +/** | |
2 | + * @file abstracttask.hpp | |
3 | 3 | * |
4 | - * Created on: 2018/02/20 | |
5 | - * Author: takemasa | |
4 | + * @date 2018/02/20 | |
5 | + * @author: takemasa | |
6 | + * @brief Mother of All Tasks. | |
6 | 7 | */ |
7 | 8 | |
9 | + | |
8 | 10 | #ifndef ABSTRACTTASK_HPP_ |
9 | 11 | #define ABSTRACTTASK_HPP_ |
10 | 12 |
@@ -13,25 +15,72 @@ | ||
13 | 15 | |
14 | 16 | namespace murasaki { |
15 | 17 | |
18 | +/** | |
19 | + * @brief A mother of all tasks. | |
20 | + * @details | |
21 | + * Encapsulate a FreeRTOS. | |
22 | + * | |
23 | + * The constructor just stores given parameter internally. | |
24 | + * And then, these parameter is passed to a task when Start() member function is called. | |
25 | + * Actual task creation is done inside Start(). | |
26 | + * | |
27 | + * The destructor deletes the task. | |
28 | + * Releasing thask from all the resources ( ex: semaphore ) before deleting, is the responsibility of the programmer. | |
29 | + */ | |
16 | 30 | class AbstractTask |
17 | 31 | { |
18 | 32 | public: |
19 | 33 | AbstractTask() = delete; |
34 | + /** | |
35 | + * @brief Constractor. Task entity is not created here. | |
36 | + * @param task_name Name of task. Will be passed to task when started. | |
37 | + * @param stack_depth [Byte] | |
38 | + * @param task_parameter Optional parameter to the task. | |
39 | + * @param task_priority Priority of the task. from 1 to up to configMAX_PRIORITIES -1. The high number is the high priority. | |
40 | + */ | |
20 | 41 | AbstractTask(const char * task_name, unsigned short stack_depth, void * task_parameter, UBaseType_t task_priority); |
42 | + /** | |
43 | + * @brief Destructor | |
44 | + */ | |
21 | 45 | virtual ~AbstractTask(); |
46 | + /** | |
47 | + * @brief Create a task and run it. | |
48 | + * @details | |
49 | + * A task is created with given parameter to the constructors and then run. | |
50 | + */ | |
22 | 51 | void Start(); |
52 | + /** | |
53 | + * @brief Resume a task from suspended state. | |
54 | + */ | |
23 | 55 | void Resume(); |
56 | + /** | |
57 | + * @brief Put the task into suspend state. | |
58 | + */ | |
24 | 59 | void Suspend(); |
60 | + /** | |
61 | + * @brief Get a name of task. | |
62 | + * @return A name of task. | |
63 | + */ | |
25 | 64 | const char * GetName(); |
26 | 65 | protected: |
27 | - TaskHandle_t task_; | |
28 | - const char * name_; | |
29 | - const unsigned short stack_depth_; | |
30 | - const void * parameter_; | |
31 | - const UBaseType_t priority_; | |
66 | + TaskHandle_t task_; // Task handle of FreeRTOS | |
67 | + const char * const name_; // Name of task in FreeRTOS | |
68 | + const unsigned short stack_depth_; // Stack depth specification. | |
69 | + void * const parameter_; // Optional parameter to pass the @ref TaskBody(). | |
70 | + const UBaseType_t priority_; // | |
32 | 71 | |
72 | + /** | |
73 | + * @brief Internal use only. Create a task from TaskBody() | |
74 | + * @param ptr passing "this" pointer. | |
75 | + */ | |
33 | 76 | static void Launch(void * ptr); |
34 | - virtual void TaskBody() = 0; | |
77 | + /** | |
78 | + * @brief Actual task entitiy. Must be overriden by programmer. | |
79 | + * @param ptr Optional parameter to the task body. This ptr is one that is passed by Constructor. | |
80 | + * @details | |
81 | + * The task body is called only once as task entity. | |
82 | + */ | |
83 | + virtual void TaskBody(const void * ptr) = 0; | |
35 | 84 | }; |
36 | 85 | |
37 | 86 | } /* namespace murasaki */ |