-
Notifications
You must be signed in to change notification settings - Fork 74
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
feat(MiscDrivers): Add API for Setting SDHC Data Width #1045
Changes from 4 commits
d2ffaef
c3b9246
d3f8669
07cd904
c6eb053
ab26130
c478504
46bb196
e869ea5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,7 @@ int card_rca; | |
mxc_sdhc_lib_card_type card_type = CARD_NONE; | ||
mxc_sdhc_csd_regs_t g_csd; | ||
bool g_csd_is_cached = false; | ||
static mxc_sdhc_data_width default_data_width = MXC_SDHC_LIB_SINGLE_DATA; | ||
|
||
/* **** Functions **** */ | ||
|
||
|
@@ -236,6 +237,8 @@ int MXC_SDHC_Lib_SetBusWidth(mxc_sdhc_data_width bus_width) | |
uint32_t card_status; | ||
int result; | ||
|
||
bus_width = bus_width == MXC_SDHC_LIB_DEFAULT_DATA ? MXC_SDHC_Get_Default_DataWidth() : bus_width; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it might be cleaner to come in "over the top" and avoid adding the extra enum value. A direct getter/setter to the state variable would work, so your call from MXC_SDHC_Lib_Write(sector, (void *)buff, count, MXC_SDHC_Get_DataWidth()) Usually you're not gonna change your data width more than once at run-time, so a mechanism for setting the default value might be better implemented as a build-time option. Users can use the setter API you've exposed on initialization. This would let us avoid these modifications to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is what is set as in |
||
|
||
cmd_cfg.direction = MXC_SDHC_DIRECTION_CFG; | ||
cmd_cfg.callback = NULL; | ||
|
||
|
@@ -445,6 +448,9 @@ int MXC_SDHC_Lib_Prepare_Trans(mxc_sdhc_data_width width) | |
mxc_sdhc_cmd_cfg_t cmd_cfg; | ||
int result; | ||
|
||
width = width == MXC_SDHC_LIB_DEFAULT_DATA ? MXC_SDHC_Get_Default_DataWidth() : width; | ||
|
||
|
||
cmd_cfg.direction = MXC_SDHC_DIRECTION_CFG; | ||
cmd_cfg.arg_1 = 0; | ||
cmd_cfg.host_control_1 = MXC_SDHC_Get_Host_Cn_1(); | ||
|
@@ -499,6 +505,8 @@ int MXC_SDHC_Lib_Write(unsigned int dst_addr, void *src_addr, unsigned int cnt, | |
int result; | ||
mxc_sdhc_cmd_cfg_t cmd_cfg; | ||
|
||
width = width == MXC_SDHC_LIB_DEFAULT_DATA ? MXC_SDHC_Get_Default_DataWidth() : width; | ||
|
||
result = MXC_SDHC_Lib_Prepare_Trans(width); | ||
if (result != E_NO_ERROR) { | ||
return result; | ||
|
@@ -527,6 +535,9 @@ int MXC_SDHC_Lib_Read(void *dst_addr, unsigned int src_addr, unsigned int cnt, m | |
int result; | ||
mxc_sdhc_cmd_cfg_t cmd_cfg; | ||
|
||
width = width == MXC_SDHC_LIB_DEFAULT_DATA ? MXC_SDHC_Get_Default_DataWidth() : width; | ||
|
||
|
||
result = MXC_SDHC_Lib_Prepare_Trans(width); | ||
if (result != E_NO_ERROR) { | ||
return result; | ||
|
@@ -555,6 +566,8 @@ int MXC_SDHC_Lib_WriteAsync(unsigned int dst_addr, void *src_addr, unsigned int | |
int data; | ||
mxc_sdhc_cmd_cfg_t cmd_cfg; | ||
|
||
width = width == MXC_SDHC_LIB_DEFAULT_DATA ? MXC_SDHC_Get_Default_DataWidth() : width; | ||
|
||
data = MXC_SDHC_Lib_Prepare_Trans(width); | ||
if (data == E_BUSY) { | ||
return E_BUSY; | ||
|
@@ -586,6 +599,8 @@ int MXC_SDHC_Lib_ReadAsync(void *dst_addr, unsigned int src_addr, unsigned int c | |
int data; | ||
mxc_sdhc_cmd_cfg_t cmd_cfg; | ||
|
||
width = width == MXC_SDHC_LIB_DEFAULT_DATA ? MXC_SDHC_Get_Default_DataWidth() : width; | ||
|
||
data = MXC_SDHC_Lib_Prepare_Trans(width); | ||
if (data == E_BUSY) { | ||
return E_BUSY; | ||
|
@@ -610,4 +625,15 @@ int MXC_SDHC_Lib_ReadAsync(void *dst_addr, unsigned int src_addr, unsigned int c | |
|
||
return MXC_SDHC_SendCommandAsync(&cmd_cfg); | ||
} | ||
void MXC_SDHC_Set_Default_DataWidth(mxc_sdhc_data_width width) | ||
{ | ||
MXC_ASSERT(width == MXC_SDHC_LIB_SINGLE_DATA || width == MXC_SDHC_LIB_QUAD_DATA); | ||
default_data_width = width; | ||
} | ||
|
||
mxc_sdhc_data_width MXC_SDHC_Get_Default_DataWidth(void) | ||
{ | ||
return default_data_width; | ||
} | ||
|
||
/**@} end of group sdhc */ |
This file was deleted.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or this |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't delete this