Using V-USB on ATMEGA328P with Arduino
Posted: Wed Sep 19, 2012 11:23 pm
I'm trying to use V-USB in a "C" program with the Arduino IDE programming an atmega328p and although I have the V-USB downloaded and have put the "vusbdrv" folder complete in the libraries section of my arduino sketchbook . All the ".h and .c" files are available there as is "usbconfig.h" it does not seem to be able to get and use the functions? I get this error message on compile
VUSBExample1.cpp.o: In function `main':
VUSBExample1.cpp:22: undefined reference to `usbInit()'
VUSBExample1.cpp:35: undefined reference to `usbPoll()'
I have spent a lot of time reading through V-USB documentation and cannot see why it should not work with the Arduino IDE
Does anybody have any knowledge of using V-USB with the Arduino IDE ? I use Arduino Version 1.0.1 to program the chip
Here is the code I am trying to compile
VUSBExample1.cpp.o: In function `main':
VUSBExample1.cpp:22: undefined reference to `usbInit()'
VUSBExample1.cpp:35: undefined reference to `usbPoll()'
I have spent a lot of time reading through V-USB documentation and cannot see why it should not work with the Arduino IDE
Does anybody have any knowledge of using V-USB with the Arduino IDE ? I use Arduino Version 1.0.1 to program the chip
Here is the code I am trying to compile
Code: Select all
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include "usbdrv.h"
#define F_CPU 16000000L
#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;
}