From 543127b187caf5950fcb1d1d2119ab25ffee5099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 16 Aug 2020 22:11:57 +0200 Subject: [PATCH] Fix bugs in settings saving --- .../fatfs/shimatta_sdio_driver/shimatta_sdio.c | 12 +++++++++++- .../shimatta_sdio_driver/shimatta_sdio_config.h | 2 +- stm-firmware/settings/settings-sd-card.c | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/stm-firmware/fatfs/shimatta_sdio_driver/shimatta_sdio.c b/stm-firmware/fatfs/shimatta_sdio_driver/shimatta_sdio.c index 964e5ca..c5e0dde 100644 --- a/stm-firmware/fatfs/shimatta_sdio_driver/shimatta_sdio.c +++ b/stm-firmware/fatfs/shimatta_sdio_driver/shimatta_sdio.c @@ -611,6 +611,15 @@ DRESULT sdio_disk_read(BYTE *buff, DWORD sector, UINT count){ uint32_t sdio_status; uint32_t fifo; uint32_t counter; + int err; + union sdio_status_conv status; + + + do { + err = sdio_check_status_register_cmd13(card_info.rca, &status.value); + if (err) + return RES_ERROR; + } while (status.statusstruct.CURRENT_STATE != CURRENT_STATE_TRAN); addr = (card_info.type == SD_V2_HC ? (sector) : (sector*512)); for (; count > 0; count--) { @@ -633,7 +642,8 @@ DRESULT sdio_disk_read(BYTE *buff, DWORD sector, UINT count){ SDIO->DCTRL = (BLOCKSIZE<<4) | SDIO_DCTRL_DTDIR | /*SDIO_DCTRL_DMAEN |*/ SDIO_DCTRL_DTEN; /* Init Transfer */ - if (sdio_send_read_block_cmd17(addr)) { + err = sdio_send_read_block_cmd17(addr); + if (err) { return RES_ERROR; } diff --git a/stm-firmware/fatfs/shimatta_sdio_driver/shimatta_sdio_config.h b/stm-firmware/fatfs/shimatta_sdio_driver/shimatta_sdio_config.h index 576c867..547806c 100644 --- a/stm-firmware/fatfs/shimatta_sdio_driver/shimatta_sdio_config.h +++ b/stm-firmware/fatfs/shimatta_sdio_driver/shimatta_sdio_config.h @@ -14,7 +14,7 @@ //Initial Transfer CLK (ca. 400kHz) #define INITCLK 140 //120 //Working CLK (Maximum) -#define WORKCLK 45 //0 +#define WORKCLK 50 //0 //Data Timeout in CLK Cycles #define DTIMEOUT 0x3000 //150 //DMA Stream used for TX and RX DMA2 Stream 3 or 6 possible diff --git a/stm-firmware/settings/settings-sd-card.c b/stm-firmware/settings/settings-sd-card.c index 8f31112..4e98b9c 100644 --- a/stm-firmware/settings/settings-sd-card.c +++ b/stm-firmware/settings/settings-sd-card.c @@ -121,7 +121,7 @@ int sd_card_settings_save_calibration(float sens_deviation, float offset, bool a int ret = 0; status = create_controller_folder(); - if (status) + if (status < 0) return -2; get_controller_settings_path(path, sizeof(path), "offset");