
Registered on : 06-16-2008
Messages : 1
OFF-Line
|
Hi everybody,
I got stuck on a piece of code where I am trying to receive some bytes through the USB port on my STM32-EVAL board.
I developed a firmware with two USB bulk pipes (address 0x81 for IN and address 0x01 for OUT) on a single interface of a single configuration.
Everithing goes fine until the device got configured, but when the host attempts to send an OUT after the setup stage, it falls in a timeout because on the device doesn't arise any interrupt (the breakpoint on the OUT handler doesn't hit).
Does anyone tell me if I follow the right steps or I miss something?
1. Initialize the USB interrupts:
void USB_Interrupts_Config(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
#ifdef VECT_TAB_RAM
/* Set the Vector Table base location at 0x20000000 */
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else /* VECT_TAB_FLASH */
/* Set the Vector Table base location at 0x08000000 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN_RX0_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
2. Call the default service routine here:
void USB_LP_CAN_RX0_IRQHandler(void)
{
USB_Istr();
}
3. Define two endpoint handlers:
EP1_IN_Callback and EP1_OUT_Callback which was assigned to the first entry of pEpInt_IN and pEpInt_OUT arrays.
4. Enable the ISR here:
void my_USBDev_init(void)
{
/* Update the serial number string descriptor with the data from the unique
ID*/
Get_SerialNum();
pInformation->Current_Configuration = 0;
/* Connect the device */
PowerOn();
/* USB interrupts initialization */
/* clear pending interrupts */
_SetISTR(0);
wInterrupt_Mask = IMR_MSK;
/* set interrupts mask */
_SetCNTR(wInterrupt_Mask);
bDeviceState = UNCONNECTED;
DEBUG_OUT("DDA initialized");
}
These steps reflect those found on the Virtual COM Port Example, adapted for my necessities.
Further question: can someone explain me the relation of the endpoint address defined on the descriptor and the endpoint used (EP1, EP2, ...) in the code?
|
|
|