moved the system_reset function into libs/utils
authorLogxen <logxen@hotmail.com>
Thu, 14 Jun 2012 08:15:48 +0000 (01:15 -0700)
committerLogxen <logxen@hotmail.com>
Thu, 14 Jun 2012 08:15:48 +0000 (01:15 -0700)
src/libs/utils.cpp
src/libs/utils.h
src/modules/utils/simpleshell/SimpleShell.cpp

index 06b42fc..81d67cc 100644 (file)
@@ -5,7 +5,9 @@
       You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. 
 */
 
+#include "libs/Kernel.h"
 #include "libs/utils.h"
+#include "system_LPC17xx.h"
 using namespace std;
 #include <string>
 using std::string;
@@ -59,5 +61,13 @@ string get_arguments( string possible_command ){
     return possible_command.substr( beginning+1, possible_command.size() - beginning);
 }
 
-
+// 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;
+}
 
index d5966ea..7e06b58 100644 (file)
@@ -16,7 +16,7 @@ string shift_parameter( string &parameters );
 
 string get_arguments( string possible_command );
 
-
+void system_reset( void );
 
 
 
index d45488c..abf0576 100644 (file)
@@ -13,7 +13,6 @@
 #include "libs/SerialMessage.h"
 #include "libs/StreamOutput.h"
 #include "modules/robot/Player.h"
-#include "system_LPC17xx.h"
 
 
 void SimpleShell::on_module_loaded(){
@@ -126,13 +125,7 @@ void SimpleShell::play_command( string parameters, StreamOutput* stream ){
 // Reset the system
 void SimpleShell::reset_command( string parameters, StreamOutput* stream){
     stream->printf("Smoothie out. Peace.\r\n");
-
-    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;
+    system_reset();
 }
 
 void SimpleShell::on_main_loop(void* argument){