Ejemplo n.º 1
0
Archivo: main.c Proyecto: brtos/demos
int main(void)
{
    // Initialize BRTOS
    BRTOS_Init();
    ////////////////////////////////////////////////////////

    // Cria um gerenciador de eventos p/ dados acelerômetro
    if (OSMboxCreate(&Data, NULL) != ALLOC_EVENT_OK)
    {
        // Oh Oh
        // Não deveria entrar aqui !!!
        while(1) {};
    };

    if(InstallTask(&System_Time,"System Time",384,31,NULL,NULL) != OK)
    {
        // Oh Oh
        // N�o deveria entrar aqui !!!
        while(1) {};
    };

    if(InstallTask(&Test_Task_1,"Tarefa de Teste 1",384,13,NULL,NULL) != OK)
    {
        // Oh Oh
        // N�o deveria entrar aqui !!!
        while(1) {};
    };

    if(InstallTask(&Test_Task_2,"Tarefa de Teste 2",384,14,NULL,NULL) != OK)
    {
        // Oh Oh
        // N�o deveria entrar aqui !!!
        while(1) {};
    };

    if(InstallTask(&SerialTask,"Tarefa Serial",512,10,NULL,NULL) != OK)
    {
        // Oh Oh
        // N�o deveria entrar aqui !!!
        while(1) {};
    };

    // Start Task Scheduler
    if(BRTOSStart() != OK)
    {
        // Oh Oh
        // N�o deveria entrar aqui !!!
        for(;;) {};
    };

    // Infinite loop
    while (1)
    {
    }
    // Infinite loop, never return.
}
Ejemplo n.º 2
0
/**
  \fn void BRTOS_TimerInit(INT16U timertask_stacksize) 
  \brief public function to start Timer Service 
  must be called before any call to the other public functions.
  It only installs "BRTOS_TimerTask".
  \param timertask_stacksize size of stack allocated to the task
  \return nothing if sucess or never if any error  
*/
void OSTimerInit(INT16U timertask_stacksize, INT8U prio){

  BRTOS_TimerTaskInit();
   
   
#if (TASK_WITH_PARAMETERS == 1)
  if (InstallTask(&BRTOS_TimerTask, "BRTOS Timers Task", timertask_stacksize, prio, NULL, NULL) != OK)
#else
  if (InstallTask(&BRTOS_TimerTask, "BRTOS Timers Task", timertask_stacksize, prio, NULL) != OK)
#endif
  {
	  while (1){};
  }
  
}
Ejemplo n.º 3
0
INT8U BRTOSStart(void)
{
 #if (TASK_WITH_PARAMETERS == 1)
  if (InstallTask(&Idle, "Idle Task", IDLE_STACK_SIZE, 0, (void*)NULL, NULL) != OK)
 #else
  if (InstallTask(&Idle, "Idle Task", IDLE_STACK_SIZE, 0, NULL) != OK)
 #endif
  {
    return NO_MEMORY;
  };

  currentTask = OSSchedule();
  SPvalue = ContextTask[currentTask].StackPoint;
  BTOSStartFirstTask();
  return OK;
}
Ejemplo n.º 4
0
Archivo: BRTOS.c Proyecto: brtos/brtos
uint8_t BRTOSStart(void)
{
 #if (TASK_WITH_PARAMETERS == 1)
  if (InstallTask(&Idle, "Idle Task", IDLE_STACK_SIZE, 0, (void*)NULL, NULL) != OK)
 #else
  if (InstallTask(&Idle, "Idle Task", IDLE_STACK_SIZE, 0, NULL) != OK)
 #endif
  {
    return NO_MEMORY;
  };

#if (COMPUTES_TASK_LOAD == 1)
  OSConfigureTimerForRuntimeStats();
#endif

  currentTask = OSSchedule();
  SPvalue = ContextTask[currentTask].StackPoint;
  BTOSStartFirstTask();
  return OK;
}
Ejemplo n.º 5
0
Archivo: main.c Proyecto: lshihab/brtos
int main(void)
{
  // Init your system clock here

  // Initialize BRTOS
  BRTOS_Init();

  if(InstallTask(&exec,"Teste 1",384,3,&th1) != OK)
  {
    // Oh Oh
    // Não deveria entrar aqui !!!
    while(1){};
  };


  if(InstallTask(&exec2,"Teste 2",384,5,&th2) != OK)
  {
    // Oh Oh
    // Não deveria entrar aqui !!!
    while(1){};
  };

  if(InstallTask(&exec3,"Teste 3",384,10,&th3) != OK)
  {
    // Oh Oh
    // Não deveria entrar aqui !!!
    while(1){};
  };


  // Start Task Scheduler
  if(BRTOSStart() != OK)
  {
    // Oh Oh
    // Não deveria entrar aqui !!!
    for(;;){};
  };

  return 0;
}
Ejemplo n.º 6
0
void main(void) 
{

  #if(BOOTLOADER_ENABLE == 1)
    ISR_vtable_reallocation();
  #endif  

  MCU_init(); /* MCU Initialization */   
  
  // Initialize BRTOS
  BRTOS_Init();  
  
  /* Peripheral inicialization */
#if (DEBUG == 1) 

  /* flash clock for reprogramming */ 
  Flash_Clock_Init();     
  
  /* Initialize A/D Converter and bandgap reference */
  ADC_Setup(HighSpeed, ShortSampleTime, 12);
  if(ADC_Bandgap_Set() != BANDGAP_OK){
    while(1){}
  }
 
#endif    
  
  
  #if(DEBUG == 1)    
  #if(NETWORK_ENABLE == 1)     
  
  GPSNET_Init();     
  
  if(InstallTask(&GPSNET_RxApp,"GPSNET RX task",320,APP3_Priority) != OK)
  {
    while(1){};
  }
  /*
  if(InstallTask(&GPSNET_TxApp,"GPSNET TX task",1280,APP2_Priority) != OK)
  {
    while(1){};
  }
  */
  
  if(InstallTask(&GPSNET_SensorApp,"GPSNET Sensor task",1280,APP1_Priority) != OK)
  {
    while(1){};
  }
    

  #endif   
  #endif
  
     
  if(InstallTask(&System_Time,"System Time",320,System_Time_Priority) != OK)
  {
    while(1){};
  };
  
  if(InstallTask(&Comm2PC_Task,"Comm2PC task",448,Comm2PC_Task_Priority) != OK)
  {
    while(1){};
  };    
  
  
  if(InstallTask(&HeartBeat_LED_Task,"HeartBeat LED task",320,HeartBeat_LED_Priority) != OK)
  {
    while(1){};
  };
    

  // Start Task Scheduler
  if(BRTOSStart() != OK)
  {
    while(1){};
  };  



  for(;;) {
    /* __RESET_WATCHDOG(); by default, COP is disabled with device init. When enabling, also reset the watchdog. */
  } /* loop forever */
  /* please make sure that you never leave main */
}
Ejemplo n.º 7
0
/*
 * Starts a new thread with priority "prio" that will begin its execution in the
 * function "thread()". The "arg" argument will be passed as an argument to the
 * thread() function. The argument "ssize" is the requested stack size for the
 * new thread. The id of the new thread is returned. Both the id and the
 * priority are system dependent.
 */
