void APP_Start(void) { #if PL_HAS_RTOS_TRACE if(RTOSTRC1_uiTraceStart()!=1) { for(;;){} /* failure? */ } #endif #if PL_HAS_RADIO RNETA_Init(); #endif SHELL_Init(); if (FRTOS1_xTaskCreate( MainTask, /* pointer to the task */ "Main", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE+500, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){} /* error! probably out of memory */ /*lint +e527 */ } timerHndl = xTimerCreate("timer0", TIMER_PERIOD_MS/portTICK_RATE_MS, pdTRUE, (void *)0, vTimerCallback); if (timerHndl==NULL) { for(;;); /* failure! */ } if (xTimerStart(timerHndl, 0)!=pdPASS) { for(;;); /* failure! */ } FRTOS1_vTaskStartScheduler(); }
void APP_Run(void) { appState = APP_STATE_INIT; MOT_Init(); SHELL_Init(); #if PL_HAS_LINE_SENSOR REF_Init(); LF_Init(); TURN_Init(); #endif #if PL_HAS_ULTRASONIC US_Init(); #endif #if PL_HAS_BUZZER BUZ_Init(); #endif #if PL_HAS_EVENTS EVNT_Init(); #endif #if PL_HAS_RADIO RADIO_Init(); #endif #if PL_HAS_REMOTE REMOTE_Init(); #endif #if PL_HAS_QUEUE QUEUE_Init(); #endif if (FRTOS1_xTaskCreate(MainTask, (signed portCHAR *)"Main", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;){} /* error */ } FRTOS1_vTaskStartScheduler(); }
/*! \brief Initialization of the module */ void TRACE_Init(void) { #if PL_HAS_ACCEL traceAccel = FALSE; #endif #if PL_HAS_FREEMASTER traceChannel = TRACE_TO_SHELL; /* just that we read the accelerometer values */ traceAccel = TRUE; #else traceChannel = TRACE_TO_NONE; #endif #if PL_HAS_MOTOR traceMotor = FALSE; #endif #if PL_HAS_ACCEL traceAccel = FALSE; #endif #if PL_HAS_MOTOR_TACHO traceTacho = FALSE; #endif #if PL_HAS_QUADRATURE traceQuad = FALSE; #endif if (FRTOS1_xTaskCreate(TraceTask, "Trace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;) {} /* error, maybe not enough memory? */ } }
/*! \brief Initializes module */ void SEM_Init(void) { #if USE_SEMAPHORES if (FRTOS1_xTaskCreate(vMasterTask, "Master", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;){} /* error */ } #endif }
void REF_Init(void) { refState = REF_STATE_INIT; timerHandle = RefCnt_Init(NULL); /*! \todo You might need to adjust priority or other task settings */ if (FRTOS1_xTaskCreate(ReflTask, "Refl", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} /* error */ } }
void SHELL_Init(void) { FSSH1_Init(); /* create mutex/semaphore */ #if PL_HAS_RTOS if (FRTOS1_xTaskCreate(ShellTask, (signed portCHAR *)"Shell", configMINIMAL_STACK_SIZE+150, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;){} /* error */ } #endif }
/*! \brief Initializes module */ void SEM_Init(void) { /*! \todo Implement functionality */ #if 0 if (FRTOS1_xTaskCreate(vMasterTask, "Master", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} /* error */ } #endif }
void APP_Start(void) { NEO_Init(); SHELL_Init(); if (FRTOS1_xTaskCreate(AppTask, "App", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+2, NULL) != pdPASS) { for(;;){} /* error */ } FRTOS1_vTaskStartScheduler(); }
void APPFRDM_Init(void) { if (FRTOS1_xTaskCreate(T3, (signed portCHAR *)"T3", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} } }
void BLEUART_CMDMODE_Init(void) { txBuffer[0] = '\0'; isConnected = FALSE; isEnabled = FALSE; if (FRTOS1_xTaskCreate(BleUartTask, "BleUart", configMINIMAL_STACK_SIZE+100, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;){} /* error */ } }
void StateMachine_Init(void) { //refState = REF_STATE_INIT; //timerHandle = RefCnt_Init(NULL); /*! \todo You might need to adjust priority or other task settings */ DRV_EnableDisable(0); if (FRTOS1_xTaskCreate(StateMachineTask, "StateMachine", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} /* error */ } }
void RTOS_Init(void) { static const int led1 = 1; static const int led2 = 2; EVNT_SetEvent(EVNT_STARTUP); /* set startup event */ /*! \todo Create tasks here */ if (FRTOS1_xTaskCreate(AppTask, (signed portCHAR *)"App1", configMINIMAL_STACK_SIZE, (void*)&led1, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} /* error case only, stay here! */ } #if 0 if (FRTOS1_xTaskCreate(AppTask, (signed portCHAR *)"App2", configMINIMAL_STACK_SIZE, (void*)&led2, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} /* error case only, stay here! */ } if (FRTOS1_xTaskCreate(KillMe, (signed portCHAR *)"KillMe", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} /* error case only, stay here! */ } #endif }
/*lint -save -e970 Disable MISRA rule (6.3) checking. */ int main(void) /*lint -restore Enable MISRA rule (6.3) checking. */ { /* Write your local variable definition here */ /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/ if (FRTOS1_xTaskCreate( Task1, /* pointer to the task */ (signed portCHAR *)"Task1", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){}; /* error! probably out of memory */ /*lint +e527 */ } if (FRTOS1_xTaskCreate( Task2, /* pointer to the task */ (signed portCHAR *)"Task2", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){}; /* error! probably out of memory */ /*lint +e527 */ } /*** Don't write any code pass this line, or it will be deleted during code generation. ***/ /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/ #ifdef PEX_RTOS_START PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */ #endif /*** End of RTOS startup code. ***/ /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/ for(;;){} /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/ } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
void SHELL_Init(void) { #if !CLS1_DEFAULT_SERIAL && PL_HAS_BLUETOOTH (void)CLS1_SetStdio(&BT_stdio); /* use the Bluetooth stdio as default */ #endif #if PL_HAS_RTOS if (FRTOS1_xTaskCreate(ShellTask, "Shell", configMINIMAL_STACK_SIZE+100, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;){} /* error */ } #endif }
/*! \brief Initializes module */ void REMOTE_Init(void) { REMOTE_isOn = FALSE; REMOTE_isVerbose = FALSE; REMOTE_useJoystick = TRUE; #if PL_CONFIG_CONTROL_SENDER if (FRTOS1_xTaskCreate(RemoteTask, "Remote", configMINIMAL_STACK_SIZE+50, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} /* error */ } #endif }
void ACCEL_StartOrientationTask(void) { #if PL_HAS_HW_ACCELEROMETER ACCEL1_CalibrateZ1g(); /* assume device is flat during reset/power-up */ //ACCEL1_CalibrateX1g(); /* flat on switch side */ //ACCEL1_CalibrateY1g(); /* flat on LCD side */ #endif #if PL_HAS_ACCEL_ORIENT FRTOS1_xTaskCreate(TaskAccelOrientation, (signed portCHAR *)"AccelOrient", configMINIMAL_STACK_SIZE+50, NULL, tskIDLE_PRIORITY+1, &xHandleTaskAccelOrientation); #endif }
void REF_Init(void) { mutexHandle = FRTOS1_xSemaphoreCreateMutex(); if (mutexHandle==NULL) { for(;;); } timerHandle = TU1_Init(NULL); InitSensorValues(); if (FRTOS1_xTaskCreate(ReflTask, (signed portCHAR *)"Refl", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;){} /* error */ } }
void HOST_Init(void) { #if ONLY_HOST FsMSD1_HostInit(); HOST_Run(); #else FsMSD1_HostInit(); if (FRTOS1_xTaskCreate(HostTask, (signed portCHAR *)"Host", configMINIMAL_STACK_SIZE+100, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;){} /* error */ } #endif }
void PLR_Init(void) { //feedSem = FRTOS1_xSemaphoreCreateRecursiveMutex(); blinky_light_ClrVal(); if (FRTOS1_xTaskCreate(playerTask, "Player", configMINIMAL_STACK_SIZE+200, NULL, tskIDLE_PRIORITY+3, NULL) != pdPASS) { for (;;) { } /* error */ } //FRTOS1_vQueueAddToRegistry(feedSem, "feedSem"); }
void main(void) { /* Write your local variable definition here */ PEX_RTOS_INIT(); /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/ if (FRTOS1_xTaskCreate( Task1, /* pointer to the task */ (signed portCHAR *)"Task1", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){}; /* error! probably out of memory */ /*lint +e527 */ } if (FRTOS1_xTaskCreate( Task2, /* pointer to the task */ (signed portCHAR *)"Task2", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){}; /* error! probably out of memory */ /*lint +e527 */ } FRTOS1_vTaskStartScheduler(); /*** Don't write any code pass this line, or it will be deleted during code generation. ***/ /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/ for(;;){} /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/ } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
void APP_Run(void) { if (FRTOS1_xTaskCreate(MainTask, (signed portCHAR *)"Main", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} /* error */ } //(void)RTOSTICK1_Enable(); //FRTOS1_taskENABLE_INTERRUPTS(); for(;;) { LED1_Neg(); WAIT1_Waitms(1000); } FRTOS1_vTaskStartScheduler(); }
/*! \brief Function for starting the Application. Inits and Start the RTOS */ void APP_Start(void) { PL_Init(); /* platform initialization */ EVNT_SetEvent(EVNT_INIT); /* set initial event */ //Create application Task if (FRTOS1_xTaskCreate(APPTask, (signed portCHAR *)"APP_Task", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} /* error */ } RTOS_Run(); }
void RTOS_Init(void) { if (FRTOS1_xTaskCreate(T1, (signed portCHAR *)"T1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} /* error */ } if (FRTOS1_xTaskCreate(App_loop, (signed portCHAR *)"App_loop", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} /* error */ } #if PL_HAS_LINE_SENSOR if (FRTOS1_xTaskCreate(CheckReflactance, (signed portCHAR *)"CheckReflactance", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, &checkRefl) != pdPASS) { for(;;){} /* error */ } #endif #if PL_HAS_REMOTE if (FRTOS1_xTaskCreate(Remote, (signed portCHAR *)"Remote", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, &remoteTask) != pdPASS) { for(;;){} /* error */ } #endif #if PL_HAS_FIGHT if(FRTOS1_xTaskCreate(Fight_modus,(signed portCHAR *) "Fight_m", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, &fightTask) != pdPASS) { for(;;){} /* error */ } #endif #if PL_HAS_ACCEL && PL_IS_ROBO if(FRTOS1_xTaskCreate(AccelObserv,(signed portCHAR *) "AccelObserv", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) { for(;;){} /* error */ } #endif }
void RTOS_Start(void) { if (FRTOS1_xTaskCreate( MyTask, /* pointer to the task */ (signed portCHAR *)"MyTask", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { for(;;){}; /* error! probably out of memory */ } FRTOS1_vTaskStartScheduler(); }
void PONG_Init(void) { if (FRTOS1_xTaskCreate( PongTask, /* pointer to the task */ "Pong", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY+2, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){}; /* error! probably out of memory */ /*lint +e527 */ } }
void MM_Init(void) { if (FRTOS1_xTaskCreate( MidiPlayTask, /* pointer to the task */ "MidiPlay", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY+1, /* initial priority */ &MidiPlayTaskHandle /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){} /* error! probably out of memory */ /*lint +e527 */ } }
void SHELL_Init(void) { #if PL_HAS_RTOS_TRACE Ptrc1_vTraceSetQueueName(CLS1_GetSemaphore(), "Shell_Sem"); #endif #if !PL_HAS_RTOS buf[0] = '\0'; (void)CLS1_ParseWithCommandTable((unsigned char*)CLS1_CMD_HELP, CLS1_GetStdio(), CmdParserTable); #endif #if PL_HAS_RTOS if (FRTOS1_xTaskCreate(ShellTask, (signed portCHAR *)"Shell", configMINIMAL_STACK_SIZE+200, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;) {} /* error */ } #endif }
static portTASK_FUNCTION(vMasterTask, pvParameters) { /*! \todo Implement functionality */ xSemaphoreHandle sem = NULL; (void)pvParameters; /* parameter not used */ sem = FRTOS1_xSemaphoreCreateBinary(); if (sem==NULL) { /* semaphore creation failed */ for(;;){} /* error */ } FRTOS1_vQueueAddToRegistry(sem, "IPC_Sem"); /* create slave task */ if (FRTOS1_xTaskCreate(vSlaveTask, "Slave", configMINIMAL_STACK_SIZE, sem, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;){} /* error */ } if (FRTOS1_xTaskCreate(vSlaveTask2, "Slave", configMINIMAL_STACK_SIZE, sem, tskIDLE_PRIORITY+2, NULL) != pdPASS) { for(;;){} /* error */ } for(;;) { if (sem != NULL) { /* valid semaphore? */ (void)xSemaphoreGive(sem); /* give control to other task */ FRTOS1_vTaskDelay(1000/portTICK_RATE_MS); } } }
void DRV_Init(void) { DRV_Status.mode = DRV_MODE_NONE; DRV_Status.speed.left = 0; DRV_Status.speed.right = 0; DRV_Status.pos.left = 0; DRV_Status.pos.right = 0; DRV_Queue = FRTOS1_xQueueCreate(QUEUE_LENGTH, QUEUE_ITEM_SIZE); if (DRV_Queue==NULL) { for(;;){} /* out of memory? */ } FRTOS1_vQueueAddToRegistry(DRV_Queue, "Drive"); if (FRTOS1_xTaskCreate(DriveTask, "Drive", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+3, NULL) != pdPASS) { for(;;){} /* error */ } }
void ACCEL_StartDemoTask(ACCEL_WindowDesc *desc) { UI1_PixelDim yPos, h; UI1_CreateScreen(&desc->screen, UI1_COLOR_WHITE); (void)UI1_CreateWindow(&desc->screen, &desc->window, UI1_COLOR_BRIGHT_GREEN, 0, 0, UI1_GetWidth(), UI1_GetHeight()); (void)UI1_CreateHeader(&desc->window, &desc->header, (unsigned char*)"Accelerometer", FONT, UI1_COLOR_BLUE); UI1_ChangeTextFgColor(&desc->header.element, UI1_COLOR_WHITE); UI1_SetWindowEventCallback(&desc->window, accelW_WindowCallback); /* Icon: Close */ h = (UI1_PixelDim)(UI1_GetElementHeight(&desc->header)); (void)UI1_CreateIcon(&desc->window, &desc->iconClose, 1, 1, (UI1_PixelDim)(h-2), (UI1_PixelDim)(h-2), UI1_ICON_CLOSE); desc->iconClose.element.prop.flags |= UI1_FLAGS_ALIGN_RIGHT; UI1_OnWindowResize(&desc->window); /* right align element(s) if needed */ UI1_ChangeElementColor(&desc->iconClose, UI1_COLOR_BLUE); UI1_ChangeIconFgColor(&desc->iconClose, UI1_COLOR_WHITE); UI1_EnableElementSelection(&desc->iconClose); yPos = (UI1_PixelDim)(UI1_GetElementPosY(&desc->window)+UI1_GetElementHeight(&desc->header)+5); /* barGraph */ desc->data[0] = 0; desc->data[1] = 0; desc->data[2] = 0; (void)UI1_CreateBarGraph(&desc->window, &desc->accelBarGraph, 5, yPos, 170, 170, UI1_COLOR_BRIGHT_GREEN, (byte*)&desc->data, sizeof(desc->data), UI1_COLOR_RED, /* bar color */ 1, /* border width */ UI1_COLOR_BLACK, /* border color */ 5 /* border space */ ); yPos = (UI1_PixelDim)(UI1_GetElementPosY(&desc->accelBarGraph)+UI1_GetElementHeight(&desc->accelBarGraph)+5); /* X */ desc->txtBufX[0] = '\0'; (void)UI1_CreateText(&desc->window, &desc->txtX, 5, yPos, 0, 0, &desc->txtBufX[0], FONT); /* Y */ desc->txtBufY[0] = '\0'; (void)UI1_CreateText(&desc->window, &desc->txtY, 58, yPos, 0, 0, &desc->txtBufY[0], FONT); /* Z */ desc->txtBufZ[0] = '\0'; (void)UI1_CreateText(&desc->window, &desc->txtZ, 110, yPos, 0, 0, &desc->txtBufZ[0], FONT); UIG1_CreateGraph(&desc->window, &desc->graph, (UI1_PixelDim)(UI1_GetElementPosX(&desc->accelBarGraph)+UI1_GetElementWidth(&desc->accelBarGraph)+10), UI1_GetElementPosY(&desc->accelBarGraph), 125, UI1_GetElementHeight(&desc->accelBarGraph)); /* update the screen */ UI1_UpdateScreen(&desc->screen); FRTOS1_xTaskCreate(TaskAccelDemo, (signed portCHAR *)"Accel", configMINIMAL_STACK_SIZE+50, desc, tskIDLE_PRIORITY+1, NULL); }