I have a driver and code that works on IAR but does not work for Atmel Studio 7. I get an error ld returned 1 exit status
and undefined reference to '_read'
(or _write
) when I try to assign a function to a pointer inside a struct.
In the driver that I need to use there are two pointers defined as follows:
#define BMM050_WR_FUNC_PTR \
s8 (*bus_write)(u8, u8, \
u8 *, u8)
#define BMM050_RD_FUNC_PTR \
s8 (*bus_read)(u8, u8, \
u8 *, u8)re
In the file they have a struct defined as follows:
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 try to do:
bmm050.bus_write = i2c_write;
bmm050.bus_read = i2c_read;
My functions are defined as:
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);
EDIT: I am attaching the error code as asked:
c:/program files (x86)/atmel/studio/7.0/toolchain/arm/arm-gnu-toolchain/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/armv6-m\libc.a(lib_a-writer.o): In function `_write_r':
C:\Users\aba\Documents\Atmel Studio\7.0\Project1\Project1\Debug\writer.c(1,1): error: undefined reference to `_write'
c:/program files (x86)/atmel/studio/7.0/toolchain/arm/arm-gnu-toolchain/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/armv6-m\libc.a(lib_a-readr.o): In function `_read_r':
C:\Users\aba\Documents\Atmel Studio\7.0\Project1\Project1\Debug\readr.c(1,1): error: undefined reference to `_read'
collect2.exe(0,0): error: ld returned 1 exit status