uint8_tcommand_bits;///< Amount of bits in command phase (0-16)
uint8_taddress_bits;///< Amount of bits in address phase (0-64)
uint8_tdummy_bits;///< Amount of dummy bits to insert between address and data phase
uint8_tmode;///< SPI mode (0-3)
uint8_tduty_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.
uint8_tcs_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_tcs_ena_posttrans;///< Amount of SPI bit-cycles the cs should stay active after the transmission (0-16)
intclock_speed_hz;///< Clock speed, in Hz
intspics_io_num;///< CS GPIO pin for this device, or -1 if not used
uint32_tflags;///< Bitwise OR of SPI_DEVICE_* flags
intqueue_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_tpre_cb;///< Callback to be called before a transmission is started. This callback is called within interrupt context.
transaction_cb_tpost_cb;///< Callback to be called after a transmission has completed. This callback is called within interrupt context.
}spi_device_interface_config_t;
#define SPI_TRANS_MODE_DIO (1<<0) ///< Transmit/receive data in 2-bit mode
#define SPI_TRANS_MODE_QIO (1<<1) ///< Transmit/receive data in 4-bit mode
#define SPI_TRANS_MODE_DIOQIO_ADDR (1<<2) ///< Also transmit address in mode selected by SPI_MODE_DIO/SPI_MODE_QIO
#define SPI_TRANS_USE_RXDATA (1<<2) ///< Receive into rx_data member of spi_transaction_t instead into memory at rx_buffer.
#define SPI_TRANS_USE_TXDATA (1<<3) ///< Transmit tx_data member of spi_transaction_t instead of data at tx_buffer. Do not set tx_buffer when using this.
/**
*ThisstructuredescribesoneSPItransaction
*/
structspi_transaction_t{
uint32_tflags;///< Bitwise OR of SPI_TRANS_* flags
uint16_tcommand;///< Command data. Specific length was given when device was added to the bus.
uint64_taddress;///< Address. Specific length was given when device was added to the bus.
size_tlength;///< Total data length, in bits
size_trxlength;///< Total data length received, if different from length. (0 defaults this to the value of ``length``)
void*user;///< User-defined variable. Can be used to store eg transaction ID.
union{
constvoid*tx_buffer;///< Pointer to transmit buffer, or NULL for no MOSI phase
uint8_ttx_data[4];///< If SPI_USE_TXDATA is set, data set here is sent directly from this variable.
};
union{
void*rx_buffer;///< Pointer to receive buffer, or NULL for no MISO phase
uint8_trx_data[4];///< If SPI_USE_RXDATA is set, data is received directly to this variable
};
};
typedefstructspi_device_t*spi_device_handle_t;///< Handle for a device on a SPI bus