pub unsafe extern "C" fn MSS_MMC_set_handler(
handler: mss_mmc_handler_t,
)Expand description
The MSS_MMC_set_handler() function registers a handler function that will be called by the driver when a read o write transfer completes. The application must create and register a transfer completion handler function. The MSS eMMC SD driver passes the outcome of the transfer to the completion handler in the form of a status (SRS12 register) parameter indicating if the transfer is successful or the type of error that occurred during the transfer if the transfer failed.
@param handler The handler parameter is a pointer to a handler function provided by the application. This handler is of type mss_mmc_handler_t. The handler function must take one parameter of type uint32_t and must not return a value.
@return This function does not return a value.
@example The following example shows the use of MSS_MMC_set_handler() function.
@code
#define BLOCK_1 0x00000001u #define BUFFER_SIZE 1024 #define ERROR_INTERRUPT 0x8000 #define TRANSFER_COMPLETE 0x1
void transfer_complete_handler(uint32_t srs12_status); volatile uint32_t g_xfer_in_progress = 0;
mss_mmc_cfg_t g_mmc0; mss_mmc_status_t ret_status; uint8_t data_buffer[BUFFER_SIZE]; uint32_t loop_count;
g_mmc0.clk_rate = MSS_MMC_CLOCK_25MHZ; g_mmc0.card_type = MSS_MMC_CARD_TYPE_MMC; g_mmc0.data_bus_width = MSS_MMC_DATA_WIDTH_4BIT; g_mmc0.bus_speed_mode = MSS_MMC_MODE_LEGACY; g_mmc0.bus_voltage = MSS_MMC_3_3V_BUS_VOLTAGE;
for (loop_count = 0; loop_count < (BUFFER_SIZE); loop_count++) { data_buffer[loop_count] = 0x45 + loop_count; }
ret_status = MMC_init(&g_mmc0); if (MSS_MMC_INIT_SUCCESS == ret_status) { MSS_MMC_set_handler(transfer_complete_handler); ret_status = MSS_MMC_adma2_write(data_buffer, BLOCK_1, BUFFER_SIZE); if (ret_status == MSS_MMC_TRANSFER_IN_PROGRESS) { while(g_xfer_in_progress) { ; } } }
void transfer_complete_handler(uint32_t srs12_status) { g_xfer_in_progress = 0; uint32_t isr_err; if(ERROR_INTERRUPT & srs12_status) { isr_err = srs12_status >> 16; } else if(TRANSFER_COMPLETE & srs12_status) { isr_err = 0; } else { } } @endcode