This is the mail archive of the ecos-devel@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: STM32 USB support


Simon Kallweit wrote:

> Chris, do you have any example code using your driver?

There's the high-level driver for my application, but that's quite
involved and will probably obscure more than it illuminates...

> I may be working on USB serial and ethernet support. 

Ethernet for the STM32?  I'd considered having a stab at a driver for
one of the SPI based Ethernet chips (either the Micrel or Microchip) but
just don't have the time right now.

> The USB serial driver at least seems to be tailored
> for the AT91 driver right now and cannot be used generically yet. We
> could change that to use dynamic setup of endpoints, which I think would
> be a great idea.

I've just had a look at the code and it shouldn't be too hard.  The key
change is that in order to obtain a handle on the endpoint data
structures you need to wait for endpoint configuration to complete
(which the serial driver does anyway):

//
--------------------------------------------------------------------------
// Block the calling thread until the USB is configured.

void
usbs_serial_wait_until_configured(void)
{
  cyg_mutex_lock(&usbs_serial_lock);
  while (usbs_serial_state != USBS_STATE_CONFIGURED)
    cyg_cond_wait(&usbs_serial_state_cond);
  cyg_mutex_unlock(&usbs_serial_lock);
}

Then you can get a handle on the endpoint data structures by calling one
of the following functions (see the STM32 USB header).

cyg_usbs_cortexm_stm32_tx_endpoint (...)
cyg_usbs_cortexm_stm32_rx_endpoint (...)

This replaces the static way of doing it, where the following lines from
the USB serial driver specify the statically allocated endpoint data
structures:

extern usbs_tx_endpoint         CYGDAT_IO_USB_SLAVE_SERIAL_TX_EP;
extern usbs_rx_endpoint         CYGDAT_IO_USB_SLAVE_SERIAL_RX_EP;

And these are hooked directly into the following static data structure:

usbs_serial usbs_ser0 = {
    tx_ep:      TX_EP,
    rx_ep:      RX_EP,
    tx_result:  0,
    rx_result:  0,
};

Everything else looks fine.  The STM32 driver should automatically parse
the device descriptors so that it looks like the 'standard' serial
device.  If you don't have any luck with it I might have time to play
with it at the weekend.

Chris.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]