This package contains a simple test of tests for various elements of the SmartBoard hardware, which is a simple baseboard designed for easy embedding. It is able to run both a semi-automatic test suite as well as allow interactive testing.
Dependencies: EthernetNetIf NTPClient_NetServices mbed
This program is most of what you need to test your SmartBoard baseboard hardware. It provides a means to test the following:
- Two channels of CAN (with a loopback cable)
- RS-232 Ports
- Analog inputs
- PWM outputs
- Ethernet port
- Real time clock
- micro SD
- USB Host port
SDFileSystem.h@0:5db287f0060b, 2011-01-16 (annotated)
- Committer:
- WiredHome
- Date:
- Sun Jan 16 18:30:14 2011 +0000
- Revision:
- 0:5db287f0060b
First release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
WiredHome | 0:5db287f0060b | 1 | /* mbed SDFileSystem Library, for providing file access to SD cards |
WiredHome | 0:5db287f0060b | 2 | * Copyright (c) 2008-2010, sford |
WiredHome | 0:5db287f0060b | 3 | * |
WiredHome | 0:5db287f0060b | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
WiredHome | 0:5db287f0060b | 5 | * of this software and associated documentation files (the "Software"), to deal |
WiredHome | 0:5db287f0060b | 6 | * in the Software without restriction, including without limitation the rights |
WiredHome | 0:5db287f0060b | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
WiredHome | 0:5db287f0060b | 8 | * copies of the Software, and to permit persons to whom the Software is |
WiredHome | 0:5db287f0060b | 9 | * furnished to do so, subject to the following conditions: |
WiredHome | 0:5db287f0060b | 10 | * |
WiredHome | 0:5db287f0060b | 11 | * The above copyright notice and this permission notice shall be included in |
WiredHome | 0:5db287f0060b | 12 | * all copies or substantial portions of the Software. |
WiredHome | 0:5db287f0060b | 13 | * |
WiredHome | 0:5db287f0060b | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
WiredHome | 0:5db287f0060b | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
WiredHome | 0:5db287f0060b | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
WiredHome | 0:5db287f0060b | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
WiredHome | 0:5db287f0060b | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
WiredHome | 0:5db287f0060b | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
WiredHome | 0:5db287f0060b | 20 | * THE SOFTWARE. |
WiredHome | 0:5db287f0060b | 21 | */ |
WiredHome | 0:5db287f0060b | 22 | |
WiredHome | 0:5db287f0060b | 23 | #ifndef MBED_SDFILESYSTEM_H |
WiredHome | 0:5db287f0060b | 24 | #define MBED_SDFILESYSTEM_H |
WiredHome | 0:5db287f0060b | 25 | |
WiredHome | 0:5db287f0060b | 26 | #include "mbed.h" |
WiredHome | 0:5db287f0060b | 27 | #include "FATFileSystem.h" |
WiredHome | 0:5db287f0060b | 28 | |
WiredHome | 0:5db287f0060b | 29 | /** Access the filesystem on an SD Card using SPI |
WiredHome | 0:5db287f0060b | 30 | * |
WiredHome | 0:5db287f0060b | 31 | * @code |
WiredHome | 0:5db287f0060b | 32 | * #include "mbed.h" |
WiredHome | 0:5db287f0060b | 33 | * #include "SDFileSystem.h" |
WiredHome | 0:5db287f0060b | 34 | * |
WiredHome | 0:5db287f0060b | 35 | * SDFileSystem sd(p5, p6, p7, p12, "sd"); // mosi, miso, sclk, cs |
WiredHome | 0:5db287f0060b | 36 | * |
WiredHome | 0:5db287f0060b | 37 | * int main() { |
WiredHome | 0:5db287f0060b | 38 | * FILE *fp = fopen("/sd/myfile.txt", "w"); |
WiredHome | 0:5db287f0060b | 39 | * fprintf(fp, "Hello World!\n"); |
WiredHome | 0:5db287f0060b | 40 | * fclose(fp); |
WiredHome | 0:5db287f0060b | 41 | * } |
WiredHome | 0:5db287f0060b | 42 | */ |
WiredHome | 0:5db287f0060b | 43 | class SDFileSystem : public FATFileSystem { |
WiredHome | 0:5db287f0060b | 44 | public: |
WiredHome | 0:5db287f0060b | 45 | |
WiredHome | 0:5db287f0060b | 46 | /** Create the File System for accessing an SD Card using SPI |
WiredHome | 0:5db287f0060b | 47 | * |
WiredHome | 0:5db287f0060b | 48 | * @param mosi SPI mosi pin connected to SD Card |
WiredHome | 0:5db287f0060b | 49 | * @param miso SPI miso pin conencted to SD Card |
WiredHome | 0:5db287f0060b | 50 | * @param sclk SPI sclk pin connected to SD Card |
WiredHome | 0:5db287f0060b | 51 | * @param cs DigitalOut pin used as SD Card chip select |
WiredHome | 0:5db287f0060b | 52 | * @param name The name used to access the virtual filesystem |
WiredHome | 0:5db287f0060b | 53 | */ |
WiredHome | 0:5db287f0060b | 54 | SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name); |
WiredHome | 0:5db287f0060b | 55 | virtual int disk_initialize(); |
WiredHome | 0:5db287f0060b | 56 | virtual int disk_write(const char *buffer, int block_number); |
WiredHome | 0:5db287f0060b | 57 | virtual int disk_read(char *buffer, int block_number); |
WiredHome | 0:5db287f0060b | 58 | virtual int disk_status(); |
WiredHome | 0:5db287f0060b | 59 | virtual int disk_sync(); |
WiredHome | 0:5db287f0060b | 60 | virtual int disk_sectors(); |
WiredHome | 0:5db287f0060b | 61 | |
WiredHome | 0:5db287f0060b | 62 | protected: |
WiredHome | 0:5db287f0060b | 63 | |
WiredHome | 0:5db287f0060b | 64 | int _cmd(int cmd, int arg); |
WiredHome | 0:5db287f0060b | 65 | int _cmdx(int cmd, int arg); |
WiredHome | 0:5db287f0060b | 66 | int _cmd8(); |
WiredHome | 0:5db287f0060b | 67 | int _cmd58(); |
WiredHome | 0:5db287f0060b | 68 | int initialise_card(); |
WiredHome | 0:5db287f0060b | 69 | int initialise_card_v1(); |
WiredHome | 0:5db287f0060b | 70 | int initialise_card_v2(); |
WiredHome | 0:5db287f0060b | 71 | |
WiredHome | 0:5db287f0060b | 72 | int _read(char *buffer, int length); |
WiredHome | 0:5db287f0060b | 73 | int _write(const char *buffer, int length); |
WiredHome | 0:5db287f0060b | 74 | int _sd_sectors(); |
WiredHome | 0:5db287f0060b | 75 | int _sectors; |
WiredHome | 0:5db287f0060b | 76 | |
WiredHome | 0:5db287f0060b | 77 | SPI _spi; |
WiredHome | 0:5db287f0060b | 78 | DigitalOut _cs; |
WiredHome | 0:5db287f0060b | 79 | }; |
WiredHome | 0:5db287f0060b | 80 | |
WiredHome | 0:5db287f0060b | 81 | #endif |