src/C/sleep.c
uint8_t sleeping(e_task_id      id,
                 uint32_t       ms,
                 sleep_mode_t   mode)
{
    if (id <= ID_APPMAX) {
        sleep_tab[id].sleep_until =
            core_systick_get_ticks() + core_ms_to_ticks (ms);
        if (mode == SLEEP_MODE_INTERRUPTIBLE) {
            sleep_tab[id].interruptible = true;
            task_set_task_state(id, TASK_MODE_MAINTHREAD, TASK_STATE_SLEEPING);
        } else {
            sleep_tab[id].interruptible = false;
            task_set_task_state(id, TASK_MODE_MAINTHREAD, TASK_STATE_SLEEPING_DEEP);
            KERNLOG(DBG_INFO, "task %d: entering deep sleep\n", id);
        }
    } else {
        goto err_id;
    }
err_id:
    return 2;
}
/*
 * \brief declare a time to sleep.
 *
 * This function is called in a syscall context and make the task
 * unschedulable for at least the given sleeptime. Only external events
 * (ISR, IPC) can awake the task during this period. If no external events
 * happend, the task is marked as schedulable at the end of the sleep period,
 * which means that the task is schedule *after* the sleep time, not exactly
 * at the sleep time end.
 * The variation of the time to wait between the end of the sleep time and
 * the effective time execution depends on the scheduling policy, the task
 * priority and the number of tasks on the system.
 *
 * \param id        the task id requesting to sleep
 * \param sleeptime the sleep duration in unit given by unit argument
 * \param unit      the unit of the sleep time, which is one of sleep_unit_t
 */
\brief declare a time to sleep.
This function is called in a syscall context and make the task
unschedulable for at least the given sleeptime. Only external events
(ISR, IPC) can awake the task during this period. If no external events
happend, the task is marked as schedulable at the end of the sleep period,
which means that the task is schedule *after* the sleep time, not exactly
at the sleep time end.
The variation of the time to wait between the end of the sleep time and
the effective time execution depends on the scheduling policy, the task
priority and the number of tasks on the system.

\param id        the task id requesting to sleep
\param sleeptime the sleep duration in unit given by unit argument
\param unit      the unit of the sleep time, which is one of sleep_unit_t
\ brief declare a time to sleep . This function is called in a syscall context and make the task unschedulable for at least the given sleeptime . Only external events ( ISR IPC ) can awake the task during this period . If no external events happend the task is marked as schedulable at the end of the sleep period which means that the task is schedule * after * the sleep time not exactly at the sleep time end . The variation of the time to wait between the end of the sleep time and the effective time execution depends on the scheduling policy the task priority and the number of tasks on the system . \ param id the task id requesting to sleep \ param sleeptime the sleep duration in unit given by unit argument \ param unit the unit of the sleep time which is one of sleep_unit_t
uint8_t sleeping(e_task_id      id,
                 uint32_t       ms,
                 sleep_mode_t   mode)
{
    if (id <= ID_APPMAX) {
        sleep_tab[id].sleep_until =
            core_systick_get_ticks() + core_ms_to_ticks (ms);
        if (mode == SLEEP_MODE_INTERRUPTIBLE) {
            sleep_tab[id].interruptible = true;
            task_set_task_state(id, TASK_MODE_MAINTHREAD, TASK_STATE_SLEEPING);
        } else {
            sleep_tab[id].interruptible = false;
            task_set_task_state(id, TASK_MODE_MAINTHREAD, TASK_STATE_SLEEPING_DEEP);
            KERNLOG(DBG_INFO, "task %d: entering deep sleep\n", id);
        }
    } else {
        goto err_id;
    }
err_id:
    return 2;
}
uint8_t sleeping ( e_task_id id , uint32_t ms , sleep_mode_t mode ) { if ( id <= ID_APPMAX ) { sleep_tab [ id ] . sleep_until = core_systick_get_ticks ( ) + core_ms_to_ticks ( ms ) ; if ( mode == SLEEP_MODE_INTERRUPTIBLE ) { sleep_tab [ id ] . interruptible = true ; task_set_task_state ( id , TASK_MODE_MAINTHREAD , TASK_STATE_SLEEPING ) ; } else { sleep_tab [ id ] . interruptible = false ; task_set_task_state ( id , TASK_MODE_MAINTHREAD , TASK_STATE_SLEEPING_DEEP ) ; KERNLOG ( DBG_INFO , " \n " , id ) ; } } else { goto err_id ; } err_id : return 2 ; }
\brief declare a time to sleep.
\ brief declare a time to sleep .