Nucleo based high altitude balloon computer
Dependencies: SDFileSystem Venus838 mbed MS5611 TinyGPS
Atlas.cpp@1:678ba5aa45fc, 2014-06-24 (annotated)
- Committer:
- ethanharstad
- Date:
- Tue Jun 24 05:42:15 2014 +0000
- Revision:
- 1:678ba5aa45fc
- Child:
- 2:244d3912b449
Update structure
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ethanharstad | 1:678ba5aa45fc | 1 | #include "mbed.h" |
ethanharstad | 1:678ba5aa45fc | 2 | #include "Atlas.h" |
ethanharstad | 1:678ba5aa45fc | 3 | #include "SDFileSystem.h" |
ethanharstad | 1:678ba5aa45fc | 4 | #include "Venus838.h" |
ethanharstad | 1:678ba5aa45fc | 5 | |
ethanharstad | 1:678ba5aa45fc | 6 | DigitalOut grn(LED_GRN); |
ethanharstad | 1:678ba5aa45fc | 7 | DigitalOut ylw(LED_YLW); |
ethanharstad | 1:678ba5aa45fc | 8 | Serial pc(USBTX, USBRX); |
ethanharstad | 1:678ba5aa45fc | 9 | Venus838 gps(GPS_TX, GPS_RX); |
ethanharstad | 1:678ba5aa45fc | 10 | SDFileSystem sd(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, "sd"); |
ethanharstad | 1:678ba5aa45fc | 11 | |
ethanharstad | 1:678ba5aa45fc | 12 | void init() { |
ethanharstad | 1:678ba5aa45fc | 13 | pc.baud(115200); |
ethanharstad | 1:678ba5aa45fc | 14 | grn = LED_ON; |
ethanharstad | 1:678ba5aa45fc | 15 | ylw = LED_ON; |
ethanharstad | 1:678ba5aa45fc | 16 | |
ethanharstad | 1:678ba5aa45fc | 17 | gps.setUpdateRate(10); |
ethanharstad | 1:678ba5aa45fc | 18 | gps.setNavigationMode(4); |
ethanharstad | 1:678ba5aa45fc | 19 | gps.setNmeaMessages(true, false, false, false, true, false); |
ethanharstad | 1:678ba5aa45fc | 20 | |
ethanharstad | 1:678ba5aa45fc | 21 | printf("Attempting to open SD card...\n"); |
ethanharstad | 1:678ba5aa45fc | 22 | mkdir("/sd/mydir", 0777); |
ethanharstad | 1:678ba5aa45fc | 23 | |
ethanharstad | 1:678ba5aa45fc | 24 | printf("Attempting to open file...\n"); |
ethanharstad | 1:678ba5aa45fc | 25 | FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); |
ethanharstad | 1:678ba5aa45fc | 26 | if(fp == NULL) { |
ethanharstad | 1:678ba5aa45fc | 27 | error("Could not open file for write\n"); |
ethanharstad | 1:678ba5aa45fc | 28 | ylw = LED_OFF; |
ethanharstad | 1:678ba5aa45fc | 29 | } |
ethanharstad | 1:678ba5aa45fc | 30 | fprintf(fp, "Hello fun SD Card World!"); |
ethanharstad | 1:678ba5aa45fc | 31 | |
ethanharstad | 1:678ba5aa45fc | 32 | printf("Closing file...\n"); |
ethanharstad | 1:678ba5aa45fc | 33 | fclose(fp); |
ethanharstad | 1:678ba5aa45fc | 34 | |
ethanharstad | 1:678ba5aa45fc | 35 | pc.printf("Atlas Ready!\n"); |
ethanharstad | 1:678ba5aa45fc | 36 | } |
ethanharstad | 1:678ba5aa45fc | 37 | |
ethanharstad | 1:678ba5aa45fc | 38 | int main() { |
ethanharstad | 1:678ba5aa45fc | 39 | init(); |
ethanharstad | 1:678ba5aa45fc | 40 | while(true) { |
ethanharstad | 1:678ba5aa45fc | 41 | if(gps.readable()) { |
ethanharstad | 1:678ba5aa45fc | 42 | pc.putc(gps.getc()); |
ethanharstad | 1:678ba5aa45fc | 43 | } |
ethanharstad | 1:678ba5aa45fc | 44 | } |
ethanharstad | 1:678ba5aa45fc | 45 | } |