zoukankan      html  css  js  c++  java
  • [FreeRTOS]软件定时器

    FreeRTOS 定时器基本使用

    软件定时器本质上是一个周期性的task

    配置

    使用软件定时器需要在FreeRTOSConfig.h先配置, 需要注意的是优先级和堆栈

    #define configUSE_TIMERS             1
    #define configTIMER_TASK_PRIORITY    (1)
    #define configTIMER_QUEUE_LENGTH     10
    #define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
    

    创建定时器

    • 函数原型
    xTimerHandle xTimerCreate( 	const signed char *pcTimerName,
                                portTickType xTimerPeriodInTicks,
                                unsigned portBASE_TYPE uxAutoReload,
                                void * pvTimerID,
                                tmrTIMER_CALLBACK pxCallbackFunction );
    
    - pcTimerName           : 任务名
    - xTimerPeriodInTicks   : 定时周期
    - uxAutoReload          : pdTRUE, 自动重载; pdFALSE, 一次性
    - pvTimerID             :
    - pxCallbackFunction    : 回调函数
    
    • 使用
    xTimerMain = xTimerCreate("TimerMain", (1000*30 / portTICK_RATE_MS), pdTRUE, (void *)0, MainCallback);`
    

    启动定时器

    #define xTimerStart( xTimer, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xBlockTime ) )
    
    • 使用
    xTimerStart( xTimerMain, 0 );
    

    Good Good Study! Day Day Up!

  • 相关阅读:
    pexpect模块
    Python正则表达式
    telnetlib
    paramiko
    threadpool和Queue
    logging
    Python异常
    Python迭代器
    程序员工资那么高,却从不炫富?网友回复让人“笑喷了”!
    小白到web前端工程师需要学习哪些知识?
  • 原文地址:https://www.cnblogs.com/kdurant/p/4174347.html
Copyright © 2011-2022 走看看