oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
Functions
HAL SPI Interface

Hardware Abstraction Layer interface for SPI bus operations. More...

Functions

int ove_hal_spi_open (ove_spi_t spi, const struct ove_spi_cfg *cfg)
 Configure and enable the SPI peripheral.
 
void ove_hal_spi_close (ove_spi_t spi)
 Disable and release the SPI peripheral.
 
int ove_hal_spi_transfer (ove_spi_t spi, const void *tx, void *rx, size_t len, uint64_t timeout_ns)
 Full-duplex SPI data transfer.
 
int ove_hal_spi_transfer_async (ove_spi_t spi, const void *tx, void *rx, size_t len)
 Submit an async SPI transfer.
 
void ove_spi_async_complete (ove_spi_t spi, int result)
 Completion notification from the HAL.
 

Detailed Description

Hardware Abstraction Layer interface for SPI bus operations.

Declares the low-level SPI functions that every platform HAL must implement. The portable SPI layer handles bus locking and chip-select management before delegating to these functions.

Function Documentation

◆ ove_hal_spi_open()

int ove_hal_spi_open ( ove_spi_t  spi,
const struct ove_spi_cfg cfg 
)

Configure and enable the SPI peripheral.

Parameters
[in]spiSPI handle with storage already assigned.
[in]cfgBus configuration descriptor.
Returns
OVE_OK on success, negative error code on failure.

◆ ove_hal_spi_close()

void ove_hal_spi_close ( ove_spi_t  spi)

Disable and release the SPI peripheral.

Parameters
[in]spiSPI handle.

◆ ove_hal_spi_transfer()

int ove_hal_spi_transfer ( ove_spi_t  spi,
const void *  tx,
void *  rx,
size_t  len,
uint64_t  timeout_ns 
)

Full-duplex SPI data transfer.

Called under the bus mutex, with CS already asserted by the portable layer. tx or rx may be NULL for half-duplex.

Parameters
[in]spiSPI handle.
[in]txTransmit buffer, or NULL.
[out]rxReceive buffer, or NULL.
[in]lenNumber of bytes to transfer.
[in]timeout_nsMaximum wait time.
Returns
OVE_OK on success, negative error code on failure.

◆ ove_hal_spi_transfer_async()

int ove_hal_spi_transfer_async ( ove_spi_t  spi,
const void *  tx,
void *  rx,
size_t  len 
)

Submit an async SPI transfer.

Optional HAL hook. The portable layer calls this only when CONFIG_OVE_ASYNC is enabled. CS is asserted by the portable layer beforehand.

Backends must call ove_spi_async_complete with the transfer result when the operation finishes. The portable layer then deasserts CS, clears the busy flag, and invokes the user callback.

Backends without native DMA support may implement this via a worker thread (POSIX/NuttX), Zephyr signal API, or return OVE_ERR_NOT_SUPPORTED in zero-heap modes that cannot allocate the worker resources.

Parameters
[in]spiSPI handle (transfer params can be stashed in the pending_tx / pending_rx / pending_len storage fields when the HAL needs to defer the work).
[in]txTransmit buffer (may be NULL for read-only).
[in]rxReceive buffer (may be NULL for write-only).
[in]lenBytes to transfer.
Returns
OVE_OK if accepted, negative error code on submission failure (no completion in that case).

◆ ove_spi_async_complete()

void ove_spi_async_complete ( ove_spi_t  spi,
int  result 
)

Completion notification from the HAL.

Called by the HAL backend (from worker thread or DMA ISR) when an async transfer finishes. The portable layer takes care of CS deassert, busy-flag clear, and user callback dispatch.

Safe to call from ISR context (no mutex unlock, no allocation).

Parameters
[in]spiSPI handle the transfer was submitted on.
[in]resultOVE_OK on success, negative error code on failure.