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

📄 csl_spi.h

📁 dsp在音频处理中的运用
💻 H
📖 第 1 页 / 共 2 页
字号:
}
            
/** default setting for @ CSL_SpiFmt */
#define CSL_SPI_FMT_DEFAULTS {      \
    CSL_SPI_PHASE_IN,               \
    CSL_SPI_ENA_LVL_LOW,            \
    CSL_SPI_POLARITY_LOW            \
}

/** @brief Peripheral specific initialization function.
 *
 * This is the peripheral specific intialization function. This function is
 * idempotent in that calling it many times is same as calling it once.
 * 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 SPI
 * module.
 *
 *  Note: As SPI doesn't have any context based information, currently, the function
 *  just returns CSL_SOK. User is expected to pass NULL in the function call.
 *
 * @b Example:
 * @verbatim

   ...
   if (CSL_SOK != CSL_spiInit(NULL)) {
       return;
   }
   @endverbatim
 *
 * @return returns the status of the operation
 *
 */

CSL_Status CSL_spiInit(
    /** SPI specific context information
     */
    CSL_SpiContext * pContext
);

/** @brief Opens the instance of SPI requested.
 *
 *  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. The handle returned by this call is input as an
 *  essential argument for rest of the APIs described for this module.
 *
 *  <b> Usage Constraints: </b>
 *  SPI must be successfully initialized via @a CSL_spiInit() before calling
 *  this function. Memory for the @a CSL_spiObj must be allocated outside
 *  this call. This object must be retained while usage of this peripheral.
 *
 *  @b Example:
 *  @verbatim

      CSL_SpiObj        spiObj;
      CSL_Status        status;
        ...
      hSpi = CSL_spiOpen(&spiObj,
                          CSL_SPI,
                          NULL,
                          &status);
   @endverbatim
 *
 * @return returns a handle @a CSL_SpiHandle to the requested instance of
 * SPI if the call is successful, otherwise, a @a NULL is returned.
 *
 */
CSL_SpiHandle CSL_spiOpen (
    /** Pointer to the object that holds reference to the
     *  instance of SPI requested after the call
     */
    CSL_SpiObj*             pSpiObj,
    /** Instance of SPI to which a handle is requested
     */
    CSL_InstNum             spiNum,
    /** Module specific parameters;
     * Currently there are none; the user should pass 'NULL'
     */
    CSL_SpiParam            *pSpiParam,
    /** This returns the status (success/errors) of the call.
     * Could be 'NULL' if the user does not want status information.
     */
    CSL_Status              *pStatus
);

/**  The Close call releases the resource and appropriate shared pins.
 *
 * <b> Usage Constraints: </b>
 * Both @a CSL_spiInit() and @a CSL_spiOpen() must be called successfully
 * in that order before @a CSL_spiClose() can be called.
 *
 * @b Example:
 * @verbatim


   CSL_SpiHandle hSpi;
   ...
   CSL_spiClose(hSpi);
   @endverbatim
 *
 * @return returns the status of the operation (see @a CSL_Status)
 *
 */
CSL_Status  CSL_spiClose(
    /** Pointer to the object that holds reference to the
     *  instance of SPI requested after the call
     */
    CSL_SpiHandle                         hSpi
);

/*
 * ======================================================
 *   @func   csl_spiHwSetup
 *   @desc   Function to Setup SPI registers Initially
 *
 *   @arg  hSpi
 *              Device Handle;
 *   @arg  setup
 *              Pointer to Initialization structure
 *   @ret  CSL_Status
 *
 *          CSL_SOK : Successful completion of the operation
 *          CSL_ESYS_BADHANDLE: Device handle is invalid
 *          CSL_ESYS_INVPARAMS: HwSetup pointer is invalid
 *
 *   @eg
 *      CSL_SpiObj              spiObj;
 *      CSL_SpiHandle           hSpi;
 *      CSL_SpiHwSetup hwSetup  = CSL_SPI_HWSETUP_DEFAULTS;
 *      ...
 *      hwSetup.opMode          = CSL_SPI_OPMOD_MASTER;
 *      hwSetup.autoIdle        = CSL_SPI_AUTOIDLE_FREE_RUN;
 *      hwSetup.wakeupEnable    = CSL_SPI_WAKEUP_ENABLE;
 *      hwSetup.idleMode = CSL_SPI_SMRT_IDLE;
 *      hwSetup.prescale        = CSL_SPI_PRESCALE_2;
 *      hwSetup.spiFmt[0].clkPhase = CSL_SPI_PHASE_IN;
 *      hwSetup.spiFmt[0].enaLvl = CSL_SPI_ENA_LVL_LOW;
 *      hwSetup.spiFmt[0].polarity = CSL_SPI_POLARITY_LOW;
 *      ...
 *      status = CSL_spiHwSetup (hSpi, &spiHwSetup);
 *
 * ======================================================
*/
CSL_Status  CSL_spiHwSetup(
    CSL_SpiHandle                         hSpi,
    CSL_SpiHwSetup                        *setup
);

/*
 * ======================================================
 *   @func   csl_spiHwControl
 *   @desc
 *         Function controls the SPI peripheral specified by the Hanldle.
 *         Operation done is based on the "cmd".
 *
 *   @arg  hSpi
 *              Spi Handle Object
 *   @arg  cmd
 *              Command that specifies the operation to be performed
 *   @arg  arg
 *              Contains the pointer to the data passed to be function
 *   @ret  CSL_Status
 *
 *          CSL_SOK : Successful, desired operation is done
 *          CSL_ESYS_BADHANDLE: Device handle is invalid
 *          CSL_ESYS_INVCMD : Control Command is not supported
 *
 *   @eg
 *     CSL_Status status;
 *     CSL_SpiHandle hSpi;
 *     Uint16 spi_cmd = CSL_SPI_INT_RX_MASK | CSL_SPI_INT_TX_MASK;
 *
 *     CSL_spiInit();
 *     hSpi = CSL_spiOpen (&spiobj, CSL_SPI, NULL, &status );
 *     .
 *     .
 *     status = CSL_spiHwControl (hSpi, CSL_SPI_CMD_ENABLE_INT, &spi_cmd );
 *     This will Enable the interrupts for the Read and Write Cycle.
 *
 *
 * ======================================================
*/
CSL_Status  CSL_spiHwControl(
    CSL_SpiHandle                         hSpi,
    CSL_SpiHwControlCmd                   cmd,
    void                                  *arg
);

/*
 * ======================================================
 *   @func   csl_spiGetHwStatus
 *   @desc
 *         Function query's the H/W configuration of the Spi specified by the 
 *         Handle, command specifies the type of data required
 *
 *   @arg  hSpi
 *              Spi Handle Object
 *   @arg  myQuery
 *              Identifies the query to be performed
 *   @arg  response
 *              Variable that contain the result of the query
 *   @ret  CSL_Status
 *
 *          CSL_SOK : Successful Retreive, (* Ptr) will have the desired value
 *          CSL_ESYS_BADHANDLE: Device handle is invalid
 *          CSL_ESYS_INVQUERY : Query Command is not supported.
 *
 *   @eg
 *     CSL_Status status;
 *     CSL_SpiHandle hSpi;
 *     Uint16 eventStatus;
 *
 *     CSL_spiInit();
 *     hSpi = (CSL_SpiHandle) CSL_spiOpen (&spiobj, CSL_SPI, NULL, &status );
 *     .
 *     .
 *     status = CSL_spiGetHwStatus( hSpi, 
 *                                  CSL_SPI_QUERY_EVT_STATUS, 
 *                                  &eventStatus);
 *
 *
 * ======================================================
*/
CSL_Status  CSL_spiGetHwStatus(
    CSL_SpiHandle                         hSpi,
    CSL_SpiHwStatusQuery                  myQuery,
    void                                  *response
);

