テスト用のあれこれ共用フォルダ
修訂 | ef85bc597e2d1b59d8da72d6388191e531646211 (tree) |
---|---|
時間 | 2018-03-03 09:09:56 |
作者 | takemasa <suikan@user...> |
Commiter | takemasa |
AbstractFifo tested
@@ -19,14 +19,16 @@ | ||
19 | 19 | murasaki::Platform murasaki::platform; |
20 | 20 | murasaki::Debugger * murasaki::debugger; |
21 | 21 | |
22 | +#define MSG1 "A quick brown fox jumps over the lazy dog." | |
23 | + | |
22 | 24 | static int counter; |
25 | +static murasaki::AbstractFifo * test_fifo; | |
23 | 26 | |
24 | 27 | // Initialize the platfrom variables. This have to be doen before |
25 | 28 | // using other murasaki funciton. |
26 | 29 | void InitTestUart(UART_HandleTypeDef * uart_handle, SPI_HandleTypeDef * spi_handle) |
27 | 30 | { |
28 | 31 | counter = 0; |
29 | - | |
30 | 32 | // UART device setting |
31 | 33 | murasaki::platform.uart_console = new murasaki::Uart(uart_handle); |
32 | 34 | // UART is used for logging port. |
@@ -55,6 +57,12 @@ void InitTestUart(UART_HandleTypeDef * uart_handle, SPI_HandleTypeDef * spi_hand | ||
55 | 57 | // Setting debugger |
56 | 58 | murasaki::debugger = new murasaki::Debugger(murasaki::platform.logger); |
57 | 59 | murasaki::debugger->AutoHistory(); // type any key to show history. |
60 | + | |
61 | + test_fifo = new murasaki::AbstractFifo(32); | |
62 | + MURASAKI_ASSERT(test_fifo != nullptr); | |
63 | + | |
64 | + unsigned int copied = test_fifo->Put(reinterpret_cast<const uint8_t *>(MSG1), sizeof(MSG1)); | |
65 | + murasaki::debugger->printf("FIFO.Put(), %d data taransfered\n\r", copied); | |
58 | 66 | } |
59 | 67 | |
60 | 68 | uint8_t tx_buffer[1] = { 0x55 }, rx_buffer[1]; |
@@ -62,13 +70,24 @@ uint8_t tx_buffer[1] = { 0x55 }, rx_buffer[1]; | ||
62 | 70 | void DoTestUart(void) |
63 | 71 | { |
64 | 72 | // MURASAKI_ASSERT(counter % 2 == 0, "Odd counter"); |
65 | - | |
73 | +#if 0 | |
66 | 74 | murasaki::platform.spi_master->Transfer(murasaki::platform.slave_1, tx_buffer, rx_buffer, 1); |
67 | - | |
75 | +#endif | |
76 | + | |
77 | + char data[10]; | |
78 | + unsigned int copied = test_fifo->Get(reinterpret_cast<uint8_t *>(data), sizeof(data)); | |
79 | + if (copied == 0) | |
80 | + { | |
81 | + murasaki::debugger->printf("FIFO.Get(), %d data taransfered \n\r", copied); | |
82 | + test_fifo->ReWind(); | |
83 | + } | |
84 | + else { | |
85 | + murasaki::debugger->printf("FIFO.Get(), %d data taransfered : '%10s'\n\r", copied, data); | |
86 | + } | |
68 | 87 | |
69 | 88 | // by murasaki debugging output. You can use this in both task and interrupt context. |
70 | 89 | // non blocking |
71 | - murasaki::debugger->printf(MSG, counter); | |
90 | +// murasaki::debugger->printf(MSG, counter); | |
72 | 91 | |
73 | 92 | } |
74 | 93 |
@@ -91,7 +91,7 @@ unsigned int AbstractFifo::Get(uint8_t data[], unsigned int size) | ||
91 | 91 | |
92 | 92 | // if tail_ reaches the end, wrap around. |
93 | 93 | if (tail_ >= size_of_buffer_) |
94 | - head_ -= size_of_buffer_; | |
94 | + tail_ -= size_of_buffer_; | |
95 | 95 | } |
96 | 96 | |
97 | 97 |
@@ -105,7 +105,7 @@ void AbstractFifo::ReWind() | ||
105 | 105 | |
106 | 106 | // wrap arround; |
107 | 107 | if (tail_ >= size_of_buffer_) |
108 | - head_ -= size_of_buffer_; | |
108 | + tail_ -= size_of_buffer_; | |
109 | 109 | } |
110 | 110 | |
111 | 111 | } /* namespace murasaki */ |
@@ -32,6 +32,7 @@ | ||
32 | 32 | #include "murasaki_defs.hpp" |
33 | 33 | |
34 | 34 | #include "abstracttask.hpp" |
35 | +#include "abstractfifo.hpp" | |
35 | 36 | |
36 | 37 | #include "uart.hpp" |
37 | 38 | #include "spimaster.hpp" |