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