int main(int argc, char **argv)
{
  printf("**starting the model**\n");
  fflush(stdout);
  rtmSetErrorStatus(Model_M, 0);
  rtExtModeParseArgs(argc, (const char_T **)argv, NULL);

  /* Initialize model */
  Model_initialize();

  /* External mode */
  rtSetTFinalForExtMode(&rtmGetTFinal(Model_M));
  rtExtModeCheckInit(1);

  {
    boolean_T rtmStopReq = false;
    rtExtModeWaitForStartPkt(Model_M->extModeInfo, 1, &rtmStopReq);
    if (rtmStopReq) {
      rtmSetStopRequested(Model_M, true);
    }
  }

  rtERTExtModeStartMsg();

  /* Call RTOS Initialization funcation */
  prosRTOSInit(0.2, 0);

  /* Wait for stop semaphore */
  mw_osSemaphoreWaitEver(&stopSem);
  return 0;
}
示例#2
0
int main(void)
{
  volatile boolean_T runModel = 1;
  float modelBaseRate = 2.0;
  float systemClock = 0;
  init();
  MW_Arduino_Init();
  rtmSetErrorStatus(test_motor_M, 0);

  /* initialize external mode */
  rtParseArgsForExtMode(0, NULL);
  test_motor_initialize();
  sei();

  /* External mode */
  rtSetTFinalForExtMode(&rtmGetTFinal(test_motor_M));
  rtExtModeCheckInit(1);

  {
    boolean_T rtmStopReq = false;
    rtExtModeWaitForStartPkt(test_motor_M->extModeInfo, 1, &rtmStopReq);
    if (rtmStopReq) {
      rtmSetStopRequested(test_motor_M, true);
    }
  }

  rtERTExtModeStartMsg();
  cli();
  configureArduinoAVRTimer();
  runModel =
    (rtmGetErrorStatus(test_motor_M) == (NULL)) && !rtmGetStopRequested
    (test_motor_M);
  sei();
  sei();
  while (runModel) {
    /* External mode */
    {
      boolean_T rtmStopReq = false;
      rtExtModeOneStep(test_motor_M->extModeInfo, 1, &rtmStopReq);
      if (rtmStopReq) {
        rtmSetStopRequested(test_motor_M, true);
      }
    }

    runModel =
      (rtmGetErrorStatus(test_motor_M) == (NULL)) && !rtmGetStopRequested
      (test_motor_M);
  }

  rtExtModeShutdown(1);

  /* Disable rt_OneStep() here */

  /* Terminate model */
  test_motor_terminate();
  cli();
  return 0;
}
示例#3
0
文件: ert_main.c 项目: epffpe/Matlab
int main(int argc, char **argv)
{
  int ret;
  baseRateInfo_t info;
  pthread_attr_t attr;
  pthread_t baseRateThread;
  size_t stackSize;
  unsigned long cpuMask = 0x1;
  unsigned int len = sizeof(cpuMask);
  printf("**starting the model**\n");
  fflush(stdout);
  rtmSetErrorStatus(raspberrypi_audioequalizer_M, 0);
  rtExtModeParseArgs(argc, (const char_T **)argv, NULL);

  /* All threads created by this process must run on a single CPU */
  ret = sched_setaffinity(0, len, (cpu_set_t *) &cpuMask);
  CHECK_STATUS(ret, "sched_setaffinity");

  /* Initialize semaphore used for thread synchronization */
  ret = sem_init(&stopSem, 0, 0);
  CHECK_STATUS(ret, "sem_init:stopSem");

  /* Create threads executing the Simulink model */
  pthread_attr_init(&attr);
  ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
  CHECK_STATUS(ret, "pthread_attr_setinheritsched");
  ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
  CHECK_STATUS(ret, "pthread_attr_setdetachstate");

  /* PTHREAD_STACK_MIN is the minimum stack size required to start a thread */
  stackSize = 64000 + PTHREAD_STACK_MIN;
  ret = pthread_attr_setstacksize(&attr, stackSize);
  CHECK_STATUS(ret, "pthread_attr_setstacksize");

  /* Block signal used for timer notification */
  info.period = 0.1;
  info.signo = SIGRTMIN;
  sigemptyset(&info.sigMask);
  MW_blockSignal(info.signo, &info.sigMask);
  signal(SIGTERM, MW_exitHandler);     /* kill */
  signal(SIGHUP, MW_exitHandler);      /* kill -HUP */
  signal(SIGINT, MW_exitHandler);      /* Interrupt from keyboard */
  signal(SIGQUIT, MW_exitHandler);     /* Quit from keyboard */
  raspberrypi_audioequalizer_initialize();

  /* External mode */
  rtSetTFinalForExtMode(&rtmGetTFinal(raspberrypi_audioequalizer_M));
  rtExtModeCheckInit(1);

  {
    boolean_T rtmStopReq = FALSE;
    rtExtModeWaitForStartPkt(raspberrypi_audioequalizer_M->extModeInfo, 1,
      &rtmStopReq);
    if (rtmStopReq) {
      rtmSetStopRequested(raspberrypi_audioequalizer_M, TRUE);
    }
  }

  rtERTExtModeStartMsg();

  /* Create base rate task */
  ret = pthread_create(&baseRateThread, &attr, (void *) baseRateTask, (void *)
                       &info);
  CHECK_STATUS(ret, "pthread_create");
  pthread_attr_destroy(&attr);

  /* Wait for a stopping condition. */
  MW_sem_wait(&stopSem);

  /* Received stop signal */
  printf("**stopping the model**\n");
  if (rtmGetErrorStatus(raspberrypi_audioequalizer_M) != NULL) {
    printf("\n**%s**\n", rtmGetErrorStatus(raspberrypi_audioequalizer_M));
  }

  /* External mode shutdown */
  rtExtModeShutdown(1);

  /* Disable rt_OneStep() here */

  /* Terminate model */
  raspberrypi_audioequalizer_terminate();
  return 0;
}
示例#4
0
int_T main(void)
{
  init();

#ifdef _RTT_USE_SERIAL1_

  Serial_begin(1, 9600);

#endif

#ifdef _RTT_USE_SERIAL2_

  Serial_begin(2, 9600);

#endif

#ifdef _RTT_USE_SERIAL3_

  Serial_begin(3, 9600);

#endif

  /* initialize external mode */
  rtParseArgsForExtMode(0, NULL);
  velo_id_gain_initialize();

  /* External mode */
  rtSetTFinalForExtMode(&rtmGetTFinal(velo_id_gain_M));
  rtExtModeCheckInit(2);

  {
    boolean_T rtmStopReq = false;
    rtExtModeWaitForStartPkt(velo_id_gain_M->extModeInfo, 2, &rtmStopReq);
    if (rtmStopReq) {
      rtmSetStopRequested(velo_id_gain_M, true);
    }
  }

  rtERTExtModeStartMsg();
  arduino_Timer_Setup();

  /* The main step loop */
  while ((rtmGetErrorStatus(velo_id_gain_M) == (NULL)) && !rtmGetStopRequested
         (velo_id_gain_M)) {
    /* External mode */
    {
      boolean_T rtmStopReq = false;
      rtExtModeOneStep(velo_id_gain_M->extModeInfo, 2, &rtmStopReq);
      if (rtmStopReq) {
        rtmSetStopRequested(velo_id_gain_M, true);
      }
    }

    rtExtModeCheckEndTrigger();
  }

  rtExtModeShutdown(2);
  delay(1000);
  velo_id_gain_terminate();

  /* Disable Interrupts */
  cli();
  return 0;
}
示例#5
0
/* Function: main =============================================================
 *
 * Abstract:
 *   Execute model on a generic target such as a workstation.
 */
int_T main(int_T argc, const char *argv[])
{
    /* External mode */
//     rtParseArgsForExtMode(argc, argv);
 
    /*******************************************
     * warn if the model will run indefinitely *
     *******************************************/
#if MAT_FILE==0 && EXT_MODE==0
    printf("warning: the simulation will run with no stop time; "
           "to change this behavior select the 'MAT-file logging' option\n");
    fflush(NULL);
#endif

    (void)printf("\n** starting the model **\n");

    /************************
     * Initialize the model *
     ************************/
    rt_InitModel();

    /* External mode */
    rtSetTFinalForExtMode(&rtmGetTFinal(RT_MDL));
    rtExtModeCheckInit(NUMST);
    Clock_Params clkParams;

    Timer_Params user_sys_tick_params;
    Timer_Handle user_sys_tick_timer;

    /* Create timer for user system tick */
    Timer_Params_init(&user_sys_tick_params);
    user_sys_tick_params.period = STEP_SIZE;
    user_sys_tick_params.periodType = Timer_PeriodType_MICROSECS;
    user_sys_tick_params.arg = 1;

    user_sys_tick_timer = Timer_create(1,
    		(ti_sysbios_hal_Timer_FuncPtr)Clock_tick, &user_sys_tick_params, NULL);

    if(user_sys_tick_timer == NULL)
    {
    	System_abort("Unable to create user system tick timer!");
    }

    /* Create a periodic Clock Instance with period = 1 system time units */
    Clock_Params_init(&clkParams);
    clkParams.period = 1;
    clkParams.startFlag = TRUE;
    Clock_create(clk0Fxn, 10, &clkParams, NULL);
    
//     rtExtModeWaitForStartPkt(rtmGetRTWExtModeInfo(RT_MDL),
//                              NUMST,
//                              (boolean_T *)&rtmGetStopRequested(RT_MDL));

    /***********************************************************************
     * Execute (step) the model.  You may also attach rtOneStep to an ISR, *
     * in which case you replace the call to rtOneStep with a call to a    *
     * background task.  Note that the generated code sets error status    *
     * to "Simulation finished" when MatFileLogging is specified in TLC.   *
     ***********************************************************************/
//     while (rtmGetErrorStatus(RT_MDL) == NULL &&
//            !rtmGetStopRequested(RT_MDL)) {
// 
// //         rtExtModePauseIfNeeded(rtmGetRTWExtModeInfo(RT_MDL),
// //                                NUMST,
// //                                (boolean_T *)&rtmGetStopRequested(RT_MDL));
// 
//         if (rtmGetStopRequested(RT_MDL)) break;
// 
//         /* external mode */
//         rtExtModeOneStep(rtmGetRTWExtModeInfo(RT_MDL),
//                          NUMST,
//                          (boolean_T *)&rtmGetStopRequested(RT_MDL));
//         
//         rt_OneStep();
//     }
    rtExtModeC6000Startup(rtmGetRTWExtModeInfo(RT_MDL),
                          NUMST,
                          (boolean_T *)&rtmGetStopRequested(RT_MDL));
    BIOS_start();

}
示例#6
0
int main(void)
{
  volatile boolean_T runModel = 1;
  float modelBaseRate = 0.01;
  float systemClock = 168;

#ifndef USE_RTX

  __disable_irq();

#endif

  ;
  stm32f4xx_init_board();
  SystemCoreClockUpdate();
  bootloaderInit();
  rtmSetErrorStatus(BeschleunigungsAuswertung_M, 0);

  /* initialize external mode */
  rtParseArgsForExtMode(0, NULL);
  BeschleunigungsAuswertung_initialize();
  __enable_irq();

  /* External mode */
  rtSetTFinalForExtMode(&rtmGetTFinal(BeschleunigungsAuswertung_M));
  rtExtModeCheckInit(1);

  {
    boolean_T rtmStopReq = false;
    rtExtModeWaitForStartPkt(BeschleunigungsAuswertung_M->extModeInfo, 1,
      &rtmStopReq);
    if (rtmStopReq) {
      rtmSetStopRequested(BeschleunigungsAuswertung_M, true);
    }
  }

  rtERTExtModeStartMsg();
  __disable_irq();
  ARMCM_SysTick_Config(modelBaseRate);
  runModel =
    (rtmGetErrorStatus(BeschleunigungsAuswertung_M) == (NULL)) &&
    !rtmGetStopRequested(BeschleunigungsAuswertung_M);
  __enable_irq();
  __enable_irq();
  while (runModel) {
    /* External mode */
    {
      boolean_T rtmStopReq = false;
      rtExtModeOneStep(BeschleunigungsAuswertung_M->extModeInfo, 1, &rtmStopReq);
      if (rtmStopReq) {
        rtmSetStopRequested(BeschleunigungsAuswertung_M, true);
      }
    }

    runModel =
      (rtmGetErrorStatus(BeschleunigungsAuswertung_M) == (NULL)) &&
      !rtmGetStopRequested(BeschleunigungsAuswertung_M);
  }

  rtExtModeShutdown(1);

#ifndef USE_RTX

  (void)systemClock;

#endif

  ;

  /* Disable rt_OneStep() here */

  /* Terminate model */
  BeschleunigungsAuswertung_terminate();
  __disable_irq();
  return 0;
}