dac_priv_dma.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include "esp_err.h"
  8. #include "esp_intr_alloc.h"
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #define DAC_DMA_EOF_INTR 0x01
  13. #define DAC_DMA_TEOF_INTR 0x02
  14. /**
  15. * @brief Initialize DAC DMA peripheral
  16. *
  17. * @param[in] freq_hz DAC data frequency per channel
  18. * @param[in] is_alternate Transmit data alternate between two channels or simultaneously
  19. * @param[in] is_apll Whether use APLL as DAC digital controller clock source
  20. * @return
  21. * - ESP_ERR_NOT_FOUND The DMA peripheral has been occupied
  22. * - ESP_ERR_NO_MEM No memory for the DMA peripheral struct
  23. * - ESP_ERR_INVALID_ARG The frequency is out of range
  24. * - ESP_OK Initialize DAC DMA peripheral success
  25. */
  26. esp_err_t dac_dma_periph_init(uint32_t freq_hz, bool is_alternate, bool is_apll);
  27. /**
  28. * @brief Deinitialize DAC DMA peripheral
  29. *
  30. * @return
  31. * - ESP_ERR_INVALID_STATE The DAC DMA has been de-initialized already
  32. * or the interrupt has not been de-registered
  33. * - ESP_OK Deinitialize DAC DMA peripheral success
  34. */
  35. esp_err_t dac_dma_periph_deinit(void);
  36. /**
  37. * @brief Get the DMA interrupt signal id
  38. *
  39. * @return
  40. * - int DMA interrupt signal id
  41. */
  42. int dac_dma_periph_get_intr_signal(void);
  43. /**
  44. * @brief Enable the DMA and interrupt of the DAC DMA peripheral
  45. *
  46. */
  47. void dac_dma_periph_enable(void);
  48. /**
  49. * @brief Disable the DMA and interrupt of the DAC DMA peripheral
  50. *
  51. */
  52. void dac_dma_periph_disable(void);
  53. /**
  54. * @brief Whether the TX_EOF interrupt is triggered
  55. *
  56. * @return
  57. * - uint32_t Mask of the triggered interrupt: DAC_DMA_EOF_INTR, DAC_DMA_EOF_INTR
  58. */
  59. uint32_t dac_dma_periph_intr_is_triggered(void);
  60. /**
  61. * @brief Get the descriptor that just finished sending data
  62. *
  63. * @return
  64. * - uint32_t The address of the EOF descriptor
  65. */
  66. uint32_t dac_dma_periph_intr_get_eof_desc(void);
  67. /**
  68. * @brief Start a DMA transaction
  69. * @note DMA transaction will stop when reaches the tail of the descriptor link
  70. *
  71. * @param[in] desc_addr Descriptor address
  72. */
  73. void dac_dma_periph_dma_trans_start(uint32_t desc_addr);
  74. #ifdef __cplusplus
  75. }
  76. #endif