/*
 * ======================================================
 *   @func   CSL_spiGetHwSetup
 *   @desc   Function to retrive setup parameters of SPI registers 
 *
 *   @arg  hSpi
 *              Device Handle;
 *   @arg  setup
 *              Pointer to structure to hold the setup parameterts
 *   @ret  CSL_Status
 *
 *          CSL_SOK : Successful completion of the operation
 *          CSL_ESYS_BADHANDLE: Device handle is invalid
 *          CSL_ESYS_INVPARAMS: HwSetup pointer is invalid
 *
 *   @eg
 *      CSL_SpiObj              spiObj;
 *      CSL_SpiHandle           hSpi;
 *      CSL_SpiHwSetup          setup;
 *      ...
 *      status = CSL_spiGetHwSetup (hSpi, &setup);
 *
 * ======================================================
*/
CSL_Status  CSL_spiGetHwSetup(
    CSL_SpiHandle                         hSpi,
    CSL_SpiHwSetup                        *setup
);

/** @brief 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.
 *
 *  Note: 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. Please refer the documentation for
 *        more details.
 *
 * @b Example:
 * @verbatim

      CSL_Status status;
      CSL_SpiBaseAddress   baseAddress;

       ...
      status = CSL_spiGetBaseAddress(CSL_SPI_1, NULL, &baseAddress);
   @endverbatim
 *
 * @return Returns the status of the operation (see @a CSL_Status)
 *
 */
CSL_Status CSL_spiGetBaseAddress(
        /** Instance number
         */
        CSL_InstNum             spiNum,
        /** Module specific parameters
         */
        CSL_SpiParam *          pSpiParam,
        /** Base address details
         */
        CSL_SpiBaseAddress *    pBaseAddress
);

/** @brief Function to write 1, , 4 bytes on the peripheral instance.
 *
 *  This function is used for getting the writting (trasmitting) 1,2, 4
 *  bytes of data.
 *
 *  Note: This function will write 1, 2, 4 bytes of data
 *
 * @b Example:
 * @verbatim

      CSL_Status status;
      CSL_SpiXevArg xevArg;

       ...
      xevArg.data = &userdata;
      xevArg.nBytes = 4;
      
      status = CSL_mibspWrite(spiHande, &xevArg);
   @endverbatim
 *
 * @return Returns the status of the operation (see @a CSL_Status)
 *
 */
CSL_Status CSL_spiWrite(
    /** Handle of already opened peripheral
     */
    CSL_SpiHandle hSpi,
    /** Command arg for spi
     */
    CSL_SpiXevArg *cmdArg
    );

/** @brief Function to read 4 bytes on the peripheral instance.
 *
 *  This function is used for reading the recieve register
 *
 *  Note: This function will read 4 bytes of data
 *
 * @b Example:
 * @verbatim

      CSL_Status status;
      CSL_SpiXevArg xevArg;

       ...
      xevArg.data = &userdata;
      
      status = CSL_spiRead(spiHande, &xevArg);
   @endverbatim
 *
 * @return Returns the status of the operation (see @a CSL_Status)
 *
 */
CSL_Status CSL_spiRead(
    /** Handle of already opened peripheral
     */
    CSL_SpiHandle hSpi,
    /** Command arg for spi
     */
    CSL_SpiXevArg *cmdArg
    );

/*
 * =============================================================================
 *   @func CSL_spiHwSetupRaw
 *
 *   @desc
 *      This function configures the SPI using the register values passed 
 *      through the config-structure.  
 *
 *   @arg   hSpi
 *          Handle to the SPI instance
 *
 *   @arg   spiConfig
 *          Pointer to config structure which contains the information to 
 *          program HDQ1W to a useful state
 *
 *   @ret   CSL_Status
 *          CSL_SOK             - Configuration successful
 *          CSL_ESYS_BADHANDLE  - Invalid handle
 *          CSL_ESYS_INVPARAMS  - Invalid configuration parameters
 *
 *   @eg
 *          CSL_SpiConfig       spiConfig = CSL_SPI_CONFIG_DEFAULTS;
 *          CSL_status          status;
 *          ... 
 *          status = CSL_spiHwSetupRaw (hSpi, &spiConfig);
 *
 * =============================================================================
 */
extern CSL_Status  CSL_spiHwSetupRaw (
    CSL_SpiHandle         hSpi,
    CSL_SpiConfig         *spiConfig
);

#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

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