nRF5 SDK v13.0.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
SD card library

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

Modules

 SD/MMC card support using SPI configuration
 

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.
 

Enumerations

enum  sdc_result_t {
  SDC_SUCCESS = 0,
  SDC_ERROR_NOT_RESPONDING,
  SDC_ERROR_TIMEOUT,
  SDC_ERROR_NOT_SUPPORTED,
  SDC_ERROR_COMMUNICATION,
  SDC_ERROR_DATA,
  SDC_ERROR_INTERNAL
}
 SDC operation result. More...
 
enum  sdc_evt_type_t {
  SDC_EVT_INIT = 0,
  SDC_EVT_READ,
  SDC_EVT_WRITE
}
 SDC event type. More...
 
enum  sdc_version_t {
  SDC_TYPE_UNKNOWN = 0,
  SDC_TYPE_MMCV3,
  SDC_TYPE_SDV1,
  SDC_TYPE_SDV2
}
 SDC type and version. More...
 

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_bufPointer to the data buffer. Must not be null.
[in]block_addressNumber of the first block to be read.
[in]block_countNumber of blocks to read. Must be greater than 0.
Return values
NRF_SUCCESSIf block read operation was started succesfully.
NRF_ERROR_INVALID_STATEIf the card is not initialized.
NRF_ERROR_BUSYIf there is already an operation active.
NRF_ERROR_INVALID_PARAMIf 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_bufPointer to the data to be written. Must not be null.
[in]block_addressNumber of the first block to write.
[in]block_countNumber of blocks to write. Must be greater than 0.
Return values
NRF_SUCCESSIf block write operation was started succesfully.
NRF_ERROR_INVALID_STATEIf the card is not initialized.
NRF_ERROR_BUSYIf there is already an operation active.
NRF_ERROR_INVALID_PARAMIf invalid parameters were specified.
bool app_sdc_busy_check ( void  )

Function for retrieving the card busy state.

Return values
trueIf there is an operation in progress.
falseIf 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_configPointer to the SDC configuration structure.
[in]event_handlerPointer to the event handler function.
Return values
NRF_SUCCESSIf initialization process was started succesfully.
NRF_ERROR_INVALID_STATEIf the card is already initialized or the initialization is in progress.
NRF_ERROR_INVALID_PARAMIf invalid parameters were specified.
ret_code_t app_sdc_uninit ( void  )

Function for uninitializing the card.

Return values
NRF_SUCCESSIf card was uninitialized succesfully.
NRF_ERROR_INVALID_STATEIf the card is not initialized.
NRF_ERROR_BUSYIf there is an operation in progress.

Documentation feedback | Developer Zone | Subscribe | Updated