Example #1
0
void rt_sys_init (void) {
#else
void rt_sys_init (FUNCP first_task, U32 prio_stksz, void *stk) {
#endif
    /* Initialize system and start up task declared with "first_task". */
    U32 i;

    DBG_INIT();

    /* Initialize dynamic memory and task TCB pointers to NULL. */
    for (i = 0U; i < os_maxtaskrun; i++) {
        os_active_TCB[i] = NULL;
    }
    rt_init_box (mp_tcb, (U32)mp_tcb_size, sizeof(struct OS_TCB));
    rt_init_box (mp_stk, mp_stk_size, BOX_ALIGN_8 | (U16)(os_stackinfo));
    rt_init_box ((U32 *)m_tmr, (U32)mp_tmr_size, sizeof(struct OS_TMR));

    /* Set up TCB of idle demon */
    os_idle_TCB.task_id    = 255U;
    os_idle_TCB.priv_stack = 0U;
    rt_init_context (&os_idle_TCB, 0U, os_idle_demon);

    /* Set up ready list: initially empty */
    os_rdy.cb_type = HCB;
    os_rdy.p_lnk   = NULL;
    /* Set up delay list: initially empty */
    os_dly.cb_type = HCB;
    os_dly.p_dlnk  = NULL;
    os_dly.p_blnk  = NULL;
    os_dly.delta_time = 0U;

    /* Fix SP and system variables to assume idle task is running */
    /* Transform main program into idle task by assuming idle TCB */
#ifndef __CMSIS_RTOS
    rt_set_PSP (os_idle_TCB.tsk_stack+32U);
#endif
    os_tsk.run = &os_idle_TCB;
    os_tsk.run->state = RUNNING;

    /* Initialize ps queue */
    os_psq->first = 0U;
    os_psq->last  = 0U;
    os_psq->size  = os_fifo_size;

    rt_init_robin ();

#ifndef __CMSIS_RTOS
    /* Initialize SVC and PendSV */
    rt_svc_init ();

    /* Initialize and start system clock timer */
    os_tick_irqn = os_tick_init ();
    if (os_tick_irqn >= 0) {
        OS_X_INIT((U32)os_tick_irqn);
    }

    /* Start up first user task before entering the endless loop */
    rt_tsk_create (first_task, prio_stksz, stk, NULL);
#endif
}
Example #2
0
void rt_sys_start (void) {
  /* Start system */

  /* Intitialize and start system clock timer */
  os_tick_irqn = os_tick_init ();
  if (os_tick_irqn >= 0) {
    OS_X_INIT(os_tick_irqn);
  }
}
Example #3
0
void rt_sys_start (void) {
  /* Start system */

  /* Intitialize and start system clock timer */
  os_tick_irqn = os_tick_init ();
  if (os_tick_irqn >= 0) {
    OS_X_INIT(os_tick_irqn);
  }
  extern void RestoreContext();
  RestoreContext(); // Start the first task
}
Example #4
0
void rt_sys_start (void) {
    /* Start system */

    /* Initialize SVC and PendSV */
    rt_svc_init ();

    /* Initialize and start system clock timer */
    os_tick_irqn = os_tick_init ();
    if (os_tick_irqn >= 0) {
        OS_X_INIT((U32)os_tick_irqn);
    }
}
uint32_t
os_arch_start(void)
{
    struct os_task *t;

    /* Get the highest priority ready to run to set the current task */
    t = os_sched_next_task();
    os_sched_set_current_task(t);

    /* Adjust PSP so it looks like this task just took an exception */
    __set_PSP((uint32_t)t->t_stackptr + offsetof(struct stack_frame, r0));

    /* Intitialize and start system clock timer */
    os_tick_init(OS_TICKS_PER_SEC, OS_TICK_PRIO);

    /* Mark the OS as started, right before we run our first task */
    g_os_started = 1;

    /* Perform context switch */
    os_arch_ctx_sw(t);

    return (uint32_t)(t->t_arg);
}