📄 devicetaskapi.h
字号:
/*
* description : DEVICE_TASK moduleAPI
* Maker : Michiru.Kagaya
* Copyright : (C)2003,SEIKO EPSON Corp. All Rights Reserved.
*/
#ifndef DEVICE_API_H
#define DEVICE_API_H
#ifdef __cplusplus
extern "C" {
#endif /* cplusplus */
//==========================================================================//
// //
// Define declaration //
// //
//==========================================================================//
//----------------------------------------------------------------------------
// DEVICE API Status error code
//----------------------------------------------------------------------------
#define DEVICE_TASK_STATUS_SUCCESS ( 0L) // Completed successfully
#define DEVICE_TASK_STATUS_UNSUCCESSFUL (- 1L) //
#define DEVICE_TASK_STATUS_NOT_IMPLEMENTED (- 3L) // Not implemented
#define DEVICE_TASK_STATUS_INVALID_PARAMETER (- 4L) //
#define DEVICE_TASK_STATUS_STATE_ERROR (-10L) //
#define DEVICE_TASK_STATUS_EXEC_CMD (-12L) //----------------------------------------------------------------------------
// DEVICE_TASK_Active() Play operation mode
//----------------------------------------------------------------------------
#define DEVICE_TASK_PLAY_CMD_ASYNC_MODE (0x00) // Asynchronous mode
#define DEVICE_TASK_PLAY_CMD_SYNC_MODE (0x01) // Isochronous mode
//----------------------------------------------------------------------------
// Tapte of DEVICE_TASK_Active() CallBack
//----------------------------------------------------------------------------
typedef void (*DEVICE_TASK_PFN_CALLBACK_PROC) ( unsigned long message, unsigned long param0, void* pParam );
//----------------------------------------------------------------------------
// Operation mode of DEVICE_TASK_StartUSB USB storage
//----------------------------------------------------------------------------
#define DEVICE_TASK_MODE_USB_MANUAL_ATTACH (0x0001) // Manual USB attach
#define DEVICE_TASK_MODE_USB_MANUAL_PWR_CTL (0x0002) // Manual USB suspend
#define DEVICE_TASK_MODE_USB_AUTO_PWR_LV0 (0x0004) // Auto USB suspend LV0
#define DEVICE_TASK_MODE_USB_AUTO_PWR_LV1 (0x0008) // Auto USB suspend LV0
#define DEVICE_TASK_MODE_USB_AUTO_PWR_LV2 (0x0010) // Auto USB suspend LV0
//----------------------------------------------------------------------------
// DEVICE_TASK_GetState state
//----------------------------------------------------------------------------
#define DEVICE_TASK_STATE_NON_EXISTENT (0x01) // State of unregistered
#define DEVICE_TASK_STATE_STOP (0x02) // State of stop
#define DEVICE_TASK_STATE_MODULE_INIT (0x03) // Module's initializing state
#define DEVICE_TASK_STATE_DEV_INIT (0x04) // Connected IDE device's initializing state
#define DEVICE_TASK_STATE_WAIT_EVENT (0x05) // State of waiting event
#define DEVICE_TASK_STATE_SLEEP_A (0x06) // State of Sleep A
#define DEVICE_TASK_STATE_PLAY_CMD_EXEC (0x07) // State of Command processing
#define DEVICE_TASK_STATE_PLAY_DMA_READY (0x08) // Wait for DMA transfer's start
#define DEVICE_TASK_STATE_PLAY_DMA_XFER (0x09) // State of DMA transferring
#define DEVICE_TASK_STATE_PLAY_DMA_ABORT (0x0A) // Wait for DMA transfer's termination
#define DEVICE_TASK_STATE_USB_NON_CONNECT (0x0B) // State of USB disconnect
#define DEVICE_TASK_STATE_USB_STORAGE (0x0C) // State of USB storage
#define DEVICE_TASK_STATE_USB_SUSPEND (0x0D) // State of USB suspend
#define DEVICE_TASK_STATE_MODULE_ACC (0x0E) // State of other module accessing
#define DEVICE_TASK_STATE_USB_WAIT_STOP (0x0F) // Wait for USB storage operation's stop
//----------------------------------------------------------------------------
// DEVICE_TASK Set/GetPowerState suspned Level
//----------------------------------------------------------------------------
#define DEVICE_TASK_SUSPEND_LV0 (0x01) // Suspend LV0
#define DEVICE_TASK_SUSPEND_LV1 (0x02) // Suspend LV1
#define DEVICE_TASK_SUSPEND_LV2 (0x03) // Suspend LV2
//----------------------------------------------------------------------------
// DEVICE_TASK_SendUserStrgStatus cmdStatus
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// DEVICE_TASK Xfer mode
//----------------------------------------------------------------------------
#define DEVICE_TASK_XFER_MODE_PIO (0x00) // PIO xfer
#define DEVICE_TASK_XFER_MODE_DMA (0x01) // DMA xfer
//----------------------------------------------------------------------------
// transfer direction
//----------------------------------------------------------------------------
#define DEVICE_TASK_XFER_DIR_IN (0x00) // DMA in xfer
#define DEVICE_TASK_XFER_DIR_OUT (0x01) // DMA out xfer
//----------------------------------------------------------------------------
// DMA channel
//----------------------------------------------------------------------------
#define DEVICE_TASK_DMA_CH0 (0x00) // DMA Channel 0
#define DEVICE_TASK_DMA_CH1 (0x01) // DMA Channel 1
//----------------------------------------------------------------------------
// USB Pull-up Control
//----------------------------------------------------------------------------
#define DEVICE_TASK_USB_PULLUP_ON (0x01) // D+ Pull-up on
#define DEVICE_TASK_USB_PULLUP_OFF (0x02) // D+ Pull-up off
//----------------------------------------------------------------------------
// VBUS STATE
//----------------------------------------------------------------------------
#define DEVICE_TASK_USB_VBUS_HIGH (0x01) // High
#define DEVICE_TASK_USB_VBUS_LOW (0x00) // Low
//----------------------------------------------------------------------------
// IDE CMD TYPE
//----------------------------------------------------------------------------
#define DEVICE_TASK_IDECMD_TYPE_ATA (0x00) // command type ATA
#define DEVICE_TASK_IDECMD_TYPE_ATAPI (0x01) // command type ATAPI
//----------------------------------------------------------------------------
// IDE Cmd Status
//----------------------------------------------------------------------------
#define DEVICE_TASK_CMD_STATUS_PASSED (1) // Command terminated normally
#define DEVICE_TASK_CMD_STATUS_FAILED (0) // Command terminated abnormally
#define DEVICE_TASK_PHASE_ERR (2) //Protocol Error(Add for USBCV MSC Test)
//----------------------------------------------------------------------------
// CallBack Message
//----------------------------------------------------------------------------
#define DEVICE_TASK_MSG_ACTIVE_CMP (0x01) // Start completed
#define DEVICE_TASK_MSG_USB_VBUS_CHANGED (0x02) // VBUS changed
#define DEVICE_TASK_MSG_USB_STOPPED (0x03) // Notification for completion of USB storage operation's stop
#define DEVICE_TASK_MSG_USB_ATTACH (0x04) // Attach completed
#define DEVICE_TASK_MSG_USB_DETACH (0x05) // Detach completed
#define DEVICE_TASK_MSG_USB_RCV_SUSPEND (0x06) // Receive of USB suspend
#define DEVICE_TASK_MSG_USB_WAKEUP (0x07) // Wake up from USB resume/reset
#define DEVICE_TASK_MSG_USB_RCV_CMD (0x08) // Receive of specified command
#define DEVICE_TASK_MSG_USB_SEND_STS (0x09) // Transfer of specified status
#define DEVICE_TASK_MSG_IDE_HRST_CMP (0x0A) // IDE Hard Reset completed
#define DEVICE_TASK_MSG_PLAY_READY_DMA_CMP (0x0B) // DMA transfer preparation completed
#define DEVICE_TASK_MSG_DATA_XFER_CMP (0x0C) // Transfer completed
#define DEVICE_TASK_MSG_PLAY_IDE_CMD_CMP (0x0D) // Command completed
#define DEVICE_TASK_MSG_DMA_ABORTED (0x0E) // Stop DMA
//==========================================================================//
// //
// Structure declaration //
// //
//==========================================================================//
//----------------------------------------------------------------------------
// DEVICE_TASK_ExecATACmd ATA_CMD
//----------------------------------------------------------------------------
typedef struct _DEVICE_TASK_ATA_CMD {
unsigned char features; // Features
unsigned char secCnt; // Sector count
unsigned char secNum; // Sector number
unsigned char cylLow; // Cylinder low
unsigned char cylHigh; // Cylinder High
unsigned char devHead; // Device head
unsigned char command; // Command
unsigned char bicSecCnt; // Bic sector count
unsigned char bicSecNum; // Bic sector number
unsigned char bicCylLow; // Bic cylinder low
unsigned char bicCylHigh; // Bic cylinder High
unsigned char bicDevHead; // Bic device head
} DEVICE_TASK_ATA_CMD;
//----------------------------------------------------------------------------
// DEVICE_TASK_ExeATAPI_CMD
//----------------------------------------------------------------------------
typedef struct _DEVICE_TASK_ATAPI_CMD {
unsigned long xferSize; // Xfer Size (Add for USBCV MSC Test)
unsigned char command[12]; // Packet Command
unsigned char xferDir; // Xfer Direction (Add for USBCV MSC Test)
} DEVICE_TASK_ATAPI_CMD;
//----------------------------------------------------------------------------
// DEVICE_TASK_ExeATA(PI)_CMD
//----------------------------------------------------------------------------
typedef struct _DEVICE_TASK_XFER_INFO {
unsigned char mode; // transfer mode
unsigned long size; // transfer size
unsigned char dir; // direction
unsigned char* pAddress; // Data address of PIO transfer
unsigned char dmaChannel; // DMA channel
} DEVICE_TASK_XFER_INFO;
//==========================================================================//
// //
// DEVICE_TASK Applicasion Interface //
// //
//==========================================================================//
// Create DEVICE module
extern long DEVICE_TASK_Create ( void );
// Delete DEVICE module
extern long DEVICE_TASK_Delete ( void );
// Start DEVICE module
extern long DEVICE_TASK_Active ( DEVICE_TASK_PFN_CALLBACK_PROC pfnCallbackProc, unsigned char cmdMode );
// Stop DEVICE module
extern long DEVICE_TASK_Inactive ( void );
// Start USB operation
extern long DEVICE_TASK_StartUSB ( unsigned long mode );
// Stop USB operation
extern long DEVICE_TASK_StopUSB ( void );
// Get DEVICE module's state
extern long DEVICE_TASK_GetState ( unsigned short* pDEVICEState );
// Set current consumption's state
extern long DEVICE_TASK_SetPowerState ( unsigned char suspendLevel );
// Get current consumption's state
extern long DEVICE_TASK_GetPowerState ( unsigned char* pSuspendLevel );
// Set USB storage's special execution command
extern long DEVICE_TASK_SetUserStrgCmd ( unsigned char LUN, unsigned char length, const unsigned char* pCmdCode );
// Set the status of USB storage's special command
extern long DEVICE_TASK_SendUserStrgStatus ( unsigned char cmdStatus);
// PLAY operation, IDE command execution
long DEVICE_TASK_ExecIdeCmd ( unsigned char LUN, unsigned char cmdType, void* pIdeCmd, DEVICE_TASK_XFER_INFO* pXferInfo );
// Request to start the USB PIO transfer
extern long DEVICE_TASK_StartUSBPIO ( unsigned char dir, unsigned long size, unsigned char* pAddress );
// Request to start the USB DMA transfer
extern long DEVICE_TASK_StartUSBDMA ( unsigned char dir, unsigned long size, unsigned char dmaChannel );
// Request to start the PLAY DMA transfer
extern long DEVICE_TASK_StartDma ( void );
// Request to abort the DMA transfer
extern long DEVICE_TASK_AbortDma ( void );
// Request to reset the connected IDE device's hardware
extern long DEVICE_TASK_IDE_HRST ( void );
// Request to set the USB D+'s Pull-up
extern long DEVICE_TASK_PullupControl ( unsigned char control );
#ifdef __cplusplus
}
#endif /* cplusplus */
#endif /* DEVICE_API_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -