Error: C:\cvavreval\inc\usart.h(55), included from: hc05.h: declaration syntax error
or one of those close to it.
As for the new error ( on line 40 in hc05.h ), look at the error again. It is saying that there's an invalid #include. The line you gave us isn't a #include. Look up two lines. What the heck is that supposed to be including? The compiler doesn't know either, the first thing it found was void main(void){ etc. Obviously it doesn't know what to do with that.
hello every onei want to run hc05 bluetooth module with atmega8L by following codes in codevisionavr ,main project file is hc11.c and it has 2 header files named hc05.h and usart.h but i see some errors and warnings after selecting build all , codes are:hc11.c[code]#include/*Includes io.h header file where all the Input/Output Registers and its Bits are defined for all AVR microcontrollers*/#define F_CPU 8000000/*Defines a macro for the delay.h header file. F_CPU is the microcontroller frequency value for the delay.h header file. Default value of F_CPU in delay.h header file is 1000000(1MHz)*/#include
/*Includes delay.h header file which defines two functions, _delay_ms (millisecond delay) and _delay_us (microsecond delay)*/
#include
/*Includes hc05.h header file which defines different functions for HC-05 Bluetooth Module. HC-05 header file version is 1.1*/
void main(void)
{
delay_ms(500);
delay_ms(500);
/*Delay of 1s*/
usart_init();
/*USART initialization*/
hc_05_bluetooth_transmit_string("bluetooth tag");
/*Transmits a string to Bluetooth Module*/
hc_05_bluetooth_transmit_byte(0x0d);
/*Transmits Carriage return to Bluetooth Module*/
hc_05_bluetooth_transmit_byte(0x0a);
/*Transmits New Line to Bluetooth Module for new line*/
hc_05_bluetooth_transmit_string("bluetooth module";);
/*Transmits a string to Bluetooth Module*/
hc_05_bluetooth_transmit_byte(0x0d);
/*Transmits Carriage return to Bluetooth Module*/
hc_05_bluetooth_transmit_byte(0x0a);
/*Transmits New Line to Bluetooth Module for new line*/
}
/*End of program*/
[/code]
hc05.h
[code]
#ifndef _HC05_H_
//#if HC05_H_
//#define _HC05_H_
#define _HC05_H_ 1
#include
#include
#include
#include
void main(void)
{
while(1){
char hc_05_buffer1[25], hc_05_buffer2[50];
char temp;
//unsigned char i;
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;
unsigned char i;
for( i=0;;i++)
{
*(receive_string+i)=usart_data_receive();
if(*(receive_string+i)==terminating_character)
break;
else
temp++;
}
*(receive_string+temp)='\0';
return receive_string;
}
unsigned char hc_05_bluetooth_at_command_mode_test(void)
{
UBRRL=12;
delay_ms(500);
usart_string_transmit("AT");
usart_data_transmit(0x0d);
usart_data_transmit(0x0a);
usart_string_receive(hc_05_buffer1,0x0d);
temp=usart_data_receive();
if(!(strcmp(hc_05_buffer1,"OK")))
{
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("AT+UART=4800,0,0");
}
else if(baud_rate==9600)
{
usart_string_transmit("AT+UART=9600,0,0");
}
else if(baud_rate==19200)
{
usart_string_transmit("AT+UART=19200,0,0");
}
else if(baud_rate==38400)
{
usart_string_transmit("AT+UART=38400,0,0");
}
else if(baud_rate==57600)
{
usart_string_transmit("AT+UART=57600,0,0");
}
else if(baud_rate==115200)
{
usart_string_transmit("AT+UART=115200,0,0");
}
else if(baud_rate==230400)
{
usart_string_transmit("AT+UART=230400,0,0");
}
else if(baud_rate==460800)
{
usart_string_transmit("AT+UART=460800,0,0");
}
else if(baud_rate==921600)
{
usart_string_transmit("AT+UART=921600,0,0");
}
else if(baud_rate==1382400)
{
usart_string_transmit("AT+UART=1382400,0,0");
}
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,"OK")))
{
return 1;
}
else
{
return 0;
}
}
unsigned char hc_05_bluetooth_device_name_change(char *device_name)
{
UBRRL=12;
delay_ms(500);
usart_string_transmit("AT+NAME=");
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,"OK")))
{
return 1;
}
else
{
return 0;
}
}
unsigned char hc_05_bluetooth_get_version(void)
{
unsigned char i=9,j=0;
UBRRL=12;
delay_ms(500);
usart_string_transmit("AT+VERSION?");
usart_data_transmit(0x0d);
usart_data_transmit(0x0a);
usart_string_receive(hc_05_buffer2,13);
temp=usart_data_receive();
usart_string_receive(hc_05_buffer1,13);
temp=usart_data_receive();
for(i=9;hc_05_buffer2[i]!=0;i++)
{
hc_05_buffer2[j]=hc_05_buffer2[i];
j++;
}
hc_05_buffer2[j]=0;
if(!(strcmp(hc_05_buffer1,"OK")))
{
return 1;
}
else
{
return 0;
}
}
unsigned char hc_05_bluetooth_pin_change(char *new_pin)
{
UBRRL=12;
delay_ms(500);
usart_string_transmit("AT+PSWD=");
usart_string_transmit(new_pin);
usart_data_transmit(0x0d);
usart_data_transmit(0x0a);
usart_string_receive(hc_05_buffer1,13);
temp=usart_data_receive();
if(!(strcmp(hc_05_buffer1,"OK")))
{
return 1;
}
else
{
return 0;
}
}
}
}
#endif
[/code]
usart.h
[code]
#ifndef _USART_H_
#define _USART_H_ 1
#include
#include
#include
/*#include
void main(int) {
set_sleep_mode(SLEEP_MODE_IDLE);
sei();
sleep_mode();}
//gcc -std=gnu99 usart.c
// unsigned char i; */
/*The function is declared to initialize the USART with following cinfiguration:-
USART mode - Asynchronous
Baud rate - 9600
Data bits - 8
Stop bit - 1
Parity - No parity.*/
void main(void){
while(1){
void usart_init();
/*The function is declared to transmit data.*/
void usart_data_transmit(unsigned char data );
/*The function is declared to receive data.*/
unsigned char usart_data_receive( void );
/*The function is declared to transmit string.*/
void usart_string_transmit(char *string);
/*The function is declared to receive string.*/
char *usart_string_receive(char *receive_string,unsigned char terminating_character);
/*Function defination*/
void usart_init()
{
UBRRH = 0;
UBRRL =51;
UCSRB|= (1<
UCSRC |= (1 << URSEL)|(3<
}
void usart_data_transmit(unsigned char data )
{
while ( !( UCSRA & (1<
;
UDR = data;
}
unsigned char usart_data_receive( void )
{
while ( !(UCSRA & (1<
;
return UDR;
}
void usart_string_transmit(char *string)
{
while(*string)
{
usart_data_transmit(*string++);
}
}
char *usart_string_receive(char *receive_string,unsigned char
terminating_character)
{
unsigned char temp=0x00;
unsigned char i;
for(i=0;;i++)
{
*(receive_string+i)=usart_data_receive();
if(*(receive_string+i)==terminating_character)
break;
else
temp++;
}
*(receive_string+temp)='\0';
return receive_string;
}
}
}
#endif
[/code]errors:Error: C:\cvavreval\inc\usart.h(55), included from: hc05.h: declaration syntax errorError: C:\cvavreval\inc\usart.h(98), included from: hc05.h: must declare first in blockError: C:\cvavreval\inc\usart.h(105), included from: hc05.h: must declare first in blockError: C:\cvavreval\inc\usart.h(109), included from: hc05.h: 'void' functions may not return a valueError: C:\cvavreval\inc\usart.h(112), included from: hc05.h: must declare first in blockError: C:\cvavreval\inc\usart.h(127), included from: hc05.h: undefined symbol 'usart_data_receive'Error: C:\cvavreval\inc\usart.h(134), included from: hc05.h: 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(41): function 'main' has already been defined in file: 'C:\Users\MY MHCE\Desktop\New folder\project\hc11\hc11.c', line: 40Error: C:\cvavreval\inc\hc05.h(46): declaration syntax errorError: C:\cvavreval\inc\hc05.h(76): undefined symbol 'usart_data_receive'Error: C:\cvavreval\inc\hc05.h(83): 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(85): must declare first in blockError: C:\cvavreval\inc\hc05.h(89): undefined symbol 'usart_string_transmit'Error: C:\cvavreval\inc\hc05.h(100): 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(104): must declare first in blockError: C:\cvavreval\inc\hc05.h(111): undefined symbol 'usart_string_transmit'Error: C:\cvavreval\inc\hc05.h(153): undefined symbol 'usart_data_transmit'Error: C:\cvavreval\inc\hc05.h(164): 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(168): must declare first in blockError: C:\cvavreval\inc\hc05.h(173): undefined symbol 'usart_string_transmit'Error: C:\cvavreval\inc\hc05.h(187): 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(192): must declare first in blockError: C:\cvavreval\inc\hc05.h(198): undefined symbol 'usart_string_transmit'Error: C:\cvavreval\inc\hc05.h(217): 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(221): 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(225): must declare first in blockError: C:\cvavreval\inc\hc05.h(230): undefined symbol 'usart_string_transmit'Error: C:\cvavreval\inc\hc05.h(244): 'void' functions may not return a valuewarnings:Warning: C:\cvavreval\inc\usart.h(102), included from: hc05.h: local variable 'data' is used before its value is setWarning: C:\cvavreval\inc\usart.h(127), included from: hc05.h: local variable 'receive_string' is used before its value is setWarning: C:\cvavreval\inc\usart.h(133), included from: hc05.h: local variable 'receive_string' is used before its value is setWarning: C:\cvavreval\inc\usart.h(134), included from: hc05.h: local variable 'receive_string' is used before its value is setWarning: C:\cvavreval\inc\hc05.h(76): local variable 'receive_string' is used before its value is setWarning: C:\cvavreval\inc\hc05.h(82): local variable 'receive_string' is used before its value is setWarning: C:\cvavreval\inc\hc05.h(83): local variable 'receive_string' is used before its value is setWarning: C:\cvavreval\inc\hc05.h(109): local variable 'baud_rate' is used before its value is setWarning: C:\cvavreval\inc\hc05.h(208): local variable 'hc_05_buffer2' is used before its value is setWarning: C:\cvavreval\inc\hc05.h(210): local variable 'hc_05_buffer2' is used before its value is setfor solving errors i declared variables after header files but nothing changed in errors,and also i cut unsigned before variable and again same thing occured , some where i read that i should active gcc mode i do that by these codes:#includevoid main(int) {set_sleep_mode(SLEEP_MODE_IDLE);sei();sleep_mode();}(also i took this code from the net)and i did not see those errors but i saw just this error:Error: C:\cvavreval\inc\usart.h(40), included from: hc05.h: invalid #include directivethat line 40 is:void main(int) {and i change it to : void main() or: void main(void)but i saw again the same error,these codes are in c++ but as you know better than me codevisionavr is a c compiler and also I lernt c++ in university and do not know how to change it to c till be accepted by this compiler ,please learn me which code I should add in my codes , it is my class project and I could not change my compiler because my programmer just support this type,I really need your help!!!