summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/bench/main.cc68
-rw-r--r--src/arch/esp8266/Makefile.inc5
-rw-r--r--src/arch/esp8266/driver/uptime.cc9
-rw-r--r--src/arch/msp430fr5969lp/Makefile.inc5
-rw-r--r--src/arch/msp430fr5969lp/arch.cc19
-rw-r--r--src/arch/msp430fr5969lp/driver/uptime.cc5
-rw-r--r--src/arch/posix/Makefile.inc6
-rw-r--r--src/arch/posix/driver/uptime.cc18
8 files changed, 113 insertions, 22 deletions
diff --git a/src/app/bench/main.cc b/src/app/bench/main.cc
new file mode 100644
index 0000000..cdbc00f
--- /dev/null
+++ b/src/app/bench/main.cc
@@ -0,0 +1,68 @@
+#include "arch.h"
+#include "driver/gpio.h"
+#include "driver/stdout.h"
+#include "driver/uptime.h"
+
+#ifndef TIMER_CYCLES
+#error makeflag timer_cycles=1 required
+#endif
+
+
+/*
+ * For ESP8266: Flash reads must be 4-Byte-aligned -> uint32_t array
+ */
+
+__attribute__ ((section(".text"))) uint32_t arr[4096];
+//uint32_t arr[1024];
+uint16_t frob;
+
+inline uint16_t bench_read(uint32_t *arr)
+{
+ uint16_t ts_pre, ts_post;
+ ts_pre = uptime.get_cycles();
+ frob += *arr;
+ ts_post = uptime.get_cycles();
+ return ts_post - ts_pre;
+}
+
+int main(void)
+{
+ arch.setup();
+ gpio.setup();
+ kout.setup();
+
+ uint16_t ts1 = uptime.get_cycles();
+ uint16_t ts2 = uptime.get_cycles();
+ uint16_t ts3 = uptime.get_cycles();
+ uint16_t ts4 = uptime.get_cycles();
+ uint16_t i;
+
+ //for (i = 0; i < 1024; i++) {
+ // arr[i] = 1;
+ //}
+
+ gpio.led_on(0);
+ kout << "Hello, World!" << endl;
+ kout << "Test, World!" << endl;
+ kout << dec << ts1 << endl;
+ kout << dec << ts2 << endl;
+ kout << dec << ts3 << endl;
+ kout << dec << ts4 << endl;
+
+ for (int i = 0; i < sizeof(arr) / sizeof(uint32_t); i++) {
+ kout << i << ": " << bench_read(&arr[i]) << endl;
+ }
+ for (signed int i = (sizeof(arr) / sizeof(uint32_t)) - 1; i >= 0; i--) {
+ kout << i << ": " << bench_read(&arr[i]) << endl;
+ }
+ kout << frob << endl;
+
+ arch.idle_loop();
+
+ //uart_setup();
+ //uart_puts("\n" COL_YELLOW "dOS" COL_GREEN " > " COL_RESET);
+
+ //arch_idle_loop();
+
+ return 0;
+}
diff --git a/src/arch/esp8266/Makefile.inc b/src/arch/esp8266/Makefile.inc
index 3b1c8cb..0484985 100644
--- a/src/arch/esp8266/Makefile.inc
+++ b/src/arch/esp8266/Makefile.inc
@@ -46,4 +46,7 @@ arch_clean:
rm -f ${OBJECTS}
rm -f build/system.ar
-.PHONY: arch_clean program
+monitor:
+ screen /dev/ttyUSB0 115200
+
+.PHONY: arch_clean monitor program
diff --git a/src/arch/esp8266/driver/uptime.cc b/src/arch/esp8266/driver/uptime.cc
index 51cc617..388edb6 100644
--- a/src/arch/esp8266/driver/uptime.cc
+++ b/src/arch/esp8266/driver/uptime.cc
@@ -1,12 +1,3 @@
#include "driver/uptime.h"
-extern "C" {
-#include "osapi.h"
-#include "user_interface.h"
-}
-
-uint32_t Uptime::get()
-{
- return system_get_time();
-}
Uptime uptime;
diff --git a/src/arch/msp430fr5969lp/Makefile.inc b/src/arch/msp430fr5969lp/Makefile.inc
index 81c8fdf..36d19c6 100644
--- a/src/arch/msp430fr5969lp/Makefile.inc
+++ b/src/arch/msp430fr5969lp/Makefile.inc
@@ -35,4 +35,7 @@ arch_clean:
rm -f ${OBJECTS}
rm -f build/system.hex
-.PHONY: arch_clean program
+monitor:
+ screen /dev/ttyACM1 115200
+
+.PHONY: arch_clean monitor program
diff --git a/src/arch/msp430fr5969lp/arch.cc b/src/arch/msp430fr5969lp/arch.cc
index be821a6..44a22c6 100644
--- a/src/arch/msp430fr5969lp/arch.cc
+++ b/src/arch/msp430fr5969lp/arch.cc
@@ -38,13 +38,14 @@ void Arch::setup(void)
__delay_cycles(1000000);
#endif
+#ifdef TIMER_US
// 16MHz/16 -> ~1MHz timer
TA0CTL = TASSEL__SMCLK | ID__8 | MC__CONTINUOUS;
TA0EX0 = 1;
TA0CTL |= TACLR;
+#endif
-#ifdef WITH_LOOP
-
+#if defined(WITH_LOOP) || defined(TIMER_S)
// 1s per wakeup for loop
TA1CTL = TASSEL__ACLK | ID__8 | MC__UP;
TA1EX0 = 0;
@@ -52,6 +53,12 @@ void Arch::setup(void)
TA1CTL |= TACLR | TAIE;
#endif
+#ifdef TIMER_CYCLES
+ TA2CTL = TASSEL__SMCLK | ID__1 | MC__CONTINUOUS;
+ TA2EX0 = 0;
+ TA2CTL |= TACLR;
+#endif
+
//P1OUT = 0;
//P4OUT = 0;
}
@@ -64,14 +71,20 @@ void Arch::idle_loop(void)
Arch arch;
-#ifdef WITH_LOOP
+#if defined(WITH_LOOP) || defined(TIMER_S)
+#include "driver/uptime.h"
extern void loop();
__attribute__((interrupt(TIMER1_A1_VECTOR))) __attribute__((wakeup)) void handle_timer0_overflow()
{
if (TA1IV == 0x0e) {
+#ifdef WITH_LOOP
loop();
+#endif
+#ifdef TIMER_S
+ uptime.tick_s();
+#endif
}
}
diff --git a/src/arch/msp430fr5969lp/driver/uptime.cc b/src/arch/msp430fr5969lp/driver/uptime.cc
index 6d16441..05154f9 100644
--- a/src/arch/msp430fr5969lp/driver/uptime.cc
+++ b/src/arch/msp430fr5969lp/driver/uptime.cc
@@ -1,9 +1,4 @@
#include "driver/uptime.h"
#include <msp430.h>
-uint32_t Uptime::get()
-{
- return TA0R;
-}
-
Uptime uptime;
diff --git a/src/arch/posix/Makefile.inc b/src/arch/posix/Makefile.inc
index 7553fd4..03b6f67 100644
--- a/src/arch/posix/Makefile.inc
+++ b/src/arch/posix/Makefile.inc
@@ -19,7 +19,11 @@ build/system.elf: ${OBJECTS}
run: build/system.elf
build/system.elf
+monitor: run
+
+program: run
+
arch_clean:
rm -f ${OBJECTS}
-.PHONY: arch_clean program
+.PHONY: arch_clean monitor program run
diff --git a/src/arch/posix/driver/uptime.cc b/src/arch/posix/driver/uptime.cc
index 040b51c..00b1d34 100644
--- a/src/arch/posix/driver/uptime.cc
+++ b/src/arch/posix/driver/uptime.cc
@@ -1,11 +1,25 @@
#include "driver/uptime.h"
#include <time.h>
-uint64_t Uptime::get()
+uint64_t Uptime::get_s()
{
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
- return (uint64_t)ts.tv_nsec + (1000000ULL * ((uint64_t)ts.tv_sec % 256));
+ return ts.tv_sec;
+}
+
+uint64_t Uptime::get_us()
+{
+ struct timespec ts;
+ clock_gettime(CLOCK_REALTIME, &ts);
+ return ts.tv_nsec / 1000;
+}
+
+uint64_t Uptime::get_cycles()
+{
+ struct timespec ts;
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
+ return ts.tv_nsec;
}
Uptime uptime;