aboutsummaryrefslogtreecommitdiff
path: root/examples/test-dac.cpp
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-05-09 16:43:27 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-05-09 16:49:08 -0400
commitb8b2607ad117822f5eba4224965cbf0456ac8a0d (patch)
tree8bcf39c3c32905f6aaf64e4b7199c1edd1c7f752 /examples/test-dac.cpp
parent5df53a5274cb29fd66aecdbb06f49c1d0369476d (diff)
parenta00029e1325393d779bd5294efc86a990ba0521b (diff)
Merge branch 'refactor'
This merges the libmaple refactor work into master. The contents of libmaple proper (/libmaple/) are almost completely incompatible with previous APIs in master. See /docs/source/libmaple/overview.rst for more information on the new design. Wirish incompatibilities are limited to the HardwareTimer class; however, there are several new deprecations, most likely to be removed in 0.1.0.
Diffstat (limited to 'examples/test-dac.cpp')
-rw-r--r--examples/test-dac.cpp96
1 files changed, 51 insertions, 45 deletions
diff --git a/examples/test-dac.cpp b/examples/test-dac.cpp
index 3a699e2..40ae5d5 100644
--- a/examples/test-dac.cpp
+++ b/examples/test-dac.cpp
@@ -1,45 +1,51 @@
-
-#include "wirish.h"
-#include "fsmc.h"
-#include "rcc.h"
-#include "gpio.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();
- Serial1.println("Done.");
-}
-
-void loop() {
- toggleLED();
- delay(100);
-
- count += 100;
- if(count > 4095) {
- count = 0;
- }
-
- dac_write(1, 2048);
- dac_write(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, HIGH);
+
+ 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);
+}
+
+__attribute__((constructor)) void premain() {
+ init();
+}
+
+int main(void) {
+ setup();
+
+ while (true) {
+ loop();
+ }
+ return 0;
+}
+