[−][src]Function esp_idf_sys::spicommon_bus_initialize_io
pub unsafe extern "C" fn spicommon_bus_initialize_io(
host: spi_host_device_t,
bus_config: *const spi_bus_config_t,
dma_chan: c_int,
flags: u32,
flags_o: *mut u32
) -> esp_err_t
@brief Connect a SPI peripheral to GPIO pins
This routine is used to connect a SPI peripheral to the IO-pads and DMA channel given in the arguments. Depending on the IO-pads requested, the routing is done either using the IO_mux or using the GPIO matrix.
@param host SPI peripheral to be routed
@param bus_config Pointer to a spi_bus_config struct detailing the GPIO pins
@param dma_chan DMA-channel (1 or 2) to use, or 0 for no DMA.
@param flags Combination of SPICOMMON_BUSFLAG_* flags, set to ensure the pins set are capable with some functions:
- SPICOMMON_BUSFLAG_MASTER
: Initialize I/O in master mode
- SPICOMMON_BUSFLAG_SLAVE
: Initialize I/O in slave mode
- SPICOMMON_BUSFLAG_NATIVE_PINS
: Pins set should match the iomux pins of the controller.
- SPICOMMON_BUSFLAG_SCLK
, SPICOMMON_BUSFLAG_MISO
, SPICOMMON_BUSFLAG_MOSI
:
Make sure SCLK/MISO/MOSI is/are set to a valid GPIO. Also check output capability according to the mode.
- SPICOMMON_BUSFLAG_DUAL
: Make sure both MISO and MOSI are output capable so that DIO mode is capable.
- SPICOMMON_BUSFLAG_WPHD
Make sure WP and HD are set to valid output GPIOs.
- SPICOMMON_BUSFLAG_QUAD
: Combination of SPICOMMON_BUSFLAG_DUAL
and SPICOMMON_BUSFLAG_WPHD
.
@param[out] flags_o A SPICOMMON_BUSFLAG_* flag combination of bus abilities will be written to this address.
Leave to NULL if not needed.
- SPICOMMON_BUSFLAG_NATIVE_PINS
: The bus is connected to iomux pins.
- SPICOMMON_BUSFLAG_SCLK
, SPICOMMON_BUSFLAG_MISO
, SPICOMMON_BUSFLAG_MOSI
: The bus has
CLK/MISO/MOSI connected.
- SPICOMMON_BUSFLAG_DUAL
: The bus is capable with DIO mode.
- SPICOMMON_BUSFLAG_WPHD
The bus has WP and HD connected.
- SPICOMMON_BUSFLAG_QUAD
: Combination of SPICOMMON_BUSFLAG_DUAL
and SPICOMMON_BUSFLAG_WPHD
.
@return
- ESP_ERR_INVALID_ARG if parameter is invalid
- ESP_OK on success