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

📄 usbd_sampletaskapi.c

📁 epson usb2.0 控制芯片 S1R72V05 固件程序。
💻 C
字号:
/*
 * description: Device Sample Task APIs
 * Maker	  : Shuichi Yanagihara
 * Copyright  : (C)2005,SEIKO EPSON Corp. All Rights Reserved.
 */

#include <string.h>
#include "SPRDEF.h"
#include "SPRSTS.h"
#include "OSCall.h"

#include "usbd_SampleTaskAPI.h"
#include "usbd_SampleTask.h"
#include "IDETask.h"

/*****************************************
 * Define definition
 *****************************************/
#define STATUS_STATE_ERROR		(-1)

/*****************************************
 * Strcuture definition
 *****************************************/

/*****************************************
 * Function prototype declaration
 *****************************************/
static void InitVariable( void );

/*****************************************
 * Macro definition
 *****************************************/

/*****************************************
 * Variables definition
 *****************************************/
USBD_SAMPLE_MODULE_INFO USBD_SampleInfo;

/*
//=============================================================================
// Function_Name: USBD_Sample_Create
// description	: Create this module
//				: Do nothing if it is things except a standard profile
//				: Reply STATUS_SUCCESS
// argument		: none
// return		: long
//=============================================================================
*/
long USBD_Sample_Create ( void )
{
	USBD_SampleInfo.state = USBD_SAMPLE_STATE_NON_EXISTENT;

	//Initialize the variables used by this module
	InitVariable();

	//Change to stop state
	USBD_SampleInfo.state = USBD_SAMPLE_STATE_STOP;


	return STATUS_SUCCESS;
}

/*
//=============================================================================
// description	: Delete this module
// argument		: none
// return		: long status Specify the error state
//				:	   : STATUS_SUCCESS : Completed successfully
//				:	   : STATUS_UNSUCSSESSFUL: Completed unsuccessfully
//=============================================================================
*/
long USBD_Sample_Delete ( void )
{
	//Confirm the state
	if( USBD_SampleInfo.state == USBD_SAMPLE_STATE_NON_EXISTENT )
	{
		//Error for an unregistered state
		return STATUS_UNSUCCESSFUL;
	}

	return STATUS_SUCCESS;
}

/*
//=============================================================================
// Function_Name: USBD_Sample_Active
// description	: Create this module
// argument		: USBD_SAMPLE_PFN_CALLBACK_PROC pfnCallbackProc
//				: Address of function whick receives message from this module
// return		: long status
//				:	Result of operation of this API
//=============================================================================
*/
long USBD_Sample_Active ( USBD_SAMPLE_PFN_CALLBACK_PROC pfnCallbackProc)
{
	OS_BOOL	dspState;		//State of dispatch

	//========================================================================
	//Parameter's judgment
	//========================================================================
	if( pfnCallbackProc == NULL )
	{
		//Parameter error
		return STATUS_INVALID_PARAMETER;
	}

	//========================================================================
	//Check state
	//========================================================================
	if( USBD_SampleInfo.state != USBD_SAMPLE_STATE_STOP )
	{
		return STATUS_UNSUCCESSFUL;
	}

	//========================================================================
	//Start the HostSample Task
	//========================================================================
	dspState = OS_SnsDsp();		//Refer to state of dispatch
	if( dspState != OS_TRUE )
	{
		//When dispatch is valid, invalidate it
		OS_DisDsp();
	}

	//========================================================================
	//Initialize each variable
	//========================================================================
	USBD_SampleInfo.state = USBD_SAMPLE_STATE_ACTIVE;
	USBD_SampleInfo.pfnMsgProc = pfnCallbackProc;			//Register the callback function
	OS_ActTsk( TSKID_USBD_SAMPLE  );							//Start the HostSample Task

	if( dspState != OS_TRUE )
	{
		//When dispatch is invalidated, return it to valid
		OS_EnaDsp();
	}

	return STATUS_SUCCESS;
}

/*
//=============================================================================
// Function_Name: HostSample_Inactive
// description	: Stop this module
// argument		: none
// return		: long
//=============================================================================
*/
long USBD_Sample_Inactive ( void )
{
	//========================================================================
	//Check state
	//========================================================================
	if( (USBD_SampleInfo.state == USBD_SAMPLE_STATE_NON_EXISTENT) || (USBD_SampleInfo.state == USBD_SAMPLE_STATE_STOP ) )
	{
		//Error for an unregistered state, and stop state
		return STATUS_UNSUCCESSFUL;
	}

	//========================================================================
	//
	//Because synchronization and communication mechanism can't be dynamically deleted
	//for a standard profile, remained mailboxes cannot be deleted.
	//Therefore, set "" bit to delete it when reset
	//========================================================================
	OS_ClrFlg( FLGID_USBD_SAMPLE, ~FLG_WAIT_PTN_USBD_SAMPLE );
	OS_SetFlg( FLGID_USBD_SAMPLE, FLG_EVENT_FORCE_USBD_SAMPLE );
	USBD_SampleInfo.state = USBD_SAMPLE_STATE_STOP;

	//This module ends the task of starting
	OS_TerTsk( TSKID_USBD_SAMPLE );

	USBD_SampleInfo.state = USBD_SAMPLE_STATE_STOP;

	return STATUS_SUCCESS;
}

/*
//=============================================================================
// Function_Name: InitVariable
// description	: Initialize the variables used by this module
// argument		: none
// return		: none
//=============================================================================
*/
void InitVariable( void )
{
	//Initialize the variables
}

⌨️ 快捷键说明

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