| M480 BSP V3.05.001 The Board Support Package for M480 Series

Macros | Functions
SDH Exported Functions
Standard Driver » SDH Driver

## Macros
#define | SDH_ENABLE_INT(sdh, u32IntMask)
| Enable specified interrupt. More...
#define | SDH_DISABLE_INT(sdh, u32IntMask)
| Disable specified interrupt. More...
#define | SDH_GET_INT_FLAG(sdh, u32IntMask)
| Get specified interrupt flag/status. More...
#define | SDH_CLR_INT_FLAG(sdh, u32IntMask)
| Clear specified interrupt flag/status. More...
#define | SDH_IS_CARD_PRESENT(sdh)
| Check SD Card inserted or removed. More...
#define | SDH_GET_CARD_CAPACITY(sdh)
| Get SD Card capacity. More...
#define | SDH_BLOCK_SIZE 512ul

## Functions
void | SDH_Open (SDH_T *sdh, uint32_t u32CardDetSrc)
| This function use to reset SD function and select card detection source and pin. More...
uint32_t | SDH_Probe (SDH_T *sdh)
| This function use to initial SD card. More...
uint32_t | SDH_Read (SDH_T *sdh, uint8_t *pu8BufAddr, uint32_t u32StartSec, uint32_t u32SecCount)
| This function use to read data from SD card. More...
uint32_t | SDH_Write (SDH_T *sdh, uint8_t *pu8BufAddr, uint32_t u32StartSec, uint32_t u32SecCount)
| This function use to write data to SD card. More...
uint32_t | SDH_CardDetection (SDH_T *sdh)
void | SDH_Open_Disk (SDH_T *sdh, uint32_t u32CardDetSrc)
void | SDH_Close_Disk (SDH_T *sdh)

## Detailed Description

HIDDEN_SYMBOLS

## Macro Definition Documentation

## ◆ SDH_BLOCK_SIZE

#define SDH_BLOCK_SIZE 512ul

Definition at line 26 of file sdh.c.

## ◆ SDH_CLR_INT_FLAG

#define SDH_CLR_INT_FLAG | ( |  | sdh,
|  |  | u32IntMask
| ) |  |

Clear specified interrupt flag/status.

Parameters

  [in] | sdh | Select SDH0 or SDH1.
  [in] | u32IntMask | Interrupt type mask: SDH_INTSTS_BLKDIF_Msk / SDH_INTSTS_CRCIF_Msk / SDH_INTSTS_CDIF_Msk / SDH_INTSTS_RTOIF_Msk / SDH_INTSTS_DITOIF_Msk

Returns
  None.

Definition at line 157 of file sdh.h.

## ◆ SDH_DISABLE_INT

#define SDH_DISABLE_INT | ( |  | sdh,
|  |  | u32IntMask
| ) |  |

Disable specified interrupt.

Parameters

  [in] | sdh | Select SDH0 or SDH1.
  [in] | u32IntMask | Interrupt type mask: SDH_INTEN_BLKDIEN_Msk / SDH_INTEN_CRCIEN_Msk / SDH_INTEN_CDIEN_Msk / SDH_INTEN_RTOIEN_Msk / SDH_INTEN_DITOIEN_Msk / SDH_INTEN_WKIEN_Msk / SDH_INTEN_CDSRC_Msk /

Returns
  None.

Definition at line 124 of file sdh.h.

## ◆ SDH_ENABLE_INT

#define SDH_ENABLE_INT | ( |  | sdh,
|  |  | u32IntMask
| ) |  |

Enable specified interrupt.

Parameters

  [in] | sdh | Select SDH0 or SDH1.
  [in] | u32IntMask | Interrupt type mask: SDH_INTEN_BLKDIEN_Msk / SDH_INTEN_CRCIEN_Msk / SDH_INTEN_CDIEN_Msk / SDH_INTEN_CDSRC_Msk SDH_INTEN_RTOIEN_Msk / SDH_INTEN_DITOIEN_Msk / SDH_INTEN_WKIEN_Msk

Returns
  None.

Definition at line 111 of file sdh.h.

## ◆ SDH_GET_CARD_CAPACITY

#define SDH_GET_CARD_CAPACITY | ( |  | sdh | ) |

Get SD Card capacity.

Parameters

  [in] | sdh | Select SDH0 or SDH1.

