test program for Silicon Laboratories Inc. Si5351A-B-GT I2C-PROGRAMMABLE ANY-FREQUENCY CMOS CLOCK GENERATOR

Dependencies:   Si5351A

Revision:
2:73d79424daa5
Parent:
1:2b29f68043f7
Child:
3:92f31b23fb0b
diff -r 2b29f68043f7 -r 73d79424daa5 si5351a_check.cpp
--- a/si5351a_check.cpp	Sun Jan 01 01:33:59 2017 +0000
+++ b/si5351a_check.cpp	Thu Jan 05 13:23:11 2017 +0000
@@ -8,7 +8,7 @@
  *  http://www.page.sannet.ne.jp/kenjia/index.html
  *  http://mbed.org/users/kenjiArai/
  *      Created:  December 28th, 2016
- *      Revised:  January   1st, 2017
+ *      Revised:  January   5th, 2017
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
@@ -333,10 +333,21 @@
     uint32_t f_set = 4000;    // 4KHz
     double f = 0;
     uint32_t flg = 0;
+    char *ptr;
+    int32_t seconds = 1;
+
     clk.all_reset();
     f = clk.set_frequency(channel, f_set);
     clk.debug_reg_print();
     PRINTF("CLK%u = %10.6f MHz\r\n", channel, f / 1000000.0f);
+    PRINTF("Please enter interval time[sec] -> ");
+    ptr = linebuf;
+    get_line(ptr, buf_size);
+    put_r();
+    xatoi(&ptr,&seconds);
+    if (seconds <= 0){ seconds = 1;}
+    if (seconds > 1000){ seconds = 1000;}
+    PRINTF("%u[sec]\r\n", seconds);
     while(true){
         f = clk.set_frequency(channel, f_set);
         PRINTF("CLK%u = %10.6f MHz\r\n", channel, f / 1000000.0f);
@@ -355,7 +366,7 @@
             GETC();
             return;
         }
-        wait(1.0);
+        wait((float)seconds);
     }
 }
 #endif
@@ -366,7 +377,18 @@
     uint32_t f_set = 0;
     uint32_t i,j;
     double f = 0;
+    char *ptr;
+    int32_t seconds = 1;
+
     clk.all_reset();
+    PRINTF("Please enter interval time[sec] -> ");
+    ptr = linebuf;
+    get_line(ptr, buf_size);
+    put_r();
+    xatoi(&ptr,&seconds);
+    if (seconds <= 0){ seconds = 1;}
+    if (seconds > 1000){ seconds = 1000;}
+    PRINTF("%u[sec]\r\n", seconds);
     while(true){
         for (i = 0; ; i++){
         	f_set = freq_tbl[i];
@@ -379,7 +401,7 @@
 	            GETC();
 	            return;
 	        }
-	        wait(1.0);
+        	wait((float)seconds);
 	    }
         for (j = i - 2; j > 0 ; j--){
         	f_set = freq_tbl[j];
@@ -389,7 +411,7 @@
 	            GETC();
 	            return;
 	        }
-	        wait(1.0);
+            wait((float)seconds);
 	    }
     }
 }