2015-04-30 04:00:03 +00:00
|
|
|
/* Very basic example that just demonstrates we can run at all!
|
|
|
|
*/
|
2015-06-02 05:20:19 +00:00
|
|
|
#include "espressif/esp_common.h"
|
|
|
|
#include "espressif/sdk_private.h"
|
2015-04-30 04:00:03 +00:00
|
|
|
#include "FreeRTOS.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "queue.h"
|
|
|
|
|
|
|
|
void task1(void *pvParameters)
|
|
|
|
{
|
|
|
|
xQueueHandle *queue = (xQueueHandle *)pvParameters;
|
|
|
|
printf("Hello from task1!\r\n");
|
2015-05-06 09:10:08 +00:00
|
|
|
uint32_t count = 0;
|
2015-04-30 04:00:03 +00:00
|
|
|
while(1) {
|
2015-06-08 23:00:32 +00:00
|
|
|
vTaskDelay(100);
|
|
|
|
xQueueSend(*queue, &count, 0);
|
|
|
|
count++;
|
2015-04-30 04:00:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void task2(void *pvParameters)
|
|
|
|
{
|
|
|
|
printf("Hello from task 2!\r\n");
|
|
|
|
xQueueHandle *queue = (xQueueHandle *)pvParameters;
|
|
|
|
while(1) {
|
2015-06-08 23:00:32 +00:00
|
|
|
uint32_t count;
|
|
|
|
if(xQueueReceive(*queue, &count, 1000)) {
|
2015-08-05 03:58:09 +00:00
|
|
|
printf("Got %lu\n", count);
|
2015-06-08 23:00:32 +00:00
|
|
|
} else {
|
|
|
|
printf("No msg :(\n");
|
|
|
|
}
|
2015-04-30 04:00:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static xQueueHandle mainqueue;
|
|
|
|
|
|
|
|
void user_init(void)
|
|
|
|
{
|
2015-06-02 07:57:33 +00:00
|
|
|
sdk_uart_div_modify(0, UART_CLK_FREQ / 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));
|
2015-04-30 04:00:03 +00:00
|
|
|
xTaskCreate(task1, (signed char *)"tsk1", 256, &mainqueue, 2, NULL);
|
|
|
|
xTaskCreate(task2, (signed char *)"tsk2", 256, &mainqueue, 2, NULL);
|
|
|
|
}
|