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; }
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; }
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; }
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; }
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; }