/* Set Stall for USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None  */
void USBD_SetStallEP(U32 EPNum)
/* Set Stall for USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None  */
void USBD_SetStallEP(U32 EPNum)
{
    U32 *ptr;
    ptr = GetEpCmdStatPtr(EPNum);
    if (EPNum & 0x7F) {
        if (*ptr & BUF_ACTIVE) {
            *ptr &= ~(BUF_ACTIVE);
        }
    } else {
        if (EPNum & 0x80) {
            EPNum &= ~0x80;
            LPC_USB->EPSKIP |= (1 << EP_IN_IDX(EPNum));
            while (LPC_USB->EPSKIP & (1 << EP_IN_IDX(EPNum)));
        } else {
            LPC_USB->EPSKIP |= (1 << EP_OUT_IDX(EPNum));
            while (LPC_USB->EPSKIP & (1 << EP_OUT_IDX(EPNum)));
        }
    }
    if ((EPNum & 0x7F) == 0) {
        ctrl_out_next = 0;
    }
    *ptr |=  EP_STALL;
}