Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Mseq.h
- Revision:
- 0:3e4357746fe2
diff -r 000000000000 -r 3e4357746fe2 Mseq.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Mseq.h	Thu Mar 28 07:14:57 2019 +0000
@@ -0,0 +1,33 @@
+#ifndef MSEQ_H
+#define MSEQ_H
+
+#include "mbed.h"
+
+/**
+ * @brief M-sequence (maximum length sequence) generator
+ */
+class Mseq
+{
+private:
+    //! シフトレジスタのビット数
+    uint8_t n;
+    
+    //! シフトレジスタ本体
+    //! reg[0](LSB)が出力
+    //! reg[n](MSB)がフィードバック先
+    //! 更新時にはregが右に1bitずつしふとされていく
+    uint32_t reg;
+    
+    //! regの更新時にfeedbackするbitの位置
+    uint32_t coef;
+    
+public:
+    Mseq(uint8_t _n);
+    void reset();
+    void reset(uint8_t _n);
+    uint8_t update();
+    uint8_t getOutput() const;
+    uint32_t getRegister() const;
+};
+
+#endif
\ No newline at end of file