signed portBASE_TYPE MPU_xTaskGenericCreate( pdTASK_CODE pvTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions ) { signed portBASE_TYPE xReturn; portBASE_TYPE xRunningPrivileged = prvRaisePrivilege(); xReturn = xTaskGenericCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask, puxStackBuffer, xRegions ); portRESET_PRIVILEGE( xRunningPrivileged ); return xReturn; }
BaseType_t MPU_xTaskGenericCreate( TaskFunction_t pvTaskCode, const char * const pcName, uint16_t usStackDepth, void *pvParameters, UBaseType_t uxPriority, TaskHandle_t *pxCreatedTask, StackType_t *puxStackBuffer, const MemoryRegion_t * const xRegions ) { BaseType_t xReturn; BaseType_t xRunningPrivileged = prvRaisePrivilege(); xReturn = xTaskGenericCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask, puxStackBuffer, xRegions ); portRESET_PRIVILEGE( xRunningPrivileged ); return xReturn; }
BaseType_t xTimerCreateTimerTask( void ) { BaseType_t xReturn = pdFAIL; StaticTask_t *pxTimerTaskTCBBuffer = NULL; StackType_t *pxTimerTaskStackBuffer = NULL; uint16_t usTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; /* This function is called when the scheduler is started if configUSE_TIMERS is set to 1. Check that the infrastructure used by the timer service task has been created/initialised. If timers have already been created then the initialisation will already have been performed. */ prvCheckForValidListAndQueue(); if( xTimerQueue != NULL ) { #if( configSUPPORT_STATIC_ALLOCATION == 1 ) { vApplicationGetTimerTaskMemory( &pxTimerTaskTCBBuffer, &pxTimerTaskStackBuffer, &usTimerTaskStackSize ); } #endif /* configSUPPORT_STATIC_ALLOCATION */ #if ( INCLUDE_xTimerGetTimerDaemonTaskHandle == 1 ) { /* Create the timer task, storing its handle in xTimerTaskHandle so it can be returned by the xTimerGetTimerDaemonTaskHandle() function. */ xReturn = xTaskGenericCreate( prvTimerTask, "Tmr Svc", usTimerTaskStackSize, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, &xTimerTaskHandle, pxTimerTaskStackBuffer, pxTimerTaskTCBBuffer, NULL ); } #else { /* Create the timer task without storing its handle. */ xReturn = xTaskGenericCreate( prvTimerTask, "Tmr Svc", usTimerTaskStackSize, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, NULL, pxTimerTaskStackBuffer, pxTimerTaskTCBBuffer, NULL ); } #endif } else { mtCOVERAGE_TEST_MARKER(); } configASSERT( xReturn ); return xReturn; }
void ProgramManager::runManager(){ uint32_t ulNotifiedValue = 0; // TickType_t xMaxBlockTime = pdMS_TO_TICKS( 1000 ); TickType_t xMaxBlockTime = portMAX_DELAY; /* Block indefinitely. */ for(;;){ /* Block indefinitely (without a timeout, so no need to check the function's return value) to wait for a notification. Bits in this RTOS task's notification value are set by the notifying tasks and interrupts to indicate which events have occurred. */ xTaskNotifyWait(pdFALSE, /* Don't clear any notification bits on entry. */ UINT32_MAX, /* Reset the notification value to 0 on exit. */ &ulNotifiedValue, /* Notified value pass out in ulNotifiedValue. */ xMaxBlockTime ); if(ulNotifiedValue & STOP_PROGRAM_NOTIFICATION){ // stop audioStatus = AUDIO_EXIT_STATUS; codec.softMute(true); if(xProgramHandle != NULL){ programVector = &staticVector; vTaskDelete(xProgramHandle); xProgramHandle = NULL; } } // allow idle task to garbage collect if necessary vTaskDelay(20); // vTaskDelay(pdMS_TO_TICKS(200)); if(ulNotifiedValue & START_PROGRAM_NOTIFICATION){ // start PatchDefinition* def = getPatchDefinition(); if(xProgramHandle == NULL && def != NULL){ BaseType_t ret; if(def->getStackBase() != 0 && def->getStackSize() > configMINIMAL_STACK_SIZE*sizeof(portSTACK_TYPE)){ ret = xTaskGenericCreate(runProgramTask, "Program", def->getStackSize()/sizeof(portSTACK_TYPE), NULL, PROGRAM_TASK_PRIORITY, &xProgramHandle, def->getStackBase(), NULL); }else{ ret = xTaskCreate(runProgramTask, "Program", PROGRAM_TASK_STACK_SIZE, NULL, PROGRAM_TASK_PRIORITY, &xProgramHandle); } if(ret != pdPASS) setErrorMessage(PROGRAM_ERROR, "Failed to start program task"); } #ifdef BUTTON_PROGRAM_CHANGE }else if(ulNotifiedValue & PROGRAM_CHANGE_NOTIFICATION){ // program change if(xProgramHandle == NULL){ BaseType_t ret = xTaskCreate(programChangeTask, "Program Change", PC_TASK_STACK_SIZE, NULL, PC_TASK_PRIORITY, &xProgramHandle); if(ret != pdPASS) setErrorMessage(PROGRAM_ERROR, "Failed to start Program Change task"); } #endif /* BUTTON_PROGRAM_CHANGE */ }else if(ulNotifiedValue & PROGRAM_FLASH_NOTIFICATION){ // program flash BaseType_t ret = xTaskCreate(programFlashTask, "Flash Write", FLASH_TASK_STACK_SIZE, NULL, FLASH_TASK_PRIORITY, &xFlashTaskHandle); if(ret != pdPASS){ setErrorMessage(PROGRAM_ERROR, "Failed to start Flash Write task"); } }else if(ulNotifiedValue & ERASE_FLASH_NOTIFICATION){ // erase flash BaseType_t ret = xTaskCreate(eraseFlashTask, "Flash Erase", FLASH_TASK_STACK_SIZE, NULL, FLASH_TASK_PRIORITY, &xFlashTaskHandle); if(ret != pdPASS) setErrorMessage(PROGRAM_ERROR, "Failed to start Flash Erase task"); // }else if(ulNotifiedValue & MIDI_SEND_NOTIFICATION){ // erase flash // TaskHandle_t handle = NULL; // BaseType_t ret = xTaskCreate(sendMidiDataTask, "MIDI", PC_TASK_STACK_SIZE, NULL, PC_TASK_PRIORITY, &handle); // if(ret != pdPASS){ // setErrorMessage(PROGRAM_ERROR, "Failed to start MIDI Send task"); // } } } }