csl_usbf.h

来自「dsp在音频处理中的运用」· C头文件 代码 · 共 1,251 行 · 第 1/4 页

H
1,251
字号
    /** Size of the data */
    Uint32  length;
} CSL_UsbfRxTxFifo ;

/*****************************************************************************/

/** @defgroup CSL_USBF_ISO_EP_STATUS_<SYMBOL> Symbols representing ISO endpoint status
*   @ingroup CSL_USBF_QUERY_ISO_EP_STATUS query of CSL_UsbfGetHwStatus API
*
* @{ */
    /** Endpoint received a packet on previous frame */
#define CSL_USBF_ISO_EP_STATUS_NO_RXPACKET      (CSL_USBF_STAT_FLG_NO_RXPACKET_MASK)
    /** IN token in previous frame */
#define CSL_USBF_ISO_EP_STATUS_NO_INTOKEN       (CSL_USBF_STAT_FLG_MISS_IN_MASK)
    /** The isochronous receive data flush status */
#define CSL_USBF_ISO_EP_STATUS_DATAFLUSHED      (CSL_USBF_STAT_FLG_DATA_FLUSH_MASK)
    /** The isochronous receive data error status */
#define CSL_USBF_ISO_EP_STATUS_ISOPACKETERROR   (CSL_USBF_STAT_FLG_ISO_ERR_MASK)
    /** The ISO FIFO empty status */
#define CSL_USBF_ISO_EP_STATUS_FIFOEMPTY        (CSL_USBF_STAT_FLG_ISO_FIFO_EMPTY_MASK)
    /** The ISO FIFO full status */
#define CSL_USBF_ISO_EP_STATUS_FIFOFULL         (CSL_USBF_STAT_FLG_ISO_FIFO_FULL_MASK)
/** 
@} */


/** @defgroup CSL_USBF_NONISO_EP_STATUS_<SYMBOL> Symbols representing non-ISO endpoint status
*   @ingroup CSL_USBF_QUERY_NONISO_EP_STATUS query of CSL_UsbfGetHwStatus API
*
* @{ */
    /** Status of selected endpoint : halted or not */
#define CSL_USBF_NONISO_EP_STATUS_EP_HALTED         (CSL_USBF_STAT_FLG_EP_HALTED_MASK)
    /** STALL handshake returned to host */
#define CSL_USBF_NONISO_EP_STATUS_STALL_HANDSHAKE   (CSL_USBF_STAT_FLG_STALL_MASK)
    /** NAK handshake returned to host */
#define CSL_USBF_NONISO_EP_STATUS_NAK_HANDSHAKE     (CSL_USBF_STAT_FLG_NAK_MASK)
    /** ACK handshake received from host */
#define CSL_USBF_NONISO_EP_STATUS_ACK_HANDSHAKE     (CSL_USBF_STAT_FLG_ACK_MASK)
    /** Endpoint FIFO status */
#define CSL_USBF_NONISO_EP_STATUS_EP_FIFO_ENABLED   (CSL_USBF_STAT_FLG_FIFO_EN_MASK)
    /** The non-ISO FIFO empty status */
#define CSL_USBF_NONISO_EP_STATUS_FIFO_EMPTY        (CSL_USBF_STAT_FLG_NON_ISO_FIFO_EMPTY_MASK)
    /** The non-ISO FIFO full status */
#define CSL_USBF_NONISO_EP_STATUS_FIFO_FULL         (CSL_USBF_STAT_FLG_NON_ISO_FIFO_FULL_MASK)
/** 
@} */

/** @defgroup CSL_USBF_DEVICE_STATUS_<SYMBOL> Symbols representing device status 
*   @ingroup CSL_USBF_QUERY_DEVICE_STATUS query of CSL_UsbfGetHwStatus API
*
* @{ */
    /** HNP capable for B-device */
#define CSL_USBF_DEVICE_STATUS_HNP_ENABLE_B             (CSL_USBF_DEVSTAT_B_HNP_ENABLE_MASK)
    /** B-device connection to HNP capable A-device */
#define CSL_USBF_DEVICE_STATUS_HNP_SUPPORT_A            (CSL_USBF_DEVSTAT_A_HNP_SUPPORT_MASK)
    /** B-device connection to not HNP capable A-device */
