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

📄 demonstrator.c

📁 The collection of AVR source code in C.
💻 C
字号:
// Demonstrator.c Messenger version

#include "PC_Comm.h"
#include "Messages.h"

	
void initializer()
{
	// Calibrate the oscillator:
    OSCCAL_calibration();   

	// Initialize the USART
	USARTinit();
	
	// Display instructions on PC
	sendFString(TALKING_TO);
	sendFString(WHO_DEMO);
	
	char c = '0';
	for(int i = 0; i < 5; i++)
	{
		sendFString(ENTER);
		sendChar(c + i);
		sendFString(FOR);	
		sendFString(ERROR_TBL[i]);
	}

}

void parseInput(char s[])
{
	if( (s[0] <= '4') && ( s[0] >= '0') ) // 5 error messages
	{
		showMessage(s[0]);
	}
	else
	{
		// parse first character	
		switch (s[0])
		{
			case 'd':
				if( (s[1] == 'e') && (s[2] == 'm') && (s[3] == 'o') && (s[4] == '?') )
				sendFString(TALKING_TO);
				sendFString(WHO_DEMO);
				break;
			default:
				sendFString(BAD_COMMAND1);
				sendChar(s[0]);
				sendFString(BAD_COMMAND2);

				break;
			
		}
	s[0] = '\0';
	}
}

void showMessage(char mess)
{

	int num = atoi(&mess);

	sendFString(ERROR_TBL[num]);     // Send the song title to the PC

}

⌨️ 快捷键说明

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