summaryrefslogtreecommitdiff
path: root/fw/midi-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/src/controller_tests/pid_reset_tests.c
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2020-10-14 12:49:08 +0200
committerjaseg <git@jaseg.net>2020-10-14 12:49:08 +0200
commit3559d845d29272050d4d44e18e0bb84e676e48ff (patch)
treed8d6ce99e40b1a3745d76f0c9aac2f10e7286481 /fw/midi-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/src/controller_tests/pid_reset_tests.c
parent491b2acaaa9db1798445f3e174e68ada7424fc33 (diff)
parent6ab94e0b318884bbcb95e2ea3835f951502e1d99 (diff)
downloadminikbd-3559d845d29272050d4d44e18e0bb84e676e48ff.tar.gz
minikbd-3559d845d29272050d4d44e18e0bb84e676e48ff.tar.bz2
minikbd-3559d845d29272050d4d44e18e0bb84e676e48ff.zip
Merge firmware and pcb repos
Diffstat (limited to 'fw/midi-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/src/controller_tests/pid_reset_tests.c')
-rw-r--r--fw/midi-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/src/controller_tests/pid_reset_tests.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/fw/midi-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/src/controller_tests/pid_reset_tests.c b/fw/midi-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/src/controller_tests/pid_reset_tests.c
new file mode 100644
index 0000000..a930dbb
--- /dev/null
+++ b/fw/midi-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/src/controller_tests/pid_reset_tests.c
@@ -0,0 +1,52 @@
+#include "jtest.h"
+#include "arr_desc.h"
+#include "arm_math.h"
+#include "type_abbrev.h"
+#include "test_templates.h"
+
+/* Bucket of zeros. For comparison with the output of arm_pid_reset_xxx. */
+ARR_DESC_DEFINE(float32_t, zeroes, 3, CURLY(0));
+
+/**
+ * Define a JTEST_TEST_t for the function arm_pid_reset_xxx function having
+ * suffix.
+ */
+#define ARM_PID_RESET_TEST(suffix) \
+ JTEST_DEFINE_TEST(arm_pid_reset_##suffix##_test, \
+ arm_pid_reset_##suffix) \
+ { \
+ /* Initialise the pid_instance */ \
+ arm_pid_instance_##suffix pid_inst = { 0 }; \
+ pid_inst.state[0] = (TYPE_FROM_ABBREV(suffix)) 0xffffffff; \
+ pid_inst.state[1] = (TYPE_FROM_ABBREV(suffix)) 0xffffffff; \
+ pid_inst.state[2] = (TYPE_FROM_ABBREV(suffix)) 0xffffffff; \
+ \
+ /* Display cycle count and run test */ \
+ JTEST_COUNT_CYCLES(arm_pid_reset_##suffix(&pid_inst)); \
+ \
+ /* Test correctness */ \
+ TEST_ASSERT_BUFFERS_EQUAL( \
+ pid_inst.state, \
+ zeroes.data_ptr, \
+ 3 * sizeof(TYPE_FROM_ABBREV(suffix))); \
+ \
+ return JTEST_TEST_PASSED; \
+ }
+
+ARM_PID_RESET_TEST(f32);
+ARM_PID_RESET_TEST(q31);
+ARM_PID_RESET_TEST(q15);
+
+/*--------------------------------------------------------------------------------*/
+/* Collect all tests in a group */
+/*--------------------------------------------------------------------------------*/
+
+JTEST_DEFINE_GROUP(pid_reset_tests)
+{
+ /*
+ To skip a test, comment it out.
+ */
+ JTEST_TEST_CALL(arm_pid_reset_f32_test);
+ JTEST_TEST_CALL(arm_pid_reset_q31_test);
+ JTEST_TEST_CALL(arm_pid_reset_q15_test);
+}