Hello Robin,
Please check the below example code and let me know if this helps!!
For this example I have 2 tasks ( MAIN_TASK and TASK_2 ) these task have different priority (MAIN_TASK priority 9 and TASK_2 priority 12)
both tasks have a while (1) but both tasks have a time_delay, this time_delay blocks the calling task.
#define MAIN_TASK 1
#define TASK_2 2
extern void Main_task(uint32_t);
extern void task_2(uint32_t);
TASK_TEMPLATE_STRUCT MQX_template_list[] =
{
/* Task number, Entry point, Stack, Pri, String, Auto? */
{MAIN_TASK, Main_task, 1500, 9, "main", MQX_AUTO_START_TASK},
{TASK_2, task_2, 1500, 12, "main", MQX_AUTO_START_TASK},
{0, 0, 0, 0, 0, 0, }
};
/*TASK*-----------------------------------------------------
*
* Task Name : Main_task
* Comments :
* This task prints " Hello World "
*
*END*-----------------------------------------------------*/
void Main_task(uint32_t initial_data)
{
printf("\n Hello World \n");
LWGPIO_STRUCT led1;
lwgpio_init(&led1, BSP_LED1, LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_NOCHANGE );
lwgpio_set_functionality(&led1, BSP_LED1_MUX_GPIO );
while (1)
{
_time_delay(10);
lwgpio_toggle_value(&led1);
}
printf("\n Hello World \n");
_mqx_exit(0);
}
void task_2(uint32_t initial_data)
{
printf("\n Hello World \n");
LWGPIO_STRUCT led2;
lwgpio_init(&led2, BSP_LED2, LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_NOCHANGE );
lwgpio_set_functionality(&led2, BSP_LED2_MUX_GPIO );
while (1)
{
_time_delay(5);
lwgpio_toggle_value(&led2);
}
printf("\n Hello World \n");
_mqx_exit(0);
}
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------