aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2010-08-07 20:29:37 -0400
committerbnewbold <bnewbold@robocracy.org>2010-08-07 20:29:37 -0400
commit7b391d7f76a2d56242420c560d65f00a60f78682 (patch)
tree8fb56b1ba9fb8fe557a5159407275ecfdd764e72 /examples
parent314846bee32479f8fd6aae46c508fdc7ff8e0a95 (diff)
downloadlibrambutan-7b391d7f76a2d56242420c560d65f00a60f78682.tar.gz
librambutan-7b391d7f76a2d56242420c560d65f00a60f78682.zip
basic working dac implementation
Diffstat (limited to 'examples')
-rw-r--r--examples/test-dac.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/examples/test-dac.cpp b/examples/test-dac.cpp
new file mode 100644
index 0000000..65496f4
--- /dev/null
+++ b/examples/test-dac.cpp
@@ -0,0 +1,53 @@
+
+#include "wirish.h"
+#include "fsmc.h"
+#include "rcc.h"
+#include "gpio.h"
+#include "dac.h"
+
+#define LED_PIN 23 // hack for maple native
+#define DISC_PIN 14 // hack for USB on native
+
+int toggle = 0;
+uint16 count = 0;
+
+void setup() {
+
+ pinMode(LED_PIN, OUTPUT);
+ pinMode(DISC_PIN, OUTPUT);
+ digitalWrite(DISC_PIN,1);
+ digitalWrite(LED_PIN,1);
+
+ Serial1.begin(9600);
+ Serial1.println("Hello World!");
+
+ Serial1.print("Init... ");
+ dac_init();
+ Serial1.println("Done.");
+}
+
+void loop() {
+ digitalWrite(LED_PIN, toggle);
+ toggle ^= 1;
+ 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;
+}
+