most functionality to splashdwon, find neutral and start mission. short timeouts still in code for testing, will adjust to go directly to sit_idle after splashdown

Dependencies:   mbed MODSERIAL FATFileSystem

Committer:
joel_ssc
Date:
Mon May 13 19:25:26 2019 +0000
Revision:
92:52a91656458a
Parent:
81:7ff2c6467892
version for first flight test, timeouts not yet set correctly

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tnhnrl 81:7ff2c6467892 1 /* mbed Microcontroller Library
tnhnrl 81:7ff2c6467892 2 * Copyright (c) 2006-2012 ARM Limited
tnhnrl 81:7ff2c6467892 3 *
tnhnrl 81:7ff2c6467892 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
tnhnrl 81:7ff2c6467892 5 * of this software and associated documentation files (the "Software"), to deal
tnhnrl 81:7ff2c6467892 6 * in the Software without restriction, including without limitation the rights
tnhnrl 81:7ff2c6467892 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
tnhnrl 81:7ff2c6467892 8 * copies of the Software, and to permit persons to whom the Software is
tnhnrl 81:7ff2c6467892 9 * furnished to do so, subject to the following conditions:
tnhnrl 81:7ff2c6467892 10 *
tnhnrl 81:7ff2c6467892 11 * The above copyright notice and this permission notice shall be included in
tnhnrl 81:7ff2c6467892 12 * all copies or substantial portions of the Software.
tnhnrl 81:7ff2c6467892 13 *
tnhnrl 81:7ff2c6467892 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
tnhnrl 81:7ff2c6467892 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
tnhnrl 81:7ff2c6467892 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
tnhnrl 81:7ff2c6467892 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
tnhnrl 81:7ff2c6467892 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
tnhnrl 81:7ff2c6467892 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
tnhnrl 81:7ff2c6467892 20 * SOFTWARE.
tnhnrl 81:7ff2c6467892 21 */
tnhnrl 81:7ff2c6467892 22 #ifndef MBED_SDFILESYSTEM_H
tnhnrl 81:7ff2c6467892 23 #define MBED_SDFILESYSTEM_H
tnhnrl 81:7ff2c6467892 24
tnhnrl 81:7ff2c6467892 25 #include "mbed.h"
tnhnrl 81:7ff2c6467892 26 #include "FATFileSystem.h"
tnhnrl 81:7ff2c6467892 27 #include <stdint.h>
tnhnrl 81:7ff2c6467892 28
tnhnrl 81:7ff2c6467892 29 /** Access the filesystem on an SD Card using SPI
tnhnrl 81:7ff2c6467892 30 *
tnhnrl 81:7ff2c6467892 31 * @code
tnhnrl 81:7ff2c6467892 32 * #include "mbed.h"
tnhnrl 81:7ff2c6467892 33 * #include "SDFileSystem.h"
tnhnrl 81:7ff2c6467892 34 *
tnhnrl 81:7ff2c6467892 35 * SDFileSystem sd(p5, p6, p7, p12, "sd"); // mosi, miso, sclk, cs
tnhnrl 81:7ff2c6467892 36 *
tnhnrl 81:7ff2c6467892 37 * int main() {
tnhnrl 81:7ff2c6467892 38 * FILE *fp = fopen("/sd/myfile.txt", "w");
tnhnrl 81:7ff2c6467892 39 * fprintf(fp, "Hello World!\n");
tnhnrl 81:7ff2c6467892 40 * fclose(fp);
tnhnrl 81:7ff2c6467892 41 * }
tnhnrl 81:7ff2c6467892 42 */
tnhnrl 81:7ff2c6467892 43 class SDFileSystem : public FATFileSystem {
tnhnrl 81:7ff2c6467892 44 public:
tnhnrl 81:7ff2c6467892 45
tnhnrl 81:7ff2c6467892 46 /** Create the File System for accessing an SD Card using SPI
tnhnrl 81:7ff2c6467892 47 *
tnhnrl 81:7ff2c6467892 48 * @param mosi SPI mosi pin connected to SD Card
tnhnrl 81:7ff2c6467892 49 * @param miso SPI miso pin conencted to SD Card
tnhnrl 81:7ff2c6467892 50 * @param sclk SPI sclk pin connected to SD Card
tnhnrl 81:7ff2c6467892 51 * @param cs DigitalOut pin used as SD Card chip select
tnhnrl 81:7ff2c6467892 52 * @param name The name used to access the virtual filesystem
tnhnrl 81:7ff2c6467892 53 */
tnhnrl 81:7ff2c6467892 54 SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name);
tnhnrl 81:7ff2c6467892 55 virtual int disk_initialize();
tnhnrl 81:7ff2c6467892 56 virtual int disk_status();
tnhnrl 81:7ff2c6467892 57 virtual int disk_read(uint8_t* buffer, uint32_t block_number, uint32_t count);
tnhnrl 81:7ff2c6467892 58 virtual int disk_write(const uint8_t* buffer, uint32_t block_number, uint32_t count);
tnhnrl 81:7ff2c6467892 59 virtual int disk_sync();
tnhnrl 81:7ff2c6467892 60 virtual uint32_t disk_sectors();
tnhnrl 81:7ff2c6467892 61
tnhnrl 81:7ff2c6467892 62 protected:
tnhnrl 81:7ff2c6467892 63
tnhnrl 81:7ff2c6467892 64 int _cmd(int cmd, int arg);
tnhnrl 81:7ff2c6467892 65 int _cmdx(int cmd, int arg);
tnhnrl 81:7ff2c6467892 66 int _cmd8();
tnhnrl 81:7ff2c6467892 67 int _cmd58();
tnhnrl 81:7ff2c6467892 68 int initialise_card();
tnhnrl 81:7ff2c6467892 69 int initialise_card_v1();
tnhnrl 81:7ff2c6467892 70 int initialise_card_v2();
tnhnrl 81:7ff2c6467892 71
tnhnrl 81:7ff2c6467892 72 int _read(uint8_t * buffer, uint32_t length);
tnhnrl 81:7ff2c6467892 73 int _write(const uint8_t *buffer, uint32_t length);
tnhnrl 81:7ff2c6467892 74 uint32_t _sd_sectors();
tnhnrl 81:7ff2c6467892 75 uint32_t _sectors;
tnhnrl 81:7ff2c6467892 76
tnhnrl 81:7ff2c6467892 77 void set_init_sck(uint32_t sck) { _init_sck = sck; }
tnhnrl 81:7ff2c6467892 78 // Note: The highest SPI clock rate is 20 MHz for MMC and 25 MHz for SD
tnhnrl 81:7ff2c6467892 79 void set_transfer_sck(uint32_t sck) { _transfer_sck = sck; }
tnhnrl 81:7ff2c6467892 80 uint32_t _init_sck;
tnhnrl 81:7ff2c6467892 81 uint32_t _transfer_sck;
tnhnrl 81:7ff2c6467892 82
tnhnrl 81:7ff2c6467892 83 SPI _spi;
tnhnrl 81:7ff2c6467892 84 DigitalOut _cs;
tnhnrl 81:7ff2c6467892 85 int cdv;
tnhnrl 81:7ff2c6467892 86 int _is_initialized;
tnhnrl 81:7ff2c6467892 87 };
tnhnrl 81:7ff2c6467892 88
tnhnrl 81:7ff2c6467892 89 #endif