Exemple #1
0
/**
 * \brief SDIO card read and write test.
 *
 * \param test Current test case.
 */
static void run_sdio_rw_test(const struct test_case *test)
{
	sd_mmc_err_t err;

	/*
	 * ---- Test direct R/W ----
	 */
	/* Write */
	err = sdio_write_direct(0, SDIO_CIA, SDIO_CCCR_IEN, 0x02);
	test_assert_true(test, err == SD_MMC_OK,
			"Error: SDIO direct write failed\n\r");

	/* Read */
	err = sdio_read_direct(0, SDIO_CIA, SDIO_CCCR_IEN,
			&buf_cia[SDIO_CCCR_IEN]);
	test_assert_true(test, err == SD_MMC_OK,
			"Error: SDIO direct read failed\n\r");

	/* Check */
	test_assert_true(test, buf_cia[SDIO_CCCR_IEN] == 0x02,
			"Error: SDIO direct R/W verification failed\n\r");

	/* Restore data to 0 */
	sdio_write_direct(0, SDIO_CIA, SDIO_CCCR_IEN, 0);

	/*
	 * ---- Test extended R/W ----
	 */
	/* Write */
	buf_cia[SDIO_CCCR_IEN] = 0x3;
	err = sdio_write_extended(0, SDIO_CIA, SDIO_CCCR_IEN, 1,
			&buf_cia[SDIO_CCCR_IEN], 1);
	test_assert_true(test, err == SD_MMC_OK,
			"Error: SDIO extended write failed\n\r");

	/* Read and check */
	err = sdio_read_extended(0, SDIO_CIA, 0, 1, &buf_cia[0],
			TEST_CIA_SIZE);
	test_assert_true(test, err == SD_MMC_OK,
			"Error: SDIO extended read failed\n\r");

	test_assert_true(test, buf_cia[SDIO_CCCR_IEN] == 0x3,
			"Error: SDIO extended R/W verification failed\n\r");

	/* Restore data to 0 */
	sdio_write_direct(0, SDIO_CIA, SDIO_CCCR_IEN, 0);
}
Exemple #2
0
/**
 * \brief Perform test on CIA (Common I/O Area) of SDIO card.
 *
 * \note The Common I/O Area (CIA) shall be implemented on all SDIO cards.
 *
 * \param slot   SD/MMC slot to test
 */
static void main_test_sdio(uint8_t slot)
{
    uint32_t i;
    uint32_t err;

    /*
     * Test with direct read and write command.
     */
    printf("\n\r--- Test with direct read and write command of CIA:\n\r");
    /* Read */
    for (i = 0; i < TEST_CIA_SIZE; i++) {
        err = sdio_read_direct(slot, SDIO_CIA, i, &buf_cia[i]);
        if (err) {
            printf("Error: SDIO direct read failed.\n\r");
            return;
        }
    }
    main_dump_buffer(buf_cia, TEST_CIA_SIZE);

    /* Write */
    printf("Write 0x02 to IEN(CIA.4).\n\r");
    err = sdio_write_direct(slot, SDIO_CIA, SDIO_CCCR_IEN, 0x02);
    if (err) {
        printf("Error: SDIO direct write failed.\n\r");
        return;
    }

    /* Check */
    printf("Check IEN after write:");
    err = sdio_read_direct(slot, SDIO_CIA, SDIO_CCCR_IEN,
            &buf_cia[SDIO_CCCR_IEN]);
    if (err) {
        printf("Error: SDIO direct read failed.\n\r");
        return;
    }

    printf("0x%02x\n\r", buf_cia[SDIO_CCCR_IEN]);
    if (0x02 == buf_cia[SDIO_CCCR_IEN]) {
        printf("Test OK.\n\r");
    } else {
        printf("Test failed.\n\r");
    }

    /* Restore data to 0 */
    sdio_write_direct(slot, SDIO_CIA, SDIO_CCCR_IEN, 0);

    /* Clear the buffer. */
    memset(buf_cia, 0x0, sizeof(buf_cia));

    /*
     *  Test with extended read and write command.
     */
    printf("\n\r--- Test with extended read and write command of CIA:\n\r");
    /* Read */
    err = sdio_read_extended(slot, SDIO_CIA, 0, 1, &buf_cia[0],
            TEST_CIA_SIZE);
    if (err) {
        printf("Error: SDIO extended read failed.\n\r");
        return;
    }

    main_dump_buffer(buf_cia, TEST_CIA_SIZE);

    /* Write */
    printf("Modify Some R/W bytes for FN0 and write:\n\r");
    buf_cia[SDIO_CCCR_IEN] = 0x3;
    err = sdio_write_extended(slot, SDIO_CIA, SDIO_CCCR_IEN, 1,
            &buf_cia[SDIO_CCCR_IEN], 1);
    if (err) {
        printf("Error: SDIO extended write failed.\n\r");
        return;
    }

    /* Read and check */
    printf("Check CIA after write:\n\r");
    err = sdio_read_extended(slot, SDIO_CIA, 0, 1, &buf_cia[0],
            TEST_CIA_SIZE);
    if (err) {
        printf("Error: SDIO extended read failed.\n\r");
        return;
    }

    main_dump_buffer(buf_cia, TEST_CIA_SIZE);

    if (buf_cia[SDIO_CCCR_IEN] != 0x3) {
        printf("CIA.4 Fail\n\r");
    } else {
        printf("Test OK\n\r");
    }

    /* Restore data to 0 */
    sdio_write_direct(slot, SDIO_CIA, SDIO_CCCR_IEN, 0);

    return;
}