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

📄 gpio.c

📁 属于麻醉机的一个程序
💻 C
📖 第 1 页 / 共 5 页
字号:

#include "DSP28_Device.h"
//#include "DSP28_Globalprototypes.h"
#include "DSP28_Globalprototypes.h"
#include "DSP28_Adc.h"
#include "DSP28_CpuTimers.h"
#include "DSP28_PieVect.h"
#include "DSP28_PieCtrl.h"
#include "DSP28_Gpio.h"
#include "DSP28_Xintf.h"
#include "DSP28_XIntrupt.h"
//#include "DSP28_DefaultIsr.h
// Prototype statements for functions found within this file.
// interrupt void ISRTimer2(void);
unsigned int key_number=0x00ff;
unsigned int key_number1=0;
int xueliang=0;
int ce;
int zdw=0;
int zdw1=0;
int status=0;
int m=0;
int m1=0; 
int m2=0;
int n=0;
int n1=0;
int n2=0;
int n3=0;
int n4=0;
int ii=0;
int jj=1;
int cishu=0;
int man;
int zhouqi=0;
unsigned int kai=0;
unsigned int guan=0;
int kai1=0;
int guan1=0;
int pl=0;
int pinlv=0;
int hxb=0;
int huxibi=0;
int pt=0;
int pintai=0;
int xqy=0;
int xiqiya=0;
int cfy=0;
int chufaya=0;
int yls=0;
int yalis=0;
int ylx=0;
int yalix=0;
int ynds=0;
int yangnds=0;
int yndx=0;
int yangndx=0;
int tqls=0;
int tongqls=0;
int tongqlx=0;
int tqlx=0;
int exit=0;
int aa=0;
int key_sign=0;
int caidan=0;
int aa2=0;//跳处采样等待
int ring=0;//响铃
int press,oxsg,flux,Flux1;//压力,氧气,流量
float	a0[3]={0,0,0};
float   a1[3]={0,0,0};//初步采样值
int a2=0;
int a3=0;
float	adclo=0.0;
int b1[100];
int b2[100];
int b3[100];
int unsigned bx1[400];
//int unsigned bx2[400];
int boo[400];
extern int bo1[400];//波形所用的值
int c1[3]={0,0,0};
int c2[3]={0,0,0};
int c3[3]={0,0,0};//中值滤波后的值
int  temp=0;
int temp1=0;
int temp2=0;
int temp3=0;

int TongBu=0;
int light1=0;
int tan_qi=0;
int Tanbz=0;
int Tanci=0;
int jikong=1;
int shoudong=0;
int Waiting=0;
int jindu=0;
int jindu1=0;
//int jioazhun=0;
int jiaozhun=0;
int jiaozhun11=0;//氧气浓度校准
int jiaozhun12=0;
int complete1=0;
int complete2=0;
int jiaozhun21=0;
int jiaozhun22=0;//小孩流速校准
int jiaozhun31=0;
int jiaozhun32=0;//成人流速校准 
//外部专用变量unsigned long i,j;
//int counter1;
int result=0;
int result1=0;
int result2=0;
//LCD 专用
/*#define red 192
#define green 68
#define black 240
#define blue 3
#define yellow 0xFC
#define purple 8
#define gray 1
#define white 66
#define lightgray 151
#define lightpurple 123
#define lightyellow 0//203
#define lightblue 167
#define lightgreen 152 //0x0C
#define lightred 19
#define lightbrown 44
#define pink 11
unsigned int colorb;*/
unsigned int color_ground;
unsigned int color_frame;
unsigned int color_word;
unsigned int color_wave;
unsigned int color_top_number;
unsigned int color_down_number;
unsigned int color_alarm;
unsigned int color_investment;
unsigned int color_change;
unsigned int color_change1;
unsigned int color_temp;
//unsigned int colorb;
unsigned int color_all[10]={12,26,45,86,59,115,156,213,79,225};
int beijin=0;
int kuangjia=0;
int hanzi=0;
int boxin=0;
int dingbu=0;
int dibu=0;
int youbaojing=0;
int youjiance=0;
//unsigned volatile int * WCMD=(unsigned int *)0x100000;
//unsigned volatile int * WDAT=(unsigned int *)0x100001;
/*void clear(int colorb);//全屏幕清0 
void co_addr(int x, int y);//坐标和地址的转换
void clear1(int x1,int y1,int x2,int y2, int colorb);//矩形清零,画线同一程序。 
void dispcn(int x,int y,int latt,int *c,int colorf,int colorb); //写字程序
*/
//显示专用
void show_Init();
void clearall();
void show_kj();
void show_plsz();
void show_hxbsz();
void show_ptsz();
void show_xqysz();
void show_cfysz();
void show_yljc();
void show_yndjc();
void show_tqljc();
void show_pljc();
void show_cqljc();
void show_dqzt();
void show_gzzt();
void show_gzms();
void show_tq();
void show_dkcd();
void show_msxz();
void show_cdcz(unsigned int cdsz);
void show_yssz(unsigned int yssz);
void show_bjys();
void show_hanziy();
void show_kxys();
void show_bxys();
void show_tcolor();
void show_bcolor();
void show_ycbjy();
void show_ycjcy();
void show_mscz(unsigned int mscz);
void show_plszs(unsigned int fset);
void show_hxb(unsigned int hxb);
void show_pt(unsigned int pt);
void show_xqy(unsigned int xqy);
void show_cfy(unsigned int cfy);
void show_pljcs(unsigned int fmon);
void show_cql(unsigned int cql);
void show_yl(unsigned int yl);
void show_ynd(unsigned int ynd);
void show_tql(unsigned int tql);
void show_ylsx(unsigned int ylsx);
void show_ylxx(unsigned int ylxx);
void show_yndsx(unsigned int yndsx);
void show_yndxx(unsigned int yndxx);
void show_tqlsx(unsigned int tqlsx);
void show_tqlxx(unsigned int tqlxx);
void show_yalibo();
void show_huxibo();
void show_yd0();
void show_yd1();
void show_yd2();
void show_yd3();
void show_jd();
void show_result();
void show_cr0();
void show_cr1();
void show_cr2();
void show_cr3();
void show_er0();
void show_er1();
void show_er2();
void show_er3();
void show_huifu();
void show_zbz();
void clear_color(unsigned int cox1,unsigned int coy1,unsigned int cox2,unsigned int coy2);
void lcd_select();
void writenum24(unsigned int x,unsigned int y,  unsigned int *c);
void writecnc(unsigned int x,unsigned int y,unsigned int latt1,unsigned int latt2,unsigned int*c);
void drawline(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2);
void writecn(unsigned int x,unsigned int y,unsigned int latt,  unsigned int *c);
void writenum32(unsigned int x,unsigned int y,unsigned int latt,  unsigned int *c);
void writenum(unsigned int x,unsigned int y,unsigned int latt,  unsigned int *c);
void clear(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2);
void drawbasic(struct lcdline line);

//
interrupt void cpu_timer0_isr(void);//time0zhongduan
interrupt void cpu_timer2_isr(void);
interrupt void ad(void);
void Mid(int *d);
//void Mid1();
//void Mid2();
//void Mid3();
void press_C(float x);
void oxsg_C(float x);
void flux_C1(float x);
void flux_C2(float x);
//void AD(void);
void up();
void up1();
void up2();
void up3();
void down();
void down1();
void down2();
void down3();
void get_key();
void realse_key();
void change_pl();
void change_hxb();
void change_pt();
void change_xqy();
void change_cfy();
void change_yls();
void change_ylx();
void change_ynds();
void change_yndx();
void change_tqls();
void change_tqlx();
void change_beijing();
void change_kuangjia();
void change_hanzi();
void change_boxing();
void change_bottom_shu();
void change_top_shu();
void change_right_limit();
void change_right_shu();
										    	
void wait();
void change_molde();
void readkey()
{
    key_number=GpioDataRegs.GPBDAT.all;
    key_number=key_number&0x00ff;
}
void delay(unsigned int timee)
{
	while(timee>1)
	{
		timee--;
	}
}
void delay1(unsigned int timee)	/*10ms*/
{
	while(timee>1)
	{
		delay(50000);
		timee--;
	}
}
void shortring()
{
	GpioDataRegs.GPADAT.bit.GPIOA1=1;
	delay1(30);
	GpioDataRegs.GPADAT.bit.GPIOA1=0;
}
void shortshortring()
{
	GpioDataRegs.GPADAT.bit.GPIOA1=1;
	delay1(3);
	GpioDataRegs.GPADAT.bit.GPIOA1=0;
}
void ippv();
void manual();
void menu();
void enter();
void light();
void silence();
void tanqi();
void set_frequency();//设置频率
void set_huxi();//设置呼吸比
//void savedata1();
void set_man();//设置成人初始参数
void set_child();//设置儿童初始参数
void text_oxsg();
void text_child();
void text_man();




void main(void)
{
    
	//int i;
	/* 初始化系统控制 */
	InitSysCtrl();
	// Disable and clear all CPU interrupts:
	DINT;
	IER = 0x0000;
	IFR = 0x0000;
	
	/* 初始化外设中断控制 */	
	InitPieCtrl();
	
	

	/* 初始化中断矢量表 */
	InitPieVectTable();	
	EALLOW;
	PieVectTable.TINT0=&cpu_timer0_isr;
	PieVectTable.TINT2=&cpu_timer2_isr;
	PieVectTable.ADCINT=&ad;
	EDIS;
	//KickDog();
	InitAdc();

	InitCpuTimers();
	
	InitGpio();
	//KickDog();
	

	//InitAdc();
	EALLOW;   
	GpioMuxRegs.GPBDIR.all=0x0200;    	//low byte as input
	GpioMuxRegs.GPBQUAL.all=0x000F;		// Input qualifier disabled
	GpioMuxRegs.GPADIR.all=0x00FE;    	//low byte as input
	GpioMuxRegs.GPAQUAL.all=0x000F;		// Input qualifier disabled
	GpioMuxRegs.GPFMUX.all=0x0000;//选数字io口
	GpioMuxRegs.GPFDIR.all=GpioMuxRegs.GPFDIR.all|0x00C2;//GPIOF1,6,7设为输出
    GpioDataRegs.GPFDAT.all=0x00C2;//GPIOF1,6,7设为1,将电平转换设为从A口到B口
	EDIS;
		//KickDog();
	ConfigCpuTimer(&CpuTimer0,150,12500);
	ConfigCpuTimer(&CpuTimer2,150,10000);
//	IER |= M_INT14;
	
//	IER |= M_INT1;
	PieCtrl.PIEIER1.bit.INTx7=1;
	PieCtrl.PIEIER1.bit.INTx6=1;

	

	EINT;
	ERTM;
	StartCpuTimer0();
	StartCpuTimer2();
	
	set_man();
	////////////////////////////////////////
	color_word=168;
    color_ground=26;
    color_alarm=0;
    color_wave=0;
    color_top_number=0;
    color_down_number=0;
    color_investment=0;
    color_change=0;
    color_change1=0;
    
    
    
    
    
		
    clearall();
    
    show_Init();
//	wait();
	/* 打开PASSWORD */
	
	//正式开始
	//关键变量的初始化
	
	//
	
	
	//读取拨码开关的设定
 	
	/*EALLOW;
     GpioMuxRegs.GPAMUX.all=0x0000;     
     GpioMuxRegs.GPADIR.all=0xFFFF;    	// upper byte as output/low byte as input
     GpioMuxRegs.GPAQUAL.all=0x0000;	// Input qualifier disabled
     GpioDataRegs.GPADAT.all=0x0fff;
    EDIS; */
	delay(1000);
	/*initial728x();//键盘初始化
	delay(65535);*/
	/*只有在选页 编程 程序开始 学习里有readdata 功能*/
	
    /*界面的绘制*/
	
	/*本该加入按键等待*/
//-------------------------------------------------------------------------------	

	                  
	                         
	                         
//---------------------------------------------------------------------------------
while(1)
{    //KickDog();
     GpioDataRegs.GPADAT.bit.GPIOA1=0;
     
	//aa2=0;
    get_key();
    while(key_sign)
    {
		while(key_sign)
		{
			realse_key();
			delay(50000);
		}
		switch(key_number1)
		{
			case 237:
				manual();
				show_gzms(color_word,0);
				break;//手动
			case 111:
				ippv();
				show_gzms(color_word,1);
				break;//机动
			case 231:
				up();
				break;//加
			case 175:
				down();
				break;//减
			case 207:
				status=1;
				menu();
				clear(529,396,638,478);
				break;//菜单
			case 238:
				enter();
				break;//确定
			case 2:
				light();
				break;//灯
			case 235:
				silence();
				break;//静音
			default:
				break;
		}  
    }
    if(GpioDataRegs.GPADAT.bit.GPIOA0==0)
    {}//显示用的是交流电
    else{}//显示用的是电池
}
}
void up()
{
 color_temp=color_word;
 if(n<11)
 {n=n+1;}
 else{n=0;}
 switch(n)
      {
      case 0:
            color_word=color_temp;
            show_hxbsz();
            show_msxz();
      		color_word=255;
      		delay(10);
            show_plsz();
            break;//调节频率
      case 1:
            color_word=color_temp;
            show_plsz();
            show_ptsz();
            color_word=255;
            delay(10);
      		show_hxbsz();
      		break;//调节呼吸比
      case 2:
       		color_word=color_temp;
       		show_hxbsz();
       		show_xqysz();
       		color_word=255;
       		delay(10);
      		show_ptsz();
      		break;//平台设置
      case 3:
      		color_word=color_temp;
      		show_ptsz();
      		show_cfysz();
      		color_word=255;
      		delay(10);
      		show_xqysz();
      		break;//吸气压设置
      case 4:
      		color_word=color_temp;
      		show_xqysz();
      		show_yljc();
      		color_word=255;
      		delay(10);
            show_cfysz();
            break;//触发压设置
      case 5:
      		color_word=color_temp;
      		show_cfysz();
      		color_word=255;
      		delay(10);
      		show_yljc();
      		break;//压力上限
      case 6:
      		color_word=color_temp;
      		show_yndjc();
      		color_word=255;
      		delay(10);
	      	show_yljc();
      		break;//压力下限
      case 7:
      		color_word=color_temp;
      		show_yljc();
      		color_word=255;
      		delay(10);
      		show_yndjc();
      		break;//养浓度上限
      case 8:
      		color_word=color_temp;
      		show_tqljc();	
      		color_word=255;
      		delay(10);
	     	show_yndjc();
      		break;//养浓度下限
      case 9:color_word=color_temp;
      		show_yndjc();
      		color_word=255;
      		delay(10);
      		show_tqljc();
	      	break;//通气量上限
      case 10:color_word=color_temp;
      		show_msxz();
      		color_word=255;
      		delay(10);
      		show_tqljc();
      		break;//通气量下限
      case 11:color_word=color_temp;
      		show_tqljc();
      		show_plsz();
      		color_word=255;
      		delay(10);
      		show_msxz();
      		break;//模式选择
      default:break;
      }
      color_word=color_temp;
}
void up1()
{
 if(n1<3)
 {n1=n1+1;}
 else{n1=0;}
  show_gzms(n1);
}
void up2()
{
 if(n2<9)
 {n2=n2+1;}
 else{n2=0;}
 show_cdcz(n2);
}
void up3()
{
 if(n3<8)
 {n3=n3+1;}
 else{n3=0;}
 show_yssz(n3);
}
void down()
{
 color_temp=color_word;
 if(n==0)
 {n=11;}
 else{n=n-1;}
 switch(n)
      {
     case 0:
            color_word=color_temp;
            show_hxbsz();
            show_msxz();
      		color_word=255;
      		delay(10);
            show_plsz();
            break;//调节频率
      case 1:
            color_word=color_temp;
            show_plsz();
            show_ptsz();

⌨️ 快捷键说明

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