![](/media/cache/profiles/f0fcf351df4eb6786e9bb6fc4e2dee02.jpg.50x50_q85.jpg)
test program for Silicon Laboratories Inc. Si5351A-B-GT I2C-PROGRAMMABLE ANY-FREQUENCY CMOS CLOCK GENERATOR
Diff: si5351a_check.cpp
- Revision:
- 1:2b29f68043f7
- Parent:
- 0:d68f1e7f7f49
- Child:
- 2:73d79424daa5
--- a/si5351a_check.cpp Sun Jan 01 01:28:25 2017 +0000 +++ b/si5351a_check.cpp Sun Jan 01 01:33:59 2017 +0000 @@ -75,80 +75,6 @@ put_rn(); } -#if defined(INCREMENT) -void test(uint8_t channel) -{ - uint32_t f_set = 4000; // 4KHz - double f = 0; - uint32_t flg = 0; - 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); - while(true){ - f = clk.set_frequency(channel, f_set); - PRINTF("CLK%u = %10.6f MHz\r\n", channel, f / 1000000.0f); - if (flg){ - f_set = f * 0.95f; - if (f_set < 5000){ - flg = 0; - } - } else { - f_set = f * 1.05f; - if (f_set > 190000000){ - flg = 1; - } - } - if (READABLE()) { - GETC(); - return; - } - wait(1.0); - } -} -#endif - -#if defined(TABLE_LOOK) -void test(uint8_t channel) -{ - uint32_t f_set = 0; - uint32_t i,j; - double f = 0; - clk.all_reset(); - while(true){ - for (i = 0; ; i++){ - f_set = freq_tbl[i]; - if (f_set == 0){ - break; - } - f = clk.set_frequency(channel, f_set); - PRINTF("CLK%u = %10.6f MHz\r\n", channel, f / 1000000.0f); - if (READABLE()) { - GETC(); - return; - } - wait(1.0); - } - for (j = i - 2; j > 0 ; j--){ - f_set = freq_tbl[j]; - f = clk.set_frequency(channel, f_set); - PRINTF("CLK%u = %10.6f MHz\r\n", channel, f / 1000000.0f); - if (READABLE()) { - GETC(); - return; - } - wait(1.0); - } - } -} -#endif - -void special_command(void) -{ - PRINTF("Not impliment yet"); - put_rn(); -} - // ---------- Program starts here! --------------------------------------------- void test_si5351(void) { @@ -400,6 +326,81 @@ } } + +#if defined(INCREMENT) +void test(uint8_t channel) +{ + uint32_t f_set = 4000; // 4KHz + double f = 0; + uint32_t flg = 0; + 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); + while(true){ + f = clk.set_frequency(channel, f_set); + PRINTF("CLK%u = %10.6f MHz\r\n", channel, f / 1000000.0f); + if (flg){ + f_set = f * 0.95f; + if (f_set < 5000){ + flg = 0; + } + } else { + f_set = f * 1.05f; + if (f_set > 190000000){ + flg = 1; + } + } + if (READABLE()) { + GETC(); + return; + } + wait(1.0); + } +} +#endif + +#if defined(TABLE_LOOK) +void test(uint8_t channel) +{ + uint32_t f_set = 0; + uint32_t i,j; + double f = 0; + clk.all_reset(); + while(true){ + for (i = 0; ; i++){ + f_set = freq_tbl[i]; + if (f_set == 0){ + break; + } + f = clk.set_frequency(channel, f_set); + PRINTF("CLK%u = %10.6f MHz\r\n", channel, f / 1000000.0f); + if (READABLE()) { + GETC(); + return; + } + wait(1.0); + } + for (j = i - 2; j > 0 ; j--){ + f_set = freq_tbl[j]; + f = clk.set_frequency(channel, f_set); + PRINTF("CLK%u = %10.6f MHz\r\n", channel, f / 1000000.0f); + if (READABLE()) { + GETC(); + return; + } + wait(1.0); + } + } +} +#endif + +void special_command(void) +{ + PRINTF("Not impliment yet"); + put_rn(); +} + // Put \r\n void put_rn ( void ) { @@ -471,63 +472,6 @@ return 1; } -#if 0 -int xatoi ( /* 0:Failed, 1:Successful */ - char **str, /* Pointer to pointer to the string */ - long *res /* Pointer to the valiable to store the value */ -) -{ - unsigned long val; - unsigned char c, r, s = 0; - - - *res = 0; - - while ((c = **str) == ' ') (*str)++; /* Skip leading spaces */ - - if (c == '-') { /* negative? */ - s = 1; - c = *(++(*str)); - } - - if (c == '0') { - c = *(++(*str)); - switch (c) { - case 'x': /* hexdecimal */ - r = 16; c = *(++(*str)); - break; - case 'b': /* binary */ - r = 2; c = *(++(*str)); - break; - default: - if (c <= ' ') return 1; /* single zero */ - if (c < '0' || c > '9') return 0; /* invalid char */ - r = 8; /* octal */ - } - } else { - if (c < '0' || c > '9') return 0; /* EOL or invalid char */ - r = 10; /* decimal */ - } - - val = 0; - while (c > ' ') { - if (c >= 'a') c -= 0x20; - c -= '0'; - if (c >= 17) { - c -= 7; - if (c <= 9) return 0; /* invalid char */ - } - if (c >= r) return 0; /* invalid char for current radix */ - val = val * r + c; - c = *(++(*str)); - } - if (s) val = 0 - val; /* apply sign if needed */ - - *res = val; - return 1; -} -#endif - // Get key input data void get_line (char *buff, int len) {