sd.h
Go to the documentation of this file.00001
00044 #ifndef DRV_SD_H
00045 #define DRV_SD_H
00046
00047 #include "cfg/cfg_sd.h"
00048
00049 #include <io/kfile.h>
00050 #include <io/kblock.h>
00051
00052 #include <fs/fatfs/diskio.h>
00053
00054
00055 #define SD_UNBUFFERED BV(0) ///< Open SD memory disabling page caching, no modification and partial write are allowed.
00056
00060 typedef struct Sd
00061 {
00062 KBlock b;
00063 KFile *ch;
00064 uint16_t r1;
00065 uint16_t tranfer_len;
00066 } Sd;
00067
00068 bool sd_initUnbuf(Sd *sd, KFile *ch);
00069 bool sd_initBuf(Sd *sd, KFile *ch);
00070
00071 #if CONFIG_SD_OLD_INIT
00072 #if !(ARCH & ARCH_NIGHTTEST)
00073 #warning "Deprecated: this API will be removed in the next major release,"
00074 #warning "please disable CONFIG_SD_OLD_INIT and pass explicitly the SD context to sd_init()."
00075 #endif
00076
00089 #define sd_init(ch) {static struct Sd sd; sd_initUnbuf(&sd, (ch));}
00090
00091 #else
00092
00105 #define sd_init(sd, ch, buffered) ((buffered & SD_UNBUFFERED) ? sd_initUnbuf((sd), (ch)) : sd_initBuf((sd), (ch)))
00106
00107 #endif
00108
00109
00110 #define KBT_SD MAKE_ID('S', 'D', 'B', 'K')
00111
00112 bool sd_test(Sd *sd);
00113 void sd_writeTest(Sd *sd);
00114
00115 INLINE Sd *SD_CAST(KBlock *b)
00116 {
00117 ASSERT(b->priv.type == KBT_SD);
00118 return (Sd *)b;
00119 }
00120
00121
00122 #endif