📄 sd_cmd.h
字号:
#ifdef _DEBUG_FUNCTIONS_
#define _FF_READ_DEBUG_
#define _FF_WRITE_DEBUG_
#define _DEBUG_MULTIBLOCK_BYTE_
#define _DEBUG_MULTI_BLOCK_
#define _DEBUG_INIT_SD_
#endif
enum {SD_IDLE, SD_SPI};
/****************************************************************************
**
** TYPEDEFS AND STRUCTURES
**
****************************************************************************/
typedef struct
{
#ifndef _BIG_ENDIAN_
uint16 nib_0 : 4;
uint16 nib_1 : 4;
uint16 nib_2 : 4;
uint16 nib_3 : 4;
#else
uint16 nib_3 : 4;
uint16 nib_2 : 4;
uint16 nib_1 : 4;
uint16 nib_0 : 4;
#endif
} Nibbles16Struct;
typedef struct
{
#ifndef _BIG_ENDIAN_
uint8 lo;
uint8 ml;
uint8 mh;
uint8 hi;
#else
uint8 hi;
uint8 mh;
uint8 ml;
uint8 lo;
#endif
} HiLo_8_32_Struct;
typedef struct
{
#ifndef _BIG_ENDIAN_
uint8 lo;
uint8 hi;
#else
uint8 hi;
uint8 lo;
#endif
} HiLo_8_16_Struct;
typedef struct
{
#ifndef _BIG_ENDIAN_
uint16 lo;
uint16 hi;
#else
uint16 hi;
uint16 lo;
#endif
} HiLo_16_32_Struct;
typedef union
{
uint32 uval32;
HiLo_8_32_Struct uval8;
HiLo_16_32_Struct uval16;
} HiLo32Union;
typedef union
{
uint16 uval16;
HiLo_8_16_Struct uval8;
Nibbles16Struct nib;
} HiLo16Union;
typedef struct
{
uint8 Active_Flagg;
uint8 Starting_Head;
uint16 Starting_Cylinder;
uint8 Partition_Type;
uint8 Ending_Head;
uint16 Ending_Cylinder;
HiLo32Union Starting_Sector;
#ifndef _BIG_ENDIAN_
uint32 Partition_Length;
#else
HiLo32Union Partition_Length;
#endif
} PartitionEntryStruct;
typedef struct
{
uint8 jmpBoot[3];
uint8 OEMName[8];
#ifndef _BIG_ENDIAN_
uint16 BytsPerSec;
uint8 SecPerClus;
uint16 RsvdSecCnt;
uint8 NumFATs;
uint16 RootEntCnt;
uint16 TotSec16;
uint8 Media;
uint16 FATSz16;
uint16 SecPerTrk;
uint16 NumHeads;
uint32 HiddSec;
uint32 TotSec32;
uint8 DrvNum;
uint8 Reserved1;
uint8 BootSig;
uint32 VolID;
#else
HiLo16Union BytsPerSec;
uint8 SecPerClus;
HiLo16Union RsvdSecCnt;
uint8 NumFATs;
HiLo16Union RootEntCnt;
HiLo16Union TotSec16;
uint8 Media;
HiLo16Union FATSz16;
HiLo16Union SecPerTrk;
HiLo16Union NumHeads;
HiLo32Union HiddSec;
HiLo32Union TotSec32;
uint8 DrvNum;
uint8 Reserved1;
uint8 BootSig;
HiLo32Union VolID;
#endif
uint8 VolLab[11];
uint8 FilSysType[8];
uint8 junk[384];
PartitionEntryStruct PartEnt[4];
uint16 SigWord;
} FAT16BootSectStruct;
#endif /*_SD_CMD_INCLUDED*/
/****************************************************************************
**
** EXPORTED VARIABLES
**
****************************************************************************/
#ifndef _SD_CMD_C_SRC
extern uint8 _FF_Buff[512];
#ifndef _BYTES_PER_SEC_512_
extern HiLo16Union BPB_BytsPerSec;
#endif
extern uint8 BPB_SecPerClus;
extern HiLo16Union BPB_RsvdSecCnt;
extern HiLo16Union BPB_RootEntCnt;
extern HiLo16Union BPB_FATSz16;
extern uint8 BPB_FATType;
extern int8 BS_VolLab[12];
extern uint16 _FF_PartitionAddr;
extern uint32 _FF_RootAddr;
#ifndef _BIG_ENDIAN_
extern uint32 BS_VolSerial;
#else
extern HiLo32Union BS_VolSerial;
#endif
#ifdef _DIRECTORIES_SUPPORTED_
extern uint32 _FF_DirAddr;
#endif
extern uint16 _FF_Fat1Addr;
extern uint32 _FF_Fat2Addr;
extern uint16 FirstDataSector;
extern uint8 _FF_error;
extern uint32 _FF_BuffAddr;
extern uint16 DataClusTot;
extern int8 _FF_FullPath[_FF_PATH_LENGTH];
extern uint16 Clus0Counter;
#if defined(_SD_BLOCK_WRITE_) && !defined(_READ_ONLY_)
extern uint32 SDBlockWriteBlockCnt;
#endif
#ifdef _DEBUG_ON_
extern flash int8 _FF_CRLFStr[];
extern flash int8 _FF_02XStr[];
#endif
#endif /*_SD_CMD_C_SRC*/
/****************************************************************************
**
** EXPORTED FUNCTIONS
**
****************************************************************************/
#ifdef _DEBUG_ON_
int16 _FF_putchar(int16 send_char);
int16 _FF_getchar(void);
#if defined(_CVAVR_) || defined(_ICCAVR_) || defined(_ROWLEY_CWAVR_)
void _FF_printf(flash int8 *pstr, ...);
#elif defined(_IAR_EWAVR_)
void _FF_printf(PGM_P pstr, ...);
#endif /*defined(_CVAVR_) || defined(_ICCAVR_)*/
#endif
int8 reset_sd(void);
int8 init_sd(void);
#ifdef _DEBUG_ON_
void _FF_read_disp(uint32 sd_addr);
#endif
int8 _FF_read(uint32 sd_addr, uint8 *sd_read_buff);
uint8 initialize_media(void);
int8 set_SD_mode(uint8 mode);
#ifndef _READ_ONLY_
int8 _FF_write(uint32 sd_addr, uint8 *sd_write_buff);
#if defined(_SD_BLOCK_WRITE_)
int8 SD_write_block_start(uint32 sd_addr, uint32 blk_size);
int8 SD_write_block_byte(uint8 sd_data);
int8 SD_write_block_end(void);
#endif
#endif
/****************************************************************************
**
** EOF
**
****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -