/* * Copyright (c) 2015, Freescale Semiconductor, Inc. * Copyright 2016-2017 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef _FSL_LPSPI_EDMA_H_ #define _FSL_LPSPI_EDMA_H_ #include "fsl_lpspi.h" #include "fsl_edma.h" /*! * @addtogroup lpspi_edma_driver * @{ */ /*********************************************************************************************************************** * Definitions **********************************************************************************************************************/ /*! @name Driver version */ /*@{*/ /*! @brief LPSPI EDMA driver version 2.0.2. */ #define FSL_LPSPI_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 0, 2)) /*@}*/ /*! * @brief Forward declaration of the _lpspi_master_edma_handle typedefs. */ typedef struct _lpspi_master_edma_handle lpspi_master_edma_handle_t; /*! * @brief Forward declaration of the _lpspi_slave_edma_handle typedefs. */ typedef struct _lpspi_slave_edma_handle lpspi_slave_edma_handle_t; /*! * @brief Completion callback function pointer type. * * @param base LPSPI peripheral base address. * @param handle Pointer to the handle for the LPSPI master. * @param status Success or error code describing whether the transfer completed. * @param userData Arbitrary pointer-dataSized value passed from the application. */ typedef void (*lpspi_master_edma_transfer_callback_t)(LPSPI_Type *base, lpspi_master_edma_handle_t *handle, status_t status, void *userData); /*! * @brief Completion callback function pointer type. * * @param base LPSPI peripheral base address. * @param handle Pointer to the handle for the LPSPI slave. * @param status Success or error code describing whether the transfer completed. * @param userData Arbitrary pointer-dataSized value passed from the application. */ typedef void (*lpspi_slave_edma_transfer_callback_t)(LPSPI_Type *base, lpspi_slave_edma_handle_t *handle, status_t status, void *userData); /*! @brief LPSPI master eDMA transfer handle structure used for transactional API. */ struct _lpspi_master_edma_handle { volatile bool isPcsContinuous; /*!< Is PCS continuous in transfer. */ volatile bool isByteSwap; /*!< A flag that whether should byte swap. */ volatile uint8_t fifoSize; /*!< FIFO dataSize. */ volatile uint8_t rxWatermark; /*!< Rx watermark. */ volatile uint8_t bytesEachWrite; /*!< Bytes for each write TDR. */ volatile uint8_t bytesEachRead; /*!< Bytes for each read RDR. */ volatile uint8_t bytesLastRead; /*!< Bytes for last read RDR. */ volatile uint8_t isThereExtraRxBytes; /*!< Is there extra RX byte. */ uint8_t *volatile txData; /*!< Send buffer. */ uint8_t *volatile rxData; /*!< Receive buffer. */ volatile size_t txRemainingByteCount; /*!< Number of bytes remaining to send.*/ volatile size_t rxRemainingByteCount; /*!< Number of bytes remaining to receive.*/ volatile uint32_t writeRegRemainingTimes; /*!< Write TDR register remaining times. */ volatile uint32_t readRegRemainingTimes; /*!< Read RDR register remaining times. */ uint32_t totalByteCount; /*!< Number of transfer bytes*/ uint32_t txBuffIfNull; /*!< Used if there is not txData for DMA purpose.*/ uint32_t rxBuffIfNull; /*!< Used if there is not rxData for DMA purpose.*/ uint32_t transmitCommand; /*!< Used to write TCR for DMA purpose.*/ volatile uint8_t state; /*!< LPSPI transfer state , _lpspi_transfer_state.*/ uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */ lpspi_master_edma_transfer_callback_t callback; /*!< Completion callback. */ void *userData; /*!< Callback user data. */ edma_handle_t *edmaRxRegToRxDataHandle; /*!