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

📄 my_description.c

📁 实现功能ATmega单片机上处理GSM模块的数据
💻 C
字号:
//#include "cdctrl_chris.c"
//#include "buffer_chris.c"
//#include "extint_chris.c"


//this is used in the "void CD_RxCmdXLAT(void)" to indicate error
void error(void)
{
}

//*************************
//read the high or low byte of u16 data ,HL is for the high or low byte 
u08 u16TOu08( u16 data,u08 HL )

{
	u08 c=0;
	if( HL==L )
	{
		//pass u16 data's low byte to u08 c
		c=data;
	}
	//*********
	if( HL==H )
	{
		//shift the high byte ,then pass its low byte to u08 c
		data>>=8;
		c=data;
	}
	return c;
}
//*************************
//compose two u08 byte to u16 word,return the u16 word
u16 u08TOu16( u08 Hdata,u08 Ldata )

{
	u16 c=0;

	c=Hdata;
	c<<=8;
	c|=Ldata;

	return c;
}
//***********
void delay_ms02(unsigned char time_ms)
{
	unsigned short delay_count = F_CPU / 4000;

	unsigned short cnt;
	asm volatile ("\n"
                  "L_dl1%=:\n\t"
                  "mov %A0, %A2\n\t"
                  "mov %B0, %B2\n"
                  "L_dl2%=:\n\t"
                  "sbiw %A0, 1\n\t"
                  "brne L_dl2%=\n\t"
                  "dec %1\n\t" "brne L_dl1%=\n\t":"=&w" (cnt)
                  :"r"(time_ms), "r"((unsigned short) (delay_count))
	);
}
//***********
//scan the key,use the position delay structure
u08 KeyScan(void)
{
	u08 ret=0;
	while(1)
	{	
		//PC0 button
		if( !ReadBit(PINC,PC0) )
		{
			//prevet the wobbling
			delay_ms02(5);
			if( !ReadBit(PINC,PC0) )
			{
				//return the key value
				ret=2;
				//jump out the while(1)
				break;
			}
	
		}//if
		//PC1 button
		if( !ReadBit(PINC,PC1) )
		{
			//prevet the wobbling	
			delay_ms02(5);
			if( !ReadBit(PINC,PC1) )
			{
				//return the key value
				ret=1;
				//jump out the while(1)
				break;
			}
	
		}//if
		//*************************
		delay_ms02(5);
	}//while(1)
	//*************************
	//wait until the botton up
	while( ReadBit(PINC,PC0)==0 || ReadBit(PINC,PC1)==0)
	{
		//delay_ms02(1);
		
	}
	//return the key value
	return ret;
	
}




/*
static unsigned char __attribute__ ((progmem)) RegisterName[]={

	//"AS","SD","DF","DW","RRE","WE","mn","l;","ERgg,"vbn","cc","xzx",
	//"A","S","D","D","R","W","n","l;","g,"v","c","x"
	'a','s','w','r','g'
	};
unsigned char   RegisterName02[]={

	//"AS","SD","DF","DW","RRE","WE","mn","l;","ERgg,"vbn","cc","xzx",
	//"A","S","D","D","R","W","n","l;","g,"v","c","x"
	//'a','s','w','r','g'
	};
*/

/*
void debugPrintHexTable_MyScript(u16 length, u08 *buffer)
{
	u08 i;
	u16 j;
	u08 *buf;
	u08 s;

	buf = buffer;
	
	// print the low order address indicies and ASCII header
	rprintfProgStrM("     00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  \r\n");
	rprintfProgStrM("     -----------------------------------------------  \r\n");
	
	// print the data
	for(j=0; j<length; j++)
	{
		// print the high order address index for this line
		rprintfu16(j);
		rprintfChar(' ');

		//rprintfProgStrM("AS");
		//rprintfProgStr(	RegisterName[j]	);
		rprintfStr(	RegisterName02[j]	);
		rprintfChar(':');
		rprintfChar(' ');

		rprintfu08(buf[j]);
		rprintfCRLF();

		

	}
}

*/

⌨️ 快捷键说明

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