I want to create a task with push button and the task sends a string to a queue and creates another task (this can also be separate task with lower priority) which reads the queue and blink led if its variable is same with the string in the queue. Otherwise system should stay in the idle mode. Im quite new with freertos and Led doesnot blink with below codes eventhough there is no compilation error. I also want to replace the datatype from char to string if it is possible. (select and zyRxBuff come from different sources, it is written as below for simplicity)
#include "main.h"
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "queue.h"
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
The handlers ;
QueueHandle_t myQueue = NULL;
TaskHandle_t QTASK1 = NULL;
TaskHandle_t QTASK2 = NULL;
Prototypes ;
void Qsender(void* p);
void Qreceiver(void* p);
Main block;
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
if (HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) == GPIO_PIN_SET)
{
xTaskCreate(Qsender, "SendingTask", 200, NULL, 1, &QTASK1);
vTaskStartScheduler();
}
while (1) {};
}
Sender Function;
void Qsender(void* p)
{
char select[10]= "BlinkLed";
myQueue = xQueueCreate(1, sizeof(select));
xQueueSend(myQueue, (void*) &select, (TickType_t)10);
if (myQueue != 0)
{
xTaskCreate(Qreceiver, "ReceivingTask", 200, NULL, 1, &QTASK2);
}
}
Receiver Function;
void Qreceiver(void* p)
{
char myRxBuff[10];
char zyRxBuff[10]="BlinkLed";
xQueueReceive(myQueue, &myRxBuff, (TickType_t)50);
if ( myRxBuff == zyRxBuff)
{
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
HAL_Delay(500);
}
}
Idle function;
void vApplicationIdleHook(void){__WFI();};