source: asp3_tinet_ecnl_arm/trunk/ntshell/fatfs/sdfs.h@ 374

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

mbed関連を更新
シリアルドライバをmbedのHALを使うよう変更
ファイルディスクリプタの処理を更新

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 3.1 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#define __NEED_time_t
28#include "../musl-1.1.18/include/bits/alltypes.h"
29#include "gpio_api.h"
30#include "spi_api.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/* MMC card type flags (MMC_GET_TYPE) */
37#define CT_FAIL 0x00
38#define CT_MMC 0x01 /* MMC ver 3 */
39#define CT_SD1 0x02 /* SD ver 1 */
40#define CT_SD2 0x04 /* SD ver 2 */
41#define CT_SDC (CT_SD1|CT_SD2) /* SD */
42#define CT_BLOCK 0x08 /* Block addressing */
43
44/** Access the filesystem on an SD Card using SPI
45 *
46 * @code
47 * #include "mbed.h"
48 * #include "SDFileSystem.h"
49 *
50 * SDFileSystem sd(p5, p6, p7, p12, "sd"); // MOSI, MISO, SCLK, SSEL
51 *
52 * int main() {
53 * FILE *fp = fopen("/sd/mbed.txt", "w");
54 * fprintf(fp, "Hello World!\n");
55 * fclose(fp);
56 * }
57 * @endcode
58 */
59typedef struct sdfs_s{
60 const char* name;
61 volatile uint8_t _is_initialized;
62 uint8_t _card_type;
63 uint8_t _csd[16], _cid[16];
64 uint64_t _capacity;
65 uint64_t _block_len;
66 uint64_t _sectors;
67 spi_t _spi;
68 gpio_t _cs;
69 int cdv;
70 uint32_t _init_sck;
71 uint32_t _transfer_sck;
72} sdfs_t;
73
74/** Create the File System for accessing an SD Card using SPI
75 *
76 * @param mosi SPI mosi pin connected to SD Card
77 * @param miso SPI miso pin conencted to SD Card
78 * @param sclk SPI sclk pin connected to SD Card
79 * @param cs DigitalOut pin used as SD Card chip select
80 * @param name The name used to access the virtual filesystem
81 */
82void sdfs_init(sdfs_t *obj, PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name);
83
84int sdfs_initialize(sdfs_t *obj);
85int sdfs_status(sdfs_t *obj);
86int sdfs_read(sdfs_t *obj, uint8_t * buffer, uint32_t sector, uint32_t count);
87int sdfs_write(sdfs_t *obj, const uint8_t * buffer, uint32_t sector, uint32_t count);
88int sdfs_sync(sdfs_t *obj);
89uint64_t sdfs_sectors(sdfs_t *obj);
90int sdfs_trim(sdfs_t *obj, uint32_t st, uint32_t ed);
91int sdfs_get_ocr(sdfs_t *obj, uint8_t buff[4]);
92int sdfs_get_sdstat(sdfs_t *obj, uint8_t buff[64]);
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif
Note: See TracBrowser for help on using the repository browser.