![](/media/cache/group/mebd_thumbnail.jpg.50x50_q85.jpg)
witの生データをとりあえずbinに書き込むだけのプログラム
Dependencies: mbed SDFileSystem
main.cpp@0:d7ab22d75bce, 2021-07-24 (annotated)
- Committer:
- MatsumotoKouki
- Date:
- Sat Jul 24 07:33:28 2021 +0000
- Revision:
- 0:d7ab22d75bce
get data from WIT write them to bin file
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MatsumotoKouki | 0:d7ab22d75bce | 1 | /* mbed Microcontroller Library |
MatsumotoKouki | 0:d7ab22d75bce | 2 | * Copyright (c) 2019 ARM Limited |
MatsumotoKouki | 0:d7ab22d75bce | 3 | * SPDX-License-Identifier: Apache-2.0 |
MatsumotoKouki | 0:d7ab22d75bce | 4 | */ |
MatsumotoKouki | 0:d7ab22d75bce | 5 | |
MatsumotoKouki | 0:d7ab22d75bce | 6 | #include "mbed.h" |
MatsumotoKouki | 0:d7ab22d75bce | 7 | #include "SDFileSystem.h" |
MatsumotoKouki | 0:d7ab22d75bce | 8 | //#include "platform/mbed_thread.h" |
MatsumotoKouki | 0:d7ab22d75bce | 9 | |
MatsumotoKouki | 0:d7ab22d75bce | 10 | Serial jy901(D1,D0); |
MatsumotoKouki | 0:d7ab22d75bce | 11 | Serial pc(USBTX,USBRX); |
MatsumotoKouki | 0:d7ab22d75bce | 12 | SDFileSystem sd(PA_7, PA_6, PA_5, PA_4, "sd"); // the pinout on the mbed Cool Components workshop board |
MatsumotoKouki | 0:d7ab22d75bce | 13 | |
MatsumotoKouki | 0:d7ab22d75bce | 14 | // Blinking rate in milliseconds |
MatsumotoKouki | 0:d7ab22d75bce | 15 | int main() |
MatsumotoKouki | 0:d7ab22d75bce | 16 | { |
MatsumotoKouki | 0:d7ab22d75bce | 17 | jy901.baud(9600); |
MatsumotoKouki | 0:d7ab22d75bce | 18 | printf("Hello World!\n"); |
MatsumotoKouki | 0:d7ab22d75bce | 19 | |
MatsumotoKouki | 0:d7ab22d75bce | 20 | mkdir("/sd/mydir2", 0777); |
MatsumotoKouki | 0:d7ab22d75bce | 21 | FILE *fp = fopen("/sd/mydir2/sdtest.bin", "w"); |
MatsumotoKouki | 0:d7ab22d75bce | 22 | |
MatsumotoKouki | 0:d7ab22d75bce | 23 | if(fp == NULL) { |
MatsumotoKouki | 0:d7ab22d75bce | 24 | error("Could not open file for write\n"); |
MatsumotoKouki | 0:d7ab22d75bce | 25 | } |
MatsumotoKouki | 0:d7ab22d75bce | 26 | |
MatsumotoKouki | 0:d7ab22d75bce | 27 | while(1){ |
MatsumotoKouki | 0:d7ab22d75bce | 28 | fputc(jy901.getc(),fp); |
MatsumotoKouki | 0:d7ab22d75bce | 29 | } |
MatsumotoKouki | 0:d7ab22d75bce | 30 | fclose(fp); |
MatsumotoKouki | 0:d7ab22d75bce | 31 | } |