📄 usbd_protenum.c
字号:
}
/*======================================================================
// Function_Name: USBD_ProtRegisterCBREnumConfiguredEvent
//
// description : Register callback function of notifying event
//
// Register callback function of notifying that it has become to Configured State by Set Configuration
//
// argument : pfnCallback Callback function
//
// return : STATUS_SUCCESS Success
// STATUS_NOT_OPEND Not opened
// STATUS_UNABLE_TO_REGISTER Unable to register
========================================================================*/
LONG USBD_ProtRegisterCBREnumConfiguredEvent( CALLBACK_PROC pfnCallback )
{
/****************************/
/* Check the registration of callback function */
/****************************/
if( ModuleStatus.pfnCallbackTable[CBR_CONFIGURED_EVENT] == NULL ){
/* Not registered */
ModuleStatus.pfnCallbackTable[CBR_CONFIGURED_EVENT] = pfnCallback;
}
return STATUS_SUCCESS;
}
/*======================================================================
// Function_Name: USBD_ProtUnregisterCBREnumConfiguredEvent
//
// description : Delete callback function of notifying event
//
// Delete callback function of notifying that it has become to Configured State by Set Configuration
//
// argument : pfnCallback Callback function
//
// return : STATUS_SUCCESS Success
// STATUS_NOT_OPEND Not opened
// STATUS_UNREGISTERED Not registered
========================================================================*/
LONG USBD_ProtUnregisterCBREnumConfiguredEvent( CALLBACK_PROC pfnCallback )
{
/****************************/
/* Check the deletion of callback function */
/****************************/
if( ModuleStatus.pfnCallbackTable[CBR_CONFIGURED_EVENT] == pfnCallback ){
/* Registered */
ModuleStatus.pfnCallbackTable[CBR_CONFIGURED_EVENT] = NULL;
}
return STATUS_SUCCESS;
}
/*======================================================================
// Function_Name: USBD_ProtRegisterCBREnumDeconfiguredEvent
//
// description : Register callback function of notifying event
//
// Register callback function of notifying that it has become to Addressed State from Configured State by Set Configuration
//
// argument : pfnCallback Callback function
//
// return : STATUS_SUCCESS Success
// STATUS_NOT_OPEND Not opened
// STATUS_UNABLE_TO_REGISTER Unable to register
========================================================================*/
LONG USBD_ProtRegisterCBREnumDeconfiguredEvent( CALLBACK_PROC pfnCallback )
{
/****************************/
/* Check the registration of callback function */
/****************************/
if( ModuleStatus.pfnCallbackTable[CBR_DECONFIGURED_EVENT] == NULL ){
/* Not registered */
ModuleStatus.pfnCallbackTable[CBR_DECONFIGURED_EVENT] = pfnCallback;
}
return STATUS_SUCCESS;
}
/*======================================================================
// Function_Name: USBD_ProtUnregisterCBREnumDeconfiguredEvent
//
// description : Delete callback function of notifying event
//
// Delete callback function of notifying that it has become to Addressed State from Configured State by Set Configuration
//
// argument : pfnCallback Callback function
//
// return : STATUS_SUCCESS Success
// STATUS_NOT_OPEND Not opened
// STATUS_UNREGISTERED Not registered
========================================================================*/
LONG USBD_ProtUnregisterCBREnumDeconfiguredEvent( CALLBACK_PROC pfnCallback )
{
/****************************/
/* Check the deletion of callback function */
/****************************/
if( ModuleStatus.pfnCallbackTable[CBR_DECONFIGURED_EVENT] == pfnCallback ){
/* Registered */
ModuleStatus.pfnCallbackTable[CBR_DECONFIGURED_EVENT] = NULL;
}
return STATUS_SUCCESS;
}
/*======================================================================
// Function_Name: USBD_ProtRegisterCBREnumAlterneteChangedEvent
//
// description : Register callback function of notifying event
//
// Register callback function of notifying by Set Interface
//
// argument : pfnCallback Callback function
//
// return : STATUS_SUCCESS Success
// STATUS_NOT_OPEND Not opened
// STATUS_UNABLE_TO_REGISTER Unable to register
========================================================================*/
LONG USBD_ProtRegisterCBREnumAlternateChangedEvent( CALLBACK_PROC pfnCallback )
{
/****************************/
/* Check the registration of callback function */
/****************************/
if( ModuleStatus.pfnCallbackTable[CBR_ALTERNATE_CHANGED_EVENT] == NULL ){
/* Not registered */
ModuleStatus.pfnCallbackTable[CBR_ALTERNATE_CHANGED_EVENT] = pfnCallback;
}
return STATUS_SUCCESS;
}
/*======================================================================
// Function_Name: USBD_ProtUnregisterCBREnumAlternateChangedEvent
//
// description : Delete callback function of notifying event
//
// Delete callback function of notifying by Set Interface
//
// argument : pfnCallback Callback function
//
// return : STATUS_SUCCESS Success
// STATUS_NOT_OPEND Not opened
// STATUS_UNREGISTERED Not registered
========================================================================*/
LONG USBD_ProtUnregisterCBREnumAlternateChangedEvent( CALLBACK_PROC pfnCallback )
{
/****************************/
/* Check the deletion of callback function */
/****************************/
if( ModuleStatus.pfnCallbackTable[CBR_ALTERNATE_CHANGED_EVENT] == pfnCallback ){
/* Registered */
ModuleStatus.pfnCallbackTable[CBR_ALTERNATE_CHANGED_EVENT] = NULL;
}
return STATUS_SUCCESS;
}
/*======================================================================
// Function_Name: USBD_ProtRegisterCBREnumClrEndpointHaltReqEvent
//
// description : Register callback function of notifying request of clearing Endpoint Halt
//
// Register callback function of notifying when there is a request of ClearFeature(ENDPOINT_HALT)
//
// argument : pfnCallback Callback function
//
// return : STATUS_SUCCESS Success
// STATUS_NOT_OPEND Not opened
// STATUS_UNABLE_TO_REGISTER Unable to register
========================================================================*/
LONG USBD_ProtRegisterCBREnumClrEndpointHaltReqEvent( CALLBACK_PROC pfnCallback )
{
/****************************/
/* Check the registration of callback function */
/****************************/
if( ModuleStatus.pfnCallbackTable[CBR_CLR_ENDPOINTHALT_REQ_EVENT] == NULL ){
/* Not registered */
ModuleStatus.pfnCallbackTable[CBR_CLR_ENDPOINTHALT_REQ_EVENT] = pfnCallback;
} else {
/* Registered */
return STATUS_UNABLE_TO_REGISTER;
}
return STATUS_SUCCESS;
}
/*======================================================================
// Function_Name: USBD_ProtUnregisterCBREnumClrEndpointHaltReqEvent
//
// description : Delete callback function of notifying request of clearing Endpoint Halt
//
// Delete callback function of notifying when there is a request of ClearFeature(ENDPOINT_HALT)
//
// argument : pfnCallback Callback function
//
// return : STATUS_SUCCESS Success
// STATUS_NOT_OPEND Not opened
// STATUS_UNREGISTERED Not registered
========================================================================*/
LONG USBD_ProtUnregisterCBREnumClrEndpointHaltReqEvent( CALLBACK_PROC pfnCallback )
{
/****************************/
/* Check the deletion of callback function */
/****************************/
if( ModuleStatus.pfnCallbackTable[CBR_CLR_ENDPOINTHALT_REQ_EVENT] == pfnCallback ){
/* Registered */
ModuleStatus.pfnCallbackTable[CBR_CLR_ENDPOINTHALT_REQ_EVENT] = NULL;
} else{
/* Not registered */
return STATUS_UNREGISTERED;
}
return STATUS_SUCCESS;
}
/*======================================================================
// Function_Name: USBD_ProtEnumGetStatus
//
// description : Return status of this module
//
// Return status of specified type
//
// argument : wStatusType Status type
// USBD_PROT_ENUM_OP_STATUS Status of operation
// USBD_PROT_ENUM_EVENT_STATUS Status of event
// USBD_PROT_ENUM_API_STATUS Status of API
//
// *pwStatusData Pointer of status data
//
// return : STATUS_SUCCESS Success
// STATUS_UNSUCCESSFUL Error
// STATUS_NOT_OPEND Not opened
// STATUS_INVALID_PARAMETER Parameter error
// STATUS_NOT_IMPLEMENTED Not implemented
========================================================================*/
LONG USBD_ProtEnumGetStatus( USHORT *pwStatusData, USHORT wStatusType )
{
LONG dwAPIStatus;
// ULONG dwStatusData;
/**************************/
/* Process for individual status type */
/**************************/
switch( wStatusType ){
case USBD_PROT_ENUM_OP_STATUS:
/* Status of operation */
/* Refresh status of operation */
*pwStatusData = ModuleStatus.wOPStatus;
break;
case USBD_PROT_ENUM_EVENT_STATUS:
/* Status of event */
*pwStatusData = ModuleStatus.wEventStatus;
ModuleStatus.wEventStatus = 0;
break;
case USBD_PROT_ENUM_API_STATUS:
/* Status of API */
/* Refresh status of API */
*pwStatusData = 0;
if( ModuleStatus.sAPIFlag.bit.wSendRemoteWakeupA == 1 ){
*pwStatusData |= API_STS_WAKEUP_A;
}
break;
default:
/* Status type which is not supported*/
return STATUS_INVALID_PARAMETER;
}
/********************************************/
/* Polling function for process after callback function */
/********************************************/
if( (dwAPIStatus = ModuleManager()) != STATUS_SUCCESS ){
/* Error occurred in lower module */
return dwAPIStatus;
}
return STATUS_SUCCESS;
}
/*======================================================================
// Function_Name: USBD_ProtEnumWakeupA
//
// description : Do Remote Wakeup
//
// Do RemoteWakeup, if it is on Suspending and Remote Wakeup has been enabled
//
// argument : None
//
// return : STATUS_SUCCESS Success
// STATUS_UNSUCCESSFUL Error
// STATUS_NOT_OPENED Not opened
// STATUS_NOT_IMPLEMENTED Not implemented
========================================================================*/
LONG USBD_ProtEnumWakeupA( void )
{
LONG dwAPIStatus;
/*****************************************************/
/* Depend on lower module if Remote Wakeup has been enabled */
/*****************************************************/
if( ModuleStatus.sUSBStatus.bEnableRemoteWakeup == 0){
/* Remote Wakeup has not been enabled */
return STATUS_UNSUCCESSFUL;
}
if( (dwAPIStatus = USBD_FuncSendRemoteWakeupA()) != STATUS_SUCCESS ){
/* Failed to Remote Wakeup */
return dwAPIStatus;
}
ModuleStatus.sAPIFlag.bit.wSendRemoteWakeupA = 1;
return STATUS_SUCCESS;
}
/*======================================================================
// Function_Name: USBD_ProtRegisterCBREnumWakeupEnd
//
// description : Register Callback function of notifying for completion of asynchronous function
//
// Register callback function of notifying for completion fo asynchronous function of USBD_ProtEnumWakeupA
//
// argument : pfnCallback Callback function
//
// return : STATUS_SUCCESS Success
// STATUS_NOT_OPENED Not opened
// STATUS_UNABLE_TO_REGISTER Unable to register
========================================================================*/
LONG USBD_ProtRegisterCBREnumWakeupEnd( CALLBACK_PROC pfnCallback )
{
/****************************/
/* Check the registration of callback function */
/****************************/
if( ModuleStatus.pfnCallbackTable[CBR_WAKEUP_END] == NULL ){
/* Not registered */
ModuleStatus.pfnCallbackTable[CBR_WAKEUP_END] = pfnCallback;
}
return STATUS_SUCCESS;
}
/*======================================================================
// Function_Name: USBD_ProtUnregisterCBREnumWakeupEnd
//
// description : Delete Callback function of notifying for completion of asynchronous function
//
// Delete callback function of notifying for completion fo asynchronous function of USBD_ProtEnumWakeupA
//
// argument : pfnCallback Callback function
//
// return : STATUS_SUCCESS Success
// STATUS_NOT_OPENED Not opened
// STATUS_NOT_IMPLEMENTED Not implemented
// STATUS_UNREGISTERED Not registered
========================================================================*/
LONG USBD_ProtUnregisterCBREnumWakeupEnd( CALLBACK_PROC pfnCallback )
{
return STATUS_UNSUCCESSFUL;
}
/*======================================================================
// Function_Name: USBD_ProtEnumRemoteWakeupEnd
//
// description : Callback function which is registered to lower module
//
// Be called when process of Remote Wakeup has completed
//
// argument : lResult Result of process
// STATUS_SUCCESS Finished normally
// STATUS_UNSUCCESSFUL Error
// lParam1 Not used
// *pParam Not used
//
// return : STATUS_SUCCESS Success
// STATUS_UNSUCCESSFUL Error
========================================================================*/
LONG USBD_ProtEnumRemoteWakeupEnd( ULONG lResult, ULONG lParam1, void *pParam )
{
/**********************************************/
/* Call the callback function if it has been registered */
/**********************************************/
if( ModuleStatus.pfnCallbackTable[CBR_WAKEUP_END] != NULL ){
(ModuleStatus.pfnCallbackTable[CBR_WAKEUP_END])(lResult,lParam1,pParam);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -