📄 usbh_sampletaskapi.c
字号:
/*
* description: Host 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 "usbh_SampleTaskAPI.h"
#include "usbh_SampleTask.h"
#include "IDETask.h"
/*****************************************
* Define definition
*****************************************/
#define STATUS_STATE_ERROR (-1)
/*****************************************
* Structure definition
*****************************************/
/*****************************************
* Function prototype declaration
*****************************************/
static void InitVariable( void );
/*****************************************
* Macro definition
*****************************************/
/*****************************************
* Variable definition
*****************************************/
USBH_SAMPLE_MODULE_INFO USBH_SampleInfo;
/*
//=============================================================================
// Function_Name: USBH_Sample_Create
// description : Create this module
// : Do nothing if it is things except a standard profile
// : STATUS_SUCCESS reply
// argument : none
// return : long
//=============================================================================
*/
long USBH_Sample_Create ( void )
{
USBH_SampleInfo.state = USBH_SAMPLE_STATE_NON_EXISTENT;
// The variable used by this module is initialized
InitVariable();
// Change to the stop state
USBH_SampleInfo.state = USBH_SAMPLE_STATE_STOP;
return STATUS_SUCCESS;
}
/*
//=============================================================================
// Function_Name: USBH_Sample_Delete
// description : Delete this module
// argument : none
// return : long status Specify the error state
// : : STATUS_SUCCESS : Terminated successfully
// : : STATUS_UNSUCSSESSFUL: Terminated unsuccessfully
//=============================================================================
*/
long USBH_Sample_Delete ( void )
{
// State confirmation
if( USBH_SampleInfo.state == USBH_SAMPLE_STATE_NON_EXISTENT )
{
// Error of unregistered state
return STATUS_UNSUCCESSFUL;
}
return STATUS_SUCCESS;
}
/*
//=============================================================================
// Function_Name: USBH_Sample_Active
// description : Create this module
// argument : USBH_SAMPLE_PFN_CALLBACK_PROC pfnCallbackProc
// : Function address of receiving message from this module
// return : long status
// : Operation result of this API
//=============================================================================
*/
long USBH_Sample_Active ( USBH_SAMPLE_PFN_CALLBACK_PROC pfnCallbackProc)
{
OS_BOOL dspState; // State of dispatch
//========================================================================
// Parameter judgment
//========================================================================
if( pfnCallbackProc == NULL )
{
// Parameter error
return STATUS_INVALID_PARAMETER;
}
//========================================================================
// Check state
//========================================================================
if( USBH_SampleInfo.state != USBH_SAMPLE_STATE_STOP )
{
return STATUS_UNSUCCESSFUL;
}
//========================================================================
// Start HostSample Task
//========================================================================
dspState = OS_SnsDsp(); // Refer to the dispatch state
if( dspState != OS_TRUE )
{
// Invalidate it when dispatch is valid
OS_DisDsp();
}
//========================================================================
// Initialization of each variable
//========================================================================
USBH_SampleInfo.state = USBH_SAMPLE_STATE_ACTIVE;
USBH_SampleInfo.pfnMsgProc = pfnCallbackProc; // Register the callback function
OS_ActTsk( TSKID_USBH_SAMPLE ); // Start the HostSample Task
if( dspState != OS_TRUE )
{
// Return to valid, When dispatch is invalidated,
OS_EnaDsp();
}
return STATUS_SUCCESS;
}
/*
//=============================================================================
// Function_Name: HostSample_Inactive
// description : Stop this module
// argument : none
// return : long
//=============================================================================
*/
long USBH_Sample_Inactive ( void )
{
//========================================================================
// Check state
//========================================================================
if( (USBH_SampleInfo.state == USBH_SAMPLE_STATE_NON_EXISTENT) || (USBH_SampleInfo.state == USBH_SAMPLE_STATE_STOP) )
{
// Error for 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_USBH_SAMPLE, ~FLG_WAIT_PTN_USBH_SAMPLE );
OS_SetFlg( FLGID_USBH_SAMPLE, FLG_EVENT_FORCE_USBH_SAMPLE );
USBH_SampleInfo.state = USBH_SAMPLE_STATE_STOP;
// This module ends the task of starting
OS_TerTsk( TSKID_USBH_USBD );
OS_TerTsk( TSKID_IDE );
OS_TerTsk( TSKID_USBH_SAMPLE );
USBH_SampleInfo.state = USBH_SAMPLE_STATE_STOP;
return STATUS_SUCCESS;
}
/*
//=============================================================================
// Function_Name: InitVariable
// description : The variable used by this module is initialized
// argument : none
// return : none
//=============================================================================
*/
void InitVariable( void )
{
// Initialization of variable
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -