📄 sd_hal.h
字号:
/************************************************************************************/
/* */
/* Copyright (C) 2004 Medeli Electric Industry Co., LTD. */
/* */
/* System Name : IC-1000 */
/* File Name : sd_hal.h */
/* Revision : 1.00 */
/* Date : 2006/4/10 */
/* Initial version */
/* Joe's work */
/************************************************************************************/
#ifndef SD_HAL_H
#define SD_HAL_H
#ifdef __cplusplus
extern "C" {
#endif
/********************************Includs***************************************/
/*******************************Constants**************************************/
#define SIO_BAUDRATE_INI (50000L)
/* 初始化时的SIO波特率,必须<400K */
//#define SIO_BAUDRATE_WORK (3200000L)
#define SIO_BAUDRATE_WORK (10000000L)
/* 工作状态下的SIO波特率,可以较大 */
#define SD_BLOCK_LENGTH (512)
/* SD卡默认块大小 */
#define SD_IDLE_DELAY_TIME (10)
/* SD卡在激活之前发送或接收字节的延时长度,单位:ms */
#define MSK_OCR_33 (0xc0)
/* Mask off the bits in the OCR corresponding to voltage range 3.2V to
* 3.4V, OCR bits 20 and 21 */
#define SD_MOST_INITIAL_TRY (5)
/* 定义在初始化阶段,对SD卡进行初始化的重试次数 */
/* Number of tries to initialize the sd card */
#define SD_IDLE_WAIT_MAX (10)
/* 定义在初始化阶段,等待SD卡退出空闲状态的重试次数 */
/* Number of tries to wait for the card to go idle during initialization */
#define SD_CMD_TIMEOUT (100)
/* SD卡命令超时时间(单位 8clock)*/
/* timeout of command */
#define READ_TIMEOUT_100MS ((UWORD)100*SIO_BAUDRATE_WORK/1000/8)
/* 100ms 相当的SPI时钟数(单位 unit: 8 clocks) */
/* 100ms correspond to SPI clock(unit: 8 clocks)*/
#define WRITE_TIMEOUT_250MS ((UWORD)250*SIO_BAUDRATE_WORK/1000/8)
/* 250ms 相当的SPI时钟数(单位 unit: 8 clocks) */
/* 250ms correspond to SPI clock(unit: 8 clocks)*/
#define SD_READREG_TIMEOUT (8)
/* 读取寄存器超时限制:8 * 8个CLOCK */
/********************************************************/
/* CSD中一些域的字节位置(高字节在前) */
/********************************************************/
#define TAAC_POS (1) //TACC
#define NSAC_POS (2) //NSAC
#define TRANS_SPEED_POS (3) //TRANSFER SPEED
#define READ_BL_LEN_POS (5) //READ_BL_LEN
#define C_SIZE_POS1 (6) //C_SIZE upper 2-bit
#define C_SIZE_POS2 (7) //C_SIZE middle 8-bit
#define C_SIZE_POS3 (8) //C_SIZE lower 2-bit
#define C_SIZE_MULT_POS1 (9) //C_SIZE_MULT upper 2-bit
#define C_SIZE_MULT_POS2 (10) //C_SIZE_MULT lower 1-bit
#define SECTOR_SIZE_POS1 (10) //SECTOR_SIZE upper 5-bit
#define SECTOR_SIZE_POS2 (11) //SECTOR_SIZE lower 2-bit
#define R2WFACTOR_POS (12) //R2WFACTOR_POS
/********************************************************/
/* CSD中一些域的掩码 */
/********************************************************/
#define TAAC_MSK (0x07) //TACC 域掩码
#define NSAC_MSK (0x78) //NSAC 域掩码
#define READ_BL_LEN_MSK (0x0f) //READ_BL_LEN 的掩码
#define C_SIZE_MSK1 (0x03) //C_SIZE 高2位掩码
#define C_SIZE_MSK3 (0xc0) //C_SIZE 低2位掩码
#define C_SIZE_MULT_MSK1 (0x03) //C_SIZE_MULT 的高2位掩码
#define C_SIZE_MULT_MSK2 (0x80) //C_SIZE_MULT 的低2位掩码
#define R2WFACTOR_MSK (0x1c) //R2WFACTOR 掩码
#define SECTOR_SIZE_MSK1 (0x3f) //SECTOR_SIZE 的高5位
#define SECTOR_SIZE_MSK2 (0x80) //SECTOR_SIZE 的低2位
/*********************************Enums****************************************/
/********************************Marcros***************************************/
/*******************************Structures*************************************/
/********************************Specials**************************************/
/**************************Variable Declaration********************************/
/**************************Function Declaration********************************/
/**************************End of sd_command.h*********************************/
#ifdef __cplusplus
}; /* End of 'extern "C"' */
#endif
#endif /* End of sd_base.h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -