aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-04-21 17:24:57 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-04-21 17:24:57 -0400
commitd64c13caf100c7fa638596bd568cce3ce2ffce0a (patch)
treeebb5a3c31726f514403374792571b3d3a6fedb8d /examples
parent7fdb4c986452756801eb8ba5eec94f9823e0b1c0 (diff)
downloadlibrambutan-d64c13caf100c7fa638596bd568cce3ce2ffce0a.tar.gz
librambutan-d64c13caf100c7fa638596bd568cce3ce2ffce0a.zip
Requiring dac_dev* argument in DAC convenience functions.
Diffstat (limited to 'examples')
-rw-r--r--examples/test-dac.cpp89
1 files changed, 48 insertions, 41 deletions
diff --git a/examples/test-dac.cpp b/examples/test-dac.cpp
index af98030..ba766a4 100644
--- a/examples/test-dac.cpp
+++ b/examples/test-dac.cpp
@@ -1,41 +1,48 @@
-#include "wirish.h"
-#include "dac.h"
-
-uint16 count = 0;
-
-void setup() {
-
- pinMode(BOARD_LED_PIN, OUTPUT);
- digitalWrite(BOARD_LED_PIN,1);
-
- Serial1.begin(9600);
- Serial1.println("**** Beginning DAC test");
-
- Serial1.print("Init... ");
- dac_init(DAC_CH1 | DAC_CH2);
- Serial1.println("Done.");
-}
-
-void loop() {
- toggleLED();
- delay(100);
-
- count += 100;
- if(count > 4095) {
- count = 0;
- }
-
- dac_write_channel(1, 4095 - count);
- dac_write_channel(2, count);
-}
-
-int main(void) {
- init();
- setup();
-
- while (1) {
- loop();
- }
- return 0;
-}
-
+/*
+ * Simple DAC test.
+ *
+ * Author: Marti Bolivar <mbolivar@leaflabs.com>
+ *
+ * This file is released into the public domain.
+ */
+
+#include "wirish.h"
+#include "dac.h"
+
+uint16 count = 0;
+
+void setup() {
+ pinMode(BOARD_LED_PIN, OUTPUT);
+ digitalWrite(BOARD_LED_PIN,1);
+
+ Serial1.begin(9600);
+ Serial1.println("**** Beginning DAC test");
+
+ Serial1.print("Init... ");
+ dac_init(DAC, DAC_CH1 | DAC_CH2);
+ Serial1.println("Done.");
+}
+
+void loop() {
+ toggleLED();
+ delay(100);
+
+ count += 100;
+ if (count > 4095) {
+ count = 0;
+ }
+
+ dac_write_channel(DAC, 1, 4095 - count);
+ dac_write_channel(DAC, 2, count);
+}
+
+int main(void) {
+ init();
+ setup();
+
+ while (1) {
+ loop();
+ }
+ return 0;
+}
+