Skip to content

Commit c73fda4

Browse files
committed
Fix timeout for Freertos semaphore.
It doesn't make sense to have portMaxDelay and then recalculate to lower value. Currently other ports are using simple implementation so i align with that. Signed-off-by: Cervenka Dusan <[email protected]>
1 parent 5069181 commit c73fda4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

erpc_c/port/erpc_setup_extensions_freertos.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void erpc::erpc_pre_cb_default(void)
2828
(void)s_erpc_call_in_progress->get(s_erpc_call_in_progress->kWaitForever);
2929
erpc_assert(s_erpc_call_timer_cb &&
3030
"If you want use default pre cb action, do not forget call erpc_init_call_progress_detection_default.");
31-
xTimerStart(s_erpc_call_timer_cb, 0);
31+
(void)xTimerStart(s_erpc_call_timer_cb, 0);
3232
}
3333

3434
void erpc::erpc_post_cb_default(void)

erpc_c/port/erpc_threading_freertos.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,17 @@ bool Semaphore::get(uint32_t timeout)
271271
{
272272
timeout = portMAX_DELAY;
273273
}
274+
else if (timeout > (portMAX_DELAY - 1))
275+
{
276+
timeout = portMAX_DELAY - 1;
277+
}
274278
else
275279
{
276-
if (timeout > (portMAX_DELAY - 1))
277-
{
278-
timeout = portMAX_DELAY - 1;
279-
}
280+
/* Misra condition */
280281
}
281282
#endif
282283

283-
return (pdTRUE == xSemaphoreTake(m_sem, timeout / 1000U / portTICK_PERIOD_MS));
284+
return (pdTRUE == xSemaphoreTake(m_sem, timeout));
284285
}
285286

286287
int Semaphore::getCount(void) const

0 commit comments

Comments
 (0)