|
Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
|
Vendor extension for the Analog Devices AXI SPI Engine. More...
#include <zephyr/device.h>#include <zephyr/sys/util_macro.h>#include <stdint.h>#include <stdbool.h>Go to the source code of this file.
Data Structures | |
| struct | spi_engine_offload_msg |
| Offload program description. More... | |
Macros | |
| #define | SPI_ENGINE_CMD_BUILD(_inst, _arg1, _arg2) |
| Build a raw SPI Engine command word. | |
| #define | SPI_ENGINE_CMD_BUILD_CONFIG_CLK_DIV(_div) |
Build a CONFIG command that sets the clock divider to _div. | |
| #define | SPI_ENGINE_MODE_CPHA BIT(0) |
| SPI_ENGINE_CMD_BUILD_CONFIG_MODE() bit: sample on the second clock edge. | |
| #define | SPI_ENGINE_MODE_CPOL BIT(1) |
| SPI_ENGINE_CMD_BUILD_CONFIG_MODE() bit: SCLK idles high. | |
| #define | SPI_ENGINE_CMD_BUILD_CONFIG_MODE(_mode) |
Build a CONFIG command that sets the SPI mode to _mode. | |
| #define | SPI_ENGINE_CMD_BUILD_CONFIG_XFER_BITS(_bits) |
Build a CONFIG command that sets the transfer width to _bits. | |
| #define | SPI_ENGINE_CMD_BUILD_READ_N_WORDS(_n) |
Build a TRANSFER command that reads _n words. | |
| #define | SPI_ENGINE_CMD_BUILD_WRITE_N_WORDS(_n) |
Build a TRANSFER command that writes _n words. | |
| #define | SPI_ENGINE_CMD_BUILD_WRITE_READ_N_WORDS(_n) |
Build a TRANSFER command that writes and reads _n words. | |
| #define | SPI_ENGINE_CMD_BUILD_CS_LOW SPI_ENGINE_CMD_BUILD(0x01, 0x03, 0x00) |
| Build a CHIPSELECT command that asserts (drives low) all chip-select lines. | |
| #define | SPI_ENGINE_CMD_BUILD_CS_HIGH SPI_ENGINE_CMD_BUILD(0x01, 0x03, 0xFF) |
| Build a CHIPSELECT command that deasserts (drives high) all chip-select lines. | |
| #define | SPI_ENGINE_CMD_BUILD_ASSERT(_cs_pattern) |
Build a CHIPSELECT command setting the CS lines to _cs_pattern (0 bit = asserted). | |
| #define | SPI_ENGINE_CMD_BUILD_SYNC(_id) |
Build a SYNC command carrying identifier _id. | |
| #define | SPI_ENGINE_CMD_BUILD_SLEEP(_cycles) |
Build a SLEEP command that idles for _cycles core clock cycles. | |
Functions | |
| int | spi_engine_offload_load (const struct device *dev, struct spi_engine_offload_msg *msg) |
| Load an offload command program into the SPI Engine. | |
| int | spi_engine_offload_enable (const struct device *dev, bool enable) |
| Enable or disable autonomous offload execution. | |
Vendor extension for the Analog Devices AXI SPI Engine.
In offload mode a fixed command program is loaded once into the core's command memory and replayed autonomously on every external trigger (e.g. a PWMGEN CNV pulse), streaming the captured SDI data to an AXI DMAC with no per-sample CPU cost.
Zephyr has no generic SPI-offload framework, so this is exposed as a driver-specific extension alongside the standard SPI controller API rather than through it. Register-mode transfers still use spi_transceive(); only the offload program setup lives here. The device handle is the SPI controller device itself.
| #define SPI_ENGINE_CMD_BUILD | ( | _inst, | |
| _arg1, | |||
| _arg2 ) |
Build a raw SPI Engine command word.
Bit layout: [14:12]=instruction, [10:8]=arg1, [7:0]=arg2. _arg1 MUST be 3-bit-masked to avoid SDO_LANE_CONFIG aliasing to CLK_DIV.
| _inst | Instruction field (3 bits). |
| _arg1 | First argument field (3 bits). |
| _arg2 | Second argument field (8 bits). |
| #define SPI_ENGINE_CMD_BUILD_ASSERT | ( | _cs_pattern | ) |
Build a CHIPSELECT command setting the CS lines to _cs_pattern (0 bit = asserted).
| #define SPI_ENGINE_CMD_BUILD_CONFIG_CLK_DIV | ( | _div | ) |
Build a CONFIG command that sets the clock divider to _div.
| #define SPI_ENGINE_CMD_BUILD_CONFIG_MODE | ( | _mode | ) |
Build a CONFIG command that sets the SPI mode to _mode.
_mode is a mask of SPI_ENGINE_MODE_* bits. These are ordered differently from Zephyr's SPI_MODE_CPOL/SPI_MODE_CPHA, so do not pass those flags.
| #define SPI_ENGINE_CMD_BUILD_CONFIG_XFER_BITS | ( | _bits | ) |
Build a CONFIG command that sets the transfer width to _bits.
| #define SPI_ENGINE_CMD_BUILD_CS_HIGH SPI_ENGINE_CMD_BUILD(0x01, 0x03, 0xFF) |
Build a CHIPSELECT command that deasserts (drives high) all chip-select lines.
| #define SPI_ENGINE_CMD_BUILD_CS_LOW SPI_ENGINE_CMD_BUILD(0x01, 0x03, 0x00) |
Build a CHIPSELECT command that asserts (drives low) all chip-select lines.
| #define SPI_ENGINE_CMD_BUILD_READ_N_WORDS | ( | _n | ) |
Build a TRANSFER command that reads _n words.
| #define SPI_ENGINE_CMD_BUILD_SLEEP | ( | _cycles | ) |
Build a SLEEP command that idles for _cycles core clock cycles.
| #define SPI_ENGINE_CMD_BUILD_SYNC | ( | _id | ) |
Build a SYNC command carrying identifier _id.
| #define SPI_ENGINE_CMD_BUILD_WRITE_N_WORDS | ( | _n | ) |
Build a TRANSFER command that writes _n words.
| #define SPI_ENGINE_CMD_BUILD_WRITE_READ_N_WORDS | ( | _n | ) |
Build a TRANSFER command that writes and reads _n words.
| #define SPI_ENGINE_MODE_CPHA BIT(0) |
SPI_ENGINE_CMD_BUILD_CONFIG_MODE() bit: sample on the second clock edge.
| #define SPI_ENGINE_MODE_CPOL BIT(1) |
SPI_ENGINE_CMD_BUILD_CONFIG_MODE() bit: SCLK idles high.
Enable or disable autonomous offload execution.
When enabled, the loaded program is replayed on every external trigger. Must be enabled before the first trigger arrives, otherwise the engine and the ADC drift out of frame.
A trigger is only accepted while offload is enabled and idle; triggers arriving while a program is running, or while offload is disabled, are dropped by the core, not queued. Disabling does not abort a program in progress: this call waits for it to complete. While offload is enabled, spi_transceive() on the same controller fails with -EBUSY.
| dev | SPI Engine controller device. |
| enable | true to start offload replay, false to stop. |
| 0 | on success. |
| -ETIMEDOUT | if a running program did not complete on disable. |
| int spi_engine_offload_load | ( | const struct device * | dev, |
| struct spi_engine_offload_msg * | msg ) |
Load an offload command program into the SPI Engine.
Resets the offload module and writes msg into the core's command (and optional SDO) memory. Does not start execution; call spi_engine_offload_enable() once the downstream DMAC is armed.
| dev | SPI Engine controller device (compatible "adi,axi-spi-engine"). |
| msg | Offload program to load. |