![]() |
|
|||
File indexing completed on 2025-05-11 08:22:59
0001 /* 0002 * Copyright (c) 2015, Freescale Semiconductor, Inc. 0003 * Copyright 2016-2020, 2022 NXP 0004 * All rights reserved. 0005 * 0006 * SPDX-License-Identifier: BSD-3-Clause 0007 */ 0008 #ifndef _FSL_FLEXIO_SPI_DMA_H_ 0009 #define _FSL_FLEXIO_SPI_DMA_H_ 0010 0011 #include "fsl_flexio_spi.h" 0012 #include "fsl_dma.h" 0013 0014 /*! 0015 * @addtogroup flexio_dma_spi 0016 * @{ 0017 */ 0018 0019 /******************************************************************************* 0020 * Definitions 0021 ******************************************************************************/ 0022 0023 /*! @name Driver version */ 0024 /*@{*/ 0025 /*! @brief FlexIO SPI DMA driver version 2.3.0. */ 0026 #define FSL_FLEXIO_SPI_DMA_DRIVER_VERSION (MAKE_VERSION(2, 3, 0)) 0027 /*@}*/ 0028 0029 /*! @brief typedef for flexio_spi_master_dma_handle_t in advance. */ 0030 typedef struct _flexio_spi_master_dma_handle flexio_spi_master_dma_handle_t; 0031 0032 /*! @brief Slave handle is the same with master handle. */ 0033 typedef flexio_spi_master_dma_handle_t flexio_spi_slave_dma_handle_t; 0034 0035 /*! @brief FlexIO SPI master callback for finished transmit */ 0036 typedef void (*flexio_spi_master_dma_transfer_callback_t)(FLEXIO_SPI_Type *base, 0037 flexio_spi_master_dma_handle_t *handle, 0038 status_t status, 0039 void *userData); 0040 0041 /*! @brief FlexIO SPI slave callback for finished transmit */ 0042 typedef void (*flexio_spi_slave_dma_transfer_callback_t)(FLEXIO_SPI_Type *base, 0043 flexio_spi_slave_dma_handle_t *handle, 0044 status_t status, 0045 void *userData); 0046 0047 /*! @brief FlexIO SPI DMA transfer handle, users should not touch the content of the handle.*/ 0048 struct _flexio_spi_master_dma_handle 0049 { 0050 size_t transferSize; /*!< Total bytes to be transferred. */ 0051 bool txInProgress; /*!< Send transfer in progress */ 0052 bool rxInProgress; /*!< Receive transfer in progress */ 0053 dma_handle_t *txHandle; /*!< DMA handler for SPI send */ 0054 dma_handle_t *rxHandle; /*!< DMA handler for SPI receive */ 0055 flexio_spi_master_dma_transfer_callback_t callback; /*!< Callback for SPI DMA transfer */ 0056 void *userData; /*!< User Data for SPI DMA callback */ 0057 }; 0058 0059 /******************************************************************************* 0060 * APIs 0061 ******************************************************************************/ 0062 #if defined(__cplusplus) 0063 extern "C" { 0064 #endif 0065 0066 /*! 0067 * @name DMA Transactional 0068 * @{ 0069 */ 0070 0071 /*! 0072 * @brief Initializes the FLEXO SPI master DMA handle. 0073 * 0074 * This function initializes the FLEXO SPI master DMA handle which can be used for other FLEXO SPI master transactional 0075 * APIs. 0076 * Usually, for a specified FLEXO SPI instance, call this API once to get the initialized handle. 0077 * 0078 * @param base Pointer to FLEXIO_SPI_Type structure. 0079 * @param handle Pointer to flexio_spi_master_dma_handle_t structure to store the transfer state. 0080 * @param callback SPI callback, NULL means no callback. 0081 * @param userData callback function parameter. 0082 * @param txHandle User requested DMA handle for FlexIO SPI RX DMA transfer. 0083 * @param rxHandle User requested DMA handle for FlexIO SPI TX DMA transfer. 0084 * @retval kStatus_Success Successfully create the handle. 0085 * @retval kStatus_OutOfRange The FlexIO SPI DMA type/handle table out of range. 0086 */ 0087 status_t FLEXIO_SPI_MasterTransferCreateHandleDMA(FLEXIO_SPI_Type *base, 0088 flexio_spi_master_dma_handle_t *handle, 0089 flexio_spi_master_dma_transfer_callback_t callback, 0090 void *userData, 0091 dma_handle_t *txHandle, 0092 dma_handle_t *rxHandle); 0093 0094 /*! 0095 * @brief Performs a non-blocking FlexIO SPI transfer using DMA. 0096 * 0097 * @note This interface returned immediately after transfer initiates. Call 0098 * FLEXIO_SPI_MasterGetTransferCountDMA to poll the transfer status to check 0099 * whether the FlexIO SPI transfer is finished. 0100 * 0101 * @param base Pointer to FLEXIO_SPI_Type structure. 0102 * @param handle Pointer to flexio_spi_master_dma_handle_t structure to store the transfer state. 0103 * @param xfer Pointer to FlexIO SPI transfer structure. 0104 * @retval kStatus_Success Successfully start a transfer. 0105 * @retval kStatus_InvalidArgument Input argument is invalid. 0106 * @retval kStatus_FLEXIO_SPI_Busy FlexIO SPI is not idle, is running another transfer. 0107 */ 0108 status_t FLEXIO_SPI_MasterTransferDMA(FLEXIO_SPI_Type *base, 0109 flexio_spi_master_dma_handle_t *handle, 0110 flexio_spi_transfer_t *xfer); 0111 0112 /*! 0113 * @brief Aborts a FlexIO SPI transfer using DMA. 0114 * 0115 * @param base Pointer to FLEXIO_SPI_Type structure. 0116 * @param handle FlexIO SPI DMA handle pointer. 0117 */ 0118 void FLEXIO_SPI_MasterTransferAbortDMA(FLEXIO_SPI_Type *base, flexio_spi_master_dma_handle_t *handle); 0119 0120 /*! 0121 * @brief Gets the remaining bytes for FlexIO SPI DMA transfer. 0122 * 0123 * @param base Pointer to FLEXIO_SPI_Type structure. 0124 * @param handle FlexIO SPI DMA handle pointer. 0125 * @param count Number of bytes transferred so far by the non-blocking transaction. 0126 */ 0127 status_t FLEXIO_SPI_MasterTransferGetCountDMA(FLEXIO_SPI_Type *base, 0128 flexio_spi_master_dma_handle_t *handle, 0129 size_t *count); 0130 0131 /*! 0132 * @brief Initializes the FlexIO SPI slave DMA handle. 0133 * 0134 * This function initializes the FlexIO SPI slave DMA handle. 0135 * 0136 * @param base Pointer to FLEXIO_SPI_Type structure. 0137 * @param handle Pointer to flexio_spi_slave_dma_handle_t structure to store the transfer state. 0138 * @param callback SPI callback, NULL means no callback. 0139 * @param userData callback function parameter. 0140 * @param txHandle User requested DMA handle for FlexIO SPI TX DMA transfer. 0141 * @param rxHandle User requested DMA handle for FlexIO SPI RX DMA transfer. 0142 */ 0143 static inline void FLEXIO_SPI_SlaveTransferCreateHandleDMA(FLEXIO_SPI_Type *base, 0144 flexio_spi_slave_dma_handle_t *handle, 0145 flexio_spi_slave_dma_transfer_callback_t callback, 0146 void *userData, 0147 dma_handle_t *txHandle, 0148 dma_handle_t *rxHandle) 0149 { 0150 (void)FLEXIO_SPI_MasterTransferCreateHandleDMA(base, handle, callback, userData, txHandle, rxHandle); 0151 } 0152 0153 /*! 0154 * @brief Performs a non-blocking FlexIO SPI transfer using DMA. 0155 * 0156 * @note This interface returns immediately after transfer initiates. Call 0157 * FLEXIO_SPI_SlaveGetTransferCountDMA to poll the transfer status and 0158 * check whether the FlexIO SPI transfer is finished. 0159 * 0160 * @param base Pointer to FLEXIO_SPI_Type structure. 0161 * @param handle Pointer to flexio_spi_slave_dma_handle_t structure to store the transfer state. 0162 * @param xfer Pointer to FlexIO SPI transfer structure. 0163 * @retval kStatus_Success Successfully start a transfer. 0164 * @retval kStatus_InvalidArgument Input argument is invalid. 0165 * @retval kStatus_FLEXIO_SPI_Busy FlexIO SPI is not idle, is running another transfer. 0166 */ 0167 status_t FLEXIO_SPI_SlaveTransferDMA(FLEXIO_SPI_Type *base, 0168 flexio_spi_slave_dma_handle_t *handle, 0169 flexio_spi_transfer_t *xfer); 0170 0171 /*! 0172 * @brief Aborts a FlexIO SPI transfer using DMA. 0173 * 0174 * @param base Pointer to FLEXIO_SPI_Type structure. 0175 * @param handle Pointer to flexio_spi_slave_dma_handle_t structure to store the transfer state. 0176 */ 0177 static inline void FLEXIO_SPI_SlaveTransferAbortDMA(FLEXIO_SPI_Type *base, flexio_spi_slave_dma_handle_t *handle) 0178 { 0179 FLEXIO_SPI_MasterTransferAbortDMA(base, handle); 0180 } 0181 0182 /*! 0183 * @brief Gets the remaining bytes to be transferred for FlexIO SPI DMA. 0184 * 0185 * @param base Pointer to FLEXIO_SPI_Type structure. 0186 * @param handle FlexIO SPI DMA handle pointer. 0187 * @param count Number of bytes transferred so far by the non-blocking transaction. 0188 */ 0189 static inline status_t FLEXIO_SPI_SlaveTransferGetCountDMA(FLEXIO_SPI_Type *base, 0190 flexio_spi_slave_dma_handle_t *handle, 0191 size_t *count) 0192 { 0193 return FLEXIO_SPI_MasterTransferGetCountDMA(base, handle, count); 0194 } 0195 0196 /*! @} */ 0197 0198 #if defined(__cplusplus) 0199 } 0200 #endif 0201 0202 /*! 0203 * @} 0204 */ 0205 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |