Skip to content

Commit

Permalink
fix(SDHC): Fix SDHC Get Capacity and Implement Get Sectors functional…
Browse files Browse the repository at this point in the history
…ity (#727)

Co-authored-by: Jake Carter <[email protected]>
  • Loading branch information
karaanil and Jake-Carter authored Sep 26, 2023
1 parent 33fddc4 commit 70e659b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Libraries/SDHC/Include/sdhc_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int MXC_SDHC_Lib_SetRCA(void);
int MXC_SDHC_Lib_GetCSD(mxc_sdhc_csd_regs_t *csd);

/* ************************************************************************** */
unsigned int MXC_SDHC_Lib_GetCapacity(mxc_sdhc_csd_regs_t* csd);
unsigned long long MXC_SDHC_Lib_GetCapacity(mxc_sdhc_csd_regs_t* csd);

/* ************************************************************************** */
unsigned int MXC_SDHC_Lib_GetSectors(mxc_sdhc_csd_regs_t* csd);
Expand Down
10 changes: 8 additions & 2 deletions Libraries/SDHC/Source/sdhc_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,17 @@ int MXC_SDHC_Lib_GetCSD(mxc_sdhc_csd_regs_t *csd)
}

/* ************************************************************************** */
unsigned int MXC_SDHC_Lib_GetCapacity(mxc_sdhc_csd_regs_t* csd)
unsigned long long MXC_SDHC_Lib_GetCapacity(mxc_sdhc_csd_regs_t* csd)
{
unsigned int size = csd->csd.c_size;

return (size*(512*1024));
return ((unsigned long long)(size+1))*((unsigned long long)512*1024);
}

/* ************************************************************************** */
unsigned int MXC_SDHC_Lib_GetSectors(mxc_sdhc_csd_regs_t* csd)
{
return csd->csd.c_size;
}

/* ************************************************************************** */
Expand Down

0 comments on commit 70e659b

Please sign in to comment.