#ifndef GYRO_H#define GYRO_H/*This is a list of registers in the ITG-3200. Registers are parameters that determine how the sensor will behave, or they can hold data that represent thesensors current status. To learn more about the registers on the ITG-3200, download and read the datasheet.*/char WHO_AM_I = 0x00;char SMPLRT_DIV= 0x15;char DLPF_FS = 0x16;char GYRO_XOUT_H = 0x1D;char GYRO_XOUT_L = 0x1E;char GYRO_YOUT_H = 0x1F;char GYRO_YOUT_L = 0x20;char GYRO_ZOUT_H = 0x21;char GYRO_ZOUT_L = 0x22;/*This is a list of settings that can be loaded into the registers.DLPF, Full Scale Register BitsFS_SEL must be set to 3 for proper operationSet DLPF_CFG to 3 for 1kHz Fint and 42 Hz Low Pass Filter*/char DLPF_CFG_0 = 1<<0;char DLPF_CFG_1 = 1<<1;char DLPF_CFG_2 = 1<<2;char DLPF_FS_SEL_0 = 1<<3;char DLPF_FS_SEL_1 = 1<<4;/*address of gyro on I2C*/char itgAddress = 0x68;/*write and read addressed on i2c for Gyro*/void itgWrite(char address, char registerAddress, char data);unsigned char itgRead(char address, char registerAddress);/*get x, y, and z axis angular rates from gyro*/int gyroReadX(void);int gyroReadY(void);int gyroReadZ(void);#endif
myproject_gyrotest.cpp.o:(.data.itgAddress+0x0): multiple definition of `itgAddress'Gyro.cpp.o:(.data.itgAddress+0x0): first defined herec:/arduino/arduino-1.0.2-windows/arduino-1.0.2/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
...or is this another compiler bug?
const char itgAddress = 0x68;
extern char itgAddress;
char itgAddress = 0x68;
You *don't* want to do anything that allocates memory in a header file.
(There are several other bugs with this Arduino compiler I have found the hard way that are documented elsewhere).
Quote(There are several other bugs with this Arduino compiler I have found the hard way that are documented elsewhere).Care to shair what these are?
Thanks, johnwasser, for the post. I have since changed all of my allocated variables to pound defines to avoid the problem I was having. I will take your advice in the future about using const and externs.Though, this http://code.google.com/p/arduino/issues/detail?id=906&q=preprocessor documented problem seems to be exactly what I've been fighting for a while.While two files include "Gyro.h", the pre-processor directives should indicate to the compiler to only create one copy of Gyro.h and link the other files against it, which (I would think) prevent the multiple inclusion problem.I will switch to my Ubuntu drive in a minute to see how gcc handles this situation.
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16