Skip to content

Commit

Permalink
[examples] Add CMSIS-DSP examples
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Jul 11, 2019
1 parent 7f94500 commit 022a60a
Show file tree
Hide file tree
Showing 30 changed files with 454 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ make gdb

## Interesting Examples

We have a lot of examples, <!--examplecount-->178<!--/examplecount--> to be
We have a lot of examples, <!--examplecount-->189<!--/examplecount--> to be
exact, but here are some of our favorite examples for our supported development
boards:

Expand Down
24 changes: 24 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/class_marks/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2019, Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#include <modm/board.hpp>
#include <arm_math.h>

#define main arm_cmsis_dsp_example
#define std var_std
#define while return ARM_MATH_SUCCESS; void // has no status variable
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_class_marks_example/arm_class_marks_example_f32.c"
#undef while
#undef main
#undef std

#define example_name "class_marks"
#include "../runner.cpp"
11 changes: 11 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/class_marks/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<library>
<extends>modm:nucleo-f429zi</extends>
<options>
<option name="modm:build:build.path">../../../../build/nucleo_f429zi/cmsis_dsp/class_marks</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:cmsis:dsp:matrix</module>
<module>modm:cmsis:dsp:statistics</module>
</modules>
</library>
27 changes: 27 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/convolution/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2019, Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#include <modm/board.hpp>
#include <arm_math.h>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
#define main arm_cmsis_dsp_example
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_convolution_example/math_helper.h"
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_convolution_example/math_helper.c"
#define while return status; void
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_convolution_example/arm_convolution_example_f32.c"
#undef while
#undef main
#pragma GCC diagnostic pop

#define example_name "convolution"
#include "../runner.cpp"
1 change: 1 addition & 0 deletions examples/nucleo_f429zi/cmsis_dsp/convolution/math_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty file to satisfy CPP
12 changes: 12 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/convolution/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<library>
<extends>modm:nucleo-f429zi</extends>
<options>
<option name="modm:build:build.path">../../../../build/nucleo_f429zi/cmsis_dsp/convolution</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:cmsis:dsp:transform</module>
<module>modm:cmsis:dsp:support</module>
<module>modm:cmsis:dsp:complex_math</module>
</modules>
</library>
23 changes: 23 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/dotproduct/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2019, Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#include <modm/board.hpp>
#include <arm_math.h>

#define main arm_cmsis_dsp_example
#define while return status; void
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_dotproduct_example/arm_dotproduct_example_f32.c"
#undef while
#undef main

#define example_name "dotproduct"
#include "../runner.cpp"

11 changes: 11 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/dotproduct/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<library>
<extends>modm:nucleo-f429zi</extends>
<options>
<option name="modm:build:build.path">../../../../build/nucleo_f429zi/cmsis_dsp/dotproduct</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:cmsis:dsp:transform</module>
<module>modm:cmsis:dsp:basic_math</module>
</modules>
</library>
23 changes: 23 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/fft_bin/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2019, Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#include <modm/board.hpp>
#include <arm_math.h>

#define main arm_cmsis_dsp_example
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_fft_bin_example/arm_fft_bin_data.c"
#define while return status; void
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_fft_bin_example/arm_fft_bin_example_f32.c"
#undef while
#undef main

#define example_name "fft_bin"
#include "../runner.cpp"
12 changes: 12 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/fft_bin/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<library>
<extends>modm:nucleo-f429zi</extends>
<options>
<option name="modm:build:build.path">../../../../build/nucleo_f429zi/cmsis_dsp/fft_bin</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:cmsis:dsp:transform</module>
<module>modm:cmsis:dsp:complex_math</module>
<module>modm:cmsis:dsp:statistics</module>
</modules>
</library>
28 changes: 28 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/fir/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2019, Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#include <modm/board.hpp>
#include <arm_math.h>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
#define main arm_cmsis_dsp_example
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_fir_example/math_helper.h"
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_fir_example/math_helper.c"
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_fir_example/arm_fir_data.c"
#define while return status; void
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_fir_example/arm_fir_example_f32.c"
#undef while
#undef main
#pragma GCC diagnostic pop

