请教下 ,关于最新版本的库
STM32Cube_FW_F7_V1.6.0 版本的 sd dma 的使用 ?
目前使用sd dma 读写总是失败,如果不使用dma读写则完全没有问题
现在就是想请教下,当使用 dma 读写时,需要调用什么函数来判断这个dma 的读写是否完成 ???????????
使用dma 相关函数如下:
uint8_t SD_RxCplt , SD_TxCplt ;
uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t NumOfBlocks)
{
uint8_t sd_state = MSD_OK;
if(HAL_SD_ReadBlocks_DMA(&_HSD, (uint8_t *)pData, ReadAddr, NumOfBlocks) != HAL_OK)
{
sd_state = MSD_ERROR;
}
return sd_state;
}
uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t NumOfBlocks)
{
uint8_t sd_state = MSD_OK;
if(HAL_SD_WriteBlocks_DMA(&_HSD, (uint8_t *)pData, WriteAddr, NumOfBlocks) != HAL_OK)
{
sd_state = MSD_ERROR;
}
return sd_state;
}
DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
{
DRESULT res = RES_OK;
uint32_t
timeout = 100000;
if(BSP_SD_ReadBlocks_DMA((uint32_t*)buff,
(uint64_t) (sector ),
count) == MSD_OK)
{
while(SD_RxCplt == 0)
{
if (timeout-- == 0)
{
SD_RxCplt = 0;
sd_state = MSD_ERROR;
}
}
SD_RxCplt = 0;
res = RES_OK;
}
return res;
}
DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
{
DRESULT res = RES_OK;
uint32_t timeout = 100000;
if(BSP_SD_WriteBlocks_DMA((uint32_t*)buff,
(uint64_t)(sector ),
count) == MSD_OK)
{
while(SD_TxCplt == 0)
{
if (timeout-- == 0)
{
SD_TxCplt = 0;
sd_state = MSD_ERROR;
}
}
SD_TxCplt = 0;
res = RES_OK;
}
return res;
}
回调函数/**
* @brief Tx Transfer completed callbacks
*/
void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)
{
SD_TxCplt = 1;
printf("SD Tx Completed
");
}
/**
* @brief Rx Transfer completed callbacks
*/
void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd)
{
SD_RxCplt = 1;
printf("SD Rx Completed
");
}
现在就是想请教下,当使用 dma 读写时,需要调用什么函数来判断这个dma 的读写是否完成 ???????????
// **********************************************************************************
在以前的老版本里面有个 如下函数,但是在目前的 这个 f7 v1.6的库里面已经找不到了
/* Wait until Tx Rx complete */
HAL_SD_CheckWriteOperation(&_HSD, (uint32_t)SD_DATATIMEOUT) ;
HAL_SD_CheckReadOperation(&_HSD, (uint32_t)SD_DATATIMEOUT);
不太好确定 你测试试试 反正我的read_dma只能读4个字节
你好,这个最新的固件库 v1.6版本里面已经木有你所说的那两个函数了,
在 v1.6 版本之前是有的,但是在 v1.6 版本里面已经找不到了
* @brief Reads block(s) from a specified address in a card. The Data transfer
* is managed by DMA mode.
* @note This API should be followed by a check on the card state through
* HAL_SD_GetCardState().
* @note You could also check the DMA transfer process through the SD Rx
* interrupt event.
* @param hsd: Pointer SD handle
* @param pData: Pointer to the buffer that will contain the received data
* @param BlockAdd: Block Address from where data is to be read
* @param NumberOfBlocks: Number of blocks to read.
* @retval HAL status
*/
HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks)
这个是在库文件找到的,当用HAL_SD_GetCardState().返回的结果总是4 HAL_SD_CARD_TRANSFER = 0x00000004U, /*!< Card is in transfer state */
我目前使用的查询貌似,dma 模式还没有去研究,除非把他替换为 v1.6 之前的版本就可以使用 dma 模式了,
一周热门 更多>