diff --git a/src/W800_SDK_v1.00.10/app/app_drivers/mmc_sdio/mmc_sdio.c b/src/W800_SDK_v1.00.10/app/app_drivers/mmc_sdio/mmc_sdio.c index 0dbe660..dacdb22 100644 --- a/src/W800_SDK_v1.00.10/app/app_drivers/mmc_sdio/mmc_sdio.c +++ b/src/W800_SDK_v1.00.10/app/app_drivers/mmc_sdio/mmc_sdio.c @@ -99,7 +99,7 @@ void mmc_sdio_driver_write_dma_async(uint32_t *data, uint32_t dataLengthInBytes) void mmc_sdio_driver_write_one(uint8_t data) { /* Wait for MMC device to be ready to send the data */ - while (SDIO_HOST->MMC_IO & 0x01); + mmc_sdio_driver_blocking_wait_bus_free(); SDIO_HOST->BUF_CTL = 0x4820; SDIO_HOST->DATA_BUF[0] = (uint32_t)data; @@ -107,19 +107,25 @@ void mmc_sdio_driver_write_one(uint8_t data) /* Start the transfer */ SDIO_HOST->MMC_IO = 0x01; /* Wait for MMC device to be done sending the data */ - while (SDIO_HOST->MMC_IO & 0x01); + mmc_sdio_driver_blocking_wait_bus_free(); } void mmc_sdio_driver_write(const uint8_t *data, uint16_t dataLengthInBytes) { /* Wait for MMC device to be ready to send the data */ - while (SDIO_HOST->MMC_IO & 0x01); + mmc_sdio_driver_blocking_wait_bus_free(); SDIO_HOST->BUF_CTL = 0x4820; memcpy((void *)SDIO_HOST->DATA_BUF, (void *)data, dataLengthInBytes); SDIO_HOST->MMC_BYTECNTL = dataLengthInBytes; /* Start the transfer */ SDIO_HOST->MMC_IO = 0x01; + /* Wait for MMC device to be done sending the data */ + mmc_sdio_driver_blocking_wait_bus_free(); +} + +void mmc_sdio_driver_blocking_wait_bus_free(void) +{ while (SDIO_HOST->MMC_IO & 0x01); } diff --git a/src/W800_SDK_v1.00.10/app/app_drivers/mmc_sdio/mmc_sdio.h b/src/W800_SDK_v1.00.10/app/app_drivers/mmc_sdio/mmc_sdio.h index 2a1ec8d..f20e4a0 100644 --- a/src/W800_SDK_v1.00.10/app/app_drivers/mmc_sdio/mmc_sdio.h +++ b/src/W800_SDK_v1.00.10/app/app_drivers/mmc_sdio/mmc_sdio.h @@ -23,7 +23,7 @@ void mmc_sdio_driver_periph_init(DMATransferDoneCb_t DMATransferDoneCb, void *ar * @param dataLengthInBytes the size in bytes of the data to transfer. * Maximum length is 65535 bytes. */ -void mmc_sdio_driver_write_dma_async(uint32_t *data, u32 dataLengthInBytes); +void mmc_sdio_driver_write_dma_async(uint32_t *data, uint32_t dataLengthInBytes); /** * @brief Sends one byte of data to the slave @@ -43,4 +43,10 @@ void mmc_sdio_driver_write_one(uint8_t data); */ void mmc_sdio_driver_write(const uint8_t *data, uint16_t dataLengthInBytes); +/** + * @brief Performs a busy wait until the data bus is free for us to use. + * + */ +void mmc_sdio_driver_blocking_wait_bus_free(void); + #endif //MMC_SDIO_H \ No newline at end of file