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

📄 devicetaskapi.c

📁 epson usb2.0 控制芯片 S1R72V05 固件程序。
💻 C
📖 第 1 页 / 共 3 页
字号:
*/
long DEVICE_TASK_StopUSB ( void )
{
	//========================================================================
	// Check state
	//========================================================================
	switch( DEVICEInfo.state )
	{
		case DEVICE_TASK_STATE_NON_EXISTENT:
		case DEVICE_TASK_STATE_STOP:
		case DEVICE_TASK_STATE_MODULE_INIT:
			//------------------------------------------------------------------------
			// Error when F/W is not started
			//------------------------------------------------------------------------
			return DEVICE_TASK_STATUS_STATE_ERROR;
			// No break required here.
		case DEVICE_TASK_STATE_SLEEP_A:
		case DEVICE_TASK_STATE_PLAY_CMD_EXEC:
		case DEVICE_TASK_STATE_PLAY_DMA_XFER:
		case DEVICE_TASK_STATE_DEV_INIT:
		case DEVICE_TASK_STATE_WAIT_EVENT:
			//------------------------------------------------------------------------
			// When it is not USB mode, terminate it normally
			//------------------------------------------------------------------------
			return DEVICE_TASK_STATUS_SUCCESS;
			// No break required here.
		case DEVICE_TASK_STATE_USB_NON_CONNECT:
		case DEVICE_TASK_STATE_USB_STORAGE:
		case DEVICE_TASK_STATE_MODULE_ACC:
		case DEVICE_TASK_STATE_USB_SUSPEND:
			break;

		default:
			//------------------------------------------------------------------------
			// Return error for states outside assumption
			//------------------------------------------------------------------------
			return DEVICE_TASK_STATUS_STATE_ERROR;
//			break;
	}

	//========================================================================
	// Request to stop USB storage
	//========================================================================
	DEVICEInfo.usbInfo.bEnable = FALSE;
	DEVICEInfo.state = DEVICE_TASK_STATE_USB_WAIT_STOP;
	OS_SetFlg( FLGID_DEVICE, FLG_EVENT_STOP_USB_DEVICE );

	return DEVICE_TASK_STATUS_SUCCESS;
}

/*
//=============================================================================
// Function_Name: DEVICE_TASK_GetState
// description	: Reply state to this module
// argument		: none
// return		: long
// flag			:
// global		:
//=============================================================================
*/
long DEVICE_TASK_GetState ( unsigned short* pDEVICEState )
{
	*pDEVICEState = DEVICEInfo.state;
	return DEVICE_TASK_STATUS_SUCCESS;
}

/*
//=============================================================================
// Function_Name: DEVICE_TASK_SetPowerState
// description	: Controll the power consumption of DEVICEIC
// argument		: none
// return		: long
// flag			:
// global		:
//=============================================================================
*/
long DEVICE_TASK_SetPowerState ( unsigned char suspendLevel )
{
	//========================================================================
	// Check parameter
	//========================================================================
	switch( suspendLevel )
	{
		case DEVICE_TASK_SUSPEND_LV0:
		case DEVICE_TASK_SUSPEND_LV1:
		case DEVICE_TASK_SUSPEND_LV2:
			break;
		default:
			// Suspend Level of outside regulations
			return DEVICE_TASK_STATUS_INVALID_PARAMETER;
	}

	//========================================================================
	// Confirm state
	//========================================================================
	switch( DEVICEInfo.state )
	{
		case DEVICE_TASK_STATE_WAIT_EVENT:			/* The current consumption state can be changed */

			if( suspendLevel == DEVICE_TASK_SUSPEND_LV0 )
			{
				// Ignore for it is unnecessary to change
				return DEVICE_TASK_STATUS_SUCCESS;
			}
			// Change to DEVICE_TASK_STATE_SLEEP_A state, when the suspend level is set out of 0
			DEVICEInfo.state = DEVICE_TASK_STATE_SLEEP_A;
			break;

		case DEVICE_TASK_STATE_SLEEP_A:			/* The current consumption state can be changed */

			if( suspendLevel == DEVICE_TASK_SUSPEND_LV0 )
			{
				// Change to DEVICE_TASK_STATE_WAIT_EVENT state, When the suspend release requirement is received
				DEVICEInfo.state = DEVICE_TASK_STATE_WAIT_EVENT;
			}
			break;

		case DEVICE_TASK_STATE_USB_SUSPEND:

			if( DEVICEInfo.usbInfo.bManPwrCtrl == TRUE )
			{
				// Valid when it is manual setting mode in USB SUSPEND
				break;
			}
			// State error for manual set mode
		default:
			return DEVICE_TASK_STATUS_STATE_ERROR;
			// break;
	}

	// PM control requirement for DEVICE task
	ChangePMMode( suspendLevel );

	return DEVICE_TASK_STATUS_SUCCESS;
}

/*
//=============================================================================
// Function_Name: DEVICE_TASK_GetPowerState
// description	: Return state of power consumption control of DEVICEIC
// argument		: none
// return		: long
//=============================================================================
*/
long DEVICE_TASK_GetPowerState ( unsigned char* pPMState )
{
	// Check argument
	if( pPMState == NULL )
	{
		// NULL is set in argument
		return DEVICE_TASK_STATUS_INVALID_PARAMETER;
	}

	// Return present state of current consumption
	PM_IFGetPMState( pPMState );

	switch( *pPMState )
	{
		case PM_IF_PMSTATE_ACT_DEVICE:	*pPMState = DEVICE_TASK_SUSPEND_LV0;	break;
		case PM_IF_PMSTATE_ACT_60:	*pPMState = DEVICE_TASK_SUSPEND_LV0;	break;
		case PM_IF_PMSTATE_SNOOZE:	*pPMState = DEVICE_TASK_SUSPEND_LV1;	break;
		case PM_IF_PMSTATE_SLEEP:	*pPMState = DEVICE_TASK_SUSPEND_LV2;	break;
		default:
			// It doesn't come here
			break;
	}

	return DEVICE_TASK_STATUS_SUCCESS;
}

/*
//=============================================================================
// Function_Name: DEVICE_TASK_SetUserStrgCmd
// description	:
// argument		: none
// return		: long
//=============================================================================
*/
long DEVICE_TASK_SetUserStrgCmd ( unsigned char LUN, unsigned char length, const unsigned char* pCmdCode )
{
	int i;

	//========================================================================
	// Check state
	//========================================================================
	switch( DEVICEInfo.state )
	{
		case DEVICE_TASK_STATE_MODULE_INIT:	// State of module initialization
		case DEVICE_TASK_STATE_DEV_INIT:		// State of initialization for connected IDE device
		case DEVICE_TASK_STATE_WAIT_EVENT:		// State for event waiting
			break;
		default:
			return DEVICE_TASK_STATUS_STATE_ERROR;
//			break;
	}

	//========================================================================
	// Check argument
	//========================================================================
	if( LUN >= MAX_LUN_SIZE )
	{
		// Parameter error when the LUN number is larger than a regulated value
		return DEVICE_TASK_STATUS_INVALID_PARAMETER;
	}

	if( pCmdCode == NULL )
	{
		// Parameter error when command is specified as NULL
		return DEVICE_TASK_STATUS_INVALID_PARAMETER;
	}

	//========================================================================
	// Copy data
	//========================================================================
	UserCmdInfo.cmd[LUN].length = length;
	for( i = 0; i < length; i++ )
	{
		UserCmdInfo.cmd[LUN].code[i] = *(pCmdCode + i);
	}

	return DEVICE_TASK_STATUS_SUCCESS;
}

/*
//=============================================================================
// Function_Name: DEVICE_TASK_SendUserStrgStatus
// description	:
// argument		: none
// return		: long
//=============================================================================
*/
long DEVICE_TASK_SendUserStrgStatus ( unsigned char cmdStatus)
{
	//========================================================================
	// Check state
	//========================================================================
	if( DEVICEInfo.state != DEVICE_TASK_STATE_MODULE_ACC )
	{
		return DEVICE_TASK_STATUS_STATE_ERROR;
	}

	//========================================================================
	// Check parameter
	//========================================================================
	if( cmdStatus != DEVICE_TASK_CMD_STATUS_PASSED && cmdStatus != DEVICE_TASK_CMD_STATUS_FAILED && cmdStatus != DEVICE_TASK_PHASE_ERR)
	{
		// Error for status's setting value
		return DEVICE_TASK_STATUS_INVALID_PARAMETER;
	}

	//========================================================================
	// Set status and request to send
	//========================================================================
	UserCmdInfo.status = cmdStatus;
	OS_SetFlg( FLGID_DEVICE, (FLG_EVENT_STRG_STS_DEVICE) );

	return DEVICE_TASK_STATUS_SUCCESS;
}

/*
//=============================================================================
// Function_Name: DEVICE_TASK_ExecIdeCmd
// description	: Send command to the IDE connection device
// argument		: none
// return		: long
//=============================================================================
*/
long DEVICE_TASK_ExecIdeCmd ( unsigned char LUN, unsigned char cmdType, void* pIdeCmd, DEVICE_TASK_XFER_INFO* pXferInfo )
{
	//========================================================================
	// Check state
	//========================================================================
	switch( DEVICEInfo.state )
	{
		case DEVICE_TASK_STATE_WAIT_EVENT:
		case DEVICE_TASK_STATE_MODULE_ACC:
			// Valid at the state of event waiting/upper module access
			break;

		case DEVICE_TASK_STATE_PLAY_CMD_EXEC:
		case DEVICE_TASK_STATE_PLAY_DMA_XFER:
		case DEVICE_TASK_STATE_PLAY_DMA_READY:
		case DEVICE_TASK_STATE_PLAY_DMA_ABORT:
			// Error in executing, in case of command on executing
			return DEVICE_TASK_STATUS_EXEC_CMD;

		default:
			// State error for other state
			return DEVICE_TASK_STATUS_STATE_ERROR;


	}

	//========================================================================
	// Check parameter
	//========================================================================
	if( LUN >= MAX_LUN_SIZE )
	{
		// Parameter error when the LUN number is larger than regular value
		return DEVICE_TASK_STATUS_INVALID_PARAMETER;
	}

	if( pIdeCmd == NULL || pXferInfo == NULL )
	{
		// Error when pAtapiCmd/pXferInfo is NULL
		return DEVICE_TASK_STATUS_INVALID_PARAMETER;
	}

	//========================================================================
	//
	//	Notification of executing ATAPI command to EVICE task
	//	Set to semaphore waiting when the command execution mode is synchronization
	//========================================================================

⌨️ 快捷键说明

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