M480 BSP V3.05.006
The Board Support Package for M480 Series
Macros | Functions | Variables

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...
 
int32_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...
 
int32_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...
 
int32_t SDH_CardDetection (SDH_T *sdh)
 
int32_t SDH_Open_Disk (SDH_T *sdh, uint32_t u32CardDetSrc)
 
void SDH_Close_Disk (SDH_T *sdh)
 

Variables

unsigned char SDH_info_t::IsCardInsert
 
unsigned char SDH_info_t::R3Flag
 
unsigned char SDH_info_t::R7Flag
 
unsigned char volatile SDH_info_t::DataReadyFlag
 
unsigned int SDH_info_t::CardType
 
unsigned int SDH_info_t::RCA
 
unsigned int SDH_info_t::totalSectorN
 
unsigned int SDH_info_t::diskSize
 
int SDH_info_t::sectorSize
 
unsigned char * SDH_info_t::dmabuf
 
int32_t SDH_info_t::i32ErrCode
 

Detailed Description

HIDDEN_SYMBOLS

Macro Definition Documentation

◆ SDH_BLOCK_SIZE

#define SDH_BLOCK_SIZE   512ul

Definition at line 25 of file sdh.c.

◆ SDH_CLR_INT_FLAG

#define SDH_CLR_INT_FLAG (   sdh,
  u32IntMask 
)

Clear specified interrupt flag/status.

Parameters
[in]sdhSelect SDH0 or SDH1.
[in]u32IntMaskInterrupt 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 165 of file sdh.h.

◆ SDH_DISABLE_INT

#define SDH_DISABLE_INT (   sdh,
  u32IntMask 
)

Disable specified interrupt.

Parameters
[in]sdhSelect SDH0 or SDH1.
[in]u32IntMaskInterrupt 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 132 of file sdh.h.

◆ SDH_ENABLE_INT

#define SDH_ENABLE_INT (   sdh,
  u32IntMask 
)

Enable specified interrupt.

Parameters
[in]sdhSelect SDH0 or SDH1.
[in]u32IntMaskInterrupt 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 119 of file sdh.h.

◆ SDH_GET_CARD_CAPACITY

#define SDH_GET_CARD_CAPACITY (   sdh)

Get SD Card capacity.

Parameters
[in]sdhSelect SDH0 or SDH1.
Returns
SD Card capacity. (unit: KByte)

Definition at line 187 of file sdh.h.

◆ SDH_GET_INT_FLAG

#define SDH_GET_INT_FLAG (   sdh,
  u32IntMask 
)

Get specified interrupt flag/status.

Parameters
[in]sdhSelect SDH0 or SDH1.
[in]u32IntMaskInterrupt 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 150 of file sdh.h.

◆ SDH_IS_CARD_PRESENT

#define SDH_IS_CARD_PRESENT (   sdh)

Check SD Card inserted or removed.

Parameters
[in]sdhSelect SDH0 or SDH1.
Returns
1: Card inserted. 0: Card removed.

Definition at line 177 of file sdh.h.

Function Documentation

◆ SDH_CardDetection()

int32_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]sdhSelect SDH0 or SDH1.
[in]u32CardDetSrcSelect card detection pin from GPIO or DAT3 pin. ( CardDetect_From_GPIO / CardDetect_From_DAT3)
Returns
None

Definition at line 1106 of file sdh.c.

◆ SDH_Open_Disk()

int32_t 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]sdhSelect 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 1216 of file sdh.c.

◆ SDH_Read()

int32_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]sdhSelect SDH0 or SDH1.
[out]pu8BufAddrThe buffer to receive the data from SD card.
[in]u32StartSecThe start read sector address.
[in]u32SecCountThe the read sector number of data
Returns
None

Definition at line 1266 of file sdh.c.

◆ SDH_Write()

int32_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]sdhSelect SDH0 or SDH1.
[in]pu8BufAddrThe buffer to send the data to SD card.
[in]u32StartSecThe start write sector address.
[in]u32SecCountThe 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 1446 of file sdh.c.

Variable Documentation

◆ CardType

unsigned int SDH_info_t::CardType

SDHC, SD, or MMC

Definition at line 87 of file sdh.h.

◆ DataReadyFlag

unsigned char volatile SDH_info_t::DataReadyFlag

Definition at line 86 of file sdh.h.

◆ diskSize

unsigned int SDH_info_t::diskSize

Disk size in K bytes

Definition at line 90 of file sdh.h.

◆ dmabuf

unsigned char* SDH_info_t::dmabuf

Definition at line 92 of file sdh.h.

◆ i32ErrCode

int32_t SDH_info_t::i32ErrCode

SDH global error code

Definition at line 93 of file sdh.h.

◆ IsCardInsert

unsigned char SDH_info_t::IsCardInsert

Card insert state

Definition at line 83 of file sdh.h.

◆ R3Flag

unsigned char SDH_info_t::R3Flag

Definition at line 84 of file sdh.h.

◆ R7Flag

unsigned char SDH_info_t::R7Flag

Definition at line 85 of file sdh.h.

◆ RCA

unsigned int SDH_info_t::RCA

Relative card address

Definition at line 88 of file sdh.h.

◆ sectorSize

int SDH_info_t::sectorSize

Sector size in bytes

Definition at line 91 of file sdh.h.

◆ totalSectorN

unsigned int SDH_info_t::totalSectorN

Total sector number

Definition at line 89 of file sdh.h.