static void spi_worker_thread_finished(void *data) { struct sol_spi *spi = data; spi->transfer.worker = NULL; spi_transfer_dispatch(spi); }
static bool spi_timeout_cb(void *data) { struct sol_spi *spi = data; spi_transfer(spi, spi->transfer.tx, spi->transfer.rx, spi->transfer.count); spi->transfer.timeout = NULL; spi_transfer_dispatch(spi); return false; }
SOL_API void sol_spi_close(struct sol_spi *spi) { SOL_NULL_CHECK(spi); if (spi->transfer.timeout) { sol_timeout_del(spi->transfer.timeout); spi_transfer_dispatch(spi); } spi_poweroff(spi->bus); free(spi); }
SOL_API void sol_spi_close(struct sol_spi *spi) { SOL_NULL_CHECK(spi); #ifdef PTHREAD if (spi->transfer.worker) { sol_worker_thread_cancel(spi->transfer.worker); } #else if (spi->transfer.timeout) { sol_timeout_del(spi->transfer.timeout); spi_transfer_dispatch(spi); } #endif close(spi->fd); free(spi); }
static bool spi_timeout_cb(void *data) { struct sol_spi *spi = data; int ret; spi_acquire(spi->bus); gpio_clear(spi->cs_pin); ret = spi_transfer_bytes(spi->bus, (char *)spi->transfer.tx, (char *)spi->transfer.rx, spi->transfer.count); gpio_set(spi->cs_pin); spi_release(spi->bus); spi->transfer.status = ret; spi->transfer.timeout = NULL; spi_transfer_dispatch(spi); return false; }