Fork to see if I can get working

Dependencies:   BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated

Fork of xDotBridge_update_test20180823 by Matt Briggs

Files at this revision

API Documentation at this revision

Comitter:
Matt Briggs
Date:
Fri Feb 10 07:41:16 2017 -0700
Parent:
46:20c89e9e751d
Child:
48:bab9f747d9ed
Commit message:
Added test files

Changed in this revision

testLRRPins_20170209.bin Show annotated file Show diff for this revision Revisions of this file
xDotBridge/TESTS/autoLibs/testDs2408/testAPI.cpp Show annotated file Show diff for this revision Revisions of this file
xDotBridge/config.h Show annotated file Show diff for this revision Revisions of this file
xDotBridge/inc/CommProtocolPeerBrute.h Show annotated file Show diff for this revision Revisions of this file
xDotBridge/inc/DS2408.h Show annotated file Show diff for this revision Revisions of this file
xDotBridge/manualTest/testLRRPins/testLRRPins.cpp Show annotated file Show diff for this revision Revisions of this file
xDotBridge/src/BaseboardIO.cpp Show annotated file Show diff for this revision Revisions of this file
xDotBridge/src/main.cpp Show annotated file Show diff for this revision Revisions of this file
Binary file testLRRPins_20170209.bin has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xDotBridge/TESTS/autoLibs/testDs2408/testAPI.cpp	Fri Feb 10 07:41:16 2017 -0700
@@ -0,0 +1,116 @@
+/*
+ * testAPI.cpp
+ *
+ *  Created on: Feb 3, 2017
+ *      Author: mbriggs
+ */
+#include "mbed.h"
+#include "greentea-client/test_env.h"
+#include "unity.h"
+#include "utest.h"
+#include "rtos.h"
+
+// API under test
+#include "DS2408.h"
+
+#define __TEST__ 1
+
+using namespace utest::v1;
+
+OneWire OWMaster(I2C_SDA);
+uint8_t ds2408Addr[8];
+
+/**
+ * A test that the OneWire Device is on the bus.  If not all other tests will fail.
+ */
+void test_search() {
+    uint8_t result;
+    wait(1.0);
+    for (int i=0; i<5; i++) {
+        OWMaster.reset();
+        wait(1.0);
+        result = OWMaster.search(ds2408Addr);
+        if (result == 1) {
+            break;
+        }
+    }
+    TEST_ASSERT(result == 1);
+}
+
+/**
+ * Test the init function returns correctly
+ */
+void test_init() {
+    DS2408 ds2408(&OWMaster, ds2408Addr);
+    CmdResult result = ds2408.init();
+    TEST_ASSERT(result == cmdSuccess);
+}
+
+/**
+ * Checks that in idle state all the IOs are pulled up.
+ */
+void test_idle_state() {
+    DS2408 ds2408(&OWMaster, ds2408Addr);
+    CmdResult result;
+    result = ds2408.init();
+    TEST_ASSERT(result == cmdSuccess);
+
+    result = ds2408.pioLogicWrite(0xFF); // Leave all IOs high Z e.g. should float high
+    TEST_ASSERT_MESSAGE(result == cmdSuccess, "Error returned during write operation");
+
+    uint8_t val = 0;
+    result = ds2408.pioLogicRead(val);
+    TEST_ASSERT_MESSAGE(result == cmdSuccess, "Error returned during read operation");
+    TEST_ASSERT_MESSAGE(val == 0xFF, "Bits not correct");
+}
+
+/**
+ * This test walks a zero bit for ds2408.  Note this requires a ds2408 with all
+ * IOs pulled up since each will pulled low in sequence.
+ */
+void test_walk_the_zero() {
+    DS2408 ds2408(&OWMaster, ds2408Addr);
+    CmdResult result = ds2408.init();
+    TEST_ASSERT(result == cmdSuccess);
+
+    result = ds2408.pioLogicWrite(0xFF); // Leave all IOs high Z e.g. should float high
+    TEST_ASSERT_MESSAGE(result == cmdSuccess, "Error returned during write operation");
+
+    uint8_t readVal = 0;
+    result = ds2408.pioLogicRead(readVal);
+    TEST_ASSERT_MESSAGE(result == cmdSuccess, "Error returned during read operation");
+    TEST_ASSERT_MESSAGE(readVal == 0xFF, "Bits not correct");
+
+    uint8_t writeVal;
+    for (int i=0; i<8; i++) {
+        writeVal = ~(1 << i);
+        result = ds2408.pioLogicWrite(writeVal); // Leave all IOs high Z e.g. should float high
+        TEST_ASSERT_MESSAGE(result == cmdSuccess, "Error returned during write operation");
+
+        result = ds2408.pioLogicRead(readVal);
+        TEST_ASSERT_MESSAGE(result == cmdSuccess, "Error returned during read operation");
+        TEST_ASSERT_MESSAGE(readVal == writeVal, "Bits not correct");
+    }
+}
+
+
+utest::v1::status_t test_setup(const size_t number_of_cases) {
+    // Setup Greentea using a reasonable timeout in seconds
+    GREENTEA_SETUP(40, "default_auto");
+    return verbose_test_setup_handler(number_of_cases);
+}
+
+// Test cases
+Case cases[] = {
+    Case("Testing search", test_search),
+    Case("Testing init", test_init),
+    Case("Testing idle state", test_idle_state),
+    Case("Test walking the zero", test_walk_the_zero)
+};
+
+Specification specification(test_setup, cases);
+
+// Entry point into the tests
+int main() {
+    return !Harness::run(specification);
+}
--- a/xDotBridge/config.h	Thu Feb 02 22:51:59 2017 +0000
+++ b/xDotBridge/config.h	Fri Feb 10 07:41:16 2017 -0700
@@ -5,6 +5,7 @@
 #ifndef CONFIG_H_
 #define CONFIG_H_
 
