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

📄 analog.c

📁 用8051做的WEB SERVER
💻 C
字号:
//-----------------------------------------------------------------------------
// Net ANALOG.C
//
// This module handles the analog inputs which are external temperature
// sensor, the on-chip temperature sensor, and operating voltage.
//-----------------------------------------------------------------------------
#include <string.h>
#include <stdlib.h>
#include "AT89X52.h"
#include "net.h"
#include "serial.h"
#include "analog.h"

extern char xdata text[];
UINT idata cpu_temperature, air_temperature, cpu_voltage;
UCHAR idata mux_select;

//--------------------------------------------------------------------------
// Initialize the A/D converter
// 
//--------------------------------------------------------------------------
void init_adc(void)
{
	
}



//--------------------------------------------------------------------------
// This function is a little state machine which reads one analog
// inputs at a time, out of the 3 possible inputs
//  1. On-chip temperature
//  2. External air temperature
//  3. CPU operating voltage
//--------------------------------------------------------------------------
void read_analog_inputs(void)
{
   	switch (mux_select)
	{
		case MUX_CPU_TEMP:
	      	cpu_temperature++;
			mux_select = MUX_CPU_VOLTS;
		break;

		case MUX_CPU_VOLTS:
			cpu_voltage++;
			mux_select = MUX_AIR_TEMP;
		break;

		case MUX_AIR_TEMP:
			air_temperature++;
			mux_select = MUX_CPU_TEMP;
		break;

		default:
			mux_select = MUX_CPU_TEMP;
		break;
  	}
}
 

 

⌨️ 快捷键说明

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