Page 1 of 1

Using V-USB on ATMEGA328P with Arduino

Posted: Wed Sep 19, 2012 11:23 pm
by tytower
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

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;
}

Re: Using V-USB on ATMEGA328P with Arduino

Posted: Fri Sep 21, 2012 1:01 pm
by ulao
Have you put the usbconfig.c in the make? Can you show us your make file.

Re: Using V-USB on ATMEGA328P with Arduino

Posted: Wed Oct 03, 2012 11:56 pm
by Peter Chaffe
the c language of arduino c is not the same as the c language of avr. Your going to need to screw around a lot with the code(not recommended) or Use a real programming environment like avr studio for instance, You will find it compiles no trouble...

Peter

Re: Using V-USB on ATMEGA328P with Arduino

Posted: Thu Oct 04, 2012 1:22 pm
by probono
http://code.google.com/p/vusb-for-arduino/ is what you are looking for