/* Change the period of a timer. 
If OS_TimerChangePeriod() is used to change the period of a timer that is not already running, then the timer will use the new period value to calculate an expiry time, and the timer will start running. */
OS_Status OS_TimerChangePeriod(OS_Timer_t *timer, OS_Time_t periodMS)
/* Change the period of a timer. 
If OS_TimerChangePeriod() is used to change the period of a timer that is not already running, then the timer will use the new period value to calculate an expiry time, and the timer will start running. */
OS_Status OS_TimerChangePeriod(OS_Timer_t *timer, OS_Time_t periodMS)
{
    rt_err_t ret;
    OS_DBG("%s(), handle %p\n", __func__, timer->handle);
    OS_HANDLE_ASSERT(OS_TimerIsValid(timer), timer->handle);
    if (OS_TimerIsActive(timer)) {
        ret = rt_timer_stop(timer->handle);
        if (ret != RT_EOK) {
            OS_ERR("err %"OS_BASETYPE_F"\n", ret);
            return OS_FAIL;
        }
    }
    ret = rt_timer_control(timer->handle, RT_TIMER_CTRL_SET_TIME, &periodMS);
    if (ret != RT_EOK) {
        OS_ERR("err %"OS_BASETYPE_F"\n", ret);
        return OS_FAIL;
    }
    ret = rt_timer_start(timer->handle);
    if (ret != RT_EOK) {
        OS_ERR("err %"OS_BASETYPE_F"\n", ret);
        return OS_FAIL;
    }
    return OS_OK;
}