📄 usbh_ide_api.c
字号:
/*=============================================================================================
// Function_Name: USBH_IDE_FuncGetDeviceParameter
//
// description : It informs the the detailed information of the device to the upper layer
//
// It informs the the detailed information of the device to the upper layer.
// Can use Identify (Packet) Device to get the device information.Device inforamation is 256 words data.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
// *pDataPtr (out)Pointer of the device information
//
// return : STATUS_SUCCESS Process completed normally
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module had not been opened
// STATUS_INVALID_PARAMETER Parameter error
===============================================================================================*/
LONG USBH_IDE_FuncGetDeviceParameter( USHORT id, USHORT deviceNo, UCHAR *pDataPtr)
{
LONG result;
/* OpenFlag Check */
if(OpenFlag != OPEN){
/* Not Opened Error */
return STATUS_NOT_OPENED;
}
/* Check ID value */
if((id - 1) > USBH_IDE_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return USBH_IDE_STATUS_ID_ERR;
}
/* Check deviceNo value */
if( deviceNo >= USBH_IDE_MAX_DEVICE ){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
result = USBH_IDE_IFGetDeviceParameter(deviceNo, pDataPtr);
return result;
}
/*=============================================================================================
// Function_Name: USBH_IDE_FuncCommandOut
//
// description : Send command to the specified device (Asyncronous (Asynchronous processing)
//
// Send command to the specified device.
// The issued command can be invalidated with USBH_IDE_FuncDMAStop.
// It does not do the data transfer with the device until USBH_IDE_FuncDMAStartA is called.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
// transferMode (in)The transfer mode of the command
// *pCmdBlock (in)The pointer of the command parameter
//
// return : STATUS_SUCCESS Process completed normally
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module had not been opened
// STATUS_INVALID_PARAMETER Parameter error
// STATUS_EXECUTION_PORT The specified port is operating
===============================================================================================*/
LONG USBH_IDE_FuncCommandOut( USHORT id, USHORT deviceNo, UCHAR transferMode, DRIVEACCESS_FUNCCMDPARA *pCmdBlock, DRIVEACCESS_FUNCTRANPARA *pTranPara )
{
LONG result;
/* OpenFlag Check */
if(OpenFlag != OPEN){
/* Not Opened Error */
return STATUS_NOT_OPENED;
}
/* Check ID value */
if((id - 1) > USBH_IDE_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check deviceNo value */
if( deviceNo >= USBH_IDE_MAX_DEVICE ){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check whether device is executing the data transfer. */
if(deviceStatus[deviceNo].dmaStatus == DRV_DMA_FUNC_EXEC) {
/* Device is executing the data transfer */
return STATUS_EXECUTION_PORT;
}
result = USBH_IDE_IFCommandOut(deviceNo, transferMode, pCmdBlock);
/* Sets the specified device to the on executing command. */
if(result == STATUS_SUCCESS) {
deviceStatus[deviceNo].id = id;
deviceStatus[deviceNo].cmdStatus = DRV_FUNC_TRAN_READY;
}
return result;
}
/*=============================================================================================
// Function_Name: USBH_IDE_FuncCommandStop
//
// description : Force stop the on executing command of the specifed device
//
// It sets it while executing a specified device in the command.
// The command end notification is not done.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
//
// return : STATUS_SUCCESS Process completed normally
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module had not been opened
// STATUS_INVALID_PARAMETER Parameter error
// STATUS_EXECUTION_PORT The specified port is operating
===============================================================================================*/
LONG USBH_IDE_FuncCommandStop( USHORT id, USHORT deviceNo)
{
LONG result;
/* OpenFlag Check */
if(OpenFlag != OPEN){
/* Not Opened Error */
return STATUS_NOT_OPENED;
}
/* Check ID value */
if((id - 1) > USBH_IDE_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check deviceNo value */
if( deviceNo >= USBH_IDE_MAX_DEVICE ){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check whether other ID is using Device. */
if(deviceStatus[deviceNo].id != id && deviceStatus[deviceNo].id != NO_ID ) {
/* Device is in operating */
return STATUS_EXECUTION_PORT;
}
result = USBH_IDE_IFCommandStop(deviceNo);
/* Command Status Clear */
deviceStatus[deviceNo].id = NO_ID;
deviceStatus[deviceNo].cmdStatus = DRV_FUNC_CMD_STOP;
return result;
}
/*=============================================================================================
// Function_Name: USBH_IDE_FuncDMAStartA
//
// description : Do Asynchronous data transfer between the specified devices.
//
// Do Asynchronous data transfer between the specified devices.
// When transfer begins, the control is returned to the upper layer at once.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
// transferMode (in)The transfer mode of the command
// *pTranPara (in)Pointer of data transfer parameter
//
// return : STATUS_SUCCESS Process completed normally
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module had not been opened
// STATUS_INVALID_PARAMETER Parameter error
// STATUS_EXECUTION_PORT The specified port is operating
===============================================================================================*/
LONG USBH_IDE_FuncDMAStartA( USHORT id, USHORT deviceNo, UCHAR transferMode, DRIVEACCESS_FUNCTRANPARA *pTranPara )
{
LONG result;
/* OpenFlag Check */
if(OpenFlag != OPEN){
/* Not Opened Error */
return STATUS_NOT_OPENED;
}
/* Check ID value */
if((id - 1) > USBH_IDE_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check deviceNo value */
if( deviceNo >= USBH_IDE_MAX_DEVICE ){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check whether other ID is using Device. */
if(deviceStatus[deviceNo].id != id && deviceStatus[deviceNo].id != NO_ID ) {
/* Device is in operating */
return STATUS_EXECUTION_PORT;
}
/* Check if the device is ready to transfer */
if(deviceStatus[deviceNo].cmdStatus != DRV_FUNC_TRAN_READY) {
/* Not execute the command */
return STATUS_UNSUCCESSFUL;
}
/* Check whether device is executing the data transfer. */
if(deviceStatus[deviceNo].dmaStatus == DRV_DMA_FUNC_EXEC) {
/* Device is executing the data transfer */
return STATUS_EXECUTION_PORT;
}
/* Set the specified device to on executing data transmission */
deviceStatus[deviceNo].id = id;
deviceStatus[deviceNo].dmaStatus = DRV_DMA_FUNC_EXEC;
result = USBH_IDE_IFDMAStartA(deviceNo, transferMode, pTranPara);
if(result != STATUS_SUCCESS) {
/* When cannot start transmission because of the error */
deviceStatus[deviceNo].dmaStatus = DRV_DMA_FUNC_STOP;
}
return result;
}
/*=============================================================================================
// Function_Name: USBH_IDE_FuncDMAStop
//
// description : Force stop the Asynchronous data transfer
//
// Force stop the Asynchronous data transfer.
// The command end notification is not done.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
//
// return : STATUS_SUCCESS Process completed normally
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module had not been opened
// STATUS_INVALID_PARAMETER Parameter error
// STATUS_EXECUTION_PORT The specified port is operating
===============================================================================================*/
LONG USBH_IDE_FuncDMAStop( USHORT id, USHORT deviceNo )
{
LONG result;
/* OpenFlag Check */
if(OpenFlag != OPEN){
/* Not Opened Error */
return STATUS_NOT_OPENED;
}
/* Check ID value */
if((id - 1) > USBH_IDE_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check deviceNo value */
if( deviceNo >= USBH_IDE_MAX_DEVICE ){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check whether other ID is using Device. */
if(deviceStatus[deviceNo].id != id && deviceStatus[deviceNo].id != NO_ID ) {
/* Device in operating */
return STATUS_EXECUTION_PORT;
}
result = USBH_IDE_IFDMAStop(deviceNo);
/* DMA State Clear */
deviceStatus[deviceNo].id = NO_ID;
deviceStatus[deviceNo].dmaStatus = DRV_DMA_FUNC_COMP;
return result;
}
/*=============================================================================================
// Function_Name: USBH_IDE_FuncGetDMAStatus
//
// description : It informs the Asynchronous data transfering status of the specified to the upper layer.
//
// It informs the Asynchronous data transfering status of the specified to the upper layer.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
// *pStatus (in)DMA status pointer
//
// return : STATUS_SUCCESS Process completed normally
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module had not been opened
// STATUS_INVALID_PARAMETER Parameter error
// STATUS_EXECUTION_PORT The specified port is operating
===============================================================================================*/
LONG USBH_IDE_FuncGetDMAStatus( USHORT id, USHORT deviceNo, ULONG *pStatus )
{
/* OpenFlag Check */
if(OpenFlag != OPEN){
/* Not Opened Error */
return STATUS_NOT_OPENED;
}
/* Check ID value */
if((id - 1) > USBH_IDE_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check deviceNo value */
if( deviceNo >= USBH_IDE_MAX_DEVICE ) {
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check whether other ID is using Device. */
if(deviceStatus[deviceNo].id != id && deviceStatus[deviceNo].id != NO_ID ) {
/* Device in operating */
return STATUS_EXECUTION_PORT;
}
*pStatus = deviceStatus[deviceNo].dmaStatus;
return STATUS_SUCCESS;
}
/*=============================================================================================
// Function_Name: USBH_IDE_FuncSoftDataTransfer
//
// description : Non-correspondence API
//
// return : STATUS_NOT_IMPLEMENTEDS It is not implemented.
===============================================================================================*/
LONG USBH_IDE_FuncSoftDataTransfer( USHORT id, USHORT deviceNo, UCHAR transferMode, DRIVEACCESS_FUNCTRANPARA *pTranPara )
{
return STATUS_NOT_IMPLEMENTED ;
}
/*=============================================================================================
// Function_Name: USBH_IDE_FuncGetStatus
//
// description : It informs the status of the specified device to the upper layer.
//
// It informs the status of the specified device to the upper layer.
// Get the request sense data automatically and inform the upper layer.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
// *pStatus (in)Status pointer
// *pTransferSize (in)The pointer that points to the number of bytes
// transfered in the previous executed data transfer
// *pSenseData (in)Pointer of the request sense data
//
// return : STATUS_SUCCESS Process completed normally
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module had not been opened
// STATUS_INVALID_PARAMETER Parameter error
// STATUS_EXECUTION_PORT The specified port is operating
===============================================================================================*/
LONG USBH_IDE_FuncGetStatus( USHORT id, USHORT deviceNo, ULONG *pStatus, ULONG *pTransferSize, UCHAR *pSenseData )
{
LONG result;
/* OpenFlag Check */
if(OpenFlag != OPEN){
/* Not Opened Error */
return STATUS_NOT_OPENED;
}
/* Check ID value */
if((id - 1) > USBH_IDE_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check deviceNo value */
if( deviceNo >= USBH_IDE_MAX_DEVICE ){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -