shared_fooの不要ディレクトリ削除前のもの
Revision | 5bc4a729112383c7e15a3c1219f9cfca8f1ab853 (tree) |
---|---|
Time | 2018-03-01 07:58:48 |
Author | takemasa <suikan@user...> |
Commiter | takemasa |
Added new classes
@@ -12,8 +12,8 @@ | ||
12 | 12 | <targetDefinitions> |
13 | 13 | <board id="nucleo-f746zg"> |
14 | 14 | <name>NUCLEO-F746ZG</name> |
15 | - <dbgIF>JTAG</dbgIF> | |
16 | 15 | <dbgIF>SWD</dbgIF> |
16 | + <dbgIF>JTAG</dbgIF> | |
17 | 17 | <dbgDEV>ST-Link</dbgDEV> |
18 | 18 | <mcuId>stm32f746zgtx</mcuId> |
19 | 19 | </board> |
@@ -23,7 +23,7 @@ namespace murasaki { | ||
23 | 23 | * |
24 | 24 | * The Get member funciton returns with "copied" data count and data. |
25 | 25 | * If the internal buffer is empty, it returns without copy data. |
26 | - * | |
26 | + * @ingroup MURASAKI_ABSTRACT_GROUP | |
27 | 27 | */ |
28 | 28 | class AbstractFifo |
29 | 29 | { |
@@ -46,18 +46,18 @@ class AbstractFifo | ||
46 | 46 | * @param size Data count to be copied |
47 | 47 | * @return The count of copied data. 0, if the internal buffer is full. |
48 | 48 | */ |
49 | - unsigned int Put(uint8_t const data[], unsigned int size); | |
49 | + virtual unsigned int Put(uint8_t const data[], unsigned int size); | |
50 | 50 | /** |
51 | 51 | * @brief Get the data from the internal buffer. |
52 | 52 | * @param data Data buffer to receive from the internal buffer |
53 | 53 | * @param size Size of the data parameter. |
54 | 54 | * @return The count of copied data. 0, if the internal buffer is empty |
55 | 55 | */ |
56 | - unsigned int Get(uint8_t data[], unsigned int size); | |
56 | + virtual unsigned int Get(uint8_t data[], unsigned int size); | |
57 | 57 | /* |
58 | 58 | * @brief Mark all the data inside the internal buffer as "not sent". |
59 | 59 | */ |
60 | - void ReWind(); | |
60 | + virtual void ReWind(); | |
61 | 61 | private: |
62 | 62 | /** |
63 | 63 | * @brief The index of where next data will be written. |
@@ -71,7 +71,7 @@ void Debugger::printf(const char * fmt, ...) | ||
71 | 71 | |
72 | 72 | MURASAKI_ASSERT(nullptr != fmt); // nullptr check. Perhaps, overkill. |
73 | 73 | |
74 | - ::portDISABLE_INTERRUPTS(); // ARM dependent API. OK to use in task and ISR. | |
74 | + portDISABLE_INTERRUPTS(); // ARM dependent API. OK to use in task and ISR. | |
75 | 75 | { |
76 | 76 | #if 0 |
77 | 77 | // Test the remains of task stack in byte. |
@@ -94,7 +94,7 @@ void Debugger::printf(const char * fmt, ...) | ||
94 | 94 | // Append the line to the buffer to be sent. |
95 | 95 | AppendToBuffer(); |
96 | 96 | } |
97 | - ::portENABLE_INTERRUPTS(); | |
97 | + portENABLE_INTERRUPTS(); | |
98 | 98 | |
99 | 99 | // Notify to the consumer task, the new data has come. |
100 | 100 | if (isTaskContext()) // Are we in the task context? |
@@ -157,7 +157,7 @@ void Debugger::RePrint() | ||
157 | 157 | { |
158 | 158 | MURASAKI_ASSERT(isTaskContext()); |
159 | 159 | |
160 | - ::taskENTER_CRITICAL(); | |
160 | + taskENTER_CRITICAL(); | |
161 | 161 | { |
162 | 162 | // Mark the all old data as "not sent" |
163 | 163 | // By setting the circular buffer length maximumn. |
@@ -166,7 +166,7 @@ void Debugger::RePrint() | ||
166 | 166 | if (tail_ >= sizeof(buffer_)) |
167 | 167 | tail_ = 0; |
168 | 168 | } |
169 | - ::taskEXIT_CRITICAL(); | |
169 | + taskEXIT_CRITICAL(); | |
170 | 170 | |
171 | 171 | // tell there is data |
172 | 172 | ::xSemaphoreGive(sem_notify_new_data_); |
@@ -239,7 +239,7 @@ void Debugger::TxTask() | ||
239 | 239 | while (true) { |
240 | 240 | // To avoid race condition, Take a snapshot of the head_ and tail_ pointer. |
241 | 241 | // head_ could be modified during this task is running but no problem. |
242 | - ::taskENTER_CRITICAL(); | |
242 | + taskENTER_CRITICAL(); | |
243 | 243 | { |
244 | 244 | // check whether the data area is wrapped araound at the end of buffer. Note : Data is added to the head. |
245 | 245 | if (head_ > tail_) { // not wrapped around |
@@ -264,7 +264,7 @@ void Debugger::TxTask() | ||
264 | 264 | // head_ == tail_ . Do nothing. |
265 | 265 | copy_size = 0; |
266 | 266 | } |
267 | - ::taskEXIT_CRITICAL(); | |
267 | + taskEXIT_CRITICAL(); | |
268 | 268 | |
269 | 269 | if (copy_size != 0) // if copied |
270 | 270 | logger_->putMessage((char *) block, copy_size); |
@@ -0,0 +1,74 @@ | ||
1 | +/* | |
2 | + * debuggerfifo.cpp | |
3 | + * | |
4 | + * Created on: 2018/03/01 | |
5 | + * Author: takemasa | |
6 | + */ | |
7 | + | |
8 | +#include <FreeRTOS.h> | |
9 | +#include <task.h> | |
10 | +#include <semphr.h> | |
11 | + | |
12 | +#include "murasaki_defs.hpp" | |
13 | +#include <debuggerfifo.hpp> | |
14 | +#include "murasaki_assert.hpp" | |
15 | + | |
16 | +namespace murasaki { | |
17 | + | |
18 | + | |
19 | +DebuggerFifo::DebuggerFifo(unsigned int buffer_size) | |
20 | + : AbstractFifo(buffer_size), | |
21 | + sync_(new Synchronizer()) | |
22 | +{ | |
23 | + MURASAKI_ASSERT(sync_ != nullptr); | |
24 | +} | |
25 | + | |
26 | +DebuggerFifo::~DebuggerFifo() | |
27 | +{ | |
28 | + if (sync_ != nullptr) | |
29 | + delete sync_; | |
30 | +} | |
31 | + | |
32 | +unsigned int DebuggerFifo::Put(const uint8_t data[], unsigned int size) | |
33 | +{ | |
34 | + unsigned int ret_val; | |
35 | + | |
36 | + portDISABLE_INTERRUPTS(); | |
37 | + { | |
38 | + ret_val = inherited::Put(data, size); | |
39 | + } | |
40 | + portENABLE_INTERRUPTS(); | |
41 | + | |
42 | + sync_->ReleaseTask(); | |
43 | + | |
44 | + return ret_val; | |
45 | +} | |
46 | + | |
47 | +unsigned int DebuggerFifo::Get(uint8_t data[], unsigned int size) | |
48 | +{ | |
49 | + MURASAKI_ASSERT(murasaki::isTaskContext()) | |
50 | + unsigned int ret_val; | |
51 | + | |
52 | + taskENTER_CRITICAL(); | |
53 | + { | |
54 | + ret_val = inherited::Get(data, size); | |
55 | + } | |
56 | + taskEXIT_CRITICAL(); | |
57 | + | |
58 | + if ( ret_val == 0) | |
59 | + sync_->WaitForSignalFromTask(); | |
60 | + | |
61 | + return ret_val; | |
62 | + | |
63 | +} | |
64 | + | |
65 | +void DebuggerFifo::ReWind() | |
66 | +{ | |
67 | + portDISABLE_INTERRUPTS(); | |
68 | + { | |
69 | + inherited::ReWind(); | |
70 | + } | |
71 | + portENABLE_INTERRUPTS(); | |
72 | +} | |
73 | + | |
74 | +} /* namespace murasaki */ |
@@ -0,0 +1,56 @@ | ||
1 | +/* | |
2 | + * debuggerfifo.hpp | |
3 | + * | |
4 | + * Created on: 2018/03/01 | |
5 | + * Author: takemasa | |
6 | + */ | |
7 | + | |
8 | +#ifndef DEBUGGERFIFO_HPP_ | |
9 | +#define DEBUGGERFIFO_HPP_ | |
10 | + | |
11 | +#include <abstractfifo.hpp> | |
12 | +#include "synchronizer.hpp" | |
13 | + | |
14 | +namespace murasaki { | |
15 | + | |
16 | +class DebuggerFifo : public AbstractFifo | |
17 | +{ | |
18 | + public: | |
19 | + /** | |
20 | + * @brief Create an internal buffer | |
21 | + * @param buffer_size Size of the internal buffer to be allocated [byte] | |
22 | + * @details | |
23 | + * Allocate the internal buffer with given buffer_size. | |
24 | + */ | |
25 | + DebuggerFifo(unsigned int buffer_size); | |
26 | + /** | |
27 | + * @brief Delete an internal buffer | |
28 | + */ | |
29 | + virtual ~DebuggerFifo(); | |
30 | + /** | |
31 | + * @brief Put the data into the internal buffer. | |
32 | + * @param data Data to be copied to the internal buffer | |
33 | + * @param size Data count to be copied | |
34 | + * @return The count of copied data. 0, if the internal buffer is full. | |
35 | + */ | |
36 | + virtual unsigned int Put(uint8_t const data[], unsigned int size); | |
37 | + /** | |
38 | + * @brief Get the data from the internal buffer. | |
39 | + * @param data Data buffer to receive from the internal buffer | |
40 | + * @param size Size of the data parameter. | |
41 | + * @return The count of copied data. 0, if the internal buffer is empty | |
42 | + */ | |
43 | + virtual unsigned int Get(uint8_t data[], unsigned int size); | |
44 | + /* | |
45 | + * @brief Mark all the data inside the internal buffer as "not sent". | |
46 | + */ | |
47 | + virtual void ReWind(); | |
48 | + private: | |
49 | + typedef AbstractFifo inherited; | |
50 | + Synchronizer * const sync_; | |
51 | + | |
52 | +}; | |
53 | + | |
54 | +} /* namespace murasaki */ | |
55 | + | |
56 | +#endif /* DEBUGGERFIFO_HPP_ */ |