1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-16 02:10:55 +00:00

trezorhal: minor changes in sdcard

This commit is contained in:
Pavol Rusnak 2017-03-13 11:48:19 +01:00
parent f6f3765a3e
commit 0cb0b11723
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 6 additions and 6 deletions

View File

@ -115,7 +115,7 @@ void SDIO_IRQHandler(void) {
HAL_SD_IRQHandler(&sd_handle); HAL_SD_IRQHandler(&sd_handle);
} }
uint32_t sdcard_read_blocks(uint8_t *dest, uint32_t block_num, uint32_t num_blocks) { uint32_t sdcard_read_blocks(void *dest, uint32_t block_num, uint32_t num_blocks) {
// check that SD card is initialised // check that SD card is initialised
if (sd_handle.Instance == NULL) { if (sd_handle.Instance == NULL) {
return SD_ERROR; return SD_ERROR;
@ -123,13 +123,13 @@ uint32_t sdcard_read_blocks(uint8_t *dest, uint32_t block_num, uint32_t num_bloc
// check that dest pointer is aligned on a 4-byte boundary // check that dest pointer is aligned on a 4-byte boundary
if (((uint32_t)dest & 3) != 0) { if (((uint32_t)dest & 3) != 0) {
return SD_ERROR; return SD_INVALID_PARAMETER;
} }
return HAL_SD_ReadBlocks_BlockNumber(&sd_handle, (uint32_t*)dest, block_num, SDCARD_BLOCK_SIZE, num_blocks); 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) { uint32_t sdcard_write_blocks(const void *src, uint32_t block_num, uint32_t num_blocks) {
// check that SD card is initialised // check that SD card is initialised
if (sd_handle.Instance == NULL) { if (sd_handle.Instance == NULL) {
return SD_ERROR; return SD_ERROR;
@ -137,7 +137,7 @@ uint32_t sdcard_write_blocks(const uint8_t *src, uint32_t block_num, uint32_t nu
// check that src pointer is aligned on a 4-byte boundary // check that src pointer is aligned on a 4-byte boundary
if (((uint32_t)src & 3) != 0) { if (((uint32_t)src & 3) != 0) {
return SD_ERROR; return SD_INVALID_PARAMETER;
} }
return HAL_SD_WriteBlocks_BlockNumber(&sd_handle, (uint32_t*)src, block_num, SDCARD_BLOCK_SIZE, num_blocks); return HAL_SD_WriteBlocks_BlockNumber(&sd_handle, (uint32_t*)src, block_num, SDCARD_BLOCK_SIZE, num_blocks);

View File

@ -11,7 +11,7 @@ bool sdcard_is_present(void);
bool sdcard_power_on(void); bool sdcard_power_on(void);
void sdcard_power_off(void); void sdcard_power_off(void);
uint64_t sdcard_get_capacity_in_bytes(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_read_blocks(void *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); uint32_t sdcard_write_blocks(const void *src, uint32_t block_num, uint32_t num_blocks);
#endif #endif