static ErrorCode_t USB_ConfigureEvent(USBD_HANDLE_T hUsb)
{
static USB_CORE_CTRL_T *pCtrl;
USB_Prog_DTD(EP2_IN_INDEX, EP2_IN_BIT);/* EP2_IN */
pCtrl = (USB_CORE_CTRL_T *) hUsb;
if(pCtrl->config_value == 1)
{
USBD_API->hw->ConfigEP(g_hUsb, &EP2);
USBD_API->hw->EnableEP(g_hUsb, USB_IN_EP);
USBD_API->hw->ResetEP(g_hUsb, USB_IN_EP);
g_u32_NbOctetEP2 = USBD_API->hw->WriteEP(g_hUsb, USB_IN_EP, (u8*)g_tu8_TabEcg, 0);
}
return LPC_OK;
}
void USB_Prog_DTD(u32 epIndex, u32 epBit)
{
u8 u8_i;
u32 dtd_phys;
dtd_phys = 1;
DQH_T *ep_QH = (DQH_T *) LPC_USB->ENDPOINTLISTADDR;
// Récupération des adresse physiques
dtd_phys = (u32) (&g_dtdPool[epIndex - 2][0]);
// Récupération de DTD pour l'endpoint passé en param.
DTD_T *ep_TD = &g_dtdPool[epIndex - 2][0];
// Initialisation
memset((void *) dtd_phys, 0, 8 * sizeof(DTD_T));
for (u8_i = 0; u8_i < 8; u8_i++)
{
ep_TD[u8_i].next_dTD = (u32) (dtd_phys + ((1 + u8_i) * sizeof(DTD_T)));
ep_TD[u8_i].total_bytes = (0x5000 << 16) | TD_IOC | 0x80;
ep_TD[u8_i].buffer0 = USB_DEST_ADDR;
ep_TD[u8_i].buffer1 = (USB_DEST_ADDR + 0x1000);
ep_TD[u8_i].buffer2 = (USB_DEST_ADDR + 0x2000);
ep_TD[u8_i].buffer3 = (USB_DEST_ADDR + 0x3000);
ep_TD[u8_i].buffer4 = (USB_DEST_ADDR + 0x4000);
ep_TD[u8_i].reserved = 0;
}
ep_TD[7].next_dTD = 0x01;
// Mise à jour de la file des endpoint
ep_QH[epIndex].next_dTD = dtd_phys;
ep_QH[epIndex].total_bytes &= (~0xC0);
// Activation de l'endpoint
LPC_USB->ENDPTPRIME |= epBit;
}
|