#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
void vTaskFunction( void * pvParameters );
const char * pcTextForTask1 = "Task 1 is running\n";
const char * pcTextForTask2 = "Task 2 is running\n";
void app_main( void )
{
BaseType_t t1, t2;
vTaskDelay(1000 / portTICK_PERIOD_MS);
t1 = xTaskCreate( vTaskFunction, /* Pointer to the function that implements the task. */
"Task 1", /* Text name for the task. This is to facilitate debugging only. */
2048, /* Stack depth - most small microcontrollers will use much less stack than this. */
( void * ) pcTextForTask1, /* Pass the text to be printed in as the task parameter. */
2, /* This task will run at priority 1. */
NULL ); /* We are not using the task handle. */
if (t1 == pdPASS) {
printf("Task 1 created\n");
} else {
printf("Task 1 create failed: %d\n", t1);
}
t2 = xTaskCreate( vTaskFunction, "Task 2", 2048, ( void * ) pcTextForTask2, 3, NULL );
if (t2 == pdPASS) {
printf("Task 2 created\n");
} else {
printf("Task 2 create failed: %d\n", t2);
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
// vTaskStartScheduler();
for( ; ; )
{
vTaskDelay(portMAX_DELAY);
// vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
/*-----------------------------------------------------------*/
void vTaskFunction( void * pvParameters )
{
// char * pcTaskName;
// pcTaskName = ( char * ) pvParameters;
const char *pcTaskName = (const char *) pvParameters;
for( ; ; )
{
// vPrintString( pcTaskName );
// printf(pcTaskName);
printf("%s", pcTaskName);
fflush(stdout);
// vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}