Example #1
0
File: main.c Project: sdalu/ChibiOS
/*
 * Application entry point.
 */
int main(void) {
  uint32 blinker_id;

  /* HAL initialization, this also initializes the configured device drivers
     and performs the board-specific initializations.*/
  halInit();

  /* OS initialization.*/
  (void) OS_API_Init();

  /* Activates the serial driver 2 using the driver default configuration.
    PA2(TX) and PA3(RX) are routed to USART2.*/
  sdStart(&SD2, NULL);
  palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
  palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));

  /* Starting the blinker thread.*/
  (void) OS_TaskCreate(&blinker_id, "blinker", blinker,
                       (uint32 *)wa_blinker, sizeof wa_blinker,
                       128, 0);

  /* In the ChibiOS/RT OSAL implementation the main() function is an
     usable thread with priority 128 (NORMALPRIO), here we just sleep
     in a loop printing a message on the serial port.*/
  while (true) {
    sdWrite(&SD2, (uint8_t *)"Hello World!\r\n", 14);
    OS_TaskDelay(500);
  }
}
Example #2
0
/*
 * Application entry point.
 */
int main(void) {
  uint32 blinker_id;

  /* HAL initialization, this also initializes the configured device drivers
     and performs the board-specific initializations.*/
  halInit();

  /* OS initialization.*/
  (void) OS_API_Init();

  /* Activates the serial driver 1 using the driver default configuration.*/
  sdStart(&SD1, NULL);

  /* ARD_D13 is programmed as output (board LED).*/
  palClearLine(LINE_ARD_D13);
  palSetLineMode(LINE_ARD_D13, PAL_MODE_OUTPUT_PUSHPULL);

  /* Starting the blinker thread.*/
  (void) OS_TaskCreate(&blinker_id, "blinker", blinker,
                       (uint32 *)wa_blinker, sizeof wa_blinker,
                       128, 0);

  /* In the ChibiOS/RT OSAL implementation the main() function is an
     usable thread with priority 128 (NORMALPRIO), here we just sleep
     waiting for a button event, then the test suite is executed.*/
  while (true) {
    if (palReadLine(LINE_BUTTON_USER))
      test_execute((BaseSequentialStream *)&SD1, &nasa_osal_test_suite);
    OS_TaskDelay(500);
  }
}
Example #3
0
void OS_BSPMain( void )
{
   int    TicksPerSecond;
   
   /*
   ** Initialize the OS API
   */
   OS_API_Init();

   /* 
   ** Delay for one second. 
   */
   TicksPerSecond = sysClkRateGet();
   (void) taskDelay( TicksPerSecond );

   OS_printf("Starting Up OSAPI App.\n");
   
   /*
   ** Call OSAL entry point.    
   */
   OS_Application_Startup();

   /*
   ** Exit the main thread.
   ** in VxWorks we can delete all of the OS tasks if we want.
   */

}
Example #4
0
SYS_DRV_ErrorCode_t Pvware_DRV_Init( void )
{
	int iRet = 0;

    if( 1 == g_DrivesInitFlag )
    {
       return SYS_DRV_NO_ERROR;
    }
    
	OS_API_Init();
#if 0
	iRet = DRV_I2C_Open();
    if( 0 != iRet )
    {
        pbierror("%s  DRV_I2C_Open  error!\n", __FUNCTION__ );
    }
#endif	
	ConfigInit();
    
	iRet = DRV_Tuner_Init();
	if( 0 != iRet )
	{
		pbierror("%s  DRV_Tuner_Init  error!\n", __FUNCTION__ );
	}

        /* The DRV_AV_Init before SFILTER_Init */
	iRet = SFILTER_Init();
	if( 0 != iRet )
	{
    	pbierror("%s  SFILTER_Init  error!\n", __FUNCTION__ );
	}
    
    iRet = DRV_AV_Init();
    if( 0 != iRet )
    {
        PBIDEBUG("DRV_AV_Init error!");
    }

    /* PVR INIT */
    iRet = SFILTER_PVR_Init();
    if( 0 != iRet )
    {
    	pbierror("%s  SFILTER_PVR_Init  error!\n", __FUNCTION__ );
    }
    
    iRet = DRV_PVR_Init();
	if( 0 != iRet )
	{
    	pbierror("%s  DRV_PVR_Init  error!\n", __FUNCTION__ );
	}
    //CtrlTunerLockLed(1);
    //CtrlTunerLockLed(1);
    //CtrlTunerLockLed(1);

    g_DrivesInitFlag = 1;


	return SYS_DRV_NO_ERROR;
}
void OS_Application_Startup(void)
{
   uint32             status;

   OS_API_Init();

   OS_printf("OS Application Startup\n");

   status = OS_QueueCreate( &msgq_id, "MsgQ", MSGQ_DEPTH, MSGQ_SIZE, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Message Queue\n");
   }

   /*
   ** Create a timer
   */
   status = OS_TimerCreate(&timer_id, "Timer 1", &timer_accuracy, &(TimerFunction));
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating OS Timer\n");
   }
   else
   {
      OS_printf("Timer ID = %d\n", (int)timer_id);
      OS_printf("Timer Accuracy = %d microseconds \n",(int)timer_accuracy);
   }

   /*
   ** Create the "consumer" task.
   */
   status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 1\n");
   }
   else
   {
      OS_printf("Created Task 1\n");
   }

   /*
   ** Start the timer
   */
   status  =  OS_TimerSet(timer_id, timer_start, timer_interval);
   if ( status != OS_SUCCESS )
   {
       OS_printf("Error calling OS_TimerSet: ID = %d\n", (int)timer_id);
   }
   else
   {
       OS_printf("Timer programmed\n");
   }

}
Example #6
0
void Test_OS_API_Init_QueueTableSem_Error(void)
{
    int32 expected = OS_ERROR;
    int32 actual   = 99;

    /* Setup Inputs */
    OsApi_SetReturnCode(OSAPI_SEMMCREATE_INDEX, 0, 2);

    /* Execute Test */
    actual = OS_API_Init();

    /* Verify Outputs */
    UtAssert_True(actual == expected, "actual == OS_ERROR");
}
Example #7
0
void Test_OS_API_Init_TimerApiInit_Error(void)
{
    int32 expected = OS_ERROR;
    int32 actual   = 99;

    /* Setup Inputs */
    OsApi_SetReturnCode(OSAPI_OSTIMERAPIINIT_INDEX, OS_ERROR, 1);

    /* Execute Test */
    actual = OS_API_Init();

    /* Verify Outputs */
    UtAssert_True(actual == expected, "actual == OS_ERROR");
}
Example #8
0
void Test_OS_API_Init_TaskSpawn_Error(void)
{
    int32 expected = OS_ERROR;
    int32 actual   = 99;

    /* Setup Inputs */
    OsApi_SetReturnCode(OSAPI_TASKSPAWN_INDEX, VCS_ERROR, 1);

    /* Execute Test */
    actual = OS_API_Init();

    /* Verify Outputs */
    UtAssert_True(actual == expected, "actual == OS_ERROR");
}
Example #9
0
void Test_OS_API_Init_MsgQCreate_Error(void)
{
    int32 expected = OS_ERROR;
    int32 actual   = 99;

    /* Setup Inputs */
    OsApi_SetReturnCode(OSAPI_MSGQCREATE_INDEX, 0, 1);

    /* Execute Test */
    actual = OS_API_Init();

    /* Verify Outputs */
    UtAssert_True(actual == expected, "actual == OS_ERROR");
    UtAssert_True(getNTaskDeleteForce() == 1, "taskDeleteForce called");
}
   int main(int argc, char* argv[])
