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

📄 devicetask.c

📁 epson usb2.0 控制芯片 S1R72V05 固件程序。
💻 C
📖 第 1 页 / 共 5 页
字号:
			DEVICE_EventState_IntProc();
			break;

		default:
			break;

	}
}

/*
//=============================================================================
// Function_Name: DEVICE_EventState_IntProc
// description	: Process the DEVICE interrupt
// argument		: none
// return		: none
//=============================================================================
*/
void DEVICE_EventState_IntProc ( void )
{
	UCHAR main_int_enb,
		  cpu_int_enb,
		  fifo_int_enb;
	OS_BOOL bLocSts;
	UCHAR  mediafifo_int_enb;

	// CPU lock
	bLocSts = OS_SnsLoc();
	if( bLocSts != TRUE )
	{
		OS_LocCpu();					/* Disable the interrupt */
	}

	// Shelter the interrupt factor
	main_int_enb = main_int_enb_device_task;
	cpu_int_enb  = cpu_int_enb_device_task;
	fifo_int_enb = fifo_int_enb_device_task;

	main_int_enb_device_task = 0x00;
	cpu_int_enb_device_task  = 0x00;
	fifo_int_enb_device_task = 0x00;

	mediafifo_int_enb = mediafifo_int_enb_device_task;
	mediafifo_int_enb_device_task = 0x00;

	// CPU unlock
	if( bLocSts != TRUE )
	{
		OS_UnlCpu();					/* Enable interrupt */
	}

	//========================================================================
	// Call each I/F and process the interrupt
	//========================================================================
	PM_IFInterruptProc( main_int_enb );		// Call the handler of PM interrupt.
	CPUDMA_IFInterruptProc( cpu_int_enb );	// Call the handler of DMA interrupt.
	FIFO_IFInterruptProc( fifo_int_enb );		// Call the handler of FIFO interrupt
	FIFO_IFInterruptProcMedia( mediafifo_int_enb );		// Call the handler of FIFO interrupt

}


/*
//=============================================================================
// Function_Name: MsgEvent
// description	: Process Message event
// argument		: DEVICE_MSG* pDEVICEMsg Mail receiving
// return		: none
//=============================================================================
*/
void MsgEvent( DEVICE_MSG* pDEVICEMsg )
{
	//========================================================================
	// Process messages in each status
	//========================================================================
	switch( DEVICEInfo.state ) {
		case DEVICE_TASK_STATE_NON_EXISTENT:		// Unregistered state
			StateNonExistentMsgProc( pDEVICEMsg );

		case DEVICE_TASK_STATE_STOP:				// Stop state
			StateStopMsgProc( pDEVICEMsg );
			break;

		case DEVICE_TASK_STATE_MODULE_INIT:		// Moudle initialization state
			StateModuleInitMsgProc( pDEVICEMsg );
			break;

		case DEVICE_TASK_STATE_DEV_INIT:			// Device initialization waiting state
			StateDevInitMsgProc( pDEVICEMsg );
			break;

		case DEVICE_TASK_STATE_WAIT_EVENT:			// Event waiting state
			StateWaitEventMsgProc( pDEVICEMsg );
			break;

		case DEVICE_TASK_STATE_SLEEP_A:			// Sleep A state
			StateSleepAMsgProc( pDEVICEMsg );
			break;

		case DEVICE_TASK_STATE_PLAY_CMD_EXEC:		// Command processing state
			StatePlayCmdExecMsgProc( pDEVICEMsg );
			break;

		case DEVICE_TASK_STATE_PLAY_DMA_XFER:		// DMA transfer state
			StatePlayDmaXferMsgProc( pDEVICEMsg );
			break;

		case DEVICE_TASK_STATE_USB_NON_CONNECT:	// Unconnected state
			StateUsbNonConnectMsgProc( pDEVICEMsg );
			break;

		case DEVICE_TASK_STATE_USB_STORAGE:		// USB storage state
			StateUsbStorageMsgProc( pDEVICEMsg );
			break;

		case DEVICE_TASK_STATE_USB_SUSPEND:		// USB suspend state
			StateUsbSleepBMsgProc( pDEVICEMsg );
			break;

		case DEVICE_TASK_STATE_MODULE_ACC:			// Other module access state
			StateModuleAccMsgProc( pDEVICEMsg );
			break;

		default:
			// does not run to here
			break;
	}

	// Free the fixed length memory pool
	OS_RelMpf( pDEVICEMsg->msgHead.useMpfId, pDEVICEMsg );
	return;
}

/*
//=============================================================================
// Function_Name: DEVICEMailDataCancel
// description	: Destruction of DEVICE mailbox data
// argument		: none
// return		: none
//=============================================================================
*/
void DEVICEMailDataCancel( void )
{
	OS_T_MSG*	pMsg;
	OS_ID		mpfId;
	OS_ER		errCode;

	//========================================================================
	// Get and free until the mail box becomes empty
	//========================================================================
	do {
		// Receive message from mailbox
		errCode = OS_PRcvMbx( MBXID_DEVICE, &pMsg );

		if ( errCode == E_OK )
		{
			// Discard data when there is message
			mpfId = (( PMSGHEAD )pMsg )->useMpfId;
			OS_RelMpf( mpfId, (VP)pMsg );				// Free message buffer
		}
	} while( errCode == E_OK );

}

/*
//=============================================================================
// Function_Name: StateNonExistentMsgProc
// description	: Process for message of unregistered state
// argument		: DEVICE_MSG* pMsg Message receiving
// return		:
//=============================================================================
*/
void StateNonExistentMsgProc ( DEVICE_MSG* pMsg )
{
	//------------------------------------------------------------------------
	//
	//Mail is not received in unregistered state
	//Return error if mail has come
	//------------------------------------------------------------------------
	ErrMessageProc( pMsg );
}

