SD card library

nRF5 SDK v15.0.0

Asynchronous Secure Digital card (SDC) and MultiMedia card (MMC) library. More...

Data Structures

struct sdc_evt_t
SDC event structure. More...
struct sdc_type_t
SDC type information structure. More...
struct app_sdc_config_t
SDC configuration structure. More...
struct app_sdc_info_t
SDC information structure. More...

Macros

#define SDC_SECTOR_SIZE 512
Size of a single SD card block in bytes.
#define APP_SDCARD_CONFIG (MOSI_PIN, MISO_PIN, SCK_PIN, CS_PIN)

Typedefs

typedef void(* sdc_event_handler_t )( sdc_evt_t const *p_event)
SDC event handler type.

Functions

ret_code_t app_sdc_init ( app_sdc_config_t const *const p_config, sdc_event_handler_t event_handler)
Function for initializing the card. More...
ret_code_t app_sdc_uninit (void)
Function for uninitializing the card. More...
bool app_sdc_busy_check (void)
Function for retrieving the card busy state. More...
ret_code_t app_sdc_block_read (uint8_t *p_buf, uint32_t block_address, uint16_t block_count)
Function for reading the data blocks from the card. More...
ret_code_t app_sdc_block_write (uint8_t const *p_buf, uint32_t block_address, uint16_t block_count)
Function for writing the data blocks to the card. More...
app_sdc_info_t const * app_sdc_info_get (void)
Function for retrieving the card information structure. More...

Detailed Description

Asynchronous Secure Digital card (SDC) and MultiMedia card (MMC) library.

Macro Definition Documentation

#define APP_SDCARD_CONFIG ( MOSI_PIN,
MISO_PIN,
SCK_PIN,
CS_PIN
)
Value:
{ \
.mosi_pin = MOSI_PIN, \
.miso_pin = MISO_PIN, \
.sck_pin = SCK_PIN, \
.cs_pin = CS_PIN \
}

Enumeration Type Documentation

SDC event type.

Enumerator
SDC_EVT_INIT

Initialization procedure.

SDC_EVT_READ

Data read procedure.

SDC_EVT_WRITE

Data write procedure.

SDC operation result.

Enumerator
SDC_SUCCESS

Operation successful.

SDC_ERROR_NOT_RESPONDING

Card is not responding or not present.

SDC_ERROR_TIMEOUT

Card response timeout.

SDC_ERROR_NOT_SUPPORTED

Operation not supported.

SDC_ERROR_COMMUNICATION

Communication error.

SDC_ERROR_DATA

Data read/write error.

SDC_ERROR_INTERNAL

Internal error.

SDC type and version.

Enumerator
SDC_TYPE_UNKNOWN

Unknown / uninitialized card.

SDC_TYPE_MMCV3

MultiMedia card (MMC) version 3.

SDC_TYPE_SDV1

Secure Digital card (SDC) version 1.0.

SDC_TYPE_SDV2

Secure Digital card (SDC) version 2.0.

Function Documentation

ret_code_t app_sdc_block_read ( uint8_t * p_buf ,
uint32_t block_address ,
uint16_t block_count
)

Function for reading the data blocks from the card.

Parameters
[out] p_buf Pointer to the data buffer. Must not be null.
[in] block_address Number of the first block to be read.
[in] block_count Number of blocks to read. Must be greater than 0.
Return values
NRF_SUCCESS If block read operation was started succesfully.
NRF_ERROR_INVALID_STATE If the card is not initialized.
NRF_ERROR_BUSY If there is already an operation active.
NRF_ERROR_INVALID_PARAM If invalid parameters were specified.
ret_code_t app_sdc_block_write ( uint8_t const * p_buf ,
uint32_t block_address ,
uint16_t block_count
)

Function for writing the data blocks to the card.

Parameters
[out] p_buf Pointer to the data to be written. Must not be null.
[in] block_address Number of the first block to write.
[in] block_count Number of blocks to write. Must be greater than 0.
Return values
NRF_SUCCESS If block write operation was started succesfully.
NRF_ERROR_INVALID_STATE If the card is not initialized.
NRF_ERROR_BUSY If there is already an operation active.
NRF_ERROR_INVALID_PARAM If invalid parameters were specified.
bool app_sdc_busy_check ( void )

Function for retrieving the card busy state.

Return values
true If there is an operation in progress.
false If the card is in idle state.
app_sdc_info_t const* app_sdc_info_get ( void )

Function for retrieving the card information structure.

Returns
Pointer to the card information structure or NULL if card is not initialized.
ret_code_t app_sdc_init ( app_sdc_config_t const *const p_config ,
sdc_event_handler_t event_handler
)

Function for initializing the card.

Parameters
[in] p_config Pointer to the SDC configuration structure.
[in] event_handler Pointer to the event handler function.
Return values
NRF_SUCCESS If initialization process was started succesfully.
NRF_ERROR_INVALID_STATE If the card is already initialized or the initialization is in progress.
NRF_ERROR_INVALID_PARAM If invalid parameters were specified.
ret_code_t app_sdc_uninit ( void )

Function for uninitializing the card.

Return values
NRF_SUCCESS If card was uninitialized succesfully.
NRF_ERROR_INVALID_STATE If the card is not initialized.
NRF_ERROR_BUSY If there is an operation in progress.