Clock generator @ 145 MHz and 7 mhz
Fork of Check_Si5351A_Clock_generator by
si5351a_check.cpp@3:92f31b23fb0b, 2017-01-06 (annotated)
- Committer:
- kenjiArai
- Date:
- Fri Jan 06 14:09:18 2017 +0000
- Revision:
- 3:92f31b23fb0b
- Parent:
- 2:73d79424daa5
- Child:
- 4:5981cf106502
use new function "frequency compensation function" as 'p' command
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kenjiArai | 0:d68f1e7f7f49 | 1 | /* |
kenjiArai | 0:d68f1e7f7f49 | 2 | * mbed Application program / Si5351A sample program |
kenjiArai | 0:d68f1e7f7f49 | 3 | * tested on: |
kenjiArai | 0:d68f1e7f7f49 | 4 | * ST Nucleo-F411RE & F401RE |
kenjiArai | 0:d68f1e7f7f49 | 5 | * LPC1114FN28 |
kenjiArai | 0:d68f1e7f7f49 | 6 | * |
kenjiArai | 0:d68f1e7f7f49 | 7 | * Copyright (c) 2016,'17 Kenji Arai / JH1PJL |
kenjiArai | 0:d68f1e7f7f49 | 8 | * http://www.page.sannet.ne.jp/kenjia/index.html |
kenjiArai | 0:d68f1e7f7f49 | 9 | * http://mbed.org/users/kenjiArai/ |
kenjiArai | 0:d68f1e7f7f49 | 10 | * Created: December 28th, 2016 |
kenjiArai | 3:92f31b23fb0b | 11 | * Revised: January 6th, 2017 |
kenjiArai | 0:d68f1e7f7f49 | 12 | * |
kenjiArai | 0:d68f1e7f7f49 | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
kenjiArai | 0:d68f1e7f7f49 | 14 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
kenjiArai | 0:d68f1e7f7f49 | 15 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
kenjiArai | 0:d68f1e7f7f49 | 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
kenjiArai | 0:d68f1e7f7f49 | 17 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
kenjiArai | 0:d68f1e7f7f49 | 18 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR |
kenjiArai | 0:d68f1e7f7f49 | 19 | * THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
kenjiArai | 0:d68f1e7f7f49 | 20 | */ |
kenjiArai | 0:d68f1e7f7f49 | 21 | |
kenjiArai | 0:d68f1e7f7f49 | 22 | // Include -------------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 23 | #include "mbed.h" |
kenjiArai | 0:d68f1e7f7f49 | 24 | #include "si5351a.h" |
kenjiArai | 0:d68f1e7f7f49 | 25 | #include "si5351a_check.h" |
kenjiArai | 0:d68f1e7f7f49 | 26 | |
kenjiArai | 0:d68f1e7f7f49 | 27 | // Definition ----------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 28 | |
kenjiArai | 0:d68f1e7f7f49 | 29 | // Object --------------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 30 | Serial pc(USBTX, USBRX); |
kenjiArai | 0:d68f1e7f7f49 | 31 | //I2C i2c(dp5, dp27); // communication with Si5351A |
kenjiArai | 0:d68f1e7f7f49 | 32 | I2C i2c(I2C_SDA, I2C_SCL); // communication with Si5351A |
kenjiArai | 0:d68f1e7f7f49 | 33 | SI5351A clk(i2c, 25000000UL); // base clock = 25.0MHz |
kenjiArai | 0:d68f1e7f7f49 | 34 | |
kenjiArai | 3:92f31b23fb0b | 35 | // RAM ------------------------------------------------------------------------ |
kenjiArai | 3:92f31b23fb0b | 36 | bool one_char = false; |
kenjiArai | 3:92f31b23fb0b | 37 | |
kenjiArai | 0:d68f1e7f7f49 | 38 | //------------------------------------------------------------------------------ |
kenjiArai | 0:d68f1e7f7f49 | 39 | // Control Program |
kenjiArai | 0:d68f1e7f7f49 | 40 | //------------------------------------------------------------------------------ |
kenjiArai | 0:d68f1e7f7f49 | 41 | int main() |
kenjiArai | 0:d68f1e7f7f49 | 42 | { |
kenjiArai | 0:d68f1e7f7f49 | 43 | while (true){ test_si5351();} |
kenjiArai | 0:d68f1e7f7f49 | 44 | } |
kenjiArai | 0:d68f1e7f7f49 | 45 | |
kenjiArai | 0:d68f1e7f7f49 | 46 | // Help Massage |
kenjiArai | 0:d68f1e7f7f49 | 47 | void msg_hlp (void) |
kenjiArai | 0:d68f1e7f7f49 | 48 | { |
kenjiArai | 0:d68f1e7f7f49 | 49 | PRINTF(opening_msg); |
kenjiArai | 0:d68f1e7f7f49 | 50 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 51 | PRINTF("0 - Check CLK0 output between 50KHz to 90MHz"); |
kenjiArai | 0:d68f1e7f7f49 | 52 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 53 | PRINTF("1 - Check CLK1 (same as #1)"); |
kenjiArai | 0:d68f1e7f7f49 | 54 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 55 | PRINTF("2 - Check CLK2 (same as #1)"); |
kenjiArai | 0:d68f1e7f7f49 | 56 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 57 | PRINTF("3 - Example CLK0:120.00MHz, CLK1:12.00MHz, CLK2:13.56MHz"); |
kenjiArai | 0:d68f1e7f7f49 | 58 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 59 | PRINTF("4 - Set desired freq. into CLK0"); |
kenjiArai | 0:d68f1e7f7f49 | 60 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 61 | PRINTF("5 - Set desired freq. into CLK0 & CLK1"); |
kenjiArai | 0:d68f1e7f7f49 | 62 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 63 | PRINTF("6 - Set desired freq. into CLK0, CLK1 & CLK2"); |
kenjiArai | 0:d68f1e7f7f49 | 64 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 65 | PRINTF("7 - CLK0: set desired center freq. then shift +/- range"); |
kenjiArai | 0:d68f1e7f7f49 | 66 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 67 | PRINTF("a - All clear registers"); |
kenjiArai | 0:d68f1e7f7f49 | 68 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 69 | PRINTF("c - Show current configration"); |
kenjiArai | 0:d68f1e7f7f49 | 70 | put_rn(); |
kenjiArai | 3:92f31b23fb0b | 71 | PRINTF("p - Compensation"); |
kenjiArai | 3:92f31b23fb0b | 72 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 73 | PRINTF("r - Show current resisters"); |
kenjiArai | 0:d68f1e7f7f49 | 74 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 75 | PRINTF("x - Go to special command"); |
kenjiArai | 0:d68f1e7f7f49 | 76 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 77 | PRINTF("Hit any key then return to prompt screen"); |
kenjiArai | 0:d68f1e7f7f49 | 78 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 79 | PRINTF("Reset mbed board -> please hit key <Alt>+<B>"); |
kenjiArai | 0:d68f1e7f7f49 | 80 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 81 | } |
kenjiArai | 0:d68f1e7f7f49 | 82 | |
kenjiArai | 0:d68f1e7f7f49 | 83 | // ---------- Program starts here! --------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 84 | void test_si5351(void) |
kenjiArai | 0:d68f1e7f7f49 | 85 | { |
kenjiArai | 0:d68f1e7f7f49 | 86 | char *ptr; |
kenjiArai | 0:d68f1e7f7f49 | 87 | int32_t f; |
kenjiArai | 0:d68f1e7f7f49 | 88 | |
kenjiArai | 0:d68f1e7f7f49 | 89 | BAUD(BAUD_RATE); |
kenjiArai | 0:d68f1e7f7f49 | 90 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 91 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 92 | PRINTF("%s [Help:'?' key]", opening_msg); |
kenjiArai | 0:d68f1e7f7f49 | 93 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 94 | clk.all_reset(); |
kenjiArai | 0:d68f1e7f7f49 | 95 | for (;;) { |
kenjiArai | 0:d68f1e7f7f49 | 96 | put_r(); |
kenjiArai | 0:d68f1e7f7f49 | 97 | PUTC('>'); |
kenjiArai | 0:d68f1e7f7f49 | 98 | ptr = linebuf; |
kenjiArai | 0:d68f1e7f7f49 | 99 | get_line(ptr, sizeof(linebuf)); |
kenjiArai | 0:d68f1e7f7f49 | 100 | put_r(); |
kenjiArai | 0:d68f1e7f7f49 | 101 | switch (*ptr++) { |
kenjiArai | 0:d68f1e7f7f49 | 102 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 103 | // test0 |
kenjiArai | 0:d68f1e7f7f49 | 104 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 105 | case '0' : |
kenjiArai | 0:d68f1e7f7f49 | 106 | clk.all_reset(); |
kenjiArai | 0:d68f1e7f7f49 | 107 | test(0); |
kenjiArai | 0:d68f1e7f7f49 | 108 | //put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 109 | break; |
kenjiArai | 0:d68f1e7f7f49 | 110 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 111 | // test1 |
kenjiArai | 0:d68f1e7f7f49 | 112 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 113 | case '1' : |
kenjiArai | 0:d68f1e7f7f49 | 114 | clk.all_reset(); |
kenjiArai | 0:d68f1e7f7f49 | 115 | test(1); |
kenjiArai | 0:d68f1e7f7f49 | 116 | //put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 117 | break; |
kenjiArai | 0:d68f1e7f7f49 | 118 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 119 | // test2 |
kenjiArai | 0:d68f1e7f7f49 | 120 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 121 | case '2' : |
kenjiArai | 0:d68f1e7f7f49 | 122 | clk.all_reset(); |
kenjiArai | 0:d68f1e7f7f49 | 123 | test(2); |
kenjiArai | 0:d68f1e7f7f49 | 124 | //put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 125 | break; |
kenjiArai | 0:d68f1e7f7f49 | 126 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 127 | // test3 |
kenjiArai | 0:d68f1e7f7f49 | 128 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 129 | case '3' : |
kenjiArai | 0:d68f1e7f7f49 | 130 | clk.debug_example_clock(); |
kenjiArai | 0:d68f1e7f7f49 | 131 | //clk.debug_reg_print(); |
kenjiArai | 0:d68f1e7f7f49 | 132 | //put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 133 | break; |
kenjiArai | 0:d68f1e7f7f49 | 134 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 135 | // test4 |
kenjiArai | 0:d68f1e7f7f49 | 136 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 137 | case '4' : |
kenjiArai | 0:d68f1e7f7f49 | 138 | clk.all_reset(); |
kenjiArai | 0:d68f1e7f7f49 | 139 | PRINTF("CLK0 %s", msg0); |
kenjiArai | 0:d68f1e7f7f49 | 140 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 141 | ptr = linebuf; |
kenjiArai | 0:d68f1e7f7f49 | 142 | get_line(ptr, buf_size); |
kenjiArai | 0:d68f1e7f7f49 | 143 | put_r(); |
kenjiArai | 0:d68f1e7f7f49 | 144 | if (xatoi(&ptr,&f)){ |
kenjiArai | 0:d68f1e7f7f49 | 145 | if (f < 0){ break;} |
kenjiArai | 0:d68f1e7f7f49 | 146 | PRINTF("CLK0:%u [Hz]", clk.set_frequency(0, f)); |
kenjiArai | 0:d68f1e7f7f49 | 147 | } else { |
kenjiArai | 0:d68f1e7f7f49 | 148 | PUTC('?'); |
kenjiArai | 0:d68f1e7f7f49 | 149 | } |
kenjiArai | 0:d68f1e7f7f49 | 150 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 151 | break; |
kenjiArai | 0:d68f1e7f7f49 | 152 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 153 | // test5 |
kenjiArai | 0:d68f1e7f7f49 | 154 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 155 | case '5' : |
kenjiArai | 0:d68f1e7f7f49 | 156 | clk.all_reset(); |
kenjiArai | 0:d68f1e7f7f49 | 157 | PRINTF("CLK0 %s", msg0); |
kenjiArai | 0:d68f1e7f7f49 | 158 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 159 | ptr = linebuf; |
kenjiArai | 0:d68f1e7f7f49 | 160 | get_line(ptr, buf_size); |
kenjiArai | 0:d68f1e7f7f49 | 161 | put_r(); |
kenjiArai | 0:d68f1e7f7f49 | 162 | if (xatoi(&ptr,&f)){ |
kenjiArai | 0:d68f1e7f7f49 | 163 | if (f < 0){ break;} |
kenjiArai | 0:d68f1e7f7f49 | 164 | PRINTF("CLK0:%u [Hz]", clk.set_frequency(0, f)); |
kenjiArai | 0:d68f1e7f7f49 | 165 | } else { |
kenjiArai | 0:d68f1e7f7f49 | 166 | PUTC('?'); |
kenjiArai | 0:d68f1e7f7f49 | 167 | } |
kenjiArai | 0:d68f1e7f7f49 | 168 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 169 | PRINTF("CLK1 %s", msg0); |
kenjiArai | 0:d68f1e7f7f49 | 170 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 171 | ptr = linebuf; |
kenjiArai | 0:d68f1e7f7f49 | 172 | get_line(ptr, buf_size); |
kenjiArai | 0:d68f1e7f7f49 | 173 | put_r(); |
kenjiArai | 0:d68f1e7f7f49 | 174 | if (xatoi(&ptr,&f)){ |
kenjiArai | 0:d68f1e7f7f49 | 175 | if (f < 0){ break;} |
kenjiArai | 0:d68f1e7f7f49 | 176 | PRINTF("CLK1:%u [Hz]", clk.set_frequency(1, f)); |
kenjiArai | 0:d68f1e7f7f49 | 177 | } else { |
kenjiArai | 0:d68f1e7f7f49 | 178 | PUTC('?'); |
kenjiArai | 0:d68f1e7f7f49 | 179 | } |
kenjiArai | 0:d68f1e7f7f49 | 180 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 181 | break; |
kenjiArai | 0:d68f1e7f7f49 | 182 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 183 | // test6 |
kenjiArai | 0:d68f1e7f7f49 | 184 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 185 | case '6' : |
kenjiArai | 0:d68f1e7f7f49 | 186 | clk.all_reset(); |
kenjiArai | 0:d68f1e7f7f49 | 187 | PRINTF("CLK0 %s", msg0); |
kenjiArai | 0:d68f1e7f7f49 | 188 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 189 | ptr = linebuf; |
kenjiArai | 0:d68f1e7f7f49 | 190 | get_line(ptr, buf_size); |
kenjiArai | 0:d68f1e7f7f49 | 191 | put_r(); |
kenjiArai | 0:d68f1e7f7f49 | 192 | if (xatoi(&ptr,&f)){ |
kenjiArai | 0:d68f1e7f7f49 | 193 | if (f < 0){ break;} |
kenjiArai | 0:d68f1e7f7f49 | 194 | PRINTF("CLK0:%u [Hz]", clk.set_frequency(0, f)); |
kenjiArai | 0:d68f1e7f7f49 | 195 | } else { |
kenjiArai | 0:d68f1e7f7f49 | 196 | PUTC('?'); |
kenjiArai | 0:d68f1e7f7f49 | 197 | } |
kenjiArai | 0:d68f1e7f7f49 | 198 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 199 | PRINTF("CLK1 %s", msg0); |
kenjiArai | 0:d68f1e7f7f49 | 200 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 201 | PRINTF( |
kenjiArai | 0:d68f1e7f7f49 | 202 | "If you set CLK1 over 100MHz, you cannt set CLK2 anymore"); |
kenjiArai | 0:d68f1e7f7f49 | 203 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 204 | ptr = linebuf; |
kenjiArai | 0:d68f1e7f7f49 | 205 | get_line(ptr, buf_size); |
kenjiArai | 0:d68f1e7f7f49 | 206 | put_r(); |
kenjiArai | 0:d68f1e7f7f49 | 207 | if (xatoi(&ptr,&f)){ |
kenjiArai | 0:d68f1e7f7f49 | 208 | if (f < 0){ break;} |
kenjiArai | 0:d68f1e7f7f49 | 209 | PRINTF("CLK1:%u [Hz]", clk.set_frequency(1, f)); |
kenjiArai | 0:d68f1e7f7f49 | 210 | } else { |
kenjiArai | 0:d68f1e7f7f49 | 211 | PUTC('?'); |
kenjiArai | 0:d68f1e7f7f49 | 212 | } |
kenjiArai | 0:d68f1e7f7f49 | 213 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 214 | PRINTF("CLK2 %s", msg0); |
kenjiArai | 0:d68f1e7f7f49 | 215 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 216 | ptr = linebuf; |
kenjiArai | 0:d68f1e7f7f49 | 217 | get_line(ptr, buf_size); |
kenjiArai | 0:d68f1e7f7f49 | 218 | put_r(); |
kenjiArai | 0:d68f1e7f7f49 | 219 | if (xatoi(&ptr,&f)){ |
kenjiArai | 0:d68f1e7f7f49 | 220 | if (f < 0){ break;} |
kenjiArai | 0:d68f1e7f7f49 | 221 | PRINTF("CLK2:%u [Hz]", clk.set_frequency(2, f)); |
kenjiArai | 0:d68f1e7f7f49 | 222 | } else { |
kenjiArai | 0:d68f1e7f7f49 | 223 | PUTC('?'); |
kenjiArai | 0:d68f1e7f7f49 | 224 | } |
kenjiArai | 0:d68f1e7f7f49 | 225 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 226 | break; |
kenjiArai | 0:d68f1e7f7f49 | 227 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 228 | // test7 CLK0: set desired center freq. then shift +/- range |
kenjiArai | 0:d68f1e7f7f49 | 229 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 230 | case '7' : |
kenjiArai | 3:92f31b23fb0b | 231 | one_char = true; |
kenjiArai | 0:d68f1e7f7f49 | 232 | clk.all_reset(); |
kenjiArai | 0:d68f1e7f7f49 | 233 | PRINTF("CLK0 %s", msg0); |
kenjiArai | 0:d68f1e7f7f49 | 234 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 235 | ptr = linebuf; |
kenjiArai | 0:d68f1e7f7f49 | 236 | get_line(ptr, buf_size); |
kenjiArai | 0:d68f1e7f7f49 | 237 | put_r(); |
kenjiArai | 0:d68f1e7f7f49 | 238 | if (xatoi(&ptr,&f)){ |
kenjiArai | 0:d68f1e7f7f49 | 239 | if (f < 0){ break;} |
kenjiArai | 0:d68f1e7f7f49 | 240 | PRINTF("CLK0:%u [Hz]", clk.set_frequency(0, f)); |
kenjiArai | 0:d68f1e7f7f49 | 241 | } else { |
kenjiArai | 0:d68f1e7f7f49 | 242 | PUTC('?'); |
kenjiArai | 0:d68f1e7f7f49 | 243 | } |
kenjiArai | 0:d68f1e7f7f49 | 244 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 245 | PRINTF("Please enter sift command [Help: ?]"); |
kenjiArai | 0:d68f1e7f7f49 | 246 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 247 | while (true){ |
kenjiArai | 0:d68f1e7f7f49 | 248 | PRINTF("[S]>"); |
kenjiArai | 0:d68f1e7f7f49 | 249 | ptr = linebuf; |
kenjiArai | 0:d68f1e7f7f49 | 250 | get_line(ptr, buf_size); |
kenjiArai | 0:d68f1e7f7f49 | 251 | put_r(); |
kenjiArai | 0:d68f1e7f7f49 | 252 | switch(*ptr) { |
kenjiArai | 0:d68f1e7f7f49 | 253 | case 'p' : |
kenjiArai | 0:d68f1e7f7f49 | 254 | PRINTF("Shift to %u [Hz]", clk.shift_freq(0, 10)); |
kenjiArai | 0:d68f1e7f7f49 | 255 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 256 | break; |
kenjiArai | 0:d68f1e7f7f49 | 257 | case 'm' : |
kenjiArai | 0:d68f1e7f7f49 | 258 | PRINTF("Shift to %u [Hz]", clk.shift_freq(0, -10)); |
kenjiArai | 0:d68f1e7f7f49 | 259 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 260 | break; |
kenjiArai | 0:d68f1e7f7f49 | 261 | case 's' : |
kenjiArai | 0:d68f1e7f7f49 | 262 | ptr++; |
kenjiArai | 0:d68f1e7f7f49 | 263 | xatoi(&ptr,&f); |
kenjiArai | 0:d68f1e7f7f49 | 264 | PRINTF("offset=%d\r\n", f); |
kenjiArai | 0:d68f1e7f7f49 | 265 | PRINTF("Shift to %u [Hz]", clk.shift_freq(0, f)); |
kenjiArai | 0:d68f1e7f7f49 | 266 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 267 | break; |
kenjiArai | 0:d68f1e7f7f49 | 268 | case '?' : |
kenjiArai | 0:d68f1e7f7f49 | 269 | PRINTF("p -> +10Hz"); |
kenjiArai | 0:d68f1e7f7f49 | 270 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 271 | PRINTF("m -> -10Hz"); |
kenjiArai | 0:d68f1e7f7f49 | 272 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 273 | PRINTF("s -> Shift +/-x Hz (example -100)"); |
kenjiArai | 0:d68f1e7f7f49 | 274 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 275 | PRINTF("? -> You know this"); |
kenjiArai | 0:d68f1e7f7f49 | 276 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 277 | PRINTF("e -> Exit"); |
kenjiArai | 0:d68f1e7f7f49 | 278 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 279 | break; |
kenjiArai | 0:d68f1e7f7f49 | 280 | case 'e' : |
kenjiArai | 0:d68f1e7f7f49 | 281 | break; |
kenjiArai | 0:d68f1e7f7f49 | 282 | default: |
kenjiArai | 0:d68f1e7f7f49 | 283 | PUTC('?'); |
kenjiArai | 0:d68f1e7f7f49 | 284 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 285 | } |
kenjiArai | 0:d68f1e7f7f49 | 286 | if (*ptr == 'e'){ |
kenjiArai | 0:d68f1e7f7f49 | 287 | break; |
kenjiArai | 0:d68f1e7f7f49 | 288 | } |
kenjiArai | 0:d68f1e7f7f49 | 289 | } |
kenjiArai | 3:92f31b23fb0b | 290 | one_char = false; |
kenjiArai | 0:d68f1e7f7f49 | 291 | break; |
kenjiArai | 0:d68f1e7f7f49 | 292 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 293 | // All clear alll registers |
kenjiArai | 0:d68f1e7f7f49 | 294 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 295 | case 'a' : |
kenjiArai | 0:d68f1e7f7f49 | 296 | clk.all_reset(); |
kenjiArai | 0:d68f1e7f7f49 | 297 | PRINTF("Cleared all of registers!\r\n"); |
kenjiArai | 0:d68f1e7f7f49 | 298 | break; |
kenjiArai | 0:d68f1e7f7f49 | 299 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 300 | // Show configration |
kenjiArai | 0:d68f1e7f7f49 | 301 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 302 | case 'c' : |
kenjiArai | 0:d68f1e7f7f49 | 303 | clk.debug_current_config(); |
kenjiArai | 0:d68f1e7f7f49 | 304 | //put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 305 | break; |
kenjiArai | 0:d68f1e7f7f49 | 306 | //-------------------------------------------------------------- |
kenjiArai | 3:92f31b23fb0b | 307 | // Compensation |
kenjiArai | 3:92f31b23fb0b | 308 | //-------------------------------------------------------------- |
kenjiArai | 3:92f31b23fb0b | 309 | case 'p' : |
kenjiArai | 3:92f31b23fb0b | 310 | clk.set_frequency(0, 25000000); // Set CLK0=10MHz |
kenjiArai | 3:92f31b23fb0b | 311 | PRINTF( |
kenjiArai | 3:92f31b23fb0b | 312 | "Please measure Clock0 output frequency (aound 25MHz)\r\n"); |
kenjiArai | 3:92f31b23fb0b | 313 | PRINTF("Enter your mesured data = "); |
kenjiArai | 3:92f31b23fb0b | 314 | ptr = linebuf; |
kenjiArai | 3:92f31b23fb0b | 315 | get_line(ptr, buf_size); |
kenjiArai | 3:92f31b23fb0b | 316 | if (xatoi(&ptr,&f)){ |
kenjiArai | 3:92f31b23fb0b | 317 | if (f < 0){ |
kenjiArai | 3:92f31b23fb0b | 318 | PUTC('?'); |
kenjiArai | 3:92f31b23fb0b | 319 | break; |
kenjiArai | 3:92f31b23fb0b | 320 | } |
kenjiArai | 3:92f31b23fb0b | 321 | PRINTF("\r%u [Hz]\r\n", f); |
kenjiArai | 3:92f31b23fb0b | 322 | clk.f_compensation(25000000, f); |
kenjiArai | 3:92f31b23fb0b | 323 | clk.debug_current_config(); |
kenjiArai | 3:92f31b23fb0b | 324 | } else { |
kenjiArai | 3:92f31b23fb0b | 325 | PUTC('?'); |
kenjiArai | 3:92f31b23fb0b | 326 | } |
kenjiArai | 3:92f31b23fb0b | 327 | break; |
kenjiArai | 3:92f31b23fb0b | 328 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 329 | // Show resisters |
kenjiArai | 0:d68f1e7f7f49 | 330 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 331 | case 'r' : |
kenjiArai | 0:d68f1e7f7f49 | 332 | clk.debug_reg_print(); |
kenjiArai | 0:d68f1e7f7f49 | 333 | //put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 334 | break; |
kenjiArai | 0:d68f1e7f7f49 | 335 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 336 | // Go to special command |
kenjiArai | 0:d68f1e7f7f49 | 337 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 338 | case 'x' : |
kenjiArai | 0:d68f1e7f7f49 | 339 | special_command(); |
kenjiArai | 0:d68f1e7f7f49 | 340 | break; |
kenjiArai | 0:d68f1e7f7f49 | 341 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 342 | // help |
kenjiArai | 0:d68f1e7f7f49 | 343 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 344 | case '?' : |
kenjiArai | 0:d68f1e7f7f49 | 345 | msg_hlp(); |
kenjiArai | 0:d68f1e7f7f49 | 346 | break; |
kenjiArai | 0:d68f1e7f7f49 | 347 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 348 | // no support |
kenjiArai | 0:d68f1e7f7f49 | 349 | //-------------------------------------------------------------- |
kenjiArai | 0:d68f1e7f7f49 | 350 | default: |
kenjiArai | 0:d68f1e7f7f49 | 351 | PUTC('?'); |
kenjiArai | 0:d68f1e7f7f49 | 352 | put_rn(); |
kenjiArai | 0:d68f1e7f7f49 | 353 | break; |
kenjiArai | 0:d68f1e7f7f49 | 354 | } |
kenjiArai | 0:d68f1e7f7f49 | 355 | } |
kenjiArai | 0:d68f1e7f7f49 | 356 | } |
kenjiArai | 0:d68f1e7f7f49 | 357 | |
kenjiArai | 1:2b29f68043f7 | 358 | |
kenjiArai | 1:2b29f68043f7 | 359 | #if defined(INCREMENT) |
kenjiArai | 1:2b29f68043f7 | 360 | void test(uint8_t channel) |
kenjiArai | 1:2b29f68043f7 | 361 | { |
kenjiArai | 1:2b29f68043f7 | 362 | uint32_t f_set = 4000; // 4KHz |
kenjiArai | 1:2b29f68043f7 | 363 | double f = 0; |
kenjiArai | 1:2b29f68043f7 | 364 | uint32_t flg = 0; |
kenjiArai | 2:73d79424daa5 | 365 | char *ptr; |
kenjiArai | 2:73d79424daa5 | 366 | int32_t seconds = 1; |
kenjiArai | 2:73d79424daa5 | 367 | |
kenjiArai | 1:2b29f68043f7 | 368 | clk.all_reset(); |
kenjiArai | 1:2b29f68043f7 | 369 | f = clk.set_frequency(channel, f_set); |
kenjiArai | 1:2b29f68043f7 | 370 | clk.debug_reg_print(); |
kenjiArai | 1:2b29f68043f7 | 371 | PRINTF("CLK%u = %10.6f MHz\r\n", channel, f / 1000000.0f); |
kenjiArai | 2:73d79424daa5 | 372 | PRINTF("Please enter interval time[sec] -> "); |
kenjiArai | 2:73d79424daa5 | 373 | ptr = linebuf; |
kenjiArai | 2:73d79424daa5 | 374 | get_line(ptr, buf_size); |
kenjiArai | 2:73d79424daa5 | 375 | put_r(); |
kenjiArai | 2:73d79424daa5 | 376 | xatoi(&ptr,&seconds); |
kenjiArai | 2:73d79424daa5 | 377 | if (seconds <= 0){ seconds = 1;} |
kenjiArai | 2:73d79424daa5 | 378 | if (seconds > 1000){ seconds = 1000;} |
kenjiArai | 2:73d79424daa5 | 379 | PRINTF("%u[sec]\r\n", seconds); |
kenjiArai | 1:2b29f68043f7 | 380 | while(true){ |
kenjiArai | 1:2b29f68043f7 | 381 | f = clk.set_frequency(channel, f_set); |
kenjiArai | 1:2b29f68043f7 | 382 | PRINTF("CLK%u = %10.6f MHz\r\n", channel, f / 1000000.0f); |
kenjiArai | 1:2b29f68043f7 | 383 | if (flg){ |
kenjiArai | 1:2b29f68043f7 | 384 | f_set = f * 0.95f; |
kenjiArai | 1:2b29f68043f7 | 385 | if (f_set < 5000){ |
kenjiArai | 1:2b29f68043f7 | 386 | flg = 0; |
kenjiArai | 1:2b29f68043f7 | 387 | } |
kenjiArai | 1:2b29f68043f7 | 388 | } else { |
kenjiArai | 1:2b29f68043f7 | 389 | f_set = f * 1.05f; |
kenjiArai | 1:2b29f68043f7 | 390 | if (f_set > 190000000){ |
kenjiArai | 1:2b29f68043f7 | 391 | flg = 1; |
kenjiArai | 1:2b29f68043f7 | 392 | } |
kenjiArai | 1:2b29f68043f7 | 393 | } |
kenjiArai | 1:2b29f68043f7 | 394 | if (READABLE()) { |
kenjiArai | 1:2b29f68043f7 | 395 | GETC(); |
kenjiArai | 1:2b29f68043f7 | 396 | return; |
kenjiArai | 1:2b29f68043f7 | 397 | } |
kenjiArai | 2:73d79424daa5 | 398 | wait((float)seconds); |
kenjiArai | 1:2b29f68043f7 | 399 | } |
kenjiArai | 1:2b29f68043f7 | 400 | } |
kenjiArai | 1:2b29f68043f7 | 401 | #endif |
kenjiArai | 1:2b29f68043f7 | 402 | |
kenjiArai | 1:2b29f68043f7 | 403 | #if defined(TABLE_LOOK) |
kenjiArai | 1:2b29f68043f7 | 404 | void test(uint8_t channel) |
kenjiArai | 1:2b29f68043f7 | 405 | { |
kenjiArai | 1:2b29f68043f7 | 406 | uint32_t f_set = 0; |
kenjiArai | 1:2b29f68043f7 | 407 | uint32_t i,j; |
kenjiArai | 1:2b29f68043f7 | 408 | double f = 0; |
kenjiArai | 2:73d79424daa5 | 409 | char *ptr; |
kenjiArai | 2:73d79424daa5 | 410 | int32_t seconds = 1; |
kenjiArai | 2:73d79424daa5 | 411 | |
kenjiArai | 1:2b29f68043f7 | 412 | clk.all_reset(); |
kenjiArai | 2:73d79424daa5 | 413 | PRINTF("Please enter interval time[sec] -> "); |
kenjiArai | 2:73d79424daa5 | 414 | ptr = linebuf; |
kenjiArai | 2:73d79424daa5 | 415 | get_line(ptr, buf_size); |
kenjiArai | 2:73d79424daa5 | 416 | put_r(); |
kenjiArai | 2:73d79424daa5 | 417 | xatoi(&ptr,&seconds); |
kenjiArai | 2:73d79424daa5 | 418 | if (seconds <= 0){ seconds = 1;} |
kenjiArai | 2:73d79424daa5 | 419 | if (seconds > 1000){ seconds = 1000;} |
kenjiArai | 2:73d79424daa5 | 420 | PRINTF("%u[sec]\r\n", seconds); |
kenjiArai | 1:2b29f68043f7 | 421 | while(true){ |
kenjiArai | 1:2b29f68043f7 | 422 | for (i = 0; ; i++){ |
kenjiArai | 1:2b29f68043f7 | 423 | f_set = freq_tbl[i]; |
kenjiArai | 1:2b29f68043f7 | 424 | if (f_set == 0){ |
kenjiArai | 1:2b29f68043f7 | 425 | break; |
kenjiArai | 1:2b29f68043f7 | 426 | } |
kenjiArai | 1:2b29f68043f7 | 427 | f = clk.set_frequency(channel, f_set); |
kenjiArai | 1:2b29f68043f7 | 428 | PRINTF("CLK%u = %10.6f MHz\r\n", channel, f / 1000000.0f); |
kenjiArai | 1:2b29f68043f7 | 429 | if (READABLE()) { |
kenjiArai | 1:2b29f68043f7 | 430 | GETC(); |
kenjiArai | 1:2b29f68043f7 | 431 | return; |
kenjiArai | 1:2b29f68043f7 | 432 | } |
kenjiArai | 2:73d79424daa5 | 433 | wait((float)seconds); |
kenjiArai | 1:2b29f68043f7 | 434 | } |
kenjiArai | 1:2b29f68043f7 | 435 | for (j = i - 2; j > 0 ; j--){ |
kenjiArai | 1:2b29f68043f7 | 436 | f_set = freq_tbl[j]; |
kenjiArai | 1:2b29f68043f7 | 437 | f = clk.set_frequency(channel, f_set); |
kenjiArai | 1:2b29f68043f7 | 438 | PRINTF("CLK%u = %10.6f MHz\r\n", channel, f / 1000000.0f); |
kenjiArai | 1:2b29f68043f7 | 439 | if (READABLE()) { |
kenjiArai | 1:2b29f68043f7 | 440 | GETC(); |
kenjiArai | 1:2b29f68043f7 | 441 | return; |
kenjiArai | 1:2b29f68043f7 | 442 | } |
kenjiArai | 2:73d79424daa5 | 443 | wait((float)seconds); |
kenjiArai | 1:2b29f68043f7 | 444 | } |
kenjiArai | 1:2b29f68043f7 | 445 | } |
kenjiArai | 1:2b29f68043f7 | 446 | } |
kenjiArai | 1:2b29f68043f7 | 447 | #endif |
kenjiArai | 3:92f31b23fb0b | 448 | |
kenjiArai | 1:2b29f68043f7 | 449 | void special_command(void) |
kenjiArai | 1:2b29f68043f7 | 450 | { |
kenjiArai | 1:2b29f68043f7 | 451 | PRINTF("Not impliment yet"); |
kenjiArai | 1:2b29f68043f7 | 452 | put_rn(); |
kenjiArai | 1:2b29f68043f7 | 453 | } |
kenjiArai | 1:2b29f68043f7 | 454 | |
kenjiArai | 0:d68f1e7f7f49 | 455 | // Put \r\n |
kenjiArai | 0:d68f1e7f7f49 | 456 | void put_rn ( void ) |
kenjiArai | 0:d68f1e7f7f49 | 457 | { |
kenjiArai | 0:d68f1e7f7f49 | 458 | PUTC('\r'); |
kenjiArai | 0:d68f1e7f7f49 | 459 | PUTC('\n'); |
kenjiArai | 0:d68f1e7f7f49 | 460 | } |
kenjiArai | 0:d68f1e7f7f49 | 461 | |
kenjiArai | 0:d68f1e7f7f49 | 462 | // Put \r |
kenjiArai | 0:d68f1e7f7f49 | 463 | void put_r ( void ) |
kenjiArai | 0:d68f1e7f7f49 | 464 | { |
kenjiArai | 0:d68f1e7f7f49 | 465 | PUTC('\r'); |
kenjiArai | 0:d68f1e7f7f49 | 466 | } |
kenjiArai | 0:d68f1e7f7f49 | 467 | |
kenjiArai | 0:d68f1e7f7f49 | 468 | // Change string -> integer |
kenjiArai | 0:d68f1e7f7f49 | 469 | int xatoi (char **str, int32_t *res) |
kenjiArai | 0:d68f1e7f7f49 | 470 | { |
kenjiArai | 0:d68f1e7f7f49 | 471 | uint32_t val; |
kenjiArai | 0:d68f1e7f7f49 | 472 | int8_t c, radix, s = 0; |
kenjiArai | 0:d68f1e7f7f49 | 473 | |
kenjiArai | 0:d68f1e7f7f49 | 474 | while ((c = **str) == ' ') (*str)++; |
kenjiArai | 0:d68f1e7f7f49 | 475 | if (c == '-') { |
kenjiArai | 0:d68f1e7f7f49 | 476 | s = 1; |
kenjiArai | 0:d68f1e7f7f49 | 477 | c = *(++(*str)); |
kenjiArai | 0:d68f1e7f7f49 | 478 | } |
kenjiArai | 0:d68f1e7f7f49 | 479 | if (c == '+') { |
kenjiArai | 0:d68f1e7f7f49 | 480 | c = *(++(*str)); |
kenjiArai | 0:d68f1e7f7f49 | 481 | } |
kenjiArai | 0:d68f1e7f7f49 | 482 | if (c == '0') { |
kenjiArai | 0:d68f1e7f7f49 | 483 | c = *(++(*str)); |
kenjiArai | 0:d68f1e7f7f49 | 484 | if (c <= ' ') { |
kenjiArai | 0:d68f1e7f7f49 | 485 | *res = 0; |
kenjiArai | 0:d68f1e7f7f49 | 486 | return 1; |
kenjiArai | 0:d68f1e7f7f49 | 487 | } |
kenjiArai | 0:d68f1e7f7f49 | 488 | if (c == 'x') { |
kenjiArai | 0:d68f1e7f7f49 | 489 | radix = 16; |
kenjiArai | 0:d68f1e7f7f49 | 490 | c = *(++(*str)); |
kenjiArai | 0:d68f1e7f7f49 | 491 | } else { |
kenjiArai | 0:d68f1e7f7f49 | 492 | if (c == 'b') { |
kenjiArai | 0:d68f1e7f7f49 | 493 | radix = 2; |
kenjiArai | 0:d68f1e7f7f49 | 494 | c = *(++(*str)); |
kenjiArai | 0:d68f1e7f7f49 | 495 | } else { |
kenjiArai | 0:d68f1e7f7f49 | 496 | if ((c >= '0')&&(c <= '9')) { |
kenjiArai | 0:d68f1e7f7f49 | 497 | radix = 8; |
kenjiArai | 0:d68f1e7f7f49 | 498 | } else { |
kenjiArai | 0:d68f1e7f7f49 | 499 | return 0; |
kenjiArai | 0:d68f1e7f7f49 | 500 | } |
kenjiArai | 0:d68f1e7f7f49 | 501 | } |
kenjiArai | 0:d68f1e7f7f49 | 502 | } |
kenjiArai | 0:d68f1e7f7f49 | 503 | } else { |
kenjiArai | 0:d68f1e7f7f49 | 504 | if ((c < '1')||(c > '9')) { |
kenjiArai | 0:d68f1e7f7f49 | 505 | return 0; |
kenjiArai | 0:d68f1e7f7f49 | 506 | } |
kenjiArai | 0:d68f1e7f7f49 | 507 | radix = 10; |
kenjiArai | 0:d68f1e7f7f49 | 508 | } |
kenjiArai | 0:d68f1e7f7f49 | 509 | val = 0; |
kenjiArai | 0:d68f1e7f7f49 | 510 | while (c > ' ') { |
kenjiArai | 0:d68f1e7f7f49 | 511 | if (c >= 'a') c -= 0x20; |
kenjiArai | 0:d68f1e7f7f49 | 512 | c -= '0'; |
kenjiArai | 0:d68f1e7f7f49 | 513 | if (c >= 17) { |
kenjiArai | 0:d68f1e7f7f49 | 514 | c -= 7; |
kenjiArai | 0:d68f1e7f7f49 | 515 | if (c <= 9) return 0; |
kenjiArai | 0:d68f1e7f7f49 | 516 | } |
kenjiArai | 0:d68f1e7f7f49 | 517 | if (c >= radix) return 0; |
kenjiArai | 0:d68f1e7f7f49 | 518 | val = val * radix + c; |
kenjiArai | 0:d68f1e7f7f49 | 519 | c = *(++(*str)); |
kenjiArai | 0:d68f1e7f7f49 | 520 | } |
kenjiArai | 0:d68f1e7f7f49 | 521 | if (s) val = -val; |
kenjiArai | 0:d68f1e7f7f49 | 522 | *res = val; |
kenjiArai | 0:d68f1e7f7f49 | 523 | return 1; |
kenjiArai | 0:d68f1e7f7f49 | 524 | } |
kenjiArai | 0:d68f1e7f7f49 | 525 | |
kenjiArai | 0:d68f1e7f7f49 | 526 | // Get key input data |
kenjiArai | 0:d68f1e7f7f49 | 527 | void get_line (char *buff, int len) |
kenjiArai | 0:d68f1e7f7f49 | 528 | { |
kenjiArai | 0:d68f1e7f7f49 | 529 | char c; |
kenjiArai | 0:d68f1e7f7f49 | 530 | int idx = 0; |
kenjiArai | 0:d68f1e7f7f49 | 531 | |
kenjiArai | 0:d68f1e7f7f49 | 532 | for (;;) { |
kenjiArai | 0:d68f1e7f7f49 | 533 | c = GETC(); |
kenjiArai | 0:d68f1e7f7f49 | 534 | if (c == '\r') { |
kenjiArai | 0:d68f1e7f7f49 | 535 | buff[idx++] = c; |
kenjiArai | 0:d68f1e7f7f49 | 536 | break; |
kenjiArai | 0:d68f1e7f7f49 | 537 | } |
kenjiArai | 0:d68f1e7f7f49 | 538 | if ((c == '\b') && idx) { |
kenjiArai | 0:d68f1e7f7f49 | 539 | idx--; |
kenjiArai | 0:d68f1e7f7f49 | 540 | PUTC(c); |
kenjiArai | 0:d68f1e7f7f49 | 541 | PUTC(' '); |
kenjiArai | 0:d68f1e7f7f49 | 542 | PUTC(c); |
kenjiArai | 0:d68f1e7f7f49 | 543 | } |
kenjiArai | 0:d68f1e7f7f49 | 544 | if (((uint8_t)c >= ' ') && (idx < len - 1)) { |
kenjiArai | 0:d68f1e7f7f49 | 545 | buff[idx++] = c; |
kenjiArai | 0:d68f1e7f7f49 | 546 | PUTC(c); |
kenjiArai | 3:92f31b23fb0b | 547 | // Special control |
kenjiArai | 3:92f31b23fb0b | 548 | if (one_char == true){ |
kenjiArai | 3:92f31b23fb0b | 549 | if ((c == 'p') || (c == 'm')){ break;} |
kenjiArai | 3:92f31b23fb0b | 550 | } |
kenjiArai | 0:d68f1e7f7f49 | 551 | } |
kenjiArai | 0:d68f1e7f7f49 | 552 | } |
kenjiArai | 0:d68f1e7f7f49 | 553 | buff[idx] = 0; |
kenjiArai | 0:d68f1e7f7f49 | 554 | PUTC('\n'); |
kenjiArai | 0:d68f1e7f7f49 | 555 | } |
kenjiArai | 3:92f31b23fb0b | 556 |