work with usb on at90usb162

Go To Last Post
47 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi
i try to use the usb of at90usb162 but i don't know i must to have what information to geting start of course i know somewhat things about usb opration .
i search in net and encounter to the LUFA library but when i look at its file more confused! i don't understand for a simple connection to usb i need which file's and how to use them ?

pleas help me

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe start by saying what kind of USB device you are trying to implement - there are lots to choose from HID=keyboard/mice/joystick/etc., CDC=UART/comm port, MSD=mass storage (memory stick), MIDI=music etc., app specific, vendor specific.

if it's just to make a UART/comm connection from a PC terminal program to the AVR then see Dean's examples of CDC in LUFA.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks alot
well i don't ever know these you say !
can you explain for me ?

are these variety of USB classes?

i just want to connect to usb and for example monitor a tempereture or set point or contrlo speed of a dc motor by chenging the pwm.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

i just want to connect to usb and for example monitor a tempereture or set point or contrlo speed of a dc motor by chenging the pwm.

I'd suggest CDC-ACM is the place to start - that way you don't need "special" USB software on the PC - you can just use any terminal program (like Hyperterminal but preferably not Hyperterminal!) and see the logged temperature or type command to the AVR. This means you aren't developing both AVR and PC software at the same time and you know the PC end will work (with the exception of Hyperterminal!)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I'd suggest CDC-ACM is the place to start - that way you don't need "special" USB software on the PC - you can just use any terminal program

this means i don't need to build a dll file for connect to usb?

Quote:

like Hyperterminal but preferably not Hyperterminal!

can i use the terminal emulator in codvision and can i build a terminal with VB(NOT .NET) ?

AND i want to use the exampel of this address :LUFA-111009_3\LUFA-111009\Projects\USBtoSerial
is it good to start with cdc?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

this means i don't need to build a dll file for connect to usb?


Correct you use any software that can open a COMn port.
Quote:

can i use the terminal emulator in codvision and can i build a terminal with VB(NOT .NET) ?

Almost certainly yes and yes.

Quote:

AND i want to use the exampel of this address :LUFA-111009_3\LUFA-111009\Projects\USBtoSerial

Exactly that USB to serial is the place to start. You can ignore the serial output on the "other side" if you want.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

THANK YOU VERY MUCH!
but i have very question in next!

thanks again

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The USBtoSerial demo is designed to be a full USB to Serial converter IC replacement; i.e. it has internal FIFO buffer for sending and receiving to and from the physical USART.

An easier place to start is LUFA\Demos\Device\ClassDriver\VirtualSerial\, which focuses on virtual serial communications over a USB connection that are generated from within the AVR application itself.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

An easier place to start is LUFA\Demos\Device\ClassDriver\VirtualSerial\, which focuses on virtual serial communications over a USB connection that are generated from within the AVR application itself.

do this oprate in CDC class?
and how much the rate of send and recive deta in class?

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

do this oprate in CDC class?

Yes. The USBtoSerial is essentially just an extended version of the demo I quoted, which means it contains more features and code than you need for your application. Stick to the simpler demo.

Quote:

and how much the rate of send and recive deta in class?

I see varying figures, but with double banked 64KB endpoints I've heard figures as high as 2Mb (256KB/s). Remember that the USB AVR controllers may be USB 2.0 compliant, but they can't actually saturate the USB bus even at USB 1.0 Full Speed.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

excuse me i am beginner!
in VirtualSerial folder there are no main.c file this mean that file is exist here are lib for another application?

and what are Doxygen.conf and LUFA VirtualSerial.inf and VirtualSerial.aps files in this folder?

and i want write my code in avrstudio5 so i must copy these file in this folder to my folder application and use the make file that exist here as my make file of project ?

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am also a beginner, but

mojtaba_led wrote:

in VirtualSerial folder there are no main.c file this mean that file is exist here are lib for another application?

no, the main.c file for VirtualSerial is a same VirtualSerial.c and so in all other projects
mojtaba_led wrote:

and what are Doxygen.conf and LUFA VirtualSerial.inf and VirtualSerial.aps files in this folder?

Doxygen.conf is config file for make indexed documents of the project and help
VirtualSerial.aps is project file which opens the program: AVR Studio 4
mojtaba_led wrote:

and i want write my code in avrstudio5 so i must copy these file in this folder to my folder application and use the make file that exist here as my make file of project ?

When you run an AVR Studio 5, select menu: File->Import->AVR STudio 4 Project... and in folder VirtualSerial file: VirtualSerial.aps

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

there are no main.c file

Yes there is:

E:\LUFA101122\Demos\Device\ClassDriver\VirtualSerial>dir
 Volume in drive E is VBOX_linux
 Volume Serial Number is 0000-0805

 Directory of E:\LUFA101122\Demos\Device\ClassDriver\VirtualSerial

27/04/2011  14:55              .
27/04/2011  14:55              ..
22/11/2010  16:24            10,318 Descriptors.c
28/10/2010  17:09             3,287 Descriptors.h
02/08/2010  19:53            67,579 Doxygen.conf
28/10/2010  17:09             3,306 LUFA VirtualSerial.inf
14/10/2010  01:05            21,688 makefile
13/07/2010  16:38             2,850 VirtualSerial.aps
05/11/2010  16:15             5,455 VirtualSerial.c
05/11/2010  16:15             2,610 VirtualSerial.h
14/10/2010  01:05             2,283 VirtualSerial.txt
               9 File(s)        127,568 bytes
               2 Dir(s)  304,529,379,328 bytes free

E:\LUFA101122\Demos\Device\ClassDriver\VirtualSerial>grep main( *.c
VirtualSerial.c:int main(void)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

oh my god why i don't understand ?

Quote:

When you run an AVR Studio 5, select menu: File->Import->AVR STudio 4 Project... and in folder VirtualSerial file: VirtualSerial.aps

i do this and compile but this project write for Atmega128 this means this project can only use for avr that not usb port but i want the usb port of AT90USB162 !??

Quote:

es there is:
Code:
E:\LUFA101122\Demos\Device\ClassDriver\VirtualSerial>dir
Volume in drive E is VBOX_linux
Volume Serial Number is 0000-0805

Directory of E:\LUFA101122\Demos\Device\ClassDriver\VirtualSerial

27/04/2011 14:55

.
27/04/2011 14:55 ..
22/11/2010 16:24 10,318 Descriptors.c
28/10/2010 17:09 3,287 Descriptors.h
02/08/2010 19:53 67,579 Doxygen.conf
28/10/2010 17:09 3,306 LUFA VirtualSerial.inf
14/10/2010 01:05 21,688 makefile
13/07/2010 16:38 2,850 VirtualSerial.aps
05/11/2010 16:15 5,455 VirtualSerial.c
05/11/2010 16:15 2,610 VirtualSerial.h
14/10/2010 01:05 2,283 VirtualSerial.txt
9 File(s) 127,568 bytes
2 Dir(s) 304,529,379,328 bytes free

E:\LUFA101122\Demos\Device\ClassDriver\VirtualSerial>grep main( *.c
VirtualSerial.c:int main(void)


i don't see \VirtualSerial>dir and VirtualSerial>grep main( *.c !?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

grep is a search tool - it searches files for text patterns. I asked it to identify any file that contained "main(" and it said VirtualSerial.c

My point therefore is that the file with the main() function in it here is the one called VirtualSerial.c - there's no law that states that the source file that contains main() must be called main.c

As for using AS5 to build. Start simple and use make at the command prompt.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i change the target to AT90USB162 and compile VirtualSerial.c and program my at90usb162 with FLIP and click on start application then run hyperterminal now i must which com port 1 or 2 or 3 or ...?

this is my sChematic of board that i use :

do i must use library of usart in my application to send and receive data than hypertermianal ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
i do this and compile but this project write for Atmega128 this means this project can only use for avr that not usb port but i want the usb port of AT90USB162 !??

In same folder of project, exist file = makefile.
Find this place and change the code as I did:
MCU = at90usb162

#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------


# MCU name
# MCU = at90usb1287
MCU = at90usb162



# Target board (see library "Board Types" documentation, NONE for projects not requiring

save makefile and rebuild solution. :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

In same folder of project, exist file = makefile.
Find this place and change the code as I did:
MCU = at90usb162
save makefile and rebuild solution.

i do this but yet pc don't detect my board on usb port !
what do i do for exampel display "hello word" on hyper terminal?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

All that is about USB things I check my in Linux. I can not help you...
Can you check if the USB is registered successfully on your PC?

Look how I have checked this:
http://www.youtube.com/watch?v=o...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i must to say i use s usb cable and connect the usb port on at90usb162 to usb port oc pc and program with flip adn then start application without any rs232 connection is this correct ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Look how I have checked this:
http://www.youtube.com/watch?v=o...

excuse me youtube is filter in my country!
can you uplod you'r movie on 4shared or another server?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On Windows you will find usbdeview.exe to by invaluable I think - it's a free download - it tells you loads about the enumeration of USB devices you plug into the PC. Google it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
On Windows you will find usbdeview.exe to by invaluable I think - it's a free download - it tells you loads about the enumeration of USB devices you plug into the PC. Google it.

This is the best solution for you mojtaba_led, as clawson has already said!

and I put a file on site 4shared:
http://www.4shared.com/video/SnG...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks
i download usbdeview.exe and use but i don't see any expect connection than clicck on start application!
my schematic is correct that i use to connect to usb port of pc?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now you know where to look for the problem. I went through this problem and he was on my board...

Whether you're after build successfully programmed device?
Did you put the VirtualSerial.hex file into device by programmer?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Whether you're after build successfully programmed device?

yes,i sure
this is output then compile :
Build succeeded.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
Quote:

Did you put the VirtualSerial.hex file into device by programmer?

yes,i program flash with flip .

and a question , when run aplication what things display on terminal ?
consider i send "mojtaba" to terminal which function i shoud use that to send it?
and what is you'r terminal that use on that movie ?

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

yes,i program flash with flip .

The very fact that Flip (and therefore DFU) work shows that the electronics of the USB interface to the PC are setup correctly. (unless you are holding it in bootloader mode all the time with HWB or something?)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

The very fact that Flip (and therefore DFU) work shows that the electronics of the USB interface to the PC are setup correctly. (unless you are holding it in bootloader mode all the time with HWB or something?)

before i use flip to program my codes to this device and those work corectly
my metod that use is as follow :
1.hold reset then
2.hold hwb then
3.release hwb then
4.release reset then
5.open usb in flip then
6.program flash then
7.click on start application
finish

see i just compile only this cod without any change and excess code ! do i need to add any code ?


#include "VirtualSerial.h"

/** LUFA CDC Class driver interface configuration and state information. This structure is
 *  passed to all CDC Class driver functions, so that multiple instances of the same class
 *  within a device can be differentiated from one another.
 */
USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
	{
		.Config =
			{
				.ControlInterfaceNumber         = 0,

				.DataINEndpointNumber           = CDC_TX_EPNUM,
				.DataINEndpointSize             = CDC_TXRX_EPSIZE,
				.DataINEndpointDoubleBank       = false,

				.DataOUTEndpointNumber          = CDC_RX_EPNUM,
				.DataOUTEndpointSize            = CDC_TXRX_EPSIZE,
				.DataOUTEndpointDoubleBank      = false,

				.NotificationEndpointNumber     = CDC_NOTIFICATION_EPNUM,
				.NotificationEndpointSize       = CDC_NOTIFICATION_EPSIZE,
				.NotificationEndpointDoubleBank = false,
			},
	};

/** Standard file stream for the CDC interface when set up, so that the virtual CDC COM port can be
 *  used like any regular character stream in the C APIs
 */
static FILE USBSerialStream;


/** Main program entry point. This routine contains the overall program flow, including initial
 *  setup of all components and the main program loop.
 */
int main(void)
{
	SetupHardware();

	/* Create a regular character stream for the interface so that it can be used with the stdio.h functions */
	CDC_Device_CreateStream(&VirtualSerial_CDC_Interface, &USBSerialStream);

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	sei();

	for (;;)
	{
		CheckJoystickMovement();

		/* Must throw away unused bytes from the host, or it will lock up while waiting for the device */
		CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);

		CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
		USB_USBTask();
	}
}

/** Configures the board hardware and chip peripherals for the demo's functionality. */
void SetupHardware(void)
{
	/* Disable watchdog if enabled by bootloader/fuses */
	MCUSR &= ~(1 << WDRF);
	wdt_disable();

	/* Disable clock division */
	clock_prescale_set(clock_div_1);

	/* Hardware Initialization */
	Joystick_Init();
	LEDs_Init();
	USB_Init();
}

/** Checks for changes in the position of the board joystick, sending strings to the host upon each change. */
void CheckJoystickMovement(void)
{
	uint8_t     JoyStatus_LCL = Joystick_GetStatus();
	char*       ReportString  = NULL;
	static bool ActionSent    = false;

	if (JoyStatus_LCL & JOY_UP)
	  ReportString = "Joystick Up\r\n";
	else if (JoyStatus_LCL & JOY_DOWN)
	  ReportString = "Joystick Down\r\n";
	else if (JoyStatus_LCL & JOY_LEFT)
	  ReportString = "Joystick Left\r\n";
	else if (JoyStatus_LCL & JOY_RIGHT)
	  ReportString = "Joystick Right\r\n";
	else if (JoyStatus_LCL & JOY_PRESS)
	  ReportString = "Joystick Pressed\r\n";
	else
	  ActionSent = false;

	if ((ReportString != NULL) && (ActionSent == false))
	{
		ActionSent = true;

		/* Write the string to the virtual COM port via the created character stream */
		fputs(ReportString, &USBSerialStream);

		/* Alternatively, without the stream: */
		// CDC_Device_SendString(&VirtualSerial_CDC_Interface, ReportString);
	}
}

/** Event handler for the library USB Connection event. */
void EVENT_USB_Device_Connect(void)
{
	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
}

/** Event handler for the library USB Disconnection event. */
void EVENT_USB_Device_Disconnect(void)
{
	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
}

/** Event handler for the library USB Configuration Changed event. */
void EVENT_USB_Device_ConfigurationChanged(void)
{
	bool ConfigSuccess = true;

	ConfigSuccess &= CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface);

	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
}

