📄 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 */
/*******************************************************************/
/* 20080928: modify codes for ARM platform (NXP LPC2132) */
/* 20071212: modify code for mcuzone's mp3 player */
/* 20071208: modify codes for ARM platform (AT91SAM7S256) */
/* 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__
#include "global.h"
//#include "board.h"
#define PSTR
#define _delay_ms soft_delay_ms
#define uint8 unsigned char
#define int8 signed char
#define uint16 unsigned short
#define int16 signed short
#define uint32 unsigned int
#define int32 signed int
#if 0
#define MMC_SD_CS (1<<31)
#define MMC_SD_SCK (1<<14)
#define MMC_SD_MOSI (1<<13)
#define MMC_SD_MISO (1<<12)
/****************************************************************/
/*
#define MMC_SD_PORT_INI {\
pPIO->PIO_SODR = MMC_SD_CS|MMC_SD_SCK|MMC_SD_MOSI|MMC_SD_MISO;\
pPIO->PIO_PER = MMC_SD_CS|MMC_SD_SCK|MMC_SD_MOSI|MMC_SD_MISO; \
pPIO->PIO_OER = MMC_SD_CS|MMC_SD_SCK|MMC_SD_MOSI|MMC_SD_MISO; \
}
*/
#define MMC_SD_PORT_INI {\
pPIO->PIO_SODR = MMC_SD_CS;\
pPIO->PIO_PER = MMC_SD_CS; \
pPIO->PIO_OER = MMC_SD_CS; \
}
#define SPI_CS_Assert pPIO->PIO_CODR = MMC_SD_CS
#define SPI_CS_Deassert pPIO->PIO_SODR = MMC_SD_CS
#endif
//cs p0.21
#define SPI1_CS (0x01 << 21)
#define SPI1_CS_GPIO() PINSEL1 &= ~(0x03 << 10)
#define SPI1_CS_OUT() IO0DIR |= SPI1_CS
#define SPI_CS_Deassert IO0SET |= SPI1_CS
#define SPI_CS_Assert IO0CLR |= SPI1_CS
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 + -