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

📄 csl_spi.h

📁 基于ti tms320c672x下音频开发例子程式
💻 H
📖 第 1 页 / 共 3 页
字号:

/** @brief gets the information for interrupt vectors */
typedef struct CSL_SpiIntVec {
    /** interrupt vector number */
    Uint8  intVal;
    /** status of suspend */
    Bool   suspend;
} CSL_SpiIntVec;


/** @brief gets the status of buffer after a transfer */
typedef struct CSL_SpiBufStat {
    /** status as a bit-vector of the different events */
    Uint8  status;
    /** status of the chip select during last transfer */
    Uint8  cSel;
} CSL_SpiBufStat;


typedef struct CSL_SpiCptData {
    /** Place to hold the data */
    Uint16            data;
    /** Place to hold the status */
    CSL_SpiBufStat *bufStat;
} CSL_SpiCptData;


/** default setting for @a CSL_SpiHwSetup */
#define CSL_SPI_HWSETUP_DEFAULTS { \
    NULL,                             \
    NULL,                             \
    NULL,                             \
    NULL                              \
    }


/** default setting for @a CSL_SpiHwSetupGen */
#define CSL_SPI_HWSETUP_GEN_DEFAULTS { \
    CSL_SPI_PROTOCOL_COMPATIBLE,       \
    CSL_SPI_OPMOD_SLAVE,               \
    CSL_SPI_ENAHIZ_NO,                 \
    0,                                    \
    0,                                    \
    0,                                    \
    0,                                    \
    0                                     \
    }


/** default setting for @a CSL_SpiHwSetupPri */
#define CSL_SPI_HWSETUP_PRI_DEFAULTS { \
    {                                     \
        NULL,                             \
        NULL,                             \
        NULL,                             \
        NULL                              \
    }                                     \
    }


/** default setting for @a CSL_SpiHwSetupPriFmt */
#define CSL_SPI_HWSETUP_PRI_FMT_DEFAULTS { \
    0,                                        \
    0,                                        \
    0,                                        \
    CSL_SPI_WAITEN_NO,                     \
    CSL_SPI_PARITY_DISABLE,                \
    CSL_SPI_PHASE_IN,                      \
    CSL_SPI_SHDIR_LSBFIRST                 \
    }


/** default setting for @a CSL_SpiHwSetupCpt */
#define CSL_SPI_HWSETUP_CPT_DEFAULTS { \
    NULL,                                 \
    NULL                                  \
    }


/** default setting for @a CSL_SpiHwSetupFmtCtrl */
#define CSL_SPI_HWSETUP_FMTCTRL_DEFAULTS { \
    CSL_SPI_CSHOLD_NO,                     \
    CSL_SPI_WDELAYEN_NO,                   \
    CSL_SPI_FMTSEL_0,                      \
    0,                                        \
    }


/** default setting for @a CSL_SpiHwSetupPins */
#define CSL_SPI_HWSETUP_PINS_DEFAULTS { \
    NULL,                                  \
    NULL,                                  \
    NULL,                                  \
    NULL                                   \
    }

/** ===========================================================================
 *   @func CSL_spiOpen
 *
 *   @desc
 *        This function populates the peripheral data object for the instance
 *        and returns a handle to the instance.
 *        The open call sets up the data structures for the particular instance
 *        of SPI device. The device can be re-opened anytime after it has been
 *        normally closed if so required. SPI Hardware setup will be performed
 *        at the end of the open call only if the HwSetup Pointer supplied was
 *        non-NULL. The handle returned by this call is input as an essential
 *        argument for rest of the APIs described for this module.
 *
 *   @arg pSpiObj
 *        Pointer to the SPI instance object
 *
 *   @arg spiNum
 *        Instance of the SPI to be opened.
 *
 *   @arg pSpiParam
 *        Pointer to module specific parameters
 *
 *   @arg pStatus
 *        pointer for returning status of the function call
 *
 *   @ret CSL_SpiHandle
 *        Valid SPI instance handle will be returned if status value is
 *        equal to CSL_SOK.
 *
 *   @eg
 *        CSL_Status        status;
 *        CSL_SpiObj        spiObj;
 *        CSL_SpiHandle     hSpi;
 *
 *        hSpi = CSL_spiOpen (&spiObj,
 *                            CSL_SPI_PER_CNT,
 *                            NULL,
 *                            &status
 *                            );
 *
 * ===========================================================================
 */
/** @brief opens if possible the instance of SPI requested */
CSL_SpiHandle CSL_spiOpen(
    /** pointer to the object that holds reference to the instance of SPI
     * requested after the call */
    CSL_SpiObj                            *hSpiObj,
    /** instance of SPI to which a handle is requested */
    CSL_InstNum                           spiNum,
    /** specifies if SPI should be opened with excusive or share access to
     * the associate pins */
    CSL_SpiParam                          *pSpiParam,
    /** This returns the status (success/errors) of the call */
    CSL_Status                            *status
);

/** ===========================================================================
 *   @func CSL_spiClose
 *
 *   @b Description
 *   @n Unreserves the SPI identified by the handle.
 *
 *   @arg  hSpi
           Handle to the Spi instance
 *
 *   @ret CSL_Status
 *         CSL_SOK            - Close successful
 *         CSL_ESYS_BADHANDLE - Invalid handle
 *
 *   <b> Pre Condition </b>
 *   @n  Both @a CSL_spiInit() and @a CSL_spiOpen() must be called successfully
 *       in that order before @a CSL_spiClose() can be called.
 *
 *   <b> Post Condition </b>
 *   @n  None.
 *
 *   @b Example
 *   @verbatim
        CSL_SpiHandle       hSpi;
        ...
        status = CSL_spiClose (hSpi);
        ...
     @endverbatim
 * =============================================================================
 */
CSL_Status  CSL_spiClose(
    /** Pointer to the object that holds reference to the
     *  instance of SPI requested after the call
     */

    CSL_SpiHandle                         hSpi
);

/** @brief programs the SPI to a useful state as specified */
CSL_Status  CSL_spiHwSetup(
    /** pointer to the object that holds reference to the instance of SPI
     * requested after the call */
    CSL_SpiHandle                         hSpi,
    /** pointer to setup structure which contains the information to program
     * SPI to a useful state */
    CSL_SpiHwSetup                        *hwSetup
);

CSL_Status  CSL_spiGetHwSetup(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                         hSpi,
    /** the query to this API which indicates the status/setup
     * to be returned */
    CSL_SpiHwSetup                        *setup
);

/** @brief controls the different operations that can be performed by
 * SPI */
CSL_Status  CSL_spiHwControl(
    /** pointer to the object that holds reference to the instance of SPI
     * requested after the call */
    CSL_SpiHandle                         hSpi,
    /** the command to this API which indicates the action to be taken */
    CSL_SpiHwControlCmd                   cmd,
    /** an optional argument @a void* casted */
    void                                     *arg
);


/** ===========================================================================
 *   @func CSL_spiInit
 *
 *   @desc
 *        This function initializes the SPI CSL data structures.
 *
 *   @arg pContext
 *        Context information for SPI
 *
 *   @ret CSL_Status
 *        CSL_SOK - Always returns
 *
 *   @eg
 *     CSL_spiInit (NULL);
 * ============================================================================
 */
CSL_Status  CSL_spiInit(
    CSL_SpiContext * pContext
);


/** ===========================================================================
 *   @func CSL_spiHwSetupRaw
 *
 *   @desc
 *       This function configures the registers of SPI as per the values given
 *       in the Config structure.
 *
 *   @arg hSpi
 *        Handle to the SPI instance
 *
 *   @arg hwConfig
 *        Pointer to SPI config structure
 *
 *   @ret CSL_Status
 *         CSL_SOK             - Configuration successful
 *         CSL_ESYS_BADHANDLE  - Invalid handle
 *
 *   @eg
 *
 *        CSL_Status            status;
 *        CSL_SpiConfig     hwConfig;
 *
 *        status = CSL_spiHwsetupRaw (hSpi, &hwConfig);
 *
 * ===========================================================================
 */

extern CSL_Status  CSL_spiHwSetupRaw (
    CSL_SpiHandle           hSpi,
    CSL_SpiConfig *         config
);

/** @brief returns the status of different operations or the current setup of
 * SPI */
CSL_Status  CSL_spiGetHwStatus(
    /** pointer to the object that holds reference to the instance of SPI
     * requested after the call */
    CSL_SpiHandle                         hSpi,
    /** the query to this API which indicates the status/setup to be
     * returned */
    CSL_SpiHwStatusQuery                  query,
    /** placeholder to return the status; @a void* casted */
    void                                     *response
);

/** ===========================================================================
 *   @n@b CSL_spiGetBaseAddress
 *
 *   @b Description
 *   @n  Function to get the base address of the peripheral instance.
 *       This function is used for getting the base address of the peripheral
 *       instance. This function will be called inside the CSL_spiOpen()
 *       function call. This function is open for re-implementing if the user
 *       wants to modify the base address of the peripheral object to point to
 *       a different location and there by allow CSL initiated write/reads into
 *       peripheral MMR's go to an alternate location.
 *
 *   @b Arguments
 *   @verbatim
            spiNum          Specifies the instance of SPI to be opened.

            pSpiParam       Module specific parameters.

            pBaseAddress    Pointer to baseaddress structure containing base
                            address details.

     @endverbatim
 *
 *   <b> Return Value </b>  CSL_Status
 *   @li                    CSL_OK            Open call is successful
 *   @li                    CSL_ESYS_FAIL     The instance number is invalid.
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  Base Address structure is populated
 *
 *   @b Modifies
 *   @n    1. The status variable
 *
 *         2. Base address structure is modified.
 *
 *   @b Example
 *   @verbatim
        CSL_Status              status;
        CSL_SpiBaseAddress  baseAddress;

       ...
      status = CSL_spiGetBaseAddress(CSL_SPI_PER_CNT, NULL, &baseAddress);

    @endverbatim
 * ============================================================================
 */
extern CSL_Status   CSL_spiGetBaseAddress (
        CSL_InstNum            spiNum,
        CSL_SpiParam *         pSpiParam,
        CSL_SpiBaseAddress *   pBaseAddress
);

#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

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