EasyManua.ls Logo

Espressif ESP32-S2 - Page 388

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
not use this when there is still a transaction that hasnt 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.
Return
ESP_ERR_INVALID_ARG if parameter is invalid
ESP_OK on success
Parameters
handle: Device handle obtained using spi_host_add_dev
trans_desc: Description of transaction to execute
esp_err_t spi_device_acquire_bus(spi_device_handle_t device, TickType_t wait)
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.
Return
ESP_ERR_INVALID_ARG : wait is not set to portMAX_DELAY.
ESP_OK : Success.
Parameters
device: The device to occupy the bus.
wait: Time to wait before the the bus is occupied by the device. Currently MUST set to port-
MAX_DELAY.
void spi_device_release_bus(spi_device_handle_t dev)
Release the SPI bus occupied by the device. All other devices can start sending transactions.
Parameters
dev: The device to release the bus.
int spi_cal_clock(int fapb, int hz, int duty_cycle, uint32_t *reg_o)
Calculate the working frequency that is most close to desired frequency, and also the register value.
Parameters
fapb: The frequency of apb clock, should be APB_CLK_FREQ.
hz: Desired working frequency
duty_cycle: Duty cycle of the spi clock
reg_o: Output of value to be set in clock register, or NULL if not needed.
Return Actual working frequency that most fit.
int spi_get_actual_clock(int fapb, int hz, int duty_cycle)
Calculate the working frequency that is most close to desired frequency.
Return Actual working frequency that most fit.
Parameters
fapb: The frequency of apb clock, should be APB_CLK_FREQ.
hz: Desired working frequency
duty_cycle: Duty cycle of the spi clock
void spi_get_timing(bool gpio_is_used, int input_delay_ns, int eff_clk, int *dummy_o, int
*cycles_remain_o)
Calculate the timing settings of specified frequency and settings.
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.
Parameters
gpio_is_used: True if using GPIO matrix, or False if iomux pins are used.
input_delay_ns: Input delay from SCLK launch edge to MISO data valid.
eff_clk: Effective clock frequency (in Hz) from spi_cal_clock.
dummy_o: Address of dummy bits used output. Set to NULL if not needed.
cycles_remain_o: Address of cycles remaining (after dummy bits are used) output.
-1 If too many cycles remaining, suggest to compensate half a clock.
0 If no remaining cycles or dummy bits are not used.
Espressif Systems 377
Submit Document Feedback
Release v4.4

Table of Contents