mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 14:28:07 +00:00
trezorhal: enable write to sdcard
This commit is contained in:
parent
a66e5e4ad8
commit
f6f3765a3e
@ -121,14 +121,24 @@ uint32_t sdcard_read_blocks(uint8_t *dest, uint32_t block_num, uint32_t num_bloc
|
||||
return SD_ERROR;
|
||||
}
|
||||
|
||||
HAL_SD_ErrorTypedef err = SD_OK;
|
||||
|
||||
// check that dest pointer is aligned on a 4-byte boundary
|
||||
if (((uint32_t)dest & 3) != 0) {
|
||||
return SD_ERROR;
|
||||
}
|
||||
|
||||
err = HAL_SD_ReadBlocks_BlockNumber(&sd_handle, (uint32_t*)dest, block_num, SDCARD_BLOCK_SIZE, num_blocks);
|
||||
|
||||
return err;
|
||||
return HAL_SD_ReadBlocks_BlockNumber(&sd_handle, (uint32_t*)dest, block_num, SDCARD_BLOCK_SIZE, num_blocks);
|
||||
}
|
||||
|
||||
uint32_t sdcard_write_blocks(const uint8_t *src, uint32_t block_num, uint32_t num_blocks) {
|
||||
// check that SD card is initialised
|
||||
if (sd_handle.Instance == NULL) {
|
||||
return SD_ERROR;
|
||||
}
|
||||
|
||||
// check that src pointer is aligned on a 4-byte boundary
|
||||
if (((uint32_t)src & 3) != 0) {
|
||||
return SD_ERROR;
|
||||
}
|
||||
|
||||
return HAL_SD_WriteBlocks_BlockNumber(&sd_handle, (uint32_t*)src, block_num, SDCARD_BLOCK_SIZE, num_blocks);
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ bool sdcard_power_on(void);
|
||||
void sdcard_power_off(void);
|
||||
uint64_t sdcard_get_capacity_in_bytes(void);
|
||||
uint32_t sdcard_read_blocks(uint8_t *dest, uint32_t block_num, uint32_t num_blocks);
|
||||
uint32_t sdcard_write_blocks(const uint8_t *src, uint32_t block_num, uint32_t num_blocks);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user