Exemplo n.º 1
0
Arquivo: example.c Projeto: 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++;
	}
}
Exemplo n.º 2
0
void memories_initialization(void)
{
#ifdef CONF_BOARD_SMC_PSRAM
	psram_init();
#endif

#ifdef CONF_BOARD_SRAM
	sram_init();
#endif

#ifdef CONF_BOARD_SDRAMC
	/* Enable SMC peripheral clock */
	pmc_enable_periph_clk(ID_SMC);

	/* Complete SDRAM configuration */
	sdramc_init((sdramc_memory_dev_t *)&SDRAM_MICRON_MT48LC16M16A2,
			sysclk_get_cpu_hz());
#endif

#ifdef CONF_BOARD_AT45DBX
	at45dbx_init();

	if (at45dbx_mem_check() != true) {
		while (1) {
		}
	}
#endif

#ifdef CONF_BOARD_SD_MMC_HSMCI
	uint8_t slot = 0;
	sd_mmc_err_t err;
	sd_mmc_init();
          if (slot == sd_mmc_nb_slot()) {
                  slot = 0;
          }
          // 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)) {
                          while (SD_MMC_ERR_NO_CARD != sd_mmc_check(slot)) {
                          }
                  }
          } while (SD_MMC_OK != err);
#endif
}
Exemplo n.º 3
0
void datalog_tasks_init(void)
{
	uint8_t slot = 0;
	sd_mmc_err_t err;
	sd_mmc_init();
	if (slot == sd_mmc_nb_slot()) {
			slot = 0;
	}
	// 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)) {
					while (SD_MMC_ERR_NO_CARD != sd_mmc_check(slot)) {
					}
			}
	} while (SD_MMC_OK != err);
}
Exemplo n.º 4
0
Arquivo: example.c Projeto: 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++;
	}
}