added reset to console comamnd to actually reset the chip, dfu still goes into boot...
authorJim Morris <morris@wolfman.com>
Mon, 25 Feb 2013 04:22:37 +0000 (20:22 -0800)
committerJim Morris <morris@wolfman.com>
Mon, 25 Feb 2013 04:25:49 +0000 (20:25 -0800)
src/libs/utils.cpp
src/libs/utils.h
src/modules/utils/simpleshell/SimpleShell.cpp
src/modules/utils/simpleshell/SimpleShell.h

index 58d3842..e89987f 100644 (file)
@@ -120,13 +120,17 @@ bool file_exists( const string file_name ){
     return exists;
 }
 
-// Prepares and executes a watchdog reset
-void system_reset( void ){
-    LPC_WDT->WDCLKSEL = 0x1;                // Set CLK src to PCLK
-    uint32_t clk = SystemCoreClock / 16;    // WD has a fixed /4 prescaler, PCLK default is /4
-    LPC_WDT->WDTC = 1 * (float)clk;         // Reset in 1 second
-    LPC_WDT->WDMOD = 0x3;                   // Enabled and Reset
-    LPC_WDT->WDFEED = 0xAA;                 // Kick the dog!
-    LPC_WDT->WDFEED = 0x55;
+// Prepares and executes a watchdog reset for dfu or reboot
+void system_reset( bool dfu ){
+       if(dfu) {
+               LPC_WDT->WDCLKSEL = 0x1;                // Set CLK src to PCLK
+               uint32_t clk = SystemCoreClock / 16;    // WD has a fixed /4 prescaler, PCLK default is /4
+               LPC_WDT->WDTC = 1 * (float)clk;         // Reset in 1 second
+               LPC_WDT->WDMOD = 0x3;                   // Enabled and Reset
+               LPC_WDT->WDFEED = 0xAA;                 // Kick the dog!
+               LPC_WDT->WDFEED = 0x55;
+       }else{
+               NVIC_SystemReset();
+       }
 }
 
index 23b2801..c950452 100644 (file)
@@ -29,7 +29,7 @@ string get_arguments( string possible_command );
 
 bool file_exists( const string file_name );
 
-void system_reset( void );
+void system_reset( bool dfu= false );
 
 
 
index e2097f1..2d44580 100644 (file)
@@ -45,7 +45,7 @@ void SimpleShell::on_console_line_received( void* argument ){
     else if (check_sum == reset_command_checksum)
         this->reset_command(get_arguments(possible_command),new_message.stream );
     else if (check_sum == dfu_command_checksum)
-        this->reset_command(get_arguments(possible_command),new_message.stream );
+        this->dfu_command(get_arguments(possible_command),new_message.stream );
        else if (check_sum == help_command_checksum)
                this->help_command(get_arguments(possible_command),new_message.stream );
 }
@@ -133,7 +133,13 @@ void SimpleShell::cat_command( string parameters, StreamOutput* stream ){
 // Reset the system
 void SimpleShell::reset_command( string parameters, StreamOutput* stream){
     stream->printf("Smoothie out. Peace.\r\n");
-    system_reset();
+    system_reset(false);
+}
+
+// go into dfu boot mode
+void SimpleShell::dfu_command( string parameters, StreamOutput* stream){
+       stream->printf("Entering boot mode...\r\n");
+       system_reset(true);
 }
 
 // Break out into the MRI debugging system
@@ -149,9 +155,11 @@ void SimpleShell::help_command( string parameters, StreamOutput* stream ){
        stream->printf("pwd\r\n");      
        stream->printf("cat file [limit]\r\n");
        stream->printf("play file [-q]\r\n");
-       stream->printf("progress\r\n");
-       stream->printf("abort\r\n");
-       stream->printf("reset\r\n");                    
+       stream->printf("progress - shows progress of current play\r\n");
+       stream->printf("abort - abort currently playing file\r\n");
+       stream->printf("reset - reset smoothie\r\n");                   
+       stream->printf("dfu - enter dfu boot loader\r\n");                      
+       stream->printf("break- break into debugger\r\n");                       
        stream->printf("config-get [<configuration_source>] <configuration_setting>\r\n");
        stream->printf("config-set [<configuration_source>] <configuration_setting> <value>\r\n");
        stream->printf("config-load [<file_name>]\r\n");
index d65564f..5ec1867 100644 (file)
@@ -37,6 +37,7 @@ class SimpleShell : public Module {
         void cat_command(  string parameters, StreamOutput* stream );
         void break_command(string parameters, StreamOutput* stream );
                void reset_command(string parameters, StreamOutput* stream );
+               void dfu_command(string parameters, StreamOutput* stream );
                void help_command(string parameters, StreamOutput* stream );
                
        private: