zoukankan      html  css  js  c++  java
  • CC2640R2F&TI-RTOS 拿到 TI CC2640R2F 开发板 第三件事就是使用 TI-RTOS 创建 一个任务 和 使用 信号量 超时来闪烁 LED灯

    /*
     * data_process.c
     *
     *  Created on: 2018年7月5日
     *      Author: admin
     */
    
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Clock.h>
    #include <ti/sysbios/knl/Event.h>
    #include <ti/sysbios/knl/Queue.h>
    #include <ti/sysbios/knl/Semaphore.h>
    
    
    #include "board_led.h"
    #include "board_uart.h"
    
    #include <ti/drivers/dpl/SemaphoreP.h>
    
    #include "data_process.h"
    
    // Task configuration
    #define LF_TASK_PRIORITY      1
    #define LF_TASK_STACK_SIZE   256
    
    // Task configuration
    Task_Struct lfTask;
    Char lfTaskStack[LF_TASK_STACK_SIZE];
    
    Semaphore_Handle semLedFicker;
    
    
    /*********************************************************************
     * @fn      LedFicker_createTask
     *
     * @brief   Task creation function for the led ficker.
     *
     * @param   None.
     *
     * @return  None.
     */
    void LedFicker_createTask(void)
    {
      Task_Params taskParams;
    
      // Configure task
      Task_Params_init(&taskParams);
      taskParams.stack = lfTaskStack;
      taskParams.stackSize = LF_TASK_STACK_SIZE;
      taskParams.priority  = LF_TASK_PRIORITY;
    
      Task_construct(&lfTask, LedFicker_taskFxn, &taskParams, NULL);
    }
    
    /*********************************************************************
     * @fn      LedFicker_taskFxn
     *
     * @brief   Application task entry point for the Led Ficker.
     *
     * @param   a0, a1 - not used.
     *
     * @return  None.
     */
    static void LedFicker_taskFxn(UArg a0, UArg a1)
    {
        Semaphore_Params semLedFickerParams;
    
        uint32_t timeoutInTicks = 1000 * (1000/Clock_tickPeriod);
    
        Semaphore_Params_init(&semLedFickerParams);
        semLedFicker = Semaphore_create(0, &semLedFickerParams, NULL); /* Memory allocated in here */
    
        if (semLedFicker == NULL) /* Check if the handle is valid */
        {
            bspDebugPrintf( true,"semLedFicker could not be created.
    ");
        }
        else
        {
    
            bspDebugPrintf( true,"semLedFicker be created.
    ");
        }
    
        // Application main loop
        for (;;)
        {
    
            Semaphore_pend(semLedFicker, timeoutInTicks);
    
            //翻转LED灯
            ledBoardToggle( ledBlueBoard );
            ledBoardToggle( ledRedBoard );
        }
    }
    /*
     * data_process.h
     *
     *  Created on: 2018年7月5日
     *      Author: admin
     */
    
    #ifndef APPLICATION_DATA_PROCESS_H_
    #define APPLICATION_DATA_PROCESS_H_
    
    void LedFicker_createTask(void);
    
    static void LedFicker_taskFxn(UArg a0, UArg a1);
    
    #endif /* APPLICATION_DATA_PROCESS_H_ */

     需要 吐槽的 是 我居然 没有 找到  系统 延时函数 ,所以采用  信号量超时 来 作为  LED 延时!

    官方教程链接

  • 相关阅读:
    完美解决php无法上传大文件分享
    完美解决php无法上传大文件问题
    完美解决php无法上传大文件思路
    完美解决php无法上传大文件功能
    IfcRightCircularCylinder
    IfcRightCircularCone
    IfcRectangularPyramid
    IfcBlock
    IfcCsgPrimitive3D
    IfcReparametrisedCompositeCurveSegment
  • 原文地址:https://www.cnblogs.com/suozhang/p/9268449.html
Copyright © 2011-2022 走看看