From b9fba8a471bc570a2c20283beb60a56e242dd49d Mon Sep 17 00:00:00 2001 From: bnewbold Date: Tue, 27 Apr 2010 18:48:00 -0400 Subject: updated test-session with new banner art etc --- examples/test-session.cpp | 227 +++++++++++++++++++++++++++++++++------------- 1 file changed, 163 insertions(+), 64 deletions(-) (limited to 'examples') diff --git a/examples/test-session.cpp b/examples/test-session.cpp index 0fa7d52..b760d97 100644 --- a/examples/test-session.cpp +++ b/examples/test-session.cpp @@ -22,14 +22,7 @@ * THE SOFTWARE. * ****************************************************************************/ -/** - * @file example_main.cpp - * - * @brief Sample main.cpp file. Blinks an LED, sends a message out USART2 - * and turns on PWM on pin 2 - */ - -#include "wiring.h" +#include "wirish.h" #include "HardwareSerial.h" #include "HardwareUsb.h" #include @@ -46,8 +39,9 @@ int toggle = 0; int rate = 0; int sample = 0; -// read off maple board rev3 +// read these off maple board rev3 const uint8 pwm_pins[] = {0,1,2,3,5,6,7,8,9,11,12,14,24,25,27,28}; +// note that 38 is just a button and 39+ aren't functional as of 04/22/2010 const uint8 adc_pins[] = {0,1,2,10,11,12,13,15,16,17,18,19,20,27,28}; #define NUM_GPIO 44 // 43 is the MAX uint8 gpio_state[NUM_GPIO]; @@ -63,20 +57,26 @@ void setup() { /* Set up the LED to blink */ pinMode(LED_PIN, OUTPUT); - /* Send a message out USART2 */ - //Serial2.begin(115200); + /* Send a message out over USART2 */ + //Serial2.begin(115200); // 9600 is more compatible Serial2.begin(9600); Serial2.println(""); + Serial2.println(" __ __ _ _"); + Serial2.println(" | \\/ | __ _ _ __ | | ___| |"); + Serial2.println(" | |\\/| |/ _` | '_ \\| |/ _ \\ |"); + Serial2.println(" | | | | (_| | |_) | | __/_|"); + Serial2.println(" |_| |_|\\__,_| .__/|_|\\___(_)"); + Serial2.println(" |_|"); + Serial2.println(" by leaflabs"); + Serial2.println(""); + Serial2.println(""); Serial2.println("Maple interactive test program (type '?' for help)"); Serial2.println("------------------------------------------------------------"); Serial2.print("> "); - /* Turn on PWM on pin PWM_PIN */ - //pinMode(PWM_PIN, PWM); - //pwmWrite(PWM_PIN, 0x8000); /* Send a message out the USB virtual com port */ // TODO: this should all be over usb as well - Usb.println("Maple test program starting; use serial port for interactivity"); + //Usb.println("Maple test program starting; use serial port for interactivity"); } void loop() { @@ -84,7 +84,6 @@ void loop() { digitalWrite(LED_PIN, toggle); delay(100); - //Serial2.flush(); while(Serial2.available()) { input = Serial2.read(); Serial2.println(input); @@ -95,8 +94,6 @@ void loop() { Serial2.println("spacebar, nice!"); break; case 63: // '?' - print_help(); - break; case 104: // 'h' print_help(); break; @@ -108,9 +105,63 @@ void loop() { Serial2.println("Hello World!"); Serial3.println("Hello World!"); break; + case 109: // 'm' + Serial2.println("Testing 57600 baud on USART1 and USART3. Press enter."); + Serial1.begin(57600); + Serial3.begin(57600); + while(!Serial2.available()) { + Serial1.println(DUMMY_DAT); + Serial3.println(DUMMY_DAT); + if(Serial1.available()) { + Serial1.println(Serial1.read()); + delay(1000); + } + if(Serial3.available()) { + Serial3.println(Serial3.read()); + delay(1000); + } + } + Serial2.read(); + Serial2.println("Testing 115200 baud on USART1 and USART3. Press enter."); + Serial1.begin(115200); + Serial3.begin(115200); + while(!Serial2.available()) { + Serial1.println(DUMMY_DAT); + Serial3.println(DUMMY_DAT); + if(Serial1.available()) { + Serial1.println(Serial1.read()); + delay(1000); + } + if(Serial3.available()) { + Serial3.println(Serial3.read()); + delay(1000); + } + } + Serial2.read(); + Serial2.println("Testing 9600 baud on USART1 and USART3. Press enter."); + Serial1.begin(9600); + Serial3.begin(9600); + while(!Serial2.available()) { + Serial1.println(DUMMY_DAT); + Serial3.println(DUMMY_DAT); + if(Serial1.available()) { + Serial1.println(Serial1.read()); + delay(1000); + } + if(Serial3.available()) { + Serial3.println(Serial3.read()); + delay(1000); + } + } + Serial2.read(); + Serial2.println("Resetting USART1 and USART3..."); + Serial1.begin(9600); + Serial3.begin(9600); + break; case 46: // '.' while(!Serial2.available()) { Serial2.print("."); + Usb.print("."); } //Serial2.flush(); break; @@ -118,8 +169,9 @@ void loop() { Serial2.println("Taking ADC noise stats..."); // turn off LED digitalWrite(LED_PIN, 0); - // make sure to skip the TX/RX pins - for(int i = 2; i 65500) rate = 0; - for(int i = 2; i 5734) rate = 4096; + for(uint32 i = 2; i