• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

テスト用のあれこれ共用フォルダ


Commit MetaInfo

修訂ef85bc597e2d1b59d8da72d6388191e531646211 (tree)
時間2018-03-03 09:09:56
作者takemasa <suikan@user...>
Commitertakemasa

Log Message

AbstractFifo tested

Change Summary

差異

--- a/stm32_development/murasaki/Src/my_test.cpp
+++ b/stm32_development/murasaki/Src/my_test.cpp
@@ -19,14 +19,16 @@
1919 murasaki::Platform murasaki::platform;
2020 murasaki::Debugger * murasaki::debugger;
2121
22+#define MSG1 "A quick brown fox jumps over the lazy dog."
23+
2224 static int counter;
25+static murasaki::AbstractFifo * test_fifo;
2326
2427 // Initialize the platfrom variables. This have to be doen before
2528 // using other murasaki funciton.
2629 void InitTestUart(UART_HandleTypeDef * uart_handle, SPI_HandleTypeDef * spi_handle)
2730 {
2831 counter = 0;
29-
3032 // UART device setting
3133 murasaki::platform.uart_console = new murasaki::Uart(uart_handle);
3234 // UART is used for logging port.
@@ -55,6 +57,12 @@ void InitTestUart(UART_HandleTypeDef * uart_handle, SPI_HandleTypeDef * spi_hand
5557 // Setting debugger
5658 murasaki::debugger = new murasaki::Debugger(murasaki::platform.logger);
5759 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);
5866 }
5967
6068 uint8_t tx_buffer[1] = { 0x55 }, rx_buffer[1];
@@ -62,13 +70,24 @@ uint8_t tx_buffer[1] = { 0x55 }, rx_buffer[1];
6270 void DoTestUart(void)
6371 {
6472 // MURASAKI_ASSERT(counter % 2 == 0, "Odd counter");
65-
73+#if 0
6674 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+ }
6887
6988 // by murasaki debugging output. You can use this in both task and interrupt context.
7089 // non blocking
71- murasaki::debugger->printf(MSG, counter);
90+// murasaki::debugger->printf(MSG, counter);
7291
7392 }
7493
--- a/stm32_development/murasaki/murasaki/abstractfifo.cpp
+++ b/stm32_development/murasaki/murasaki/abstractfifo.cpp
@@ -91,7 +91,7 @@ unsigned int AbstractFifo::Get(uint8_t data[], unsigned int size)
9191
9292 // if tail_ reaches the end, wrap around.
9393 if (tail_ >= size_of_buffer_)
94- head_ -= size_of_buffer_;
94+ tail_ -= size_of_buffer_;
9595 }
9696
9797
@@ -105,7 +105,7 @@ void AbstractFifo::ReWind()
105105
106106 // wrap arround;
107107 if (tail_ >= size_of_buffer_)
108- head_ -= size_of_buffer_;
108+ tail_ -= size_of_buffer_;
109109 }
110110
111111 } /* namespace murasaki */
--- a/stm32_development/murasaki/murasaki/murasaki.hpp
+++ b/stm32_development/murasaki/murasaki/murasaki.hpp
@@ -32,6 +32,7 @@
3232 #include "murasaki_defs.hpp"
3333
3434 #include "abstracttask.hpp"
35+#include "abstractfifo.hpp"
3536
3637 #include "uart.hpp"
3738 #include "spimaster.hpp"