Page 1 of 5

CDC Class added to USB Device Library!

Posted: 21 May 2013 10:38
by anikolic
CDC Class added to USB Device Library!

USB Device library gets a new addition - Communications Device Class.

Image

The comprehensive new USB Device Library gets a great update. Upon your request, we have
added Communication Device Class (CDC). We provided Virtual COM port example as a quick starter
project to help you get around easily. Make sure to visit Libstock and download the new update now!

Yours sincerely,
mikroElektronika

Re: CDC Class added to USB Device Library!

Posted: 21 May 2013 11:13
by Toley
Very nice addition. I've done a quick test and it works well. But I have a little question. I have noticed that VID is 0x0000 and PID is 0x0400, can this be changed if someone has is own VID/PID ?

Re: CDC Class added to USB Device Library!

Posted: 22 May 2013 06:48
by rus51
Open up the PC driver info file VCPDriver.inf in Notepad and change both the PID and VID numbers. Open the mC VCD_Descriptor.c file in Notepad or mE IDE and change the idVendor and idProduct numbers. Recompile mE code and load it onto the target MCU. Go to the PC Control Panel Hardware manager and re-install the driver for the mE serial port. Connect target board to PC.

rus51

Re: CDC Class added to USB Device Library!

Posted: 22 May 2013 11:38
by Toley
Thanks rus51.

Re: CDC Class added to USB Device Library!

Posted: 25 May 2013 15:39
by chimimic
Thanks ME ! :D

Re: CDC Class added to USB Device Library!

Posted: 29 May 2013 13:02
by tyzanu
Thanks, good library... :P

HELP CDC Class added to USB Device Library!

Posted: 31 May 2013 11:40
by tyzanu
How do I send a string on the show?I can not send...
I tried several methods but nothing...

/*
* Project name:
Virtual COM Port Demo
* Description
Example showing usage USB CDC device that functions as a generic virtual
COM port. The example echoes data sent via USART terminal.
* Test configuration:
MCU: P18F4550
dev.board: EasyPIC v7 Connectivity
http://www.mikroe.com/easypic/
Oscillator: HS-PLL, 48.000MHz
Ext. Modules: None.
SW: mikroC PRO for PIC
http://www.mikroe.com/mikroc/pic/
Notes: Example uses CDC Driver included in Windows. An .inf file
is supplied with the example in order to match the driver
with this device (user must guide driver installation
wizard to the VCPDriver folder).

*/

#include <stdint.h>

// Buffer of 64 bytes
char buffer[64] absolute 0x500;
char aa[64];
// USB interrupt service routine
void interrupt(){
// Call library interrupt handler routine
USBDev_IntHandler();
}

void USBDev_CDCParamsChanged(){

}

extern const uint8_t _USB_CDC_BULK_EP_IN; // Data interface IN endpoint
extern const uint8_t _USB_CDC_BULK_EP_OUT; // Data interface OUT endpoint
uint8_t dataReceived = 0;
uint16_t dataReceivedSize;

void USBDev_CDCDataReceived(uint16_t size){
dataReceived = 1;
dataReceivedSize = size;
}

void main(void){
ADCON1 |= 0x0F; // Configure all ports with analog function as digital
CMCON |= 7; // Disable comparators

// Initialize CDC Class
USBDev_CDCInit();

// Initialize USB device module
USBDev_Init();

// Enable USB device interrupt
IPEN_bit = 1;
USBIP_bit = 1;
USBIE_bit = 1;
GIEH_bit = 1;

// Wait until device is configured (enumeration is successfully finished)
while(USBDev_GetDeviceState() != _USB_DEV_STATE_CONFIGURED)
;

// Set receive buffer where received data is stored
USBDev_CDCSetReceiveBuffer(buffer);

// Infinite loop
while(1){
if(dataReceived == 1){
dataReceived = 0;
// Send back received packet
USBDev_CDCSetReceiveBuffer(buffer);
USBDev_CDCSendData(buffer, dataReceivedSize);
}

USBDev_CDCSendData("dasf", 10);///not work correct
delay_ms(1000);
}

}

Re: CDC Class added to USB Device Library!

Posted: 31 May 2013 13:01
by tyzanu
i solved with next function:

Code: Select all

void SendUart(char aa[64])
{
 int i;
 for(i = 0; i<strlen(aa); i++)
 {
  buffer[i] = aa[i];
 }
 USBDev_CDCSendData(buffer, strlen(aa));
}

thanks...

Re: CDC Class added to USB Device Library!

Posted: 01 Jun 2013 22:24
by mfranco
I appologize if this question is out of topic (also, I have just written a new post regarding my question below, which is waiting for aproval).

I have just purchased EasyPic Fusion v7 board, as I will need to develop a new printer with USB and Ethernet capabilities. As I would like to start with the USB part of the project, after reading lots and lots of tutorials and Application Notes, sometimes I think I am getting even more confused.

From what I could understand, 99,9% of the examples I found develop the projects considering the HID class, as there are plenty of usb-ready device libraries with simple functions to be used. Also, there is no need to develop custom host-side drivers, as any OS already has HID drivers. So, people just build some blinking led project on top of this HID class, using some very simple functions, such as HID_Enable, etc...

However, if I need to develop some device hardware that is not classified as HID, how do I start? Is there any kind of USB device library to use, or do I need to write every single function from scratch?

Can I use Mikroelektronika's USB library to write firmware for non-HID devices?

Thank you all in advance.

Re: CDC Class added to USB Device Library!

Posted: 03 Jun 2013 17:52
by dejan.odabasic
Hello,

Please take a look at my answer to your question on your topic:
http://www.mikroe.com/forum/viewtopic.p ... 27#p215327

Best regards.

Re: CDC Class added to USB Device Library!

Posted: 09 Jun 2013 09:35
by tyzanu
Hello, exist driver CDC for linux???????

Re: CDC Class added to USB Device Library!

Posted: 10 Jun 2013 08:22
by dejan.odabasic
Hello,

Linux doesn't require additional CDC drivers, it should already have support for CDC USB devices.

Best regards.

Re: CDC Class added to USB Device Library!

Posted: 20 Jun 2013 18:27
by bobihot
For Avr pascal ?

Re: CDC Class added to USB Device Library!

Posted: 21 Jun 2013 08:20
by dejan.odabasic
Hello,

We have in our plans development of USB support for AVR(including CDC class), but currently I cannot specify any date.

Thank you for understanding.

Best regards.

Re: CDC Class added to USB Device Library!

Posted: 07 Aug 2013 18:47
by yzubek
I have to connect a GPS on a PIC18F4550 using the CDC class. Is there any possibility to use this microcontroller as master?