Skip to content

Commit

Permalink
feat(MiscDrivers): Add API for Setting SDHC Data Width (#1045)
Browse files Browse the repository at this point in the history
Signed-off-by: Sadik Ozer <[email protected]>
Co-authored-by: Sadik Ozer <[email protected]>
Co-authored-by: Jake Carter <[email protected]>
  • Loading branch information
3 people committed Jun 25, 2024
1 parent a8938a5 commit e6474de
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/BLE_Examples_Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ on:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
push:


env:
LOCK_MAX32655_B2: false
Expand Down
24 changes: 24 additions & 0 deletions Libraries/CMSIS/Device/Maxim/GCC/mxc_version.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
###############################################################################
#
# Copyright (C) 2024 Analog Devices, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
# Autogenerated version info for build system.
MSDK_VERSION_STRING := v2023_10-172-gd3f8669fd6
MSDK_VERSION_YEAR := 2023
MSDK_VERSION_MONTH := 10

# Add root MAXIM_PATH to IPATH so compiler can locate msdk_version.h
IPATH += $(MAXIM_PATH)
5 changes: 4 additions & 1 deletion Libraries/SDHC/Include/sdhc_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ int MXC_SDHC_Lib_WriteAsync(unsigned int dst_addr, void *src_addr, unsigned int

/* ************************************************************************** */
int MXC_SDHC_Lib_ReadAsync(void *dst_addr, unsigned int src_addr, unsigned int cnt, mxc_sdhc_data_width width, mxc_sdhc_callback_fn callback);

/* ************************************************************************** */
void MXC_SDHC_Set_Default_DataWidth(mxc_sdhc_data_width width);
/* ************************************************************************** */
mxc_sdhc_data_width MXC_SDHC_Get_Default_DataWidth(void);

/**@} end of group sdhc */

Expand Down
25 changes: 25 additions & 0 deletions Libraries/SDHC/Source/sdhc_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 **** */

Expand Down Expand Up @@ -236,6 +237,8 @@ int MXC_SDHC_Lib_SetBusWidth(mxc_sdhc_data_width bus_width)
uint32_t card_status;
int result;



cmd_cfg.direction = MXC_SDHC_DIRECTION_CFG;
cmd_cfg.callback = NULL;

Expand Down Expand Up @@ -445,6 +448,9 @@ int MXC_SDHC_Lib_Prepare_Trans(mxc_sdhc_data_width width)
mxc_sdhc_cmd_cfg_t cmd_cfg;
int result;




cmd_cfg.direction = MXC_SDHC_DIRECTION_CFG;
cmd_cfg.arg_1 = 0;
cmd_cfg.host_control_1 = MXC_SDHC_Get_Host_Cn_1();
Expand Down Expand Up @@ -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;



result = MXC_SDHC_Lib_Prepare_Trans(width);
if (result != E_NO_ERROR) {
return result;
Expand Down Expand Up @@ -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;




result = MXC_SDHC_Lib_Prepare_Trans(width);
if (result != E_NO_ERROR) {
return result;
Expand Down Expand Up @@ -555,6 +566,7 @@ int MXC_SDHC_Lib_WriteAsync(unsigned int dst_addr, void *src_addr, unsigned int
int data;
mxc_sdhc_cmd_cfg_t cmd_cfg;


data = MXC_SDHC_Lib_Prepare_Trans(width);
if (data == E_BUSY) {
return E_BUSY;
Expand Down Expand Up @@ -586,6 +598,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;



data = MXC_SDHC_Lib_Prepare_Trans(width);
if (data == E_BUSY) {
return E_BUSY;
Expand All @@ -610,4 +624,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 */
4 changes: 2 additions & 2 deletions Libraries/SDHC/ff13/Source/diskio.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ DRESULT disk_read (
switch(pdrv){
case DEV_SD:

if (MXC_SDHC_Lib_Read(buff, sector, count, MXC_SDHC_LIB_SINGLE_DATA) != E_NO_ERROR) {
if (MXC_SDHC_Lib_Read(buff, sector, count, MXC_SDHC_Get_Default_DataWidth()) != E_NO_ERROR) {
status = RES_ERROR;
} else {
status = RES_OK;
Expand Down Expand Up @@ -196,7 +196,7 @@ DRESULT disk_write (
switch(pdrv){
case DEV_SD:

if (MXC_SDHC_Lib_Write(sector, (void *)buff, count, MXC_SDHC_LIB_SINGLE_DATA) != E_NO_ERROR) {
if (MXC_SDHC_Lib_Write(sector, (void *)buff, count, MXC_SDHC_Get_Default_DataWidth()) != E_NO_ERROR) {
status = RES_ERROR;
} else {
status = RES_OK;
Expand Down
4 changes: 2 additions & 2 deletions Libraries/SDHC/ff14/Source/diskio.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ DRESULT disk_read (
{
DRESULT status;

if (MXC_SDHC_Lib_Read(buff, sector, count, MXC_SDHC_LIB_SINGLE_DATA) != E_NO_ERROR) {
if (MXC_SDHC_Lib_Read(buff, sector, count, MXC_SDHC_Get_Default_DataWidth()) != E_NO_ERROR) {
status = RES_ERROR;
} else {
status = RES_OK;
Expand All @@ -135,7 +135,7 @@ DRESULT disk_write (
{
DRESULT status;

if (MXC_SDHC_Lib_Write(sector, (void *)buff, count, MXC_SDHC_LIB_SINGLE_DATA) != E_NO_ERROR) {
if (MXC_SDHC_Lib_Write(sector, (void *)buff, count, MXC_SDHC_Get_Default_DataWidth()) != E_NO_ERROR) {
status = RES_ERROR;
} else {
status = RES_OK;
Expand Down
4 changes: 2 additions & 2 deletions Libraries/SDHC/ff15/source/diskio.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ DRESULT disk_read (
switch(pdrv){
case DEV_SD:

if (MXC_SDHC_Lib_Read(buff, sector, count, MXC_SDHC_LIB_SINGLE_DATA) != E_NO_ERROR) {
if (MXC_SDHC_Lib_Read(buff, sector, count, MXC_SDHC_Get_Default_DataWidth()) != E_NO_ERROR) {
status = RES_ERROR;
} else {
status = RES_OK;
Expand Down Expand Up @@ -196,7 +196,7 @@ DRESULT disk_write (
switch(pdrv){
case DEV_SD:

if (MXC_SDHC_Lib_Write(sector, (void *)buff, count, MXC_SDHC_LIB_SINGLE_DATA) != E_NO_ERROR) {
if (MXC_SDHC_Lib_Write(sector, (void *)buff, count, MXC_SDHC_Get_Default_DataWidth()) != E_NO_ERROR) {
status = RES_ERROR;
} else {
status = RES_OK;
Expand Down

0 comments on commit e6474de

Please sign in to comment.