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

📄 usbh_ide_api.c

📁 epson usb2.0 控制芯片 S1R72V05 固件程序。
💻 C
📖 第 1 页 / 共 3 页
字号:

	/* Check whether other ID is using Device.	*/
	if(deviceStatus[deviceNo].id != id && deviceStatus[deviceNo].id != NO_ID ) {
		/* Device in operating	*/
		return STATUS_EXECUTION_PORT;
	}

	result = USBH_IDE_IFGetStatus(deviceNo, pStatus, pTransferSize, pSenseData);

	if(*pStatus == DRV_FUNC_CMD_COMP) {
		*pStatus = deviceStatus[deviceNo].cmdStatus;
	}

	return result;
}

/*=============================================================================================
// Function_Name: USBH_IDE_FuncSyncCommand
//
// description	: It sends command to the specified device (isochronous process )
//
//				  It sends command to the specified device (isochronous process )
//				  Control will not return to the Upper layer until all the processes completed.
//
// argument 	: id								(in)ID value
//				  deviceNo							(in)Device No.
//				  transferMode						(in)The transfer mode of the command
//				  *pTransferSize					(in)The pointer that points to the number of bytes
//														transfered in the previous executed data transfer
//				  *pCmdBlock						(in)Pointer of command parameter
//				  *pTranPara						(in)Pointer of data transfer parameter
//				  *pStatus							(in)Status pointer
//				  *pSenseData						(in)Pointer of requesr sense data
//
// return		: STATUS_SUCCESS					Process completed normally
//				  STATUS_UNSUCCESSFUL				Error occured during the process
//				  STATUS_NOT_OPENED					This module had not been opened
//				  STATUS_INVALID_PARAMETER			Parameter error
//				  STATUS_EXECUTION_PORT				The specified port is operating
===============================================================================================*/
LONG USBH_IDE_FuncSyncCommand( USHORT id, USHORT deviceNo, UCHAR transferMode, DRIVEACCESS_FUNCCMDPARA *pCmdBlock, DRIVEACCESS_FUNCTRANPARA *pTranPara, ULONG *pStatus, UCHAR *pSenseData )
{
	LONG	result;

	/* OpenFlag Check */
	if(OpenFlag != OPEN){
		/* Not Opened Error */
		return STATUS_NOT_OPENED;
	}

	/* Check ID value */
	if((id - 1) > USBH_IDE_MAX_ID || (IdTable[id-1] == FREE_ID)){
		/* Parameter error */
		return STATUS_INVALID_PARAMETER;
	}

	/* Check deviceNo value */
	if( deviceNo >= USBH_IDE_MAX_DEVICE ){
		/* Parameter error */
		return STATUS_INVALID_PARAMETER;
	}

	/* Check if the device is executing command or not. */
	if(deviceStatus[deviceNo].cmdStatus == DRV_FUNC_CMD_EXEC) {
		/* Device in operating	*/
		return STATUS_EXECUTION_PORT;
	}

	/* Check if the device is transfering data or not. */
	if(deviceStatus[deviceNo].dmaStatus == DRV_DMA_FUNC_EXEC) {
		/* Device is executing the data transfer */
		return STATUS_EXECUTION_PORT;
	}

	/* Check if transfer mode is DirectCopy mode or not. */
	if(transferMode == FOR_HARD_DIRECTCOPY) {
		/* It is DirectCopy Mode.  */
		return STATUS_INVALID_PARAMETER;
	}

	/* Command Status Set */
	deviceStatus[deviceNo].id = id;
	deviceStatus[deviceNo].cmdStatus = DRV_FUNC_CMD_EXEC;

	result = USBH_IDE_IFSyncCommand(deviceNo, transferMode, pCmdBlock, pTranPara, pStatus, pSenseData);

	/* Command Status Clear */
	deviceStatus[deviceNo].id = NO_ID;
	deviceStatus[deviceNo].cmdStatus = DRV_FUNC_CMD_COMP;

	return result;
}

/*=============================================================================================
// Function_Name: USBH_IDE_FuncRegisterCBRDMAComp
//
// description	: Register the asynchronous data transfer completion callback.
//
//				  It registers the callback when the asynchronous data transfer completed.
//
// argument 	: id								(in)ID value
//				  cbrID								(in)Callback identifier
//				  deviceNo							(in)Device No.
//				  pfnNotifyDMAComp					(in)Pointer of the callback fucntion
//
// return		: STATUS_SUCCESS					Process completed normally
//				  STATUS_UNSUCCESSFUL				Error occured during the process
//				  STATUS_NOT_OPENED					This module had not been opened
//				  STATUS_INVALID_PARAMETER			Parameter error
//				  STATUS_UNABLE_TO_REGISTER			It is unable to register.
===============================================================================================*/
LONG USBH_IDE_FuncRegisterCBRDMAComp( USHORT id, USHORT cbrID, USHORT deviceNo, CALLBACK_PROC pfnNotifyDMAComp )
{
	LONG	result;

	/* OpenFlag Check */
	if(OpenFlag != OPEN){
		/* Not Opened Error */
		return STATUS_NOT_OPENED;
	}

	/* Check ID value */
	if((id - 1) > USBH_IDE_MAX_ID || (IdTable[id-1] == FREE_ID)){
		/* Parameter error */
		return STATUS_INVALID_PARAMETER;
	}


	/* Check deviceNo value */
	if( deviceNo >= USBH_IDE_MAX_DEVICE ){
		/* Parameter error */
		return STATUS_INVALID_PARAMETER;
	}

	/* Check the CALLBACK registration */
	if(USBH_IDE_DMACompCBR[deviceNo][id - 1] != NULL){
		/* CALLBACK has been registered. */
		return STATUS_UNABLE_TO_REGISTER;
	}

	/* Register the callback */
	USBH_IDE_DMACompCBR[deviceNo][id - 1] = pfnNotifyDMAComp;
	USBH_IDE_DMACompCbrID[deviceNo][id - 1] = cbrID;

	/* Registrat lower layer CALLBACK */
	result = USBH_IDE_IFRegisterCBRDMAComp( deviceNo, USBH_IDE_FuncNotifyDMAComp );

	return result;
}

/*=============================================================================================
// Function_Name: USBH_IDE_FuncUnregisterCBRDMAComp
//
// description	: Delete the callback when the asynchronous transfer completed.
//
//				  When the asynchronous transfer completed,delete the callback fucntiont that used for notification.
//
// argument 	: id								(in)ID value
//				  cbrID								(in)Callback identifier
//				  deviceNo							(in)Device No.
//				  pfnNotifyDMAComp					(in)Pointer of the callback function
//
// return		: STATUS_SUCCESS					Process completed normally
//				  STATUS_UNSUCCESSFUL				Error occured during the process
//				  STATUS_NOT_OPENED					This module had not been opened
//				  STATUS_INVALID_PARAMETER			Parameter error
//				  STATUS_UNREGISTERED				It is not registered.
===============================================================================================*/
LONG USBH_IDE_FuncUnregisterCBRDMAComp( USHORT id, USHORT cbrID, USHORT deviceNo, CALLBACK_PROC pfnNotifyDMAComp )
{
	LONG	result;

	/* OpenFlag Check */
	if(OpenFlag != OPEN){
		/* Not Opened Error */
		return STATUS_NOT_OPENED;
	}

	/* Check ID value */
	if((id - 1) > USBH_IDE_MAX_ID || (IdTable[id - 1] == FREE_ID)){
		/* Parameter error */
		return STATUS_INVALID_PARAMETER;
	}

	/* Check deviceNo value */
	if( deviceNo >= USBH_IDE_MAX_DEVICE ){
		/* Parameter error */
		return STATUS_INVALID_PARAMETER;
	}

	/* Check the CALLBACK registration */
	if(USBH_IDE_DMACompCBR[deviceNo][id - 1] != pfnNotifyDMAComp){
		/* The callback is not registered */
		return STATUS_UNREGISTERED;
	}

	/* Delete the callback */
	USBH_IDE_DMACompCBR[deviceNo][id - 1] = NULL;

	/* Deleted the callback correspond to the lower layer */
	result = USBH_IDE_IFUnregisterCBRDMAComp( deviceNo, USBH_IDE_FuncNotifyDMAComp );

	return result;
}

/*=============================================================================================
// Function_Name: USBH_IDE_FuncRegisterCBRIntrqComp
//
// description	: Register the asynchronous data transfer completion callback.
//
//				  When the asynchronous command completed, register the function that used to notify.
//
// argument 	: id								(in)ID value
//				  cbrID								(in)Callback identifier
//				  deviceNo							((in)Device No.
//				  pfnNotifyDMAComp					(in)Pointer of the callback function
//
// return		: STATUS_SUCCESS					Process completed normally
//				  STATUS_UNSUCCESSFUL				Error occured during the process
//				  STATUS_NOT_OPENED					This module had not been opened
//				  STATUS_INVALID_PARAMETER			Parameter error
//				  STATUS_UNABLE_TO_REGISTER			It is unable to register.
===============================================================================================*/
LONG USBH_IDE_FuncRegisterCBRIntrqComp( USHORT id, USHORT cbrID, USHORT deviceNo, CALLBACK_PROC pfnNotifyIntrqComp )
{
	LONG	result;

	/* OpenFlag Check */
	if(OpenFlag != OPEN){
		/* Not Opened Error */
		return STATUS_NOT_OPENED;
	}

	/* Check ID value */
	if((id - 1) > USBH_IDE_MAX_ID || (IdTable[id - 1] == FREE_ID)){
		/* Parameter error */
		return STATUS_INVALID_PARAMETER;
	}

	/* Check deviceNo value */
	if( deviceNo >= USBH_IDE_MAX_DEVICE ){
		/* Parameter error */
		return STATUS_INVALID_PARAMETER;
	}

	/* Check the CALLBACK registration */
	if(USBH_IDE_IntrqCompCBR[deviceNo][id - 1] != NULL){
		/* The callback had been registered */
		return STATUS_UNABLE_TO_REGISTER;
	}

	/* Register the callback */
	USBH_IDE_IntrqCompCBR[deviceNo][id - 1] = pfnNotifyIntrqComp;
	USBH_IDE_IntrqCompCbrID[deviceNo][id - 1] = cbrID;

	/* Register the callback of lower laye */
	result = USBH_IDE_IFRegisterCBRIntrqComp( deviceNo, USBH_IDE_FuncNotifyIntrqComp );

	return result;
}

/*=============================================================================================
// Function_Name: USBH_IDE_FuncUnregisterCBRIntrqComp
//
// description	: Delete the command completion callback function
//
//				  When the asynchronous command completed,delete the callback fucntiont that used for notification.
//
// argument 	: id								(in)ID value
//				  cbrID								(in)Callback identifier
//				  deviceNo							(in)Device No.
//				  pfnNotifyDMAComp					(in)Pointer of the callback function
//
// return		: STATUS_SUCCESS					Process completed normally
//				  STATUS_UNSUCCESSFUL				Error occured during the process
//				  STATUS_NOT_OPENED					This module had not been opened
//				  STATUS_INVALID_PARAMETER			Parameter error
//				  STATUS_UNREGISTERED				It is not registered.
===============================================================================================*/
LONG USBH_IDE_FuncUnregisterCBRIntrqComp( USHORT id, USHORT cbrID, USHORT deviceNo, CALLBACK_PROC pfnNotifyIntrqComp )
{
	LONG	result;

	/* OpenFlag Check */
	if(OpenFlag != OPEN){
		/* Not Opened Error */
		return STATUS_NOT_OPENED;
	}

	/* Check ID value */
	if((id - 1) > USBH_IDE_MAX_ID || (IdTable[id-1] == FREE_ID)){
		/* Parameter error */
		return STATUS_INVALID_PARAMETER;
	}

	/* Check deviceNo value */
	if( deviceNo >= USBH_IDE_MAX_DEVICE ){
		/* Parameter error */
		return STATUS_INVALID_PARAMETER;
	}

	/* Check the CALLBACK registration */
	if(USBH_IDE_IntrqCompCBR[deviceNo][id - 1] != pfnNotifyIntrqComp){
		/* CALLBACK had not been registered */
		return STATUS_UNREGISTERED;
	}

	/* Delete the callback */
	USBH_IDE_IntrqCompCBR[deviceNo][id - 1] = NULL;

	/* Delete the lowerlayer callback */
	result = USBH_IDE_IFUnregisterCBRIntrqComp( deviceNo, USBH_IDE_FuncNotifyIntrqComp );

	return result;
}

