Using V-USB on ATMEGA328P with Arduino

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
tytower
Posts: 6
Joined: Sun Sep 16, 2012 11:03 pm

Using V-USB on ATMEGA328P with Arduino

Post by tytower » 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

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

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: Using V-USB on ATMEGA328P with Arduino

Post by ulao » Fri Sep 21, 2012 1:01 pm

Have you put the usbconfig.c in the make? Can you show us your make file.

Peter Chaffe
Rank 1
Rank 1
Posts: 20
Joined: Fri Dec 02, 2011 12:25 pm

Re: Using V-USB on ATMEGA328P with Arduino

Post by Peter Chaffe » Wed Oct 03, 2012 11:56 pm

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

probono

Re: Using V-USB on ATMEGA328P with Arduino

Post by probono » Thu Oct 04, 2012 1:22 pm

http://code.google.com/p/vusb-for-arduino/ is what you are looking for

Post Reply