aboutsummaryrefslogtreecommitdiffstats
path: root/examples/test-timers.cpp
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2010-07-20 15:34:35 -0400
committerbnewbold <bnewbold@robocracy.org>2010-07-20 15:37:44 -0400
commitc634572c2d12d36d19f3c8f4fc9eda58bb5f3d3d (patch)
tree6c67bcc74740646a7418c181871efc0e09d33ee2 /examples/test-timers.cpp
parent895d2a48fa30fa3fb3d6897834f838e25f8a2c58 (diff)
downloadlibrambutan-c634572c2d12d36d19f3c8f4fc9eda58bb5f3d3d.tar.gz
librambutan-c634572c2d12d36d19f3c8f4fc9eda58bb5f3d3d.zip
TMP: test updates
Diffstat (limited to 'examples/test-timers.cpp')
-rw-r--r--examples/test-timers.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/examples/test-timers.cpp b/examples/test-timers.cpp
index 9b1efc6..9adce70 100644
--- a/examples/test-timers.cpp
+++ b/examples/test-timers.cpp
@@ -1,10 +1,8 @@
-// Sample main.cpp file. Blinks an LED, sends a message out USART2
-// and turns on PWM on pin 2
+// Program to test the wirish timers implementation
#include "wirish.h"
#define LED_PIN 13
-#define PWM_PIN 2
void handler1(void);
void handler2(void);
@@ -37,6 +35,7 @@ void setup()
/* Set up the LED to blink */
pinMode(LED_PIN, OUTPUT);
+ // Setup the button as input
pinMode(38, INPUT_PULLUP);
/* Send a message out USART2 */
@@ -54,6 +53,9 @@ void setup()
}
void loop() {
+ // This tests whether the pause/resume functions work; when BUT is held
+ // down Timer4 is in the "pause" state and the timer doesn't increment, so
+ // the final counts should reflect the ratio of time that BUT was held down
SerialUSB.println("-----------------------------------------------------");
SerialUSB.println("Testing Pause/Resume; button roughly controls Timer4");
count3 = 0;
@@ -86,6 +88,7 @@ void loop() {
SerialUSB.print("Count3: "); SerialUSB.println(count3);
SerialUSB.print("Count4: "); SerialUSB.println(count4);
+ // These test the setPeriod auto-configure functionality
SerialUSB.println("-----------------------------------------------------");
SerialUSB.println("Testing setPeriod");
Timer4.setChannel1Mode(TIMER_OUTPUTCOMPARE);
@@ -163,6 +166,10 @@ void loop() {
SerialUSB.print("Count4: "); SerialUSB.println(count4);
SerialUSB.println("(should be around 2sec/30000ms ~ 67)");
+ // This section is to touch every channel of every timer. The output
+ // ratios should reflect the ratios of the rate variables. Demonstrates
+ // that over time the actual timing rates get blown away by other system
+ // interrupts.
for(t=0; t<4; t++) {
toggle ^= 1; digitalWrite(LED_PIN, toggle);
delay(100);