esp-open-rtos/examples/simple/simple.c

45 lines
1.1 KiB
C
Raw Permalink Normal View History

/* Very basic example that just demonstrates we can run at all!
*/
#include "espressif/esp_common.h"
#include "esp/uart.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
void task1(void *pvParameters)
{
2016-11-05 10:04:03 +00:00
QueueHandle_t *queue = (QueueHandle_t *)pvParameters;
printf("Hello from task1!\r\n");
2015-05-06 09:10:08 +00:00
uint32_t count = 0;
while(1) {
vTaskDelay(100);
xQueueSend(*queue, &count, 0);
count++;
}
}
void task2(void *pvParameters)
{
printf("Hello from task 2!\r\n");
2016-11-05 10:04:03 +00:00
QueueHandle_t *queue = (QueueHandle_t *)pvParameters;
while(1) {
uint32_t count;
if(xQueueReceive(*queue, &count, 1000)) {
printf("Got %u\n", count);
} else {
printf("No msg :(\n");
}
}
}
2016-11-05 10:04:03 +00:00
static QueueHandle_t mainqueue;
void user_init(void)
{
uart_set_baud(0, 115200);
printf("SDK version:%s\n", sdk_system_get_sdk_version());
2015-05-06 09:10:08 +00:00
mainqueue = xQueueCreate(10, sizeof(uint32_t));
2016-10-21 09:40:36 +00:00
xTaskCreate(task1, "tsk1", 256, &mainqueue, 2, NULL);
xTaskCreate(task2, "tsk2", 256, &mainqueue, 2, NULL);
}