📄 usbh_storage_api.c
字号:
===============================================================================================*/
LONG USBH_STRG_FuncGetDeviceList( USHORT id, UCHAR *pList )
{
LONG result;
/* OpenFlag Check */
if(OpenFlag != OPEN){
/* Not Opened Error */
return STATUS_NOT_OPENED;
}
/* Check the ID value */
if((id - 1) > USBH_STRG_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
result = USBH_STRG_IFGetDeviceList(pList);
return result;
}
/*=============================================================================================
// Function_Name: USBH_STRG_FuncGetDeviceParameter
//
// description : Informs the upper layer of the detailed information of the specified device.
//
// Informs the upper layer of the detailed information of the specified device.
// Device information is 256 word data that can be acquired with Identify(Packet) Device.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
// *pDataPtr (out)Pointer that points to the device information.
//
// return : STATUS_SUCCESS Complete successfully
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module is not opened
// STATUS_INVALID_PARAMETER Parameter error
===============================================================================================*/
LONG USBH_STRG_FuncGetDeviceParameter( USHORT id, USHORT deviceNo, UCHAR *pDataPtr)
{
LONG result;
/* OpenFlag Check */
if(OpenFlag != OPEN){
/* Not Opened Error */
return STATUS_NOT_OPENED;
}
/* Check the ID value */
if((id - 1) > USBH_STRG_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check the DeviceNo */
if( deviceNo >= USBH_STRG_MAX_DEVICE ){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
result = USBH_STRG_IFGetDeviceParameter(deviceNo, pDataPtr);
return result;
}
/*=============================================================================================
// Function_Name: USBH_STRG_FuncCommandOut
//
// description : Send command to the corresponding device ( Asynchronous processing)
//
// Send command to the corresponding device.
// The issued command can be invalidated with USBH_STRG_FuncDMAStop.
// The data transfer of the device is not done until USBH_STRG_FuncDMAStartA is called.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
// transferMode (in)The transfer mode of the command
// *pCmdBlock (in)Pointer that points to the command parameter
//
// return : STATUS_SUCCESS Complete successfully
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module is not opened
// STATUS_INVALID_PARAMETER Parameter error
// STATUS_EXECUTION_PORT The specified port is running
===============================================================================================*/
LONG USBH_STRG_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 the ID value */
if((id - 1) > USBH_STRG_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check the DeviceNo*/
if( deviceNo >= USBH_STRG_MAX_DEVICE ){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check whether Device is executing the data transfer.*/
if(deviceStatus[deviceNo].dmaStatus == DRV_DMA_FUNC_EXEC) {
/* Transfering the device data */
return STATUS_EXECUTION_PORT;
}
LED_On(8);
result = USBH_STRG_IFCommandOut(deviceNo, transferMode, pCmdBlock, USBH_STRG_IntrqCompCBR[deviceNo][id]);
/* Sets the specified device as in the status of executing the command. */
if(result == STATUS_SUCCESS) {
deviceStatus[deviceNo].id = id;
deviceStatus[deviceNo].cmdStatus = DRV_FUNC_TRAN_READY;
}
return result;
}
/*=============================================================================================
// Function_Name: USBH_STRG_FuncCommandStop
//
// description : Force cancel the executing command of the specified device.
//
// Force cancel the executing command of the specified device.
// Do not notify the completeion of the command.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
//
// return : STATUS_SUCCESS Complete successfully
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module is not opened
// STATUS_INVALID_PARAMETER Parameter error
// STATUS_EXECUTION_PORT The specified port is running
===============================================================================================*/
LONG USBH_STRG_FuncCommandStop( USHORT id, USHORT deviceNo)
{
LONG result;
/* OpenFlag Check */
if(OpenFlag != OPEN){
/* Not Opened Error */
return STATUS_NOT_OPENED;
}
/* Check the ID value */
if((id - 1) > USBH_STRG_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check the DeviceNo */
if( deviceNo >= USBH_STRG_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 operating. */
return STATUS_EXECUTION_PORT;
}
result = USBH_STRG_IFCommandStop(deviceNo);
/* Command Status Clear */
deviceStatus[deviceNo].id = NO_ID;
deviceStatus[deviceNo].cmdStatus = DRV_FUNC_CMD_STOP;
return result;
}
/*=============================================================================================
// Function_Name: USBH_STRG_FuncDMAStartA
//
// description : An asynchronous data transfer is done between specified devices.
//
// An asynchronous data transfer is done between specified devices.
// After the begining of the transfer,the control is returned to a upper layer at once.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
// transferMode (in)The transfer mode of the command
// *pTranPara (in)Pointer that points to the data transfer parameter.
//
// return : STATUS_SUCCESS Complete successfully
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module is not opened
// STATUS_INVALID_PARAMETER Parameter error
// STATUS_EXECUTION_PORT The specified port is running
===============================================================================================*/
LONG USBH_STRG_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 the ID value */
if((id - 1) > USBH_STRG_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check the DeviceNo */
if( deviceNo >= USBH_STRG_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 operating. */
return STATUS_EXECUTION_PORT;
}
/* Check if the device is ready to transfer */
if(deviceStatus[deviceNo].cmdStatus != DRV_FUNC_TRAN_READY) {
/* do not execute the Command */
return STATUS_UNSUCCESSFUL;
}
/* Check if the deive is tranfering data */
if(deviceStatus[deviceNo].dmaStatus == DRV_DMA_FUNC_EXEC) {
/* Device is transfering data */
return STATUS_EXECUTION_PORT;
}
/* Sets the specified device as in the status of transfering data. */
deviceStatus[deviceNo].id = id;
deviceStatus[deviceNo].dmaStatus = DRV_DMA_FUNC_EXEC;
result = USBH_STRG_IFDMAStartA(deviceNo, transferMode, pTranPara, USBH_STRG_DMACompCBR[deviceNo][id]);
if(result != STATUS_SUCCESS) {
/* In the situation of cannot start transfer because of the error*/
deviceStatus[deviceNo].dmaStatus = DRV_DMA_FUNC_STOP;
}
return result;
}
/*=============================================================================================
// Function_Name: USBH_STRG_FuncDMAStop
//
// description : An asynchronous data transfer of the specified device is canceled compulsively.
//
// An asynchronous data transfer of the specified device is canceled compulsively.
// Do not notify the completeion of the command.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
//
// return : STATUS_SUCCESS Complete successfully
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module is not opened
// STATUS_INVALID_PARAMETER Parameter error
// STATUS_EXECUTION_PORT The specified port is running
===============================================================================================*/
LONG USBH_STRG_FuncDMAStop( USHORT id, USHORT deviceNo )
{
LONG result;
/* OpenFlag Check */
if(OpenFlag != OPEN){
/* Not Opened Error */
return STATUS_NOT_OPENED;
}
/* Check the ID value */
if((id - 1) > USBH_STRG_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check the DeviceNo */
if( deviceNo >= USBH_STRG_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_STRG_IFDMAStop(deviceNo);
/* DMA State Clear */
deviceStatus[deviceNo].id = NO_ID;
deviceStatus[deviceNo].dmaStatus = DRV_DMA_FUNC_COMP;
return result;
}
/*=============================================================================================
// Function_Name: USBH_STRG_FuncGetDMAStatus
//
// description : It informs the upper layer of the state of an asynchronous data transfer of the specified device.
//
// It informs the upper layer of the state of an asynchronous data transfer of the specified device.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
// *pStatus (in)Pointer that points to the DMA status
//
// return : STATUS_SUCCESS Complete successfully
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module is not opened
// STATUS_INVALID_PARAMETER Parameter error
// STATUS_EXECUTION_PORT The specified port is running
===============================================================================================*/
LONG USBH_STRG_FuncGetDMAStatus( USHORT id, USHORT deviceNo, ULONG *pStatus )
{
/* OpenFlag Check */
if(OpenFlag != OPEN){
/* Not Opened Error */
return STATUS_NOT_OPENED;
}
/* Check the ID value */
if((id - 1) > USBH_STRG_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check the DeviceNo */
if( deviceNo >= USBH_STRG_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 operating. */
return STATUS_EXECUTION_PORT;
}
*pStatus = deviceStatus[deviceNo].dmaStatus;
return STATUS_SUCCESS;
}
/*=============================================================================================
// Function_Name: USBH_STRG_FuncSoftDataTransfer
//
// description : Non-correspondence API
//
// return : STATUS_NOT_IMPLEMENTEDS It is not implemented.
===============================================================================================*/
LONG USBH_STRG_FuncSoftDataTransfer( USHORT id, USHORT deviceNo, UCHAR transferMode, DRIVEACCESS_FUNCTRANPARA *pTranPara )
{
return STATUS_NOT_IMPLEMENTED ;
}
/*=============================================================================================
// Function_Name: USBH_STRG_FuncGetStatus
//
// description : It informs the upper layer the status of the specified device.
//
// It informs the upper layer the status of the specified device.
// Get the request sense data automatically and notify the upper layer.
//
// argument : id (in)ID value
// deviceNo (in)Device No.
// *pStatus (in)Pointer that point to the status
// *pTransferSize (in)Pointer that point to the number of bytes that could be
// transfered in the previous data transfer process.
// *pSenseData (in)Pointer that points to the request sense data
//
// return : STATUS_SUCCESS Complete successfully
// STATUS_UNSUCCESSFUL Error occured during the process
// STATUS_NOT_OPENED This module is not opened
// STATUS_INVALID_PARAMETER Parameter error
// STATUS_EXECUTION_PORT The specified port is running
===============================================================================================*/
LONG USBH_STRG_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 the ID value */
if((id - 1) > USBH_STRG_MAX_ID || (IdTable[id-1] == FREE_ID)){
/* Parameter error */
return STATUS_INVALID_PARAMETER;
}
/* Check the DeviceNo */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -