| NANO100_BSP V3.05.000 The Board Support Package for Nano100BN Series

Functions | Variables
SDCARD Library Exported Functions
NANO100 Library » SDCARD Library | NANO100 Library » SDCARD Library » SDCARD Library Exported Constants » SDCARD Library Exported Structs
Collaboration diagram for SDCARD Library Exported Functions:

## Functions
void | SD_Delay (uint32_t count)
| Delay function. More...
static uint32_t | GenerateCRC (uint32_t u32Data, uint32_t u32GenPoly, uint32_t u32Accum)
| This function is used to generate CRC value. More...
static uint32_t | SingleWrite (uint32_t u32Data)
| This function is used to send data though SPI to general clock for SDCARD operation. More...
uint32_t | MMC_Command_Exec (uint8_t nCmd, uint32_t nArg, uint8_t *pchar, uint32_t *response)
| This function is used to Send SDCARD CMD and Receive Response. More...
void | MMC_FLASH_Init (void)
| This function is used to initialize the flash card. More...
uint32_t | SDCARD_Open (void)
| This function is used to Open GPIO function and initial SDCARD. More...
void | SDCARD_Close (void)
| This function is used to close SDCARD. More...
uint32_t | SDCARD_GetCardSize (uint32_t *pu32TotSecCnt)
| This function is used to get card total sector after SDCARD is opened. More...
uint32_t | GetLogicSector (void)
| This function is used to get logic sector size. More...
void | SpiRead (uint32_t addr, uint32_t size, uint8_t *buffer)
| This function is used to Get data from SD card. More...
void | SpiWrite (uint32_t addr, uint32_t size, uint8_t *buffer)
| This function is used to store data into SD card. More...
uint32_t | SDCARD_GetVersion (void)

## Variables
uint32_t | UINT32::l
uint8_t | UINT32::b [4]
uint16_t | UINT16::i
uint8_t | UINT16::b [2]
uint8_t | COMMAND::command_byte
uint8_t | COMMAND::arg_required
uint8_t | COMMAND::CRC
uint8_t | COMMAND::trans_type
uint8_t | COMMAND::response
uint8_t | COMMAND::var_length

## Detailed Description

## Function Documentation

## ◆ GenerateCRC()

static uint32_t GenerateCRC | ( | uint32_t | u32Data,
|  | uint32_t | u32GenPoly,
|  | uint32_t | u32Accum
| ) |  |
| static

This function is used to generate CRC value.

Parameters

  [in] | u32Data | Input Data
  [in] | u32GenPoly | CRC7:0x1200, CRC16:0x1021
  [in] | u32Accum | CRC value

Returns
  CRC value

Definition at line 101 of file SDCard.c.

Here is the caller graph for this function:

## ◆ GetLogicSector()

uint32_t GetLogicSector | ( | void |  | ) |

This function is used to get logic sector size.

Returns
  The Logic Sector size

Definition at line 640 of file SDCard.c.

## ◆ MMC_Command_Exec()

uint32_t MMC_Command_Exec | ( | uint8_t | nCmd,
|  | uint32_t | nArg,
|  | uint8_t * | pchar,
|  | uint32_t * | response
| ) |  |

This function is used to Send SDCARD CMD and Receive Response.

Parameters

  [in] | nCmd | Set command register
  [in] | nArg | Set command argument
  [out] | *pchar | Get register and data
  [out] | *response | Get response

Return values

  TRUE | get response
  FALSE | 1.SD Card busy, 2.Card moved, 3.Timeout

Definition at line 140 of file SDCard.c.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ MMC_FLASH_Init()

void MMC_FLASH_Init | ( | void |  | ) |

This function is used to initialize the flash card.

Returns
  none

Definition at line 447 of file SDCard.c.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ SD_Delay()

void SD_Delay | ( | uint32_t | count | ) |

Delay function.

Parameters

  [in] | count | loop count.

Returns
  none

Definition at line 74 of file SDCard.c.

Here is the caller graph for this function:

## ◆ SDCARD_Close()

void SDCARD_Close | ( | void |  | ) |

This function is used to close SDCARD.

Returns
  none

Definition at line 615 of file SDCard.c.

Here is the call graph for this function:

## ◆ SDCARD_GetCardSize()

uint32_t SDCARD_GetCardSize | ( | uint32_t * | pu32TotSecCnt | ) |

This function is used to get card total sector after SDCARD is opened.

Parameters

  [out] | *pu32TotSecCnt | Get sector count

Return values

  TRUE | The size is already saved
  FALSE | The size is zero

Definition at line 626 of file SDCard.c.

## ◆ SDCARD_GetVersion()

uint32_t SDCARD_GetVersion | ( | void |  | ) |

## ◆ SDCARD_Open()

uint32_t SDCARD_Open | ( | void |  | ) |

This function is used to Open GPIO function and initial SDCARD.

Return values

  SD_FAIL | Initial SDCARD Failed
  SD_SUCCESS | Success

Definition at line 584 of file SDCard.c.

Here is the call graph for this function:

## ◆ SingleWrite()

static uint32_t SingleWrite | ( | uint32_t | u32Data | ) |
| static

This function is used to send data though SPI to general clock for SDCARD operation.

Parameters

  [in] | u32Data | Data to send

Returns
  none

Definition at line 122 of file SDCard.c.

Here is the caller graph for this function:

## ◆ SpiRead()

void SpiRead | ( | uint32_t | addr,
|  | uint32_t | size,
|  | uint8_t * | buffer
| ) |  |

This function is used to Get data from SD card.

Parameters

  [in] | addr | Set start address for LBA
  [in] | size | Set data size (byte)
  [in] | buffer | Set buffer pointer

Returns
  none

Definition at line 652 of file SDCard.c.

Here is the call graph for this function:

## ◆ SpiWrite()

void SpiWrite | ( | uint32_t | addr,
|  | uint32_t | size,
|  | uint8_t * | buffer
| ) |  |

This function is used to store data into SD card.

Parameters

  [in] | addr | Set start address for LBA
  [in] | size | Set data size (byte)
  [in] | buffer | Set buffer pointer

Returns
  none

Definition at line 687 of file SDCard.c.

Here is the call graph for this function:

## Variable Documentation

## ◆ arg_required

uint8_t COMMAND::arg_required

Indicates argument requirement;

Definition at line 135 of file SDCard.h.

## ◆ b [1/2]

uint8_t UINT16::b[2]

Definition at line 80 of file SDCard.h.

## ◆ b [2/2]

uint8_t UINT32::b[4]

Definition at line 75 of file SDCard.h.

## ◆ command_byte

uint8_t COMMAND::command_byte

OpCode;

Definition at line 134 of file SDCard.h.

## ◆ CRC

uint8_t COMMAND::CRC

Holds CRC for command if necessary;

Definition at line 136 of file SDCard.h.

## ◆ i

uint16_t UINT16::i

Definition at line 79 of file SDCard.h.

## ◆ l

uint32_t UINT32::l

Definition at line 74 of file SDCard.h.

## ◆ response

uint8_t COMMAND::response

Indicates expected response;

Definition at line 138 of file SDCard.h.

## ◆ trans_type

uint8_t COMMAND::trans_type

Indicates command transfer type;

Definition at line 137 of file SDCard.h.

## ◆ var_length

uint8_t COMMAND::var_length

Indicates varialble length transfer;

Definition at line 139 of file SDCard.h.