📄 mmc_sd.h
字号:
/*******************************************************************/
/* SD diriver for MP3 Player */
/* */
/* Platform : AVRStudio4.13 b528 + WinAVR20070525 */
/* optimize -0s */
/* Author : bozai(Zhang Qibo) */
/* E-mail : sudazqb@163.com */
/* MSN : zhangqibo_1985@hotmail.com */
/* Date : 2006-06-16 */
/*******************************************************************/
/* 2007-10-21: Rewrite some function, now only suply 4 functions */
/* 2007-10-18: Adjust some time & retry count for compatibility */
/* consideration */
/* 2007-06-16: After reading the spec. in detail, I found some */
/* of the code don't meet the spec., that is after */
/* the last SPI transaction, it need an extra 8 CLK */
/* to finish it's work */
/* 2007-05-04: add read capacity function */
/* 2007-04-21: */
/* Enable some code incase that when SD reset */
/* faild program can't jump the loop */
/*******************************************************************/
#ifndef __MMC_SD_h__
#define __MMC_SD_h__
#define uint8 unsigned char
#define int8 signed char
#define uint16 unsigned int
#define int16 signed int
#define uint32 unsigned long
#define int32 signed long
#define MMC_SD_CS_DDR DDRB
#define MMC_SD_CS_PORT PORTB
#define MMC_SD_CS_BIT 0
#define MMC_SD_SCK_DDR DDRB
#define MMC_SD_SCK_PORT PORTB
#define MMC_SD_SCK_BIT 1
#define MMC_SD_MOSI_DDR DDRB
#define MMC_SD_MOSI_PORT PORTB
#define MMC_SD_MOSI_BIT 2
#define MMC_SD_MISO_DDR DDRB
#define MMC_SD_MISO_PORT PORTB
#define MMC_SD_MISO_BIT 3
/****************************************************************/
#define MMC_SD_PORT_INI {\
MMC_SD_CS_PORT |= 1<<MMC_SD_CS_BIT;\
MMC_SD_SCK_PORT |= 1<<MMC_SD_SCK_BIT;\
MMC_SD_MOSI_PORT |= 1<<MMC_SD_MOSI_BIT;\
MMC_SD_MISO_PORT |= 1<<MMC_SD_MISO_BIT;\
\
MMC_SD_CS_DDR |= 1<<MMC_SD_CS_BIT;\
MMC_SD_SCK_DDR |= 1<<MMC_SD_SCK_BIT;\
MMC_SD_MOSI_DDR |= 1<<MMC_SD_MOSI_BIT;\
MMC_SD_MISO_DDR &= ~(1<<MMC_SD_MISO_BIT);\
}
#define SPI_CS_Assert MMC_SD_CS_PORT &= ~(1<<MMC_SD_CS_BIT)
#define SPI_CS_Deassert MMC_SD_CS_PORT |= 1<<MMC_SD_CS_BIT
uint8 MMC_SD_Init(void);
uint8 MMC_SD_ReadSingleBlock(uint32 sector, uint8* buffer);
uint8 MMC_SD_WriteSingleBlock(uint32 sector, uint8* buffer);
uint32 MMC_SD_ReadCapacity(void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -