Web lists-archives.com

[Spca50x-devs] Need Help-Is_host_pipe_error()






Hello,
I am trying to read a global register of my webcam using ATMEL AVR USB MCU[AT90USB1287]. The MCU has detected the camera and allocated pipes and is running in the host mode. I am using a sample audio_host_project provided by ATMEL which can stream data from USB Microphone. Now

http://www.atmel.com/dyn/resources/prod_documents/at90usb128-demo-host-audio-1_0_0-doc.zip

In the firmware i have used a macro to read from a global register. But gives  me only a pipe_error

#define spca5xxRegRead(address)        (usb_request.bmRequestType = 0xC1,\
                                        usb_request.bRequest      = 0x00,\
                                        usb_request.wValue        = 0,\
                                        usb_request.wIndex        = (U16)address,\
                                        usb_request.wLength       = 1,\
                                        usb_request.uncomplete_read = FALSE,\
                                        host_send_control(data_check))

and the

/**
 * host_send_control.
 *
 * @brief This function is the generic Pipe 0 management function
 * This function is used to send and receive control request over pipe 0
 *
 * @todo Fix all timeout errors and disconnection in active wait loop
 *
 * @param data_pointer
 *
 * @return status
 *
 * @note This function uses the usb_request global structure as parameter.
 * Thus this structure should be filled before calling this function.
 *
 */
U8 host_send_control(U8* data_pointer)
{
U16 data_length;
U8 sav_int_sof_enable;
U8 c;

   Usb_ack_event(EVT_HOST_SOF);
   sav_int_sof_enable=Is_host_sof
_interrupt_enabled();
   Host_enable_sof_interrupt();                   // SOF software detection is in interrupt sub-routine
   while(Is_not_usb_event(EVT_HOST_SOF))          // Wait 1 sof
   {
      if (Is_host_emergency_exit())
      {
         //c=1;                                    //#add, No
         c=CONTROL_TIMEOUT;
         Host_freeze_pipe();
         Host_reset_pipe(0);
         goto host_send_control_end;
      }
   }
   if (sav_int_sof_enable==FALSE)
   {
      Host_disable_sof_interrupt();
   }

   Host_select_pipe(0);
   Host_set_token_setup();
   Host_ack_setup();
   Host_unfreeze_pipe();
  // Build the setup request fields
   Host_write_byte(usb_request.bmRequestType);
   Host_write_byte(usb_request.bRequest);
   Host_write_byte(LSB(usb_request.wValue));
   Host_write_byte(MSB(usb_request.wValue));
   Host_write_byte(LSB(usb_request.wIndex));
   Host_write_byte(MSB(usb_request.wIndex));
   Host_write_byte(LSB(usb_request.wLength));
   Host_write_byte(MSB(usb_request.wLength));

   Host_send_setup();
   while(Is_host_setup_sent() == FALSE)  // wait for SETUP ack
   {
      if (Is_host_emergency_exit())
      {
         //c=2;                                    //#add, No
         c=CONTROL_TIMEOUT;
         Host_freeze_pipe();
         Host_reset_pipe(0);
         goto host_send_control_end;
      }
      if(Is_host_pipe_error())           // Any error ?
      {
         c=6;                                    //#add, Yes Pipe Error, Time Out, c=08
         //c = Host_error_status();
         Host_ack_all_errors();
         goto host_send_control_end;     // Send error status
      }
   }
  // Setup token sent now send In or OUT token
  // Before just wait one SOF
   Usb_ack_event(EVT_HOST_SOF);
   sav_int_sof_enable=Is_host_sof_interrupt_enabled();
   Host_enable_sof_interrupt();
   Host_freeze_pipe();
   data_length = usb_request.wLength;
   while(Is_not_usb_event(EVT_HOST_SOF))         // Wait 1 sof
   {
      if (Is_host_emergency_exit())
      {
         //c=3;                                    //#add, No
         c=CONTROL_TIMEOUT;
         Host_freeze_pipe();
         Host_reset_pipe(0);
         goto host_send_control_end;
      }
   }
   if (sav_int_sof_enable==FALSE)
   {  Host_disable_sof_interrupt();  }   // Restore SOF interrupt enable

  // IN request management ---------------------------------------------
   if(usb_request.bmRequestType & 0x80)           // bmRequestType : Data stage IN (bmRequestType==1)
   {
      Host_standard_in_mode();
      Host_set_token_in();
      while(data_length != 0)
      {
         Host_unfreeze_pipe();
         while(!Is_host_control_in_received())
         {
            if (Is_host_emergency_exit())
            {
               //c=4;                                    //#add, No
               c=CONTROL_TIMEOUT;
               Host_freeze_pipe();
               Host_reset_pipe(0);
               goto host_send_control_end;
            }
            if(Is_host_pipe_error())
            {
               //c=7;                                    //#add, No
               c = Host_error_status();
               Host_ack_all_errors();
               goto host_send_control_end;
            }
            if(Is_host_stall())
            {
               c=CONTROL_STALL;
               Host_ack_stall();
               goto host_send_control_end;
            }
         }
         c = Host_data_length_U8();
         if (c == Host_get_pipe_length())
         {
            data_length -= c;
            if (usb_request.uncomplete_read == TRUE)           // uncomplete_read
            {
               data_length = 0;
            }
         }
         else
         {
            data_length = 0;
         }
         while (c!=0)
         {
            *data_pointer = Host_read_byte();
            data_pointer++;
            c--;
         }
         Host_freeze_pipe();
         Host_ack_control_in();
         Host_send_control_in();
      }                                // end of IN data stage

      Host_set_token_out();
      Host_unfreeze_pipe();
      Host_ack_control_out();
      Host_send_control_out();
      while(!Is_host_control_out_sent())
      {
         if (Is_host_emergency_exit())
         {
            //c=5;                                    //#add, No
            c=CONTROL_TIMEOUT;
            Host_freeze_pipe();
            Host_reset_pipe(0);
            goto host_send_control_end;
         }
         if(Is_host_pipe_error())
         {
            //c=9;                                    //#add
            c = Host_error_status();
            Host_ack_all_errors();
            goto host_send_control_end;
         }
         if(Is_host_stall())
         {
            c=CONTROL_STALL;
            Host_ack_stall();
            goto host_send_control_end;
         }
      }
      Host_ack_control_out();
      c=(CONTROL_GOOD);
      goto host_send_control_end;
   }

  // OUT request management ---------------------------------------------
   else                                 // Data stage OUT (bmRequestType==0)
   {
      Host_set_token_out();
      Host_ack_control_out();
      while(data_length != 0)
      {
         Host_unfreeze_pipe();
         c = Host_get_pipe_length();
         if ( (U16)c > data_length)
         {
            c = (U8)data_length;
            data_length = 0;
         }
         else
         {
            data_length -= c;
         }
         while (c!=0)
         {
            Host_write_byte(*data_pointer);
            data_pointer++;
            c--;
         }
         Host_send_control_out();
         while (!Is_host_control_out_sent())
         {
            if (Is_host_emergency_exit())
            {
               c=CONTROL_TIMEOUT;
               Host_freeze_pipe();
               Host_reset_pipe(0);
               goto host_send_control_end;
            }
            if(Is_host_pipe_error())
            {
               c = Host_error_status();
               Host_ack_all_errors();
               goto host_send_control_end;
            }
            if(Is_host_stall())
            {
               c=CONTROL_STALL;
               Host_ack_stall();
               goto host_send_control_end;
            }
         }
         Host_ack_control_out();
      }                                // end of OUT data stage
      Host_freeze_pipe();
      Host_set_token_in();
      Host_unfreeze_pipe();
      while(!Is_host_control_in_received())
      {
         if (Is_host_emergency_exit())
         {
            c=CONTROL_TIMEOUT;
            Host_freeze_pipe();
            Host_reset_pipe(0);
            goto host_send_control_end;
         }
         if(Is_host_pipe_error())
         {
            c = Host_error_status();
            Host_ack_all_errors();
            goto host_send_control_end;
         }
         if(Is_host_stall())
         {
            c=CONTROL_STALL;
            Host_ack_stall();
            goto host_send_control_end;
         }
      }
      Host_ack_control_in();
      Host_freeze_pipe();
      Host_send_control_in();
      c=(CONTROL_GOOD);
      goto host_send_control_end;
   }
host_send_control_end:
   return ((U8)c);
}


Now the MCU is in the  Is_host_pipe_error() stage. What may be the possible solutions..??

Thank you

George Neil
Design Engineer
E-Smart Satellite and Telecommunication
GCDA Complex, Kerala
India.
Pin: 682031
Telephone: +91 484 2352310
Fax: +91 484 2364850

























-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Spca50x-devs mailing list
Spca50x-devs@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/spca50x-devs