OSStatus host_platform_sdio_enumerate( void ) { OSStatus result; uint32_t loop_count; uint32_t data = 0; loop_count = 0; do { /* Send CMD0 to set it to idle state */ host_platform_sdio_transfer( BUS_WRITE, SDIO_CMD_0, SDIO_BYTE_MODE, SDIO_1B_BLOCK, 0, 0, 0, NO_RESPONSE, NULL ); /* CMD5. */ host_platform_sdio_transfer( BUS_READ, SDIO_CMD_5, SDIO_BYTE_MODE, SDIO_1B_BLOCK, 0, 0, 0, NO_RESPONSE, NULL ); /* Send CMD3 to get RCA. */ result = host_platform_sdio_transfer( BUS_READ, SDIO_CMD_3, SDIO_BYTE_MODE, SDIO_1B_BLOCK, 0, 0, 0, RESPONSE_NEEDED, &data ); loop_count++; if ( loop_count >= (uint32_t) SDIO_ENUMERATION_TIMEOUT_MS ) { return kTimeoutErr; } } while ( ( result != kNoErr ) && ( mico_thread_msleep( (uint32_t) 1 ), ( 1 == 1 ) ) ); /* If you're stuck here, check the platform matches your hardware */ /* Send CMD7 with the returned RCA to select the card */ host_platform_sdio_transfer( BUS_WRITE, SDIO_CMD_7, SDIO_BYTE_MODE, SDIO_1B_BLOCK, data, 0, 0, RESPONSE_NEEDED, NULL ); return kNoErr; }
wwd_result_t host_platform_sdio_enumerate( void ) { wwd_result_t result; uint32_t loop_count; uint32_t data = 0; loop_count = 0; do { /* Send CMD0 to set it to idle state */ host_platform_sdio_transfer( BUS_WRITE, SDIO_CMD_0, SDIO_BYTE_MODE, SDIO_1B_BLOCK, 0, 0, 0, NO_RESPONSE, NULL ); /* CMD5. */ host_platform_sdio_transfer( BUS_READ, SDIO_CMD_5, SDIO_BYTE_MODE, SDIO_1B_BLOCK, 0, 0, 0, NO_RESPONSE, NULL ); /* Send CMD3 to get RCA. */ result = host_platform_sdio_transfer( BUS_READ, SDIO_CMD_3, SDIO_BYTE_MODE, SDIO_1B_BLOCK, 0, 0, 0, RESPONSE_NEEDED, &data ); loop_count++; if ( loop_count >= (uint32_t) SDIO_ENUMERATION_TIMEOUT_MS ) { return WICED_TIMEOUT; } } while ( ( result != WWD_SUCCESS ) && ( host_rtos_delay_milliseconds( (uint32_t) 1 ), ( 1 == 1 ) ) ); /* If you're stuck here, check the platform matches your hardware */ /* Send CMD7 with the returned RCA to select the card */ host_platform_sdio_transfer( BUS_WRITE, SDIO_CMD_7, SDIO_BYTE_MODE, SDIO_1B_BLOCK, data, 0, 0, RESPONSE_NEEDED, NULL ); return WICED_SUCCESS; }