公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

Tip / 登入 to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
yjcps
Level 1
Level 1
First solution authored First reply posted First question asked

Hi,

我在CYW43438 wice wwd驱动到其他平台,目前在host_platform_sdio_transfer这个函数有个疑问,为什么host_platform_sdio_transfer里面没有传递将要读写寄存器地址呢?比如下面这段代码:

// 读寄存器 SDIOD_CCCR_IOEN
VERIFY_RESULT( wwd_bus_read_register_value ( BUS_FUNCTION, SDIOD_CCCR_IOEN, (uint8_t) 1, &byte_data ) );

wwd_result_t wwd_bus_read_register_value( wwd_bus_function_t function, uint32_t address, uint8_t value_length, /*@out@*/ uint8_t* value )
{
// 对应 address
memset( value, 0, (size_t) value_length );
return wwd_bus_sdio_transfer( BUS_READ, function, address, value_length, value, RESPONSE_NEEDED );
}

 

static wwd_result_t wwd_bus_sdio_transfer( wwd_bus_transfer_direction_t direction, wwd_bus_function_t function, uint32_t address, uint16_t data_size, /*@in@*/ /*@out@*/ uint8_t* data, sdio_response_needed_t response_expected )
{
/* Note: this function had broken retry logic (never retried), which has been removed.
* Failing fast helps problems on the bus get brought to light more quickly
* and preserves the original behavior.
*/

// 对应 address
if ( data_size == (uint16_t) 1 )
{
return wwd_bus_sdio_cmd52( direction, function, address, *data, response_expected, data );
}
else
{
return wwd_bus_sdio_cmd53( direction, function, ( data_size >= (uint16_t) 64 ) ? SDIO_BLOCK_MODE : SDIO_BYTE_MODE, address, data_size, data, response_expected, NULL );
}
}

static wwd_result_t wwd_bus_sdio_cmd52( wwd_bus_transfer_direction_t direction, wwd_bus_function_t function, uint32_t address, uint8_t value, sdio_response_needed_t response_expected, uint8_t* response )
{
uint32_t sdio_response;
wwd_result_t result;
sdio_cmd_argument_t arg;
arg.value = 0;
arg.cmd52.function_number = (unsigned int) ( function & BUS_FUNCTION_MASK );
// 对应 address
arg.cmd52.register_address = (unsigned int) ( address & 0x00001ffff );

arg.cmd52.rw_flag = (unsigned int) ( ( direction == BUS_WRITE ) ? 1 : 0 );
arg.cmd52.write_data = value;
WWD_BUS_STATS_INCREMENT_VARIABLE( cmd52 );

// 对应的 address, arg.cmd52.register_address 或者arg变量,为什么不继续传递将要读取的寄存器地址到host_platform_sdio_transfer函数呢?平台的 host_platform_sdio_transfer怎么知道要读哪个寄存器?
result = host_platform_sdio_transfer( direction, SDIO_CMD_52, SDIO_BYTE_MODE, SDIO_1B_BLOCK, arg.value, 0, 0, response_expected, &sdio_response );
WWD_BUS_STATS_CONDITIONAL_INCREMENT_VARIABLE(( result != WWD_SUCCESS ), cmd52_fail );
if ( response != NULL )
{
*response = (uint8_t) ( sdio_response & 0x00000000ff );
}
return result;
}

 

0 点赞
1 解答
yjcps
Level 1
Level 1
First solution authored First reply posted First question asked

Hi,

sdio_cmd_argument_t 的定义是union,传入arg.value参数ok,谢谢。

typedef union
{
    uint32_t              value;
    sdio_cmd5_argument_t  cmd5;
    sdio_cmd5x_argument_t cmd5x;
    wwd_bus_sdio_cmd52_argument_t cmd52;
    wwd_bus_sdio_cmd53_argument_t cmd53;
sdio_cmd_argument_t;
 

在原帖中查看解决方案

0 点赞
2 回复数
Zhengbao_Zhang
Moderator
Moderator
Moderator
250 sign-ins First comment on KBA 10 questions asked

Hello:

      cmd52只能写入和读取1 byte, 从代码里面看CMD53是被运用更加多的IO command, 可以先porting,后面添加打印看是否有很多数据还是需要CMD52的方式来进行读写。

0 点赞
yjcps
Level 1
Level 1
First solution authored First reply posted First question asked

Hi,

sdio_cmd_argument_t 的定义是union,传入arg.value参数ok,谢谢。

typedef union
{
    uint32_t              value;
    sdio_cmd5_argument_t  cmd5;
    sdio_cmd5x_argument_t cmd5x;
    wwd_bus_sdio_cmd52_argument_t cmd52;
    wwd_bus_sdio_cmd53_argument_t cmd53;
sdio_cmd_argument_t;
 
0 点赞