Wrapped the SDIO MMC IO busy wait statement in a function such that it can be called by any API needing it

This commit is contained in:
anschrammh 2023-03-30 13:08:57 +02:00
parent 2b79a31165
commit e8583254e6
2 changed files with 16 additions and 4 deletions

View File

@ -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);
}

View File

@ -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