|
oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
|
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. | |
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.
| int ove_hal_spi_open | ( | ove_spi_t | spi, |
| const struct ove_spi_cfg * | cfg | ||
| ) |
Configure and enable the SPI peripheral.
| [in] | spi | SPI handle with storage already assigned. |
| [in] | cfg | Bus configuration descriptor. |
| void ove_hal_spi_close | ( | ove_spi_t | spi | ) |
Disable and release the SPI peripheral.
| [in] | spi | SPI handle. |
| 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.
| [in] | spi | SPI handle. |
| [in] | tx | Transmit buffer, or NULL. |
| [out] | rx | Receive buffer, or NULL. |
| [in] | len | Number of bytes to transfer. |
| [in] | timeout_ns | Maximum wait time. |
| 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.
| [in] | spi | SPI 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] | tx | Transmit buffer (may be NULL for read-only). |
| [in] | rx | Receive buffer (may be NULL for write-only). |
| [in] | len | Bytes to transfer. |
| 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).
| [in] | spi | SPI handle the transfer was submitted on. |
| [in] | result | OVE_OK on success, negative error code on failure. |