diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-02-18 04:00:00 -0500 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-02-18 04:00:00 -0500 |
commit | 0d440118bd4e1ba64f92d3636302fbddeac5bef6 (patch) | |
tree | da06d190cbcf54bdbe54ff484ac66ac924c3ce38 /examples | |
parent | 3f76591b3616c07c5a02624aff8649d5fa7e9f4b (diff) | |
download | librambutan-0d440118bd4e1ba64f92d3636302fbddeac5bef6.tar.gz librambutan-0d440118bd4e1ba64f92d3636302fbddeac5bef6.zip |
Basic DAC functionality (high-density devices only).
Diffstat (limited to 'examples')
-rw-r--r-- | examples/test-dac.cpp | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/examples/test-dac.cpp b/examples/test-dac.cpp index 65496f4..3a699e2 100644 --- a/examples/test-dac.cpp +++ b/examples/test-dac.cpp @@ -5,49 +5,41 @@ #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);
+ pinMode(BOARD_LED_PIN, OUTPUT);
+ digitalWrite(BOARD_LED_PIN,1);
- Serial1.begin(9600);
- Serial1.println("Hello World!");
+ Serial1.begin(9600);
+ Serial1.println("**** Beginning DAC test");
- Serial1.print("Init... ");
- dac_init();
- Serial1.println("Done.");
+ Serial1.print("Init... ");
+ dac_init();
+ Serial1.println("Done.");
}
void loop() {
- digitalWrite(LED_PIN, toggle);
- toggle ^= 1;
- delay(100);
-
- count += 100;
+ toggleLED();
+ delay(100);
- if(count > 4095) {
- count = 0;
- }
+ count += 100;
+ if(count > 4095) {
+ count = 0;
+ }
- dac_write(1, 2048);
- dac_write(2, count);
+ dac_write(1, 2048);
+ dac_write(2, count);
}
int main(void) {
- init();
- setup();
+ init();
+ setup();
- while (1) {
- loop();
- }
- return 0;
+ while (1) {
+ loop();
+ }
+ return 0;
}
|