spi_slave_internal.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @brief
  8. * This file contains SPI Slave private/internal APIs. Private/Internal APIs are:
  9. * - Visible to other IDF components
  10. * - Suggest NOT to use these APIs in your applications
  11. * - We don't provide backward compatibility on these APIs either
  12. */
  13. #pragma once
  14. #include "sdkconfig.h"
  15. #include "esp_err.h"
  16. #include "hal/spi_types.h"
  17. #include "driver/spi_slave.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /**
  22. * @brief Reset the trans Queue of slave driver
  23. * @note
  24. * This API is used to reset SPI Slave transaction queue. After calling this function:
  25. * - The SPI Slave transaction queue will be reset.
  26. *
  27. * @note This API shouldn't be called when the corresponding SPI Master is doing an SPI transaction.
  28. * If this gets called when its corresponding SPI Master is doing an SPI transaction, the SPI Slave behaviour is undefined
  29. *
  30. * @param host SPI peripheral that is acting as a slave
  31. *
  32. * @return
  33. * - ESP_ERR_INVALID_ARG if parameter is invalid
  34. * - ESP_OK on success
  35. */
  36. esp_err_t spi_slave_queue_reset(spi_host_device_t host);
  37. /**
  38. * @brief Reset the trans Queue from within ISR of slave driver
  39. * @note
  40. * This API is used to reset SPI Slave transaction queue from within ISR. After calling this function:
  41. * - The SPI Slave transaction queue will be empty.
  42. *
  43. * @param host SPI peripheral that is acting as a slave
  44. *
  45. * @return
  46. * - ESP_ERR_INVALID_ARG if parameter is invalid
  47. * - ESP_OK on success
  48. */
  49. esp_err_t spi_slave_queue_reset_isr(spi_host_device_t host);
  50. /**
  51. * @brief Queue a SPI transaction in ISR
  52. * @note
  53. * Similar as ``spi_slave_queue_trans``, but can and can only called within an ISR, then get the transaction results
  54. * through the transaction descriptor passed in ``spi_slave_interface_config_t::post_trans_cb``. if use this API, you
  55. * should trigger a transaction by normal ``spi_slave_queue_trans`` once and only once to start isr
  56. *
  57. * If you use both ``spi_slave_queue_trans`` and ``spi_slave_queue_trans_isr`` simultaneously to transfer valid data,
  58. * you should deal with concurrency issues on your self risk
  59. *
  60. * @param host SPI peripheral that is acting as a slave
  61. * @param trans_desc Description of transaction to execute. Not const because we may want to write status back
  62. * into the transaction description.
  63. * @return
  64. * - ESP_ERR_INVALID_ARG if parameter is invalid
  65. * - ESP_ERR_NO_MEM if trans_queue is full
  66. * - ESP_OK on success
  67. */
  68. esp_err_t spi_slave_queue_trans_isr(spi_host_device_t host, const spi_slave_transaction_t *trans_desc);
  69. #ifdef __cplusplus
  70. }
  71. #endif