From d1668a6fc12062c2c180534e7825910e6fcb05b0 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 6 Mar 2019 07:54:55 +0100 Subject: add counter test application --- src/app/countertest/Makefile.inc | 2 ++ src/app/countertest/main.cc | 60 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/app/countertest/Makefile.inc create mode 100644 src/app/countertest/main.cc (limited to 'src/app/countertest') diff --git a/src/app/countertest/Makefile.inc b/src/app/countertest/Makefile.inc new file mode 100644 index 0000000..7e15c58 --- /dev/null +++ b/src/app/countertest/Makefile.inc @@ -0,0 +1,2 @@ +loop ?= 1 +arch_drivers += ,counter diff --git a/src/app/countertest/main.cc b/src/app/countertest/main.cc new file mode 100644 index 0000000..85ac7ce --- /dev/null +++ b/src/app/countertest/main.cc @@ -0,0 +1,60 @@ +#include "arch.h" +#include "driver/gpio.h" +#include "driver/stdout.h" +#include "driver/counter.h" + +void loop(void) +{ + counter.start(); + counter.stop(); + kout << "nop: " << counter.value << "/" << counter.overflow << endl; + + counter.start(); + arch.delay_ms(1); + counter.stop(); + kout << "1ms: " << counter.value << "/" << counter.overflow << endl; + + counter.start(); + arch.delay_us(10); + counter.stop(); + kout << "10us: " << counter.value << "/" << counter.overflow << endl; + + counter.start(); + arch.delay_us(20); + counter.stop(); + kout << "20us: " << counter.value << "/" << counter.overflow << endl; + + counter.start(); + arch.delay_ms(2); + counter.stop(); + kout << "2ms: " << counter.value << "/" << counter.overflow << endl; + + counter.start(); + arch.delay_ms(4); + counter.stop(); + kout << "4ms: " << counter.value << "/" << counter.overflow << endl; + + counter.start(); + arch.delay_ms(8); + counter.stop(); + kout << "8ms: " << counter.value << "/" << counter.overflow << endl; + + counter.start(); + arch.delay_ms(16); + counter.stop(); + kout << "16ms: " << counter.value << "/" << counter.overflow << endl; + + counter.start(); + arch.delay_ms(32); + counter.stop(); + kout << "32ms: " << counter.value << "/" << counter.overflow << endl; +} + +int main(void) +{ + arch.setup(); + gpio.setup(); + kout.setup(); + arch.idle_loop(); + return 0; +} -- cgit v1.2.3