summaryrefslogtreecommitdiff
path: root/fw/cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/templates/template.h
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/cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/templates/template.h
parent491b2acaaa9db1798445f3e174e68ada7424fc33 (diff)
parent6ab94e0b318884bbcb95e2ea3835f951502e1d99 (diff)
downloadminikbd-3559d845d29272050d4d44e18e0bb84e676e48ff.tar.gz
minikbd-3559d845d29272050d4d44e18e0bb84e676e48ff.tar.bz2
minikbd-3559d845d29272050d4d44e18e0bb84e676e48ff.zip
Merge firmware and pcb repos
Diffstat (limited to 'fw/cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/templates/template.h')
-rw-r--r--fw/cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/templates/template.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/fw/cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/templates/template.h b/fw/cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/templates/template.h
new file mode 100644
index 0000000..e4577d1
--- /dev/null
+++ b/fw/cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/templates/template.h
@@ -0,0 +1,88 @@
+#ifndef _TEMPLATE_H_
+#define _TEMPLATE_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Looping and Iteration */
+/*--------------------------------------------------------------------------------*/
+
+/**
+ * Template for the general structure of a loop.
+ */
+#define TEMPLATE_LOOP(setup, loop_def, body) \
+ do \
+ { \
+ setup; \
+ loop_def { \
+ body; \
+ } \
+ } while (0)
+
+/**
+ * Template for looping over an array-like sequence.
+ */
+#define TEMPLATE_DO_ARR_LIKE(iter_idx, type, \
+ arr, arr_length, \
+ iter_elem_setup, \
+ body) \
+ do \
+ { \
+ TEMPLATE_LOOP( \
+ int iter_idx, \
+ for(iter_idx = 0; iter_idx < (arr_length); ++iter_idx), \
+ iter_elem_setup; \
+ body); \
+ } while (0)
+
+/**
+ * Template for looping over the contents of an array.
+ */
+#define TEMPLATE_DO_ARR(iter_idx, type, iter_elem, arr, arr_length, body) \
+ do \
+ { \
+ TEMPLATE_DO_ARR_LIKE( \
+ iter_idx, type, arr, arr_length, \
+ type iter_elem = (arr)[iter_idx], \
+ body); \
+ } while (0)
+
+/**
+ * Template for looping over the contents of an #ARR_DESC.
+ */
+#define TEMPLATE_DO_ARR_DESC(iter_idx, type, iter_elem, arr_desc, body) \
+ do \
+ { \
+ TEMPLATE_DO_ARR_LIKE( \
+ iter_idx, type, arr_desc, (arr_desc).element_count, \
+ type iter_elem = ARR_DESC_ELT(type, iter_idx, &(arr_desc)), \
+ body); \
+ } while (0)
+
+/*--------------------------------------------------------------------------------*/
+/* Test Definition */
+/*--------------------------------------------------------------------------------*/
+
+/**
+ * Template for the general structure of a test.
+ */
+#define TEMPLATE_TEST(setup, body, teardown) \
+ do \
+ { \
+ setup; \
+ body; \
+ teardown; \
+ } while (0)
+
+/**
+ * Template for calling a function.
+ *
+ * @note Surround function arguments with the #PAREN() macro.
+ *
+ * @example
+ * void my_func(int arg1, int arg2);
+ *
+ * TEMPLATE_CALL_FN(my_func, PAREN(3, 7));
+ */
+#define TEMPLATE_CALL_FN(fn, fn_args) \
+ fn fn_args
+
+#endif /* _TEMPLATE_H_ */