CW Decoder (Morse code decoder) 1st release version. Only run on Nucleo-F446RE mbed board.

Dependencies:   Array_Matrix F446_AD_DA ST7565_SPI_LCD TextLCD UIT_FFT_Real

Fork of F446_MySoundMachine by 不韋 呂

Base on F446_MySoundMachine program created by 不韋 呂-san.
Thanks to 不韋 呂-san making fundamental part such as FFT and ADC high speed interrupt driven program.
I just combined LCD and show CW code.

Committer:
MikamiUitOpen
Date:
Sun Jan 29 09:11:30 2017 +0000
Revision:
0:fa74b1130cc3
1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 0:fa74b1130cc3 1 //--------------------------------------------------------------
MikamiUitOpen 0:fa74b1130cc3 2 // 縦続形 IIR フィルタで使う 1D タイプの 2 次のフィルタ
MikamiUitOpen 0:fa74b1130cc3 3 // Biquad filter of 1D type for IIR filter of cascade structure
MikamiUitOpen 0:fa74b1130cc3 4 // このクラスでは,係数は実行中に書き換えられることを想定している
MikamiUitOpen 0:fa74b1130cc3 5 //
MikamiUitOpen 0:fa74b1130cc3 6 // u[n] = x[n] + a1*u[n-1] + a2*u[n-2]
MikamiUitOpen 0:fa74b1130cc3 7 // y[n] = u[n] + b1*u[n-1] + b2*u[n-2]
MikamiUitOpen 0:fa74b1130cc3 8 // x[n] : input signal
MikamiUitOpen 0:fa74b1130cc3 9 // y[n] : output signal
MikamiUitOpen 0:fa74b1130cc3 10 // b0 = 1
MikamiUitOpen 0:fa74b1130cc3 11 //
MikamiUitOpen 0:fa74b1130cc3 12 // 2017/01/26, Copyright (c) 2017 MIKAMI, Naoki
MikamiUitOpen 0:fa74b1130cc3 13 //--------------------------------------------------------------
MikamiUitOpen 0:fa74b1130cc3 14
MikamiUitOpen 0:fa74b1130cc3 15 #ifndef IIR_BIQUAD_HPP
MikamiUitOpen 0:fa74b1130cc3 16 #define IIR_BIQUAD_HPP
MikamiUitOpen 0:fa74b1130cc3 17
MikamiUitOpen 0:fa74b1130cc3 18 #include "mbed.h"
MikamiUitOpen 0:fa74b1130cc3 19
MikamiUitOpen 0:fa74b1130cc3 20 // 2nd order IIR filter
MikamiUitOpen 0:fa74b1130cc3 21 namespace Mikami
MikamiUitOpen 0:fa74b1130cc3 22 {
MikamiUitOpen 0:fa74b1130cc3 23 class Biquad
MikamiUitOpen 0:fa74b1130cc3 24 {
MikamiUitOpen 0:fa74b1130cc3 25 public:
MikamiUitOpen 0:fa74b1130cc3 26 struct Coefs { float a1, a2, b1, b2; };
MikamiUitOpen 0:fa74b1130cc3 27
MikamiUitOpen 0:fa74b1130cc3 28 Biquad(const Coefs ck = (Coefs){0, 0, 0, 0})
MikamiUitOpen 0:fa74b1130cc3 29 {
MikamiUitOpen 0:fa74b1130cc3 30 SetCoefs(ck);
MikamiUitOpen 0:fa74b1130cc3 31 Clear();
MikamiUitOpen 0:fa74b1130cc3 32 }
MikamiUitOpen 0:fa74b1130cc3 33
MikamiUitOpen 0:fa74b1130cc3 34 void SetCoefs(const Coefs cf) { cf_ = cf; }
MikamiUitOpen 0:fa74b1130cc3 35
MikamiUitOpen 0:fa74b1130cc3 36 void GetCoefs(Coefs &cf) { cf = cf_; }
MikamiUitOpen 0:fa74b1130cc3 37
MikamiUitOpen 0:fa74b1130cc3 38 float Execute(float xn)
MikamiUitOpen 0:fa74b1130cc3 39 {
MikamiUitOpen 0:fa74b1130cc3 40 float un = xn + cf_.a1*un1_ + cf_.a2*un2_;
MikamiUitOpen 0:fa74b1130cc3 41 float yn = un + cf_.b1*un1_ + cf_.b2*un2_;
MikamiUitOpen 0:fa74b1130cc3 42
MikamiUitOpen 0:fa74b1130cc3 43 un2_ = un1_;
MikamiUitOpen 0:fa74b1130cc3 44 un1_ = un;
MikamiUitOpen 0:fa74b1130cc3 45
MikamiUitOpen 0:fa74b1130cc3 46 return yn;
MikamiUitOpen 0:fa74b1130cc3 47 }
MikamiUitOpen 0:fa74b1130cc3 48
MikamiUitOpen 0:fa74b1130cc3 49 void Clear() { un1_ = un2_ = 0; }
MikamiUitOpen 0:fa74b1130cc3 50
MikamiUitOpen 0:fa74b1130cc3 51 private:
MikamiUitOpen 0:fa74b1130cc3 52 Coefs cf_;
MikamiUitOpen 0:fa74b1130cc3 53 float un1_, un2_;
MikamiUitOpen 0:fa74b1130cc3 54
MikamiUitOpen 0:fa74b1130cc3 55 // disallow copy constructor and assignment operator
MikamiUitOpen 0:fa74b1130cc3 56 Biquad(const Biquad&);
MikamiUitOpen 0:fa74b1130cc3 57 Biquad& operator=(const Biquad&);
MikamiUitOpen 0:fa74b1130cc3 58 };
MikamiUitOpen 0:fa74b1130cc3 59 }
MikamiUitOpen 0:fa74b1130cc3 60 #endif // IIR_BIQUAD_HPP