Search code examples
winavr

main.c:19: undefined reference to `usbInit' & undefined reference to `usbPoll'


I faced with this error in building my project using v-usb library.followed is my code :

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>

#include "usbdrv.h"




#include <util/delay.h>

USB_PUBLIC uchar usbFunctionSetup(uchar data[8]) {
    return 0; // do nothing for now
}

int main() {

uchar i;

wdt_enable(WDTO_1S); // enable 1s watchdog timer

usbInit();

usbDeviceDisconnect(); // enforce re-enumeration
for(i = 0; i<250; i++) { // wait 500 ms
    wdt_reset(); // keep the watchdog happy
    _delay_ms(2);
}
usbDeviceConnect();

sei(); // Enable interrupts after re-enumeration

while(1) {
    wdt_reset(); // keep the watchdog happy
    usbPoll();
}

return 0;
}

and this is relative part in usbdrv.h:

 #ifndef USB_PUBLIC

 #define USB_PUBLIC

 #endif

USB_PUBLIC void usbInit(void);

USB_PUBLIC void usbPoll(void)

can someone help me?


Solution

  • i guess you have forgotten to add the usbdrv-c files to your makefile or may be they are already compiled and you have to add them as a lib to your make file. (But afair with v-usb you have to add c-files)

    Please read the documentation of the library and look at the numerous examples that are available for v-usb.