AnsweredAssumed Answered

Multiple bulk endpoints, Out Endpoints stalled?

Question asked by Pete on Feb 9, 2014
So I've been working with the Mass storage example in the STM32_USB-FS-Device_Lib_V4.0.0 on the STM32L100RC and I've been happily communicating on a single out and in bulk endpoints.
My application seems to be forcing me into 2 pairs of in and out endpoints, I have added these to the descriptor, sorted the callbacks and the initialization but I cannot receive any data on the added bulk out endpoint (the callback is never called and USBlyzer says endpoint is stalled) in debugging I'm sending back data on the new in endpoint although this seems to be incorrect data which I'm not sure is related?
so I have defined
Endpoint 1 out
Endpoint 2 in
Endpoint 3 out
Endpoint 4 in

and my various bits of code are:


usb_desc

const uint8_t MASS_ConfigDescriptor[MASS_SIZ_CONFIG_DESC] =
  {
 
    0x09,   /* bLength: Configuration Descriptor size */
    0x02,   /* bDescriptorType: Configuration */
    MASS_SIZ_CONFIG_DESC,
 
    0x00,
    0x01,   /* bNumInterfaces: 1 interface */
    0x01,   /* bConfigurationValue: */
    /*      Configuration value */
    0x00,   /* iConfiguration: */
    /*      Index of string descriptor */
    /*      describing the configuration */
    0x80,   /* bmAttributes: */
    /*      Self powered */
    0x32,   /* MaxPower 100 mA, 500mA == 0xFA */
 
    /******************** Descriptor of Mass Storage interface ********************/
    /* 09 */
    0x09,   /* bLength: Interface Descriptor size */
    0x04,   /* bDescriptorType: */
    /*      Interface descriptor type */
    0x00,   /* bInterfaceNumber: Number of Interface */
    0x00,   /* bAlternateSetting: Alternate setting */
    0x04,   /* bNumEndpoints*/
    0x00,   /* bInterfaceClass: MASS STORAGE Class */
    0x00,   /* bInterfaceSubClass : SCSI transparent*/
    0x00,   /* nInterfaceProtocol */
    4,          /* iInterface: */
    /* 18 */
    0x07,   /*Endpoint descriptor length = 7*/
    0x05,   /*Endpoint descriptor type */
    0x01,   /*Endpoint address (out, address 1) */
    0x02,   /*Bulk endpoint type */
    0x40,   /*Maximum packet size (64 bytes) */
    0x00,
    0x00,   /*Polling interval in milliseconds */
    /* 25 */
    0x07,   /*Endpoint descriptor length = 7 */
    0x05,   /*Endpoint descriptor type */
    0x82,   /*Endpoint address (in, address 2) */
    0x02,   /*Bulk endpoint type */
    0x40,   /*Maximum packet size (64 bytes) */
    0x00,
    0x00,     /*Polling interval in milliseconds*/
    /*32*/
    0x07,   /*Endpoint descriptor length = 7*/
    0x05,   /*Endpoint descriptor type */
    0x03,   /*Endpoint address (OUT, address 3) */
    0x02,   /*Bulk endpoint type */
    0x40,   /*Maximum packet size (64 bytes) */
    0x00,
    0x00,   /*Polling interval in milliseconds */
    0x07,   /*Endpoint descriptor length = 7 */
    0x05,   /*Endpoint descriptor type */
    0x84,   /*Endpoint address (in, address 4) */
    0x02,   /*Bulk endpoint type */
    0x40,   /*Maximum packet size (64 bytes) */
    0x00,
    0x00
    //46 bytes
  };



usb_conf

#define EP_NUM                          (5)
#define BTABLE_ADDRESS      (0x00)
 
#define ENDP0_RXADDR        (0x18)
#define ENDP0_TXADDR        (0x58)
 
#define ENDP2_TXADDR        (0x158)
#define ENDP1_RXADDR        (0x118)//I think since each endpoint max siz is set to 64 that all of the buffers can be just 64Bytes further on than each other
#define ENDP3_RXADDR        (0x98)
#define ENDP4_TXADDR        (0xD8)
 
/* ISTR events */
/* IMR_MSK */
/* mask defining which events has to be handled */
/* by the device application software */
#define IMR_MSK (CNTR_CTRM  | CNTR_WKUPM | CNTR_SUSPM | CNTR_ERRM  | CNTR_SOFM \
                 | CNTR_ESOFM | CNTR_RESETM )
 
/* CTR service routines */
/* associated to defined endpoints */
#define  EP1_IN_Callback   NOP_Process
//#define  EP2_IN_Callback   NOP_Process
#define  EP3_IN_Callback   NOP_Process
//#define  EP4_IN_Callback   NOP_Process
#define  EP5_IN_Callback   NOP_Process
#define  EP6_IN_Callback   NOP_Process
#define  EP7_IN_Callback   NOP_Process
 
 
//#define  EP1_OUT_Callback   NOP_Process
#define  EP2_OUT_Callback   NOP_Process
//#define  EP3_OUT_Callback  NOP_Process
#define  EP4_OUT_Callback   NOP_Process
#define  EP5_OUT_Callback   NOP_Process
#define  EP6_OUT_Callback   NOP_Process
#define  EP7_OUT_Callback   NOP_Process


usb_prop
void MASS_Reset()
{
  /* Set the device as not configured */
  Device_Info.Current_Configuration = 0;
 
  /* Current Feature initialization */
  pInformation->Current_Feature = MASS_ConfigDescriptor[7];
 
  SetBTABLE(BTABLE_ADDRESS);
 
  /* Initialize Endpoint 0 */
  SetEPType(ENDP0, EP_CONTROL);
  SetEPTxStatus(ENDP0, EP_TX_NAK);
  SetEPRxAddr(ENDP0, ENDP0_RXADDR);
  SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
  SetEPTxAddr(ENDP0, ENDP0_TXADDR);
  Clear_Status_Out(ENDP0);
  SetEPRxValid(ENDP0);
 
  /* Initialize Endpoint 1 */
  SetEPType(ENDP1, EP_BULK);
  SetEPRxAddr(ENDP1, ENDP1_RXADDR);
  SetEPRxCount(ENDP1, Device_Property.MaxPacketSize);
  SetEPRxStatus(ENDP1, EP_RX_VALID);
  SetEPTxStatus(ENDP1, EP_TX_DIS);
  /* Initialize Endpoint 2 */
  SetEPType(ENDP2, EP_BULK);
  SetEPTxAddr(ENDP2, ENDP2_TXADDR);
  SetEPTxStatus(ENDP2, EP_TX_NAK);
  SetEPRxStatus(ENDP2, EP_RX_DIS);
 
  /* Initialize Endpoint 3 */
  SetEPType(ENDP3, EP_BULK);
  SetEPRxAddr(ENDP3, ENDP3_RXADDR);
  SetEPRxCount(ENDP3, Device_Property.MaxPacketSize);
  SetEPRxStatus(ENDP3, EP_RX_VALID);
  SetEPTxStatus(ENDP3, EP_TX_DIS);
  /* Initialize Endpoint 4 */
  SetEPType(ENDP4, EP_BULK);
  SetEPTxAddr(ENDP4, ENDP4_TXADDR);
  SetEPTxStatus(ENDP4, EP_TX_NAK);
  SetEPRxStatus(ENDP4, EP_RX_DIS);
 
  SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
  SetEPRxValid(ENDP0);
 
  /* Set the device to response on default address */
  SetDeviceAddress(0);
 
  bDeviceState = ATTACHED;
}

I cannot find anything else that I think I should be doing, or any app notes on the subject?....I'm stumped!
If anyone has any suggestions as to what I might be missing then please do chirp in.

Outcomes