Microchip® Advanced Software Framework

example.c File Reference

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().

static void main_display_info_card ( uint8_t  slot)
static

Display basic information of the card.

Note
This function should be called only after the card has been initialized successfully.
Parameters
slotSD/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 void main_dump_buffer ( uint8_t *  data_buffer,
uint32_t  length 
)
static

Dump and print buffer.

Parameters
data_bufferPointer to data buffer.
lengthBuffer length.

Referenced by main_test_sdio().

static void main_test_sdio ( uint8_t  slot)
static

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.
Parameters
slotSD/MMC slot to test

References buf_cia, main_dump_buffer(), SDIO_CCCR_IEN, SDIO_CIA, sdio_read_direct(), sdio_read_extended(), sdio_write_direct(), sdio_write_extended(), and TEST_CIA_SIZE.

Referenced by main().

uint8_t buf_cia[TEST_CIA_SIZE]
static

Buffer for test SDIO data.

Referenced by main_test_sdio().

COMPILER_WORD_ALIGNED uint8_t buf_test[TEST_MEM_ACCESS_SIZE]
static

Buffer used by read/write tests.

Referenced by main_test_memory().