Performance check program for LED blinky

Dependencies:   mbed-src

Fork of GR-PEACH_blinky by Kenji Arai

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Sun Nov 30 00:23:44 2014 +0000
Parent:
1:a399a743d109
Commit message:
performance check program

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r a399a743d109 -r d30b9b9467de main.cpp
--- a/main.cpp	Sat Nov 29 12:35:30 2014 +0000
+++ b/main.cpp	Sun Nov 30 00:23:44 2014 +0000
@@ -6,7 +6,7 @@
  *  http://www.page.sannet.ne.jp/kenjia/index.html
  *  http://mbed.org/users/kenjiArai/
  *      Created: November  29th, 2014
- *      Revised: November  29th, 2014
+ *      Revised: November  30th, 2014
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
@@ -15,132 +15,51 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+//  Include ---------------------------------------------------------------------------------------
 #include "mbed.h"
 
-//#define PIN_NUM
-#define LED_NAME
-//#define LED_COLOR
+//  Object ----------------------------------------------------------------------------------------
+Timer timer;
+DigitalOut myled(LED1);
 
-#if defined(PIN_NUM)
-DigitalOut myledR(P4_4);
-DigitalOut myledG(P3_2);
-DigitalOut myledB(P4_6);
-DigitalOut myledU(P4_7);
-#elif defined(LED_NAME)
-DigitalOut myledR(LED1);
-DigitalOut myledG(LED2);
-DigitalOut myledB(LED3);
-DigitalOut myledU(LED4);
-#elif defined(LED_COLOR)
-DigitalOut myledR(LED_RED);
-DigitalOut myledG(LED_GREEN);
-DigitalOut myledB(LED_BLUE);
-DigitalOut myledU(LED_USER);
-#endif
-
+//  Definition ------------------------------------------------------------------------------------
 #define ON  0
 #define OFF 1
 
-int main() {
-    uint32_t n = 0;
-    
-    printf("Start mbed program\r\n");
-    myledR = OFF;
-    printf("RF,");
-    myledG = OFF;
-    printf("GF,");
-    myledB = OFF;
-    printf("BF,");
-    myledU = ON;
-    printf("UN");
-    while(1) {
-        wait(5.0);
-        printf(" passed %4d Sec\r\n", n +=5);
-        printf("R=ON ,G=OFF,B=OFF ");
-        myledR = ON;
-        printf("RN,");
-        myledG = OFF;
-        printf("GF,");
-        myledB = OFF;
-        printf("BF,");
-        myledU = OFF;
-        printf("UF");
-        wait(5.0);
-        printf(" passed %4d Sec\r\n", n +=5);
-        printf("R=OFF,G=OFF,B=OFF ");
-        myledR = OFF;
-        printf("RF,");
-        myledG = OFF;
-        printf("GF,");
-        myledB = OFF;
-        printf("BF,");
-        myledU = ON;
-        printf("UN");
-        wait(5.0);
-        printf(" passed %4d Sec\r\n", n +=5);
-        printf("R=OFF,G=ON ,B=OFF ");
-        myledR = OFF;
-        printf("RF,");
-        myledG = ON;
-        printf("GN,");
-        myledB = OFF;
-        printf("BF,");
-        myledU = OFF;
-        printf("UF");
-        wait(5.0);
-        printf(" passed %4d Sec\r\n", n +=5);
-        printf("R=OFF,G=OFF,B=OFF ");
-        myledR = OFF;
-        printf("RF,");
-        myledG = OFF;
-        printf("GF,");
-        myledB = OFF;
-        printf("BF,");
-        myledU = ON;
-        printf("UN");
-        wait(5.0);
-        printf(" passed %4d Sec\r\n", n +=5);
-        printf("R=OFF,G=OFF,B=ON  ");
-        myledR = OFF;
-        printf("RF,");
-        myledG = OFF;
-        printf("GF,");
-        myledB = ON;
-        printf("BN,");
-        myledU = OFF;
-        printf("UF");
-        wait(5.0);
-        printf(" passed %4d Sec\r\n", n +=5);
-        printf("R=OFF,G=OFF,B=OFF ");
-        myledR = OFF;
-        printf("RF,");
-        myledG = OFF;
-        printf("GF,");
-        myledB = OFF;
-        printf("BF,");
-        myledU = ON;
-        printf("UN");
-        wait(5.0);
-        printf(" passed %4d Sec\r\n", n +=5);
-        printf("R=ON ,G=ON ,B=ON  ");
-        myledR = ON;
-        printf("RN,");
-        myledG = ON;
-        printf("GN,");
-        myledB = ON;
-        printf("BN,");
-        myledU = OFF;
-        printf("UF");
-        wait(5.0);
-        printf(" passed %4d Sec\r\n", n +=5);
-        printf("R=OFF,G=OFF,B=OFF ");
-        myledR = OFF;
-        printf("RF,");
-        myledG = OFF;
-        printf("GF,");
-        myledB = OFF;
-        printf("BF,");
-        myledU = ON;
-        printf("UN");
+//  RAM -------------------------------------------------------------------------------------------
+
+//  ROM / Constant data ---------------------------------------------------------------------------
+#if defined(TARGET_RZ_A1H)
+char *const msg = "Start measurement on TARGET_RZ_A1H";
+#elif defined(TARGET_LPC1114)
+char *const msg = "Start measurement on TARGET_LPC1114";
+#elif defined(TARGET_NUCLEO_F411RE)
+char *const msg = "Start measurement on TARGET_NUCLEO_F411RE";
+#elif defined(TARGET_LPC1768)
+char *const msg = "Start measurement on TARGET_LPC1768";
+#elif defined(TARGET_K64F)
+char *const msg = "Start measurement on TARGET_K64F";
+#endif
+
+//  Function prototypes ---------------------------------------------------------------------------
+
+//-------------------------------------------------------------------------------------------------
+//  Control Program
+//-------------------------------------------------------------------------------------------------
+int main()
+{
+    float ts = 0, te = 0;
+    uint32_t i=0;
+
+    printf("\r\n%s\r\n", msg);
+    timer.start();
+    ts = timer.read_us();
+    for (i=0; i < 1000; i++) {
+        myled = !myled;
+    }
+    te = timer.read_us();
+    printf("Running speed %.4f[uS]\r\n", (te - ts) / i);
+    while(true) {
+        ;
     }
 }