source: EcnlProtoTool/trunk/ntshell/fatfs/sdfs.h@ 278

Last change on this file since 278 was 278, checked in by coas-nagasima, 7 years ago

フォルダ構成を変更

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr
File size: 2.5 KB
Line 
1/* mbed Microcontroller Library
2 * Copyright (c) 2006-2012 ARM Limited
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22#ifndef MBED_SDFILESYSTEM_H
23#define MBED_SDFILESYSTEM_H
24
25#include <stdint.h>
26#include <time.h>
27#include "gpio_api.h"
28#include "spi_api.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/** Access the filesystem on an SD Card using SPI
35 *
36 * @code
37 * #include "mbed.h"
38 * #include "SDFileSystem.h"
39 *
40 * SDFileSystem sd(p5, p6, p7, p12, "sd"); // MOSI, MISO, SCLK, SSEL
41 *
42 * int main() {
43 * FILE *fp = fopen("/sd/mbed.txt", "w");
44 * fprintf(fp, "Hello World!\n");
45 * fclose(fp);
46 * }
47 * @endcode
48 */
49typedef struct sdfs_s{
50 const char* name;
51 uint64_t _sectors;
52 spi_t _spi;
53 gpio_t _cs;
54 int cdv;
55 uint32_t _init_sck;
56 uint32_t _transfer_sck;
57 int _is_initialized;
58} sdfs_t;
59
60/** Create the File System for accessing an SD Card using SPI
61 *
62 * @param mosi SPI mosi pin connected to SD Card
63 * @param miso SPI miso pin conencted to SD Card
64 * @param sclk SPI sclk pin connected to SD Card
65 * @param cs DigitalOut pin used as SD Card chip select
66 * @param name The name used to access the virtual filesystem
67 */
68sdfs_init(sdfs_t *obj, PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name);
69
70int sdfs_initialize(sdfs_t *obj);
71int sdfs_status(sdfs_t *obj);
72int sdfs_read(sdfs_t *obj, uint8_t * buffer, uint32_t sector, uint32_t count);
73int sdfs_write(sdfs_t *obj, const uint8_t * buffer, uint32_t sector, uint32_t count);
74int sdfs_sync(sdfs_t *obj);
75uint64_t sdfs_sectors(sdfs_t *obj);
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif
Note: See TracBrowser for help on using the repository browser.