#endif
{
    UT_os_setup(UT_OS_LOG_FILENAME);

    /* UT_OS_LOG_OFF, UT_OS_LOG_MINIMAL, UT_OS_LOG_MODERATE, UT_OS_LOG_EVERYTHING */
    UT_os_set_log_verbose(UT_OS_LOG_EVERYTHING);

    UT_OS_LOG_MACRO("OSAL Unit Test Output File for osnetwork APIs\n");

    OS_API_Init();

    UT_os_networkgetid_test();
    UT_os_networkgethostname_test();

    UT_os_teardown("ut_osnetwork");

    return (g_logInfo.nFailed);
}
Example #11
0
/******************************************************************************
 * FUNCTION NAME:
 *      None
 * DESCRIPTION:
 *      None
 * INPUT:
 *      None
 * OUTPUT:
 *      None
 * RETURN:
 *      None
 * NOTES:
 *      None
 * HISTORY:
 *      Ver1.00     2007.02.14      Panda Xiong         Create
******************************************************************************/
static CLI_REG_CMD_RETURN_T cmd_os_osDebug
(
    IN const GT_UI32     n_param,
    IN const GT_UI8     *param[]
)
{
    GT_UI32  current_param = 1;

    if (n_param < 2)
    {
        UTL_PRT_Printf("\n\rMissing parameter!");
        return CLI_PRT_FAIL;
    }

    if (strcmp(param[current_param], (GT_UI8 *)"start") == 0)
    {
        GT_UI32 task_1_arg = 1;
        GT_UI32 task_2_arg = 2;

        UTL_PRT_Printf("\n\r OS_API_Init ...");
        OS_API_Init();

        UTL_PRT_Printf("\n\r OS_TASK_API_Create Task_1 ...");
        OS_TASK_API_Create((GT_UI8 *)"Task_1", task_1, &task_1_arg, KB(1), 6, GT_TRUE);

        UTL_PRT_Printf("\n\r OS_TASK_API_Create Task_2 ...");
        OS_TASK_API_Create((GT_UI8 *)"Task_2", task_2, &task_2_arg, KB(1), 5, GT_TRUE);

        UTL_PRT_Printf("\n\r OS_API_Start ...");
        OS_API_Start();

        /* never reach here */
        UTL_PRT_Printf("\n\rOS Start OK ...");
        return CLI_PRT_SUCCESS;
    }
    else
    {
        UTL_PRT_Printf("\n\rUnknown parameter!");
        return CLI_PRT_FAIL;
    }
}
Example #12
0
void Test_OS_API_Init_Success(void)
{
    int32 expected = OS_SUCCESS;
    int32 actual   = 99;
    uint32 ii      = 0;

    /* Setup Inputs */

    /* Execute Test */
    actual = OS_API_Init();

    /* Verify Outputs */
    UtAssert_True(actual == expected, "actual == OS_SUCCESS");
    UtAssert_True(getNTaskDeleteForce() == 0, "taskDeleteForce not called");
    for (ii = 0; ii < OS_MAX_TASKS; ++ii)
    {
        UtAssert_True(OsApi_Adaptor_getTaskTableEntry(ii)->free == TRUE,
                      "OS_task_table entry is free");
    }
    for (ii = 0; ii < OS_MAX_QUEUES; ++ii)
    {
        UtAssert_True(OsApi_Adaptor_getQueueTableEntry(ii)->free == TRUE,
                      "OS_queue_table entry is free");
    }
    for (ii = 0; ii < OS_MAX_BIN_SEMAPHORES; ++ii)
    {
        UtAssert_True(OsApi_Adaptor_getBinSemTableEntry(ii)->free == TRUE,
                      "OS_bin_sem_table entry is free");
    }
    for (ii = 0; ii < OS_MAX_COUNT_SEMAPHORES; ++ii)
    {
        UtAssert_True(OsApi_Adaptor_getCountSemTableEntry(ii)->free == TRUE,
                      "OS_count_sem_table entry is free");
    }
    for (ii = 0; ii < OS_MAX_MUTEXES; ++ii)
    {
        UtAssert_True(OsApi_Adaptor_getMutSemTableEntry(ii)->free == TRUE,
                      "OS_mut_sem_table_entry is free");
    }
}
Example #13
0
int main(void)
{
   /*
   ** Initialize the OS API data structures
   */
   OS_API_Init();
     
   /*
   ** Call application specific entry point.
   */
   OS_Application_Startup();
   
   /*
   ** Let the main thread sleep 
   */     
   for ( ;; )
   {
      sleep(1);
   }
                 
   return(0);
}
Example #14
0
int main(void)
{

   int mode;
   int status; 

   /*
   ** Create local directories for "disk" mount points
   **  See bsp_voltab for the values 
   */
   printf("Making directories: ram0, ram1, eeprom1 for OSAL mount points\n");
   mode = S_IFDIR |S_IRWXU | S_IRWXG | S_IRWXO;
   status = mkdir("ram0", mode);
   status = mkdir("ram1", mode);
   status = mkdir("eeprom1", mode); 


   /*
   ** Initialize the OS API data structures
   */
   OS_API_Init();
     
   /*
   ** Call application specific entry point.
   */
   OS_Application_Startup();
   
   /*
   ** Let the main thread sleep 
   */     
   for ( ;; )
   {
      sleep(1);
   }
                 
   return(0);
}
Example #15
0
/******************************************************************************
**  Function:  main()
**
**  Purpose:
**    BSP Application entry point.
**
**  Arguments:
**    (none)
**
**  Return:
**    (none)
*/
int main(int argc, char *argv[])
{
   uint32             reset_type;
   uint32             reset_subtype;
   struct             sigaction sa;
   struct             itimerval timer;
   int                opt = 0;
   int                longIndex = 0;
   sigset_t           mask;
   pthread_t          thread_id;
   struct sched_param thread_params;
   int                ret;

#ifdef CFE_PSP_EEPROM_SUPPORT
   int32  Status;
   uint32 eeprom_address;
   uint32 eeprom_size;
#endif
   
   /*
   ** Initialize the CommandData struct 
   */
   memset(&(CommandData), 0, sizeof(CFE_PSP_CommandData_t));
      
   /* 
   ** Process the arguments with getopt_long(), then 
   ** start the cFE
   */
   opt = getopt_long( argc, argv, optString, longOpts, &longIndex );
   while( opt != -1 ) 
   {
      switch( opt ) 
      {
         case 'R':
            strncpy(CommandData.ResetType, optarg, CFE_PSP_RESET_NAME_LENGTH);
            if ((strncmp(CommandData.ResetType, "PO", CFE_PSP_RESET_NAME_LENGTH ) != 0 ) &&
                (strncmp(CommandData.ResetType, "PR", CFE_PSP_RESET_NAME_LENGTH ) != 0 ))
            {
               printf("\nERROR: Invalid Reset Type: %s\n\n",CommandData.ResetType);
               CommandData.GotResetType = 0;
               CFE_PSP_DisplayUsage(argv[0]);
               break;
            }
            printf("CFE_PSP: Reset Type: %s\n",(char *)optarg);
            CommandData.GotResetType = 1;
            break;
				
         case 'S':
            CommandData.SubType = strtol(optarg, NULL, 0 );
            if ( CommandData.SubType < 1 || CommandData.SubType > 5 )
            {
               printf("\nERROR: Invalid Reset SubType: %s\n\n",optarg);
               CommandData.SubType = 0;
               CommandData.GotSubType = 0;
               CFE_PSP_DisplayUsage(argv[0]);
               break;
            }
            printf("CFE_PSP: Reset SubType: %d\n",(int)CommandData.SubType);
            CommandData.GotSubType = 1;
            break;

         case 'N':
            strncpy(CommandData.CpuName, optarg, CFE_PSP_CPU_NAME_LENGTH );
            printf("CFE_PSP: CPU Name: %s\n",CommandData.CpuName);
            CommandData.GotCpuName = 1;
            break;

         case 'C':
            CommandData.CpuId = strtol(optarg, NULL, 0 );
            printf("CFE_PSP: CPU ID: %d\n",(int)CommandData.CpuId);
            CommandData.GotCpuId = 1;
            break;

         case 'I':
            CommandData.SpacecraftId = strtol(optarg, NULL, 0 );
            printf("CFE_PSP: Spacecraft ID: %d\n",(int)CommandData.SpacecraftId);
            CommandData.GotSpacecraftId = 1;
            break;

         case 'h':
            CFE_PSP_DisplayUsage(argv[0]);
            break;
	
         default:
            CFE_PSP_DisplayUsage(argv[0]);
            break;
       }
		
       opt = getopt_long( argc, argv, optString, longOpts, &longIndex );
   } /* end while */
   
   /*
   ** Set the defaults for values that were not given for the 
   ** optional arguments, and check for arguments that are required.
   */
   CFE_PSP_ProcessArgumentDefaults(&CommandData);

   /*
   ** Set the reset type
   */
   if (strncmp("PR", CommandData.ResetType, 2 ) == 0 )
   {
     reset_type = CFE_ES_PROCESSOR_RESET;
      OS_printf("CFE_PSP: Starting the cFE with a PROCESSOR reset.\n");
   }
   else
   {
      reset_type = CFE_ES_POWERON_RESET;
      OS_printf("CFE_PSP: Starting the cFE with a POWER ON reset.\n");
   }

   /*
   ** Assign the Spacecraft ID, CPU ID, and CPU Name
   */
   CFE_PSP_SpacecraftId = CommandData.SpacecraftId;
   CFE_PSP_CpuId = CommandData.CpuId;
   strncpy(CFE_PSP_CpuName, CommandData.CpuName, CFE_PSP_CPU_NAME_LENGTH);

   /*
   ** Set the reset subtype
   */
   reset_subtype = CommandData.SubType;

   /*
   ** Install sigint_handler as the signal handler for SIGINT.
   */
   signal(SIGINT, CFE_PSP_SigintHandler);

   /*
   ** Init timer counter
   */
   TimerCounter = 0;

   /*
   ** Install timer_handler as the signal handler for SIGVTALRM.
   */
   memset (&sa, 0, sizeof (sa));
   sa.sa_handler = &CFE_PSP_TimerHandler;
   sigaction (SIGALRM, &sa, NULL);

   /*
   ** Configure the timer to expire after 250ms
   */
   timer.it_value.tv_sec  = 0;
   timer.it_value.tv_usec = 250000;

   /*
   **  and every 500ms after that.
   */
   timer.it_interval.tv_sec  = 0;
   timer.it_interval.tv_usec = 250000;

   /*
   ** Initialize the OS API data structures
   */
   OS_API_Init();
     
   sleep(1);

   /*
   ** Initialize the reserved memory 
   */
   CFE_PSP_InitProcessorReservedMemory(reset_type);


   /*
   ** Start the timer
   */
   setitimer (ITIMER_REAL, &timer, NULL);


#ifdef CFE_PSP_EEPROM_SUPPORT
   /*
   ** Create the simulated EEPROM segment by mapping a memory segment to a file. 
   ** Since the file will be saved, the "EEPROM" contents will be preserved.
   ** Set up 512Kbytes of EEPROM
   */
   eeprom_size = 0x80000;
   Status = CFE_PSP_SetupEEPROM(eeprom_size, &eeprom_address);
   
   if ( Status == 0 )
   {
      uint32 Dword;
      /*
      ** Install the 2nd memory range as the mapped file ( EEPROM )
      */  
      Status = CFE_PSP_MemRangeSet (1, CFE_PSP_MEM_EEPROM, eeprom_address, 
                                    eeprom_size, CFE_PSP_MEM_SIZE_DWORD, 0 ); 
      OS_printf("CFE_PSP: EEPROM Range (2) created: Start Address = %08X, Size = %08X\n", eeprom_address, eeprom_size);  
      
   }
   else
   {
      OS_printf("CFE_PSP: Cannot create EEPROM Range from Memory Mapped file.\n");
   }
#endif

   /*
   ** Disable Signals to parent thread and therefore all
   ** child threads create will block all signals
   ** Note: Timers will not work in the application unless
   **       threads are spawned in OS_Application_Startup.
   */
   sigfillset(&mask);
   sigdelset(&mask, SIGINT); /* Needed to kill program */
   sigprocmask(SIG_SETMASK, &mask, NULL);


   /*
   ** Raise the priority of the main thread so ES Main completes  
   */
   thread_id = pthread_self(); 
   thread_params.sched_priority = sched_get_priority_max(SCHED_FIFO);
   ret = pthread_setschedparam(thread_id, SCHED_FIFO, &thread_params);
   if ( ret != 0 )
   {
      OS_printf("Unable to set main thread priority to max\n");
   }

   /*
   ** Call cFE entry point.
   */
   CFE_ES_Main(reset_type, reset_subtype, 1, (uint8 *)CFE_ES_NONVOL_STARTUP_FILE); 

   /*
   ** Re-enable Signals to current thread so that
   ** any signals will interrupt in this threads context
   ** ... this is needed for timers
   */
   sigprocmask(SIG_UNBLOCK, &mask, NULL);

   /*
   ** Lower the thread priority to before entering the sleep loop
   */
   thread_params.sched_priority = sched_get_priority_min(SCHED_FIFO);
   ret = pthread_setschedparam(thread_id, SCHED_FIFO, &thread_params);
   if ( ret != 0 )
   {
      OS_printf("Unable to set main thread priority to minimum\n");
   }

   /*
   ** Let the main thread sleep 
   */     
   for ( ;; )
   {
      /* 
      ** Even though this sleep call is for 1 second,
      ** the sigalarm timer for the 1hz will keep waking
      ** it up. Keep that in mind when setting the timer down
      ** to something very small.
      */
      sleep(1);
   }
                 
   return(0);
}
Example #16
0
void CFE_PSP_Main(  int ModeId, char *StartupFilePath )
{
   uint32            reset_type;
   uint32            reset_subtype;
   rtems_status_code RtemsStatus;
   rtems_name        RtemsTimerName;
   
   /*
   ** Initialize the OS API
   */
   OS_API_Init();

   /* 
   ** Create an interval timer for the 1hz
   */
   RtemsTimerName = rtems_build_name('1',' ','H','Z');
   RtemsStatus = rtems_timer_create(RtemsTimerName, &RtemsTimerId);
   if ( RtemsStatus != RTEMS_SUCCESSFUL )
   {
      printf("CFE_PSP: Error: Cannot create RTEMS 1hz interval timer\n");
   }
   
   /*
   ** Allocate memory for the cFE memory. Note that this is malloced on
   ** the COTS board, but will be a static location in the ETU. 
   */
   printf("Sizeof BSP reserved memory = %d bytes\n",sizeof(CFE_PSP_ReservedMemory_t));

   CFE_PSP_ReservedMemoryPtr = malloc(sizeof(CFE_PSP_ReservedMemory_t));

   if ( CFE_PSP_ReservedMemoryPtr == NULL )
   {
      printf("CFE_PSP: Error: Cannot malloc BSP reserved memory!\n");
   }
   else
   {
      printf("CFE_PSP: Allocated %d bytes for PSP reserved memory at: 0x%08X\n",
              sizeof(CFE_PSP_ReservedMemory_t), (int)CFE_PSP_ReservedMemoryPtr);
   }
   /*
   ** Determine Reset type by reading the hardware reset register.
   */
   reset_type = CFE_ES_POWERON_RESET;
   reset_subtype = CFE_ES_POWER_CYCLE;

   /*
   ** Initialize the reserved memory 
   */
   CFE_PSP_InitProcessorReservedMemory(reset_type);

   /*
   ** Call cFE entry point. This will return when cFE startup
   ** is complete.
   */
   CFE_ES_Main(reset_type,reset_subtype, 1, (uint8 *)StartupFilePath); 

   /*
   ** Setup the timer to fire at 1hz 
   */  
   
   /* CLOCK TICK */ 
   RtemsStatus = rtems_timer_fire_after(RtemsTimerId, 100, CFE_PSP_1hzTimer, NULL );
   if ( RtemsStatus != RTEMS_SUCCESSFUL )
   {
      printf("CFE_PSP: Error: Cannot setup interval timer to fire at 1hz\n");
   }
      
   /*
   ** Return to the shell/monitor
   */
   return; 
   
}
/*
** Main function
*/
void OS_Application_Startup(void)
{
   uint32 status;
   OS_bin_sem_prop_t  bin_sem_prop;

   OS_API_Init();

   OS_printf("OS Application Startup\n");

   /*
   ** Create the binary semaphore
   */
   status = OS_BinSemCreate( &bin_sem_id, "BinSem1", 1, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Binary Sem\n");
   }
   else
   {
      status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop);
      OS_printf("Binary Sem ID = %d, value = %d\n", (int)bin_sem_id, (int)bin_sem_prop.value);
   }

   /*
   ** Take the semaphore so the value is 0 and the next SemTake call should block
   */
   status = OS_BinSemTake(bin_sem_id);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error calling OS_BinSemTake with bin_sem_id = %d\n",(int)bin_sem_id);
   }
   else
   {
      status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop);
      OS_printf("Initial Binary Sem Take: value = %d\n", (int)bin_sem_prop.value);
   }

   /*
   ** Create the tasks
   */
   status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_STACK_SIZE, TASK_1_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 1\n");
   }
   else
   {
      OS_printf("Created Task 1\n");
   }

   status = OS_TaskCreate( &task_2_id, "Task 2", task_2, task_2_stack, TASK_STACK_SIZE, TASK_2_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 2\n");
   }
   else
   {
      OS_printf("Created Task 2\n");
   }
 
   status = OS_TaskCreate( &task_3_id, "Task 3", task_3, task_3_stack, TASK_STACK_SIZE, TASK_3_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 3\n");
   }
   else
   {
      OS_printf("Created Task 3\n");
   }

   /* 
   ** Delay, then release the semaphore
   */
   OS_TaskDelay(2000); 

   status = OS_BinSemFlush(bin_sem_id);

   OS_printf("Main done!\n");

}
Example #18
0
/******************************************************************************
**  Function:  CFE_PSP_Start()
**
**  Purpose:
**    Initialize the PSP and start cFE
**
**  Arguments:
**    ModeId          - Used to indicate which bank of non-volatile memory
**                      was used to boot.  If the bank used to boot this time
**                      is different from the previous boot, then we re-initialize
**                      reserved memory.
**    StartupFilePath - path to cFE startup file to use 
**
**  Return:
**    (none)
*/
void CFE_PSP_Start( int ModeId, char *StartupFilePath )
{
   uint32 reset_type = 0;
   uint32 reset_subtype = 0;
   uint32 status = 0;
   

   /*
    ** Initialize the hardware timer for the local time source
    ** On VxWorks, the default config sets the sysClk to 200 Hz (default 60Hz)
    ** OS_API_Init() calls OS_TimerAPIInit() which gets the
    ** clock resolution of the realtime clock, which is based on the sysClk
    ** and determines the clock accuracy which is used by the scheduler
    ** timers later.  sysClk needs to be at least 200Hz for a 100Hz minor
    ** frame rate.
    */
   CFE_PSP_InitLocalTime();

   /*
   ** Initialize the OS API data structures
   */
   status = OS_API_Init();
   if(status != OS_SUCCESS)
   {
     printf("CFE_PSP_Start() - OS_API_Init() fail, RC = 0x%x\n", status);
   }
 
   /*
   ** Setup the pointer to the reserved area in vxWorks.
   ** This must be done before any of the reset variables are used.
   */
   CFE_PSP_ReservedMemoryPtr = (CFE_PSP_ReservedMemory_t *) sysMemTop();

   printf("CFE_PSP_Main: Reserved Memory Address %08X\n", (uint32)CFE_PSP_ReservedMemoryPtr);

   /* PSP System Initialization */
   CFE_PSP_SysInit(&reset_type, &reset_subtype, CFE_PSP_ReservedMemoryPtr->bsp_reset_type);

   /*
   ** Initialize the watchdog, it's left disabled
   */
   CFE_PSP_WatchdogInit();
   
   /*
   ** Initialize the reserved memory 
   */
   CFE_PSP_InitProcessorReservedMemory(reset_type);
   
    /*
     * Adjust system task priorities so that tasks such as the shell are
     * at a lower priority that the CFS apps
     */
    SetSysTasksPrio();

   /*
   ** Call cFE entry point. This will return when cFE startup
   ** is complete.
   */
   CFE_ES_Main(reset_type, reset_subtype, ModeId, StartupFilePath);

   /*
    * Initializing the 1Hz timer connects the cFE 1Hz ISR for providing the
    * CFS 1Hz time sync, sync the scheduler's 1Hz major frame start to the
    * 1Hz timer.  This call can only occur after CFE_ES_Main() because the
    * 1Hz ISR uses a semaphore that is created when timer services are
    * initialized.
    */
   CFE_PSP_Init1HzTimer();
   CFE_TIME_SetState(CFE_TIME_VALID);
   
   /*
   ** Enable the watchdog
   */
/* CFE_PSP_WatchdogEnable(); really should be enabled in HS */

    printf("CFE_PSP_Start done, exiting.\n");
               
   return;
   
}  /* End CFE_PSP_Main */