⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csl_spi.h

📁 基于ti tms320c672x下音频开发例子程式
💻 H
📖 第 1 页 / 共 3 页
字号:
    /** data 1/2 cycle before clock */
    CSL_SPI_PHASE_OUT  =  CSL_SPI_SPIFMT_PHASE_OUT
} CSL_SpiClkPhase;


/** @brief enumeration to control direction of the word during transfer */
typedef enum {
    /** transfer MSB first */
    CSL_SPI_SHDIR_MSBFIRST  =  CSL_SPI_SPIFMT_SHIFTDIR_MSBFIRST,
    /** transfer LSB first */
    CSL_SPI_SHDIR_LSBFIRST  =  CSL_SPI_SPIFMT_SHIFTDIR_LSBFIRST
} CSL_SpiShDir;


/** @brief enumeration to control the protocol of Spi */
typedef enum {
    /** use the multi-buffer mode */
    CSL_SPI_PROTOCOL_MULTIBUFFER  =  CSL_SPI_MIBSPIE_MIBSPIENA_YES,
    /** use the compatibility mode */
    CSL_SPI_PROTOCOL_COMPATIBLE   =  CSL_SPI_MIBSPIE_MIBSPIENA_NO
} CSL_SpiProtocol;


/** @brief enumeration tocontrol the operating mode of Spi */
typedef enum {
    /** operate as master */
    CSL_SPI_OPMOD_MASTER  =  ((CSL_SPI_SPIGCR1_CLKMOD_INTERNAL << 1) |
                                 CSL_SPI_SPIGCR1_MASTER_YES),
    /** operate as slave */
    CSL_SPI_OPMOD_SLAVE   =  ((CSL_SPI_SPIGCR1_CLKMOD_EXTERNAL << 1) |
                                 CSL_SPI_SPIGCR1_MASTER_NO)
} CSL_SpiOpMod;


/** @brief enumeration to control the SPIENA status whe inactive */
typedef enum {
    /** force SPIENA signal high-z when inactive */
    CSL_SPI_ENAHIZ_YES  =  CSL_SPI_SPIINT0_ENABLEHIGHZ_ENABLE,
    /** keep SPIENA signal a value when inactive */
    CSL_SPI_ENAHIZ_NO   =  CSL_SPI_SPIINT0_ENABLEHIGHZ_DISABLE
} CSL_SpiEnaHiZ;


typedef enum {
    /* operate on functionality register */
    CSL_SPI_GPIOTYPE_FUNC      =  0,
    /* operate on direction register */
    CSL_SPI_GPIOTYPE_DIR       =  1,
    /* operate on pull control register */
    CSL_SPI_GPIOTYPE_PULLCTRL  =  2,
    /* operate on open drain register */
    CSL_SPI_GPIOTYPE_OPNDRAIN  =  3
} CSL_SpiGpioType;


/** @brief enumeration for Spi power modes */
typedef enum {
    /** Spi is in active state */
    CSL_SPI_PWRSTAT_ACTIVE  =  CSL_SPI_SPIGCR1_P0WERDOWN_ACTIVE,
    /** Spi is powered down */
    CSL_SPI_PWRSTAT_DOWN    =  CSL_SPI_SPIGCR1_P0WERDOWN_PWRDN
} CSL_SpiPwrStat;


/** @brief enumeartion for Spi serial communication pins */
typedef enum {
    /** SOMI pin */
    CSL_SPI_PINTYPE_SOMI  =  CSL_FMKT(SPI_SPIPC0_SOMIFUN, SPI),
    /** SIMO pin */
    CSL_SPI_PINTYPE_SIMO  =  CSL_FMKT(SPI_SPIPC0_SIMOFUN, SPI),
    /** CLK pin */
    CSL_SPI_PINTYPE_CLK   =  CSL_FMKT(SPI_SPIPC0_CLKFUN, SPI),
    /** ENA pin */
    CSL_SPI_PINTYPE_ENA   =  CSL_FMKT(SPI_SPIPC0_ENABLEFUN, SPI),
    /** SCS7 pin */
    CSL_SPI_PINTYPE_SCS7  =  CSL_FMKT(SPI_SPIPC0_SCSFUN7, SPI),
    /** SCS6 pin */
    CSL_SPI_PINTYPE_SCS6  =  CSL_FMKT(SPI_SPIPC0_SCSFUN6, SPI),
    /** SCS5 pin */
    CSL_SPI_PINTYPE_SCS5  =  CSL_FMKT(SPI_SPIPC0_SCSFUN5, SPI),
    /** SCS4 pin */
    CSL_SPI_PINTYPE_SCS4  =  CSL_FMKT(SPI_SPIPC0_SCSFUN4, SPI),
    /** SCS3 pin */
    CSL_SPI_PINTYPE_SCS3  =  CSL_FMKT(SPI_SPIPC0_SCSFUN3, SPI),
    /** SCS2 pin */
    CSL_SPI_PINTYPE_SCS2  =  CSL_FMKT(SPI_SPIPC0_SCSFUN2, SPI),
    /** SCS1 pin */
    CSL_SPI_PINTYPE_SCS1  =  CSL_FMKT(SPI_SPIPC0_SCSFUN1, SPI),
    /** SCS0 pin */
    CSL_SPI_PINTYPE_SCS0  =  CSL_FMKT(SPI_SPIPC0_SCSFUN0, SPI)
} CSL_SpiPinType;