#define CSL_USBF_DEVICE_STATUS_ALT_HNP_SUPPORT_A        (CSL_USBF_DEVSTAT_A_ALT_HNP_SUPPORT_MASK)
    /** Whether remote wakeup is granted */
#define CSL_USBF_DEVICE_STATUS_REMOTE_WAKEUP_GRANTED    (CSL_USBF_DEVSTAT_R_WK_OK_MASK)
    /** Device is being reset by USB host */
#define CSL_USBF_DEVICE_STATUS_DEVICE_RESETTING         (CSL_USBF_DEVSTAT_USB_RESET_MASK)
    /** Device in suspended state */
#define CSL_USBF_DEVICE_STATUS_SUSPENDED                (CSL_USBF_DEVSTAT_SUS_MASK)
    /** Device in configured state */
#define CSL_USBF_DEVICE_STATUS_CONFIGURED               (CSL_USBF_DEVSTAT_CFG_MASK)
    /** Device in addressed state */
#define CSL_USBF_DEVICE_STATUS_ADDRESSED                (CSL_USBF_DEVSTAT_ADD_MASK)
    /** Device in default state */
#define CSL_USBF_DEVICE_STATUS_DEFAULT                  (CSL_USBF_DEVSTAT_DEF_MASK)
    /** Device in attached state */
#define CSL_USBF_DEVICE_STATUS_ATTACHED                 (CSL_USBF_DEVSTAT_ATT_MASK)
/** 
@} */

/** @defgroup CSL_USBF_FRAME_TIMER_STATUS_<SYMBOL> Symbols representing USB device frame timer status
*   @ingroup CSL_USBF_QUERY_FRAME_TIMER_STATUS query of CSL_UsbfGetHwStatus API
*
* @{ */
    /** Frame timer lock status */
#define CSL_USBF_FRAME_TIMER_STATUS_FT_LOCKED           (CSL_USBF_SOF_FT_LOCK_MASK)
    /** Time stamp validity */
#define CSL_USBF_FRAME_TIMER_STATUS_TIME_STAMP_VALID    (CSL_USBF_SOF_TS_OK_MASK)
    /** Timestamp number */
#define CSL_USBF_FRAME_TIMER_STATUS_TIME_STAMP          (CSL_USBF_SOF_TS_MASK)
/** 
@} */

/** @brief Structure representing non-ISO endpoint status */ 
typedef struct CSL_UsbfNonIsoEpIntStatus {
    /** Receive endpoint __irq source
                                0 - None
                                1 - 15 : EP1 - EP15 */                                
    CSL_UsbfEpNum  rxEpIntSource ;     
    /** Transmit endpoint __irq source
                                0 - None
                                1 - 15 : EP1 - EP15 */
    CSL_UsbfEpNum  txEpIntSource ;     
} CSL_UsbfNonIsoEpIntStatus;

/** @brief Structure representing non-ISO DMA status */ 
typedef struct CSL_UsbfNonIsoDmaIntStatus {
    /** An EOT DMA __irq is pending or odd number of bytes was received during last transaction */
    Bool    eotDmaIntPending ;  
    /** Receive DMA __irq source
                                0 - None
                                1 - 15 : EP1 - EP15 */
    CSL_UsbfEpNum  rxdmaIntSource ;    
    /** Transmit DMA __irq source
                                0 - None
                                1 - 15 : EP1 - EP15 */
    CSL_UsbfEpNum  txdmaIntSource ;     
} CSL_UsbfNonIsoDmaIntStatus;

/*****************************************************************************/

