#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/gpio.h" #define LED_RED GPIO_NUM_2 #define LED_GREEN GPIO_NUM_4 QueueHandle_t xQueue; void getQueueValue(void *pvParameter) { int32_t value_to_recieve; BaseType_t xStatusRecieve; //const TickType_t xTicksToWait = pdMS_TO_TICKS( 50 ); gpio_num_t red_led = LED_RED ; //uint8_t led_value = 0; //gpio_reset_pin(red_led); gpio_set_direction(red_led, GPIO_MODE_OUTPUT); for(;;){ //led_value = 1; gpio_set_level(red_led, 1); xStatusRecieve = xQueueReceive(xQueue, &value_to_recieve, 0); //printf("%d get value task \n",uxTaskGetStackHighWaterMark(NULL)); //if(xStatusRecieve != pdPASS){ // printf("cant get value \n"); //} //else{ //printf("value recieved is %d \n",value_to_recieve); //} //led_value = 0; gpio_set_level(red_led, 0); vTaskDelay(pdMS_TO_TICKS(200)); } } void putQueueValue(void *pvParameters) { int32_t value_to_send = (int32_t ) pvParameters; //value_to_send = (int32_t) pvParameters ; BaseType_t xStatusSend; //TickType_t xTicksToWait = 1000; gpio_num_t green_led = LED_GREEN ; //uint8_t led_value = 0; //gpio_reset_pin(green_led); gpio_set_direction(green_led, GPIO_MODE_OUTPUT); for(;;){ gpio_set_level(green_led, 1); xStatusSend = xQueueSendToBack(xQueue,&value_to_send,0); gpio_set_level(green_led, 0); vTaskDelay(pdMS_TO_TICKS(1000)); } } extern "C" void app_main() //void app_main(void) //requires setup- and loop function { xQueue = xQueueCreate(1,sizeof(int32_t)); if (xQueue != NULL){ xTaskCreate(putQueueValue,"Sender",2048,(void*)100 , 1,NULL); xTaskCreate(getQueueValue,"Reciever",2048,NULL,1,NULL); } else{ printf("not enough space"); } }