+#define __TEST__ 1
 // These define which wireless bridge you are generating code for
 #define BRIDGE_TX_BRUTE 0
 
--- a/xDotBridge/inc/CommProtocolPeerBrute.h	Thu Feb 02 22:51:59 2017 +0000
+++ b/xDotBridge/inc/CommProtocolPeerBrute.h	Fri Feb 10 07:41:16 2017 -0700
@@ -11,7 +11,6 @@
 #include "mDot.h"
 
 // TODO make base class to allow different protocols to be used with easy
-// TODO define how multiple RX would pair with a single TX
 // TODO wrap radio commands for error checking
 
 // TODO change to const
@@ -59,7 +58,7 @@
     CommProtocolPeerBrute();
 
     /**
-     * @brief Initialize radio for chosen mode of operation (i.e. RX or TX)
+     * @brief Initialize radio with stored network network settings
      *
      * @return Returns the result of all the commands
      */
--- a/xDotBridge/inc/DS2408.h	Thu Feb 02 22:51:59 2017 +0000
+++ b/xDotBridge/inc/DS2408.h	Fri Feb 10 07:41:16 2017 -0700
@@ -45,12 +45,9 @@
     /**
     * @brief init()
     *
-    * @details Just a placeholder for now
-    *
+    * @details Just a placeholder for now.  Does initiate a reset on the OneWire bus.
     *
     * On Entry:
-    *     @param[in] owMaster - reference to 1-wire master
-    *     @param[in] romAddr - 64-bit address of ROM
     *
     * On Exit:
     *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xDotBridge/manualTest/testLRRPins/testLRRPins.cpp	Fri Feb 10 07:41:16 2017 -0700
@@ -0,0 +1,147 @@
+#include "mbed.h"
+#include <string>
+
+const uint8_t TIMEOUT = 120; // In seconds
+
+/**
+ * FIXME - This needs a lot of help
+ */
+
+DigitalOut gpio0(GPIO0);
+DigitalOut gpio1(GPIO1);
+DigitalOut gpio2(GPIO2);
+DigitalOut gpio3(GPIO3);
+DigitalOut wake_DOUT(WAKE);
+DigitalOut i2cOut1(I2C1_SCL);
+DigitalOut i2cOut2(I2C1_SDA);
+
+DigitalOut uartCts(UART1_CTS);
+DigitalOut uartRts(UART1_RTS);
+DigitalOut uartTx(UART1_TX);
+DigitalOut uartRx(UART1_RX);
+
+DigitalOut mosi(SPI_MOSI);
+DigitalOut sck(SPI_SCK);
+
+DigitalOut nss(SPI_NSS, 1); // if low then miso on the flash becomes output
+DigitalInOut miso(SPI_MISO, PIN_INPUT, PullNone, 0);
+
+Serial pc(USBTX, USBRX); // Externally defined
+
+const static std::string PIN_NAMES [] = {
+       "Pin  2: UART_TX ", // Idx  0
+       "Pin  3: UART_RX ", // Idx  1
+       "Pin  4: MISO    ", // Idx  2
+       "Pin  6: SCL     ", // Idx  3
+       "Pin  7: SDA     ", // Idx  4
+       "Pin 11: MOSI    ", // Idx  5
+       "Pin 12: UART_CTS", // Idx  6
+       "Pin 13: WAKE    ", // Idx  7
+       "Pin 15: GPIO2   ", // Idx  8
+       "Pin 16: UART_RTS", // Idx  9
+       "Pin 17: NSS     ", // Idx 10
+       "Pin 18: SCK     ", // Idx 11
+       "Pin 19: GPIO1   ", // Idx 12
+       "Pin 20: GPIO3   "  // Idx 13
+};
+
+const uint8_t config0PinIdx[] = {0,1,  3,4,5,6,7,8,9,10,11,12,13};
+const uint8_t config1PinIdx[] = {0,1,2,3,4,5,6,7,8,9,   11,12,13};
+
+class MenuManager
+{
+private:
+    uint8_t mCurrSel; // Current selection
+    bool validInput(uint8_t in) {
+        return in <= 1; // Either 0, 1
+    }
+public:
+    MenuManager() {
+        mCurrSel = 0;
+    }
+    uint8_t getCurrentSel() {
+        return mCurrSel;
+    }
+    void applyInput(uint8_t in) {
+        if (validInput(in)) {
+            mCurrSel = in;
+        }
+    }
+    void printMenu() {
+        pc.printf("===============================================\r\n");
+        pc.printf("= LRR I/O Tester                              =\r\n");
+        pc.printf("===============================================\r\n");
+        pc.printf("= Option 0: MISO Disabled, NSS Enabled        =\r\n");
+        pc.printf("= Option 1: MISO Enabled,  NSS Disabled       = \r\n");
+        pc.printf("= Current Selection is %d                      =\r\n", mCurrSel);
+        pc.printf("===============================================\r\n");
+        pc.printf("= Details:                                    =\r\n");
+        if (mCurrSel == 0) {
+            pc.printf("= The following pins are toggling:            =\r\n");
+            pc.printf("= Pin #: Name                                 =\r\n");
+            for (unsigned int i=0; i < sizeof(config0PinIdx); i++) {
+                pc.printf("= %s                            =\r\n", PIN_NAMES[i].c_str());
+            }
+        }
+        else if (mCurrSel == 1) {
+            pc.printf("= The following pins are toggling:            =\r\n");
+            pc.printf("= Pin #: Name                                 =\r\n");
+            for (unsigned int i=0; i < sizeof(config1PinIdx); i++) {
+                pc.printf("= %s                            =\r\n", PIN_NAMES[i].c_str());
+            }
+        }
+        pc.printf("===============================================\r\n");
+    }
+};
+
+/**
+ * Checks that in idle state all the IOs are pulled up.
+ */
+//void menu_loop () {
+int main ()
+{
+    pc.baud(115200);
+
+    MenuManager menuMgr;
+    menuMgr.printMenu();
+
+    while (true) {
+        gpio0 = !gpio0;
+        gpio1 = !gpio1;
+        gpio2 = !gpio2;
+        gpio3 = !gpio3;
+        wake_DOUT = !wake_DOUT;
+        i2cOut1 = !i2cOut1;
+        i2cOut2 = !i2cOut2;
+
+        uartCts = !uartCts;
+        uartRts = !uartRts;
+        uartTx = !uartTx;
+        uartRx = !uartRx;
+
+        mosi = !mosi;
+        sck = !sck;
+
+        if (menuMgr.getCurrentSel() == 0) {
+            miso.input();
+            nss = !nss;
+        }
+        else if (menuMgr.getCurrentSel() == 1) {
+            nss = 1; // Disable flash
+            miso.output();
+            miso = !miso;
+        }
+
+        if (pc.readable()) {
+            char menuInput = pc.getc();
+            menuInput -= '0'; // Convert to raw interger value
+            menuMgr.applyInput(menuInput);
+            menuMgr.printMenu();
+        }
+        else {
+            pc.printf("*");
+        }
+        wait(1.0);
+    }
+    return 0;
+}
--- a/xDotBridge/src/BaseboardIO.cpp	Thu Feb 02 22:51:59 2017 +0000
+++ b/xDotBridge/src/BaseboardIO.cpp	Fri Feb 10 07:41:16 2017 -0700
@@ -8,7 +8,7 @@
 #include "BaseboardIO.h"
 #include "MTSLog.h"
 
