aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorajmeyer@mit.edu <ajmeyer@mit.edu@749a229e-a60e-11de-b98f-4500b42dc123>2009-12-27 09:17:32 +0000
committerajmeyer@mit.edu <ajmeyer@mit.edu@749a229e-a60e-11de-b98f-4500b42dc123>2009-12-27 09:17:32 +0000
commit5f423270cde82f9dfffb52bdd617e5eb439921c5 (patch)
treed13c1523b8011c8b4696fd7e7958cae133bfab3b
parentb6674cd738cc22e61ea34cb659750ef45ce01df4 (diff)
downloadlibrambutan-5f423270cde82f9dfffb52bdd617e5eb439921c5.tar.gz
librambutan-5f423270cde82f9dfffb52bdd617e5eb439921c5.zip
added a simpler main.cpp and moved the complicated stuff into a separate file
git-svn-id: https://leaflabs.googlecode.com/svn/trunk/library@88 749a229e-a60e-11de-b98f-4500b42dc123
-rw-r--r--src/example_main.cpp73
-rw-r--r--src/main.cpp54
2 files changed, 81 insertions, 46 deletions
diff --git a/src/example_main.cpp b/src/example_main.cpp
new file mode 100644
index 0000000..8c90b7d
--- /dev/null
+++ b/src/example_main.cpp
@@ -0,0 +1,73 @@
+#include "wiring.h"
+#include "HardwareSerial.h"
+#include "math.h"
+#include "usb.h"
+
+int ledPin = 13;
+uint8_t bytes_in;
+
+BootVectTable* mapleVect;
+
+void usb_tx_cb(void) {
+}
+
+void usb_rx_cb(void) {
+ bytes_in = usb_serialGetRecvLen();
+}
+
+void setup()
+{
+ pinMode(ledPin, OUTPUT);
+ Serial2.begin(9600);
+ Serial2.println("setup start");
+
+ pinMode(6, PWM);
+ pwmWrite(6, 0x8000);
+ pinMode(7, OUTPUT);
+
+ Serial2.println("setup end");
+
+ mapleVect = (BootVectTable*)(BOOTLOADER_VECT_TABLE);
+ mapleVect->serial_tx_cb = usb_tx_cb;
+ mapleVect->serial_rx_cb = usb_rx_cb;
+}
+
+
+int toggle = 0;
+
+const char* testMsg = "hello world!\n";
+
+static inline void loop() {
+ toggle ^= 1;
+ digitalWrite(ledPin, toggle);
+ delay(1000);
+ usb_serialWriteStr("blink...\n");
+
+ if (bytes_in > 0) {
+ int i;
+ for (i=0;i<bytes_in;i++) {
+ usb_serialWriteStr("b,");
+ }
+ bytes_in = 0;
+ usb_serialWriteStr("\n");
+ }
+}
+
+
+int main(void) {
+ init();
+ setup();
+
+ while (1) {
+ loop();
+ }
+ return 0;
+}
+
+/* Required for C++ hackery */
+/* TODO: This really shouldn't go here... move it later
+ * */
+extern "C" void __cxa_pure_virtual(void) {
+ while(1)
+ ;
+}
diff --git a/src/main.cpp b/src/main.cpp
index 8c90b7d..fd846ee 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4,56 +4,18 @@
#include "usb.h"
int ledPin = 13;
-uint8_t bytes_in;
-
-BootVectTable* mapleVect;
-
-void usb_tx_cb(void) {
-}
-
-void usb_rx_cb(void) {
- bytes_in = usb_serialGetRecvLen();
+int toggle=0;
+void setup() {
+ pinMode(ledPin,OUTPUT);
}
-void setup()
-{
- pinMode(ledPin, OUTPUT);
- Serial2.begin(9600);
- Serial2.println("setup start");
-
- pinMode(6, PWM);
- pwmWrite(6, 0x8000);
- pinMode(7, OUTPUT);
-
- Serial2.println("setup end");
-
- mapleVect = (BootVectTable*)(BOOTLOADER_VECT_TABLE);
- mapleVect->serial_tx_cb = usb_tx_cb;
- mapleVect->serial_rx_cb = usb_rx_cb;
+void loop() {
+ digitalWrite(ledPin,HIGH);
+ delay(200);
+ digitalWrite(ledPin,LOW);
+ delay(200);
}
-
-int toggle = 0;
-
-const char* testMsg = "hello world!\n";
-
-static inline void loop() {
- toggle ^= 1;
- digitalWrite(ledPin, toggle);
- delay(1000);
- usb_serialWriteStr("blink...\n");
-
- if (bytes_in > 0) {
- int i;
- for (i=0;i<bytes_in;i++) {
- usb_serialWriteStr("b,");
- }
- bytes_in = 0;
- usb_serialWriteStr("\n");
- }
-}
-
-
int main(void) {
init();
setup();