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@1:f7f1c0356ffd, 2020-12-09 (annotated)
- Committer:
- KINU
- Date:
- Wed Dec 09 08:48:04 2020 +0000
- Revision:
- 1:f7f1c0356ffd
- Parent:
- 0:303ad425d2ac
- Child:
- 2:f510a0b084ba
mikansei
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ryouheitakamoto | 0:303ad425d2ac | 1 | #include "mbed.h" |
| ryouheitakamoto | 0:303ad425d2ac | 2 | Serial pc(SERIAL_TX, SERIAL_RX); |
| KINU | 1:f7f1c0356ffd | 3 | Serial device(PA_9,PA_10); |
| ryouheitakamoto | 0:303ad425d2ac | 4 | |
| ryouheitakamoto | 0:303ad425d2ac | 5 | DigitalIn dir(PA_10); |
| KINU | 1:f7f1c0356ffd | 6 | |
| ryouheitakamoto | 0:303ad425d2ac | 7 | int main() |
| ryouheitakamoto | 0:303ad425d2ac | 8 | { |
| KINU | 1:f7f1c0356ffd | 9 | |
| KINU | 1:f7f1c0356ffd | 10 | int bin; |
| KINU | 1:f7f1c0356ffd | 11 | int data[100000]; |
| ryouheitakamoto | 0:303ad425d2ac | 12 | while(1) { |
| KINU | 1:f7f1c0356ffd | 13 | |
| KINU | 1:f7f1c0356ffd | 14 | if(dir) { //データが届いている場合 |
| KINU | 1:f7f1c0356ffd | 15 | |
| KINU | 1:f7f1c0356ffd | 16 | bin = device.getc(); //bin変数に値を入れる |
| KINU | 1:f7f1c0356ffd | 17 | pc.printf("%02hhx ",bin); // デバッグ用 |
| KINU | 1:f7f1c0356ffd | 18 | if(bin == 0xFE){// bin変数の中身がFEの場合、値の取得開始 |
| KINU | 1:f7f1c0356ffd | 19 | pc.printf("start"); |
| KINU | 1:f7f1c0356ffd | 20 | for(int k = 0; k<1000; k++){ |
| KINU | 1:f7f1c0356ffd | 21 | |
| KINU | 1:f7f1c0356ffd | 22 | data[k] == pc.getc(); //データをdata配列に入れる |
| KINU | 1:f7f1c0356ffd | 23 | pc.printf("%02hhx ",data[k]); // デバッグ用 |
| KINU | 1:f7f1c0356ffd | 24 | |
| KINU | 1:f7f1c0356ffd | 25 | if(data[k] == 0xFD)//データが配列の値がFDだった場合 |
| KINU | 1:f7f1c0356ffd | 26 | printf("finish"); |
| KINU | 1:f7f1c0356ffd | 27 | |
| KINU | 1:f7f1c0356ffd | 28 | } |
| KINU | 1:f7f1c0356ffd | 29 | |
| KINU | 1:f7f1c0356ffd | 30 | } |
| KINU | 1:f7f1c0356ffd | 31 | } |
| KINU | 1:f7f1c0356ffd | 32 | |
| ryouheitakamoto | 0:303ad425d2ac | 33 | } |
| KINU | 1:f7f1c0356ffd | 34 | } |
| KINU | 1:f7f1c0356ffd | 35 | |
| KINU | 1:f7f1c0356ffd | 36 | // printf("n = %x n = %X\n", n, n);これでnが16進表記になる |