#define example_name "fir"
#include "../runner.cpp"
1 change: 1 addition & 0 deletions examples/nucleo_f429zi/cmsis_dsp/fir/math_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty file to satisfy CPP
10 changes: 10 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/fir/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<library>
<extends>modm:nucleo-f429zi</extends>
<options>
<option name="modm:build:build.path">../../../../build/nucleo_f429zi/cmsis_dsp/fir</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:cmsis:dsp:filtering</module>
</modules>
</library>
28 changes: 28 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/graphic_equalizer/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2019, Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#include <modm/board.hpp>
#include <arm_math.h>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
#define main arm_cmsis_dsp_example
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_graphic_equalizer_example/math_helper.h"
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_graphic_equalizer_example/math_helper.c"
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_graphic_equalizer_example/arm_graphic_equalizer_data.c"
#define while return status; void
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_graphic_equalizer_example/arm_graphic_equalizer_example_q31.c"
#undef while
#undef main
#pragma GCC diagnostic pop

#define example_name "graphic_equalizer"
#include "../runner.cpp"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty file to satisfy CPP
11 changes: 11 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/graphic_equalizer/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<library>
<extends>modm:nucleo-f429zi</extends>
<options>
<option name="modm:build:build.path">../../../../build/nucleo_f429zi/cmsis_dsp/graphic_equalizer</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:cmsis:dsp:filtering</module>
<module>modm:cmsis:dsp:basic_math</module>
</modules>
</library>
33 changes: 33 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/linear_interp/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2019, Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#include <modm/board.hpp>
#include <arm_math.h>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
#define main arm_cmsis_dsp_example
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_linear_interp_example/math_helper.h"
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_linear_interp_example/math_helper.c"
/* `float arm_linear_interep_table[188495]` is 736kB large and MUST be placed in Flash
* memory NOT SRAM otherwise it won't fit on the device. Since we don't want (=cannot)
* to change the example, we need to take drastic measures... */
#define float const float
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_linear_interp_example/arm_linear_interp_data.c"
#define while return status; void
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_linear_interp_example/arm_linear_interp_example_f32.c"
#undef while
#undef float
#undef main
#pragma GCC diagnostic pop

#define example_name "linear_interp"
#include "../runner.cpp"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty file to satisfy CPP
14 changes: 14 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/linear_interp/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<library>
<extends>modm:nucleo-f429zi</extends>
<options>
<option name="modm:build:build.path">../../../../build/nucleo_f429zi/cmsis_dsp/linear_interp</option>
</options>
<collectors>
<!-- We need to cast `&arm_linear_interep_table[0]` to (float*), but cannot change the example... -->
<collect name="modm:build:cxxflags">-fpermissive</collect>
</collectors>
<modules>
<module>modm:build:scons</module>
<module>modm:cmsis:dsp:fast_math</module>
</modules>
</library>
27 changes: 27 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/matrix/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2019, Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#include <modm/board.hpp>
#include <arm_math.h>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
#define main arm_cmsis_dsp_example
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_matrix_example/math_helper.h"
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_matrix_example/math_helper.c"
#define while return status; void
#include "../../../../ext/arm/cmsis/CMSIS/DSP/Examples/ARM/arm_matrix_example/arm_matrix_example_f32.c"
#undef while
#undef main
#pragma GCC diagnostic pop

#define example_name "matrix"
#include "../runner.cpp"
1 change: 1 addition & 0 deletions examples/nucleo_f429zi/cmsis_dsp/matrix/math_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty file to satisfy CPP
10 changes: 10 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/matrix/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<library>
<extends>modm:nucleo-f429zi</extends>
<options>
<option name="modm:build:build.path">../../../../build/nucleo_f429zi/cmsis_dsp/matrix</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:cmsis:dsp:matrix</module>
</modules>
</library>
36 changes: 36 additions & 0 deletions examples/nucleo_f429zi/cmsis_dsp/runner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2019, Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

int main()
{
Board::initialize();

const uint32_t start{DWT->CYCCNT};
const int status = arm_cmsis_dsp_example();
const uint32_t diff{DWT->CYCCNT - start};

if (status != ARM_MATH_TEST_FAILURE) {
MODM_LOG_INFO << "Example '" << example_name << "' passed in ~" << (diff / modm::clock::fcpu_MHz) << "us!" << modm::endl;
} else {
MODM_LOG_ERROR << "Example '" << example_name << "' failed!" << modm::endl;
}

while(1) {
if (status != ARM_MATH_TEST_FAILURE) {
Board::LedBlue::toggle();
} else {
Board::LedRed::toggle();
}
modm::delayMilliseconds(1000);
}

return 0;
}
Loading

0 comments on commit 022a60a

Please sign in to comment.