/*****************************************************************************/
/** @brief Enumerations for USBF operations		 */
typedef enum CSL_UsbfHwControlCmd {
    /** Start the DMA transfer  (argument type: CSL_UsbfDMANum *) */
    CSL_USBF_CMD_START_DMA_TRANSFER         =	  0,
    
    /** Initiate remote wakeup (argument type: NULL) */
    CSL_USBF_CMD_INIT_REMOTE_WAKEUP         =     1,
      
    /** Stall current USB command (argument type: NULL) */
    CSL_USBF_CMD_STALL_USB_CMD              =     2,
     
    /** Inform command decode that itiate remote wakeup (argument type: NULL) */
    CSL_USBF_CMD_INFORM_DEVICE_CFG_DONE     =     3,
     
    /** Inform command decode that itiate remote wakeup (argument type: NULL) */
    CSL_USBF_CMD_INFORM_DEVICE_CFG_CLEARED  =     4,  
    
    /** Clear halt condition (argument type: NULL) */
    CSL_USBF_CMD_CLEAR_HALT                 =     5,  
    
    /** Halt endpoint (argument type: NULL) */
    CSL_USBF_CMD_HALT_EP                    =     6,  
    
    /** Clear endpoint FIFO pointers and flags (argument type: NULL) */
    CSL_USBF_CMD_CLEAR_EP                   =     7,  
    
    /** Reset endpoint (argument type: NULL) */
    CSL_USBF_CMD_RESET_EP                   =     8,  
    
    /** Enable FIFO (argument type: NULL) */
    CSL_USBF_CMD_ENABLE_FIFO                =     9,  
    
    /** Connect device to USB bus (argument type: NULL) */
    CSL_USBF_CMD_CONNECT_DEVICE             =    10,  
    
    /** Disconnect device from USB bus to prevent USB traffic when the 
        device is not ready. (argument type: NULL) */
    CSL_USBF_CMD_DISCONNECT_DEVICE          =    11,  
    
    /** Clear __irq source (argument type: Uint16 * ; The value passed 
        is ORed combination of CSL_USBF_IRQ_SRC_<SYMBOL> symbols) */
    CSL_USBF_CMD_CLEAR_INTERRUPT			= 	 12,
    
    /** Enable __irq (argument type: Uint16 * ; The value passed 
        is ORed combination of CSL_USBF_IE_<SYMBOL> symbols) */
    CSL_USBF_CMD_ENABLE_INTERRUPT			= 	 13,
    
    /** Disable __irq (argument type: Uint16 * ; The value passed 
        is ORed combination of CSL_USBF_IE_<SYMBOL> symbols) */
    CSL_USBF_CMD_DISABLE_INTERRUPT			= 	 14,
    
    /** Write from application buffer to endpoint FIFO (argument type: Uint8 *, pointer to application buffer) */
    CSL_USBF_CMD_WRITE_FIFO                 =    15,
    
    /** Read from endpoint FIFO into application buffer (argument type: Uint8 *, pointer to application buffer) */
    CSL_USBF_CMD_READ_FIFO                  =    16,
    
    /** Enable DMA __irq (argument type: Uint16 * ; The value passed 
        is ORed combination of CSL_USBF_DMA_IE_<SYMBOL> symbols) */
    CSL_USBF_CMD_ENABLE_DMA_INTERRUPT		= 	 17,
    
    /** Disable DMA __irq (argument type: Uint16 * ; The value passed 
        is ORed combination of CSL_USBF_DMA_IE_<SYMBOL> symbols) */
    CSL_USBF_CMD_DISABLE_DMA_INTERRUPT		= 	 18,
    
    /** Select an endpoint (argument type: CSL_UsbfEpNum *) */ 
    CSL_USBF_CMD_SELECT_EP                  =    19,
    
    /** Deselect an endpoint (argument type: NULL) */
    CSL_USBF_CMD_DESELECT_EP                =    20,
    
    /** Read setup data (argument type: CSL_UsbfSetupPacket *) */
    CSL_USBF_CMD_READ_SETUP                 =    21
} CSL_UsbfHwControlCmd;

/** brief Enumerations for USB device revisions */
typedef enum CSL_UsbfRev {
    /** Revision 0.1 */
    CSL_USBF_REV_01 = 1,
    /** Revision 0.2 */
    CSL_USBF_REV_02,
    /** Revision 2.1 */
    CSL_USBF_REV_21
} CSL_UsbfRev ; 
    
