From 495a89459f55b81dfbbe7b133993da4301d4f781 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Fri, 9 Aug 2019 17:05:19 +0100 Subject: [PATCH] AP_HAL_Empty: empty implementation of HAL FFT --- .../AP_HAL_Empty/AP_HAL_Empty_Namespace.h | 1 + libraries/AP_HAL_Empty/AP_HAL_Empty_Private.h | 1 + libraries/AP_HAL_Empty/DSP.h | 32 +++++++++++++++++++ libraries/AP_HAL_Empty/HAL_Empty_Class.cpp | 3 +- 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 libraries/AP_HAL_Empty/DSP.h diff --git a/libraries/AP_HAL_Empty/AP_HAL_Empty_Namespace.h b/libraries/AP_HAL_Empty/AP_HAL_Empty_Namespace.h index 31154e304d..f264973b44 100644 --- a/libraries/AP_HAL_Empty/AP_HAL_Empty_Namespace.h +++ b/libraries/AP_HAL_Empty/AP_HAL_Empty_Namespace.h @@ -4,6 +4,7 @@ namespace Empty { class AnalogIn; class AnalogSource; class DigitalSource; + class DSP; class GPIO; class I2CDevice; class I2CDeviceManager; diff --git a/libraries/AP_HAL_Empty/AP_HAL_Empty_Private.h b/libraries/AP_HAL_Empty/AP_HAL_Empty_Private.h index f04aeede0f..097aa30926 100644 --- a/libraries/AP_HAL_Empty/AP_HAL_Empty_Private.h +++ b/libraries/AP_HAL_Empty/AP_HAL_Empty_Private.h @@ -17,3 +17,4 @@ #include "UARTDriver.h" #include "Util.h" #include "Flash.h" +#include "DSP.h" diff --git a/libraries/AP_HAL_Empty/DSP.h b/libraries/AP_HAL_Empty/DSP.h new file mode 100644 index 0000000000..0bb5817376 --- /dev/null +++ b/libraries/AP_HAL_Empty/DSP.h @@ -0,0 +1,32 @@ +/* + * This file is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Code by Andy Piper + */ +#pragma once + +#include "AP_HAL_Empty.h" + +class Empty::DSP : public AP_HAL::DSP { +#if HAL_WITH_DSP +public: + virtual FFTWindowState* fft_init(uint16_t window_size, uint16_t sample_rate) override { return nullptr; } + virtual void fft_start(FFTWindowState* state, const float* samples, uint16_t buffer_index, uint16_t buffer_size) override {} + virtual uint16_t fft_analyse(FFTWindowState* state, uint16_t start_bin, uint16_t end_bin, uint8_t harmonics, float noise_att_cutoff) override { return 0; } +protected: + virtual void vector_max_float(const float* vin, uint16_t len, float* maxValue, uint16_t* maxIndex) const override {} + virtual void vector_scale_float(const float* vin, float scale, float* vout, uint16_t len) const override {} +#endif // HAL_WITH_DSP +}; + diff --git a/libraries/AP_HAL_Empty/HAL_Empty_Class.cpp b/libraries/AP_HAL_Empty/HAL_Empty_Class.cpp index 484feb45aa..3b7c570523 100644 --- a/libraries/AP_HAL_Empty/HAL_Empty_Class.cpp +++ b/libraries/AP_HAL_Empty/HAL_Empty_Class.cpp @@ -43,7 +43,8 @@ HAL_Empty::HAL_Empty() : &schedulerInstance, &utilInstance, &opticalFlowDriver, - &flashDriver) + &flashDriver, + nullptr) /* no DSP */ {} void HAL_Empty::run(int argc, char* const argv[], Callbacks* callbacks) const