SD/MMC card example.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include <stdio_serial.h>
#include "conf_board.h"
#include "conf_clock.h"
#include "conf_example.h"
#include "sd_mmc_protocol.h"
#include <string.h>
#include "time_tick.h"
Functions | |
int | main (void) |
Application entry point. More... | |
static void | main_display_info_card (uint8_t slot) |
Display basic information of the card. More... | |
static void | main_dump_buffer (uint8_t *data_buffer, uint32_t length) |
Dump and print buffer. More... | |
static void | main_test_memory (uint8_t slot) |
Card R/W tests. More... | |
static void | main_test_sdio (uint8_t slot) |
Perform test on CIA (Common I/O Area) of SDIO card. More... | |
Read/write access configurations | |
#define | TEST_MEM_START_OFFSET (1024lu * 1024lu * 4lu) |
Offset before the end of memory card to start the test. More... | |
#define | TEST_MEM_AREA_SIZE (1024lu * 1024lu * 1lu) |
Memory area size dedicated for the read/write test. More... | |
#define | TEST_MEM_ACCESS_SIZE (8lu * SD_MMC_BLOCK_SIZE) |
Size of each read or write access. More... | |
#define | TEST_FILL_VALUE_U32 (0x5500AAFFU) |
The value used to generate test data. More... | |
#define | TEST_CIA_SIZE (0x16) |
Read and write test length of CIA in bytes. More... | |
static COMPILER_WORD_ALIGNED uint8_t | buf_test [TEST_MEM_ACCESS_SIZE] |
Buffer used by read/write tests. More... | |
static uint8_t | buf_cia [TEST_CIA_SIZE] |
Buffer for test SDIO data. More... | |
#define TEST_CIA_SIZE (0x16) |
Read and write test length of CIA in bytes.
Referenced by main_test_sdio().
#define TEST_FILL_VALUE_U32 (0x5500AAFFU) |
The value used to generate test data.
Referenced by main_test_memory().
#define TEST_MEM_ACCESS_SIZE (8lu * SD_MMC_BLOCK_SIZE) |
Size of each read or write access.
Increasing this number can get higher R/W performance.
Referenced by main_test_memory().
#define TEST_MEM_AREA_SIZE (1024lu * 1024lu * 1lu) |
Memory area size dedicated for the read/write test.
Referenced by main_test_memory().
#define TEST_MEM_START_OFFSET (1024lu * 1024lu * 4lu) |
Offset before the end of memory card to start the test.
Referenced by main_test_memory().
int main | ( | void | ) |
Application entry point.
References uart_rs232_options::baudrate, board_init(), CARD_TYPE_MMC, CARD_TYPE_SD, CARD_TYPE_SDIO, cpu_irq_enable, irq_initialize_vectors, main_display_info_card(), main_test_memory(), main_test_sdio(), sd_mmc_check(), SD_MMC_ERR_NO_CARD, sd_mmc_get_type(), sd_mmc_init(), SD_MMC_INIT_ONGOING, sd_mmc_nb_slot(), SD_MMC_OK, stdio_serial_init(), sysclk_init(), time_tick_init(), and usart_serial_options.
|
static |
Display basic information of the card.
slot | SD/MMC slot to test |
References CARD_TYPE_HC, CARD_TYPE_MMC, CARD_TYPE_SD, CARD_TYPE_SD_COMBO, CARD_TYPE_SDIO, CARD_TYPE_UNKNOWN, sd_mmc_get_capacity(), and sd_mmc_get_type().
Referenced by main().
|
static |
Dump and print buffer.
data_buffer | Pointer to data buffer. |
length | Buffer length. |
Referenced by main_test_sdio().
|
static |
Card R/W tests.
slot | SD/MMC slot to test |
References buf_test, SD_MMC_BLOCK_SIZE, sd_mmc_get_capacity(), sd_mmc_init_read_blocks(), sd_mmc_init_write_blocks(), sd_mmc_is_write_protected(), SD_MMC_OK, sd_mmc_start_read_blocks(), sd_mmc_start_write_blocks(), sd_mmc_wait_end_of_read_blocks(), sd_mmc_wait_end_of_write_blocks(), TEST_FILL_VALUE_U32, TEST_MEM_ACCESS_SIZE, TEST_MEM_AREA_SIZE, TEST_MEM_START_OFFSET, time_tick_calc_delay(), and time_tick_get().
Referenced by main().
|
static |
Perform test on CIA (Common I/O Area) of SDIO card.
slot | SD/MMC slot to test |
References buf_cia, main_dump_buffer(), SDIO_CCCR_IEN, SDIO_CIA, and TEST_CIA_SIZE.
Referenced by main().
|
static |
Buffer for test SDIO data.
Referenced by main_test_sdio().
|
static |
Buffer used by read/write tests.
Referenced by main_test_memory().