[DONE] DualCDC associate new SerialUSBDriver
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: [DONE] DualCDC associate new SerialUSBDriver
Thanks for explaining it in details, I think I found the problem.
The SerialUSB driver used the "param" field in the USBDriver structure, of course multiple instances would conflict in writing it. I had to associate a void* parameter to each endpoint, this way upper layers objects can register themselves as "handlers" of specific endpoints, this allows to obtain the SerialUSB object pointer from the USBDriver object and endpoint number.
Please check on your side, note that the signature of the void sduConfigureHookI(); function had to change, now it is:
void sduConfigureHookI(SerialUSBDriver *sdup);
Giovanni
The SerialUSB driver used the "param" field in the USBDriver structure, of course multiple instances would conflict in writing it. I had to associate a void* parameter to each endpoint, this way upper layers objects can register themselves as "handlers" of specific endpoints, this allows to obtain the SerialUSB object pointer from the USBDriver object and endpoint number.
Please check on your side, note that the signature of the void sduConfigureHookI(); function had to change, now it is:
void sduConfigureHookI(SerialUSBDriver *sdup);
Giovanni
Re: [DONE] DualCDC associate new SerialUSBDriver
Hi Giovanni,
thank you so much, now it work very well.
2 shell is ok,
2 write command in both shell in the same instant is ok.
Tomorrow I submit your patch in usb_lld STM32 to Dmytro for MIPS-PIC32, and I post a better code example for Dual CDC,
I hope it is useful to someone.
thank you so much, now it work very well.
2 shell is ok,
2 write command in both shell in the same instant is ok.
Tomorrow I submit your patch in usb_lld STM32 to Dmytro for MIPS-PIC32, and I post a better code example for Dual CDC,
I hope it is useful to someone.
Re: [DONE] DualCDC associate new SerialUSBDriver
I will need to use dual cdc multiplexed over one usb, and have some difficulties to summarize this thread.
Is it working with stm32 now with 2.6.6 ?
In the last post there was a proposal for a code example of working dual cdc, is there a link to this ?
Thanks for any help,
Alexandre
Is it working with stm32 now with 2.6.6 ?
In the last post there was a proposal for a code example of working dual cdc, is there a link to this ?
Thanks for any help,
Alexandre
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: [DONE] DualCDC associate new SerialUSBDriver
I don't understand how to create dual cdc.
What i have done (and which don't work) :
I have modified ARMCM4-STM32F407-DISCOVERY-MEMS with the goal tu just add another CDC.
I have duplicated usbcfg.[ch] in usbcfg1.[ch] and usbcfg2.[ch],
leaving usbcfg1.[ch] as exact copy, and in usbcfg2.c, i have used
different ENDPOINT index :
then in the main I include both .h, and initialize both CDC :
it compiles, runs, but i see only one CDC over USB
If someone can show me the obvious error, it will help me
Alexandre
What i have done (and which don't work) :
I have modified ARMCM4-STM32F407-DISCOVERY-MEMS with the goal tu just add another CDC.
I have duplicated usbcfg.[ch] in usbcfg1.[ch] and usbcfg2.[ch],
leaving usbcfg1.[ch] as exact copy, and in usbcfg2.c, i have used
different ENDPOINT index :
Code: Select all
#define USBD1_DATA_REQUEST_EP 3
#define USBD1_DATA_AVAILABLE_EP 3
#define USBD1_INTERRUPT_REQUEST_EP 4
then in the main I include both .h, and initialize both CDC :
Code: Select all
sduObjectInit(&SDU1);
sduStart(&SDU1, &serusbcfg1);
sduObjectInit(&SDU2);
sduStart(&SDU2, &serusbcfg2);
/*
* Activates the USB driver and then the USB bus pull-up on D+.
* Note, a delay is inserted in order to not have to disconnect the cable
* after a reset.
*/
usbDisconnectBus(serusbcfg1.usbp);
chThdSleepMilliseconds(1000);
usbStart(serusbcfg1.usbp, &usbcfg1);
usbStart(serusbcfg2.usbp, &usbcfg2);
usbConnectBus(serusbcfg1.usbp);
it compiles, runs, but i see only one CDC over USB
If someone can show me the obvious error, it will help me
Alexandre
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: [DONE] DualCDC associate new SerialUSBDriver
You only need to start the USB driver once, it is the same USB port. The difficulty is in writing the descriptors for two CDC in a single device. I think somebody posted an example a while ago.
Giovanni
Giovanni
Re: [DONE] DualCDC associate new SerialUSBDriver
Ok, thanks, have done the descriptor, but now how do i deal with the fact that there is two set of endpoints, and two SDU in
the usb_event callback .
from the original demo with one CDC :
SDU1 and usbInitEndpointI are hardcoded, but with two CDC, i have to dynamically chose, how could i do that ?
Alexandre
the usb_event callback .
from the original demo with one CDC :
Code: Select all
static void usb_event(USBDriver *usbp, usbevent_t event) {
extern SerialUSBDriver SDU1;
switch (event) {
case USB_EVENT_RESET:
return;
case USB_EVENT_ADDRESS:
return;
case USB_EVENT_CONFIGURED:
chSysLockFromIsr();
/* Enables the endpoints specified into the configuration.
Note, this callback is invoked from an ISR so I-Class functions
must be used.*/
usbInitEndpointI(usbp, SER1_USBD1_DATA_REQUEST_EP, &ep1config);
usbInitEndpointI(usbp, SER1_USBD1_INTERRUPT_REQUEST_EP, &ep2config);
/* Resetting the state of the CDC subsystem.*/
sduConfigureHookI(&SDU1);
chSysUnlockFromIsr();
return;
case USB_EVENT_SUSPEND:
return;
case USB_EVENT_WAKEUP:
return;
case USB_EVENT_STALLED:
return;
}
return;
}
SDU1 and usbInitEndpointI are hardcoded, but with two CDC, i have to dynamically chose, how could i do that ?
Alexandre
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: [DONE] DualCDC associate new SerialUSBDriver
The CDCs should be active at the same time, you need to init the enpoints for both in that code then do sduConfigureHookI() for both.
Post the descriptors, I could give it a try later.
Giovanni
Post the descriptors, I could give it a try later.
Giovanni
Re: [DONE] DualCDC associate new SerialUSBDriver
Post the descriptors, I could give it a try later.
Weel, my actuel descriptor is 141 bytes long, and i just have read in another thread that there is an hard limitation at 127 bytes,
so i should first try to see is it is possible to make a dual cdc descriptor in 127 bytes i guess.
Alexandre
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times