Returns
  SD Card capacity. (unit: KByte)

Definition at line 179 of file sdh.h.

## ◆ SDH_GET_INT_FLAG

#define SDH_GET_INT_FLAG | ( |  | sdh,
|  |  | u32IntMask
| ) |  |

Get specified interrupt flag/status.

Parameters

  [in] | sdh | Select SDH0 or SDH1.
  [in] | u32IntMask | Interrupt type mask: SDH_INTSTS_BLKDIF_Msk / SDH_INTSTS_CRCIF_Msk / SDH_INTSTS_CRC7_Msk / SDH_INTSTS_CRC16_Msk / SDH_INTSTS_CRCSTS_Msk / SDH_INTSTS_DAT0STS_Msk / SDH_INTSTS_CDIF_Msk SDH_INTSTS_RTOIF_Msk / SDH_INTSTS_DITOIF_Msk / SDH_INTSTS_CDSTS_Msk / SDH_INTSTS_DAT1STS_Msk

Returns
  0 = The specified interrupt is not happened. 1 = The specified interrupt is happened.

Definition at line 142 of file sdh.h.

## ◆ SDH_IS_CARD_PRESENT

#define SDH_IS_CARD_PRESENT | ( |  | sdh | ) |

Check SD Card inserted or removed.

Parameters

  [in] | sdh | Select SDH0 or SDH1.

Returns
  1: Card inserted. 0: Card removed.

Definition at line 169 of file sdh.h.

## Function Documentation

## ◆ SDH_CardDetection()

uint32_t SDH_CardDetection | ( | SDH_T * | sdh | ) |

## ◆ SDH_Close_Disk()

void SDH_Close_Disk | ( | SDH_T * | sdh | ) |

## ◆ SDH_Open()

void SDH_Open | ( | SDH_T * | sdh,
|  | uint32_t | u32CardDetSrc
| ) |  |

This function use to reset SD function and select card detection source and pin.

HIDDEN_SYMBOLS

Parameters

  [in] | sdh | Select SDH0 or SDH1.
  [in] | u32CardDetSrc | Select card detection pin from GPIO or DAT3 pin. ( CardDetect_From_GPIO / CardDetect_From_DAT3)

Returns
  None

Definition at line 886 of file sdh.c.

## ◆ SDH_Open_Disk()

void SDH_Open_Disk | ( | SDH_T * | sdh,
|  | uint32_t | u32CardDetSrc
| ) |  |

## ◆ SDH_Probe()

uint32_t SDH_Probe | ( | SDH_T * | sdh | ) |

This function use to initial SD card.

Parameters

  [in] | sdh | Select SDH0 or SDH1.

Returns
  None

This function is used to initial SD card. SD initial state needs 400KHz clock output, driver will use HIRC for SD initial clock source. And then switch back to the user's setting.

Definition at line 945 of file sdh.c.

## ◆ SDH_Read()

uint32_t SDH_Read | ( | SDH_T * | sdh,
|  | uint8_t * | pu8BufAddr,
|  | uint32_t | u32StartSec,
|  | uint32_t | u32SecCount
| ) |  |

This function use to read data from SD card.

Parameters

  [in] | sdh | Select SDH0 or SDH1.
  [out] | pu8BufAddr | The buffer to receive the data from SD card.
  [in] | u32StartSec | The start read sector address.
  [in] | u32SecCount | The the read sector number of data

Returns
  None

Definition at line 995 of file sdh.c.

## ◆ SDH_Write()

uint32_t SDH_Write | ( | SDH_T * | sdh,
|  | uint8_t * | pu8BufAddr,
|  | uint32_t | u32StartSec,
|  | uint32_t | u32SecCount
| ) |  |

This function use to write data to SD card.

Parameters

  [in] | sdh | Select SDH0 or SDH1.
  [in] | pu8BufAddr | The buffer to send the data to SD card.
  [in] | u32StartSec | The start write sector address.
  [in] | u32SecCount | The the write sector number of data.

Returns
  SDH_SELECT_ERROR : u32SecCount is zero.
  SDH_NO_SD_CARD : SD card be removed.
  SDH_CRC_ERROR : CRC error happen.
  SDH_CRC7_ERROR : CRC7 error happen.
  Successful : Write data to SD card success.

Definition at line 1142 of file sdh.c.