forked from espressif/arduino-esp32
Update IDF to a0468b2 (#2108)
* Update IDF to a0468b2 * add missing ld file * Fix PIO builds and change coex policy
This commit is contained in:
@ -420,6 +420,35 @@ esp_err_t i2c_set_period(i2c_port_t i2c_num, int high_period, int low_period);
|
||||
*/
|
||||
esp_err_t i2c_get_period(i2c_port_t i2c_num, int* high_period, int* low_period);
|
||||
|
||||
/**
|
||||
* @brief enable hardware filter on I2C bus
|
||||
* Sometimes the I2C bus is disturbed by high frequency noise(about 20ns), or the rising edge of
|
||||
* the SCL clock is very slow, these may cause the master state machine broken. enable hardware
|
||||
* filter can filter out high frequency interference and make the master more stable.
|
||||
* @note
|
||||
* Enable filter will slow the SCL clock.
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
* @param cyc_num the APB cycles need to be filtered(0<= cyc_num <=7).
|
||||
* When the period of a pulse is less than cyc_num * APB_cycle, the I2C controller will ignore this pulse.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t i2c_filter_enable(i2c_port_t i2c_num, uint8_t cyc_num);
|
||||
|
||||
/**
|
||||
* @brief disable filter on I2C bus
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t i2c_filter_disable(i2c_port_t i2c_num);
|
||||
|
||||
/**
|
||||
* @brief set I2C master start signal timing
|
||||
*
|
||||
|
@ -27,11 +27,12 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief IO signals for MCPWM
|
||||
* 6 MCPWM output pins that generate PWM signals
|
||||
* 3 MCPWM fault input pins to detect faults like overcurrent, overvoltage, etc
|
||||
* 3 MCPWM sync input pins to synchronize MCPWM outputs signals
|
||||
* 3 MCPWM capture input pin to capture hall sell signal to measure time
|
||||
* @brief IO signals for the MCPWM
|
||||
*
|
||||
* - 6 MCPWM output pins that generate PWM signals
|
||||
* - 3 MCPWM fault input pins to detect faults like overcurrent, overvoltage, etc.
|
||||
* - 3 MCPWM sync input pins to synchronize MCPWM outputs signals
|
||||
* - 3 MCPWM capture input pins to gather feedback from controlled motors, using e.g. hall sensors
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM0A = 0, /*!<PWM0A output pin*/
|
||||
@ -229,9 +230,9 @@ typedef struct {
|
||||
* @brief MCPWM config carrier structure
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t carrier_period; /*!<Set carrier period = (carrier_period + 1)*800ns, carrier_period should be < 16*/
|
||||
uint8_t carrier_duty; /*!<Set carrier duty cycle, carrier_duty should be less then 8(increment every 12.5%)*/
|
||||
uint8_t pulse_width_in_os; /*!<Set pulse width of first pulse in one shot mode = (carrier period)*(pulse_width_in_os + 1), should be less then 16*/
|
||||
uint8_t carrier_period; /*!<Set carrier period = (carrier_period + 1)*800ns, carrier_period should be < 16*/
|
||||
uint8_t carrier_duty; /*!<Set carrier duty cycle, carrier_duty should be less than 8 (increment every 12.5%)*/
|
||||
uint8_t pulse_width_in_os; /*!<Set pulse width of first pulse in one shot mode = (carrier period)*(pulse_width_in_os + 1), should be less then 16*/
|
||||
mcpwm_carrier_os_t carrier_os_mode; /*!<Enable or disable carrier oneshot mode*/
|
||||
mcpwm_carrier_out_ivt_t carrier_ivt_mode; /*!<Invert output of carrier*/
|
||||
} mcpwm_carrier_config_t;
|
||||
@ -242,7 +243,7 @@ typedef struct {
|
||||
* @note
|
||||
* This function initializes one gpio at a time.
|
||||
*
|
||||
* @param mcpwm_num set MCPWM Channel(0-1)
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param io_signal set MCPWM signals, each MCPWM unit has 6 output(MCPWMXA, MCPWMXB) and 9 input(SYNC_X, FAULT_X, CAP_X)
|
||||
* 'X' is timer_num(0-2)
|
||||
* @param gpio_num set this to configure gpio for MCPWM, if you want to use gpio16, gpio_num = 16
|
||||
@ -258,7 +259,7 @@ esp_err_t mcpwm_gpio_init(mcpwm_unit_t mcpwm_num, mcpwm_io_signals_t io_signal,
|
||||
* @note
|
||||
* This function can be used to initialize more then one gpio at a time.
|
||||
*
|
||||
* @param mcpwm_num set MCPWM Channel(0-1)
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param mcpwm_pin MCPWM pin structure
|
||||
*
|
||||
* @return
|
||||
@ -270,7 +271,7 @@ esp_err_t mcpwm_set_pin(mcpwm_unit_t mcpwm_num, const mcpwm_pin_config_t *mcpwm_
|
||||
/**
|
||||
* @brief Initialize MCPWM parameters
|
||||
*
|
||||
* @param mcpwm_num set MCPWM Channel(0-1)
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param timer_num set timer number(0-2) of MCPWM, each MCPWM unit has 3 timers
|
||||
* @param mcpwm_conf configure structure mcpwm_config_t
|
||||
*
|
||||
@ -545,11 +546,11 @@ esp_err_t mcpwm_deadtime_enable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num,
|
||||
esp_err_t mcpwm_deadtime_disable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num);
|
||||
|
||||
/**
|
||||
* @brief Initialize fault submodule, currently low level triggering not supported
|
||||
* @brief Initialize fault submodule, currently low level triggering is not supported
|
||||
*
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param intput_level set fault signal level, which will cause fault to occur
|
||||
* @param fault_sig set the fault Pin, which needs to be enabled
|
||||
* @param fault_sig set the fault pin, which needs to be enabled
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -560,11 +561,11 @@ esp_err_t mcpwm_fault_init(mcpwm_unit_t mcpwm_num, mcpwm_fault_input_level_t int
|
||||
/**
|
||||
* @brief Set oneshot mode on fault detection, once fault occur in oneshot mode reset is required to resume MCPWM signals
|
||||
* @note
|
||||
* currently low level triggering not supported
|
||||
* currently low level triggering is not supported
|
||||
*
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param timer_num set timer number(0-2) of MCPWM, each MCPWM unit has 3 timers
|
||||
* @param fault_sig set the fault Pin, which needs to be enabled for oneshot mode
|
||||
* @param fault_sig set the fault pin, which needs to be enabled for oneshot mode
|
||||
* @param action_on_pwmxa action to be taken on MCPWMXA when fault occurs, either no change or high or low or toggle
|
||||
* @param action_on_pwmxb action to be taken on MCPWMXB when fault occurs, either no change or high or low or toggle
|
||||
*
|
||||
@ -578,11 +579,11 @@ esp_err_t mcpwm_fault_set_oneshot_mode(mcpwm_unit_t mcpwm_num, mcpwm_timer_t tim
|
||||
/**
|
||||
* @brief Set cycle-by-cycle mode on fault detection, once fault occur in cyc mode MCPWM signal resumes as soon as fault signal becomes inactive
|
||||
* @note
|
||||
* currently low level triggering not supported
|
||||
* currently low level triggering is not supported
|
||||
*
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param timer_num set timer number(0-2) of MCPWM, each MCPWM unit has 3 timers
|
||||
* @param fault_sig set the fault Pin, which needs to be enabled for cyc mode
|
||||
* @param fault_sig set the fault pin, which needs to be enabled for cyc mode
|
||||
* @param action_on_pwmxa action to be taken on MCPWMXA when fault occurs, either no change or high or low or toggle
|
||||
* @param action_on_pwmxb action to be taken on MCPWMXB when fault occurs, either no change or high or low or toggle
|
||||
*
|
||||
@ -610,7 +611,7 @@ esp_err_t mcpwm_fault_deinit(mcpwm_unit_t mcpwm_num, mcpwm_fault_signal_t fault_
|
||||
*
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param cap_edge set capture edge, BIT(0) - negative edge, BIT(1) - positive edge
|
||||
* @param cap_sig capture Pin, which needs to be enabled
|
||||
* @param cap_sig capture pin, which needs to be enabled
|
||||
* @param num_of_pulse count time between rising/falling edge between 2 *(pulses mentioned), counter uses APB_CLK
|
||||
*
|
||||
* @return
|
||||
@ -625,7 +626,7 @@ esp_err_t mcpwm_capture_enable(mcpwm_unit_t mcpwm_num, mcpwm_capture_signal_t ca
|
||||
* @brief Disable capture signal
|
||||
*
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param cap_sig capture Pin, which needs to be disabled
|
||||
* @param cap_sig capture pin, which needs to be disabled
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -647,7 +648,7 @@ uint32_t mcpwm_capture_signal_get_value(mcpwm_unit_t mcpwm_num, mcpwm_capture_si
|
||||
/**
|
||||
* @brief Get edge of capture signal
|
||||
*
|
||||
* @param mcpwm_num set MCPWM Channel(0-1)
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param cap_sig capture pin of whose edge is to be determined
|
||||
*
|
||||
* @return
|
||||
@ -660,8 +661,8 @@ uint32_t mcpwm_capture_signal_get_edge(mcpwm_unit_t mcpwm_num, mcpwm_capture_sig
|
||||
*
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param timer_num set timer number(0-2) of MCPWM, each MCPWM unit has 3 timers
|
||||
* @param sync_sig set the fault Pin, which needs to be enabled
|
||||
* @param phase_val phase value in 1/1000(for 86.7%, phase_val = 867) which timer moves to on sync signal
|
||||
* @param sync_sig set the synchronization pin, which needs to be enabled
|
||||
* @param phase_val phase value in 1/1000 (for 86.7%, phase_val = 867) which timer moves to on sync signal
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
|
@ -87,6 +87,11 @@ typedef struct {
|
||||
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.
|
||||
uint32_t flags; ///< Abilities of bus to be checked by the driver. Or-ed value of ``SPICOMMON_BUSFLAG_*`` flags.
|
||||
int intr_flags; /**< Interrupt flag for the bus to set the priority, and IRAM attribute, see
|
||||
* ``esp_intr_alloc.h``. Note that the EDGE, INTRDISABLED attribute are ignored
|
||||
* by the driver. Note that if ESP_INTR_FLAG_IRAM is set, ALL the callbacks of
|
||||
* the driver, and their callee functions, should be put in the IRAM.
|
||||
*/
|
||||
} spi_bus_config_t;
|
||||
|
||||
|
||||
@ -96,9 +101,32 @@ typedef struct {
|
||||
* Call this if your driver wants to manage a SPI peripheral.
|
||||
*
|
||||
* @param host Peripheral to claim
|
||||
* @param source The caller indentification string.
|
||||
*
|
||||
* @return True if peripheral is claimed successfully; false if peripheral already is claimed.
|
||||
*/
|
||||
bool spicommon_periph_claim(spi_host_device_t host);
|
||||
bool spicommon_periph_claim(spi_host_device_t host, const char* source);
|
||||
|
||||
// The macro is to keep the back-compatibility of IDF v3.2 and before
|
||||
// In this way we can call spicommon_periph_claim with two arguments, or the host with the source set to the calling function name
|
||||
// When two arguments (host, func) are given, __spicommon_periph_claim2 is called
|
||||
// or if only one arguments (host) is given, __spicommon_periph_claim1 is called
|
||||
#define spicommon_periph_claim(host...) __spicommon_periph_claim(host, 2, 1)
|
||||
#define __spicommon_periph_claim(host, source, n, ...) __spicommon_periph_claim ## n(host, source)
|
||||
#define __spicommon_periph_claim1(host, _) ({ \
|
||||
char* warning_str = "calling spicommon_periph_claim without source string is deprecated.";\
|
||||
spicommon_periph_claim(host, __FUNCTION__); })
|
||||
|
||||
#define __spicommon_periph_claim2(host, func) spicommon_periph_claim(host, func)
|
||||
|
||||
/**
|
||||
* @brief Check whether the spi periph is in use.
|
||||
*
|
||||
* @param host Peripheral to check.
|
||||
*
|
||||
* @return True if in use, otherwise false.
|
||||
*/
|
||||
bool spicommon_periph_in_use(spi_host_device_t host);
|
||||
|
||||
/**
|
||||
* @brief Return the SPI peripheral so another driver can claim it.
|
||||
@ -119,6 +147,15 @@ bool spicommon_periph_free(spi_host_device_t host);
|
||||
*/
|
||||
bool spicommon_dma_chan_claim(int dma_chan);
|
||||
|
||||
/**
|
||||
* @brief Check whether the spi DMA channel is in use.
|
||||
*
|
||||
* @param dma_chan DMA channel to check.
|
||||
*
|
||||
* @return True if in use, otherwise false.
|
||||
*/
|
||||
bool spicommon_dma_chan_in_use(int dma_chan);
|
||||
|
||||
/**
|
||||
* @brief Return the SPI DMA channel so other driver can claim it, or just to power down DMA.
|
||||
*
|
||||
|
@ -71,16 +71,34 @@ typedef struct {
|
||||
uint8_t cs_ena_pretrans; ///< Amount of SPI bit-cycles the cs should be activated before the transmission (0-16). This only works on half-duplex transactions.
|
||||
uint8_t cs_ena_posttrans; ///< Amount of SPI bit-cycles the cs should stay active after the transmission (0-16)
|
||||
int clock_speed_hz; ///< Clock speed, divisors of 80MHz, in Hz. See ``SPI_MASTER_FREQ_*``.
|
||||
int input_delay_ns; /**< Maximum data valid time of slave. The time required between SCLK and MISO
|
||||
valid, including the possible clock delay from slave to master. The driver uses this value to give an extra
|
||||
delay before the MISO is ready on the line. Leave at 0 unless you know you need a delay. For better timing
|
||||
int input_delay_ns; /**< Maximum data valid time of slave. The time required between SCLK and MISO
|
||||
valid, including the possible clock delay from slave to master. The driver uses this value to give an extra
|
||||
delay before the MISO is ready on the line. Leave at 0 unless you know you need a delay. For better timing
|
||||
performance at high frequency (over 8MHz), it's suggest to have the right value.
|
||||
*/
|
||||
int spics_io_num; ///< CS GPIO pin for this device, or -1 if not used
|
||||
uint32_t flags; ///< Bitwise OR of SPI_DEVICE_* flags
|
||||
int queue_size; ///< Transaction queue size. This sets how many transactions can be 'in the air' (queued using spi_device_queue_trans but not yet finished using spi_device_get_trans_result) at the same time
|
||||
transaction_cb_t pre_cb; ///< Callback to be called before a transmission is started. This callback is called within interrupt context.
|
||||
transaction_cb_t post_cb; ///< Callback to be called after a transmission has completed. This callback is called within interrupt context.
|
||||
transaction_cb_t pre_cb; /**< Callback to be called before a transmission is started.
|
||||
*
|
||||
* This callback is called within interrupt
|
||||
* context should be in IRAM for best
|
||||
* performance, see "Transferring Speed"
|
||||
* section in the SPI Master documentation for
|
||||
* full details. If not, the callback may crash
|
||||
* during flash operation when the driver is
|
||||
* initialized with ESP_INTR_FLAG_IRAM.
|
||||
*/
|
||||
transaction_cb_t post_cb; /**< Callback to be called after a transmission has completed.
|
||||
*
|
||||
* This callback is called within interrupt
|
||||
* context should be in IRAM for best
|
||||
* performance, see "Transferring Speed"
|
||||
* section in the SPI Master documentation for
|
||||
* full details. If not, the callback may crash
|
||||
* during flash operation when the driver is
|
||||
* initialized with ESP_INTR_FLAG_IRAM.
|
||||
*/
|
||||
} spi_device_interface_config_t;
|
||||
|
||||
|
||||
@ -150,6 +168,10 @@ typedef struct spi_device_t* spi_device_handle_t; ///< Handle for a device on a
|
||||
* @warning If a DMA channel is selected, any transmit and receive buffer used should be allocated in
|
||||
* DMA-capable memory.
|
||||
*
|
||||
* @warning The ISR of SPI is always executed on the core which calls this
|
||||
* function. Never starve the ISR on this core or the SPI transactions will not
|
||||
* be handled.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if configuration is invalid
|
||||
* - ESP_ERR_INVALID_STATE if host already is in use
|
||||
@ -206,7 +228,10 @@ esp_err_t spi_bus_remove_device(spi_device_handle_t handle);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Queue a SPI transaction for execution
|
||||
* @brief Queue a SPI transaction for interrupt transaction execution. Get the result by ``spi_device_get_trans_result``.
|
||||
*
|
||||
* @note Normally a device cannot start (queue) polling and interrupt
|
||||
* transactions simultaneously.
|
||||
*
|
||||
* @param handle Device handle obtained using spi_host_add_dev
|
||||
* @param trans_desc Description of transaction to execute
|
||||
@ -216,16 +241,17 @@ esp_err_t spi_bus_remove_device(spi_device_handle_t handle);
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_TIMEOUT if there was no room in the queue before ticks_to_wait expired
|
||||
* - ESP_ERR_NO_MEM if allocating DMA-capable temporary buffer failed
|
||||
* - ESP_ERR_INVALID_STATE if previous transactions are not finished
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spi_device_queue_trans(spi_device_handle_t handle, spi_transaction_t *trans_desc, TickType_t ticks_to_wait);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the result of a SPI transaction queued earlier
|
||||
* @brief Get the result of a SPI transaction queued earlier by ``spi_device_queue_trans``.
|
||||
*
|
||||
* This routine will wait until a transaction to the given device (queued earlier with
|
||||
* spi_device_queue_trans) has succesfully completed. It will then return the description of the
|
||||
* This routine will wait until a transaction to the given device
|
||||
* 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.
|
||||
*
|
||||
@ -247,10 +273,11 @@ esp_err_t spi_device_get_trans_result(spi_device_handle_t handle, spi_transactio
|
||||
* @brief Send a SPI transaction, wait for it to complete, and return the result
|
||||
*
|
||||
* This function is the equivalent of calling spi_device_queue_trans() followed by spi_device_get_trans_result().
|
||||
* Do not use this when there is still a transaction separately queued from spi_device_queue_trans() that hasn't been finalized
|
||||
* using spi_device_get_trans_result().
|
||||
* Do not use this when there is still a transaction separately queued (started) from spi_device_queue_trans() or polling_start/transmit that hasn't been finalized.
|
||||
*
|
||||
* @note This function is not thread safe when multiple tasks access the same SPI device.
|
||||
* Normally a device cannot start (queue) polling and interrupt
|
||||
* transactions simutanuously.
|
||||
*
|
||||
* @param handle Device handle obtained using spi_host_add_dev
|
||||
* @param trans_desc Description of transaction to execute
|
||||
@ -260,6 +287,90 @@ esp_err_t spi_device_get_trans_result(spi_device_handle_t handle, spi_transactio
|
||||
*/
|
||||
esp_err_t spi_device_transmit(spi_device_handle_t handle, spi_transaction_t *trans_desc);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Immediately start a polling transaction.
|
||||
*
|
||||
* @note Normally a device cannot start (queue) polling and interrupt
|
||||
* transactions simutanuously. Moreover, a device cannot start a new polling
|
||||
* transaction if another polling transaction is not finished.
|
||||
*
|
||||
* @param handle Device handle obtained using spi_host_add_dev
|
||||
* @param trans_desc Description of transaction to execute
|
||||
* @param ticks_to_wait Ticks to wait until there's room in the queue;
|
||||
* currently only portMAX_DELAY is supported.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_TIMEOUT if the device cannot get control of the bus before ``ticks_to_wait`` expired
|
||||
* - ESP_ERR_NO_MEM if allocating DMA-capable temporary buffer failed
|
||||
* - ESP_ERR_INVALID_STATE if previous transactions are not finished
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spi_device_polling_start(spi_device_handle_t handle, spi_transaction_t *trans_desc, TickType_t ticks_to_wait);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Poll until the polling transaction ends.
|
||||
*
|
||||
* This routine will not return until the transaction to the given device has
|
||||
* succesfully completed. The task is not blocked, but actively busy-spins for
|
||||
* the transaction to be completed.
|
||||
*
|
||||
* @param handle Device handle obtained using spi_host_add_dev
|
||||
* @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_ERR_TIMEOUT if the transaction cannot finish before ticks_to_wait expired
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spi_device_polling_end(spi_device_handle_t handle, TickType_t ticks_to_wait);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Send a polling transaction, wait for it to complete, and return the result
|
||||
*
|
||||
* This function is the equivalent of calling spi_device_polling_start() followed by spi_device_polling_end().
|
||||
* Do not use this when there is still a transaction that hasn't been finalized.
|
||||
*
|
||||
* @note This function is not thread safe when multiple tasks access the same SPI device.
|
||||
* Normally a device cannot start (queue) polling and interrupt
|
||||
* transactions simutanuously.
|
||||
*
|
||||
* @param handle Device handle obtained using spi_host_add_dev
|
||||
* @param trans_desc Description of transaction to execute
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spi_device_polling_transmit(spi_device_handle_t handle, spi_transaction_t *trans_desc);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Occupy the SPI bus for a device to do continuous transactions.
|
||||
*
|
||||
* Transactions to all other devices will be put off until ``spi_device_release_bus`` is called.
|
||||
*
|
||||
* @note The function will wait until all the existing transactions have been sent.
|
||||
*
|
||||
* @param device The device to occupy the bus.
|
||||
* @param wait Time to wait before the the bus is occupied by the device. Currently MUST set to portMAX_DELAY.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG : ``wait`` is not set to portMAX_DELAY.
|
||||
* - ESP_OK : Success.
|
||||
*/
|
||||
esp_err_t spi_device_acquire_bus(spi_device_handle_t device, TickType_t wait);
|
||||
|
||||
/**
|
||||
* @brief Release the SPI bus occupied by the device. All other devices can start sending transactions.
|
||||
*
|
||||
* @param dev The device to release the bus.
|
||||
*/
|
||||
void spi_device_release_bus(spi_device_handle_t dev);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Calculate the working frequency that is most close to desired frequency, and also the register value.
|
||||
*
|
||||
@ -282,6 +393,7 @@ int spi_cal_clock(int fapb, int hz, int duty_cycle, uint32_t* reg_o);
|
||||
* - -1 If too many cycles remaining, suggest to compensate half a clock.
|
||||
* - 0 If no remaining cycles or dummy bits are not used.
|
||||
* - positive value: cycles suggest to compensate.
|
||||
*
|
||||
* @note If **dummy_o* is not zero, it means dummy bits should be applied in half duplex mode, and full duplex mode may not work.
|
||||
*/
|
||||
void spi_get_timing(bool gpio_is_used, int input_delay_ns, int eff_clk, int* dummy_o, int* cycles_remain_o);
|
||||
@ -290,6 +402,7 @@ void spi_get_timing(bool gpio_is_used, int input_delay_ns, int eff_clk, int* dum
|
||||
* @brief Get the frequency limit of current configurations.
|
||||
* SPI master working at this limit is OK, while above the limit, full duplex mode and DMA will not work,
|
||||
* and dummy bits will be aplied in the half duplex mode.
|
||||
*
|
||||
* @param gpio_is_used True if using GPIO matrix, or False if native pins are used.
|
||||
* @param input_delay_ns Input delay from SCLK launch edge to MISO data valid.
|
||||
* @return Frequency limit of current configurations.
|
||||
|
@ -44,8 +44,26 @@ typedef struct {
|
||||
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
|
||||
slave_transaction_cb_t post_setup_cb; /**< Callback called after the SPI registers are loaded with new data.
|
||||
*
|
||||
* This callback is called within interrupt
|
||||
* context should be in IRAM for best
|
||||
* performance, see "Transferring Speed"
|
||||
* section in the SPI Master documentation for
|
||||
* full details. If not, the callback may crash
|
||||
* during flash operation when the driver is
|
||||
* initialized with ESP_INTR_FLAG_IRAM.
|
||||
*/
|
||||
slave_transaction_cb_t post_trans_cb; /**< Callback called after a transaction is done.
|
||||
*
|
||||
* This callback is called within interrupt
|
||||
* context should be in IRAM for best
|
||||
* performance, see "Transferring Speed"
|
||||
* section in the SPI Master documentation for
|
||||
* full details. If not, the callback may crash
|
||||
* during flash operation when the driver is
|
||||
* initialized with ESP_INTR_FLAG_IRAM.
|
||||
*/
|
||||
} spi_slave_interface_config_t;
|
||||
|
||||
/**
|
||||
@ -71,10 +89,14 @@ struct spi_slave_transaction_t {
|
||||
* it. The SPI hardware has two DMA channels to share. This parameter indicates which
|
||||
* one to use.
|
||||
*
|
||||
* @warning If a DMA channel is selected, any transmit and receive buffer used should be allocated in
|
||||
* @warning If a DMA channel is selected, any transmit and receive buffer used should be allocated in
|
||||
* DMA-capable memory.
|
||||
*
|
||||
* @return
|
||||
* @warning The ISR of SPI is always executed on the core which calls this
|
||||
* function. Never starve the ISR on this core or the SPI transactions will not
|
||||
* be handled.
|
||||
*
|
||||
* @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
|
||||
@ -86,7 +108,7 @@ esp_err_t spi_slave_initialize(spi_host_device_t host, const spi_bus_config_t *b
|
||||
* @brief Free a SPI bus claimed as a SPI slave interface
|
||||
*
|
||||
* @param host SPI peripheral to free
|
||||
* @return
|
||||
* @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
|
||||
@ -110,7 +132,7 @@ esp_err_t spi_slave_free(spi_host_device_t host);
|
||||
* 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
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
@ -120,19 +142,19 @@ esp_err_t spi_slave_queue_trans(spi_host_device_t host, const spi_slave_transact
|
||||
/**
|
||||
* @brief Get the result of a SPI transaction queued earlier
|
||||
*
|
||||
* This routine will wait until a transaction to the given device (queued earlier with
|
||||
* 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
|
||||
* 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
|
||||
* @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
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
@ -143,16 +165,16 @@ esp_err_t spi_slave_get_trans_result(spi_host_device_t host, spi_slave_transacti
|
||||
* @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
|
||||
* 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
|
||||
* @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
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
|
Reference in New Issue
Block a user