Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
RT-Thread一般讨论
关于文件系统的sd卡。。。
发布于 2010-05-28 12:14:26 浏览:3979
订阅该版
请问下, rt_thread里面有个文件系统例程, 里面的sd卡驱动支持sdhc吗?也就是sd卡2.0的,怎么我的stm32使用时一直检测不到起始位,不仅仅是读的时候,而是在使能总线位的时候。代码如下: status = SD_EnableWideBusOperation(SDIO_BusWide_4b); if (status != SD_OK) { rt_kprintf("enable wide bus operation fail.n"); goto __return; } SD_Error SD_EnableWideBusOperation(u32 WideMode) { SD_Error errorstatus = SD_OK; /* MMC Card doesn't support this feature */ if (SDIO_MULTIMEDIA_CARD == CardType) { errorstatus = SD_UNSUPPORTED_FEATURE; rt_kprintf("SD unsupported feature.n"); return(errorstatus); } else if ((SDIO_STD_CAPACITY_SD_CARD_V1_1 == CardType) || (SDIO_STD_CAPACITY_SD_CARD_V2_0 == CardType) || (SDIO_HIGH_CAPACITY_SD_CARD == CardType)) { if (SDIO_BusWide_8b == WideMode) { errorstatus = SD_UNSUPPORTED_FEATURE; rt_kprintf("SD unsupported feature.n"); return(errorstatus); } else if (SDIO_BusWide_4b == WideMode) { errorstatus = _SDEnWideBus(ENABLE);_ if (SD_OK == errorstatus) { /* Configure the SDIO peripheral */ SDIO_InitStructure.SDIO_ClockDiv = SDIO_TRANSFER_CLK_DIV; SDIO_InitStructure.SDIO_ClockEdge = SDIO_ClockEdge_Rising; SDIO_InitStructure.SDIO_ClockBypass = SDIO_ClockBypass_Disable; SDIO_InitStructure.SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable; SDIO_InitStructure.SDIO_BusWide = SDIO_BusWide_4b; SDIO_InitStructure.SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable; SDIO_Init(&SDIO_InitStructure); } else rt_kprintf("SD enable wide bus fail.n"); } else { errorstatus = SDEnWideBus(DISABLE); if (SD_OK == errorstatus) { /* Configure the SDIO peripheral */ SDIO_InitStructure.SDIO_ClockDiv = SDIO_TRANSFER_CLK_DIV; SDIO_InitStructure.SDIO_ClockEdge = SDIO_ClockEdge_Rising; SDIO_InitStructure.SDIO_ClockBypass = SDIO_ClockBypass_Disable; SDIO_InitStructure.SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable; SDIO_InitStructure.SDIO_BusWide = SDIO_BusWide_1b; SDIO_InitStructure.SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable; SDIO_Init(&SDIO_InitStructure); } else rt_kprintf("SD disable wide bus fail.n"); } } static SD_Error SDEnWideBus(FunctionalState NewState) { SD_Error errorstatus = SD_OK; uint32_t scr[2] = {0, 0}; if (SDIO_GetResponse(SDIO_RESP1) & SD_CARD_LOCKED) { errorstatus = SD_LOCK_UNLOCK_FAILED; rt_kprintf("sd locke unlock faile:in line 2537.n"); return(errorstatus); } /* Get SCR Register */ _errorstatus = FindSCR(RCA, scr);_ if (errorstatus != SD_OK) { rt_kprintf("get scr register error:in line4 2547.n"); return(errorstatus); } static SD_Error FindSCR(uint16_t rca, uint32_t *pscr) { uint32_t index = 0; SD_Error errorstatus = SD_OK; uint32_t tempscr[2] = {0, 0}; /* Set Block Size To 8 Bytes */ /* Send CMD55 APP_CMD with argument as card's RCA */ SDIO_CmdInitStructure.SDIO_Argument = (uint32_t)8; SDIO_CmdInitStructure.SDIO_CmdIndex = SDIO_SET_BLOCKLEN; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp1Error(SDIO_SET_BLOCKLEN); if (errorstatus != SD_OK) { rt_kprintf("send card rca fail :in line 2829.n"); return(errorstatus); } /* Send CMD55 APP_CMD with argument as card's RCA */ SDIO_CmdInitStructure.SDIO_Argument = (uint32_t) RCA << 16; SDIO_CmdInitStructure.SDIO_CmdIndex = SDIO_APP_CMD; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp1Error(SDIO_APP_CMD); if (errorstatus != SD_OK) { rt_kprintf("send rca fail:in line 2845.n"); return(errorstatus); } SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT; SDIO_DataInitStructure.SDIO_DataLength = 8; SDIO_DataInitStructure.SDIO_DataBlockSize = SDIO_DataBlockSize_8b; SDIO_DataInitStructure.SDIO_TransferDir = SDIO_TransferDir_ToSDIO; SDIO_DataInitStructure.SDIO_TransferMode = SDIO_TransferMode_Block; SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable; SDIO_DataConfig(&SDIO_DataInitStructure); rt_kprintf("sdio->sta = %o.n",SDIO->STA); //SDIO_ClearFlag(SDIO_FLAG_STBITERR); /* Send ACMD51 SD_APP_SEND_SCR with argument as 0 */ SDIO_CmdInitStructure.SDIO_Argument = 0x0; SDIO_CmdInitStructure.SDIO_CmdIndex = SDIO_SD_APP_SEND_SCR; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp1Error(SDIO_SD_APP_SEND_SCR); if (errorstatus != SD_OK) { rt_kprintf("cmd Resp1 error : in line 2870.n"); return(errorstatus); } while (!(SDIO->STA & (SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DBCKEND | SDIO_FLAG_STBITERR ))) { if (SDIO_GetFlagStatus(SDIO_FLAG_RXDAVL) != RESET) { *(tempscr + index) = SDIO_ReadData(); rt_kprintf("can read data.n"); index++; } } if (SDIO_GetFlagStatus(SDIO_FLAG_DTIMEOUT) != RESET) { SDIO_ClearFlag(SDIO_FLAG_DTIMEOUT); errorstatus = SD_DATA_TIMEOUT; rt_kprintf("sd data timeout : inline 2886.n"); return(errorstatus); } else if (SDIO_GetFlagStatus(SDIO_FLAG_DCRCFAIL) != RESET) { SDIO_ClearFlag(SDIO_FLAG_DCRCFAIL); errorstatus = SD_DATA_CRC_FAIL; rt_kprintf("sd data fail : inline 2886.n"); return(errorstatus); } else if (SDIO_GetFlagStatus(SDIO_FLAG_RXOVERR) != RESET) { SDIO_ClearFlag(SDIO_FLAG_RXOVERR); errorstatus = SD_RX_OVERRUN; rt_kprintf("sd rx overrun : inline 2886.n"); return(errorstatus); } else if (SDIO_GetFlagStatus(SDIO_FLAG_STBITERR) != RESET) { SDIO_ClearFlag(SDIO_FLAG_STBITERR); errorstatus = SD_START_BIT_ERR; _rt_kprintf("sd can't not find start bit : inline 2886.n");_ return(errorstatus); } /* Clear all the static flags */ SDIO_ClearFlag(SDIO_STATIC_FLAGS); *(pscr + 1) = ((tempscr[0] & SD_0TO7BITS) << 24) | ((tempscr[0] & SD_8TO15BITS) << 8) | ((tempscr[0] & SD_16TO23BITS) >> 8) | ((tempscr[0] & SD_24TO31BITS) >> 24); *(pscr) = ((tempscr[1] & SD_0TO7BITS) << 24) | ((tempscr[1] & SD_8TO15BITS) << 8) | ((tempscr[1] & SD_16TO23BITS) >> 8) | ((tempscr[1] & SD_24TO31BITS) >> 24); return(errorstatus); } 运行到这里总会提示没有检测到起始位: sd can't not find start bit : inline 2886. 我的是金士顿4gsd2.0卡
查看更多
1
个回答
默认排序
按发布时间排序
撰写答案
登录
注册新账号
关注者
0
被浏览
4k
关于作者
xiao苦
这家伙很懒,什么也没写!
提问
57
回答
244
被采纳
0
关注TA
发私信
相关问题
1
有关动态模块加载的一篇论文
2
最近的调程序总结
3
晕掉了,这么久都不见layer2的踪影啊
4
继续K9ii的历程
5
[GUI相关] FreeType 2
6
[GUI相关]嵌入式系统中文输入法的设计
7
20081101 RT-Thread开发者聚会总结
8
嵌入式系统基础
9
linux2.4.19在at91rm9200 上的寄存器设置
10
[转]基于嵌入式Linux的通用触摸屏校准程序
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
freemodbus主机在freertos的适配,参考rtthread例程
2
开源共生 商业共赢 | RT-Thread 2024开发者大会议程正式发布!
3
【24嵌入式设计大赛】基于RT-Thread星火一号的智慧家居系统
4
RT-Thread EtherKit开源以太网硬件正式发布
5
还在担心bsp不好维护吗?快使用yml管理主线bsp
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
FAL
rt-smart
ESP8266
I2C_IIC
WIZnet_W5500
UART
ota在线升级
PWM
cubemx
freemodbus
flash
packages_软件包
BSP
潘多拉开发板_Pandora
定时器
ADC
GD32
flashDB
socket
中断
Debug
编译报错
SFUD
msh
rt_mq_消息队列_msg_queue
keil_MDK
ulog
MicroPython
C++_cpp
本月问答贡献
a1012112796
20
个答案
3
次被采纳
张世争
12
个答案
3
次被采纳
踩姑娘的小蘑菇
7
个答案
3
次被采纳
用户名由3_15位
14
个答案
2
次被采纳
rv666
9
个答案
2
次被采纳
本月文章贡献
程序员阿伟
9
篇文章
2
次点赞
hhart
3
篇文章
4
次点赞
RTT_逍遥
1
篇文章
8
次点赞
大龄码农
1
篇文章
5
次点赞
ThinkCode
1
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部