Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(SDHC): Fix SDHC Get Capacity and Implement Get Sectors functionality #727

Merged
merged 2 commits into from
Sep 26, 2023

Conversation

karaanil
Copy link
Contributor

Description

unsigned int MXC_SDHC_Lib_GetCapacity(mxc_sdhc_csd_regs_t* csd) function returns wrong value.
If 32 GB card is inserted to the SD card slot, MXC_SDHC_Lib_GetCapacity function can return at most UINT32_MAX as a result.
Therefore, the function prototype is changed to unsigned long long MXC_SDHC_Lib_GetCapacity(mxc_sdhc_csd_regs_t* csd) to get the correct result.

unsigned int MXC_SDHC_Lib_GetSectors(mxc_sdhc_csd_regs_t* csd, int i) function is implemented in sdhc_lib.c file.

Checklist Before Requesting Review

  • PR Title follows correct guidelines.
  • Description of changes and all other relevant information.
  • (Optional) Link any related GitHub issues using a keyword
  • (Optional) Provide info on any relevant functional testing/validation. For API changes or significant features, this is not optional.

@@ -91,10 +91,10 @@ 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing function return value might cause some warnings (or error) on existing application that use this library.
But the addition seems simple can be handle easily incase of any warning arise.

Copy link
Contributor

@Jake-Carter Jake-Carter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some suggested modifications to GetSectors

Libraries/SDHC/Source/sdhc_lib.c Outdated Show resolved Hide resolved
Libraries/SDHC/Source/sdhc_lib.c Outdated Show resolved Hide resolved
@Jake-Carter Jake-Carter merged commit 70e659b into main Sep 26, 2023
@Jake-Carter Jake-Carter deleted the sdhc-capacity-fix branch September 26, 2023 00:09
EricB-ADI pushed a commit that referenced this pull request Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants