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

📄 usbd_func.c

📁 epson usb2.0 控制芯片 S1R72V05 固件程序。
💻 C
📖 第 1 页 / 共 5 页
字号:
		retIFValue = USBD_IFGetFeatureMode(&feature);
		retValue = IFRET_TO_FUNCRET(retIFValue);
		if (retValue == STATUS_SUCCESS) {
			if (feature.HWSetAddress != 0) {
				/* Assume it as error when H/W sopport function is enabled */
				retValue = STATUS_SUCCESS;
				break;
			}
		}

#ifdef SW_SETADR
		/* Set the flag of USB Address's setting */
		SET_BIT(PrvStatusInfo.dwInternalStatus,PRV_IS_SETADRREQ);
		PrvUsbAddress = usbaddress;
#else
#ifdef AUTO_SET_ADDRESS_DIS	/* Countermeasure against AutoSetAddress */
		/* Mode of setting USB Address by H/W in Status Stage */
		if( USBD_IFGetAddress( &autoSetAddress ) != STATUS_SUCCESS ) {
			retValue = STATUS_UNSUCCESSFUL;
			break;
		}
		if( USBD_IFSetAddress( ( autoSetAddress | 0x80 ) ) != STATUS_SUCCESS ) {
			retValue = STATUS_UNSUCCESSFUL;
			break;
		}
		/* Clear the flag of USB Address setting */
		CLR_BIT(PrvStatusInfo.dwInternalStatus,PRV_IS_SETADRREQ);
