spi context: Add function for getting single transfer buffers length.
Added function helps setting the longest possible rx and tx buffers for single SPI transfer. Each of these buffers is a continuous memory region. It is useful for example when peripheral supports easyDMA. Signed-off-by: Michał Kruszewski <michal.kruszewski@nordicsemi.no>
This commit is contained in:
parent
ce80c9e42d
commit
ddef35c1da
1 changed files with 13 additions and 0 deletions
|
|
@ -254,6 +254,19 @@ bool spi_context_rx_on(struct spi_context *ctx)
|
|||
return !!(ctx->rx_buf || ctx->rx_len);
|
||||
}
|
||||
|
||||
static inline size_t spi_context_longest_current_buf(struct spi_context *ctx)
|
||||
{
|
||||
if (!ctx->tx_len) {
|
||||
return ctx->rx_len;
|
||||
} else if (!ctx->rx_len) {
|
||||
return ctx->tx_len;
|
||||
} else if (ctx->tx_len < ctx->rx_len) {
|
||||
return ctx->tx_len;
|
||||
}
|
||||
|
||||
return ctx->rx_len;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue