Raspberry Pi MOT HAT Based on STM32F030R8. The clock needs to be changed to 8MHz after export.

Dependencies:   mbed

Revision:
3:171f4d0ca77b
Parent:
2:cff0fa966e58
Child:
4:fb5235d39a9c
--- a/AplicationLayer/SelfTest.cpp	Tue Aug 18 11:03:37 2015 +0000
+++ b/AplicationLayer/SelfTest.cpp	Thu Aug 20 11:36:01 2015 +0000
@@ -2,25 +2,25 @@
 
 void SpeedTest(void)
 {
-    printf("[Speed Test]\n\rMOT1 = %drpm, MOT2 = %drpm, MOT3 = %drpm, MOT4 = %drpm.\n\r", Mot_GetSpeed(1), Mot_GetSpeed(2), Mot_GetSpeed(3), Mot_GetSpeed(4));  
+    uart_db.printf("[Speed Test]\n\rMOT1 = %drpm, MOT2 = %drpm, MOT3 = %drpm, MOT4 = %drpm.\n\r", Mot_GetSpeed(1), Mot_GetSpeed(2), Mot_GetSpeed(3), Mot_GetSpeed(4));  
 }
 
 void VoltageTest(void)
 {
-    printf("[Voltage Test]\n\rVBAT = %.2fV, VDD12V = %.2fV, VDD5V = %.2fV, VDD3V3 = %.2fV.\n\r", Vmon_ReadVolt(1), Vmon_ReadVolt(2), Vmon_ReadVolt(3), Vmon_ReadVolt(4)); 
+    uart_db.printf("[Voltage Test]\n\rVBAT = %.2fV, VDD12V = %.2fV, VDD5V = %.2fV, VDD3V3 = %.2fV.\n\r", Vmon_ReadVolt(1), Vmon_ReadVolt(2), Vmon_ReadVolt(3), Vmon_ReadVolt(4)); 
 }
 
 void MotTest(void)
 {
     int dir, turn;
-    printf("\n\r==== Motor Test ====\n\r");
+    uart_db.printf("\n\r==== Motor Test ====\n\r");
     for(int i=0; i<100; i+=20)
     {
-        printf("\n\rMotor speed set to %d%%.\n\r", i);
-        printf("-->Motor will move forward.\n\r");
+        uart_db.printf("\n\rMotor speed set to %d%%.\n\r", i);
+        uart_db.printf("-->Motor will move forward.\n\r");
         dir = 'f';
         
-        printf("---->Motor will move straight.\n\r");
+        uart_db.printf("---->Motor will move straight.\n\r");
         turn = 'm';
         Mot_Ctrl(dir, turn, (float)i / 100.0);
         SpeedTest();
@@ -28,7 +28,7 @@
         LedToggle(0);
         wait(3);
         
-        printf("---->Motor will turn left.\n\r");
+        uart_db.printf("---->Motor will turn left.\n\r");
         turn = 'l';
         Mot_Ctrl(dir, turn, (float)i / 100.0);
         SpeedTest();
@@ -36,7 +36,7 @@
         LedToggle(0);
         wait(3);
         
-        printf("---->Motor will turn right.\n\r");
+        uart_db.printf("---->Motor will turn right.\n\r");
         turn = 'r';
         Mot_Ctrl(dir, turn, (float)i / 100.0);
         SpeedTest();
@@ -44,10 +44,10 @@
         LedToggle(0);
         wait(3);
         
-        printf("-->Motor will move forward.\n\r");
+        uart_db.printf("-->Motor will move forward.\n\r");
         dir = 'b';
         
-        printf("---->Motor will move straight.\n\r");
+        uart_db.printf("---->Motor will move straight.\n\r");
         turn = 'm';
         Mot_Ctrl(dir, turn, (float)i / 100.0);
         SpeedTest();
@@ -55,7 +55,7 @@
         LedToggle(0);
         wait(3);
         
-        printf("---->Motor will turn left.\n\r");
+        uart_db.printf("---->Motor will turn left.\n\r");
         turn = 'l';
         Mot_Ctrl(dir, turn, (float)i / 100.0);
         SpeedTest();
@@ -63,7 +63,7 @@
         LedToggle(0);
         wait(3);
         
-        printf("---->Motor will turn right.\n\r");
+        uart_db.printf("---->Motor will turn right.\n\r");
         turn = 'r';
         Mot_Ctrl(dir, turn, (float)i / 100.0);
         SpeedTest();
@@ -76,12 +76,10 @@
 void SelfTest(void)
 #if 1
 {
-    printf("Starting motor velocimeter...\n\r");
+    uart_db.printf("Starting motor velocimeter...\n\r");
     Mot_StartVelocimeter();
-    while(1)
-    {
-        MotTest();
-    }   
+    MotTest();
+    Mot_StopVelocimeter();
 }
 #elif
 {
@@ -113,4 +111,4 @@
         wait_ms(200);
     }      
 }
-#endif
\ No newline at end of file
+#endif