سؤال

I'm using the ChibiOS/RT operating system, trying to get the USB to Serial library to work. I have managed to link all the files together and it ran with Yagarto. but I can't seem to even use the start function of the USB to Serial lib.

I am using STM32F4 Discovery and want to use its USB as a connection to the PC. I've done that using the CDC class with IAR but I wanted to use ChibiOS for this project and it all seems so overcomplicated. (I have used ChibiOS but only the UART and some port toggling leds and stuff).

Can you give me an example code to start up the USB? I have been unable to find anything.

sduStart( ??? , ??? ); // I saw what parameters it wants in there but I cannot figure what to actually put :/
هل كانت مفيدة؟

المحلول

First parameter is a pointer to SerialUSBDriver, defined like this:

SerialUSBDriver SDU1;

Second parameters is a pointer to SerialUSBConfig, defined like this:

SerialUSBConfig SDU1_cfg = {                                                     
    .usbp     = &USBD1,      // USB driver to use                                
    .int_in   = CDC_IRQ_EP,  // Interrupt IN endpoint used for notifications        
    .bulk_in  = CDC_DATA_EP, // Bulk IN endpoint used for outgoing data transfer 
    .bulk_out = CDC_DATA_EP  // Bulk OUT endpoint used for incoming data transfer
};

You should define your proper endpoint numbers CDC_IRQ_EP and CDC_DATA_EP. In my particular case they are defined like this (but this is not relevant):

#define CDC_IRQ_EP   6
#define CDC_DATA_EP  7

So the working call should be something like:

sduStart(&SDU1, &SDU1_cfg);

Hope this helps.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top