so i'm trying to call a c function in a c file in arduino uno.
using the gcc-avr command it gets compiled successfully:
sudo avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o nrf nrf.c
but on arduino ide, it gives me error of missing functions that the nrf.c is calling which exist in other c files. so how to fix it?
.ino file
#include "nrf.c"
extern "C" // these functions does not exist in c file they are in a .s file
{
void init_serial();
void print_msg();
void light();
}
//----------------------------------------------------
void setup()
{
}
void loop(){
nrf_start1();
light();
}
this is the arduino ide's output:
/tmp/arduino/sketches/8589FEB308F7EAA6CFEF4682C1500C77/sketch/sketch_jul11a.ino.cpp.o (symbol from plugin): In function `nrf_start1()':
(.text+0x0): multiple definition of `__vector_1'
/tmp/arduino/sketches/8589FEB308F7EAA6CFEF4682C1500C77/sketch/nrf.c.o (symbol from plugin):(.text+0x0): first defined here
/tmp/arduino/sketches/8589FEB308F7EAA6CFEF4682C1500C77/sketch/sketch_jul11a.ino.cpp.o (symbol from plugin): In function `nrf_start1()':
(.text+0x0): multiple definition of `message_received'
/tmp/arduino/sketches/8589FEB308F7EAA6CFEF4682C1500C77/sketch/nrf.c.o (symbol from plugin):(.text+0x0): first defined here
/tmp/arduino/sketches/8589FEB308F7EAA6CFEF4682C1500C77/sketch/sketch_jul11a.ino.cpp.o (symbol from plugin): In function `nrf_start1()':
(.text+0x0): multiple definition of `status'
i tried to call the compiled one using extern c
but it did not work
#include
.c files. That's wrong in 99.9% of cases