⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 drvusb.c

📁 cortex-m0 LCD1602程序
💻 C
📖 第 1 页 / 共 5 页
字号:
/*---------------------------------------------------------------------------------------------------------*/
void DrvUSB_Reset(uint32_t u32EpNum)
{
    uint32_t u32EpId;
    u32EpId = DrvUSB_GetEpIdentity(u32EpNum, EP_INPUT);
    
    if(u32EpId != E_DRVUSB_INVALID_EP_NUM)
    {
        _DRVUSB_SET_CFG(u32EpId,  CFG_EP_SETTING[u32EpId]);
        _DRVUSB_SET_CFGP(u32EpId, CFGP_CLRRDY);
    }

    u32EpId = DrvUSB_GetEpIdentity(u32EpNum, EP_OUTPUT);
    
    if(u32EpId != E_DRVUSB_INVALID_EP_NUM)
    {
        _DRVUSB_SET_CFG(u32EpId,  CFG_EP_SETTING[u32EpId]);
        _DRVUSB_SET_CFGP(u32EpId, CFGP_CLRRDY);
    }


}


/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvUSB_ClrCtrlReady                                                                           */
/*                                                                                                         */
/* Parameters:                                                                                             */
/*      None                                                                                               */
/*                                                                                                         */
/* Returns:                                                                                                */
/*      None                                                                                               */
/*                                                                                                         */
/* Description:                                                                                            */
/*      Clear ctrl pipe ready flag that was set by MXPLD                                                   */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/
void DrvUSB_ClrCtrlReady(void)
{
    uint32_t u32EpId;

    u32EpId = DrvUSB_GetEpIdentity(0, EP_OUTPUT);
    _DRVUSB_CLEAR_EP_READY(u32EpId);
    u32EpId = DrvUSB_GetEpIdentity(0, EP_INPUT);
    _DRVUSB_CLEAR_EP_READY(u32EpId);
}


/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvUSB_ClrCtrlReadyAndTrigStall                                                               */
/*                                                                                                         */
/* Parameters:                                                                                             */
/*      None                                                                                               */
/*                                                                                                         */
/* Returns:                                                                                                */
/*      None                                                                                               */
/*                                                                                                         */
/* Description:                                                                                            */
/*      Clear ctrl pipe ready flag that was set by MXPLD  and send stall                                   */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/
void DrvUSB_ClrCtrlReadyAndTrigStall(void)
{
    uint32_t u32EpId;

    u32EpId = DrvUSB_GetEpIdentity(0, EP_OUTPUT);
    _DRVUSB_CLEAR_EP_READY_AND_TRIG_STALL(u32EpId);
    u32EpId = DrvUSB_GetEpIdentity(0, EP_INPUT);
    _DRVUSB_CLEAR_EP_READY_AND_TRIG_STALL(u32EpId);
}


/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvUSB_GetSetupBuffer                                                                         */
/*                                                                                                         */
/* Parameters:                                                                                             */
/*      None                                                                                               */
/*                                                                                                         */
/* Returns:                                                                                                */
/*      Setup buffer address                                                                               */
/*                                                                                                         */
/* Description:                                                                                            */
/*      Get setup buffer address in USB sram                                                               */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/
uint32_t DrvUSB_GetSetupBuffer(void)
{
    return (uint32_t)gsUsbDevice.sEpCrl[MAX_EP_ID].u8SramBuffer;
}


/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvUSB_GetFreeSRAM                                                                            */
/*                                                                                                         */
/* Parameters:                                                                                             */
/*      None                                                                                               */
/*                                                                                                         */
/* Returns:                                                                                                */
/*      Free USB SRAM address                                                                              */
/*                                                                                                         */
/* Description:                                                                                            */
/*      Get free USB SRAM buffer address after EP assign base on                                           */
/*      sEpDescription[i].u32MaxPacketSize in DrvUSB_Open                                                  */
/*      User can get this for dual buffer                                                                  */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/
uint32_t DrvUSB_GetFreeSRAM(void)
{
    return (uint32_t)g_UsbSramBase;
}


/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvUSB_EnableSelfPower                                                                        */
/*                                                                                                         */
/* Parameters:                                                                                             */
/*      None                                                                                               */
/*                                                                                                         */
/* Returns:                                                                                                */
/*      None                                                                                               */
/*                                                                                                         */
/* Description:                                                                                            */
/*      Enable self power attribution                                                                      */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/
void DrvUSB_EnableSelfPower (void)
{   
    gsUsbDevice.bSelfPowered = 1; 
}


/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvUSB_DisableSelfPower                                                                       */
/*                                                                                                         */
/* Parameters:                                                                                             */
/*      None                                                                                               */
/*                                                                                                         */
/* Returns:                                                                                                */
/*      None                                                                                               */
/*                                                                                                         */
/* Description:                                                                                            */
/*      Disable self power attribution                                                                     */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/
void DrvUSB_DisableSelfPower(void)
{   
    gsUsbDevice.bSelfPowered = 0; 
}


/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvUSB_IsSelfPowerEnabled                                                                     */
/*                                                                                                         */
/* Parameters:                                                                                             */
/*      None                                                                                               */
/*                                                                                                         */
/* Returns:                                                                                                */
/*      1  : Self-Powereded                                                                                */
/*      0  : BUS-Powereded                                                                                 */
/*                                                                                                         */
/* Description:                                                                                            */
/*      Self-power is enabled or disabled                                                                  */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/
int32_t DrvUSB_IsSelfPowerEnabled(void)
{
    return gsUsbDevice.bSelfPowered;
}


/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvUSB_EnableRemoteWakeup                                                                     */
/*                                                                                                         */
/* Parameters:                                                                                             */
/*      None                                                                                               */
/*                                                                                                         */
/* Returns:                                                                                                */
/*      None                                                                                               */
/*                                                                                                         */
/* Description:                                                                                            */
/*      Enable remote wakeup attribution                                                                   */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/
void DrvUSB_EnableRemoteWakeup(void)
{   
    gsUsbDevice.bRemoteWakeup = 1;  
}


/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvUSB_DisableRemoteWakeup                                                                    */
/*                                                                                                         */
/* Parameters:                                                                                             */
/*      None                                                                                               */
/*                                                                                                         */
/* Returns:                                                                                                */
/*      None                                                                                               */
/*                                                                                                         */
/* Description:                                                                                            */
/*      Disable remote wakeup attribution                                                                  */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/
void DrvUSB_DisableRemoteWa

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -