![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
private
Dependencies: ADXL345 FATFileSystem LPS331_SPI mbed
main.cpp@0:e9f20ea63046, 2016-09-22 (annotated)
- Committer:
- obaratakahiro
- Date:
- Thu Sep 22 03:08:19 2016 +0000
- Revision:
- 0:e9f20ea63046
- Child:
- 1:9dc9b228c5b7
SD????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
obaratakahiro | 0:e9f20ea63046 | 1 | #include "mbed.h" |
obaratakahiro | 0:e9f20ea63046 | 2 | #include "SDFileSystem.h" |
obaratakahiro | 0:e9f20ea63046 | 3 | #include "LPS331_SPI.h" |
obaratakahiro | 0:e9f20ea63046 | 4 | DigitalOut myled(LED1); |
obaratakahiro | 0:e9f20ea63046 | 5 | LPS331_SPI press(dp2, dp1, dp6, dp26); |
obaratakahiro | 0:e9f20ea63046 | 6 | SDFileSystem sd(dp2, dp1, dp6, dp17, "sd"); |
obaratakahiro | 0:e9f20ea63046 | 7 | |
obaratakahiro | 0:e9f20ea63046 | 8 | int main() |
obaratakahiro | 0:e9f20ea63046 | 9 | { |
obaratakahiro | 0:e9f20ea63046 | 10 | |
obaratakahiro | 0:e9f20ea63046 | 11 | press.quickStart(); |
obaratakahiro | 0:e9f20ea63046 | 12 | |
obaratakahiro | 0:e9f20ea63046 | 13 | int count; |
obaratakahiro | 0:e9f20ea63046 | 14 | |
obaratakahiro | 0:e9f20ea63046 | 15 | while(1){ |
obaratakahiro | 0:e9f20ea63046 | 16 | FILE *fp = fopen("/sd/sdtest.txt", "a"); |
obaratakahiro | 0:e9f20ea63046 | 17 | if(fp == NULL) { |
obaratakahiro | 0:e9f20ea63046 | 18 | error("Could not open file for write\n"); |
obaratakahiro | 0:e9f20ea63046 | 19 | } |
obaratakahiro | 0:e9f20ea63046 | 20 | |
obaratakahiro | 0:e9f20ea63046 | 21 | float pressure; |
obaratakahiro | 0:e9f20ea63046 | 22 | pressure = press.getPressure(); |
obaratakahiro | 0:e9f20ea63046 | 23 | |
obaratakahiro | 0:e9f20ea63046 | 24 | count = fprintf(fp, "%f\r\n",pressure); |
obaratakahiro | 0:e9f20ea63046 | 25 | if ( count < 0 ) { |
obaratakahiro | 0:e9f20ea63046 | 26 | printf("ファイルの書込みに失敗しました.\n"); |
obaratakahiro | 0:e9f20ea63046 | 27 | |
obaratakahiro | 0:e9f20ea63046 | 28 | } |
obaratakahiro | 0:e9f20ea63046 | 29 | |
obaratakahiro | 0:e9f20ea63046 | 30 | |
obaratakahiro | 0:e9f20ea63046 | 31 | fclose(fp); |
obaratakahiro | 0:e9f20ea63046 | 32 | myled = !myled; |
obaratakahiro | 0:e9f20ea63046 | 33 | wait(0.5); |
obaratakahiro | 0:e9f20ea63046 | 34 | } |
obaratakahiro | 0:e9f20ea63046 | 35 | |
obaratakahiro | 0:e9f20ea63046 | 36 | |
obaratakahiro | 0:e9f20ea63046 | 37 | |
obaratakahiro | 0:e9f20ea63046 | 38 | |
obaratakahiro | 0:e9f20ea63046 | 39 | } |