/** @brief Enumerations for h/w status query */
typedef enum CSL_UsbfHwStatusQuery {
    /** Get USB device status. (response type: CSL_UsbfStatus *) */
    CSL_USBF_QUERY_STATUS           =	0,  
    /** Get revision of device controller (response type: CSL_UsbfRev * ) */
    CSL_USBF_QUERY_DEVICE_REVISION  =   1,
    /** Get the receive FIFO count (response type: Uint16 *) */
    CSL_USBF_QUERY_RX_FIFO_COUNT    =   2,
    /** Get the ISO endpoint status (response type: BitMask16 *;  AND with 
    CSL_USBF_ISO_EP_STATUS_<SYMBOL> to get specific ISO endpoint status) */
    CSL_USBF_QUERY_ISO_EP_STATUS    =   3,
    /** Get non-ISO endpoint status (response type: BitMask16 *;  AND with 
    CSL_USBF_NONISO_EP_STATUS_<SYMBOL> to get specific non-ISO endpoint status) */
    CSL_USBF_QUERY_NONISO_EP_STATUS =   4,
    /** Get the device status (response type: BitMask16 *;  AND with 
    CSL_USBF_DEVICE_STATUS_<SYMBOL> to get particular device status ) */
    CSL_USBF_QUERY_DEVICE_STATUS    =   5, 
    /** Get the frame timer status (response type: BitMask16 *;  AND with 
    CSL_USBF_FRAME_TIMER_STATUS_<SYMBOL> to get frame timer status ) */
    CSL_USBF_QUERY_FRAME_TIMER_STATUS   =   6,
    /** Get the non-ISO endpoint status (response type: CSL_UsbfNonIsoEpIntStatus *) */
    CSL_USBF_QUERY_FRAME_NONISO_EP_INT_STATUS   =   7,
    /** Get the non-ISO DMA status (response type: CSL_UsbfNonIsoDmaIntStatus *) */
    CSL_USBF_QUERY_FRAME_NONISO_DMA_INT_STATUS  =   8,
    /** Get the __irq source (response type: BitMask16 *;  AND with 
    CSL_USBF_IRQ_SRC_<SYMBOL> to get particular __irq source) */
    CSL_USBF_QUERY_IRQ_SRC  =   9
} CSL_UsbfHwStatusQuery;

/*****************************************************************************/

/*****************************************************************************/

/** @brief This object contains the reference to the instance of USBF opened
 *  using the @a CSL_usbfOpen().
 *
 *  The pointer to this, is passed to all USBF CSL APIs.
 */
typedef struct CSL_UsbfObj {
	/** This is a pointer to the registers of the instance of USBF
     *  referred to by this object
     */
	CSL_UsbfRegsOvly regs;
	/** This is the instance of USBF being referred to by this object  */
	CSL_InstNum  	perNum;
} CSL_UsbfObj;

typedef struct CSL_UsbfObj *CSL_UsbfHandle;

/** @brief This will have the base-address information for the peripheral
 *  instance
 */
typedef struct {
	/** Base-address of the Configuration registers of the peripheral
	 */
	CSL_UsbfRegsOvly	regs;
} CSL_UsbfBaseAddress;


/** @brief Module specific parameters. Present implementation doesn't have
 *  any module specific parameters.
 */
typedef struct{
	/** Bit mask to be used for module specific parameters.
         *  The below declaration is just a place-holder for future
 	 *  implementation.
	 */
	CSL_BitMask16   flags;
} CSL_UsbfParam;

/** @brief Module specific context information. Present implementation doesn't have
 *  any Context information.
 */

typedef struct {
	/** Context information of USBF.
         *  The below declaration is just a place-holder for future
 	 *  implementation.
 	 */
    Uint16	contextInfo;
} CSL_UsbfContext;

/**************************************************************************\
* USBF global function declarations
\**************************************************************************/
/** @brief  Initializes the module
 *
 * CSL_usbfInit(..) initializes the USBF module. 
 * This function is idempotent -- calling it several times would
 * have the same effect as calling it the first time.
 * This function initializes the CSL data structures, and doesn't
 * touches the hardware.
 *
 * <b> Usage Constraints: </b>
 * This function should be called before using any of the CSL APIs
 * in the USBF module.
 *
 * Note: As USBF doesn't have any context based information, the function 
 * just returns CSL_SOK. User is expected to pass NULL.
 *
 * @b Example:
 * @verbatim
   ...
   if (CSL_SOK != CSL_usbfInit(NULL)) {
       return;
   }
   @endverbatim
 *
 *  @return Returns the status of the operation
 *
 */
CSL_Status

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?