/** @brief enumeration to control DMA enabling in compatibility mode */
typedef enum {
    /** enable dma servicing in compatibility mode */
    CSL_SPI_CPTDMA_ENABLE   =  CSL_SPI_SPIINT0_DMAREQEN_ENABLE,
    /** disable dma servicing in compatibility mode */
    CSL_SPI_CPTDMA_DISABLE  =  CSL_SPI_SPIINT0_DMAREQEN_DISABLE
} CSL_SpiCptDma;


/** @brief enumeration to control reset of transfer mechnism of Spi */
typedef enum {
    /** enable spi to begin transfers */
    CSL_SPI_XFEREN_DISABLE  =  CSL_SPI_SPIGCR1_SPIEN_INRESET,
    /** hold spi transfer mechanism in reset */
    CSL_SPI_XFEREN_ENABLE   =  CSL_SPI_SPIGCR1_SPIEN_ACTIVE
} CSL_SpiXferEn;


/** @brief this object contains the reference to the instance of SPI
 * opened using the @a CSL_spiOpen()
 *
 * An object related to this structure is passed to all SPI CSL APIs
 * as the first argument */
typedef struct CSL_SpiObj {
    /** This is a pointer to the registers of the instance of SPI referred
      * to by this object */
    CSL_SpiRegsOvly  regs;
    /** This is the instance of SPI being referred to by this object */
    CSL_InstNum       perNum;
} CSL_SpiObj;


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

/** @brief SPI specific parameters. Present implementation doesn't have
 *  any 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_SpiParam;

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

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


typedef struct  {
    volatile Uint32 SPIGCR0;
    volatile Uint32 SPIGCR1;
    volatile Uint32 SPIINT0;
    volatile Uint32 SPILVL;
    volatile Uint32 SPIFLG;
    volatile Uint32 SPIPC0;
    volatile Uint32 SPIPC1;
    volatile Uint32 SPIPC2;
    volatile Uint32 SPIPC3;
    volatile Uint32 SPIPC4;
    volatile Uint32 SPIPC5;
    volatile Uint32 SPIPC6;
    volatile Uint32 SPIPC7;
    volatile Uint32 SPIPC8;
    volatile Uint32 SPIDAT0;
    volatile Uint32 SPIDAT1;
    volatile Uint32 SPIBUF;
    volatile Uint32 SPIEMU;
    volatile Uint32 SPIDELAY;
    volatile Uint32 SPIDEF;
    volatile Uint32 SPIFMT[4];
    volatile Uint32 TGINTVEC[2];
    volatile Uint8 RSVD0[8];
    volatile Uint32 MIBSPIE;
} CSL_SpiConfig;

/** Default Values for Config structure */
#define CSL_SPI_CONFIG_DEFAULTS {    \
        CSL_SPI_SPIGCR0_RESETVAL     \
        CSL_SPI_SPIGCR1_RESETVAL     \
        CSL_SPI_SPIINT0_RESETVAL     \
        CSL_SPI_SPILVL_RESETVAL      \
        CSL_SPI_SPIFLG_RESETVAL      \
        CSL_SPI_SPIPC0_RESETVAL      \
        CSL_SPI_SPIPC1_RESETVAL      \
        CSL_SPI_SPIPC2_RESETVAL      \
        CSL_SPI_SPIPC3_RESETVAL      \
        CSL_SPI_SPIPC4_RESETVAL      \
        CSL_SPI_SPIPC5_RESETVAL      \
        CSL_SPI_SPIPC6_RESETVAL      \
        CSL_SPI_SPIPC7_RESETVAL      \
        CSL_SPI_SPIPC8_RESETVAL      \
        CSL_SPI_SPIDAT0_RESETVAL     \
        CSL_SPI_SPIDAT1_RESETVAL     \
        CSL_SPI_SPIBUF_RESETVAL      \
        CSL_SPI_SPIEMU_RESETVAL      \
        CSL_SPI_SPIDELAY_RESETVAL    \
        CSL_SPI_SPIDEF_RESETVAL      \
        CSL_SPI_SPIFMT_RESETVAL      \
        CSL_SPI_TGINTVEC_RESETVAL    \
        CSL_SPI_MIBSPIE_RESETVAL     \
}

/** @brief a pointer to @a CSL_SpiObj; this is passed to all SPI CSL
 * APIs */
typedef struct CSL_SpiObj *CSL_SpiHandle;


/** @brief sets up the properties if the pins of Spi
 *
 * This object is used to setup or get the setup of the pins in Spi */
