summaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/prototest/Makefile.inc96
-rw-r--r--src/app/prototest/main.cc79
2 files changed, 175 insertions, 0 deletions
diff --git a/src/app/prototest/Makefile.inc b/src/app/prototest/Makefile.inc
new file mode 100644
index 0000000..c088f6b
--- /dev/null
+++ b/src/app/prototest/Makefile.inc
@@ -0,0 +1,96 @@
+ifeq (${aspectc}, 1)
+ CXX_FLAGS += --Xweaver -asrc/app/prototest/prototest.ah --Xcompiler
+endif
+
+ifeq (${prototest_bench_energy}, 1)
+ loop ?= 1
+ COMMON_FLAGS += -DPROTOTEST_BENCH_ENERGY
+endif
+
+ifeq (${prototest_bench_cycles}, 1)
+ loop ?= 0
+ arch_drivers += ,counter
+ COMMON_FLAGS += -DPROTOTEST_BENCH_CYCLES
+endif
+
+ifneq (${prototest_include_global}, )
+ COMMON_FLAGS += -DPROTOTEST_INCLUDE_GLOBAL=${prototest_include_global}
+endif
+
+ifneq (${prototest_include_local}, )
+ COMMON_FLAGS += -DPROTOTEST_INCLUDE_LOCAL=${prototest_include_local}
+endif
+
+ifeq (${prototest_arduinojson}, 1)
+ COMMON_FLAGS += -DPROTOTEST_ARDUINOJSON
+endif
+
+ifeq (${prototest_binn}, 1)
+ COMMON_FLAGS += -DPROTOTEST_BINN
+ CXX_TARGETS += src/lib/binn.cc
+endif
+
+ifeq (${prototest_capnproto_c}, 1)
+ COMMON_FLAGS += -DPROTOTEST_CAPNPROTO_C
+ CXX_TARGETS += src/app/prototest/capnp_c_bench.capnp.cc
+ CXX_TARGETS += src/lib/capnp-c/capn.cc
+ CXX_TARGETS += src/lib/capnp-c/capn-malloc.cc
+ CXX_TARGETS += src/lib/capnp-c/capn-stream.cc
+ INCLUDES += -Iinclude/lib/capnp-c
+endif
+
+ifeq (${prototest_manualjson}, 1)
+ COMMON_FLAGS += -DPROTOTEST_MANUALJSON
+endif
+
+ifeq (${prototest_modernjson}, 1)
+ COMMON_FLAGS += -DPROTOTEST_MODERNJSON
+ ostream = 1
+endif
+
+ifeq (${prototest_mpack}, 1)
+ COMMON_FLAGS += -DPROTOTEST_MPACK
+ CXX_TARGETS += src/lib/mpack/mpack.cc
+ INCLUDES += -Iinclude/lib/mpack
+endif
+
+ifeq (${prototest_nanopb}, 1)
+ COMMON_FLAGS += -DPROTOTEST_NANOPB
+ CXX_TARGETS += src/app/prototest/nanopbbench.pb.cc src/lib/nanopb/pb_common.cc
+ CXX_TARGETS += src/lib/nanopb/pb_decode.cc src/lib/nanopb/pb_encode.cc
+ INCLUDES += -Iinclude/lib/nanopb
+endif
+
+ifeq (${prototest_ubjson}, 1)
+ COMMON_FLAGS += -DPROTOTEST_UBJSON
+ C_TARGETS += src/lib/ubjson/ubjr.c src/lib/ubjson/ubjw.c
+ INCLUDES += -Iinclude/lib/ubjson
+endif
+
+ifeq (${prototest_xdr}, 1)
+ COMMON_FLAGS += -DPROTOTEST_XDR
+ CXX_TARGETS += src/lib/xdr.cc
+endif
+
+ifeq (${prototest_xdr16}, 1)
+ COMMON_FLAGS += -DPROTOTEST_XDR16
+ CXX_TARGETS += src/lib/xdr16.cc
+endif
+
+# Don't try to make .capnp from .capnp.c
+%.capnp: ;
+
+# Don't try to make .proto from .proto.c
+%.proto: ;
+
+%.pb.cc: %.proto
+ ${QUIET}protoc --plugin=protoc-gen-nanopb=${HOME}/var/ess/protocol-modeling/nanopb/generator/protoc-gen-nanopb --nanopb_out=. src/app/prototest/nanopbbench.proto
+ ${QUIET}mv src/app/prototest/nanopbbench.pb.c src/app/prototest/nanopbbench.pb.cc
+ ${QUIET}cp src/app/prototest/nanopbbench.pb.cc /tmp
+ ${QUIET}sed -i 's!src/app/prototest/!!' src/app/prototest/nanopbbench.pb.cc
+ ${QUIET}sed -i 's!\#include "src/app/prototest/nanopb.pb.h"!!' src/app/prototest/nanopbbench.pb.h
+
+%.capnp.cc: %.capnp
+ ${QUIET}capnp compile -oc $<
+ ${QUIET}mv $<.c $<.cc
+ ${QUIET}cp $<.cc /tmp
diff --git a/src/app/prototest/main.cc b/src/app/prototest/main.cc
new file mode 100644
index 0000000..7fc897e
--- /dev/null
+++ b/src/app/prototest/main.cc
@@ -0,0 +1,79 @@
+#include "arch.h"
+#include "driver/gpio.h"
+#include "driver/stdout.h"
+
+#ifdef PROTOTEST_BENCH_CYCLES
+#include "driver/counter.h"
+#endif
+
+#ifdef PROTOTEST_ARDUINOJSON
+#include "lib/ArduinoJson.h"
+#endif
+#ifdef PROTOTEST_BINN
+#include "lib/binn.h"
+#endif
+#ifdef PROTOTEST_CAPNPROTO_C
+#include <capnp_c.h>
+#include "capnp_c_bench.capnp.h"
+#endif
+#ifdef PROTOTEST_MANUALJSON
+#include "object/stdbuf.h"
+#endif
+#ifdef PROTOTEST_MODERNJSON
+#include "lib/modernjson/json.h"
+#endif
+#ifdef PROTOTEST_MPACK
+#include "mpack.h"
+#endif
+#ifdef PROTOTEST_NANOPB
+#include <pb.h>
+#include "nanopbbench.pb.h"
+#include <pb_encode.h>
+#include <pb_decode.h>
+#endif
+#ifdef PROTOTEST_UBJSON
+#include "ubj.h"
+#endif
+#ifdef PROTOTEST_XDR
+#include "lib/xdr.h"
+#endif
+#ifdef PROTOTEST_XDR16
+#include "lib/xdr16.h"
+#endif
+
+#include <stdint.h>
+
+#ifdef PROTOTEST_INCLUDE_GLOBAL
+#include "prototest_global.cc.inc"
+#endif
+
+void loop(void)
+{
+ //static uint16_t ts = 0;
+ //ts++;
+
+#ifdef PROTOTEST_INCLUDE_LOCAL
+#include "prototest_local.cc.inc"
+#endif
+
+}
+
+int main(void)
+{
+ arch.setup();
+ gpio.setup();
+ kout.setup();
+
+ //gpio.led_on(0);
+ kout << "Hello, World!" << endl;
+
+#if defined(PROTOTEST_BENCH_CYCLES) and !defined(PROTOTEST_ARCH_esp8266)
+ while (1) {
+ loop();
+ }
+#else
+ arch.idle_loop();
+#endif
+
+ return 0;
+}