mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-01 21:10:58 +02:00
Update IDF to 65acd99 (#358)
* Update IDF to 65acd99 * Update platformio and arduino build paths and libs * Update esptool binaries
This commit is contained in:
@ -221,7 +221,7 @@ typedef intr_handle_t gpio_isr_handle_t;
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*
|
||||
*/
|
||||
esp_err_t gpio_config(gpio_config_t *pGPIOConfig);
|
||||
esp_err_t gpio_config(const gpio_config_t *pGPIOConfig);
|
||||
|
||||
|
||||
/**
|
||||
@ -356,7 +356,7 @@ esp_err_t gpio_wakeup_disable(gpio_num_t gpio_num);
|
||||
* @param handle Pointer to return handle. If non-NULL, a handle for the interrupt will be returned here.
|
||||
*
|
||||
* \verbatim embed:rst:leading-asterisk
|
||||
* To disable or remove the ISR, pass the returned handle to the :doc:`interrupt allocation functions </api/system/intr_alloc>`.
|
||||
* To disable or remove the ISR, pass the returned handle to the :doc:`interrupt allocation functions </api-reference/system/intr_alloc>`.
|
||||
* \endverbatim
|
||||
*
|
||||
* @return
|
||||
|
@ -135,7 +135,7 @@ esp_err_t i2c_driver_delete(i2c_port_t i2c_num);
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t i2c_param_config(i2c_port_t i2c_num, i2c_config_t* i2c_conf);
|
||||
esp_err_t i2c_param_config(i2c_port_t i2c_num, const i2c_config_t* i2c_conf);
|
||||
|
||||
/**
|
||||
* @brief reset I2C tx hardware fifo
|
||||
|
@ -43,6 +43,15 @@ typedef enum {
|
||||
I2S_BITS_PER_SAMPLE_32BIT = 32, /*!< I2S bits per sample: 32-bits*/
|
||||
} i2s_bits_per_sample_t;
|
||||
|
||||
/**
|
||||
* @brief I2S channel.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_CHANNEL_MONO = 1, /*!< I2S 1 channel (mono)*/
|
||||
I2S_CHANNEL_STEREO = 2 /*!< I2S 2 channel (stereo)*/
|
||||
} i2s_channel_t;
|
||||
|
||||
/**
|
||||
* @brief I2S communication standard format
|
||||
*
|
||||
@ -338,6 +347,25 @@ esp_err_t i2s_start(i2s_port_t i2s_num);
|
||||
*/
|
||||
esp_err_t i2s_zero_dma_buffer(i2s_port_t i2s_num);
|
||||
|
||||
/**
|
||||
* @brief Set clock & bit width used for I2S RX and TX.
|
||||
*
|
||||
* Similar to i2s_set_sample_rates(), but also sets bit width.
|
||||
*
|
||||
* @param i2s_num I2S_NUM_0, I2S_NUM_1
|
||||
*
|
||||
* @param rate I2S sample rate (ex: 8000, 44100...)
|
||||
*
|
||||
* @param bits I2S bit width (I2S_BITS_PER_SAMPLE_16BIT, I2S_BITS_PER_SAMPLE_24BIT, I2S_BITS_PER_SAMPLE_32BIT)
|
||||
*
|
||||
* @param ch I2S channel, (I2S_CHANNEL_MONO, I2S_CHANNEL_STEREO)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t i2s_set_clk(i2s_port_t i2s_num, uint32_t rate, i2s_bits_per_sample_t bits, i2s_channel_t ch);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -115,7 +115,7 @@ typedef intr_handle_t ledc_isr_handle_t;
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t ledc_channel_config(ledc_channel_config_t* ledc_conf);
|
||||
esp_err_t ledc_channel_config(const ledc_channel_config_t* ledc_conf);
|
||||
|
||||
/**
|
||||
* @brief LEDC timer configuration
|
||||
@ -128,7 +128,7 @@ esp_err_t ledc_channel_config(ledc_channel_config_t* ledc_conf);
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Can not find a proper pre-divider number base on the given frequency and the current bit_num.
|
||||
*/
|
||||
esp_err_t ledc_timer_config(ledc_timer_config_t* timer_conf);
|
||||
esp_err_t ledc_timer_config(const ledc_timer_config_t* timer_conf);
|
||||
|
||||
/**
|
||||
* @brief LEDC update channel parameters
|
||||
|
@ -88,7 +88,7 @@ typedef intr_handle_t pcnt_isr_handle_t;
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t pcnt_unit_config(pcnt_config_t *pcnt_config);
|
||||
esp_err_t pcnt_unit_config(const pcnt_config_t *pcnt_config);
|
||||
|
||||
/**
|
||||
* @brief Get pulse counter value
|
||||
|
@ -57,7 +57,7 @@ typedef struct {
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t sigmadelta_config(sigmadelta_config_t *config);
|
||||
esp_err_t sigmadelta_config(const sigmadelta_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Set Sigma-delta channel duty.
|
||||
|
233
tools/sdk/include/driver/driver/spi_common.h
Normal file
233
tools/sdk/include/driver/driver/spi_common.h
Normal file
@ -0,0 +1,233 @@
|
||||
// Copyright 2010-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#ifndef _DRIVER_SPI_COMMON_H_
|
||||
#define _DRIVER_SPI_COMMON_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "soc/spi_struct.h"
|
||||
#include "rom/lldesc.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
//Maximum amount of bytes that can be put in one DMA descriptor
|
||||
#define SPI_MAX_DMA_LEN (4096-4)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Enum with the three SPI peripherals that are software-accessible in it
|
||||
*/
|
||||
typedef enum {
|
||||
SPI_HOST=0, ///< SPI1, SPI
|
||||
HSPI_HOST=1, ///< SPI2, HSPI
|
||||
VSPI_HOST=2 ///< SPI3, VSPI
|
||||
} spi_host_device_t;
|
||||
|
||||
/**
|
||||
* @brief This is a configuration structure for a SPI bus.
|
||||
*
|
||||
* You can use this structure to specify the GPIO pins of the bus. Normally, the driver will use the
|
||||
* GPIO matrix to route the signals. An exception is made when all signals either can be routed through
|
||||
* the IO_MUX or are -1. In that case, the IO_MUX is used, allowing for >40MHz speeds.
|
||||
*/
|
||||
typedef struct {
|
||||
int mosi_io_num; ///< GPIO pin for Master Out Slave In (=spi_d) signal, or -1 if not used.
|
||||
int miso_io_num; ///< GPIO pin for Master In Slave Out (=spi_q) signal, or -1 if not used.
|
||||
int sclk_io_num; ///< GPIO pin for Spi CLocK signal, or -1 if not used.
|
||||
int quadwp_io_num; ///< GPIO pin for WP (Write Protect) signal which is used as D2 in 4-bit communication modes, or -1 if not used.
|
||||
int quadhd_io_num; ///< GPIO pin for HD (HolD) signal which is used as D3 in 4-bit communication modes, or -1 if not used.
|
||||
int max_transfer_sz; ///< Maximum transfer size, in bytes. Defaults to 4094 if 0.
|
||||
} spi_bus_config_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Try to claim a SPI peripheral
|
||||
*
|
||||
* Call this if your driver wants to manage a SPI peripheral.
|
||||
*
|
||||
* @param host Peripheral to claim
|
||||
* @return True if peripheral is claimed successfully; false if peripheral already is claimed.
|
||||
*/
|
||||
bool spicommon_periph_claim(spi_host_device_t host);
|
||||
|
||||
/**
|
||||
* @brief Return the SPI peripheral so another driver can claim it.
|
||||
*
|
||||
* @param host Peripheral to claim
|
||||
* @return True if peripheral is returned successfully; false if peripheral was free to claim already.
|
||||
*/
|
||||
bool spicommon_periph_free(spi_host_device_t host);
|
||||
|
||||
|
||||
#define SPICOMMON_BUSFLAG_SLAVE 0 ///< Initialize I/O in slave mode
|
||||
#define SPICOMMON_BUSFLAG_MASTER (1<<0) ///< Initialize I/O in master mode
|
||||
#define SPICOMMON_BUSFLAG_QUAD (1<<1) ///< Also initialize WP/HD pins, if specified
|
||||
|
||||
/**
|
||||
* @brief Connect a SPI peripheral to GPIO pins
|
||||
*
|
||||
* This routine is used to connect a SPI peripheral to the IO-pads and DMA channel given in
|
||||
* the arguments. Depending on the IO-pads requested, the routing is done either using the
|
||||
* IO_mux or using the GPIO matrix.
|
||||
*
|
||||
* @param host SPI peripheral to be routed
|
||||
* @param bus_config Pointer to a spi_bus_config struct detailing the GPIO pins
|
||||
* @param dma_chan DMA-channel (1 or 2) to use, or 0 for no DMA.
|
||||
* @param flags Combination of SPICOMMON_BUSFLAG_* flags
|
||||
* @param[out] is_native A value of 'true' will be written to this address if the GPIOs can be
|
||||
* routed using the IO_mux, 'false' if the GPIO matrix is used.
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spicommon_bus_initialize_io(spi_host_device_t host, const spi_bus_config_t *bus_config, int dma_chan, int flags, bool *is_native);
|
||||
|
||||
/**
|
||||
* @brief Free the IO used by a SPI peripheral
|
||||
*
|
||||
* @param host SPI peripheral to be freed
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
|
||||
esp_err_t spicommon_bus_free_io(spi_host_device_t host);
|
||||
|
||||
/**
|
||||
* @brief Initialize a Chip Select pin for a specific SPI peripheral
|
||||
*
|
||||
*
|
||||
* @param host SPI peripheral
|
||||
* @param cs_io_num GPIO pin to route
|
||||
* @param cs_num CS id to route
|
||||
* @param force_gpio_matrix If true, CS will always be routed through the GPIO matrix. If false,
|
||||
* if the GPIO number allows it, the routing will happen through the IO_mux.
|
||||
*/
|
||||
|
||||
void spicommon_cs_initialize(spi_host_device_t host, int cs_io_num, int cs_num, int force_gpio_matrix);
|
||||
|
||||
/**
|
||||
* @brief Free a chip select line
|
||||
*
|
||||
* @param host SPI peripheral
|
||||
* @param cs_num CS id to free
|
||||
*/
|
||||
void spicommon_cs_free(spi_host_device_t host, int cs_num);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Setup a DMA link chain
|
||||
*
|
||||
* This routine will set up a chain of linked DMA descriptors in the array pointed to by
|
||||
* ``dmadesc``. Enough DMA descriptors will be used to fit the buffer of ``len`` bytes in, and the
|
||||
* descriptors will point to the corresponding positions in ``buffer`` and linked together. The
|
||||
* end result is that feeding ``dmadesc[0]`` into DMA hardware results in the entirety ``len`` bytes
|
||||
* of ``data`` being read or written.
|
||||
*
|
||||
* @param dmadesc Pointer to array of DMA descriptors big enough to be able to convey ``len`` bytes
|
||||
* @param len Length of buffer
|
||||
* @param data Data buffer to use for DMA transfer
|
||||
* @param isrx True if data is to be written into ``data``, false if it's to be read from ``data``.
|
||||
*/
|
||||
void spicommon_setup_dma_desc_links(lldesc_t *dmadesc, int len, const uint8_t *data, bool isrx);
|
||||
|
||||
/**
|
||||
* @brief Get the position of the hardware registers for a specific SPI host
|
||||
*
|
||||
* @param host The SPI host
|
||||
*
|
||||
* @return A register descriptor stuct pointer, pointed at the hardware registers
|
||||
*/
|
||||
spi_dev_t *spicommon_hw_for_host(spi_host_device_t host);
|
||||
|
||||
/**
|
||||
* @brief Get the IRQ source for a specific SPI host
|
||||
*
|
||||
* @param host The SPI host
|
||||
*
|
||||
* @return The hosts IRQ source
|
||||
*/
|
||||
int spicommon_irqsource_for_host(spi_host_device_t host);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Callback, to be called when a DMA engine reset is completed
|
||||
*/
|
||||
typedef void(*dmaworkaround_cb_t)(void *arg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Request a reset for a certain DMA channel
|
||||
*
|
||||
* @note In some (well-defined) cases in the ESP32 (at least rev v.0 and v.1), a SPI DMA channel will get confused. This can be remedied
|
||||
* by resetting the SPI DMA hardware in case this happens. Unfortunately, the reset knob used for thsi will reset _both_ DMA channels, and
|
||||
* as such can only done safely when both DMA channels are idle. These functions coordinate this.
|
||||
*
|
||||
* Essentially, when a reset is needed, a driver can request this using spicommon_dmaworkaround_req_reset. This is supposed to be called
|
||||
* with an user-supplied function as an argument. If both DMA channels are idle, this call will reset the DMA subsystem and return true.
|
||||
* If the other DMA channel is still busy, it will return false; as soon as the other DMA channel is done, however, it will reset the
|
||||
* DMA subsystem and call the callback. The callback is then supposed to be used to continue the SPI drivers activity.
|
||||
*
|
||||
* @param dmachan DMA channel associated with the SPI host that needs a reset
|
||||
* @param cb Callback to call in case DMA channel cannot be reset immediately
|
||||
* @param arg Argument to the callback
|
||||
*
|
||||
* @return True when a DMA reset could be executed immediately. False when it could not; in this
|
||||
* case the callback will be called with the specified argument when the logic can execute
|
||||
* a reset, after that reset.
|
||||
*/
|
||||
bool spicommon_dmaworkaround_req_reset(int dmachan, dmaworkaround_cb_t cb, void *arg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Check if a DMA reset is requested but has not completed yet
|
||||
*
|
||||
* @return True when a DMA reset is requested but hasn't completed yet. False otherwise.
|
||||
*/
|
||||
bool spicommon_dmaworkaround_reset_in_progress();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Mark a DMA channel as idle.
|
||||
*
|
||||
* A call to this function tells the workaround logic that this channel will
|
||||
* not be affected by a global SPI DMA reset.
|
||||
*/
|
||||
void spicommon_dmaworkaround_idle(int dmachan);
|
||||
|
||||
/**
|
||||
* @brief Mark a DMA channel as active.
|
||||
*
|
||||
* A call to this function tells the workaround logic that this channel will
|
||||
* be affected by a global SPI DMA reset, and a reset like that should not be attempted.
|
||||
*/
|
||||
void spicommon_dmaworkaround_transfer_active(int dmachan);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -20,6 +20,7 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "driver/spi_common.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -27,37 +28,10 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Enum with the three SPI peripherals that are software-accessible in it
|
||||
*/
|
||||
typedef enum {
|
||||
SPI_HOST=0, ///< SPI1, SPI
|
||||
HSPI_HOST=1, ///< SPI2, HSPI
|
||||
VSPI_HOST=2 ///< SPI3, VSPI
|
||||
} spi_host_device_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief This is a configuration structure for a SPI bus.
|
||||
*
|
||||
* You can use this structure to specify the GPIO pins of the bus. Normally, the driver will use the
|
||||
* GPIO matrix to route the signals. An exception is made when all signals either can be routed through
|
||||
* the IO_MUX or are -1. In that case, the IO_MUX is used, allowing for >40MHz speeds.
|
||||
*/
|
||||
typedef struct {
|
||||
int mosi_io_num; ///< GPIO pin for Master Out Slave In (=spi_d) signal, or -1 if not used.
|
||||
int miso_io_num; ///< GPIO pin for Master In Slave Out (=spi_q) signal, or -1 if not used.
|
||||
int sclk_io_num; ///< GPIO pin for Spi CLocK signal, or -1 if not used.
|
||||
int quadwp_io_num; ///< GPIO pin for WP (Write Protect) signal which is used as D2 in 4-bit communication modes, or -1 if not used.
|
||||
int quadhd_io_num; ///< GPIO pin for HD (HolD) signal which is used as D3 in 4-bit communication modes, or -1 if not used.
|
||||
} spi_bus_config_t;
|
||||
|
||||
|
||||
#define SPI_DEVICE_TXBIT_LSBFIRST (1<<0) ///< Transmit command/address/data LSB first instead of the default MSB first
|
||||
#define SPI_DEVICE_RXBIT_LSBFIRST (1<<1) ///< Receive data LSB first instead of the default MSB first
|
||||
#define SPI_DEVICE_BIT_LSBFIRST (SPI_TXBIT_LSBFIRST|SPI_RXBIT_LSBFIRST); ///< Transmit and receive LSB first
|
||||
#define SPI_DEVICE_3WIRE (1<<2) ///< Use spiq for both sending and receiving data
|
||||
#define SPI_DEVICE_3WIRE (1<<2) ///< Use MOSI (=spid) for both sending and receiving data
|
||||
#define SPI_DEVICE_POSITIVE_CS (1<<3) ///< Make CS positive during a transaction instead of negative
|
||||
#define SPI_DEVICE_HALFDUPLEX (1<<4) ///< Transmit data before receiving it, instead of simultaneously
|
||||
#define SPI_DEVICE_CLK_AS_CS (1<<5) ///< Output clock on CS line if CS is active
|
||||
@ -122,16 +96,17 @@ typedef struct spi_device_t* spi_device_handle_t; ///< Handle for a device on a
|
||||
*
|
||||
* @param host SPI peripheral that controls this bus
|
||||
* @param bus_config Pointer to a spi_bus_config_t struct specifying how the host should be initialized
|
||||
* @param dma_chan Either 1 or 2. A SPI bus used by this driver must have a DMA channel associated with
|
||||
* it. The SPI hardware has two DMA channels to share. This parameter indicates which
|
||||
* one to use.
|
||||
* @param dma_chan Either channel 1 or 2, or 0 in the case when no DMA is required. Selecting a DMA channel
|
||||
* for a SPI bus allows transfers on the bus to have sizes only limited by the amount of
|
||||
* internal memory. Selecting no DMA channel (by passing the value 0) limits the amount of
|
||||
* bytes transfered to a maximum of 32.
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if configuration is invalid
|
||||
* - ESP_ERR_INVALID_STATE if host already is in use
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spi_bus_initialize(spi_host_device_t host, spi_bus_config_t *bus_config, int dma_chan);
|
||||
esp_err_t spi_bus_initialize(spi_host_device_t host, const spi_bus_config_t *bus_config, int dma_chan);
|
||||
|
||||
/**
|
||||
* @brief Free a SPI bus
|
||||
@ -235,4 +210,4 @@ esp_err_t spi_device_transmit(spi_device_handle_t handle, spi_transaction_t *tra
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
161
tools/sdk/include/driver/driver/spi_slave.h
Normal file
161
tools/sdk/include/driver/driver/spi_slave.h
Normal file
@ -0,0 +1,161 @@
|
||||
// Copyright 2010-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#ifndef _DRIVER_SPI_SLAVE_H_
|
||||
#define _DRIVER_SPI_SLAVE_H_
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "driver/spi_common.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
#define SPI_SLAVE_TXBIT_LSBFIRST (1<<0) ///< Transmit command/address/data LSB first instead of the default MSB first
|
||||
#define SPI_SLAVE_RXBIT_LSBFIRST (1<<1) ///< Receive data LSB first instead of the default MSB first
|
||||
#define SPI_SLAVE_BIT_LSBFIRST (SPI_TXBIT_LSBFIRST|SPI_RXBIT_LSBFIRST); ///< Transmit and receive LSB first
|
||||
|
||||
|
||||
typedef struct spi_slave_transaction_t spi_slave_transaction_t;
|
||||
typedef void(*slave_transaction_cb_t)(spi_slave_transaction_t *trans);
|
||||
|
||||
/**
|
||||
* @brief This is a configuration for a SPI host acting as a slave device.
|
||||
*/
|
||||
typedef struct {
|
||||
int spics_io_num; ///< CS GPIO pin for this device
|
||||
uint32_t flags; ///< Bitwise OR of SPI_SLAVE_* flags
|
||||
int queue_size; ///< Transaction queue size. This sets how many transactions can be 'in the air' (queued using spi_slave_queue_trans but not yet finished using spi_slave_get_trans_result) at the same time
|
||||
uint8_t mode; ///< SPI mode (0-3)
|
||||
slave_transaction_cb_t post_setup_cb; ///< Callback called after the SPI registers are loaded with new data
|
||||
slave_transaction_cb_t post_trans_cb; ///< Callback called after a transaction is done
|
||||
} spi_slave_interface_config_t;
|
||||
|
||||
/**
|
||||
* This structure describes one SPI transaction
|
||||
*/
|
||||
struct spi_slave_transaction_t {
|
||||
size_t length; ///< Total data length, in bits
|
||||
const void *tx_buffer; ///< Pointer to transmit buffer, or NULL for no MOSI phase
|
||||
void *rx_buffer; ///< Pointer to receive buffer, or NULL for no MISO phase
|
||||
void *user; ///< User-defined variable. Can be used to store eg transaction ID.
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Initialize a SPI bus as a slave interface
|
||||
*
|
||||
* @warning For now, only supports HSPI and VSPI.
|
||||
*
|
||||
* @param host SPI peripheral to use as a SPI slave interface
|
||||
* @param bus_config Pointer to a spi_bus_config_t struct specifying how the host should be initialized
|
||||
* @param slave_config Pointer to a spi_slave_interface_config_t struct specifying the details for the slave interface
|
||||
* @param dma_chan Either 1 or 2. A SPI bus used by this driver must have a DMA channel associated with
|
||||
* it. The SPI hardware has two DMA channels to share. This parameter indicates which
|
||||
* one to use.
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if configuration is invalid
|
||||
* - ESP_ERR_INVALID_STATE if host already is in use
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spi_slave_initialize(spi_host_device_t host, const spi_bus_config_t *bus_config, const spi_slave_interface_config_t *slave_config, int dma_chan);
|
||||
|
||||
/**
|
||||
* @brief Free a SPI bus claimed as a SPI slave interface
|
||||
*
|
||||
* @param host SPI peripheral to free
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_INVALID_STATE if not all devices on the bus are freed
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spi_slave_free(spi_host_device_t host);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Queue a SPI transaction for execution
|
||||
*
|
||||
* Queues a SPI transaction to be executed by this slave device. (The transaction queue size was specified when the slave
|
||||
* device was initialised via spi_slave_initialize.) This function may block if the queue is full (depending on the
|
||||
* ticks_to_wait parameter). No SPI operation is directly initiated by this function, the next queued transaction
|
||||
* will happen when the master initiates a SPI transaction by pulling down CS and sending out clock signals.
|
||||
*
|
||||
* This function hands over ownership of the buffers in ``trans_desc`` to the SPI slave driver; the application is
|
||||
* not to access this memory until ``spi_slave_queue_trans`` is called to hand ownership back to the application.
|
||||
*
|
||||
* @param host SPI peripheral that is acting as a slave
|
||||
* @param trans_desc Description of transaction to execute. Not const because we may want to write status back
|
||||
* into the transaction description.
|
||||
* @param ticks_to_wait Ticks to wait until there's room in the queue; use portMAX_DELAY to
|
||||
* never time out.
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spi_slave_queue_trans(spi_host_device_t host, const spi_slave_transaction_t *trans_desc, TickType_t ticks_to_wait);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the result of a SPI transaction queued earlier
|
||||
*
|
||||
* This routine will wait until a transaction to the given device (queued earlier with
|
||||
* spi_slave_queue_trans) has succesfully completed. It will then return the description of the
|
||||
* completed transaction so software can inspect the result and e.g. free the memory or
|
||||
* re-use the buffers.
|
||||
*
|
||||
* It is mandatory to eventually use this function for any transaction queued by ``spi_slave_queue_trans``.
|
||||
*
|
||||
* @param host SPI peripheral to that is acting as a slave
|
||||
* @param[out] trans_desc Pointer to variable able to contain a pointer to the description of the
|
||||
* transaction that is executed
|
||||
* @param ticks_to_wait Ticks to wait until there's a returned item; use portMAX_DELAY to never time
|
||||
* out.
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spi_slave_get_trans_result(spi_host_device_t host, spi_slave_transaction_t **trans_desc, TickType_t ticks_to_wait);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Do a SPI transaction
|
||||
*
|
||||
* Essentially does the same as spi_slave_queue_trans followed by spi_slave_get_trans_result. Do
|
||||
* not use this when there is still a transaction queued that hasn't been finalized
|
||||
* using spi_slave_get_trans_result.
|
||||
*
|
||||
* @param host SPI peripheral to that is acting as a slave
|
||||
* @param trans_desc Pointer to variable able to contain a pointer to the description of the
|
||||
* transaction that is executed. Not const because we may want to write status back
|
||||
* into the transaction description.
|
||||
* @param ticks_to_wait Ticks to wait until there's a returned item; use portMAX_DELAY to never time
|
||||
* out.
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spi_slave_transmit(spi_host_device_t host, spi_slave_transaction_t *trans_desc, TickType_t ticks_to_wait);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -287,7 +287,7 @@ esp_err_t timer_isr_register(timer_group_t group_num, timer_idx_t timer_num, voi
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t timer_init(timer_group_t group_num, timer_idx_t timer_num, timer_config_t* config);
|
||||
esp_err_t timer_init(timer_group_t group_num, timer_idx_t timer_num, const timer_config_t* config);
|
||||
|
||||
/** @brief Get timer configure value.
|
||||
*
|
||||
|
Reference in New Issue
Block a user