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

📄 analogs.c

📁 老外开发的机器人的底层单片机代码。比较有参考价值哦!
💻 C
字号:
//  Analog input handler   Analogs.c					// Rev 4/30/05

//Copyright (C) 2005 Alex Brown	rbirac@cox.net
//This program is free software; See license at the end of this file for details.

/*												
  	  Analogs.c reads in data from ATD converters.  It will eventually be 
	  modified so that the 4 data values received between 64 msec outputs 
	  to the laptop can be average, last value, filter, midvalue or whatever as
	  a function of the AnaCfg parameters.
	  
  	  This is a standalone function.  The ATD converter is initialized to run 
	  autonomously (in init.c) and the IR range values will be updated each 
	  time this function is called by the real time executive.	
	  
	  //note:  10 bit ATD data will vary 0 to 0x3FF
 */
#include <hcs12dp256.h>		    //for registers

// the following will define how the data is to be processed here
int AnaCfg0,AnaCfg1,AnaCfg2,AnaCfg3,AnaCfg4,AnaCfg5,AnaCfg6;
int AnaCfg7,AnaCfg8,AnaCfg9,AnaCfg10,AnaCfg11,AnaCfg12;


//exported values
int Analog0;	 //RC 0 jack
int Analog1;	 //RC 1 jack
int Analog2;	 //RC 2 jack
int Analog3;	 //RC 3 jack
int Analog4;	 //RC 4 jack
int Analog5;	 //RC 5 jack
int Analog6;	 //RC 6 jack
int Analog7;	 //RC 7 jack
int Analog8;	 //Battery voltage
int Analog9;	 //spare
int Analog10;	 //spare
int Analog11;	 //spare
int Analog12;	 //spare

//---------------------------------------------------------------------------
void Analogs(void)
{	
  //for now,  just output the most recent value	
  Analog0  = ATD0DR4;  	//RC0 jack	
  Analog1  = ATD0DR5;	//RC1
  Analog2  = ATD0DR6;	//RC2
  Analog3  = ATD1DR3;	//RC3
  Analog4  = ATD1DR7;	//RC4
  Analog5  = ATD1DR6;	//RC5
  Analog6  = ATD1DR5;	//RC6
  Analog7  = ATD1DR4;	//RC7
  Analog8  = ATD1DR2;	//internal battery voltage
  Analog9  = ATD0DR3;	//spare
  Analog10 = ATD0DR7;	//spare
  Analog11 = ATD1DR0;	//spare
  Analog12 = ATD1DR0;	//spare
}
 
//  OPEN SOURCE SOFTWARE LICENSE
/* Permission is hereby granted, free of charge, to any person obtaining a copy 
of this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to use, 
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the 
Software, and to permit persons to whom the Software is furnished to do so, 
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all 
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ 

⌨️ 快捷键说明

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