4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
32 * \brief Function library for secure digital memory.
34 * Right now, the interface for these function is the one defined in diskio.h from
38 * \author Francesco Sacchi <batt@develer.com>
45 #include <fs/fatfs/diskio.h>
46 #include <kern/kfile.h>
47 #include <cfg/cfg_fat.h>
52 * Initializes the SD driver.
54 * \param _fd A pointer to a kfile where the SD will read/write to.
55 * \return true if initialization succeds, false otherwise.
57 bool sd_init(KFile *_fd);
59 #if CONFIG_FAT_DRIVES == 1
62 * Same as sd_disk_status.
64 * Card initialization must be done with sd_init.
66 #define sd_disk_initialize disk_initialize
69 * Return the status of the disk.
71 * \param drv The number of the drive to initialize. Currently only drive 0 is allowed.
72 * \return RES_OK if the sd card was correctly initialized by a previous call to sd_init(), STA_NOINIT otherwise.
74 #define sd_disk_status disk_status
76 * Read \a count sectors from SD card.
78 * \param drv The drive number to read from. Only 0 is supported.
79 * \param buf A buffer to store read data. You can get sector size using sd_disk_ioctl.
80 * \param sector Start sector number.
81 * \param count The number of sectors to read.
82 * \return RES_OK if the function succeded, RES_ERROR if any error occurred, RES_NOTRDY if the disk is not initialized.
86 #define sd_disk_read disk_read
88 #if CONFIG_FAT_FS_READONLY == 0
91 * Write \a count sectors to SD card.
93 * \param drv The drive number to read from. Only 0 is supported.
94 * \param buf The data to be written.
95 * \param sector Start sector number.
96 * \param count The number of sectors to write.
97 * \return RES_OK if the function succeded, RES_ERROR if any error occurred, RES_NOTRDY if the disk is not initialized.
101 #define sd_disk_write disk_write
105 * Interface to send device independant commands to the device.
107 * \sa diskio.h and related documentation for further explanations.
109 #define sd_disk_ioctl disk_ioctl
111 #endif /* CONFIG_FAT_DRIVES == 1 */
113 #endif /* DRV_SD_H */