예제 #1
0
파일: example.c 프로젝트: marekr/asf
/**
 * \brief Application entry point.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main(void)
{
	uint8_t slot = 0;
	sd_mmc_err_t err;

	system_init();
	delay_init();
	cdc_uart_init();

	irq_initialize_vectors();
	cpu_irq_enable();

	time_tick_init();

	// Initialize SD MMC stack
	sd_mmc_init();

	printf("\x0C\n\r-- SD/MMC Card Example --\n\r");
	printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__);
	while (1) {
		if (slot == sd_mmc_nb_slot()) {
			slot = 0;
		}
		printf("Please plug an SD/MMC card in slot %d.\n\r", slot+1);

		// Wait for a card and ready
		do {
			err = sd_mmc_check(slot);
			if ((SD_MMC_ERR_NO_CARD != err)
					&& (SD_MMC_INIT_ONGOING != err)
					&& (SD_MMC_OK != err)) {
				printf("Card install FAILED\n\r");
				printf("Please unplug and re-plug the card.\n\r");
				while (SD_MMC_ERR_NO_CARD != sd_mmc_check(slot)) {
				}
			}
		} while (SD_MMC_OK != err);
	
		// Display basic card information
		main_display_info_card(slot);
	
		/* Test the card */
		if (sd_mmc_get_type(slot) & (CARD_TYPE_SD | CARD_TYPE_MMC)) {
			// SD/MMC Card R/W
			main_test_memory(slot);
		}	

		printf("Test finished, please unplugged the card.\n\r");
		while (SD_MMC_OK == sd_mmc_check(slot)) {
		}
		slot++;
	}
}
예제 #2
0
void AtmelMemTest(void)
{
    uint8_t slot = 0;
    sd_mmc_err_t err;
    REDSTATUS ret;

    printf("\x0C\n\r-- SD/MMC/SDIO Card Example --\n\r");
    printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__);

    printf("Please plug an SD, MMC or SDIO card in slot %d.\n\r", slot+1);

    // Wait for a card and ready
    do {
        err = sd_mmc_check(slot);
        if ((SD_MMC_ERR_NO_CARD != err)
        && (SD_MMC_INIT_ONGOING != err)
        && (SD_MMC_OK != err)) {
            printf("Card install FAILED\n\r");
            printf("Please unplug and re-plug the card.\n\r");
            while(SD_MMC_ERR_NO_CARD != sd_mmc_check(slot)) {
            }
        }
    } while (SD_MMC_OK != err);

    // Display basic card information
    main_display_info_card(slot);

    ret = RedOsTimestampInit();
    if (ret != 0) {
        printf("Unable to initialize timestamps, err=%d\n\r", (int)ret);
        return;
    }

    /* Test the card */
    if (sd_mmc_get_type(slot) & CARD_TYPE_SDIO) {
        // Test CIA of SDIO card
        main_test_sdio(slot);
    }
    if (sd_mmc_get_type(slot) & (CARD_TYPE_SD | CARD_TYPE_MMC)) {
        // SD/MMC Card R/W
        main_test_memory(slot);
    }

    (void)RedOsTimestampUninit();

    printf("SD/MMC card test finished.\n\r");
}
예제 #3
0
파일: example.c 프로젝트: Dewb/mod
/**
 * \brief Application entry point.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main(void)
{
	uint8_t slot = 0;
	sd_mmc_err_t err;

	const usart_serial_options_t usart_serial_options = {
		.baudrate   = CONF_TEST_BAUDRATE,
		.charlength = CONF_TEST_CHARLENGTH,
		.paritytype = CONF_TEST_PARITY,
		.stopbits   = CONF_TEST_STOPBITS,
	};

	irq_initialize_vectors();
	cpu_irq_enable();

	sysclk_init();
	board_init();
	stdio_serial_init(CONF_TEST_USART, &usart_serial_options);

	time_tick_init();

	// Initialize SD MMC stack
	sd_mmc_init();

	printf("\x0C\n\r-- SD/MMC/SDIO Card Example --\n\r");
	printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__);
	while (1) {
		if (slot == sd_mmc_nb_slot()) {
			slot = 0;
		}
		printf("Please plug an SD, MMC or SDIO card in slot %d.\n\r", slot+1);

		// Wait for a card and ready
		do {
			err = sd_mmc_check(slot);
			if ((SD_MMC_ERR_NO_CARD != err)
					&& (SD_MMC_INIT_ONGOING != err)
					&& (SD_MMC_OK != err)) {
				printf("Card install FAILED\n\r");
				printf("Please unplug and re-plug the card.\n\r");
				while (SD_MMC_ERR_NO_CARD != sd_mmc_check(slot)) {
				}
			}
		} while (SD_MMC_OK != err);
	
		// Display basic card information
		main_display_info_card(slot);
	
		/* Test the card */
		if (sd_mmc_get_type(slot) & CARD_TYPE_SDIO) {
			// Test CIA of SDIO card
			main_test_sdio(slot);
		}
		if (sd_mmc_get_type(slot) & (CARD_TYPE_SD | CARD_TYPE_MMC)) {
			// SD/MMC Card R/W
			main_test_memory(slot);
		}	

		printf("Test finished, please unplugged the card.\n\r");
		while (SD_MMC_OK == sd_mmc_check(slot)) {
		}
		slot++;
	}
}