typedef struct CSL_SpiHwSetupPins {
    /** decides if the pins will be Spi or GPIO */
    Uint16  func;
    /** if GPIO, decides the directions of the pins */
    Uint16  dir;
    /** if configured as GPIO output, decides if the pull control is to
     * be turned on */
    Uint16  pullCtrl;
    /** if configured as GPIO output, decides the pull control is pull up 
     * or pull down */
    Uint16  pullSel;
    /** if configured as GPIO output, decides if the pin should output
     * logic 1 or tristate */
    Uint16  opnDrain;
} CSL_SpiHwSetupPins;


/** @brief sets up the format selection for a set of transfers
 *
 * This object is used to setup or get the setup of the format selection
 * for a set of transfers */
typedef struct CSL_SpiHwSetupFmtCtrl {
    /** decides if chip select is to be held active between transfers */
    CSL_SpiCsHold    csHold;
    /** decides if delay specified in the selected format must be allowed
     * between 2 consecutive transfers */
    CSL_SpiWDelayEn  wDel;
    /** decides which format to select */
    CSL_SpiFmtSel    fmtSel;
    /** defines the chip select that will be activated for the transfer */
    Uint8               cSel;
} CSL_SpiHwSetupFmtCtrl;


/** @brief sets up the Spi for compatibility mode
 *
 * This structure is used to setup or get the setup of Spi in comaptibility
 * mode */
typedef struct CSL_SpiHwSetupCpt {
    /** selects if interrupts should go to lines INT0 or INT1 */
    Uint32                    *lvl;
    /** selects the format & associated controls */
    CSL_SpiHwSetupFmtCtrl  *fmtCtrlPtr;
} CSL_SpiHwSetupCpt;


/** @brief sets up the a formatting for an outgoing word
 *
 * This object is used to set up or get the setup of the format registers in
 * Spi */
typedef struct CSL_SpiHwSetupPriFmt {
    /** delay between 2 consecutive words */
    Uint8             wDelay;
    /** the factor with which to multiply functional clock in order to get the
     * serial clock */
    Uint8             preScale;
    /** the length of the word to be transmitted and/or received */
    Uint8             charLen;
    /** if in master mode; whether Spi should wait for ENA from slave */
    CSL_SpiWaitEn  waitEna;
    /** whether parity should be enabled; if enabled then even or odd */
    CSL_SpiParity  parity;
    /** whether clock should be high or low when inactive */
    CSL_SpiClkPolarity  polarity;
    /** whether data should be in phase of 1/2 cycle ahead of the clock */
    CSL_SpiClkPhase   phase;
    /** whether LSB or MSB should be shifted first */
    CSL_SpiShDir   shiftDir;
} CSL_SpiHwSetupPriFmt;


/** @brief sets up the parameters to be setup in priority mode
 *
 * This object is used to setup or get the setup of the parameters to be setup
 * in priority mode */
typedef struct CSL_SpiHwSetupPri {
    /** array of pointers to structures of formats of an outgoing word */
    CSL_SpiHwSetupPriFmt  *fmt[4];
} CSL_SpiHwSetupPri;


/** @brief sets up the parameters that are needed by multi-buffer as well as
 * compatibility modes
 *
 * This objetc is used to set up or get the setup of parameters that are needed
 * by multi-buffer as well as compatibility modes */
typedef struct CSL_SpiHwSetupGen {
    /** whether to use Spi in compatibility mode or multi-buffer mode */
    CSL_SpiProtocol   protocol;
    /** master or slave mode */
    CSL_SpiOpMod      opMode;
    /** whether ENA signal should be tristated when inactive or if it should
     * bear a value */
    CSL_SpiEnaHiZ     enaHiZ;
    /** the default value on Chip select when inactive */
    Uint8                csDefault;
    /** Chip-select-active-to-transmit-start-delay */
    Uint8                c2tDelay;
    /** Transmit-end-to-chip-select-inactive-delay */
    Uint8                t2cDelay;
    /** Transmit-data-finished-to-ENA-pin-inactive-time-out */
    Uint8                t2eTmout;
    /** Chip-select-active-to-ENA-signal-active-time-out */
    Uint8                c2eTmout;
} CSL_SpiHwSetupGen;


/** @brief main structure that is used to setup the SPI
 *
 * This structure is used to setup or obtain the existing setup of SPI
 * using @a CSL_spiHwSetup() & @a CSL_spiGetHwStatus() functions
 * respectively. If a particular member pointer is null, then these functions
 * do not setup or get the setup of the corresponding part of SPI
 * respectively */
typedef struct CSL_SpiHwSetup {
    /** This pointer to @a CSL_SpiHwSetupCommon is used to hold
     * information on the common part of the SPI setup */
    CSL_SpiHwSetupGen   *genPtr;
    /** This pointer to @a CSL_SpiHwSetupFifo is used to hold information
     * on the data FIFO part of the SPI setup */
    CSL_SpiHwSetupPri   *priPtr;
    /** This pointer to @a CSL_SpiHwSetupSdio is used to hold information
     * on the SDIO part of the SPI setup */
    CSL_SpiHwSetupCpt   *cptPtr;
    /** This pointer to @a CSL_SpiHwSetupSdio is used to hold information
     * on the SPI part of the SPI setup */
    CSL_SpiHwSetupPins  *pinsPtr;
} CSL_SpiHwSetup;

⌨️ 快捷键说明

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