aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-05-06 20:11:48 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-05-06 20:11:48 -0400
commitf432df24764cee2f7d1590650eeac4f3a121f25e (patch)
treea375dd09f399aa7f695c16542ff7a64fae25aff6
parent6765e0eaf8da078195373e297acc9dff6dde7b9e (diff)
downloadlibrambutan-f432df24764cee2f7d1590650eeac4f3a121f25e.tar.gz
librambutan-f432df24764cee2f7d1590650eeac4f3a121f25e.zip
Updating VGA examples for use with new timer API.
-rw-r--r--examples/vga-leaf.cpp42
-rw-r--r--examples/vga-scope.cpp18
2 files changed, 31 insertions, 29 deletions
diff --git a/examples/vga-leaf.cpp b/examples/vga-leaf.cpp
index e663639..f31dc87 100644
--- a/examples/vga-leaf.cpp
+++ b/examples/vga-leaf.cpp
@@ -102,6 +102,8 @@ uint32 logo[y_max][x_max] = {
{0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,}, };
+HardwareTimer timer(4);
+
void setup() {
// Setup our pins
pinMode(BOARD_LED_PIN, OUTPUT);
@@ -132,25 +134,25 @@ void setup() {
systick_disable();
// Configure
- Timer4.pause(); // while we configure
- Timer4.setPrescaleFactor(1); // Full speed
- Timer4.setChannel1Mode(TIMER_OUTPUTCOMPARE);
- Timer4.setChannel2Mode(TIMER_OUTPUTCOMPARE);
- Timer4.setChannel3Mode(TIMER_OUTPUTCOMPARE);
- Timer4.setChannel4Mode(TIMER_OUTPUTCOMPARE);
- Timer4.setOverflow(2287); // Total line time
-
- Timer4.setCompare1(200);
- Timer4.attachCompare1Interrupt(isr_porch);
- Timer4.setCompare2(300);
- Timer4.attachCompare2Interrupt(isr_start);
- Timer4.setCompare3(2170);
- Timer4.attachCompare3Interrupt(isr_stop);
- Timer4.setCompare4(1); // Could be zero I guess
- Timer4.attachCompare4Interrupt(isr_update);
-
- Timer4.setCount(0); // Ready...
- Timer4.resume(); // Go!
+ timer.pause(); // while we configure
+ timer.setPrescaleFactor(1); // Full speed
+ timer.setMode(TIMER_CH1, TIMER_OUTPUT_COMPARE);
+ timer.setMode(TIMER_CH2, TIMER_OUTPUT_COMPARE);
+ timer.setMode(TIMER_CH3, TIMER_OUTPUT_COMPARE);
+ timer.setMode(TIMER_CH4, TIMER_OUTPUT_COMPARE);
+ timer.setOverflow(2287); // Total line time
+
+ timer.setCompare(TIMER_CH1, 200);
+ timer.attachInterrupt(TIMER_CH1, isr_porch);
+ timer.setCompare(TIMER_CH2, 300);
+ timer.attachInterrupt(TIMER_CH2, isr_start);
+ timer.setCompare(TIMER_CH3, 2170);
+ timer.attachInterrupt(TIMER_CH3, isr_stop);
+ timer.setCompare(TIMER_CH4, 1); // Could be zero, I guess
+ timer.attachInterrupt(TIMER_CH4, isr_update);
+
+ timer.setCount(0); // Ready...
+ timer.resume(); // Go!
}
void loop() {
@@ -203,7 +205,7 @@ void isr_start(void) {
for (x = 0; x < 16; x++) {
// setting the color several times is just an easy way to
// delay, so the image is wider. if you only do the following
- // once, you'll be able to make the logo array a lot wider:
+ // once, you'll be able to make the logo array bigger:
VGA_COLOR(logo[logo_y][x]);
VGA_COLOR(logo[logo_y][x]);
VGA_COLOR(logo[logo_y][x]);
diff --git a/examples/vga-scope.cpp b/examples/vga-scope.cpp
index 9aa8bcb..b5fa8a5 100644
--- a/examples/vga-scope.cpp
+++ b/examples/vga-scope.cpp
@@ -76,7 +76,7 @@
// set has priority, so clear every bit and set some given bits:
#define VGA_COLOR(c) (*ABSRR = c | \
- BIT(RBIT+16) | BIT(GBIT+16) | BIT(BBIT+16))
+ BIT(RBIT + 16) | BIT(GBIT + 16) | BIT(BBIT + 16))
#define VGA_V_HIGH *ABSRR = BIT(6)
#define VGA_V_LOW *ABRR = BIT(6)
@@ -116,15 +116,15 @@ void setup() {
timer_pause(TIMER4);
timer_set_prescaler(TIMER4, 0);
- timer_set_mode(TIMER4, 1, TIMER_OUTPUTCOMPARE);
- timer_set_mode(TIMER4, 2, TIMER_OUTPUTCOMPARE);
- timer_set_mode(TIMER4, 3, TIMER_OUTPUTCOMPARE);
- timer_set_mode(TIMER4, 4, TIMER_OUTPUTCOMPARE);
+ timer_set_mode(TIMER4, 1, TIMER_OUTPUT_COMPARE);
+ timer_set_mode(TIMER4, 2, TIMER_OUTPUT_COMPARE);
+ timer_set_mode(TIMER4, 3, TIMER_OUTPUT_COMPARE);
+ timer_set_mode(TIMER4, 4, TIMER_OUTPUT_COMPARE);
timer_set_reload(TIMER4, 2287);
- timer_set_compare_value(TIMER4, 1, 200);
- timer_set_compare_value(TIMER4, 2, 250);
- timer_set_compare_value(TIMER4, 3, 2170); // 2219 max...
- timer_set_compare_value(TIMER4, 4, 1);
+ timer_set_compare(TIMER4, 1, 200);
+ timer_set_compare(TIMER4, 2, 250);
+ timer_set_compare(TIMER4, 3, 2170); // 2219 max...
+ timer_set_compare(TIMER4, 4, 1);
timer_attach_interrupt(TIMER4, 1, isr_porch);
timer_attach_interrupt(TIMER4, 2, isr_start);
timer_attach_interrupt(TIMER4, 3, isr_stop);