RTOS(4)自己的第一个FreeRTOS程序

创建两个任务

什么是任务呢?
对于整个单片机程序,我们称之为application,应用程序。
使用FreeRTOS时,我们可以在application中创建多个任务(task),有些文档把任务也称为线程
(thread)。
在这里插入图片描述

void Task1Function(void *param)
{
    
    
	while(1)
	{
    
    
		printf("1");
	}
}

void Task2Function(void *param)
{
    
    
	while(1)
	{
    
    
		printf("2");
	}
}


/*-----------------------------------------------------------*/

int main( void )
{
    
    
  TaskHandle_t XHandleTask1;
  TaskHandle_t XHandleTask2;

#ifdef DEBUG
  debug();
#endif

	prvSetupHardware();
	
	printf("Hello,world!\r\n");

	xTaskCreate(Task1Function,"task1",100,NULL,1,&XHandleTask1);
	xTaskCreate(Task2Function,"task2",100,NULL,1,&XHandleTask2);

	/* Start the scheduler. */
	vTaskStartScheduler();

	/* Will only get here if there was not enough heap space to create the
	idle task. */
	return 0;
}

作业:建立第三个任务:LED闪烁

FreeRTOS源码结构

在这里插入图片描述
Demo就是工程文件,命名方式就是芯片+编辑器;
Source是核心文件,包括列表队列什么的;

编程规范

这个编程规范只适用于FreeRTOS,不适用于其他的;

数据类型

在这里插入图片描述

变量名

在这里插入图片描述

函数名

在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_45636780/article/details/133883601