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