/** Event handler for the library USB Control Request reception event. */
void EVENT_USB_Device_ControlRequest(void)
{
	CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface);
}

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi
i can connect to usb and hyperterminal with atmel example for CDC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi
i use the VirtualSerial demo to connect to avr (at90usb162) through usb port .
i change the target on makefile to at90usb162 then make all in winavr and it build succefull the .hex then i program that the hex file by flip on micro then perss the application start on flip then pc detect device as "lufa cdc demo" then i instal it's driver from this address: J:\sampels1\winavr\LUFA\LUFA-111009\Demos\Device\ClassDriver\VirtualSerial
and this driver install succefull with Communications Port name.

but now i can't connect to device by any terminal !

please hlep me for this problem

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That version of LUFA contains a CDC bug that causes the problem you are having - update to the newest (corrected) release and recompile.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi dear dean
thank you

i now download the LUFA-120219 version and make all .
i can to connect with terminal
but
now i want to print a sentence for example i want to display "HELLO WORLD" on terminal to this work , i execes this code in part of progarm of main file :

int main(void)
{	
	fputs("HELLO WORLD"\r\n", &USBSerialStream);
			
			
			
	SetupHardware();

	/* Create a regular character stream for the interface so that it can be used with the stdio.h functions */
	CDC_Device_CreateStream(&VirtualSerial_CDC_Interface, &USBSerialStream);

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	sei();

	for (;;)
	{
		CheckJoystickMovement();

		/* Must throw away unused bytes from the host, or it will lock up while waiting for the device */
		CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);

		CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
		USB_USBTask();
	}
}

