This is the mail archive of the ecos-discuss@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]

How to send USB enumeration data to host


Hello everyone,

I intend to implement USB driver into my target board.
So I am studying sa11x0 driver relying on Reference Manual,but I can't understand how to start communication to host PC.


According to Reference Manual,in order to start usb operation I should call usbs_start in application.
--- source code begin
usbs_start(usbs_control_endpoint* endpoint)
{
CYG_CHECK_DATA_PTR( endpoint, "A valid USB endpoint must be supplied");
CYG_CHECK_FUNC_PTR( endpoint->start_fn, "The USB endpoint should have a start function");


   (*endpoint->start_fn)(endpoint);
}
--- source code end

In case of sa11x0-driver,start_fn is usbs_sa11x0_ep0_start.

--- source code begin
static ep0_impl ep0 = {
       start_fn:               &usbs_sa11x0_ep0_start,

static void
usbs_sa11x0_ep0_start(usbs_control_endpoint* endpoint)
{
CYG_ASSERT( endpoint == &ep0.common, "USB startup involves the wrong endpoint");


   // Activate the hardware. Write a 0 to the enable/disable bit 0.
   // Bit 1 is read-only. The other bits are set to 1 to disable
   // the corresponding interrupt source.
   usbs_sa11x0_poke(USBS_CONTROL, CONTROL_ALL_INTR, CONTROL_ALL_INTR, 0);
//#define CONTROL_ALL_INTR                0x00FC

   // If there is additional platform-specific initialization to
   // perform, do it now. This macro can come from the platform HAL.
#ifdef SA11X0_USB_PLATFORM_INIT
   SA11X0_USB_PLATFORM_INIT;
#endif

   // Clear any pending interrupts. There should not be any, but just
   // in case. Note: passing 0x00FF as the should_be_clear argument
   // is a race condition, an external event can happen at any time,
   // so we may loop unnecessarily and lose an interrupt. However
   // the initial reset should last for 10ms.
   usbs_sa11x0_poke(USBS_STATUS, 0x00FF, 0x00, 0x00FF);

// The only interrupt really of interest right now is reset, but
// it is likely to be preceded by a resume.
usbs_sa11x0_poke(USBS_CONTROL,
CONTROL_INTR_ENABLE(CONTROL_RESET_INTR | CONTROL_RESUME_INTR), // 01111000
0,
CONTROL_INTR_CLEAR(CONTROL_RESET_INTR | CONTROL_RESUME_INTR)); // 10000100
}
--- source code end


I understand, perusing SA11X0 manual, that it makes all interrupts but Reset-interrupt disable.
I searched where it makes interrupts enable,and found that usbs_sa11x0_init() makes USB-line interrupts enable.


--- source code begin
usbs_sa11x0_init(void)
{

   // It is also possible and desirable to install the interrupt
   // handler here, even though there will be no interrupts for a
   // while yet.
   cyg_drv_interrupt_create(SA11X0_IRQ_USB_SERVICE_REQUEST,
                            99,        // priority
                            0,         // data
                            &usbs_sa11x0_isr,
#ifdef CYGPKG_DEVS_USB_SA11X0_THREAD
                            &usbs_sa11x0_thread_dsr,
#else
                            &usbs_sa11x0_dsr,
#endif
                            &usbs_sa11x0_intr_handle,
                            &usbs_sa11x0_intr_data);
   cyg_drv_interrupt_attach(usbs_sa11x0_intr_handle);
   cyg_drv_interrupt_unmask(SA11X0_IRQ_USB_SERVICE_REQUEST);
}
--- source code end

I studied where usbs_sa11x0_init is called and knew that it is called by way of staic constructor like below,supposing devtab is not used.

--- source code begin
C:\cygwin\opt\el_sc1\ecos\packages\devs\usb\sa11x0\current\src\usbs_sa11x0_data.cxx
class usbs_sa11x0_initialization {
public:
usbs_sa11x0_initialization() {
usbs_sa11x0_init();
}
};
static usbs_sa11x0_initialization usbs_sa11x0_init_object CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_IO);
--- source code end


Although I am not sure,but I think staic constructor is executed before main().
I think,in sa11x0 case,usbs_sa11x0_init() is executed previous to usbs_start() and set interrupts enable.
But after that, usbs_start() is executed and makes interrupts disable.


Where am I wrong and how to enable interrups and start communication to host ?
Please enlighten me.


m mariga


-- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


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