⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thrcontrol.c

📁 在海尔的DM642开发板实现RF5框架
💻 C
字号:
/*
 *  Copyright 2002 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/*
 *  ======== thrControl.c ========
 *  This file shows an example of sending messages from one thread to the
 *  other using mailbox.
 */
#include <std.h>

// DSP/BIOS includes
#include <mbx.h>
#include <tsk.h>

// RF includes
#include <utl.h>

// application includes
#include "appResources.h"   // application-wide common info
#include "appThreads.h"     // thread-wide common info
#include "thrControl.h"

#include "thrProcess.h"     /* contains thread specific information */
#include "seeddm642.h"
// global variables to be modified by GEL
#define NUMCONTROLS 5

//Structure for external control variables
typedef struct ExternalControl {
    Int AccidentCause;	//0 or 1, to set reference frame
	Int setDisplayFront;
	Int setDisplayBack;
	Int setDisplayIntel;
	Int setDisplayDefault;
} ExternalControl;

ExternalControl externalControl;        // GEL script writes here
ExternalControl externalControlPrev;    // this is a local copy 

/*
 *  ======== thrControlInit ========
 *
 */
Void thrControlInit()
{
    UTL_assert( NUMCONTROLS == 5 );

    // set the default Reference Frame and Colors
    externalControl.AccidentCause = 0; 	//Set first frame as reference
	externalControl.setDisplayFront = 0;
	externalControl.setDisplayBack = 0;
	externalControl.setDisplayIntel = 0;
	externalControl.setDisplayDefault = 0;
    
    externalControlPrev = externalControl;
}

/*
 *  ======== thrControlStartup ========
 *
 */
Void thrControlStartup()
{    
    
    CtrlMsg txMsg1;
    CtrlMsg txMsg2;
	CtrlMsg txMsg3;
	CtrlMsg txMsg4;
	CtrlMsg txMsg5;
    //Set initial reference frame to be 1st frame.
    //Only need to send message that we want a new
    //reference frame.
    txMsg1.cmd = MSGNEWACCIDENT;
    txMsg1.arg1 = 0;
    txMsg1.arg2 = 0;
    
    MBX_post(&mbxProcess, &txMsg1, 0);

	txMsg2.cmd = MSGNEWDISPLAYF;
	txMsg2.arg1 = 0;
	txMsg2.arg2 = 0;
	MBX_post(&mbxProcess, &txMsg2, 0);

    txMsg3.cmd = MSGNEWDISPLAYB;
	txMsg3.arg1 = 0;
	txMsg3.arg2 = 0;
    MBX_post(&mbxProcess, &txMsg3, 0);

    txMsg4.cmd = MSGNEWDISPLAYI;
	txMsg4.arg1 = 0;
	txMsg4.arg2 = 0;
	MBX_post(&mbxProcess,&txMsg4, 0);

   /* txMsg5.cmd = MSGNEWDISPLAYD;
	txMsg5.arg1 = 0;
	txMsg5.arg2 = 0;
	MBX_post(&mbxProcess,&txMsg5, 0);*/
    
}

/*
 *  ======== thrControlRun ========
 *
 *  Main function of Control task.
 */
Void thrControlRun()
{
    CtrlMsg txMsg1;
	CtrlMsg txMsg2;
	CtrlMsg txMsg3;
	CtrlMsg txMsg4;
	CtrlMsg txMsg5;

	// Main loop
	while (TRUE) {
	    
	    //See if user requested new reference frame
	    if (externalControl.AccidentCause)
	    {
	    	txMsg1.cmd = MSGNEWACCIDENT;
	    	txMsg1.arg1 = 0;
	    	txMsg1.arg2 = 0;
	    	MBX_post(&mbxProcess, &txMsg1, 0);
			printf("the accidentcause \n");
	    	
	    	//Reset setReference to FALSE
	    	externalControl.AccidentCause = 0;
	    } 
		if(externalControl.setDisplayFront)
		{
		   txMsg2.cmd = MSGNEWDISPLAYF;
		   txMsg2.arg1 = 0;
		   txMsg2.arg2 = 0;
		   MBX_post(&mbxProcess,&txMsg2, 0);
		   printf("the setDisplayFront\n");
		   externalControl.setDisplayFront = 0;    
		
		}
		if(externalControl.setDisplayBack)
		{
		  txMsg3.cmd = MSGNEWDISPLAYB;
		  txMsg3.arg1 = 0;
		  txMsg3.arg2 = 0;
		  MBX_post(&mbxProcess, &txMsg3, 0);
		  printf("the setDisplayBack\n");
		  externalControl.setDisplayBack = 0;
		
		}
       if(externalControl.setDisplayIntel)
	   {
	     txMsg4.cmd = MSGNEWDISPLAYI;
		 txMsg4.arg1  = 0;
		 txMsg4.arg2  = 0;
		 MBX_post(&mbxProcess,&txMsg4, 0);
		 printf("the setDisplayIntel\n");
		 externalControl.setDisplayIntel = 0;
	   }
	 /*  if(externalControl.setDisplayDefault)
	   {
	     txMsg5.cmd = MSGNEWDISPLAYD;
		 txMsg5.arg1 = 0;
		 txMsg5.arg2 = 0;
		 MBX_post(&mbxProcess,&txMsg5, 0);
		 externalControl.setDisplayDefault = 0;
	   }*/

	    externalControlPrev = externalControl;
	    
	    // suspend self for 100 ticks, and then poll again
	    TSK_sleep( 100000 );
	}
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -