Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

141 Zeilen
4.9 KiB

  1. /*
  2. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2020 NXP
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef _FSL_FLEXCAN_EDMA_H_
  9. #define _FSL_FLEXCAN_EDMA_H_
  10. #include "fsl_flexcan.h"
  11. #include "fsl_edma.h"
  12. /*!
  13. * @addtogroup flexcan_edma_driver
  14. * @{
  15. */
  16. /*******************************************************************************
  17. * Definitions
  18. ******************************************************************************/
  19. /*! @name Driver version */
  20. /*@{*/
  21. /*! @brief FlexCAN EDMA driver version. */
  22. #define FSL_FLEXCAN_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 5, 2))
  23. /*@}*/
  24. /* Forward declaration of the handle typedef. */
  25. typedef struct _flexcan_edma_handle flexcan_edma_handle_t;
  26. /*! @brief FlexCAN transfer callback function. */
  27. typedef void (*flexcan_edma_transfer_callback_t)(CAN_Type *base,
  28. flexcan_edma_handle_t *handle,
  29. status_t status,
  30. void *userData);
  31. /*!
  32. * @brief FlexCAN eDMA handle
  33. */
  34. struct _flexcan_edma_handle
  35. {
  36. flexcan_edma_transfer_callback_t callback; /*!< Callback function. */
  37. void *userData; /*!< FlexCAN callback function parameter.*/
  38. edma_handle_t *rxFifoEdmaHandle; /*!< The EDMA Rx FIFO channel used. */
  39. volatile uint8_t rxFifoState; /*!< Rx FIFO transfer state. */
  40. };
  41. /*******************************************************************************
  42. * API
  43. ******************************************************************************/
  44. #if defined(__cplusplus)
  45. extern "C" {
  46. #endif
  47. /*!
  48. * @name eDMA transactional
  49. * @{
  50. */
  51. /*!
  52. * @brief Initializes the FlexCAN handle, which is used in transactional functions.
  53. *
  54. * @param base FlexCAN peripheral base address.
  55. * @param handle Pointer to flexcan_edma_handle_t structure.
  56. * @param callback The callback function.
  57. * @param userData The parameter of the callback function.
  58. * @param rxFifoEdmaHandle User-requested DMA handle for Rx FIFO DMA transfer.
  59. */
  60. void FLEXCAN_TransferCreateHandleEDMA(CAN_Type *base,
  61. flexcan_edma_handle_t *handle,
  62. flexcan_edma_transfer_callback_t callback,
  63. void *userData,
  64. edma_handle_t *rxFifoEdmaHandle);
  65. /*!
  66. * @brief Prepares the eDMA transfer configuration for FLEXCAN Legacy RX FIFO.
  67. *
  68. * This function prepares the eDMA transfer configuration structure according to FLEXCAN Legacy RX FIFO.
  69. *
  70. * @param base FlexCAN peripheral base address.
  71. * @param pFifoXfer FlexCAN Rx FIFO EDMA transfer structure, see #flexcan_fifo_transfer_t.
  72. * @param pEdmaConfig The user configuration structure of type edma_transfer_t.
  73. *
  74. */
  75. void FLEXCAN_PrepareTransfConfiguration(CAN_Type *base,
  76. flexcan_fifo_transfer_t *pFifoXfer,
  77. edma_transfer_config_t *pEdmaConfig);
  78. /*!
  79. * @brief Start Transfer Data from the FLEXCAN Legacy Rx FIFO using eDMA.
  80. *
  81. * This function to Update edma transfer confiugration and Start eDMA transfer
  82. *
  83. * @param base FlexCAN peripheral base address.
  84. * @param handle Pointer to flexcan_edma_handle_t structure.
  85. * @param pEdmaConfig The user configuration structure of type edma_transfer_t.
  86. * @retval kStatus_Success if succeed, others failed.
  87. * @retval kStatus_FLEXCAN_RxFifoBusy Previous transfer ongoing.
  88. */
  89. status_t FLEXCAN_StartTransferDatafromRxFIFO(CAN_Type *base,
  90. flexcan_edma_handle_t *handle,
  91. edma_transfer_config_t *pEdmaConfig);
  92. /*!
  93. * @brief Receives the CAN Message from the Rx FIFO using eDMA.
  94. *
  95. * This function receives the CAN Message using eDMA. This is a non-blocking function, which returns
  96. * right away. After the CAN Message is received, the receive callback function is called.
  97. *
  98. * @param base FlexCAN peripheral base address.
  99. * @param handle Pointer to flexcan_edma_handle_t structure.
  100. * @param pFifoXfer FlexCAN Rx FIFO EDMA transfer structure, see #flexcan_fifo_transfer_t.
  101. * @retval kStatus_Success if succeed, others failed.
  102. * @retval kStatus_FLEXCAN_RxFifoBusy Previous transfer ongoing.
  103. */
  104. status_t FLEXCAN_TransferReceiveFifoEDMA(CAN_Type *base,
  105. flexcan_edma_handle_t *handle,
  106. flexcan_fifo_transfer_t *pFifoXfer);
  107. /*!
  108. * @brief Aborts the receive process which used eDMA.
  109. *
  110. * This function aborts the receive process which used eDMA.
  111. *
  112. * @param base FlexCAN peripheral base address.
  113. * @param handle Pointer to flexcan_edma_handle_t structure.
  114. */
  115. void FLEXCAN_TransferAbortReceiveFifoEDMA(CAN_Type *base, flexcan_edma_handle_t *handle);
  116. /*@}*/
  117. #if defined(__cplusplus)
  118. }
  119. #endif
  120. /*! @}*/
  121. #endif /* _FSL_FLEXCAN_EDMA_H_ */