summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2017-12-13 15:29:23 +0100
committerDaniel Friesel <derf@finalrewind.org>2017-12-13 15:29:23 +0100
commite9bebe253fdecee009414bdce7ccdfba83f980e6 (patch)
tree49330d7108869ddfbe8682fb6f20ff79794f57b5 /src/arch
parent22f2335259594569ba4a95544939ef72f3d1bb9d (diff)
add simple cache benchmark application
Diffstat (limited to 'src/arch')
-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
7 files changed, 45 insertions, 22 deletions
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;