- #1
- 646
- 1
I have a function for my robot that reads multiple IR sensors, and I get a syntax error on the bolded lines.
Pretty simple. It access a structure located in the header file for that source file. It's declared as external so that functions in other files can find it.
I get a syntax error when I try to access the structure on the lines that have been bolded in the function declaration.
From what I can tell I haven't misdeclared anything, and the data type for the ReadADC() function matches according to the data sheet. I thought it might be cause I made a declare statement that used the same terms for each channel as the members of the structure, but I changed one of them and the error remained.
So what's going on here?
Code:
//Performs An ADC Reading On All RLS Channels
//Reads left to right
void ADC_All(void)
{
//Reads Left Outer Sensor
SetChanADC(RLS_LOuter);
ConvertADC();
while(BusyADC());
[B]SensorsADC.RLS_LOuter = ReadADC();[/B]
//Reads Left Inner Sensor
SetChanADC(RLS_LInner);
ConvertADC();
while(BusyADC());
[B]SensorsADC.RLS_LInner = ReadADC();[/B]
//Reads Centre Sensor
SetChanADC(RLS_Centre);
ConvertADC();
while(BusyADC());
[B] SensorsADC.Centre = ReadADC();[/B]
//Reads Right Inner Sensor
SetChanADC(RLS_LOuter);
ConvertADC();
while(BusyADC());
[B]SensorsADC.RLS_RInner = ReadADC();[/B]
//Reads Right Outer Sensor
SetChanADC(RLS_LOuter);
ConvertADC();
while(BusyADC());
[B]SensorsADC.RLS_ROuter = ReadADC()[/B];
}
Code:
//This structure contains the ADC values for each sensor
extern struct Sensors_ADC
{
int RLS_LOuter; //Outer Left Sensor
int RLS_LInner; //Inner Left Sensor
int RLS_Centre; //Centre Sensor
int RLS_RInner; //Inner Right Sensor
int RLS_ROuter; //Outer Right Sensor
};
//Tag for the above structure
extern struct Sensors_ADC SensorsADC;
I get a syntax error when I try to access the structure on the lines that have been bolded in the function declaration.
From what I can tell I haven't misdeclared anything, and the data type for the ReadADC() function matches according to the data sheet. I thought it might be cause I made a declare statement that used the same terms for each channel as the members of the structure, but I changed one of them and the error remained.
So what's going on here?
Last edited: