SDIO_RESET
时间: 2023-08-07 15:03:34 浏览: 72
SDIO_RESET是一个函数,用于重置SDIO主机。在函数中,首先通过调用mmc_io_rw_direct_host函数向SDIO设备发送命令,将SDIO_CCCR_ABORT寄存器的值设置为0x08。如果发送命令失败,则将abort变量的值设置为0x08,否则将abort变量的值与0x08进行或操作。接下来,再次调用mmc_io_rw_direct_host函数向SDIO设备发送命令,将abort变量的值写入SDIO_CCCR_ABORT寄存器。最后,函数返回一个表示操作成功与否的值。[1]
SDIO设备的硬件操作接口有三种方式:SPI mode、SD 1-bit mode和SD 4-bit mode。其中,SPI mode不在本文的讨论范围内。SDIO设备内部有一些寄存器,用于存储相关状态值和配置信息。[2]
为了支持I/O特性,SDIO标准在SD的基础上新增了两条命令:IO_RW_DIRECT(CMD52)和IO_RW_EXTENDED(CMD53)。其中,CMD52用于访问单个寄存器,可以用于初始化寄存器或检测IO功能的相关状态值。CMD52可以读写单个寄存器的1字节数据,只需要一个命令/响应对即可完成。[3]
相关问题
rst:0x1 (poweron_reset),boot:0x3 (download_boot(uart0/uart1/sdio_rei_reo_v2)
这个回答是关于系统启动过程中的两个重要状态码。
首先是rst:0x1 (poweron_reset),它表示系统发生了电源复位。当我们打开电源时,系统会进行一系列的初始化操作,包括恢复所有硬件设备的初始状态。这个状态码告诉我们系统是通过电源复位来启动的。
接下来是boot:0x3 (download_boot(uart0/uart1/sdio_rei_reo_v2))。这个状态码表示系统启动时选择了下载启动模式。在这种模式下,系统会通过串口0、串口1或SDIO接口与其他设备进行通信,并下载启动镜像。这意味着系统将从外部设备中加载特定的启动程序或固件,并执行它们来完成系统的启动过程。
总的来说,这两个状态码告诉我们系统是通过电源复位启动的,并选择了下载启动模式,以便通过外部设备加载启动镜像。此后,系统将继续执行特定的启动程序或固件,完成整个系统的启动过程。
帮我写一段stm32 sd卡写入的驱动
好的,以下是一段基于STM32的SD卡写入驱动的代码:
#include "stm32f4xx.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_sdio.h"
#define SDIO_INIT_CLK_DIV x76 // SDIO初始化时的时钟分频系数
#define SDIO_TRANSFER_CLK_DIV x02 // SDIO传输时的时钟分频系数
void SDIO_GPIO_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOB, ENABLE);
// PC8-11: SDIO_D-D3
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource8, GPIO_AF_SDIO);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_SDIO);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_SDIO);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_SDIO);
// PD2: SDIO_CMD
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource2, GPIO_AF_SDIO);
// PB15: SDIO_CK
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource15, GPIO_AF_SDIO);
}
void SDIO_Config(void)
{
SDIO_InitTypeDef SDIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SDIO, ENABLE);
SDIO_DeInit();
SDIO_InitStructure.SDIO_ClockDiv = SDIO_INIT_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);
SDIO_SetPowerState(SDIO_PowerState_ON);
SDIO_ClockCmd(ENABLE);
SDIO_InitStructure.SDIO_ClockDiv = SDIO_TRANSFER_CLK_DIV;
SDIO_Init(&SDIO_InitStructure);
}
void SDIO_WriteBlock(uint8_t *buf, uint32_t addr, uint16_t blocksize)
{
SDIO_DataInitTypeDef SDIO_DataInitStructure;
SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT;
SDIO_DataInitStructure.SDIO_DataLength = blocksize;
SDIO_DataInitStructure.SDIO_DataBlockSize = SDIO_DataBlockSize_512b;
SDIO_DataInitStructure.SDIO_TransferDir = SDIO_TransferDir_ToCard;
SDIO_DataInitStructure.SDIO_TransferMode = SDIO_TransferMode_Block;
SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable;
SDIO_ConfigData(&SDIO_DataInitStructure);
SDIO_SendCommand(SDIO_CMD_SET_BLOCKLEN, blocksize, SDIO_Response_Short);
SDIO_SendCommand(SDIO_CMD_WRITE_SINGLE_BLOCK, addr, SDIO_Response_Short);
while (SDIO_GetFlagStatus(SDIO_FLAG_TXFIFOHE) == RESET);
for (int i = ; i < blocksize; i += 4)
{
while (SDIO_GetFlagStatus(SDIO_FLAG_TXFIFOHE) == RESET);
SDIO_WriteData(*((uint32_t *)buf));
buf += 4;
}
while (SDIO_GetFlagStatus(SDIO_FLAG_TXC) == RESET);
}
int main(void)
{
uint8_t buf[512];
uint32_t addr = x00000000;
uint16_t blocksize = 512;
SDIO_GPIO_Config();
SDIO_Config();
// 将buf中的数据写入SD卡
SDIO_WriteBlock(buf, addr, blocksize);
while (1);
return ;
}
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)