/* The example of esp-free-rtos
*
* This sample code is in the public domain.
*/
#include <stdlib.h>
#include <string.h>
#include "espressif/esp_common.h"
#include "esp/uart.h"
#include "FreeRTOS.h"
#include "task.h"
#include "esp8266.h"
static TaskHandle_t xTask1 = NULL, xTask2 = NULL;
void task1(void *pvParameters)
{
TickType_t nowTick;
nowTick = xTaskGetTickCount();
printf("[%s:%d]
Start\n",pcTaskGetName(0),nowTick);
while(1) {
// delay 1000mSec
vTaskDelay(1000 /
portTICK_PERIOD_MS);
/* Send a notification to
prvTask2(), bringing it out of the Blocked
state. */
xTaskNotifyGive( xTask2 );
nowTick =
xTaskGetTickCount();
printf("[%s:%d]
xTaskNotifyGive\n",pcTaskGetName(0),nowTick);
/* Block to wait for
prvTask2() to notify this task. */
ulTaskNotifyTake( pdTRUE,
portMAX_DELAY );
nowTick =
xTaskGetTickCount();
printf("[%s:%d]
ulTaskNotifyTake\n\n",pcTaskGetName(0),nowTick);
}
}
void task2(void *pvParameters)
{
TickType_t nowTick;
nowTick = xTaskGetTickCount();
printf("[%s:%d]
Start\n",pcTaskGetName(0),nowTick);
while(1) {
/* Block to wait for
prvTask2() to notify this task. */
ulTaskNotifyTake( pdTRUE,
portMAX_DELAY );
nowTick =
xTaskGetTickCount();
printf("[%s:%d]
ulTaskNotifyTake\n",pcTaskGetName(0),nowTick);
// delay 1000mSec
vTaskDelay(1000 /
portTICK_PERIOD_MS);
/* Send a notification to
prvTask2(), bringing it out of the Blocked
state. */
xTaskNotifyGive( xTask1 );
nowTick =
xTaskGetTickCount();
printf("[%s:%d]
xTaskNotifyGive\n",pcTaskGetName(0),nowTick);
}
}
void user_init(void)
{
uart_set_baud(0, 115200);
printf("SDK version:%s\n",
sdk_system_get_sdk_version());
printf("pcTaskGetName=%s\n",pcTaskGetName(0));
xTaskCreate(task1, "task1", 256, NULL,
2, &xTask1);
xTaskCreate(task2, "task2", 256, NULL,
2, &xTask2);
}
|