/** Configures the board hardware and chip peripherals for the demo's functionality. */
void SetupHardware(void)
{
	/* Disable watchdog if enabled by bootloader/fuses */
	MCUSR &= ~(1 << WDRF);
	wdt_disable();

	/* Disable clock division */
	clock_prescale_set(clock_div_1);

	/* Hardware Initialization */
	Joystick_Init();
	LEDs_Init();
	USB_Init();
}

then againe try make all and the hex file builded then i program with flip and start but now don't display anything on terminal !?

please say to me what i do to dispaly and resive a character than devise through writting ion terminal !

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can't call fputs() before SetupHardware(), or you'll try to write to the USB interface before the USB controller has been initialized. Try placing it just before the main loop.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks alot

now, can you say to me for send data for example a character to the avr through trminal what i do !?
or this better, i say for get data with avr from pc which function to use ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

See:

http://www.fourwalledcubicle.com...

Specifically, you can either use the fgetc() function to get a byte of data from the PC, or you can use the functions listed there to read bytes.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi Dean.

i can't send a digit or character from pc to uc !?

i use follow routin for recive data from pc :

int16_t temp;
char      ReportString2[1];
.
.
.

back:
		USB_USBTask();
	temp = CDC_Device_ReceiveByte (&VirtualSerial_CDC_Interface);
	if(temp<0) goto back;
	itoa(temp,ReportString2,10);	
	
	fputs("\n\r", &USBSerialStream);
	fputs(ReportString2, &USBSerialStream);

this code recive data but send asci code in dec to pc where i want to send digit or charater from pc to pc with uc interface.

can you write an example about recive characther and digit from pc?

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

HI

i can transfer character form pc to pc with follow routin:

//recive_data_function
recive_data_function(){
int ch;
char str[20];

/*recive data form pc then 
send to pc(display on hyper terminal):*/
ch=getc(&USBSerialStream);
while(ch!=EOF){
putc(ch,&USBSerialStream);
fputs("\n\r", &USBSerialStream);
ch=getc(&USBSerialStream);
}

}//recive_data_function

but , the rate of transmit data in above routin is very bad! for example , i must wait to eof check always so when i don't enter a character the routin don't implement so pc lose my charcter !

