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>
40 * $WIZ$ module_name = "sd"
41 * $WIZ$ module_configuration = "bertos/cfg/cfg_fat.h"
42 * $WIZ$ module_depends = "kfile", "timer"
43 * $WIZ$ module_hw = "bertos/hw/hw_sd.h"
50 #include <fs/fatfs/diskio.h>
51 #include <kern/kfile.h>
52 #include "cfg/cfg_fat.h"
57 * Initializes the SD driver.
59 * \param _fd A pointer to a kfile where the SD will read/write to.
60 * \return true if initialization succeds, false otherwise.
62 bool sd_init(KFile *_fd);
64 #if CONFIG_FAT_DRIVES == 1
67 * Same as sd_disk_status.
69 * Card initialization must be done with sd_init.
71 #define sd_disk_initialize disk_initialize
74 * Return the status of the disk.
76 * \param drv The number of the drive to initialize. Currently only drive 0 is allowed.
77 * \return RES_OK if the sd card was correctly initialized by a previous call to sd_init(), STA_NOINIT otherwise.
79 #define sd_disk_status disk_status
81 * Read \a count sectors from SD card.
83 * \param drv The drive number to read from. Only 0 is supported.
84 * \param buf A buffer to store read data. You can get sector size using sd_disk_ioctl.
85 * \param sector Start sector number.
86 * \param count The number of sectors to read.
87 * \return RES_OK if the function succeded, RES_ERROR if any error occurred, RES_NOTRDY if the disk is not initialized.
91 #define sd_disk_read disk_read
93 #if CONFIG_FAT_FS_READONLY == 0
96 * Write \a count sectors to SD card.
98 * \param drv The drive number to read from. Only 0 is supported.
99 * \param buf The data to be written.
100 * \param sector Start sector number.
101 * \param count The number of sectors to write.
102 * \return RES_OK if the function succeded, RES_ERROR if any error occurred, RES_NOTRDY if the disk is not initialized.
106 #define sd_disk_write disk_write
110 * Interface to send device independant commands to the device.
112 * \sa diskio.h and related documentation for further explanations.
114 #define sd_disk_ioctl disk_ioctl
116 #endif /* CONFIG_FAT_DRIVES == 1 */
118 #endif /* DRV_SD_H */