esp-open-rtos/examples/simple/main.c
Angus Gratton c09167715e Indentation fixes
- Fix dir-locals so emacs won't inject occasional tabs to case statements.
- Fix stray tab indentation in example programs. (Thx @pfalcon for pointing this out)
2015-06-09 09:00:32 +10:00

44 lines
1.1 KiB
C

/* Very basic example that just demonstrates we can run at all!
*/
#include "espressif/esp_common.h"
#include "espressif/sdk_private.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
void task1(void *pvParameters)
{
xQueueHandle *queue = (xQueueHandle *)pvParameters;
printf("Hello from task1!\r\n");
uint32_t count = 0;
while(1) {
vTaskDelay(100);
xQueueSend(*queue, &count, 0);
count++;
}
}
void task2(void *pvParameters)
{
printf("Hello from task 2!\r\n");
xQueueHandle *queue = (xQueueHandle *)pvParameters;
while(1) {
uint32_t count;
if(xQueueReceive(*queue, &count, 1000)) {
printf("Got %d\n", count);
} else {
printf("No msg :(\n");
}
}
}
static xQueueHandle mainqueue;
void user_init(void)
{
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
printf("SDK version:%s\n", sdk_system_get_sdk_version());
mainqueue = xQueueCreate(10, sizeof(uint32_t));
xTaskCreate(task1, (signed char *)"tsk1", 256, &mainqueue, 2, NULL);
xTaskCreate(task2, (signed char *)"tsk2", 256, &mainqueue, 2, NULL);
}