1 /* 2 * Copyright 2019-2020 NXP 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef _FSL_DBI_FLEXIO_EDMA_H_ 9 #define _FSL_DBI_FLEXIO_EDMA_H_ 10 11 #include "fsl_dbi.h" 12 #include "fsl_flexio_mculcd.h" 13 #include "fsl_flexio_mculcd_edma.h" 14 15 /* 16 * Change log: 17 * 18 * 1.0.1 19 * - Fix MISRA-C 2012 issues. 20 * 21 * 1.0.0 22 * - Initial version 23 */ 24 25 /*! 26 * @addtogroup dbi_flexio_edma 27 * @{ 28 */ 29 30 /******************************************************************************* 31 * Definitions 32 ******************************************************************************/ 33 /*! @brief FLEXIO DBI interface (MCU LCD) transfer operation. */ 34 typedef struct _dbi_flexio_edma_xfer_handle 35 { 36 dbi_xfer_ops_t *xferOps; /*!< Transfer operations. */ 37 flexio_mculcd_edma_handle_t flexioHandle; /*!< FLEXIO DMA transfer handle. */ 38 dbi_mem_done_callback_t memDoneCallback; /*!< The callback function when video memory access done. */ 39 void *userData; /*!< Parameter of @ref memDoneCallback */ 40 } dbi_flexio_edma_xfer_handle_t; 41 42 /*! @brief FLEXIO DBI interface (MCU LCD) transfer operation. */ 43 extern const dbi_xfer_ops_t g_dbiFlexioEdmaXferOps; 44 45 /******************************************************************************* 46 * API 47 ******************************************************************************/ 48 #if defined(__cplusplus) 49 extern "C" { 50 #endif 51 52 /*! 53 * @brief Create FLEXIO DBI transfer handle. 54 * 55 * @param[out] dbiXferHandle Pointer the handle that will be created. 56 * @param[in] flexioLCD Pointer FLEXIO LCD structure. 57 * @param[in] txDmaHandle Pointer to the DMA TX transfer handle, if you don't 58 * want to use the function @ref DBI_FLEXIO_EDMA_WriteMemory, this could be NULL. 59 * When this is NULL, the blocking method will be used instead of DMA method. 60 * @param[in] txDmaHandle Pointer to the DMA RX transfer handle, if you don't 61 * want to use the function @ref DBI_FLEXIO_EDMA_ReadMemory, this could be NULL. 62 * When this is NULL, the blocking method will be used instead of DMA method. 63 * @return Return true if success, otherwise return error code. 64 */ 65 status_t DBI_FLEXIO_EDMA_CreateXferHandle(dbi_flexio_edma_xfer_handle_t *dbiXferHandle, 66 FLEXIO_MCULCD_Type *flexioLCD, 67 edma_handle_t *txDmaHandle, 68 edma_handle_t *rxDmaHandle); 69 70 /*! 71 * @brief Write command through DBI. 72 * 73 * @param[in] dbiXferHandle Pointer the handle that created by @ref DBI_FLEXIO_EDMA_CreateXferHandle. 74 * @param[in] command The command to send. 75 * @return Return true if success, otherwise return error code. 76 */ 77 status_t DBI_FLEXIO_EDMA_WriteCommand(void *dbiXferHandle, uint32_t command); 78 79 /*! 80 * @brief Write data through DBI. 81 * 82 * @param[in] dbiXferHandle Pointer the handle that created by @ref DBI_FLEXIO_EDMA_CreateXferHandle. 83 * @param[in] data The data to send. 84 * @param[in] len_byte The length of the data in bytes. 85 * @return Return true if success, otherwise return error code. 86 */ 87 status_t DBI_FLEXIO_EDMA_WriteData(void *dbiXferHandle, void *data, uint32_t len_byte); 88 89 /*! 90 * @brief Write data to the video memory through DBI. 91 * 92 * This function is faster than @ref DBI_FLEXIO_EDMA_WriteData because DMA is involved. 93 * 94 * @param[in] dbiXferHandle Pointer the handle that created by @ref DBI_FLEXIO_EDMA_CreateXferHandle. 95 * @param[in] command The command sent before writing data. 96 * @param[in] data The data to send. 97 * @param[in] len_byte The length of the data in bytes. 98 * @return Return true if success, otherwise return error code. 99 */ 100 status_t DBI_FLEXIO_EDMA_WriteMemory(void *dbiXferHandle, uint32_t command, const void *data, uint32_t len_byte); 101 102 /*! 103 * @brief Read data from the video memory through DBI. 104 * 105 * @param[in] dbiXferHandle Pointer the handle that created by @ref DBI_FLEXIO_EDMA_CreateXferHandle. 106 * @param[in] command The command sent before reading data. 107 * @param[out] data The buffer to receive the data. 108 * @param[in] len_byte The length of the data in bytes. 109 * @return Return true if success, otherwise return error code. 110 */ 111 status_t DBI_FLEXIO_EDMA_ReadMemory(void *dbiXferHandle, uint32_t command, void *data, uint32_t len_byte); 112 113 /*! 114 * @brief Register the callback function called when memory function done. 115 * 116 * The memory read and write functions are non-blocking function, when transaction 117 * finished, callback is called to inform higher layer. 118 * 119 * @param[in] dbiXferHandle Pointer the handle that created by @ref DBI_FLEXIO_EDMA_CreateXferHandle. 120 * @param[in] callback The callback when memory read or write finished. 121 * @param[in] userData Parameter of the callback. 122 */ 123 void DBI_FLEXIO_EDMA_SetMemoryDoneCallback(void *dbiXferHandle, dbi_mem_done_callback_t callback, void *userData); 124 125 #if defined(__cplusplus) 126 } 127 #endif 128 129 /*! @} */ 130 131 #endif /* _FSL_DBI_FLEXIO_EDMA_H_ */ 132