[bsp/renesas] drv_sci_spi.c add timeout. (#7632)

This commit is contained in:
guo 2023-06-09 06:22:59 +08:00 committed by GitHub
parent 0b6f7743f1
commit 3a7546671a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 21 deletions

View File

@ -106,35 +106,53 @@ SCI_SPIx_CALLBACK(9);
rt_event_recv(event, \
RA_SCI_SPI##n##_EVENT, \
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, \
RT_WAITING_FOREVER, \
rt_tick_from_millisecond(1000), \
&recved);
static rt_err_t ra_wait_complete(rt_event_t event, const char bus_name[RT_NAME_MAX])
{
rt_uint32_t recved = 0x00;
rt_err_t ret = RT_EOK;
switch (bus_name[4])
{
case '0':
return SCI_SPIx_EVENT_RECV(0);
ret = SCI_SPIx_EVENT_RECV(0);
break;
case '1':
return SCI_SPIx_EVENT_RECV(1);
ret = SCI_SPIx_EVENT_RECV(1);
break;
case '2':
return SCI_SPIx_EVENT_RECV(2);
ret = SCI_SPIx_EVENT_RECV(2);
break;
case '3':
return SCI_SPIx_EVENT_RECV(3);
ret = SCI_SPIx_EVENT_RECV(3);
break;
case '4':
return SCI_SPIx_EVENT_RECV(4);
ret = SCI_SPIx_EVENT_RECV(4);
break;
case '5':
return SCI_SPIx_EVENT_RECV(5);
ret = SCI_SPIx_EVENT_RECV(5);
break;
case '6':
return SCI_SPIx_EVENT_RECV(6);
ret = SCI_SPIx_EVENT_RECV(6);
break;
case '7':
return SCI_SPIx_EVENT_RECV(7);
ret = SCI_SPIx_EVENT_RECV(7);
break;
case '8':
return SCI_SPIx_EVENT_RECV(8);
ret = SCI_SPIx_EVENT_RECV(8);
break;
case '9':
return SCI_SPIx_EVENT_RECV(9);
ret = SCI_SPIx_EVENT_RECV(9);
break;
default:
break;
}
if (ret != RT_EOK)
{
LOG_D("%s ra_wait_complete failed!", bus_name);
return ret;
}
return -RT_EINVAL;
}