mirror of
https://github.com/espressif/esp-idf.git
synced 2024-09-20 10:46:02 -04:00
Merge branch 'fix/spi_freq_limit_check' into 'master'
spi: modify some docs about the freq limit and the ISR See merge request idf/esp-idf!3686
This commit is contained in:
commit
6cdfea4251
@ -150,6 +150,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
|
* @warning If a DMA channel is selected, any transmit and receive buffer used should be allocated in
|
||||||
* DMA-capable memory.
|
* 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
|
* @return
|
||||||
* - ESP_ERR_INVALID_ARG if configuration is invalid
|
* - ESP_ERR_INVALID_ARG if configuration is invalid
|
||||||
* - ESP_ERR_INVALID_STATE if host already is in use
|
* - ESP_ERR_INVALID_STATE if host already is in use
|
||||||
|
@ -74,6 +74,10 @@ struct spi_slave_transaction_t {
|
|||||||
* @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.
|
* 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
|
* @return
|
||||||
* - ESP_ERR_INVALID_ARG if configuration is invalid
|
* - ESP_ERR_INVALID_ARG if configuration is invalid
|
||||||
* - ESP_ERR_INVALID_STATE if host already is in use
|
* - ESP_ERR_INVALID_STATE if host already is in use
|
||||||
|
@ -442,14 +442,14 @@ esp_err_t spi_bus_add_device(spi_host_device_t host, const spi_device_interface_
|
|||||||
duty_cycle = (dev_config->duty_cycle_pos==0) ? 128 : dev_config->duty_cycle_pos;
|
duty_cycle = (dev_config->duty_cycle_pos==0) ? 128 : dev_config->duty_cycle_pos;
|
||||||
eff_clk = spi_cal_clock(apbclk, dev_config->clock_speed_hz, duty_cycle, (uint32_t*)&clk_reg);
|
eff_clk = spi_cal_clock(apbclk, dev_config->clock_speed_hz, duty_cycle, (uint32_t*)&clk_reg);
|
||||||
int freq_limit = spi_get_freq_limit(!(spihost[host]->flags&SPICOMMON_BUSFLAG_NATIVE_PINS), dev_config->input_delay_ns);
|
int freq_limit = spi_get_freq_limit(!(spihost[host]->flags&SPICOMMON_BUSFLAG_NATIVE_PINS), dev_config->input_delay_ns);
|
||||||
//GPIO matrix can only change data at 80Mhz rate, which only allows 40MHz SPI clock.
|
|
||||||
SPI_CHECK(eff_clk <= 40*1000*1000 || spihost[host]->flags&SPICOMMON_BUSFLAG_NATIVE_PINS, "80MHz only supported on iomux pins", ESP_ERR_INVALID_ARG);
|
|
||||||
//Speed >=40MHz over GPIO matrix needs a dummy cycle, but these don't work for full-duplex connections.
|
//Speed >=40MHz over GPIO matrix needs a dummy cycle, but these don't work for full-duplex connections.
|
||||||
spi_get_timing(!(spihost[host]->flags&SPICOMMON_BUSFLAG_NATIVE_PINS), dev_config->input_delay_ns, eff_clk, &dummy_required, &miso_delay);
|
spi_get_timing(!(spihost[host]->flags&SPICOMMON_BUSFLAG_NATIVE_PINS), dev_config->input_delay_ns, eff_clk, &dummy_required, &miso_delay);
|
||||||
SPI_CHECK( dev_config->flags & SPI_DEVICE_HALFDUPLEX || dummy_required == 0 ||
|
SPI_CHECK( dev_config->flags & SPI_DEVICE_HALFDUPLEX || dummy_required == 0 ||
|
||||||
dev_config->flags & SPI_DEVICE_NO_DUMMY,
|
dev_config->flags & SPI_DEVICE_NO_DUMMY,
|
||||||
"When GPIO matrix is used in full-duplex mode at frequency > %.1fMHz, device cannot read correct data.\n\
|
"When work in full-duplex mode at frequency > %.1fMHz, device cannot read correct data.\n\
|
||||||
Please note the SPI can only work at divisors of 80MHz, and the driver always tries to find the closest frequency to your configuration.\n\
|
Try to use IOMUX pins to increase the frequency limit, or use the half duplex mode.\n\
|
||||||
|
Please note the SPI master can only work at divisors of 80MHz, and the driver always tries to find the closest frequency to your configuration.\n\
|
||||||
Specify ``SPI_DEVICE_NO_DUMMY`` to ignore this checking. Then you can output data at higher speed, or read data at your own risk.",
|
Specify ``SPI_DEVICE_NO_DUMMY`` to ignore this checking. Then you can output data at higher speed, or read data at your own risk.",
|
||||||
ESP_ERR_INVALID_ARG, freq_limit/1000./1000 );
|
ESP_ERR_INVALID_ARG, freq_limit/1000./1000 );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user