/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* 文件名称: stm32f10x_sdio.c
* 程序作者: MCD Application Team
* 程序版本: V2.0.2
* 编制日期: 07/11/2008
* 功能描述: 这个文件提供了所有SDIO的固件函数.
********************************************************************************
* 目前的固件的目的是为客户提供关于他们的产品的编码信息以便于节省他们时间。
* 结果, 意法半导体将不会为此承担任何直接,间接或相应的损害赔偿方面的任何索赔要求,
* 例如固件或使用所作的客户编码中他涉嫌包含与他们的相关产品的信息。
*******************************************************************************/
/*******************************************************************************
* 函数名称: SDIO_DeInit
* 功能描述: Deinitializes the SDIO peripheral registers to their default
* reset values[取消SDIO设备寄存器的初始化还原到他们的默认值].
* 输入参数: 无
* 输出参数: 无
* 返回参数: 无
*******************************************************************************/
void SDIO_DeInit(void)
{
SDIO->POWER = 0x00000000;
SDIO->CLKCR = 0x00000000;
SDIO->ARG = 0x00000000;
SDIO->CMD = 0x00000000;
SDIO->DTIMER = 0x00000000;
SDIO->DLEN = 0x00000000;
SDIO->DCTRL = 0x00000000;
SDIO->ICR = 0x00C007FF;
SDIO->MASK = 0x00000000;
}
/*******************************************************************************
* 函数名称: SDIO_Init
* 功能描述: Initializes the SDIO peripheral according to the specified
* parameters in the SDIO_InitStruct[依照SDIO_InitStruct结构体指定的参数初始化SDIO设备].
* 输入参数: SDIO_InitStruct : pointer to a SDIO_InitTypeDef structure
* that contains the configuration information for the SDIO
* peripheral.[指向包含着SDIO设备配置信息的结构体SDIO_InitTypeDef的指针]
* 输出参数: 无
* 返回参数: 无
*******************************************************************************/
void SDIO_Init(SDIO_InitTypeDef* SDIO_InitStruct)
{
u32 tmpreg = 0;
/* Check the parameters [检查参数]*/
assert_param(IS_SDIO_CLOCK_EDGE(SDIO_InitStruct->SDIO_ClockEdge));
assert_param(IS_SDIO_CLOCK_BYPASS(SDIO_InitStruct->SDIO_ClockBypass));
assert_param(IS_SDIO_CLOCK_POWER_SAVE(SDIO_InitStruct->SDIO_ClockPowerSave));
assert_param(IS_SDIO_BUS_WIDE(SDIO_InitStruct->SDIO_BusWide));
assert_param(IS_SDIO_HARDWARE_FLOW_CONTROL(SDIO_InitStruct->SDIO_HardwareFlowControl));
/*---------------------------- SDIO CLKCR Configuration ------------------------*/
/* Get the SDIO CLKCR value [取得SDIO CLKCR的值]*/
tmpreg = SDIO->CLKCR;
/* Clear CLKDIV, PWRSAV, BYPASS, WIDBUS, NEGEDGE, HWFC_EN bits [清CLKDIV, PWRSAV, BYPASS, WIDBUS, NEGEDGE, HWFC_EN位]*/
tmpreg &= CLKCR_CLEAR_MASK;
/* Set CLKDIV bits according to SDIO_ClockDiv value [依照SDIO_ClockDiv的值设置CLKDIV位]*/
/* Set PWRSAV bit according to SDIO_ClockPowerSave value [依照SDIO_ClockPowerSave的值设置PWRSAV位]*/
/* Set BYPASS bit according to SDIO_ClockBypass value [依照SDIO_ClockBypass的值设置BYPASS位]*/
/* Set WIDBUS bits according to SDIO_BusWide value [依照SDIO_BusWide的值设置WIDBUS位]*/
/* Set NEGEDGE bits according to SDIO_ClockEdge value [依照SDIO_ClockEdge的值设置NEGEDGE位]*/
/* Set HWFC_EN bits according to SDIO_HardwareFlowControl value [依照SDIO_HardwareFlowControl的值设置HWFC_EN位]*/
tmpreg |= (SDIO_InitStruct->SDIO_ClockDiv | SDIO_InitStruct->SDIO_ClockPowerSave |
SDIO_InitStruct->SDIO_ClockBypass | SDIO_InitStruct->SDIO_BusWide |
SDIO_InitStruct->SDIO_ClockEdge | SDIO_InitStruct->SDIO_HardwareFlowControl);
/* Write to SDIO CLKCR [写SDIO CLKCR]*/
SDIO->CLKCR = tmpreg;
}
/*******************************************************************************
* 函数名称: SDIO_StructInit
* 功能描述: Fills each SDIO_InitStruct member with its default value.[用默认值填充SDIO_InitStruct的每一个成员]
* 输入参数: SDIO_InitStruct: pointer to an SDIO_InitTypeDef structure which
* will be initialized.[指向将要被初始化的结构体SDIO_InitTypeDef的指针]
* 输出参数: 无
* 返回参数: 无
*******************************************************************************/
void SDIO_StructInit(SDIO_InitTypeDef* SDIO_InitStruct)
{
/* SDIO_InitStruct members default value [SDIO_InitStruct成员的默认值]*/
SDIO_InitStruct->SDIO_ClockDiv = 0x00;
SDIO_InitStruct->SDIO_ClockEdge = SDIO_ClockEdge_Rising;
SDIO_InitStruct->SDIO_ClockBypass = SDIO_ClockBypass_Disable;
SDIO_InitStruct->SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable;
SDIO_InitStruct->SDIO_BusWide = SDIO_BusWide_1b;
SDIO_InitStruct->SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable;
}
完整的stm32f10x_sdio.c,终于完成了!几次都想放弃了,还是咬牙坚持下来了.
用户377235 2014-2-11 02:42
用户377235 2013-3-7 19:54
用户592336 2012-2-6 16:17
用户379758 2010-8-23 10:41
用户113131 2010-4-8 13:03
sunke9_998892717 2009-7-2 16:37
用户829600 2009-7-1 14:09
用户203537 2009-1-29 10:27
用户1055968 2009-1-17 10:35
用户502047 2008-11-3 16:02