Lines Matching refs:host_id
42 .host_id = 0, \
55 int host_id; member
178 static esp_err_t alloc_dma_chan(spi_host_device_t host_id, spi_dma_chan_t dma_chan, uint32_t *out_a… in alloc_dma_chan() argument
180 assert(is_valid_host(host_id)); in alloc_dma_chan()
184 assert(dma_chan == (int)host_id || dma_chan == SPI_DMA_CH_AUTO); in alloc_dma_chan()
201 success = claim_dma_chan(host_id, &actual_dma_chan); in alloc_dma_chan()
215 connect_spi_and_dma(host_id, *out_actual_tx_dma_chan); in alloc_dma_chan()
221 static esp_err_t alloc_dma_chan(spi_host_device_t host_id, spi_dma_chan_t dma_chan, uint32_t *out_a… in alloc_dma_chan() argument
223 assert(is_valid_host(host_id)); in alloc_dma_chan()
227 spicommon_bus_context_t *ctx = bus_ctx[host_id]; in alloc_dma_chan()
248 if (host_id == SPI2_HOST) { in alloc_dma_chan()
253 else if (host_id == SPI3_HOST) { in alloc_dma_chan()
266 esp_err_t spicommon_dma_chan_alloc(spi_host_device_t host_id, spi_dma_chan_t dma_chan, uint32_t *ou… in spicommon_dma_chan_alloc() argument
268 assert(is_valid_host(host_id)); in spicommon_dma_chan_alloc()
272 assert(dma_chan == (int)host_id || dma_chan == SPI_DMA_CH_AUTO); in spicommon_dma_chan_alloc()
283 bus_ctx[host_id] = ctx; in spicommon_dma_chan_alloc()
284 ctx->host_id = host_id; in spicommon_dma_chan_alloc()
286 ret = alloc_dma_chan(host_id, dma_chan, &actual_tx_dma_chan, &actual_rx_dma_chan); in spicommon_dma_chan_alloc()
304 esp_err_t spicommon_gdma_get_handle(spi_host_device_t host_id, gdma_channel_handle_t *gdma_handle, … in spicommon_gdma_get_handle() argument
306 assert(is_valid_host(host_id)); in spicommon_gdma_get_handle()
313 *gdma_handle = bus_ctx[host_id]->tx_channel; in spicommon_gdma_get_handle()
316 *gdma_handle = bus_ctx[host_id]->rx_channel; in spicommon_gdma_get_handle()
323 static esp_err_t dma_chan_free(spi_host_device_t host_id) in dma_chan_free() argument
325 assert(is_valid_host(host_id)); in dma_chan_free()
327 spicommon_bus_context_t *ctx = bus_ctx[host_id]; in dma_chan_free()
352 esp_err_t spicommon_dma_chan_free(spi_host_device_t host_id) in spicommon_dma_chan_free() argument
354 assert(is_valid_host(host_id)); in spicommon_dma_chan_free()
356 esp_err_t ret = dma_chan_free(host_id); in spicommon_dma_chan_free()
357 free(bus_ctx[host_id]); in spicommon_dma_chan_free()
358 bus_ctx[host_id] = NULL; in spicommon_dma_chan_free()
753 spi_bus_lock_handle_t spi_bus_lock_get_by_id(spi_host_device_t host_id) in spi_bus_lock_get_by_id() argument
755 return bus_ctx[host_id]->bus_attr.lock; in spi_bus_lock_get_by_id()
759 esp_err_t spi_bus_initialize(spi_host_device_t host_id, const spi_bus_config_t *bus_config, spi_dma… in spi_bus_initialize() argument
767 SPI_CHECK(is_valid_host(host_id), "invalid host_id", ESP_ERR_INVALID_ARG); in spi_bus_initialize()
768 SPI_CHECK(bus_ctx[host_id] == NULL, "SPI bus already initialized.", ESP_ERR_INVALID_STATE); in spi_bus_initialize()
772 …SPI_CHECK( dma_chan == SPI_DMA_DISABLED || dma_chan == (int)host_id || dma_chan == SPI_DMA_CH_AUTO… in spi_bus_initialize()
781 bool spi_chan_claimed = spicommon_periph_claim(host_id, "spi master"); in spi_bus_initialize()
790 bus_ctx[host_id] = ctx; in spi_bus_initialize()
791 ctx->host_id = host_id; in spi_bus_initialize()
798 err = alloc_dma_chan(host_id, dma_chan, &actual_tx_dma_chan, &actual_rx_dma_chan); in spi_bus_initialize()
823 .host_id = host_id, in spi_bus_initialize()
824 .cs_num = SOC_SPI_PERIPH_CS_NUM(host_id), in spi_bus_initialize()
839 …err = spicommon_bus_initialize_io(host_id, bus_config, SPICOMMON_BUSFLAG_MASTER | bus_config->flag… in spi_bus_initialize()
859 dma_chan_free(host_id); in spi_bus_initialize()
862 spicommon_periph_free(host_id); in spi_bus_initialize()
863 free(bus_ctx[host_id]); in spi_bus_initialize()
864 bus_ctx[host_id] = NULL; in spi_bus_initialize()
868 const spi_bus_attr_t* spi_bus_get_attr(spi_host_device_t host_id) in spi_bus_get_attr() argument
870 if (bus_ctx[host_id] == NULL) return NULL; in spi_bus_get_attr()
872 return &bus_ctx[host_id]->bus_attr; in spi_bus_get_attr()
875 esp_err_t spi_bus_free(spi_host_device_t host_id) in spi_bus_free() argument
877 if (bus_ctx[host_id] == NULL) { in spi_bus_free()
882 spicommon_bus_context_t* ctx = bus_ctx[host_id]; in spi_bus_free()
900 dma_chan_free(host_id); in spi_bus_free()
902 spicommon_periph_free(host_id); in spi_bus_free()
904 bus_ctx[host_id] = NULL; in spi_bus_free()
908 esp_err_t spi_bus_register_destroy_func(spi_host_device_t host_id, in spi_bus_register_destroy_func() argument
911 bus_ctx[host_id]->destroy_func = f; in spi_bus_register_destroy_func()
912 bus_ctx[host_id]->destroy_arg = arg; in spi_bus_register_destroy_func()