Chapter 2. API Reference
– positive value: cycles suggest to compensate.
int spi_get_freq_limit(bool gpio_is_used, int input_delay_ns)
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.
Return Frequency limit of current configurations.
Parameters
• gpio_is_used: True if using GPIO matrix, or False if native pins are used.
• input_delay_ns: Input delay from SCLK launch edge to MISO data valid.
Structures
struct spi_device_interface_config_t
This is a configuration for a SPI slave device that is connected to one of the SPI buses.
Public Members
uint8_t command_bits
Default amount of bits in command phase (0-16), used when SPI_TRANS_VARIABLE_CMD is not
used, otherwise ignored.
uint8_t address_bits
Default amount of bits in address phase (0-64), used when SPI_TRANS_VARIABLE_ADDR is not
used, otherwise ignored.
uint8_t dummy_bits
Amount of dummy bits to insert between address and data phase.
uint8_t mode
SPI mode, representing a pair of (CPOL, CPHA) configuration:
• 0: (0, 0)
• 1: (0, 1)
• 2: (1, 0)
• 3: (1, 1)
uint16_t duty_cycle_pos
Duty cycle of positive clock, in 1/256th increments (128 = 50%/50% duty). Setting this to 0 (=not setting
it) is equivalent to setting this to 128.
uint16_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 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.
Espressif Systems 378
Submit Document Feedback
Release v4.4