spi: callback API for asynchronous transcieve
Adds a new spi_transcieve_cb API which enables asynchronous SPI transactions with callback notification. The exist spi_transcieve_async API remains and uses the new spi_transcieve_cb API to provide a k_poll_signal notifier. The driver API changes to provide a callback and userdata parameter to async transcieve. All drivers in the tree have been updated to the change. Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
This commit is contained in:
parent
096fc3b826
commit
4c20403629
28 changed files with 325 additions and 148 deletions
|
@ -95,7 +95,7 @@ static int spi_mcux_transfer_next_packet(const struct device *dev)
|
|||
/* nothing left to rx or tx, we're done! */
|
||||
LOG_DBG("spi transceive done");
|
||||
spi_context_cs_control(&data->ctx, false);
|
||||
spi_context_complete(&data->ctx, 0);
|
||||
spi_context_complete(&data->ctx, dev, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -675,7 +675,8 @@ static int transceive(const struct device *dev,
|
|||
const struct spi_buf_set *tx_bufs,
|
||||
const struct spi_buf_set *rx_bufs,
|
||||
bool asynchronous,
|
||||
struct k_poll_signal *signal)
|
||||
spi_callback_t cb,
|
||||
void *userdata)
|
||||
{
|
||||
struct spi_mcux_data *data = dev->data;
|
||||
int ret;
|
||||
|
@ -684,7 +685,7 @@ static int transceive(const struct device *dev,
|
|||
SPI_Type *base = config->base;
|
||||
#endif
|
||||
|
||||
spi_context_lock(&data->ctx, asynchronous, signal, spi_cfg);
|
||||
spi_context_lock(&data->ctx, asynchronous, cb, userdata, spi_cfg);
|
||||
|
||||
ret = spi_mcux_configure(dev, spi_cfg);
|
||||
if (ret) {
|
||||
|
@ -731,7 +732,7 @@ static int spi_mcux_transceive(const struct device *dev,
|
|||
const struct spi_buf_set *tx_bufs,
|
||||
const struct spi_buf_set *rx_bufs)
|
||||
{
|
||||
return transceive(dev, spi_cfg, tx_bufs, rx_bufs, false, NULL);
|
||||
return transceive(dev, spi_cfg, tx_bufs, rx_bufs, false, NULL, NULL);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPI_ASYNC
|
||||
|
@ -739,9 +740,10 @@ static int spi_mcux_transceive_async(const struct device *dev,
|
|||
const struct spi_config *spi_cfg,
|
||||
const struct spi_buf_set *tx_bufs,
|
||||
const struct spi_buf_set *rx_bufs,
|
||||
struct k_poll_signal *async)
|
||||
spi_callback_t cb,
|
||||
void *userdata)
|
||||
{
|
||||
return transceive(dev, spi_cfg, tx_bufs, rx_bufs, true, async);
|
||||
return transceive(dev, spi_cfg, tx_bufs, rx_bufs, true, cb, userdata);
|
||||
}
|
||||
#endif /* CONFIG_SPI_ASYNC */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue