FFT によるスペクトル解析器

Dependencies:   Array_Matrix mbed SerialTxRxIntr UIT_FFT_Real DSP_ADDA

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MSeq16.hpp Source File

MSeq16.hpp

00001 //---------------------------------------------------------
00002 //  M 系列信号発生器(N = 16)
00003 //
00004 //  2020/10/17, Copyright (c) 2020 MIKAMI, Naoki
00005 //---------------------------------------------------------
00006 
00007 #include "mbed.h"
00008 
00009 #ifndef MSEQ16_HPP
00010 #define MSEQ16_HPP
00011 
00012 namespace Mikami
00013 {
00014     class MSeq16
00015     {
00016     public:
00017         MSeq16() : reg_(1) {}
00018 
00019         // 戻り値: 1 => 1, 0 => -1
00020         int Execute()
00021         {
00022             if ((reg_ & B_M_) == B_M_)
00023             {
00024                 reg_ = ((reg_ ^ XOR_) << 1) | 1;    // 1 の場合の処理
00025                 return 1;
00026             }
00027             else
00028             {
00029                 reg_ = reg_ << 1;                   // 0 の場合の処理
00030                 return -1;
00031             }
00032         }
00033     private:
00034         static const uint16_t XOR_ = (1 << (2-1))
00035                                    | (1 << (3-1))
00036                                    | (1 << (5-1));  // XOR の位置に対応する定数
00037         static const uint16_t B_M_ = 1 << (16-1);   // 16 段目に相当するビットを調べる
00038         
00039         uint16_t reg_;
00040     };
00041 }
00042 #endif  // MSEQ16_HPP