sd.h

来自「AVR单片机做的MP3」· C头文件 代码 · 共 45 行

H
45
字号
/*M16-SPI*/
#define SD_SS          PB4
#define SD_SCK         PB7
#define SD_MOSI        PB5
#define SD_MISO        PB6

#define SD_DDR         DDRB
#define SD_PORT        PORTB
#define SD_PIN         PINB

#define SD_SS_H        SD_PORT |= (1<<SD_SS)
#define SD_SS_L        SD_PORT &= ~(1<<SD_SS)

#define SD_MISO_IN     (SD_PIN&(1<<SD_MISO))
//------------------------------------------------------------
// Error define
//-------------------------------------------------------------
#define INIT_OK                  0x00
#define READ_BLOCK_OK            0x00
#define INIT_CMD0_ERROR          0x01
#define INIT_CMD1_ERROR		     0x02
#define WRITE_BLOCK_ERROR	     0x03
#define READ_BLOCK_ERROR   	     0x04

// MMC/SD commands

//set MMC_Chip_Select to high (MMC/SD-Card Invalid)
#define SD_Disable()   SD_SS_H
//set MMC_Chip_Select to low (MMC/SD-Card Active)
#define SD_Enable()    SD_SS_L



uint8 SD_Init(void);
//void SD_Port_Init(void);
uint8 sd_write_sector(uint32 addr,uint8 *Buffer);
//uint8 Write_Command_SD(uint8 *cmd);
//uint8 SD_Read_Block(uint8 *CMD,uint8 *Buffer,uint16 Bytes);
uint8 SD_read_sector(uint32 addr,uint8 *Buffer);

//void SPI_TransferByte(uint8 cmp1);
//uint8 SPI_ReadferByte(uint8 cmp1);
void uart_init(void);
void put_c(uint8 c);
void put_s(char *ptr);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?