当前位置: 首页 > wzjs >正文

网站备案年限查询涿州网站建设

网站备案年限查询,涿州网站建设,广点通推广登录入口,阿里巴巴官网首页方块鱼饵一、简介 1、定时器介绍 2、软件定时器优缺点 3、FreeRTOS定时器特点 4、软件定时器相关配置 5、软件定时器的状态 6、单次定时器和周期定时器 1、举例 2、软件定时器状态转换图 二、 FreeRTOS软件定时器相关API函数 三、实验 1、代码 main.c #include "stm32f…

一、简介

1、定时器介绍

2、软件定时器优缺点

3、FreeRTOS定时器特点

4、软件定时器相关配置

5、软件定时器的状态 

6、单次定时器和周期定时器 

1、举例 

2、软件定时器状态转换图

 二、 FreeRTOS软件定时器相关API函数 

三、实验

1、代码

main.c 

#include "stm32f10x.h"
#include "FreeRTOS.h"
#include "task.h"
#include "freertos_demo.h"
#include "Delay.h"
#include "sys.h"
#include "usart.h"
#include "LED.h"
#include "Key.h"int main(void){	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);//设置系统中断优先级分组 4 uart_init(115200);	 delay_init();Key_Init();LED_Init();// 创建任务FrrrRTOS_Demo();}

freertos_demo.c

#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
#include "event_groups.h"
#include "LED.h"
#include "Key.h"
#include "usart.h"
#include "delay.h"void Timer1Callback( TimerHandle_t pxTimer );
void Timer2Callback( TimerHandle_t pxTimer );/******************************************************************任务配置****************************************************/
//任务优先级
#define START_TASK_PRIO					1
//任务堆栈大小	
#define START_TASK_STACK_SIZE 	128  
//任务句柄
TaskHandle_t StartTask_Handler;
//任务函数
void start_task(void *pvParameters);//任务优先级
#define TASK1_PRIO							2
//任务堆栈大小	
#define TASK1_STACK_SIZE 				128  
//任务句柄
TaskHandle_t Task1_Handler;
//任务函数
void task1(void *pvParameters);//任务优先级/******************************************************************任务函数****************************************************/
TimerHandle_t	Timer1_handle = 0;													//单次定时器
TimerHandle_t	Timer2_handle = 0;													//周期定时器void FrrrRTOS_Demo(void)
{//创建开始任务xTaskCreate((TaskFunction_t )start_task,            			//任务函数( char*         )"start_task",          			//任务名称(uint16_t       )START_TASK_STACK_SIZE, 			//任务堆栈大小(void*          )NULL,                  			//传递给任务函数的参数(UBaseType_t    )START_TASK_PRIO,       			//任务优先级(TaskHandle_t*  )&StartTask_Handler);   			//任务句柄 // 启动任务调度vTaskStartScheduler();}void start_task(void *pvParameters)
{taskENTER_CRITICAL();           //进入临界区/**创建单次定时器**/Timer1_handle  = xTimerCreate( "timer1", 1000,pdFALSE,(void *)1,Timer1Callback);/**创建周期定时器**/		Timer2_handle  = xTimerCreate( "timer2", 1000,pdTRUE,(void *)1,Timer2Callback);	//创建1任务xTaskCreate((TaskFunction_t )task1,     	(const char*    )"task1",   	(uint16_t       )TASK1_STACK_SIZE, (void*          )NULL,				(UBaseType_t    )TASK1_PRIO,	(TaskHandle_t*  )&Task1_Handler); vTaskDelete(NULL); 							//删除开始任务taskEXIT_CRITICAL();            //退出临界区
}//1按键扫描并控制任务定时器
void task1(void *pvParameters)
{uint8_t				key = 0;while(1){key = Key_GetNum();if(key ==2){printf("开启定时器\r\n");xTimerStart(Timer1_handle,portMAX_DELAY);xTimerStart(Timer2_handle,portMAX_DELAY);}else if(key ==3){printf("关闭定时器\r\n");xTimerStop(Timer1_handle,portMAX_DELAY);xTimerStop(Timer2_handle,portMAX_DELAY);}vTaskDelay(10);}
}//timer1超时回调函数
void Timer1Callback( TimerHandle_t pxTimer )
{static uint32_t	timer = 0;printf("timer1的运行次数%d\r\n",++timer);
}//timer2超时回调函数
void Timer2Callback( TimerHandle_t pxTimer )
{static uint32_t	timer = 0;printf("timer2的运行次数%d\r\n",++timer);	}

key.c

#include "stm32f10x.h"                  // Device header
#include "FreeRTOS.h"
#include "task.h"
#include "usart.h"
#include "Delay.h"/*** 函    数:按键初始化* 参    数:无* 返 回 值:无* 按键:PB4/PB12/PB14*/
void Key_Init(void)
{GPIO_InitTypeDef GPIO_InitStructure;/*开启时钟*/RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);		//开启GPIOB的时钟/*GPIO初始化*/GPIO_InitStructure.GPIO_Mode 	= GPIO_Mode_IPU;GPIO_InitStructure.GPIO_Pin 	= GPIO_Pin_4 | GPIO_Pin_12 | GPIO_Pin_14;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_Init(GPIOB, &GPIO_InitStructure);						
}/*** 函    数:按键获取键码* 参    数:无* 返 回 值:按下按键的键码值,范围:0~3,返回0代表没有按键按下* 注意事项:此函数是阻塞式操作,当按键按住不放时,函数会卡住,直到按键松手*/
uint8_t Key_GetNum(void)
{uint8_t KeyNum = 0;																				//定义变量,默认键码值为0if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_4) == 0)			  //读PB4输入寄存器的状态,如果为0,则代表按键1按下{KeyNum= GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_4);delay_xms(20);																					//延时消抖while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_4) == 0);	//等待按键松手delay_xms(20);																					//延时消抖KeyNum = 1;																							//置键码为1}if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_12) == 0)			{KeyNum= GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_12);delay_xms(20);											while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_12) == 0);	delay_xms(20);									KeyNum = 2;											}if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_14) == 0)			{KeyNum= GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_14);delay_xms(20);											while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_14) == 0);	delay_xms(20);									KeyNum = 3;											}return KeyNum;																						//返回键码值,如果没有按键按下,所有if都不成立,则键码为默认值0
}

2、实验解析 

四、重点

 使用函数前,需要先将宏置1(默认是1)

#define configUSE_TIMERS                                 1

 创建软件定时函数:

TimerHandle_t   xTimerCreate(  const char * const             pcTimerName,                                                                                 const TickType_t             xTimerPeriodInTicks,                                                                       const UBaseType_t         uxAutoReload,                   

                                                   void * const                 pvTimerID,                                                                                             TimerCallbackFunction_t     pxCallbackFunction  );

 开启软件定时器函数: 

BaseType_t   xTimerStart(     TimerHandle_t     xTimer,               

                                                 const TickType_t     xTicksToWait  );

停止软件定时器函数:

BaseType_t   xTimerStop(  TimerHandle_t     xTimer,                 

                                                const TickType_t     xTicksToWait); 

复位软件定时器函数:

 BaseType_t  xTimerReset( TimerHandle_t     xTimer,               

                                             const TickType_t     xTicksToWait);

 更改软件定时器超时时间API函数 :

BaseType_t  xTimerChangePeriod( TimerHandle_t         xTimer,                         

                                                          const TickType_t     xNewPeriod,                                                                                               const TickType_t     xTicksToWait);

 


文章转载自:

http://l2HpEWgv.mttqp.cn
http://c0dA074S.mttqp.cn
http://IFceN0L3.mttqp.cn
http://hIxNr0Po.mttqp.cn
http://AVCbc0Cl.mttqp.cn
http://HF8IvnkR.mttqp.cn
http://S46BALfr.mttqp.cn
http://3LLNDVXW.mttqp.cn
http://8Du9B3s6.mttqp.cn
http://DhfvrXZ6.mttqp.cn
http://gwJRav89.mttqp.cn
http://x7kwI4Ek.mttqp.cn
http://2iDRSpNS.mttqp.cn
http://Q5bmQlUm.mttqp.cn
http://123vtABI.mttqp.cn
http://LsLsBudQ.mttqp.cn
http://KUk2t19P.mttqp.cn
http://tmbkVm6G.mttqp.cn
http://SLbQB7RT.mttqp.cn
http://Ze9ZJYqi.mttqp.cn
http://NtpMQvEw.mttqp.cn
http://u936Sq94.mttqp.cn
http://GMfIzpQn.mttqp.cn
http://PjWUx2Tg.mttqp.cn
http://I1TltGEE.mttqp.cn
http://JsR4zoNN.mttqp.cn
http://533o6IaJ.mttqp.cn
http://XcOKPXVd.mttqp.cn
http://emJtEtSA.mttqp.cn
http://Fmrgoknh.mttqp.cn
http://www.dtcms.com/wzjs/761712.html

相关文章:

  • 陕西交通建设集团西镇分公司网站手机网站模板网
  • 西安网站优化推广方案企业网站的设计论文
  • 网站后台修改图片集顺序wordpress 不做SEO
  • 咸阳专业网站建设wordpress 插件经验
  • 域名绑定网站高清视频网络服务器
  • 网站建设论文基础摘要微信订阅号做网站
  • 免费照片的网站模板免费下载wordpress建立php站点地图
  • 济南网站建设yigeseo怎么做外卖网站
  • 网站做以后怎么修改网站内容企业网站 单页
  • 网站开发需求表成都软件公司排名
  • 网站建设需要具备哪些知识北京专业做网站公司
  • 佛山制作网站公司吗汽车网站模板下载
  • 网站建设业务方法wordpress占用id
  • 网站代运营公司有哪些做网站的服务商
  • 用php做购物网站视频福田蒙派克g5
  • 更改网站logo地址怎么讲解网页的制作技术
  • 网站程序如何上传苏州网络推广公司服务平台
  • 做网站平台多少钱seo排名赚app官网
  • 中国备案查询网站wordpress沙盒框架
  • 浙江省建设厅新网站人员无法查询促销礼品网站建设
  • 网站建立需要哪些材料北京市城市建设档案馆网站
  • 如何提高网站关键词排名武清做网站的公司
  • 网站建设前 需要准备的做网站超链接
  • html5单页面网站军事网站模板下载
  • 建设商务网站ppt类似谷德设计网的网站
  • 开封市建设教育协会网站秀米编辑器
  • 电子商务网站的规划与建设论文app开发app制作公司
  • 中天建设网站wordpress安全插件对比
  • 销售网站建设推广网站建设毕业设计中期进度报告
  • dp抖音代运营太原seo管理