can tell me a metode to solve this problem?

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi again!
Mr.Camera

what is you'r intent than this follow parsmeter in Config structure?

uint8_t  NotificationEndpointNumber; 
uint16_t NotificationEndpointSize;  
bool     NotificationEndpointDoubleBank; 

i don't understand that what is notification endpoint!?

Please help me.

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

and again, Hi Mr.Camera!

in this part of you'r web tutorial saied, the USB_Init function have two input as blow:


void USB_Init (const uint8_t Mode, const uint8_t Options)

but, in VirtualSerial demo ,used this function without any input,as this blow routin :

void SetupHardware(void)
{
	/* Disable watchdog if enabled by bootloader/fuses */
	MCUSR &= ~(1 << WDRF);
	wdt_disable();

	/* Disable clock division */
	clock_prescale_set(clock_div_1);

	/* Hardware Initialization */
	Joystick_Init();
	LEDs_Init();
	USB_Init();


}

why? what is default input?

thanks again and again!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi
i find out an other thing!

when i delete this blow function from main routin ,

CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);

Is increased the speed of routin implementation !

do we have to use this function in main routin or when we want send or recive data Through usb, for corecte opration ?

please help me!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wowza, I have a dedicated mailing list for LUFA if you have lots of questions to ask:

www.lufa-lib.org/support

In any case, your questions:

Quote:

but , the rate of transmit data in above routin is very bad! for example , i must wait to eof check always so when i don't enter a character the routin don't implement so pc lose my charcter !

can tell me a metode to solve this problem?

It's better to try to read a character and then process it if one was received, without blocking. Sending data should be buffered and you should send it in chunks to make sure as many bytes as possible are packed into each USB packet, otherwise the throughput will be very poor.

Quote:

i don't understand that what is notification endpoint!?

That's part of the CDC (Virtual Serial) USB class - it is used by the class driver to give notifications to the host about changes to the virtual serial port control lines, such as CTS and DCD. You don't interact with the notification endpoint in your code directly, it is used in the CDC driver when you call the various API functions.

Quote:

in this part of you'r web tutorial saied, the USB_Init function have two input as blow:
Code:

void USB_Init (const uint8_t Mode, const uint8_t Options)

but, in VirtualSerial demo ,used this function without any input,as this blow routin :

As the documentation says, you can use various compile time tokens in your makefile or LUFAConfig.h header to reduce the size of the compiled LUFA code, by removing unused portions of the stack and/or fixing certain options as constants at compile time. See this page of the documentation:

http://fourwalledcubicle.com/fil...

In this case, USB_DEVICE_ONLY and USE_STATIC_OPTIONS are used in the project makefile to set the USB driver mode and options statically.

Quote:

do we have to use this function in main routin or when we want send or recive data Through usb, for corecte opration ?

You will need to drain received bytes at some point if the host is trying to send your application data (or the host will become locked up if it has blocking waits for send completion) but you don't need to do it all the time.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi dean
thank you very much for answers.

now,i want to use external 3.3v configuration , i know form data sheet that Set REGDIS bit in REGCR register but how to do this act in lufa ?

thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use USB_OPT_REG_DISABLED:

http://www.fourwalledcubicle.com...

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Wowza, I have a dedicated mailing list for LUFA if you have lots of questions to ask:

I know it'll be convenient for you but this is a shame as I learnt pretty much all I know about LUFA by reading your replies to LUFA questions here on Freaks. I'm not sure I'll be stopping by to read another forum though :-(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Use USB_OPT_REG_DISABLED:

i write this code:

USB_Init(USB_CurrentMode,USB_OPT_REG_DISABLED);

but compiler give this error :

VirtualSerial.c:186: error: too many arguments to function 'USB_Init'
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

oh, excuse me .

i understand you'r intent,now!

is it correct in make file for my request:

 LUFA library compile-time options and predefined tokens
LUFA_OPTS  = -D USB_DEVICE_ONLY
LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_DISABLED | USB_OPT_AUTO_PLL)"
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, that's correct. If you remove the USE_STATIC_OPTIONS=... line in your makefile you can pass those options to the USB_Init() function directly, but the resulting compiled library size will be bigger.

Quote:

I know it'll be convenient for you but this is a shame as I learnt pretty much all I know about LUFA by reading your replies to LUFA questions here on Freaks. I'm not sure I'll be stopping by to read another forum though

It's a matter of keeping a dedicated, focused, searchable resource center for all things LUFA, and to keep the noise off here (or everyone else will get grumpy). It's both a mailing list and an online forum (you can choose either format, same content) so you can get updates emailed to you if you don't want to read over the web version.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!