CDC Class added to USB Device Library!

General discussion on Libstock website & codes posted on this website.
Author
Message
User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

CDC Class added to USB Device Library!

#1 Post by anikolic » 21 May 2013 10:38

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
Web Department Manager

Toley
Posts: 922
Joined: 03 Sep 2008 16:17

Re: CDC Class added to USB Device Library!

#2 Post by Toley » 21 May 2013 11:13

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 ?
Serge T.
Learning is an endeless process but it must start somewhere!

rus51
Posts: 169
Joined: 31 Oct 2010 07:23
Location: Australia

Re: CDC Class added to USB Device Library!

#3 Post by rus51 » 22 May 2013 06:48

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

Toley
Posts: 922
Joined: 03 Sep 2008 16:17

Re: CDC Class added to USB Device Library!

#4 Post by Toley » 22 May 2013 11:38

Thanks rus51.
Serge T.
Learning is an endeless process but it must start somewhere!

chimimic
Posts: 178
Joined: 29 Sep 2007 14:35
Location: France
Contact:

Re: CDC Class added to USB Device Library!

#5 Post by chimimic » 25 May 2013 15:39

Thanks ME ! :D

tyzanu
Posts: 182
Joined: 21 Aug 2011 17:27
Contact:

Re: CDC Class added to USB Device Library!

#6 Post by tyzanu » 29 May 2013 13:02

Thanks, good library... :P

tyzanu
Posts: 182
Joined: 21 Aug 2011 17:27
Contact:

HELP CDC Class added to USB Device Library!

#7 Post by tyzanu » 31 May 2013 11:40

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

}

tyzanu
Posts: 182
Joined: 21 Aug 2011 17:27
Contact:

Re: CDC Class added to USB Device Library!

#8 Post by tyzanu » 31 May 2013 13:01

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...

mfranco
Posts: 10
Joined: 01 Jun 2013 21:51

Re: CDC Class added to USB Device Library!

#9 Post by mfranco » 01 Jun 2013 22:24

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.

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: CDC Class added to USB Device Library!

#10 Post by dejan.odabasic » 03 Jun 2013 17:52

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.

tyzanu
Posts: 182
Joined: 21 Aug 2011 17:27
Contact:

Re: CDC Class added to USB Device Library!

#11 Post by tyzanu » 09 Jun 2013 09:35

Hello, exist driver CDC for linux???????

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: CDC Class added to USB Device Library!

#12 Post by dejan.odabasic » 10 Jun 2013 08:22

Hello,

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

Best regards.

bobihot
Posts: 2
Joined: 20 Jun 2013 16:33

Re: CDC Class added to USB Device Library!

#13 Post by bobihot » 20 Jun 2013 18:27

For Avr pascal ?

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: CDC Class added to USB Device Library!

#14 Post by dejan.odabasic » 21 Jun 2013 08:20

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.

yzubek
Posts: 1
Joined: 07 Aug 2013 13:51

Re: CDC Class added to USB Device Library!

#15 Post by yzubek » 07 Aug 2013 18:47

I have to connect a GPS on a PIC18F4550 using the CDC class. Is there any possibility to use this microcontroller as master?

Post Reply

Return to “Libstock Discussion”