Hey, so I face a linker issue (I assume so...) I am using a 'bmm050' driver where they have two pointers and a struct defined as:
#define BMM050_WR_FUNC_PTR \ s8 (*bus_write)(u8, u8, \ u8 *, u8) #define BMM050_RD_FUNC_PTR \ s8 (*bus_read)(u8, u8, \ u8 *, u8) struct bmm050_t { u8 company_id;/**<mag chip id*/ u8 dev_addr;/**<mag device address*/ BMM050_WR_FUNC_PTR;/**< bus write function pointer*/ BMM050_RD_FUNC_PTR;/**< bus read function pointer*/ void (*delay_msec)(BMM050_MDELAY_DATA_TYPE);/**< delay function pointer*/ s8 dig_x1;/**< trim x1 data */ s8 dig_y1;/**< trim y1 data */ s8 dig_x2;/**< trim x2 data */ s8 dig_y2;/**< trim y2 data */ u16 dig_z1;/**< trim z1 data */ s16 dig_z2;/**< trim z2 data */ s16 dig_z3;/**< trim z3 data */ s16 dig_z4;/**< trim z4 data */ u8 dig_xy1;/**< trim xy1 data */ s8 dig_xy2;/**< trim xy2 data */ u16 dig_xyz1;/**< trim xyz1 data */ };
In my application I do the following to assign the function to the pointer:
bmm050.bus_write = i2c_write; bmm050.bus_read = i2c_read;
Where the two functions are defined as follows:
int8_t i2c_write(uint8_t dev_addr, uint8_t reg_addr, uint8_t *reg_data, uint8_t count); int8_t i2c_read(uint8_t dev_addr, uint8_t reg_addr, uint8_t *reg_data, uint8_t count);
After compiling I get errors:
Severity Code Description Project File Line Error undefined reference to `_write' Project1 C:\Users\ab\Documents\Atmel Studio\7.0\Project1\Project1\Debug\writer.c 1 Error undefined reference to `_read' Project1 C:\Users\ab\Documents\Atmel Studio\7.0\Project1\Project1\Debug\readr.c 1 Error ld returned 1 exit status Project1 collect2.exe 0
I tried changing the driver's code, etc. but to no avail. I now settled on the hypothesis that this is a linker's issue, however, I have no idea how to solve it... All suggestions are welcome!