mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
spi-transfer: Add SPI transfer helper routines
These routines assume that any messages is composed of a write and/or read part. While the API allows sending and receiving as part of one messages/transfer, it does not permit full duplex operation where data is both send and received at the same time.
This commit is contained in:
committed by
Benjamin Berg
parent
b0d9d00762
commit
7fcce7891a
@@ -737,3 +737,56 @@ fpi_ssm_usb_transfer_with_weak_pointer_cb (FpiUsbTransfer *transfer,
|
||||
|
||||
fpi_ssm_usb_transfer_cb (transfer, device, weak_ptr, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_spi_transfer_cb:
|
||||
* @transfer: a #FpiSpiTransfer
|
||||
* @device: a #FpDevice
|
||||
* @unused_data: User data (unused)
|
||||
* @error: The #GError or %NULL
|
||||
*
|
||||
* Can be used in as a #FpiSpiTransfer callback handler to automatically
|
||||
* advance or fail a statemachine on transfer completion.
|
||||
*
|
||||
* Make sure to set the #FpiSsm on the transfer.
|
||||
*/
|
||||
void
|
||||
fpi_ssm_spi_transfer_cb (FpiSpiTransfer *transfer, FpDevice *device,
|
||||
gpointer unused_data, GError *error)
|
||||
{
|
||||
g_return_if_fail (transfer->ssm);
|
||||
|
||||
if (error)
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
else
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_spi_transfer_with_weak_pointer_cb:
|
||||
* @transfer: a #FpiSpiTransfer
|
||||
* @device: a #FpDevice
|
||||
* @weak_ptr: A #gpointer pointer to nullify. You can pass a pointer to any
|
||||
* #gpointer to nullify when the callback is completed. I.e a
|
||||
* pointer to the current #FpiSpiTransfer.
|
||||
* @error: The #GError or %NULL
|
||||
*
|
||||
* Can be used in as a #FpiSpiTransfer callback handler to automatically
|
||||
* advance or fail a statemachine on transfer completion.
|
||||
* Passing a #gpointer* as @weak_ptr permits to nullify it once we're done
|
||||
* with the transfer.
|
||||
*
|
||||
* Make sure to set the #FpiSsm on the transfer.
|
||||
*/
|
||||
void
|
||||
fpi_ssm_spi_transfer_with_weak_pointer_cb (FpiSpiTransfer *transfer,
|
||||
FpDevice *device, gpointer weak_ptr,
|
||||
GError *error)
|
||||
{
|
||||
g_return_if_fail (transfer->ssm);
|
||||
|
||||
if (weak_ptr)
|
||||
g_nullify_pointer ((gpointer *) weak_ptr);
|
||||
|
||||
fpi_ssm_spi_transfer_cb (transfer, device, weak_ptr, error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user