• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

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

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


Commit MetaInfo

修订版36a744c12ea00a90b1ccf8e169d76a1d6edcb11a (tree)
时间2018-02-28 22:19:13
作者takemasa <suikan@user...>
Commitertakemasa

Log Message

Correct initialize processing.

更改概述

差异

--- a/stm32_development/murasaki/murasaki/basefifo.cpp
+++ b/stm32_development/murasaki/murasaki/basefifo.cpp
@@ -19,6 +19,13 @@ BaseFifo::BaseFifo(unsigned int buffer_size):
1919 MURASAKI_ASSERT(size_of_buffer_ != 0); // very explicit check
2020 MURASAKI_ASSERT(buffer_ != nullptr);
2121
22+ // set both pointer same value ( empty buffer ).
23+ tail_ = head_ = 0;
24+
25+ // Clean up buffer.
26+ // This is essential to outptu clear data when ReWind() is called at very initial stage.
27+ ::memset(buffer_, ' ', size_of_buffer_);
28+
2229 }
2330
2431
@@ -58,7 +65,7 @@ unsigned int BaseFifo::Put(uint8_t const data[], unsigned int size)
5865
5966 // wrap around the head index;
6067 if (head_ >= size_of_buffer_)
61- head_ = 0;
68+ head_ -= size_of_buffer_;
6269 } // end for loop.
6370
6471 return copy_size;
@@ -89,7 +96,7 @@ unsigned int BaseFifo::Get(uint8_t data[], unsigned int size)
8996
9097 // if tail_ reaches the end, wrap around.
9198 if (tail_ >= size_of_buffer_)
92- tail_ = 0;
99+ head_ -= size_of_buffer_;
93100 }
94101
95102
@@ -103,7 +110,7 @@ void BaseFifo::ReWind()
103110
104111 // wrap arround;
105112 if (tail_ >= size_of_buffer_)
106- tail_ = 0;
113+ head_ -= size_of_buffer_;
107114 }
108115
109116 } /* namespace murasaki */