-const float coilOnTime = 0.030; // 30 ms
+const float COIL_ON_TIME = 0.030; // 30 ms
 
 // Port expander 0
 const uint8_t pEx0232En     = 0x01;
@@ -57,16 +57,15 @@
 }
 CmdResult BaseboardIO::init()
 {
-    logError("Not implemented yet!!!");
     // Setup port expanders
-    CmdResult result = readInfoFromNVM();
-    if (result == cmdSuccess) {
+    if (readInfoFromNVM() == cmdSuccess) {
         // Values stored just read them foo
         logError("Not implemented yet!!!");
     }
-    else { // EEPROM values not there or corrupt
-        result = identifyPortExpanders(); // Get ROM addresses
-        if (result != cmdSuccess) {
+    else { // EEPROM values not there or corrupt.  Should only happen in factory.
+        // Find ROM address and test which one is which.  Requires user
+        // switches to be in known state.
+        if (identifyPortExpanders() != cmdSuccess) {
             logError("Error identifying port expanders");
             return cmdError;
         }
@@ -75,6 +74,15 @@
     mPortEx1 = new DS2408(&mOWMaster, mPortExpanderROM1);
 
     // Put relay in known state
+    if (relayNormal() != cmdSuccess) {
+        logError("Error setting relay during init");
+        return cmdError;
+    }
+
+    if (sampleUserSwitches() != cmdSuccess) {
+        logError("Error sampling user switches");
+        return cmdError;
+    }
 
     logInfo("Baseboard IO initialization successful");
     return cmdSuccess;
@@ -249,6 +257,7 @@
     // Search Bus
     logInfo("Starting OneWire Search");
     int i=0;
+    mOWMaster.reset();
     while (true) {
         // TODO maybe change to family based search
         result = mOWMaster.search(addr);
@@ -263,6 +272,7 @@
             std::memcpy(mPortExpanderROM1, addr, sizeof(mPortExpanderROM1));
         }
         i++;
+        // TODO maybe only allow a reasonable number of Port Expanders
     }
 
     logInfo("Finished OneWire Search");
@@ -327,7 +337,7 @@
         return cmdError;
     }
 
-    wait(coilOnTime);
+    wait(COIL_ON_TIME);
 
     val &= ~pEx1RlyA; // Turn Relay A off
     val &= ~pEx1RlyB; // Turn Relay B off
@@ -355,7 +365,7 @@
         return cmdError;
     }
 
-    wait(coilOnTime);
+    wait(COIL_ON_TIME);
 
     val &= ~pEx1RlyA; // Turn Relay A off
     val &= ~pEx1RlyB; // Turn Relay B off
--- a/xDotBridge/src/main.cpp	Thu Feb 02 22:51:59 2017 +0000
+++ b/xDotBridge/src/main.cpp	Fri Feb 10 07:41:16 2017 -0700
@@ -3,59 +3,28 @@
 #include "xdot_flash.h"
 #include "dot_util.h"
 #include "RadioEvent.h"
-#include "W25X40BV.h"
-#include "BaseboardIO.h"
+#include "WinbondSPIFlash.h"
 //#include <xdot_low_power.h>
 
+#include "BaseboardIO.h"
 #include "CommProtocolPeerBrute.h"
 
-///////////////////////
-// I/O Configuration //
-///////////////////////
-DigitalOut led1(GPIO0);
-//AnalogIn an1(GPIO1);
-//AnalogIn an2(GPIO2);
-
-// Inputs
-InterruptIn intTest(GPIO1);  // Works.  Be careful of which pins are interrupts.
-//DigitalIn gpio3(GPIO3);
-//DigitalIn wake_DOUT(WAKE);
-//DigitalIn i2cOut1(I2C1_SCL);
-//DigitalIn i2cOut2(I2C1_SDA);
-//DigitalIn uartOut1(UART1_CTS);
-//DigitalIn uartOut2(UART1_RTS);
-//DigitalIn jtag_gpio1(SWDIO);
-//DigitalIn jtag_gpio2(SWCLK);
-
-// Outputs
-//DigitalOut gpio3(GPIO3);
-////DigitalOut wake_DOUT(WAKE);
-//DigitalOut i2cOut1(I2C1_SCL);
-//DigitalOut i2cOut2(I2C1_SDA);
-//
-//DigitalOut uartOut1(UART1_CTS);
-//DigitalOut uartOut2(UART1_RTS);
-
-mDot* dot = NULL;
-
+#ifndef __TEST__ // Exclude code for tests
 Serial pc(USBTX, USBRX);
 
-unsigned int callbackCnt = 0;
-static void testCallback () {
-//    callbackCnt = us_ticker_read();
-    callbackCnt++;
-}
+mDot* dot = NULL; // Used by dot-utils
 
 int main() {
+    CommProtocolPeerBrute protocol;
     BaseboardIO bbio;
     RadioEvent events;  // Custom event handler for automatically displaying RX data
-    W25X40BV flash(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_NSS);
+    WinbondSPIFlash flash(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_NSS);
 //    flash.frequency(48e6); // TODO try overridding for faster freq (Default 1MHz)
 
     pc.baud(115200);
 
     mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL);
-    
+
     dot = mDot::getInstance();
 
     logInfo("mbed-os library version: %d", MBED_LIBRARY_VERSION);
@@ -89,7 +58,6 @@
 
     // TODO setup IO here
 
-    CommProtocolPeerBrute protocol; // TX
 #if BRIDGE_TX_BRUTE
     protocol.setTx(true);
 #else
@@ -110,201 +78,68 @@
 
     uint16_t seqNum=0;
 
-    // mbed-os Interrupt setup
-    intTest.mode(PullUp);
-    intTest.fall(&testCallback);
-    intTest.enable_irq(); // TODO check if this is useful
-
-//    dot->setWakePin(GPIO2); // This works but disables the wake button
-
-    // Using xdot hal libs
-//int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id)
-//    gpio_irq_init();
-
-    // Try the STM32 way
-//    //EXTI structure to init EXT
-//    EXTI_InitTypeDef EXTI_InitStructure;
-//    //NVIC structure to set up NVIC controller
-//    NVIC_InitTypeDef NVIC_InitStructure;
-//    //Connect EXTI Line to Button Pin
-////    GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0);
-//    GPIO_EXTILineConfig(STM_PORT(GPIO2), STM_PIN(GPIO2));
-//    //Configure Button EXTI line
-//    EXTI_InitStructure.EXTI_Line = EXTI_Line0;
-//    //select interrupt mode
-//    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
-//    //generate interrupt on rising edge
-//    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
-//    //enable EXTI line
-//    EXTI_InitStructure.EXTI_LineCmd = ENABLE;
-//    //send values to registers
-//    EXTI_Init(&EXTI_InitStructure);
-//    //configure NVIC
-//    //select NVIC channel to configure
-//    NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
-//    //set priority to lowest
-//    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
-//    //set subpriority to lowest
-//    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
-//    //enable IRQ channel
-//    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
-//    //update NVIC registers
-//    NVIC_Init(&NVIC_InitStructure);
-
+    /**
+     * Main Loop
+     */
     while (true) {
         std::vector<uint8_t> data;
-        led1=0;
+        bbio.ledOff();
+
+		if (protocol.isTx()) {
+#if LED_FEEDBACK
+		    bbio.ledOn();
+#endif
+            // TODO check for CC_IN
+
+            data.push_back((seqNum >> 8) & 0xFF);
+            data.push_back(seqNum & 0xFF);
+            protocol.send(data);
+            seqNum++;
+
+#if LED_FEEDBACK
+            bbio.ledOff();
+#endif
+            sleep_save_io();
+            sleep_configure_io();
+            dot->sleep(0, mDot::INTERRUPT, false);  // Go to sleep until wake button
+            sleep_restore_io();
+		}
 
-//		if (protocol.isTx()) {
-//#if LED_FEEDBACK
-//            led1=1;
-//#endif
-//            // TODO check for CC_IN
-//
-//            data.push_back((seqNum >> 8) & 0xFF);
-//            data.push_back(seqNum & 0xFF);
-//            protocol.send(data);
-//            seqNum++;
-//
-//#if LED_FEEDBACK
-//            led1=0;
-//#endif
-//            sleep_save_io();
-//            sleep_configure_io();
-//            dot->sleep(0, mDot::INTERRUPT, false);  // Go to sleep until wake button
-//            sleep_restore_io();
-//		}
-//
-//		if (protocol.isRx()) {
-//		    bool msgPending;
-//		    protocol.listen(msgPending);
-//		    if (msgPending) {
-//		        protocol.recv(data);
-//                std::string dataStr(data.begin(), data.end());
-//                logInfo("Got msg num: %d, payload: %s", seqNum, dataStr.c_str());
-//                // TODO add CC_OUT code here
-//                seqNum++;
-//#if LED_FEEDBACK
-//                led1 = 1;
-//                wait(0.5);
-//#endif
-//		    }
-//            led1=0;
-//            logInfo("Sleeping.  Time %d", us_ticker_read());
-//            sleep_save_io();
-//            sleep_configure_io();
-//            // TODO maybe add if statement here to prevent double hits by sleeping for a longer time
-//            dot->sleep(2, mDot::RTC_ALARM_OR_INTERRUPT, false);  // Go to sleep until wake button
-//            sleep_restore_io();
-//		}
+		if (protocol.isRx()) {
+		    bool msgPending;
+		    protocol.listen(msgPending);
+		    if (msgPending) {
+		        protocol.recv(data);
+                std::string dataStr(data.begin(), data.end());
+                logInfo("Got msg num: %d, payload: %s", seqNum, dataStr.c_str());
+                // TODO add CC_OUT code here
+                seqNum++;
+#if LED_FEEDBACK
+                bbio.ledOn();
+                wait(0.5);
+#endif
+		    }
+            bbio.ledOff();
+            logInfo("Sleeping.  Time %d", us_ticker_read());
+            sleep_save_io();
+            sleep_configure_io();
+            // TODO maybe add if statement here to prevent double hits by sleeping for a longer time
+            dot->sleep(2, mDot::RTC_ALARM_OR_INTERRUPT, false);  // Go to sleep until wake button
+            sleep_restore_io();
+		}
 
-        //////////////
-        // I/O Play //
-        //////////////
-
-        // Check interrupt
-        logInfo("Callback last called @ %d", callbackCnt);
-
-//        // Check Analog
-//        logInfo("Read AN1/GPIO1: %f", an1.read());
-//        logInfo("Read AN2/GPIO2: %f", an2.read()); // Ranges from 0.0 to 1.0
-//
-//        // check inputs
-//        logInfo("Read GPIO3: %d", gpio3.read());
-////        logInfo("Read wake_DOUT: %d", wake_DOUT.read());
-//        logInfo("Read i2cOut1: %d", i2cOut1.read()); // Appears to be pulled up
-//        logInfo("Read i2cOut2: %d", i2cOut2.read()); // Appears to be pulled up
-//        logInfo("Read uartOut1: %d", uartOut1.read());
-//        logInfo("Read uartOut2: %d", uartOut2.read());
-//
-//        logInfo("Read jtag_gpio1: %d", jtag_gpio1.read());
-//        logInfo("Read jtag_gpio2: %d", jtag_gpio2.read());
-//
-//        if (jtag_gpio1.read() == 0) {
-//        	led1 = 1;
-//        }
-//        else {
-//        	led1 = 0;
-//        }
-
-        // check digital outputs
-//		led1 = !led1;
-//		gpio3 = !gpio3;
-////		wake_DOUT = !wake_DOUT;
-//		i2cOut1 = !i2cOut1;
-//		i2cOut2 = !i2cOut2;
-//
-//		uartOut1 = !uartOut1;
-//		uartOut2 = !uartOut2;
 
         logInfo("================================");
         wait(1.0);
+        // Need to re-implement some of these sleep functions
 //		sleep_save_io();
 //		sleep_configure_io();
-//        __GPIOA_CLK_ENABLE();
-//        __GPIOB_CLK_ENABLE();
-//        __GPIOC_CLK_ENABLE();
-//        __GPIOH_CLK_ENABLE();
-
-        dot->sleep(2, mDot::INTERRUPT, false);  // Go to sleep until wake button
-        //////////////////
-        // OneWire Play //
-        //////////////////
 
-//        logInfo("Starting OneWire Play");
-//        OneWire owMaster(I2C_SDA);
-//        uint8_t addr[8];
-//        uint8_t result;
-//
-//        // Search Bus
-//        logInfo("Starting OneWire Search");
-//        do {
-//            result = owMaster.search(addr);
-//            logInfo("ROM Addr: %02x:%02x:%02x:%02x:%02x:%02x:%02x%02x\n",
-//                    addr[7],addr[6],addr[5],addr[4],addr[3],addr[2],addr[1],addr[0]);
-//        } while (result == 1);
-//        logInfo("Finished OneWire Search");
-//        wait(1.0);
-//
-//        uint8_t pioStateAddr[] = {0x88, 0x00};
-//        uint8_t pioLatchAddr[] = {0x89, 0x00};
-//        uint8_t printAddr = 0x88;
-//        while (true) {
-//            owMaster.reset();
-//            owMaster.select(addr);
-//            owMaster.write(0xF0); // Read Register Command
-//            owMaster.write_bytes(pioStateAddr, 2); // Write 2 byte addr
-//            printAddr = 0x88;
-//            for (int i=0;i<8;i++) {
-//                result = owMaster.read();
-//                logInfo("%02x Reg Value: %02x\n", printAddr++, result);
-//            }
-//
-//            owMaster.reset();
-//            owMaster.select(addr);
-//            owMaster.write(0xF0); // Read Register Command
-//            owMaster.write_bytes(pioLatchAddr, 2); // Write 2 byte addr
-//            result = owMaster.read();
-//            logInfo("Latch Reg Value: %02x\n", result);
-//            // TODO try reading inverted 16-bit CRC
-//
-//            wait(1.0);
-//            // Try write
-//            owMaster.reset();
-//            owMaster.select(addr);
-//            owMaster.write(0x5A); // Channel Access Write Command
-//            uint8_t val = ~0xAA;
-//            owMaster.write(val); // Pull-down all even bits
-//            owMaster.write(~val); // Pull-down all even bits
-//            result = owMaster.read();
-//            logInfo("Confirm after write value: %02x, expected %02x\n", result, 0xAA);
-//
-//            // Check if the read back is just a latch reg thing or a true logic state
-//            wait(1.0);
-//        }
+//        dot->sleep(2, mDot::INTERRUPT, false);  // Go to sleep until wake button
     }
- 
+
     return 0;
 }
+#endif