继续:如何解决这些codevisionavr语法错误? [英] Continue:how can I solve these codevisionavr syntax errors?

查看:232
本文介绍了继续:如何解决这些codevisionavr语法错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hc05.h
#ifndef	_HC05_H_
#define	_HC05_H_ 	1


#include <io.h>;
#include <delay.h>;
#include <usart.h>;

char hc_05_buffer1[25], hc_05_buffer2[50];
char temp;

void hc_05_bluetooth_transmit_byte(char data_byte);
char hc_05_bluetooth_receive_byte(void);
void hc_05_bluetooth_transmit_string(char *transmit_string);
void hc_05_bluetooth_transmit_command(char *transmit_string);
char *hc_05_bluetooth_receive_string(char *receive_string, unsigned char terminating_character);
unsigned char hc_05_bluetooth_at_command_mode_test(void);
unsigned char hc_05_bluetooth_device_name_change(char *device_name);
unsigned char hc_05_bluetooth_get_version(void);
unsigned  char hc_05_bluetooth_change_baud_rate(long int baud_rate);
unsigned  char hc_05_bluetooth_pin_change(char *new_pin);


void hc_05_bluetooth_transmit_byte(char data_byte)
{
	usart_data_transmit(data_byte);
}
char hc_05_bluetooth_receive_byte(void)
{
	return usart_data_receive();
}
void hc_05_bluetooth_transmit_string(char *transmit_string)
{
	usart_string_transmit(transmit_string);
}
char *hc_05_bluetooth_receive_string(char *receive_string, unsigned char terminating_character)
{
	unsigned char temp=0x00;
	for(unsigned char i=0;;i++)
	{
		*(receive_string+i)=usart_data_receive();
		if(*(receive_string+i)==terminating_character)
			break;
		else
			temp++;
	}
	*(receive_string+temp)=&#39;\0&#39;;
	return receive_string;
}
unsigned char hc_05_bluetooth_at_command_mode_test(void)
{
	UBRRL=12;
	delay_ms(500);
	usart_string_transmit(&quot;AT&quot;);
	usart_data_transmit(0x0d);
	usart_data_transmit(0x0a);
	usart_string_receive(hc_05_buffer1,0x0d);
	temp=usart_data_receive();
	if(!(strcmp(hc_05_buffer1,&quot;OK&quot;)))
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

unsigned  char hc_05_bluetooth_change_baud_rate(long int baud_rate)
{
	UBRRL=12;
	delay_ms(500);
	
	if(baud_rate==4800)
	{
		usart_string_transmit(&quot;AT+UART=4800,0,0&quot;);
	}
	else if(baud_rate==9600)
	{
		usart_string_transmit(&quot;AT+UART=9600,0,0&quot;);
	}
	else if(baud_rate==19200)
	{
		usart_string_transmit(&quot;AT+UART=19200,0,0&quot;);
	}
	else if(baud_rate==38400)
	{
		usart_string_transmit(&quot;AT+UART=38400,0,0&quot;);
	}
	else if(baud_rate==57600)
	{
		usart_string_transmit(&quot;AT+UART=57600,0,0&quot;);
	}
	else if(baud_rate==115200)
	{
		usart_string_transmit(&quot;AT+UART=115200,0,0&quot;);
	}
	else if(baud_rate==230400)
	{
		usart_string_transmit(&quot;AT+UART=230400,0,0&quot;);
	}
	else if(baud_rate==460800)
	{
		usart_string_transmit(&quot;AT+UART=460800,0,0&quot;);
	}
	else if(baud_rate==921600)
	{
		usart_string_transmit(&quot;AT+UART=921600,0,0&quot;);
	}
	else if(baud_rate==1382400)
	{
		usart_string_transmit(&quot;AT+UART=1382400,0,0&quot;);
	}
	else
	{
		;
	}
	usart_data_transmit(0x0d);
	usart_data_transmit(0x0a);
	usart_string_receive(hc_05_buffer1,13);
	temp=usart_data_receive();
	
	if(!(strcmp(hc_05_buffer1,&quot;OK&quot;)))
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

unsigned char hc_05_bluetooth_device_name_change(char *device_name)
{
	UBRRL=12;
	delay_ms(500);
	
	usart_string_transmit(&quot;AT+NAME=&quot;);
	usart_string_transmit(device_name);
	usart_data_transmit(0x0d);
	usart_data_transmit(0x0a);
	
	usart_string_receive(hc_05_buffer1,13);
	temp=usart_data_receive();
	
	if(!(strcmp(hc_05_buffer1,&quot;OK&quot;)))
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

What I have tried:

Error: C:\cvavr\INC\hc05.h(34): can't open #include file: usart.h
Error: C:\cvavr\INC\hc05.h(53): undefined symbol 'usart_data_transmit'
Error: C:\cvavr\INC\hc05.h(66): undefined symbol 'unsigned'
Error: C:\cvavr\INC\hc05.h(66): undefined symbol 'i'
Error: C:\cvavr\INC\hc05.h(81): undefined symbol 'usart_string_transmit'
Error: C:\cvavr\INC\hc05.h(90): no matching if
Error: C:\cvavr\INC\hc05.h(103): undefined symbol 'usart_string_transmit'
Error: C:\cvavr\INC\hc05.h(145): undefined symbol 'usart_data_transmit'
Error: C:\cvavr\INC\hc05.h(154): no matching if
<pre lang="JavaScript">Error: C:\cvavr\INC\hc05.h(165): undefined symbol 'usart_string_transmit'



错误:C:\ cvavr \INC \ hc05.h(177):如果没有匹配

错误:C:\ cvavr \INC \ hc05.h(187):必须声明第一个在块中


Error: C:\cvavr\INC\hc05.h(177): no matching if
Error: C:\cvavr\INC\hc05.h(187): must declare first in block

Error: C:\cvavr\INC\hc05.h(188): undefined symbol 'usart_string_transmit'




Error: C:\cvavr\INC\hc05.h(205): undefined symbol 'strcmp'



错误:C:\ cvavr \ INC \\ \\ hc05.h(209):如果没有匹配


Error: C:\cvavr\INC\hc05.h(209): no matching if

Error: C:\cvavr\INC\hc05.h(220): undefined symbol 'usart_string_transmit'



错误:C:\ cvavr \INC \ hc05.h(232):如果


Error: C:\cvavr\INC\hc05.h(232): no matching if

推荐答案

它告诉你问题......首先处理主要的问题



1.)usart.h是一个文件它无法找到。 include语句清楚地表明它应该在默认的库目录中但显然不是。我猜usart.h是一个串行通信文件,无论你从哪里获得此代码,你需要找到该文件然后正确包含它。它可能是AVR C编译器的标准文件,因为它试图包含在其中,但它不是C标准文件。无论如何,您需要找到文件或制作自己的匹配功能。代码只是从串口发送和接收字符,这不是火箭科学要理解的。



2.)strcmp是标准库文件string.h中的标准C函数。它也需要包括在内。

It's telling you the problems ... deal with the main ones first

1.) usart.h is a file it can't be found. The include statement makes it clear it is supposed to be in the default library directories but clearly it isn't. I am guessing usart.h is a serial comms file from wherever you got this code from and you need to find the file and then include it properly. It might be a standard file to an AVR C compiler given where it's trying to be included from but it isn't a C standard file. Whatever the case you need to find the file or make your own matching functions. The code is just sending and receiving characters from a serial port it isn't rocket science to understand.

2.) strcmp is a standard C function in the unit in the standard library file "string.h". It needs to be included as well.
#include <string.h>



将修复那个

C库函数 - strcmp() [ ^ ]



其余部分错误看起来是基于编译器无法克服这两个问题的语法。首先解决这些问题,其余部分应该删除。


will fix that one
C library function - strcmp()[^]

The rest of the errors look to be syntax based on the compiler not being able to get over those two problems. Fix those first and the rest should drop away.


这篇关于继续:如何解决这些codevisionavr语法错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