A code for the spindling of bots.

Dependencies:   MX12 ServoRingBuffer mbed-src

Fork of SpindleBot by MRD Lab

Committer:
labmrd
Date:
Thu Aug 13 17:55:40 2015 +0000
Revision:
14:7c5beaa9fb01
Parent:
4:e44ac08027bd
This revision marks Mark's mark of resignation from the labmrd mbed account.

Who changed what in which revision?

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