/* Set Stall for USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None  */
void USBD_SetStallEP(uint32_t 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(uint32_t EPNum)
{
    uint32_t *ptr;
    ptr = GetEpCmdStatPtr(EPNum);
    if (EPNum & USB_LOGICAL_EP_MASK) {
        if (*ptr & EP_BUF_ACTIVE) {
            *ptr &= ~(EP_BUF_ACTIVE);
        }
    } else {
        if (EPNum & USB_IN_MASK) {
            EPNum &= ~USB_IN_MASK;
            USBHSD->EPSKIP |= (1 << EP_IN_IDX(EPNum));
            while (USBHSD->EPSKIP & (1 << EP_IN_IDX(EPNum)));
        } else {
            USBHSD->EPSKIP |= (1 << EP_OUT_IDX(EPNum));
            while (USBHSD->EPSKIP & (1 << EP_OUT_IDX(EPNum)));
        }
    }
    if ((EPNum & USB_LOGICAL_EP_MASK) == 0) {
        s_read_ctrl_out_next = 0;
    }
    *ptr |=  EP_STALL;
}