Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp@5:215407735ff3, 2021-03-25 (annotated)
- Committer:
- KINU
- Date:
- Thu Mar 25 13:46:14 2021 +0000
- Revision:
- 5:215407735ff3
- Parent:
- 4:a263257f3a2b
- Child:
- 6:85891eee5322
wertyui
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
KINU | 0:4f081a382f9b | 1 | #include <mbed.h> |
KINU | 0:4f081a382f9b | 2 | #include <stdio.h> |
KINU | 0:4f081a382f9b | 3 | #include <stdlib.h> |
KINU | 0:4f081a382f9b | 4 | Serial pc(USBTX, USBRX,921600); |
KINU | 0:4f081a382f9b | 5 | Serial device( p9, p10, 9600); |
KINU | 0:4f081a382f9b | 6 | #define kHz 1000 |
KINU | 0:4f081a382f9b | 7 | #define MHz 1000000 |
KINU | 0:4f081a382f9b | 8 | #define PFD 19.68 |
KINU | 0:4f081a382f9b | 9 | LocalFileSystem local("local"); |
KINU | 0:4f081a382f9b | 10 | #pragma diag_suppress 870 |
KINU | 0:4f081a382f9b | 11 | class calsat32 |
KINU | 0:4f081a382f9b | 12 | { |
KINU | 0:4f081a382f9b | 13 | public: |
KINU | 0:4f081a382f9b | 14 | int Fractional_N; |
KINU | 0:4f081a382f9b | 15 | int Integer_N; |
KINU | 0:4f081a382f9b | 16 | int intbin[8]; |
KINU | 0:4f081a382f9b | 17 | int decbin[15]; |
KINU | 0:4f081a382f9b | 18 | int register_data;//レジスタへ入れるファイルから読み込んだ10進数の値 |
KINU | 0:4f081a382f9b | 19 | int length; //値の長さ |
KINU | 0:4f081a382f9b | 20 | int size;//累計の長さこれが32となったら1つのレジスタの設定が完了として次のレジスタの設定へ移る |
KINU | 0:4f081a382f9b | 21 | int register_num;//レジスタ番号 |
KINU | 0:4f081a382f9b | 22 | int buf; |
KINU | 0:4f081a382f9b | 23 | char _command[128]; |
KINU | 1:515864d13410 | 24 | double human_freq; //人から受け取る周波数の値 |
KINU | 0:4f081a382f9b | 25 | uint32_t _register;//最終的に欲しいレジスタの値.32ビット |
KINU | 2:0a0b5c62d10c | 26 | uint32_t register_data_array[16];//完成したレジスターを格納する配列 |
KINU | 5:215407735ff3 | 27 | uint32_t reg0;//reg0_gen に渡す用の配列 |
KINU | 0:4f081a382f9b | 28 | const char* filename; |
KINU | 0:4f081a382f9b | 29 | FILE *fp; |
KINU | 0:4f081a382f9b | 30 | calsat32() |
KINU | 0:4f081a382f9b | 31 | { |
KINU | 0:4f081a382f9b | 32 | Fractional_N = 0; |
KINU | 0:4f081a382f9b | 33 | Integer_N = 0; |
KINU | 0:4f081a382f9b | 34 | register_data = 0;//レジスタへ入れる1ファイルから読み込んだ10進数の値 |
KINU | 0:4f081a382f9b | 35 | length = 0; //値の長さ |
KINU | 0:4f081a382f9b | 36 | size = 0;//累計の長さこれが32となったら1つのレジスタの設定が完了として次のレジスタの設定へ移る |
KINU | 0:4f081a382f9b | 37 | register_num = 1;//レジスタ番号 |
KINU | 0:4f081a382f9b | 38 | filename = "/local/register.tsv"; |
KINU | 0:4f081a382f9b | 39 | _register = 0; |
KINU | 1:515864d13410 | 40 | human_freq = 0; |
KINU | 0:4f081a382f9b | 41 | } |
KINU | 0:4f081a382f9b | 42 | //main関数内でコマンドが0x00の時にmainでbinary()を呼ぶと計算をしてuint_32型の値を返す |
KINU | 3:e6d72c02e045 | 43 | uint32_t Reg0_gen(int key,double calsat_freq,double human_freq ) |
KINU | 3:e6d72c02e045 | 44 | { |
KINU | 5:215407735ff3 | 45 | printf("%lf %lf\r\n",calsat_freq,human_freq); |
KINU | 3:e6d72c02e045 | 46 | uint32_t freq_bit; |
KINU | 5:215407735ff3 | 47 | uint32_t tmp = 0; |
KINU | 4:a263257f3a2b | 48 | if(key == '0') { |
KINU | 5:215407735ff3 | 49 | /* printf("reg0= "); |
KINU | 5:215407735ff3 | 50 | for(int i = 32; i > 0; i--) {//デバッグ用 |
KINU | 5:215407735ff3 | 51 | if(reg0& (1 << (i - 1))) { |
KINU | 5:215407735ff3 | 52 | pc.printf("1"); |
KINU | 5:215407735ff3 | 53 | } else { |
KINU | 5:215407735ff3 | 54 | pc.printf("0"); |
KINU | 5:215407735ff3 | 55 | } |
KINU | 5:215407735ff3 | 56 | }*/ |
KINU | 5:215407735ff3 | 57 | printf("\r\n"); |
KINU | 5:215407735ff3 | 58 | |
KINU | 5:215407735ff3 | 59 | tmp = reg0 >> 27; //この行と次の行でレジスタのデータの部分を全て0にしている |
KINU | 5:215407735ff3 | 60 | tmp = tmp << 27; |
KINU | 5:215407735ff3 | 61 | for(int i = 32; i > 0; i--) {//デバッグ用 |
KINU | 4:a263257f3a2b | 62 | if(tmp & (1 << (i - 1))) { |
KINU | 4:a263257f3a2b | 63 | pc.printf("1"); |
KINU | 4:a263257f3a2b | 64 | } else { |
KINU | 4:a263257f3a2b | 65 | pc.printf("0"); |
KINU | 4:a263257f3a2b | 66 | } |
KINU | 4:a263257f3a2b | 67 | } |
KINU | 5:215407735ff3 | 68 | printf("\r\n"); //001110000000000…が出力 |
KINU | 5:215407735ff3 | 69 | |
KINU | 5:215407735ff3 | 70 | freq_bit = binary(calsat_freq)<<4; |
KINU | 5:215407735ff3 | 71 | printf("freq_bit=");//デバッグ用 |
KINU | 5:215407735ff3 | 72 | for(int i = 32; i > 0; i--) { |
KINU | 5:215407735ff3 | 73 | if(freq_bit & (1 << (i - 1))) { |
KINU | 5:215407735ff3 | 74 | pc.printf("1"); |
KINU | 5:215407735ff3 | 75 | } else { |
KINU | 5:215407735ff3 | 76 | pc.printf("0"); //00000[23bit]0000が出力 |
KINU | 5:215407735ff3 | 77 | } |
KINU | 5:215407735ff3 | 78 | } |
KINU | 4:a263257f3a2b | 79 | printf("\r\n"); |
KINU | 5:215407735ff3 | 80 | /*printf("freq_bit0=");//デバッグ用 |
KINU | 5:215407735ff3 | 81 | for(int i = 32; i > 0; i--) { |
KINU | 5:215407735ff3 | 82 | if(freq_bit & (1 << (i - 1))) { |
KINU | 5:215407735ff3 | 83 | pc.printf("1"); |
KINU | 5:215407735ff3 | 84 | } else { |
KINU | 5:215407735ff3 | 85 | pc.printf("0"); |
KINU | 5:215407735ff3 | 86 | } |
KINU | 5:215407735ff3 | 87 | } |
KINU | 5:215407735ff3 | 88 | printf("\r\n");*/ |
KINU | 5:215407735ff3 | 89 | /*freq_bit = freq_bit>>5; |
KINU | 5:215407735ff3 | 90 | printf("freq_bit5 = ");//デバッグ用 |
KINU | 5:215407735ff3 | 91 | for(int i = 28; i > 0; i--) { |
KINU | 5:215407735ff3 | 92 | if(freq_bit & (1 << (i - 1))) { |
KINU | 5:215407735ff3 | 93 | pc.printf("1"); |
KINU | 5:215407735ff3 | 94 | } else { |
KINU | 5:215407735ff3 | 95 | pc.printf("0"); |
KINU | 5:215407735ff3 | 96 | } |
KINU | 5:215407735ff3 | 97 | } |
KINU | 5:215407735ff3 | 98 | printf("\r\n");*/ |
KINU | 5:215407735ff3 | 99 | |
KINU | 5:215407735ff3 | 100 | /*freq_bit = freq_bit<<4; |
KINU | 5:215407735ff3 | 101 | printf("freq_bit4 = ");//デバッグ用 |
KINU | 5:215407735ff3 | 102 | for(int i = 32; i > 0; i--) { |
KINU | 5:215407735ff3 | 103 | if(freq_bit & (1 << (i - 1))) { |
KINU | 5:215407735ff3 | 104 | pc.printf("1"); |
KINU | 5:215407735ff3 | 105 | } else { |
KINU | 5:215407735ff3 | 106 | pc.printf("0"); |
KINU | 5:215407735ff3 | 107 | } |
KINU | 5:215407735ff3 | 108 | } |
KINU | 5:215407735ff3 | 109 | printf("\r\n");*/ |
KINU | 5:215407735ff3 | 110 | tmp |= freq_bit; |
KINU | 5:215407735ff3 | 111 | register_data_array[2] = tmp; |
KINU | 5:215407735ff3 | 112 | printf("register_data_array[2]=");//デバッグ用 |
KINU | 5:215407735ff3 | 113 | for(int i = 32; i > 0; i--) { |
KINU | 4:a263257f3a2b | 114 | if(tmp & (1 << (i - 1))) { |
KINU | 4:a263257f3a2b | 115 | pc.printf("1"); |
KINU | 4:a263257f3a2b | 116 | } else { |
KINU | 4:a263257f3a2b | 117 | pc.printf("0"); |
KINU | 4:a263257f3a2b | 118 | } |
KINU | 4:a263257f3a2b | 119 | } |
KINU | 4:a263257f3a2b | 120 | printf("\r\n"); |
KINU | 4:a263257f3a2b | 121 | } else if(key == '1') { |
KINU | 5:215407735ff3 | 122 | |
KINU | 4:a263257f3a2b | 123 | freq_bit = binary(calsat_freq); |
KINU | 5:215407735ff3 | 124 | tmp = freq_bit<<4; |
KINU | 3:e6d72c02e045 | 125 | |
KINU | 3:e6d72c02e045 | 126 | } else if(key =='2') { //calsatから受けとる |
KINU | 3:e6d72c02e045 | 127 | freq_bit = binary(human_freq); |
KINU | 5:215407735ff3 | 128 | tmp = freq_bit<<4; |
KINU | 3:e6d72c02e045 | 129 | } |
KINU | 5:215407735ff3 | 130 | /*else if(key == '3') { |
KINU | 3:e6d72c02e045 | 131 | uint32_t tmp = 0; |
KINU | 5:215407735ff3 | 132 | tmp = reg0 >> 27; //この行と次の行でレジスタのデータの部分を全て0にしている |
KINU | 5:215407735ff3 | 133 | tmp = tmp << 27; |
KINU | 5:215407735ff3 | 134 | freq_bit = binary(human_freq); |
KINU | 5:215407735ff3 | 135 | freq_bit = freq_bit<<4; |
KINU | 5:215407735ff3 | 136 | tmp |= freq_bit; |
KINU | 3:e6d72c02e045 | 137 | register_data_array[2] = tmp;//配列の中に格納する |
KINU | 3:e6d72c02e045 | 138 | show_all(); |
KINU | 4:a263257f3a2b | 139 | */ |
KINU | 3:e6d72c02e045 | 140 | else {} |
KINU | 3:e6d72c02e045 | 141 | |
KINU | 5:215407735ff3 | 142 | for(int i = 32; i > 0; i--) { |
KINU | 5:215407735ff3 | 143 | if(tmp & (1 << (i - 1))) { |
KINU | 2:0a0b5c62d10c | 144 | pc.printf("1"); |
KINU | 2:0a0b5c62d10c | 145 | } else { |
KINU | 2:0a0b5c62d10c | 146 | pc.printf("0"); |
KINU | 2:0a0b5c62d10c | 147 | } |
KINU | 2:0a0b5c62d10c | 148 | } |
KINU | 3:e6d72c02e045 | 149 | |
KINU | 3:e6d72c02e045 | 150 | printf("\r\n"); |
KINU | 3:e6d72c02e045 | 151 | return freq_bit; |
KINU | 3:e6d72c02e045 | 152 | |
KINU | 1:515864d13410 | 153 | } |
KINU | 0:4f081a382f9b | 154 | void Shift_bit(uint32_t& Register, int Register_data, int Size) |
KINU | 0:4f081a382f9b | 155 | { |
KINU | 0:4f081a382f9b | 156 | Register |= (Register_data << Size); |
KINU | 0:4f081a382f9b | 157 | } |
KINU | 3:e6d72c02e045 | 158 | void file_read(char key,double calsat_freq) |
KINU | 0:4f081a382f9b | 159 | { |
KINU | 0:4f081a382f9b | 160 | /* ファイルのオープン */ |
KINU | 0:4f081a382f9b | 161 | char name[100] = {};//出力はしない |
KINU | 0:4f081a382f9b | 162 | if ((fp = fopen("/local/register.tsv", "r")) == NULL) { |
KINU | 0:4f081a382f9b | 163 | fprintf(stderr, "%sのオープンに失敗しました.\r\n", filename); |
KINU | 0:4f081a382f9b | 164 | exit(EXIT_FAILURE); |
KINU | 0:4f081a382f9b | 165 | } |
KINU | 0:4f081a382f9b | 166 | /* ファイルの終端まで文字を読み取り表示する */ |
KINU | 0:4f081a382f9b | 167 | int num[5] = {1,3,0,5,4}; |
KINU | 0:4f081a382f9b | 168 | int l = 1;//行数 |
KINU | 0:4f081a382f9b | 169 | uint32_t _register = 0;//最終的に欲しいレジスタの値.32ビット |
KINU | 0:4f081a382f9b | 170 | while ( fscanf(fp,"%s%d%d%d",name, ®ister_data,&length,&buf) != EOF ) { |
KINU | 0:4f081a382f9b | 171 | if(l == 1 || l == 14 || l == 21 ||l == 27 || l == 37) { |
KINU | 0:4f081a382f9b | 172 | printf("%d\r\n",l); |
KINU | 0:4f081a382f9b | 173 | l++; |
KINU | 0:4f081a382f9b | 174 | } else { |
KINU | 0:4f081a382f9b | 175 | printf(" %d %d %d \r\n",register_data, length,size); |
KINU | 0:4f081a382f9b | 176 | if(l==23) { |
KINU | 3:e6d72c02e045 | 177 | /*if(key == '1') |
KINU | 1:515864d13410 | 178 | Shift_bit(_register, binary(calsat_freq), 4); |
KINU | 1:515864d13410 | 179 | if(key == '2')*/ |
KINU | 3:e6d72c02e045 | 180 | human_freq = register_data; |
KINU | 3:e6d72c02e045 | 181 | // Shift_bit(_register, binary(register_data), 4); |
KINU | 3:e6d72c02e045 | 182 | _register = Reg0_gen(key, calsat_freq, human_freq ); |
KINU | 3:e6d72c02e045 | 183 | |
KINU | 3:e6d72c02e045 | 184 | for(int i = 27; i > 0; i--) {//デバッグ用 |
KINU | 3:e6d72c02e045 | 185 | if(_register & (1 << (i - 1))) { |
KINU | 3:e6d72c02e045 | 186 | pc.printf("1"); |
KINU | 3:e6d72c02e045 | 187 | } else { |
KINU | 3:e6d72c02e045 | 188 | pc.printf("0"); |
KINU | 3:e6d72c02e045 | 189 | } |
KINU | 3:e6d72c02e045 | 190 | } |
KINU | 4:a263257f3a2b | 191 | printf("\r\n"); |
KINU | 4:a263257f3a2b | 192 | size = 27; |
KINU | 0:4f081a382f9b | 193 | //テキストファイルから受け取った値を格納するとき |
KINU | 0:4f081a382f9b | 194 | } else { |
KINU | 0:4f081a382f9b | 195 | Shift_bit(_register, register_data, size); |
KINU | 0:4f081a382f9b | 196 | size += length; |
KINU | 0:4f081a382f9b | 197 | if(register_num == 1 && size == 26) { |
KINU | 0:4f081a382f9b | 198 | printf(" = reg_%d ",num[register_num - 1]); |
KINU | 0:4f081a382f9b | 199 | show(_register); |
KINU | 0:4f081a382f9b | 200 | register_num++; |
KINU | 2:0a0b5c62d10c | 201 | //_register = 0; |
KINU | 0:4f081a382f9b | 202 | size = 0; |
KINU | 0:4f081a382f9b | 203 | } |
KINU | 0:4f081a382f9b | 204 | if(size == 32) { |
KINU | 2:0a0b5c62d10c | 205 | //これで一つ完成. |
KINU | 0:4f081a382f9b | 206 | printf(" = reg_%d ",num[register_num - 1]); |
KINU | 0:4f081a382f9b | 207 | show(_register); |
KINU | 0:4f081a382f9b | 208 | register_num++; |
KINU | 0:4f081a382f9b | 209 | _register = 0; |
KINU | 0:4f081a382f9b | 210 | size = 0; |
KINU | 0:4f081a382f9b | 211 | } |
KINU | 0:4f081a382f9b | 212 | } |
KINU | 0:4f081a382f9b | 213 | l++; |
KINU | 0:4f081a382f9b | 214 | } |
KINU | 0:4f081a382f9b | 215 | } |
KINU | 0:4f081a382f9b | 216 | /* ファイルのクローズ */ |
KINU | 0:4f081a382f9b | 217 | fclose(fp); |
KINU | 0:4f081a382f9b | 218 | } |
KINU | 4:a263257f3a2b | 219 | uint32_t binary(double RFout) |
KINU | 0:4f081a382f9b | 220 | { |
KINU | 0:4f081a382f9b | 221 | double n = RFout * 2 / PFD; |
KINU | 0:4f081a382f9b | 222 | Integer_N = (int)n; |
KINU | 0:4f081a382f9b | 223 | double test = (n - (int)n); |
KINU | 0:4f081a382f9b | 224 | Fractional_N = test*32768; |
KINU | 0:4f081a382f9b | 225 | uint32_t data = Fractional_N; |
KINU | 0:4f081a382f9b | 226 | return data |= (Integer_N << 15);//レジスタ入力に適した形にした23桁の2進数を返す |
KINU | 0:4f081a382f9b | 227 | } |
KINU | 0:4f081a382f9b | 228 | //データを取得し返す関数 |
KINU | 0:4f081a382f9b | 229 | double doppler(char *a) |
KINU | 0:4f081a382f9b | 230 | { |
KINU | 0:4f081a382f9b | 231 | int data[10] = {0}; |
KINU | 1:515864d13410 | 232 | double calsat_freq = 0; |
KINU | 0:4f081a382f9b | 233 | int flag = 0; |
KINU | 0:4f081a382f9b | 234 | for(int i = 5; i < 10; i++) { |
KINU | 0:4f081a382f9b | 235 | char c = a[i]; |
KINU | 0:4f081a382f9b | 236 | data[flag] = (c >> 4) & 0xf; |
KINU | 0:4f081a382f9b | 237 | data[flag+1] = c & 0xf; |
KINU | 0:4f081a382f9b | 238 | flag += 2; |
KINU | 0:4f081a382f9b | 239 | } |
KINU | 1:515864d13410 | 240 | calsat_freq = 10 * data[0] + data[1] + kHz * data[2] + 100 * data[3] + 100*kHz * data[4] + 10*kHz * data[5] + 10*MHz * data[6] + MHz * data[7] + data[8] + 100*MHz * data[9];//Hz |
KINU | 3:e6d72c02e045 | 241 | printf("\n%lf\r\n",calsat_freq / 1000000); //Mhz |
KINU | 1:515864d13410 | 242 | return calsat_freq / 1000000; |
KINU | 0:4f081a382f9b | 243 | } |
KINU | 0:4f081a382f9b | 244 | void show(uint32_t bin) |
KINU | 0:4f081a382f9b | 245 | { |
KINU | 0:4f081a382f9b | 246 | static int reg_num = 0; |
KINU | 0:4f081a382f9b | 247 | //表示フェーズ |
KINU | 0:4f081a382f9b | 248 | for(int i = 32; i > 0; i--) { |
KINU | 0:4f081a382f9b | 249 | if(bin & (1 << (i - 1))) { |
KINU | 0:4f081a382f9b | 250 | pc.printf("1"); |
KINU | 0:4f081a382f9b | 251 | } else { |
KINU | 0:4f081a382f9b | 252 | pc.printf("0"); |
KINU | 0:4f081a382f9b | 253 | } |
KINU | 0:4f081a382f9b | 254 | } |
KINU | 0:4f081a382f9b | 255 | printf("\r\n"); |
KINU | 0:4f081a382f9b | 256 | //格納フェーズ |
KINU | 0:4f081a382f9b | 257 | register_data_array[reg_num] = bin; |
KINU | 5:215407735ff3 | 258 | if(reg_num == 2) |
KINU | 5:215407735ff3 | 259 | reg0 = bin; |
KINU | 0:4f081a382f9b | 260 | reg_num++; |
KINU | 0:4f081a382f9b | 261 | if(reg_num == 4) { |
KINU | 0:4f081a382f9b | 262 | reg_num = 0; |
KINU | 0:4f081a382f9b | 263 | } |
KINU | 0:4f081a382f9b | 264 | } |
KINU | 0:4f081a382f9b | 265 | void show_all()//完成したレジスタの値を出力 |
KINU | 0:4f081a382f9b | 266 | { |
KINU | 0:4f081a382f9b | 267 | for(int j = 0; j < 5; j++) { |
KINU | 0:4f081a382f9b | 268 | for(int i = 32; i > 0; i--) { |
KINU | 0:4f081a382f9b | 269 | if(register_data_array[j] & (1 << (i - 1))) { |
KINU | 0:4f081a382f9b | 270 | pc.printf("1"); |
KINU | 0:4f081a382f9b | 271 | } else { |
KINU | 0:4f081a382f9b | 272 | pc.printf("0"); |
KINU | 0:4f081a382f9b | 273 | } |
KINU | 0:4f081a382f9b | 274 | } |
KINU | 0:4f081a382f9b | 275 | printf("\r\n"); |
KINU | 0:4f081a382f9b | 276 | } |
KINU | 0:4f081a382f9b | 277 | } |
KINU | 1:515864d13410 | 278 | double packet(char c) |
KINU | 0:4f081a382f9b | 279 | { |
KINU | 0:4f081a382f9b | 280 | static int a = 0; |
KINU | 1:515864d13410 | 281 | double calsat_freq; |
KINU | 0:4f081a382f9b | 282 | _command[a] = c; |
KINU | 0:4f081a382f9b | 283 | a++; |
KINU | 0:4f081a382f9b | 284 | if(_command[a-1] == 0xfd) { |
KINU | 3:e6d72c02e045 | 285 | calsat_freq = doppler(_command); |
KINU | 5:215407735ff3 | 286 | _register = Reg0_gen('0', calsat_freq, human_freq); //reg0をcalsatの値で更新 |
KINU | 0:4f081a382f9b | 287 | /* |
KINU | 0:4f081a382f9b | 288 | for(int j = 0; j < a; j++) |
KINU | 0:4f081a382f9b | 289 | printf("%02hhx",_command[j]); |
KINU | 0:4f081a382f9b | 290 | printf("\r\n"); |
KINU | 0:4f081a382f9b | 291 | */ |
KINU | 0:4f081a382f9b | 292 | a = 0; |
KINU | 0:4f081a382f9b | 293 | } |
KINU | 1:515864d13410 | 294 | return calsat_freq; |
KINU | 0:4f081a382f9b | 295 | } |
KINU | 1:515864d13410 | 296 | void check(char key,double calsat_freq) |
KINU | 0:4f081a382f9b | 297 | { |
KINU | 2:0a0b5c62d10c | 298 | printf("key = %c\r\n",key); |
KINU | 0:4f081a382f9b | 299 | if(_command[4] == 0x00) { |
KINU | 0:4f081a382f9b | 300 | printf("---------------------------Start-----------------------------\r\n"); |
KINU | 1:515864d13410 | 301 | file_read(key,calsat_freq); |
KINU | 0:4f081a382f9b | 302 | } |
KINU | 0:4f081a382f9b | 303 | } |
KINU | 0:4f081a382f9b | 304 | }; |
KINU | 0:4f081a382f9b | 305 | int main() |
KINU | 0:4f081a382f9b | 306 | { |
KINU | 0:4f081a382f9b | 307 | Serial device( p9, p10, 9600); |
KINU | 2:0a0b5c62d10c | 308 | printf("Start\r\n"); |
KINU | 0:4f081a382f9b | 309 | while(1) { |
KINU | 0:4f081a382f9b | 310 | calsat32 tmp; |
KINU | 0:4f081a382f9b | 311 | while(device.readable()) { |
KINU | 3:e6d72c02e045 | 312 | |
KINU | 0:4f081a382f9b | 313 | char c = device.getc(); |
KINU | 1:515864d13410 | 314 | double calsat_freq = tmp.packet(c); |
KINU | 0:4f081a382f9b | 315 | if(pc.readable()) { |
KINU | 0:4f081a382f9b | 316 | char key = pc.getc(); |
KINU | 3:e6d72c02e045 | 317 | if(key == '1' ||key == '2') { |
KINU | 3:e6d72c02e045 | 318 | tmp.check(key,calsat_freq); |
KINU | 3:e6d72c02e045 | 319 | //file読み込み、calsator人の更新 |
KINU | 3:e6d72c02e045 | 320 | } else if(key == '3') //reg0を人にする |
KINU | 3:e6d72c02e045 | 321 | tmp.check(key,calsat_freq); |
KINU | 5:215407735ff3 | 322 | else if(key == '0') //reg0を人にする |
KINU | 4:a263257f3a2b | 323 | tmp.check(key,calsat_freq); |
KINU | 0:4f081a382f9b | 324 | } |
KINU | 0:4f081a382f9b | 325 | } |
KINU | 0:4f081a382f9b | 326 | } |
KINU | 0:4f081a382f9b | 327 | return 0; |
KINU | 0:4f081a382f9b | 328 | } |