/*
//=============================================================================
// Function_Name: StateStopMsgProc
// description	: Message process for Stop state
// argument		: DEVICE_MSG* pMsg Message receiving
// return		: none
//=============================================================================
*/
void StateStopMsgProc ( DEVICE_MSG* pMsg )
{
	//------------------------------------------------------------------------
	//
	//Mail is not received in Stop state
	//Return error if mail has come
	//------------------------------------------------------------------------
	ErrMessageProc( pMsg );
}

/*
//=============================================================================
// Function_Name: StateModuleInitMsgProc
// description	: Message process for module's initialization state
// argument		: DEVICE_MSG* pMsg Message receiving
// return		: none
//=============================================================================
*/
void StateModuleInitMsgProc ( DEVICE_MSG* pMsg )
{
	//========================================================================
	// Judge the transfer destination of mailbox, process each mail
	//========================================================================
	if( pMsg->msgHead.msgSndTskId == TSKID_USBD )
	{
		//------------------------------------------------------------------------
		// Process message from USBD Task
		//------------------------------------------------------------------------
		switch( pMsg->msgHead.msgNo )
		{
			case MSG_NTFY_USBD_FORCE_CMP:			// Notification of completion for USB force cancel process
				TaskInfo.forceEvntInfo.bUsbInit = TRUE;
				if( TaskInfo.forceEvntInfo.bUsbInit == TRUE )
				{
					// Request to reset when the initialization of the lower level task event has finished
					ResetLowRankTsk();
				}
				break;

			case MSG_NTFY_USBD_SET_DESC_CMP:		// Notification of completion for Descriptor setting
				//-----------------------------------------------
				// Receive notification of completion for Descriptor setting
				//-----------------------------------------------
				if( ((PARAM_MSG_NTFY_USBD_SET_DESC_CMP *)pMsg->msgData)->result == USBD_REQ_OK )
				{
					PARAM_MSG_REQ_USBD_DETECT_VBUS vbus;

					// Descriptor setting completed
					TaskInfo.usbTaskInfo.bSetDesc = TRUE;
					// Send the request of enabling USB VBUS detection
					vbus.detectFlag = USBD_VBUS_ENABLE;
					SendMessage( MBXID_USBD, MSG_REQ_USBD_DETECT_VBUS, sizeof(vbus), &vbus );
				}
				else
				{
					// Mistake in the format of descriptor!
					Panic();
				}
				break;

			default:	// Message receptions other than this state
				ErrMessageProc( pMsg );
				break;
		}
	}
	else if( pMsg->msgHead.msgSndTskId == TSKID_IDE )
	{
		//------------------------------------------------------------------------
		// Message process for IDE Task
		//------------------------------------------------------------------------
		switch( pMsg->msgHead.msgNo )
		{
			case MSG_NTFY_IDE_FORCE_CMP:			// Notification of completion for IDE force cancel processing
				TaskInfo.forceEvntInfo.bIdeInit = TRUE;
				if( TaskInfo.forceEvntInfo.bUsbInit == TRUE )
				{
					// Request to reset when the initialization of the lower level task event fas finished
					ResetLowRankTsk();
				}
				break;

			default:	// Message receptions other than this state
				ErrMessageProc( pMsg );
				break;
		}
	}
	else
	{
		//------------------------------------------------------------------------
		// Process when unexpected mailbox is received
		//------------------------------------------------------------------------
		ErrMessageProc( pMsg );
	}
}

/*
//=============================================================================
// Function_Name: StateDevInitMsgProc
// description	: Message process for device initialization state
// argument		: DEVICE_MSG* pMsg Message receiving
// return		: none
//=============================================================================
*/
void StateDevInitMsgProc ( DEVICE_MSG* pMsg )
{
	//========================================================================
	// Judge the transfer destination of mailbox, process each mail
	//========================================================================
	if( pMsg->msgHead.msgSndTskId == TSKID_USBD )
	{
		PARAM_MSG_REQ_USBD_DETECT_VBUS vbus;

		//------------------------------------------------------------------------
		// Process message from USBD Task
		//------------------------------------------------------------------------
		switch( pMsg->msgHead.msgNo )
		{
			case MSG_NTFY_USBD_DETECT_VBUS:		// Completion notification of MSG_REQ_USBD_DETECT_VBUS request
				// Status judgment
				//==================================
				if( ((PARAM_MSG_NTFY_USBD_DETECT_VBUS *)pMsg->msgData)->result != USBD_REQ_OK )
				{
					// The VBUS detection requirement is sent again
					vbus.detectFlag = USBD_VBUS_ENABLE;
					SendMessage( MBXID_USBD, MSG_REQ_USBD_DETECT_VBUS, sizeof(vbus), &vbus );
				}
				break;

			case MSG_NTFY_USBD_VBUS_STATUS:		// Change notification for state of VBUS
				// VBUS state judgment
				MsgUsbVBusChanged( pMsg );
				break;

			case MSG_NTFY_USBD_SET_DESC_CMP:		// Completion notification of Descriptor setting

				// Receive completion notification of Descriptor setting
				//==================================
				if( ((PARAM_MSG_NTFY_USBD_SET_DESC_CMP *)pMsg->msgData)->result == USBD_REQ_OK )
				{
					PARAM_MSG_REQ_USBD_DETECT_VBUS vbus;

⌨️ 快捷键说明

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