/*=============================================================================================
// Function_Name: USBH_IDE_FuncNotifyDMAComp
//
// description	: Process the data transfer completion callback
//
//				  Process the data transfer completion callback when at DirectCopy.
//
// argument 	: deviceNo							(in)Device No.
//				  ULONG lReserve1					Reserved
//				  ULONG VOID *pReserve				Reserved
//
// return		: STATUS_SUCCESS					Process completed normally
//				  STATUS_UNSUCCESSFUL				Error occured during the process
===============================================================================================*/
LONG USBH_IDE_FuncNotifyDMAComp(ULONG deviceNo, ULONG lReserve1, VOID *pReserve )
{
	if(USBH_IDE_DMACompCBR[deviceNo][deviceStatus[deviceNo].id - 1] != NULL){
		deviceStatus[deviceNo].dmaStatus = DRV_DMA_FUNC_COMP;
		/* The callback to FileSystem is called.  */
		ideCbrID.cbrID = USBH_IDE_DMACompCbrID[deviceNo][deviceStatus[deviceNo].id - 1];

// ideCbrID.cbrID = 1;

		ideCbrID.allocID = deviceStatus[deviceNo].id;
		USBH_IDE_DMACompCBR[deviceNo][deviceStatus[deviceNo].id - 1]( deviceNo, DRV_DMA_FUNC_COMP, (VOID *) &ideCbrID );
	}
	else {
		return STATUS_UNSUCCESSFUL;
	}

	/* COMPLETE */
	return STATUS_SUCCESS;

}

/*=============================================================================================
// Function_Name: USBH_IDE_FuncNotifyIntrqComp
//
// description	: Process intrq completion callback
//
//				  Process the intrq completion callback when at DirectCopy.
//
// argument 	: deviceNo							(in)Device No.
//				  ULONG lReserve1					Reserved
//				  ULONG VOID *pReserve				Reserved
//
// return		: STATUS_SUCCESS					Process completed normally
//				  STATUS_UNSUCCESSFUL				Error occured during the process
===============================================================================================*/
LONG USBH_IDE_FuncNotifyIntrqComp(ULONG deviceNo, ULONG lReserve1, VOID *pReserve )
{
	if(USBH_IDE_IntrqCompCBR[deviceNo][deviceStatus[deviceNo].id - 1] != NULL){
		deviceStatus[deviceNo].cmdStatus = DRV_FUNC_CMD_COMP;
		/* The callback to FileSystem is called. */
		ideCbrID.cbrID = USBH_IDE_IntrqCompCbrID[deviceNo][deviceStatus[deviceNo].id - 1];

// ideCbrID.cbrID = 1;

		ideCbrID.allocID = deviceStatus[deviceNo].id;
		USBH_IDE_IntrqCompCBR[deviceNo][deviceStatus[deviceNo].id - 1]( deviceNo, DRV_FUNC_CMD_COMP, (VOID *) &ideCbrID );
	}
	else {
		return STATUS_UNSUCCESSFUL;
	}

	/* COMPLETE */
	return STATUS_SUCCESS;

}

⌨️ 快捷键说明

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