📄 usbh_usbd_api.c
字号:
/*
* description: USBH USBD APIs(global)
* Maker : Toshiyuki Sakai
* 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 <usbh_usbd_api.h>
#include <usbh_usbds_api.h>
#include <usbh_stacktask.h>
/*****************************************
* Define definition
*****************************************/
/*****************************************
* Structure definition
*****************************************/
/*****************************************
* Function prototype declaration
*****************************************/
Inline void USBH_USBD_SendMessage ( USHORT msgCode, USHORT size, const VOID* buffer );
extern USBH_USBD_USBDEV * USBH_USBDS_SearchDev(UCHAR devaddr, long *retValue);
/*****************************************
* Macro definition
*****************************************/
/*****************************************
* Variable definition
*****************************************/
/*=============================================================================================
// Function_Name:USBH_USBD_Init
//
// description : Initalize this module
//
// Carry out securing necessary memory area, HCD initialization, reset,
// initialization of each function block for management of this module.
//
// argument : pfnCallback Pointer to call back function to notify completion ( in ).
//
// return : USBH_USBD_STATUS_SUCCESS Process is finished normally
// USBH_USBD_STATUS_INVALID_PARAMETER There were some errors in passed parameter
===============================================================================================*/
long USBH_USBD_Init( USBH_USBD_CALLBACK pfnCallback )
{
long retValue ;
MSG_USBH_USBD tmp;
if((USBH_USBD_CALLBACK)pfnCallback == NULL) {
retValue = USBH_USBD_STATUS_INVALID_PARAMETER;
} else {
memset(&tmp, 0, sizeof(MSG_USBH_USBD));
tmp.pfnCallback = pfnCallback;
/* Send message to USB task */
USBH_USBD_SendMessage( MSG_USBH_USBD_INIT, sizeof(MSG_USBH_USBD), &tmp );
retValue = USBH_USBD_STATUS_SUCCESS;
}
return retValue ;
}
/*=============================================================================================
// Function_Name: USBH_USBD_Cleanup
//
// description : HostStack actuation it halts.
//
// Halt, of the power supply that is supplying it to (VBUS of a/the route hub port
// the initialization of HCD I do the release of the memory) that used it for the release,
// device control of the memory area that used it with HCD.
// Also I do the release of the memory area of active URB, device information etc.
// with HostStack.
//
// argument : none
//
// return : USBH_USBD_STATUS_SUCCESS Processing settled normally.
// USBH_USBD_STATUS_UNSCCESSFUL Host Controller is during suspend.
===============================================================================================*/
long USBH_USBD_Cleanup( void )
{
long retValue;
MSG_USBH_USBD tmp;
/* Initialize. */
memset(&tmp, 0, sizeof(MSG_USBH_USBD));
/* Send to USB Task. */
USBH_USBD_SendMessage( MSG_USBH_USBD_CLEANUP, sizeof(MSG_USBH_USBD), &tmp );
retValue = USBH_USBD_STATUS_SUCCESS;
return retValue;
}
/*=============================================================================================
// Function_Name:USBH_USBD_SubmitURB
//
// description : After checking passed URB parameter, pipe, carry out URB registration and execution.
// It will be used in data transfer etc..
//
// argument : *psUrb Pointer to URB structure ( in )
// : classid Class ID ( in )
// : pfnCallback Pointer to call back function to notify completion ( in )
//
// return : USBH_USBD_STATUS_SUCCESS Registration finish normally
// USBH_USBD_STATUS_INVALID_PARAMETER There were some errors in passed parameter
===============================================================================================*/
long USBH_USBD_SubmitURB( USBH_USBD_URB *psURB, unsigned char classid, USBH_USBD_CALLBACK pfnCallback )
{
long retValue;
MSG_USBH_USBD tmp;
UCHAR devaddr;
if((USBH_USBD_CALLBACK)pfnCallback == NULL) {
retValue = USBH_USBD_STATUS_INVALID_PARAMETER;
} else if(USBH_USBDS_PipeCheck( psURB->pipe ) == USBH_USBD_STATUS_UNSUCCESSFUL ) { /* Pipe check */
retValue = USBH_USBD_STATUS_INVALID_PARAMETER;
} else if(classid > USBH_USBD_CLASSDRIVERNUM) {
retValue = USBH_USBD_STATUS_INVALID_PARAMETER;
} else {
tmp.classid = classid;
tmp.psURB = psURB;
tmp.pfnCallback = pfnCallback;
USBH_USBD_PipeToPara(psURB->pipe, retValue, retValue, devaddr, retValue);
tmp.psURB->psDev = (USBH_USBD_USBDEV *)USBH_USBDS_SearchDev(devaddr, &retValue);
if(tmp.psURB->psDev) {
/* Send message to USB task */
USBH_USBD_SendMessage( MSG_USBH_USBD_SUBMITURB, sizeof(tmp), &tmp );
retValue = USBH_USBD_STATUS_SUCCESS;
}
else {
/* Case of can't get device information corresponding */
retValue = USBH_USBD_STATUS_INVALID_PARAMETER;
}
}
return retValue;
}
/*=============================================================================================
// Function_Name:USBH_USBD_UnlinkURB
//
// description : Cancel execution of passed URB, carry out deletion.
//
// argument : *psUrb Pointer to URB structure ( in )
// : classid Class ID ( in )
// : pfnCallback Pointer to call back function to notify completion ( in )
//
// return : USBH_USBD_STATUS_SUCCESS Registration finish normally
// USBH_USBD_STATUS_INVALID_PARAMETER There were some errors in passed parameter
===============================================================================================*/
long USBH_USBD_UnlinkURB( USBH_USBD_URB *psURB, unsigned char classid, USBH_USBD_CALLBACK pfnCallback )
{
long retValue;
MSG_USBH_USBD tmp;
UCHAR devaddr;
if((USBH_USBD_CALLBACK)pfnCallback == NULL) {
retValue = USBH_USBD_STATUS_INVALID_PARAMETER;
} else if(classid > USBH_USBD_CLASSDRIVERNUM) {
retValue = USBH_USBD_STATUS_INVALID_PARAMETER;
} else {
tmp.classid = classid;
tmp.psURB = psURB;
tmp.pfnCallback = pfnCallback;
USBH_USBD_PipeToPara(psURB->pipe, retValue, retValue, devaddr, retValue);
if(tmp.psURB->psDev == NULL) {
tmp.psURB->psDev = (USBH_USBD_USBDEV *)USBH_USBDS_SearchDev(devaddr, &retValue);
}
/* Send message to USB task */
USBH_USBD_SendMessage( MSG_USBH_USBD_UNLINKURB, sizeof(tmp), &tmp );
retValue = USBH_USBD_STATUS_SUCCESS;
}
return retValue;
}
/*=============================================================================================
// Function_Name:USBH_USBD_EntryClass
//
// description : Register specified class driver.
//
// argument : classno Class driver number ( in )
// : *classid Class ID ( out )
// : pfnCallback Pointer to call back function to notify completion ( in )
//
// return : USBH_USBD_STATUS_SUCCESS Registration finish normally
// USBH_USBD_STATUS_INVALID_PARAMETER There were some errors in passed parameter
===============================================================================================*/
long USBH_USBD_EntryClass( unsigned char classno, unsigned char *classid, USBH_USBD_CALLBACK pfnCallback, USBH_USBD_CALLBACK pfnEventCallback )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -