Skip to content

Commit 3a75466

Browse files
authored
[bsp/renesas] drv_sci_spi.c add timeout. (#7632)
1 parent 0b6f774 commit 3a75466

File tree

1 file changed

+39
-21
lines changed

1 file changed

+39
-21
lines changed

bsp/renesas/libraries/HAL_Drivers/drv_sci_spi.c

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,35 +106,53 @@ SCI_SPIx_CALLBACK(9);
106106
rt_event_recv(event, \
107107
RA_SCI_SPI##n##_EVENT, \
108108
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, \
109-
RT_WAITING_FOREVER, \
109+
rt_tick_from_millisecond(1000), \
110110
&recved);
111111

112112
static rt_err_t ra_wait_complete(rt_event_t event, const char bus_name[RT_NAME_MAX])
113113
{
114114
rt_uint32_t recved = 0x00;
115+
rt_err_t ret = RT_EOK;
115116

116117
switch (bus_name[4])
117118
{
118-
case '0':
119-
return SCI_SPIx_EVENT_RECV(0);
120-
case '1':
121-
return SCI_SPIx_EVENT_RECV(1);
122-
case '2':
123-
return SCI_SPIx_EVENT_RECV(2);
124-
case '3':
125-
return SCI_SPIx_EVENT_RECV(3);
126-
case '4':
127-
return SCI_SPIx_EVENT_RECV(4);
128-
case '5':
129-
return SCI_SPIx_EVENT_RECV(5);
130-
case '6':
131-
return SCI_SPIx_EVENT_RECV(6);
132-
case '7':
133-
return SCI_SPIx_EVENT_RECV(7);
134-
case '8':
135-
return SCI_SPIx_EVENT_RECV(8);
136-
case '9':
137-
return SCI_SPIx_EVENT_RECV(9);
119+
case '0':
120+
ret = SCI_SPIx_EVENT_RECV(0);
121+
break;
122+
case '1':
123+
ret = SCI_SPIx_EVENT_RECV(1);
124+
break;
125+
case '2':
126+
ret = SCI_SPIx_EVENT_RECV(2);
127+
break;
128+
case '3':
129+
ret = SCI_SPIx_EVENT_RECV(3);
130+
break;
131+
case '4':
132+
ret = SCI_SPIx_EVENT_RECV(4);
133+
break;
134+
case '5':
135+
ret = SCI_SPIx_EVENT_RECV(5);
136+
break;
137+
case '6':
138+
ret = SCI_SPIx_EVENT_RECV(6);
139+
break;
140+
case '7':
141+
ret = SCI_SPIx_EVENT_RECV(7);
142+
break;
143+
case '8':
144+
ret = SCI_SPIx_EVENT_RECV(8);
145+
break;
146+
case '9':
147+
ret = SCI_SPIx_EVENT_RECV(9);
148+
break;
149+
default:
150+
break;
151+
}
152+
if (ret != RT_EOK)
153+
{
154+
LOG_D("%s ra_wait_complete failed!", bus_name);
155+
return ret;
138156
}
139157
return -RT_EINVAL;
140158
}

0 commit comments

Comments
 (0)