#endif /* AUTO_SET_ADDRESS_DIS */
#endif
	break;};
	return retValue;
}
/* =============================================================================
// Function_Name: USBD_FuncSetTestMode
// description	: Do TestMode which is supported by HS device
// argument		: testmode			[in]	Value to specify TestMode
// return		: STATUS_SUCCESS			Finished normally
// return		: STATUS_UNSUCCESSFUL		Finished abnormally
// return		: STATUS_NOT_OPENED			Not be opened yet
// return		: STATUS_INVALID_PARAMETER	Parameter error
// =============================================================================
*/
LONG USBD_FuncSetTestMode(UCHAR testmode)
{
	LONG retValue;

	retValue = STATUS_SUCCESS;
	while (1) {
		/* Check if ReserveControlTransfer() has been called */
		if (IS_BIT(PrvStatusInfo.dwInternalStatus,PRV_IS_EP0TRNDIS) == TRUE) {
			/* Assume it as error when ReserveControlTransfer() has not been done */
			retValue = STATUS_UNSUCCESSFUL;
			break;
		}

		/* Test Mode */
		switch (testmode) {
			case USBD_FUNC_TEST_J:			/* Test J */
			case USBD_FUNC_TEST_K:			/* Test K */
			case USBD_FUNC_TEST_SE0NAK:		/* SE0 NAK */
			case USBD_FUNC_TEST_PACKET:		/* Test Packet */
				/* OK */
				break;
			default:
				retValue = STATUS_INVALID_PARAMETER;
				break;
		}

		if (retValue == STATUS_SUCCESS) {
			/* Set the flag of TestMode */
			SET_BIT(PrvStatusInfo.dwInternalStatus,PRV_IS_TESTMODEREQ);
			PrvTestMode = testmode;
		}

	break;};

	return retValue;

}
/* =============================================================================
// Function_Name: USBD_FuncRegisterCBRVBusChange
// description	: Register the callback function for change of VBUS state
// argument		: pfnCallback			[in]	Address of callback function
// return		: STATUS_SUCCESS				Finished normally
// return		: STATUS_NOT_OPENED			Not be opened yet
// return		: STATUS_UNABLE_TO_REGISTER	Unable to register the callback function
// =============================================================================
*/
LONG USBD_FuncRegisterCBRVBusChange(CALLBACK_PROC pfnCallback)
{
	LONG retValue;

	retValue = STATUS_SUCCESS;
	while (1) {
		/* Register the callback for VBUS change */
		retValue = USBD_IFRegisterCBRBusChange(PrvUsbVbusCallback);
		if (retValue != STATUS_SUCCESS) {
// Return the return value of USBD_IFRegisterCBRBusChange()
//			retValue = STATUS_UNSUCCESSFUL;
			break;
		}

		/* Register the callback function */
		retValue = PrvAddCallbackInf(PRV_CBINF_VBUS,PRV_ID_NONE,PRV_PORT_NONE,pfnCallback);

	break;};

	return retValue;

}
/* =============================================================================
// Function_Name: USBD_FuncUnregisterCBRVBusChange
// description	: Delete the callback function for completion of change of VBUS state
// argument		: pfnCallback			[in]	Address of callback function
// return		: STATUS_SUCCESS				Finished normally
// return		: STATUS_NOT_OPENED			Not be opened yet
// return		: STATUS_UNREGISTERED			Unable to delete the callback function
// =============================================================================
*/
LONG USBD_FuncUnregisterCBRVBusChange(CALLBACK_PROC pfnCallback)
{
	LONG retValue;

	retValue = STATUS_SUCCESS;
	while (1) {
		/* Delete the callback for VBUS change */
		retValue = USBD_IFUnregisterCBRBusChange(PrvUsbVbusCallback);
		if (retValue != STATUS_SUCCESS) {
//  Return the return value of USBD_IFUnregisterCBRBusChange()
//			retValue = STATUS_UNSUCCESSFUL;
			break;
		}

		/* Delete the callback function */
		retValue = PrvDelCallbackInf(PRV_CBINF_VBUS,PRV_ID_NONE,PRV_PORT_NONE,pfnCallback);

	break;};

	return retValue;

}
/* =============================================================================
// Function_Name: USBD_FuncRegisterCBRAttach
// description	: Register the callback function for completion of attach process
// argument		: pfnCallback			[in]	Address of callback function
// return		: STATUS_SUCCESS				Finished normally
// return		: STATUS_NOT_OPENED			Not be opened yet
// return		: STATUS_UNABLE_TO_REGISTER	Unable to register the callback function
// =============================================================================
*/
LONG USBD_FuncRegisterCBRAttach(CALLBACK_PROC pfnCallback)
{
	LONG retValue;

	retValue = STATUS_SUCCESS;
	while (1) {
		/* Register the callback function */
		retValue = PrvAddCallbackInf(PRV_CBINF_ATTACH,PRV_ID_NONE,PRV_PORT_NONE,pfnCallback);

	break;};

	return retValue;

}
/* =============================================================================
// Function_Name: USBD_FuncUnregisterCBRAttach
// description	: Delete the callback function for completion of attach process
// argument		: pfnCallback			[in]	Address of callback function
// return		: STATUS_SUCCESS				Finished normally
// return		: STATUS_NOT_OPENED			Not be opened yet
// return		: STATUS_UNREGISTERED			Unable to delete the callback function
// =============================================================================
*/
LONG USBD_FuncUnregisterCBRAttach(CALLBACK_PROC pfnCallback)
{
	LONG retValue;

	retValue = STATUS_SUCCESS;
	while (1) {
		/* Delete the callback function */
		retValue = PrvDelCallbackInf(PRV_CBINF_ATTACH,PRV_ID_NONE,PRV_PORT_NONE,pfnCallback);

	break;};

	return retValue;

}
/* =============================================================================
// Function_Name: USBD_FuncRegisterCBRDetach
// description	: Register the callback function of notification when detach has been done
// argument		: pfnCallback			[in]	Address of callback function
// return		: STATUS_SUCCESS				Finished normally
// return		: STATUS_NOT_OPENED			Not be opened yet
// return		: STATUS_UNABLE_TO_REGISTER	Unable to register the callback function
// =============================================================================
*/
LONG USBD_FuncRegisterCBRDetach(CALLBACK_PROC pfnCallback)
{
	LONG retValue;

	retValue = STATUS_SUCCESS;
	while (1) {
		/* Register the callback function */
		retValue = PrvAddCallbackInf(PRV_CBINF_DETACH,PRV_ID_NONE,PRV_PORT_NONE,pfnCallback);

	break;};

	return retValue;

}
/* =============================================================================
// Function_Name: USBD_FuncUnregisterCBRDetach
// description	: Delete the callback function of notification when detach has been done
// argument		: pfnCallback			[in]	Address of callback function
// return		: STATUS_SUCCESS				Finished normally
// return		: STATUS_NOT_OPENED			Not be opened yet
// return		: STATUS_UNREGISTERED			Unable to delete the callback function
// =============================================================================
*/
LONG USBD_FuncUnregisterCBRDetach(CALLBACK_PROC pfnCallback)
{
	LONG retValue;

	retValue = STATUS_SUCCESS;
	while (1) {
		/* Delete the callback function */
		retValue = PrvDelCallbackInf(PRV_CBINF_DETACH,PRV_ID_NONE,PRV_PORT_NONE,pfnCallback);

	break;};

	return retValue;

}
/* =============================================================================
// Function_Name: USBD_FuncRegisterCBRReset
// description	: Register the callback function of notification when USB reset has occurred
// argument		: pfnCallback			[in]	Address of callback function
// return		: STATUS_SUCCESS				Finished normally
// return		: STATUS_NOT_OPENED			Not be opened yet
// return		: STATUS_UNABLE_TO_REGISTER	Unable to register the callback function
// =============================================================================
*/
LONG USBD_FuncRegisterCBRReset(CALLBACK_PROC pfnCallback)
{
	LONG retValue;

	retValue = STATUS_SUCCESS;
	while (1) {
		/* Register the callback function */
		retValue = PrvAddCallbackInf(PRV_CBINF_RESET,PRV_ID_NONE,PRV_PORT_NONE,pfnCallback);

	break;};

	return retValue;

}
/* =============================================================================
// Function_Name: USBD_FuncUnregisterCBRReset
// description	: Delete the callback function of notification when USB reset has occurred
// argument		: pfnCallback			[in]	Address of callback function
// return		: STATUS_SUCCESS				Finished normally
// return		: STATUS_NOT_OPENED			Not be opened yet
// return		: STATUS_UNREGISTERED			Unable to delete the callback function
// =============================================================================
*/
LONG USBD_FuncUnregisterCBRReset(CALLBACK_PROC pfnCallback)
{
	LONG retValue;

	retValue = STATUS_SUCCESS;
	while (1) {
		/* Delete the callback function */
		retValue = PrvDelCallbackInf(PRV_CBINF_RESET,PRV_ID_NONE,PRV_PORT_NONE,pfnCallback);
	break;};

	return retValue;

}
/* =============================================================================
// Function_Name: USBD_FuncRegisterCBRSuspend
// description	: Register the callback function of notification when USB suspend has occurred
// argument		: pfnCallback			[in]	Address of callback function
// return		: STATUS_SUCCESS				Finished normally
// return		: STATUS_NOT_OPENED			Not be opened yet
// return		: STATUS_UNABLE_TO_REGISTER	Unable to register the callback function
// =============================================================================
*/
LONG USBD_FuncRegisterCBRSuspend(CALLBACK_PROC pfnCallback)
{
	LONG retValue;

	retValue = STATUS_SUCCESS;
	while (1) {
		/* Delete the callback function */
		retValue = PrvAddCallbackInf(PRV_CBINF_SUSPEND,PRV_ID_NONE,PRV_PORT_NONE,pfnCallback);

	break;};

	return retValue;

}
/* =============================================================================
// Function_Name: USBD_FuncUnregisterCBRSuspend
// description	: Delete the callback function of notification when USB suspend has occurred
// argument		: pfnCallback			[in]	Address of callback function
// return		: STATUS_SUCCESS				Finished normally
// return		: STATUS_NOT_OPENED			Not be opened yet
// return		: STATUS_UNREGISTERED			Unable to delete the callback function
// =============================================================================
*/
LONG USBD_FuncUnregisterCBRSuspend(CALLBACK_PROC pfnCallback)
{
	LONG retValue;

	retValue = STATUS_SUCCESS;
	while (1) {
		/* Delete the callback function */
		retValue = PrvDelCallbackInf(PRV_CBINF_SUSPEND,PRV_ID_NONE,PRV_PORT_NONE,pfnCallback);
	break;};

	return retValue;

}
/* =============================================================================
// Function_Name: USBD_FuncRegisterCBRWakeup
// description	: Register the callback function for releasing USB suspend while USB resume occurred
// argument		: pfnCallback			[in]	Address of callback function
// return		: STATUS_SUCCESS				Finished normally
// return		: STATUS_NOT_OPENED			Not be opened yet
// return		: STATUS_UNABLE_TO_REGISTER	Unable to register the callback function
// =============================================================================
*/
LONG USBD_FuncRegisterCBRWakeup(CALLBACK_PROC pfnCallback)
{
	LONG retValue;

	retValue = STATUS_SUCCESS;
	while (1) {
		/* Register the callback function */
		retValue = PrvAddCallbackInf(PRV_CBINF_WAKEUP,PRV_ID_NONE,PRV_PORT_NONE,pfnCallback);

	break;};

	return retValue;

}
/* =============================================================================
// Function_Name: USBD_FuncUnregisterCBRWakeup
// description	: Delete the callback function for releasing USB suspend while USB resume occurred
// argument		: pfnCallback			[in]	Address of callback function
// return		: STATUS_SUCCESS				Finished normally
// return		: STATUS_NOT_OPENED			Not be opened yet
// return		: STATUS_UNREGISTERED			Unable to delete the callback function
// =============================================================================
*/
LONG USBD_FuncUnregisterCBRWakeup(CALLBACK_PROC pfnCallback)
{
	LONG retValue;

	retValue = STATUS_SUCCESS;

⌨️ 快捷键说明

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