diff --git a/firmware/baseband/proc_ais.cpp b/firmware/baseband/proc_ais.cpp index 7cb0f3cb..3db550ad 100644 --- a/firmware/baseband/proc_ais.cpp +++ b/firmware/baseband/proc_ais.cpp @@ -26,10 +26,24 @@ #include "i2s.hpp" using namespace lpc43xx; +#include "dsp_fir_taps.hpp" + +AISProcessor::AISProcessor() { + decim_0.configure(taps_11k0_decim_0.taps, 33554432); + decim_1.configure(taps_11k0_decim_1.taps, 131072); +} + void AISProcessor::execute(const buffer_c8_t& buffer) { /* 2.4576MHz, 2048 samples */ - auto decimator_out = decimator.execute(buffer); + const buffer_c16_t dst_buffer { + dst.data(), + dst.size() + }; + + const auto decim_0_out = decim_0.execute(buffer, dst_buffer); + const auto decim_1_out = decim_1.execute(decim_0_out, dst_buffer); + const auto decimator_out = decim_1_out; /* 76.8kHz, 64 samples */ feed_channel_stats(decimator_out); diff --git a/firmware/baseband/proc_ais.hpp b/firmware/baseband/proc_ais.hpp index 16bf42b4..59812efb 100644 --- a/firmware/baseband/proc_ais.hpp +++ b/firmware/baseband/proc_ais.hpp @@ -42,11 +42,15 @@ class AISProcessor : public BasebandProcessor { public: + AISProcessor(); + void execute(const buffer_c8_t& buffer) override; private: - ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By32 }; - dsp::matched_filter::MatchedFilter mf { baseband::ais::rrc_taps_76k8_4t_p, 4 }; + std::array dst; + dsp::decimate::FIRC8xR16x24FS4Decim8 decim_0; + dsp::decimate::FIRC16xR16x32Decim8 decim_1; + dsp::matched_filter::MatchedFilter mf { baseband::ais::rrc_taps_38k4_4t_p, 2 }; clock_recovery::ClockRecovery clock_recovery { 19200, 9600, { 0.0555f }, diff --git a/firmware/common/ais_baseband.hpp b/firmware/common/ais_baseband.hpp index c693d610..1d7a2aa6 100644 --- a/firmware/common/ais_baseband.hpp +++ b/firmware/common/ais_baseband.hpp @@ -36,25 +36,17 @@ namespace ais { // cleaning up ISI. // Translate+RRC filter -// sample=76.8k, deviation=2400, b=0.5, symbol=9600 -// Length: 32 taps, 4 symbols, 1 cycle of sinusoid -constexpr std::array, 32> rrc_taps_76k8_4t_p { { - { 5.3368736990e-03f, 0.0000000000e+00f }, { 4.6850211151e-03f, 9.3190864122e-04f }, - { 1.7970187432e-03f, 7.4434953528e-04f }, { -2.5478608559e-03f, -1.7024261963e-03f }, - { -6.6710920858e-03f, -6.6710920858e-03f }, { -8.6960320791e-03f, -1.3014531722e-02f }, - { -7.5474785839e-03f, -1.8221225159e-02f }, { -3.8115552023e-03f, -1.9161981995e-02f }, - { -8.1697309033e-19f, -1.3342183083e-02f }, { 3.6940784220e-05f, -1.8571386338e-04f }, - { -7.5474785839e-03f, 1.8221225159e-02f }, { -2.4954265902e-02f, 3.7346698152e-02f }, - { -5.1450054092e-02f, 5.1450054092e-02f }, { -8.3018814119e-02f, 5.5471398140e-02f }, - { -1.1321218147e-01f, 4.6894020990e-02f }, { -1.3498960022e-01f, 2.6851100952e-02f }, - { -1.4292666316e-01f, 1.7503468055e-17f }, { -1.3498960022e-01f, -2.6851100952e-02f }, - { -1.1321218147e-01f, -4.6894020990e-02f }, { -8.3018814119e-02f, -5.5471398140e-02f }, - { -5.1450054092e-02f, -5.1450054092e-02f }, { -2.4954265902e-02f, -3.7346698152e-02f }, - { -7.5474785839e-03f, -1.8221225159e-02f }, { 3.6940784220e-05f, 1.8571386338e-04f }, - { 2.4509192710e-18f, 1.3342183083e-02f }, { -3.8115552023e-03f, 1.9161981995e-02f }, - { -7.5474785839e-03f, 1.8221225159e-02f }, { -8.6960320791e-03f, 1.3014531722e-02f }, - { -6.6710920858e-03f, 6.6710920858e-03f }, { -2.5478608559e-03f, 1.7024261963e-03f }, - { 1.7970187432e-03f, -7.4434953528e-04f }, { 4.6850211151e-03f, -9.3190864122e-04f }, +// sample=38.4k, deviation=2400, b=0.5, symbol=9600 +// Length: 16 taps, 4 symbols, 1 cycles of sinusoid +constexpr std::array, 16> rrc_taps_38k4_4t_p { { + { 1.0619794019e-02f, 0.0000000000e+00f }, { 3.5758705854e-03f, 1.4811740938e-03f }, + { -1.3274742629e-02f, -1.3274742629e-02f }, { -1.5018657262e-02f, -3.6258246051e-02f }, + { 0.0000000000e+00f, -2.6549484581e-02f }, { -1.5018657262e-02f, 3.6258246051e-02f }, + { -1.0237997393e-01f, 1.0237997393e-01f }, { -2.2527985355e-01f, 9.3313970669e-02f }, + { -2.8440842032e-01f, 0.0000000000e+00f }, { -2.2527985355e-01f, -9.3313970669e-02f }, + { -1.0237997393e-01f, -1.0237997393e-01f }, { -1.5018657262e-02f, -3.6258246051e-02f }, + { 0.0000000000e+00f, 2.6549484581e-02f }, { -1.5018657262e-02f, 3.6258246051e-02f }, + { -1.3274742629e-02f, 1.3274742629e-02f }, { 3.5758705854e-03f, -1.4811740938e-03f }, } }; } /* namespace ais */