mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
refactor(core/embed): remove unnecessary sync from sdcard driver
[no changelog]
This commit is contained in:
parent
20814f7ae6
commit
3fb55a373d
@ -298,9 +298,6 @@ secbool sdcard_read_blocks(uint32_t *dest, uint32_t block_num,
|
|||||||
|
|
||||||
HAL_StatusTypeDef err = HAL_OK;
|
HAL_StatusTypeDef err = HAL_OK;
|
||||||
|
|
||||||
// we must disable USB irqs to prevent MSC contention with SD card
|
|
||||||
uint32_t basepri = raise_irq_pri(IRQ_PRI_OTG_FS);
|
|
||||||
|
|
||||||
sd_dma.Instance = DMA2_Stream3;
|
sd_dma.Instance = DMA2_Stream3;
|
||||||
sd_dma.State = HAL_DMA_STATE_RESET;
|
sd_dma.State = HAL_DMA_STATE_RESET;
|
||||||
sd_dma.Init.Channel = DMA_CHANNEL_4;
|
sd_dma.Init.Channel = DMA_CHANNEL_4;
|
||||||
@ -340,8 +337,6 @@ secbool sdcard_read_blocks(uint32_t *dest, uint32_t block_num,
|
|||||||
HAL_DMA_DeInit(&sd_dma);
|
HAL_DMA_DeInit(&sd_dma);
|
||||||
sd_handle.hdmarx = NULL;
|
sd_handle.hdmarx = NULL;
|
||||||
|
|
||||||
restore_irq_pri(basepri);
|
|
||||||
|
|
||||||
return sectrue * (err == HAL_OK);
|
return sectrue * (err == HAL_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,9 +354,6 @@ secbool sdcard_write_blocks(const uint32_t *src, uint32_t block_num,
|
|||||||
|
|
||||||
HAL_StatusTypeDef err = HAL_OK;
|
HAL_StatusTypeDef err = HAL_OK;
|
||||||
|
|
||||||
// we must disable USB irqs to prevent MSC contention with SD card
|
|
||||||
uint32_t basepri = raise_irq_pri(IRQ_PRI_OTG_FS);
|
|
||||||
|
|
||||||
sd_dma.Instance = DMA2_Stream3;
|
sd_dma.Instance = DMA2_Stream3;
|
||||||
sd_dma.State = HAL_DMA_STATE_RESET;
|
sd_dma.State = HAL_DMA_STATE_RESET;
|
||||||
sd_dma.Init.Channel = DMA_CHANNEL_4;
|
sd_dma.Init.Channel = DMA_CHANNEL_4;
|
||||||
@ -401,7 +393,5 @@ secbool sdcard_write_blocks(const uint32_t *src, uint32_t block_num,
|
|||||||
HAL_DMA_DeInit(&sd_dma);
|
HAL_DMA_DeInit(&sd_dma);
|
||||||
sd_handle.hdmatx = NULL;
|
sd_handle.hdmatx = NULL;
|
||||||
|
|
||||||
restore_irq_pri(basepri);
|
|
||||||
|
|
||||||
return sectrue * (err == HAL_OK);
|
return sectrue * (err == HAL_OK);
|
||||||
}
|
}
|
||||||
|
@ -301,16 +301,12 @@ secbool sdcard_read_blocks(uint32_t *dest, uint32_t block_num,
|
|||||||
|
|
||||||
HAL_StatusTypeDef err = HAL_OK;
|
HAL_StatusTypeDef err = HAL_OK;
|
||||||
|
|
||||||
// we must disable USB irqs to prevent MSC contention with SD card
|
|
||||||
uint32_t basepri = raise_irq_pri(IRQ_PRI_OTG_FS);
|
|
||||||
|
|
||||||
sdcard_reset_periph();
|
sdcard_reset_periph();
|
||||||
err =
|
err =
|
||||||
HAL_SD_ReadBlocks_DMA(&sd_handle, (uint8_t *)dest, block_num, num_blocks);
|
HAL_SD_ReadBlocks_DMA(&sd_handle, (uint8_t *)dest, block_num, num_blocks);
|
||||||
if (err == HAL_OK) {
|
if (err == HAL_OK) {
|
||||||
err = sdcard_wait_finished(&sd_handle, 5000);
|
err = sdcard_wait_finished(&sd_handle, 5000);
|
||||||
}
|
}
|
||||||
restore_irq_pri(basepri);
|
|
||||||
|
|
||||||
return sectrue * (err == HAL_OK);
|
return sectrue * (err == HAL_OK);
|
||||||
}
|
}
|
||||||
@ -329,9 +325,6 @@ secbool sdcard_write_blocks(const uint32_t *src, uint32_t block_num,
|
|||||||
|
|
||||||
HAL_StatusTypeDef err = HAL_OK;
|
HAL_StatusTypeDef err = HAL_OK;
|
||||||
|
|
||||||
// we must disable USB irqs to prevent MSC contention with SD card
|
|
||||||
uint32_t basepri = raise_irq_pri(IRQ_PRI_OTG_FS);
|
|
||||||
|
|
||||||
sdcard_reset_periph();
|
sdcard_reset_periph();
|
||||||
err =
|
err =
|
||||||
HAL_SD_WriteBlocks_DMA(&sd_handle, (uint8_t *)src, block_num, num_blocks);
|
HAL_SD_WriteBlocks_DMA(&sd_handle, (uint8_t *)src, block_num, num_blocks);
|
||||||
@ -339,7 +332,5 @@ secbool sdcard_write_blocks(const uint32_t *src, uint32_t block_num,
|
|||||||
err = sdcard_wait_finished(&sd_handle, 5000);
|
err = sdcard_wait_finished(&sd_handle, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
restore_irq_pri(basepri);
|
|
||||||
|
|
||||||
return sectrue * (err == HAL_OK);
|
return sectrue * (err == HAL_OK);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user