![]() |
|
|||
File indexing completed on 2025-05-11 08:22:59
0001 /* 0002 * Copyright (c) 2015, Freescale Semiconductor, Inc. 0003 * Copyright 2016-2022 NXP 0004 * All rights reserved. 0005 * 0006 * SPDX-License-Identifier: BSD-3-Clause 0007 */ 0008 #ifndef _FSL_FLEXCAN_EDMA_H_ 0009 #define _FSL_FLEXCAN_EDMA_H_ 0010 0011 #include "fsl_flexcan.h" 0012 #include "fsl_edma.h" 0013 0014 /*! 0015 * @addtogroup flexcan_edma_driver 0016 * @{ 0017 */ 0018 0019 /******************************************************************************* 0020 * Definitions 0021 ******************************************************************************/ 0022 0023 /*! @name Driver version */ 0024 /*@{*/ 0025 /*! @brief FlexCAN EDMA driver version. */ 0026 #define FSL_FLEXCAN_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 9, 2)) 0027 /*@}*/ 0028 0029 /* Forward declaration of the handle typedef. */ 0030 typedef struct _flexcan_edma_handle flexcan_edma_handle_t; 0031 0032 /*! @brief FlexCAN transfer callback function. */ 0033 typedef void (*flexcan_edma_transfer_callback_t)(CAN_Type *base, 0034 flexcan_edma_handle_t *handle, 0035 status_t status, 0036 void *userData); 0037 0038 /*! 0039 * @brief FlexCAN eDMA handle 0040 */ 0041 struct _flexcan_edma_handle 0042 { 0043 flexcan_edma_transfer_callback_t callback; /*!< Callback function. */ 0044 void *userData; /*!< FlexCAN callback function parameter.*/ 0045 edma_handle_t *rxFifoEdmaHandle; /*!< The EDMA handler for Rx FIFO. */ 0046 volatile uint8_t rxFifoState; /*!< Rx FIFO transfer state. */ 0047 size_t frameNum; /*!< The number of messages that need to be received. */ 0048 #if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) 0049 flexcan_fd_frame_t *framefd; /*!< Point to the buffer of CAN Message to be received from Enhanced Rx FIFO. */ 0050 #endif 0051 }; 0052 0053 /******************************************************************************* 0054 * API 0055 ******************************************************************************/ 0056 0057 #if defined(__cplusplus) 0058 extern "C" { 0059 #endif 0060 0061 /*! 0062 * @name eDMA transactional 0063 * @{ 0064 */ 0065 0066 /*! 0067 * @brief Initializes the FlexCAN handle, which is used in transactional functions. 0068 * 0069 * @param base FlexCAN peripheral base address. 0070 * @param handle Pointer to flexcan_edma_handle_t structure. 0071 * @param callback The callback function. 0072 * @param userData The parameter of the callback function. 0073 * @param rxFifoEdmaHandle User-requested DMA handle for Rx FIFO DMA transfer. 0074 */ 0075 void FLEXCAN_TransferCreateHandleEDMA(CAN_Type *base, 0076 flexcan_edma_handle_t *handle, 0077 flexcan_edma_transfer_callback_t callback, 0078 void *userData, 0079 edma_handle_t *rxFifoEdmaHandle); 0080 0081 /*! 0082 * @brief Prepares the eDMA transfer configuration for FLEXCAN Legacy RX FIFO. 0083 * 0084 * This function prepares the eDMA transfer configuration structure according to FLEXCAN Legacy RX FIFO. 0085 * 0086 * @param base FlexCAN peripheral base address. 0087 * @param pFifoXfer FlexCAN Rx FIFO EDMA transfer structure, see #flexcan_fifo_transfer_t. 0088 * @param pEdmaConfig The user configuration structure of type edma_transfer_t. 0089 * 0090 */ 0091 void FLEXCAN_PrepareTransfConfiguration(CAN_Type *base, 0092 flexcan_fifo_transfer_t *pFifoXfer, 0093 edma_transfer_config_t *pEdmaConfig); 0094 0095 /*! 0096 * @brief Start Transfer Data from the FLEXCAN Legacy Rx FIFO using eDMA. 0097 * 0098 * This function to Update edma transfer confiugration and Start eDMA transfer 0099 * 0100 * @param base FlexCAN peripheral base address. 0101 * @param handle Pointer to flexcan_edma_handle_t structure. 0102 * @param pEdmaConfig The user configuration structure of type edma_transfer_t. 0103 * @retval kStatus_Success if succeed, others failed. 0104 * @retval kStatus_FLEXCAN_RxFifoBusy Previous transfer ongoing. 0105 */ 0106 status_t FLEXCAN_StartTransferDatafromRxFIFO(CAN_Type *base, 0107 flexcan_edma_handle_t *handle, 0108 edma_transfer_config_t *pEdmaConfig); 0109 0110 /*! 0111 * @brief Receives the CAN Message from the Legacy Rx FIFO using eDMA. 0112 * 0113 * This function receives the CAN Message using eDMA. This is a non-blocking function, which returns 0114 * right away. After the CAN Message is received, the receive callback function is called. 0115 * 0116 * @param base FlexCAN peripheral base address. 0117 * @param handle Pointer to flexcan_edma_handle_t structure. 0118 * @param pFifoXfer FlexCAN Rx FIFO EDMA transfer structure, see #flexcan_fifo_transfer_t. 0119 * @retval kStatus_Success if succeed, others failed. 0120 * @retval kStatus_FLEXCAN_RxFifoBusy Previous transfer ongoing. 0121 */ 0122 status_t FLEXCAN_TransferReceiveFifoEDMA(CAN_Type *base, 0123 flexcan_edma_handle_t *handle, 0124 flexcan_fifo_transfer_t *pFifoXfer); 0125 /*! 0126 * @brief Gets the Legacy Rx Fifo transfer status during a interrupt non-blocking receive. 0127 * 0128 * @param base FlexCAN peripheral base address. 0129 * @param handle FlexCAN handle pointer. 0130 * @param count Number of CAN messages receive so far by the non-blocking transaction. 0131 * @retval kStatus_InvalidArgument count is Invalid. 0132 * @retval kStatus_Success Successfully return the count. 0133 */ 0134 0135 status_t FLEXCAN_TransferGetReceiveFifoCountEMDA(CAN_Type *base, flexcan_edma_handle_t *handle, size_t *count); 0136 /*! 0137 * @brief Aborts the receive Legacy/Enhanced Rx FIFO process which used eDMA. 0138 * 0139 * This function aborts the receive Legacy/Enhanced Rx FIFO process which used eDMA. 0140 * 0141 * @param base FlexCAN peripheral base address. 0142 * @param handle Pointer to flexcan_edma_handle_t structure. 0143 */ 0144 void FLEXCAN_TransferAbortReceiveFifoEDMA(CAN_Type *base, flexcan_edma_handle_t *handle); 0145 0146 #if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) 0147 /*! 0148 * @brief Receives the CAN FD Message from the Enhanced Rx FIFO using eDMA. 0149 * 0150 * This function receives the CAN FD Message using eDMA. This is a non-blocking function, which returns 0151 * right away. After the CAN Message is received, the receive callback function is called. 0152 * 0153 * @param base FlexCAN peripheral base address. 0154 * @param handle Pointer to flexcan_edma_handle_t structure. 0155 * @param pFifoXfer FlexCAN Rx FIFO EDMA transfer structure, see #flexcan_fifo_transfer_t. 0156 * @retval kStatus_Success if succeed, others failed. 0157 * @retval kStatus_FLEXCAN_RxFifoBusy Previous transfer ongoing. 0158 */ 0159 status_t FLEXCAN_TransferReceiveEnhancedFifoEDMA(CAN_Type *base, 0160 flexcan_edma_handle_t *handle, 0161 flexcan_fifo_transfer_t *pFifoXfer); 0162 /*! 0163 * @brief Gets the Enhanced Rx Fifo transfer status during a interrupt non-blocking receive. 0164 * 0165 * @param base FlexCAN peripheral base address. 0166 * @param handle FlexCAN handle pointer. 0167 * @param count Number of CAN messages receive so far by the non-blocking transaction. 0168 * @retval kStatus_InvalidArgument count is Invalid. 0169 * @retval kStatus_Success Successfully return the count. 0170 */ 0171 0172 static inline status_t FLEXCAN_TransferGetReceiveEnhancedFifoCountEMDA(CAN_Type *base, 0173 flexcan_edma_handle_t *handle, 0174 size_t *count) 0175 { 0176 return FLEXCAN_TransferGetReceiveFifoCountEMDA(base, handle, count); 0177 } 0178 #endif 0179 0180 /*@}*/ 0181 0182 #if defined(__cplusplus) 0183 } 0184 #endif 0185 0186 /*! @}*/ 0187 0188 #endif /* _FSL_FLEXCAN_EDMA_H_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |