Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions cores/apollo3/component/core/mcu/apollo3/uhal/uhal_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,22 @@ int32_t uhal_timer_create (TimerID_E timer_id, timer_handler tmr_handler, TimerM
uhal_timer_pdata[timer_id].timer_id = timer_id;
uhal_timer_pdata[timer_id].timer_func = tmr_handler;

if(apollo3_timer_id == NULL)
if(apollo3_timer_id != NULL)
{
apollo3_timer_id = xTimerCreate("TMR",
1,
get_apollo_timer_mode(mode),
NULL,
uhal_timer_handler_dispatcher);
if(pdPASS != xTimerDelete(apollo3_timer_id, OSTIMER_WAIT_FOR_QUEUE))
{
return -UDRV_INTERNAL_ERR;
}
set_apollo_timer_id(timer_id, NULL);
apollo3_timer_id = NULL;
}

apollo3_timer_id = xTimerCreate("TMR",
1,
get_apollo_timer_mode(mode),
NULL,
uhal_timer_handler_dispatcher);

if (apollo3_timer_id != NULL) {
set_apollo_timer_id(timer_id, apollo3_timer_id);
return UDRV_RETURN_OK;
Expand Down Expand Up @@ -332,15 +339,22 @@ int32_t uhal_sys_timer_create (SysTimerID_E timer_id, timer_handler tmr_handler,
uhal_sys_timer_pdata[timer_id].sys_timer_id = timer_id;
uhal_sys_timer_pdata[timer_id].timer_func = tmr_handler;

if(apollo3_timer_id == NULL)
if(apollo3_timer_id != NULL)
{
apollo3_timer_id = xTimerCreate("SYS_TMR",
1,
get_apollo_timer_mode(mode),
NULL,
uhal_sys_timer_handler_dispatcher);
if(pdPASS != xTimerDelete(apollo3_timer_id, OSTIMER_WAIT_FOR_QUEUE))
{
return -UDRV_INTERNAL_ERR;
}
set_sys_apollo_timer_id(timer_id, NULL);
apollo3_timer_id = NULL;
}

apollo3_timer_id = xTimerCreate("SYS_TMR",
1,
get_apollo_timer_mode(mode),
NULL,
uhal_sys_timer_handler_dispatcher);

if (apollo3_timer_id != NULL) {
set_sys_apollo_timer_id(timer_id, apollo3_timer_id);
return UDRV_RETURN_OK;
Expand Down