sys_thread_t
sys_thread_new(char *name, void ( *thread ) ( void *arg ), void *arg, int stacksize, int prio )
{
    sys_thread_t    thread_hdl = SYS_THREAD_NULL;
    int             i,j;
    sys_tcb_t      *p;

    /* We disable the FreeRTOS scheduler because it might be the case that the new
     * tasks gets scheduled inside the xTaskCreate function. To prevent this we
     * disable the scheduling. Note that this can happen although we have interrupts
     * disabled because xTaskCreate contains a call to taskYIELD( ).
     */
    UserEnterCritical( );

    p = tasks;
    i = 0;
    /* We are called the first time. Initialize it. */
    if( p == NULL )
    {
        p = (sys_tcb_t *)BRTOS_ALLOC( sizeof( sys_tcb_t ) );
        if( p != NULL )
        {
            tasks = p;
        }
    }
    else
    {
        /* First task already counter. */
        i++;
        /* Cycle to the end of the list. */
        while( p->next != NULL )
        {
            i++;
            p = p->next;
        }
        p->next = (sys_tcb_t *)BRTOS_ALLOC( sizeof( sys_tcb_t ) );
        p = p->next;
    }

    if( p != NULL )
    {
        /* Memory allocated. Initialize the data structure. */
        THREAD_INIT( p );

        /* Now q points to a free element in the list. */
        //if( xTaskCreate( thread, (const signed char *)name, stacksize, arg, prio, &p->pid ) == pdPASS )        
        if (InstallTask(thread, name, stacksize, prio, arg) == OK)
        {
        	for(j = 1;j<NUMBER_OF_TASKS;j++)
        	{
        		if (ContextTask[j].Priority == prio)
        		{
        			p->pid = &ContextTask[j];
            		thread_hdl = p->pid;
        		}
        	}
        }
        else
        {
        	BRTOS_DEALLOC( p );
        }
    }

    UserExitCritical( );
    return thread_hdl;
}
Ejemplo n.º 8
0
/* Function to start all GPSNET Tasks */   
void GPSNET_Init(void)
{  
  ////////////////////////////////////////////////////
  //     Initialize IEEE 802.15.4 radio mutex     ////
  ////////////////////////////////////////////////////  
  init_radio_resource(GPSNET_Mutex_Priority);
  
  
  ////////////////////////////////////////////////
  //     Initialize OS Network Services     //////
  ////////////////////////////////////////////////  
  if ((INT8U)OSQueueCreate(&RFBuffer,RFBufferSize,&RF) != ALLOC_EVENT_OK)
  {
    while(1){};              
  }

  /* GPSNET signals */
  if ((INT8U)OSSemCreate(0,&RF_RX_Event) != ALLOC_EVENT_OK)
  {
    while(1){};
  }
  
  if ((INT8U)OSSemCreate(0,&RF_TX_Event) != ALLOC_EVENT_OK)
  {
    while(1){};
  }  
  
  if ((INT8U)OSSemCreate(0,&MAC_Event) != ALLOC_EVENT_OK)
  {
    while(1){};
  } 
   
  
  #ifdef SIGNAL_APP1
    if ((INT8U)OSSemCreate(0,&(SIGNAL_APP1)) != ALLOC_EVENT_OK)
    {
      while(1){};
    } 
  #endif
  #ifdef SIGNAL_APP2
    if ((INT8U)OSSemCreate(0,&(SIGNAL_APP2)) != ALLOC_EVENT_OK)
    {
      while(1){};
    } 
  #endif 
  #ifdef SIGNAL_APP3
    if ((INT8U)OSSemCreate(0,&(SIGNAL_APP3)) != ALLOC_EVENT_OK)
    {
      while(1){};
    } 
  #endif 
  #ifdef SIGNAL_APP4
    if ((INT8U)OSSemCreate(0,&(SIGNAL_APP4)) != ALLOC_EVENT_OK)
    {
      while(1){};
    } 
  #endif 
  #ifdef SIGNAL_APP255
    if ((INT8U)OSSemCreate(0,&(SIGNAL_APP255)) != ALLOC_EVENT_OK)
    {
      while(1){};
    } 
  #endif    

     
  
    
  ////////////////////////////////////////////////
  //     Initialize Network Tasks           //////
  ////////////////////////////////////////////////
  if(InstallTask(&GPSNET_RF_Event,"RF Event Handler",GPSNET_RF_Event_StackSize,RF_EventHandlerPriority) != OK)
  {
     while(1){};
  }
  if(InstallTask(&GPSNET_MAC,"GPS MAC Handler",GPSNET_MAC_StackSize,MAC_HandlerPriority) != OK)
  {
     while(1){};
  }
  
  if(InstallTask(&GPSNET_NWK,"GPS NWK Handler",GPSNET_NWK_StackSize,NWK_HandlerPriority) != OK)
  {
     while(1){};
  }

}