summaryrefslogtreecommitdiff
path: root/src/app/energybench
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/energybench')
-rw-r--r--src/app/energybench/Makefile.inc2
-rw-r--r--src/app/energybench/main.cc105
2 files changed, 39 insertions, 68 deletions
diff --git a/src/app/energybench/Makefile.inc b/src/app/energybench/Makefile.inc
index d7dcd37..e69de29 100644
--- a/src/app/energybench/Makefile.inc
+++ b/src/app/energybench/Makefile.inc
@@ -1,2 +0,0 @@
-timer_cycles ?= 1
-loop ?= 1
diff --git a/src/app/energybench/main.cc b/src/app/energybench/main.cc
index 59a775e..27371b8 100644
--- a/src/app/energybench/main.cc
+++ b/src/app/energybench/main.cc
@@ -3,79 +3,52 @@
#include "driver/stdout.h"
#include "driver/uptime.h"
-#ifndef TIMER_CYCLES
-#error makeflag timer_cycles=1 required
-#endif
-
-void loop(void)
-{
-#if 0
- static unsigned char i = 0;
-
- switch (i) {
- case 0:
- gpio.led_on(0);
- gpio.led_off(0);
- break;
- case 1:
- gpio.led_on(0);
- arch.delay_us(1);
- gpio.led_off(0);
- break;
- case 2:
- gpio.led_on(0);
- arch.delay_us(2);
- gpio.led_off(0);
- break;
- case 3:
- gpio.led_on(1);
- gpio.led_off(1);
- break;
- case 4:
- gpio.led_on(1);
- arch.delay_us(1);
- gpio.led_off(1);
- break;
- case 5:
- gpio.led_on(1);
- arch.delay_us(2);
- gpio.led_off(1);
- break;
- case 6:
- gpio.led_on(0);
- break;
- case 7:
- gpio.led_off(0);
- break;
- case 8:
- gpio.led_on(1);
- break;
- case 9:
- gpio.led_off(1);
- break;
- default:
- break;
- }
-
-
- i = (i+1) % 10;
-#endif
-}
-
int main(void)
{
arch.setup();
gpio.setup();
kout.setup();
- kout << "Hello, World!" << endl;
- kout << "Test, World!" << endl;
- kout << dec << uptime.get_cycles() << endl;
- kout << dec << uptime.get_cycles() << endl;
- kout << dec << uptime.get_cycles() << endl;
- kout << dec << uptime.get_cycles() << endl;
+ gpio.output(GPIO::p1_1);
+
+ arch.delay_ms(5000);
+
+ gpio.write(GPIO::p1_1, 1);
+ __delay_cycles(64000); // 8 ms
+ __delay_cycles(64000); // 8 ms
+ gpio.write(GPIO::p1_1, 0);
+ __delay_cycles(64000); // 8 ms
+ __delay_cycles(64000); // 8 ms
+ gpio.write(GPIO::p1_1, 1);
+ __delay_cycles(64000); // 8 ms
+ __delay_cycles(64000); // 8 ms
+ gpio.write(GPIO::p1_1, 0);
+
+ for (uint8_t i = 0; i < 200; i++) {
+ arch.sleep_ms(50);
+ gpio.write(GPIO::p1_1, 1);
+ arch.sleep_ms(i);
+ gpio.write(GPIO::p1_1, 0);
+ arch.sleep_ms(i);
+ gpio.write(GPIO::p1_1, 1);
+ arch.sleep_ms(i);
+ gpio.write(GPIO::p1_1, 0);
+ }
- arch.idle_loop();
+ for (uint8_t i = 0; i < 200; i++) {
+ arch.delay_ms(50);
+ gpio.write(GPIO::p1_1, 1);
+ arch.delay_ms(i);
+ gpio.write(GPIO::p1_1, 0);
+ arch.delay_ms(i);
+ gpio.write(GPIO::p1_1, 1);
+ arch.delay_ms(i);
+ gpio.write(GPIO::p1_1, 0);
+ }
+
+ while(1) {
+ arch.idle();
+ }
return 0;
}