📄 usbdtask.h
字号:
/*
* description :
* Maker :
* Copyright : (C)2003,SEIKO EPSON Corp. All Rights Reserved.
*/
#ifndef USBD_TSK_H
#define USBD_TSK_H
#include "SPRDEF.h"
/*
* Function prototype declaration
*/
// USB Device Task:Task
#define TSK_EXINFO_USBD (NULL)
#define TSK_ATTRIBUTE_USBD (OS_TA_HLNG)
#define TSK_PRIORITY_USBD (7)
#define TSK_STACK_SIZE_USBD (1024)
#define TSK_STACK_ADD_USBD (0)
// USB Device Task:Fixed length memory pool for message transmission
#define MPF_ATTRIBUTE_USBD_MSG (OS_TA_TFIFO)
#define MPF_BLOCK_CNT_USBD_MSG (8)
#define MPF_BLOCK_SIZE_USBD_MSG (44 + OS_TMSG_SIZE)
#define MPF_BLOCK_ADD_USBD_MSG (NULL)
// USB Device Task:Mailbox
#define MBX_ATTRIBUTE_USBD (OS_TA_TFIFO)
#define MBX_MAX_PRI_USBD (1)
#define MBX_PRI_ADD_USBD (NULL)
// USB Device Task:Event flag
#define FLG_ATTRIBUTE_USBD (OS_TA_TFIFO)
#define FLG_PATTERN_USBD (0)
// Event flag: Bit definition
#define FLG_EVENT_FORCE_USBD 0x80000000 /* (bit31) Force process event */
#define FLG_EVENT_INT_USBD 0x08000000 /* (bit27) Interrupt process event */
#define FLG_EVENT_MSG_USBD 0x00000001 /* (bit0 ) Message process event */
// Event flag: Pattern of waiting
#define FLG_WAIT_PTN_USBD ( FLG_EVENT_FORCE_USBD | FLG_EVENT_INT_USBD | FLG_EVENT_MSG_USBD )
#define MSGUSBD_DATSIZE (32) /* Size of USBD message data */
typedef struct _MsgHeadUsbd{ /* Common header of message */
T_MSG header; /* Area used by OS */
OS_ID useMpfId; /* ID of memory pool to be used */
OS_ID msgSndTskId; /* Task ID of sending side */
USHORT msgNo; /* Message number */
USHORT msgLength; /* Length of message data */
}MSGHEADUSBD, *PMSGHEADUSBD;
typedef struct _MsgUsbd{ /* Mailbox for USBD task */
MSGHEADUSBD msgHead; /* Header of message */
UCHAR msgData[MSGUSBD_DATSIZE]; /* Data of message */
} MSGUSBD, *PMSGUSBD;
extern void USBDTask( void );
/*------------------------------------*/
/* Message number */
/*------------------------------------*/
/* Task management */
#define MSG_NTFY_USBD_FORCE_CMP (0x0000) /* Notification of completion for force event process */
/* Descriptor management */
#define MSG_REQ_USBD_SET_DESC (0x0001) /* Request of setting USB Descriptor */
#define MSG_NTFY_USBD_SET_DESC_CMP (0x0002) /* Notification of completion for USB Descriptor setting */
/* USB-BUS management */
#define MSG_REQ_USBD_DETECT_VBUS (0x0011) /* Request of VBUS detection setting */
#define MSG_NTFY_USBD_DETECT_VBUS (0x0012) /* Notification of completion for VBUS detection setting */
#define MSG_REQ_USBD_VBUS_STATUS (0x0013) /* Request of notifying VBUS state */
#define MSG_NTFY_USBD_VBUS_STATUS (0x0014) /* Notification of VBUS state */
#define MSG_REQ_USBD_PULLUP_CTRL (0x0021) /* Request of USB Attach/Detach */
#define MSG_NTFY_USBD_PULLUP_CTRL (0x0022) /* Notification of USB Attach/Detach */
#define MSG_REQ_USBD_WAKEUP (0x0023) /* Request of Wake-up */
#define MSG_NTFY_USBD_WAKEUP (0x0024) /* Notification of completion for Wake-up */
#define MSG_REQ_USBD_REMOTEWAKEUP (0x0025) /* Request of USB's remote Wake-up */
#define MSG_NTFY_USBD_REMOTEWAKEUP (0x0026) /* Notification of completion for USB remote Wake-up */
#define MSG_NTFY_USBD_SUSPEND (0x0027) /* Notification of USB suspension */
#define MSG_NTFY_USBD_RESET (0x0028) /* Notification of USB reset */
#define MSG_NTFY_USBD_RESUME (0x0029) /* Notification of USB resume */
/* Process for request */
#define MSG_REQ_USBD_REQUEST_NTFY_PARAM (0x0041) /* Request of setting notification of receiving request */
#define MSG_NTFY_USBD_REQUEST_NTFY_PARAM (0x0042) /* Notification of completion for setting notification of receiving request */
#define MSG_NTFY_USBD_REQUEST (0x0043) /* Notification of receiving of USB request */
#define MSG_REQ_USBD_REQUEST_XFER_START (0x0044) /* Request of transferring of request data */
#define MSG_NTFY_USBD_REQUEST_XFER_CMP (0x0045) /* Notification of completion for transferring request data */
#define MSG_REQ_USBD_REQUEST_END (0x0046) /* Request of completing request process */
#define MSG_NTFY_USBD_REQUEST_END (0x0047) /* Notification of completion for request process */
/* Process of Storage Class */
#define MSG_NTFY_USBD_STRG_ACTIVE_CHANGE (0x0101) /* Notification of Enable/Disable for Storage Class */
#define MSG_REQ_USBD_STRG_RESET (0x0102) /* Request of storage reset */
#define MSG_NTFY_USBD_STRG_RESET (0x0103) /* Notification of completion for storage reset */
#define MSG_REQ_USBD_STRG_SET_LUN (0x0104) /* Request of setting the number of connected devices */
#define MSG_NTFY_USBD_STRG_SET_LUN (0x0105) /* Notification of completion for setting the number of connected devices */
#define MSG_NTFY_USBD_STRG_CMD (0x0106) /* Notification of receiving for storage command */
#define MSG_REQ_USBD_STRG_XFER_START (0x0107) /* Request of transferring storage data */
#define MSG_NTFY_USBD_STRG_XFER_READY (0x0108) /* Notification of completion for preparing of storage data transfer */
#define MSG_REQ_USBD_STRG_XFER_ABORT (0x0109) /* Request of terminating storage data transfer */
#define MSG_REQ_USBD_STRG_XFER_FLUSH (0x010A) /* Request of flushing storage data transfer */
#define MSG_NTFY_USBD_STRG_XFER_CMP (0x010B) /* Notification of completion for storage data transfer */
#define MSG_REQ_USBD_STRG_CMD_END (0x010C) /* Request of completing storage command process */
#define MSG_NTFY_USBD_STRG_CMD_END (0x010D) /* Notification of completion for storage command process */
/*------------------------------------*/
/* Definition for message data */
/*------------------------------------*/
/* Value for common result */
#define USBD_REQ_OK (0x00) /* Finished normally */
#define USBD_DATA_ABORT (0x01) /* Data transfer is terminated */
#define USBD_REQ_NG (0xFF) /* Finished abnormally */
#define USBD_STATE_ERR (0xFE) /* State error */
#define USBD_PARAM_ERR (0xFD) /* Parameter error */
/* MSG_REQ_USBD_DETECT_VBUS */
#define USBD_VBUS_ENABLE (1) /* VBUS detection is enabled */
#define USBD_VBUS_DISABLE (0) /* VBUS detection is disabled */
/* MSG_NTFY_USBD_VBUS_STATUS */
#define USBD_VBUS_CONNECT (1) /* Connect the USB cable */
#define USBD_VBUS_DISCONNECT (0) /* Disconnect the USB cable */
/* MSG_REQ_USBD_PULLUP_CTRL */
#define USBD_ATTACH (1) /* Attach */
#define USBD_DETACH (0) /* Detach */
/* MSG_NTFY_USBD_RESET */
#define USBD_FS_MODE (1) /* FS action */
#define USBD_HS_MODE (2) /* HS action */
/* MSG_REQ_USBD_REQUEST_NTFY_PARAM */
#define USBD_REQ_NTFY_ENABLE (1) /* Notification of receiving for USB Class/Vendor Request is enabled */
#define USBD_REQ_NTFY_DISABLE (0) /* Notification of receiving for USB Class/Vendor Request is disabled */
/* MSG_REQ_USBD_REQUEST_XFER_START/MSG_REQ_USBD_STRG_XFER_START */
#define USBD_DIRIN (1) /* IN direction */
#define USBD_DIROUT (0) /* OUT direction */
/* MSG_REQ_USBD_REQUEST_END_CMD */
#define USBD_REQUEST_PASS (1) /* PASS */
#define USBD_REQUEST_FAILED (2) /* FAIL */
/* MSG_NTFY_USBD_STRG_ACTIVE_CHANGE */
#define USBD_STORAGE_ACTIVE (1) /* Storage Class is enabled */
#define USBD_STORAGE_INACTIVE (0) /* Storage Class is disabled */
/* MSG_REQ_USBD_STRG_XFER_START */
#define USBD_PIO (1) /* PIO transfer */
#define USBD_DMA (2) /* DMA transfer */
#define USBD_DMACH0 (0) /* IDE DMA transfer */
#define USBD_DMACH1 (1) /* CPU DMA0 transfer */
#define USBD_DMACH2 (2) /* CPU DMA1 transfer */
#define USBD_SHORTENB (1) /* ShortPkt is enabled */
#define USBD_SHORTDIS (0) /* ShortPkt is disabled */
/* MSG_REQ_USBD_STRG_END_CMD */
#define USBD_STRG_CMD_PASS (1) /* Storage command Finished normally */
#define USBD_STRG_CMD_FAILED (2) /* Storage command Finished abnormally */
#define USBD_STRG_PHASE_ERR (3) /* Storage command phase error(Add for USBCV MSC Test) */
/*------------------------------------*/
/* Format for message data area */
/*------------------------------------*/
/* Request of setting USB Descriptor */
typedef struct _PARAM_MSG_REQ_USBD_SET_DESC {
UCHAR *bufferPtr; /* Descriptor information */
USHORT descSize;
} PARAM_MSG_REQ_USBD_SET_DESC;
/* Notification of completion for USB Descriptor setting */
typedef struct _PARAM_MSG_NTFY_USBD_SET_DESC_CMP {
UCHAR result; /* Result of process */
} PARAM_MSG_NTFY_USBD_SET_DESC_CMP;
/* Request of setting VBUS detection */
typedef struct _PARAM_MSG_REQ_USBD_DETECT_VBUS {
UCHAR detectFlag; /* VBUS detection is enabled/disabled */
} PARAM_MSG_REQ_USBD_DETECT_VBUS;
/* Notification of completion for VBUS detection */
typedef struct _PARAM_MSG_NTFY_USBD_DETECT_VBUS {
UCHAR result; /* Result of process */
} PARAM_MSG_NTFY_USBD_DETECT_VBUS;
/* Notification of VBUS state */
typedef struct _PARAM_MSG_NTFY_USBD_VBUS_STATUS {
UCHAR vbusStatus; /* State of VBUS */
} PARAM_MSG_NTFY_USBD_VBUS_STATUS;
/* Request of USB Attach/Detach */
typedef struct _PARAM_MSG_REQ_USBD_PULLUP_CTRL {
UCHAR pullupFlag; /* Request of USB Attach/Detach */
} PARAM_MSG_REQ_USBD_PULLUP_CTRL;
/* Notification of USB Attach/Detach */
typedef struct _PARAM_MSG_NTFY_USBD_PULLUP_CTRL {
UCHAR result; /* Result of process */
} PARAM_MSG_NTFY_USBD_PULLUP_CTRL;
/* Notification of completion for USB remote Wake-up */
typedef struct _PARAM_MSG_NTFY_USBD_REMOTEWAKEUP {
UCHAR result; /* Result of process */
} PARAM_MSG_NTFY_USBD_REMOTEWAKEUP;
/* Notification of USB reset */
typedef struct _PARAM_MSG_NTFY_USBD_RESET {
UCHAR speedStatus; /* Action mode of FS/HS */
} PARAM_MSG_NTFY_USBD_RESET;
/* Request of setting notification of request receiving */
typedef struct _PARAM_MSG_REQ_USBD_REQUEST_NTFY_PARAM {
UCHAR notifyFlag; /* Flag of notification/non-notification */
} PARAM_MSG_REQ_USBD_REQUEST_NTFY_PARAM;
/* Notification of completion for setting notification of request receiving */
typedef struct _PARAM_MSG_NTFY_USBD_REQUEST_NTFY_PARAM {
UCHAR result; /* Result of process */
} PARAM_MSG_NTFY_USBD_REQUEST_NTFY_PARAM;
/* Notification of USB request receiving */
typedef struct _PARAM_MSG_NTFY_USBD_REQUEST {
UCHAR bmRequestType; /* bmRequestType */
UCHAR bRequest; /* bRequest */
UCHAR wIndexL; /* wIndex 0-7 Bit */
UCHAR wIndexH; /* wIndex 8-15 Bit */
UCHAR wValueL; /* wValue 0-7 Bit */
UCHAR wValueH; /* wValue 8-15 Bit */
UCHAR wLengthL; /* wLength 0-7 Bit */
UCHAR wLengthH; /* wLength 8-15 Bit */
} PARAM_MSG_NTFY_USBD_REQUEST;
/* Request to transferring request data */
typedef struct _PARAM_MSG_REQ_USBD_REQUEST_XFER_START {
UCHAR *bufferPtr; /* Pointer of buffer */
ULONG xferSize; /* Number of data to transfer */
UCHAR xferDir; /* Direction of transfer */
} PARAM_MSG_REQ_USBD_REQUEST_XFER_START;
/* Notification of completion for transferring request data */
typedef struct _PARAM_MSG_NTFY_USBD_REQUEST_XFER_CMP {
USHORT xferedSize; /* Number of data been transferred */
USHORT fifoRemainSize; /* Number of data remained in FIFO */
UCHAR result; /* Result of process */
} PARAM_MSG_NTFY_USBD_REQUEST_XFER_CMP;
/* Request to completing request process */
typedef struct _PARAM_MSG_REQ_USBD_REQUEST_END {
UCHAR requestStatus; /* State of executing for request */
} PARAM_MSG_REQ_USBD_REQUEST_END;
/* Notification of completion for request process */
typedef struct _PARAM_MSG_NTFY_USBD_REQUEST_END {
UCHAR result; /* Result of process */
} PARAM_MSG_NTFY_USBD_REQUEST_END;
/* Notification of Storage Class's Enable/Disable */
typedef struct _PARAM_MSG_NTFY_USBD_STRG_ACTIVE_CHANGE {
UCHAR activeStatus; /* Status of Active/Inactive */
} PARAM_MSG_NTFY_USBD_STRG_ACTIVE_CHANGE;
/* Notification of completion for storage reset */
typedef struct _PARAM_MSG_NTFY_USBD_STRG_RESET {
UCHAR result; /* Result of process */
} PARAM_MSG_NTFY_USBD_STRG_RESET;
/* Request of setting the number of connected devices */
typedef struct _PARAM_MSG_REQ_USBD_STRG_SET_LUN {
UCHAR maxLUN; /* Value of MaxLun */
} PARAM_MSG_REQ_USBD_STRG_SET_LUN;
/* Notification of completion for setting the number of connected devices */
typedef struct _PARAM_MSG_NTFY_USBD_STRG_SET_LUN {
UCHAR result; /* Result of process */
} PARAM_MSG_NTFY_USBD_STRG_SET_LUN;
/* Notification of storage command receiving */
typedef struct _PARAM_MSG_NTFY_USBD_STRG_CMD {
UCHAR storageCmd[12]; /* Storage command */
ULONG xferSize; /* Number of data to transfer */
UCHAR xferDir; /* Direction of transfer */
UCHAR lun; /* LUN */
} PARAM_MSG_NTFY_USBD_STRG_CMD;
/* Request of transferring storage data */
typedef struct _PARAM_MSG_REQ_USBD_STRG_XFER_START {
UCHAR *bufferPtr; /* Pointer of buffer */
ULONG xferSize; /* Number of data to transfer */
UCHAR xferDir; /* Direction of transfer */
UCHAR xferType; /* Transfer type(PIO/DMA) */
UCHAR dmaCh; /* DMA Channel */
UCHAR xferMode; /* Transfer mode */
} PARAM_MSG_REQ_USBD_STRG_XFER_START;
/* Notification of completion for transferring storage data */
typedef struct _PARAM_MSG_NTFY_USBD_STRG_XFER_CMP {
ULONG xferedSize; /* Number of data been transferred */
ULONG fifoRemainSize; /* Number of data remained in FIFO */
UCHAR result; /* Result of process */
} PARAM_MSG_NTFY_USBD_STRG_XFER_CMP;
/* Request to completing storage command process */
typedef struct _PARAM_MSG_REQ_USBD_STRG_CMD_END {
ULONG xferedSize; /* Number of data been transferred */
UCHAR cmdStatus; /* Status of storage command */
} PARAM_MSG_REQ_USBD_STRG_CMD_END;
/* Notification of completion for storage command process */
typedef struct _PARAM_MSG_NTFY_USBD_STRG_CMD_END {
UCHAR result; /* Result of process */
} PARAM_MSG_NTFY_USBD_STRG_CMD_END;
#endif /* USBD_TSK_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -