Configuration
Informative
A worked SPI channel configuration, using the YAML configuration model (the toolchain and file format are implementation-defined). The full property tables are in Configuration Reference; the binding rule is CHI-SPI-MUST-23.
Controller and target channels
Each channel is configured as either a controller or a target — the node_type selects which
properties apply. A controller channel carries a clock_divider, a cs_ctrl choice, and a
list of external devices (one per chip select); a target channel carries a single device
configuration.
general:
enable_development_error_reporting: true
config_set:
- config_set_name: "SpiCfg"
channel:
- node_type: "Controller"
channel_id: 0
hw_channel: 0
event_handling_mode: "Interrupt" # or "Polling"
data_width: 8 # bits per transfer element [1, 32]
bit_order: "MSBFirst" # or "LSBFirst"
default_data: 0xFF # sent when a TX buffer pointer is null
clock_divider: 16 # derives the SPI bitrate
cs_ctrl: "ViaHW" # or "ViaGPIO" (Spi_Callout_CsControl)
device_config:
- cs_hw_id: 0
cs_polarity: "Low"
data_shift_edge: "Leading"
shift_clock_idle_level: "Low"
cs_logical_id: 0 # csId used in the API call
- node_type: "Target"
channel_id: 1
hw_channel: 1
event_handling_mode: "Polling"
data_width: 8
bit_order: "MSBFirst"
default_data: 0x00
device_config:
cs_hw_id: 0
cs_polarity: "Low"
data_shift_edge: "Leading"
shift_clock_idle_level: "Low"
Notes
Controller vs target properties differ. A controller channel has
clock_divider,cs_ctrl, and a list ofdevice_config(one entry per chip select, each with acs_logical_id). A target channel has a singledevice_configand nocs_ctrl.Chip-select control is per controller:
ViaHWlets the SPI hardware drive CS;ViaGPIOmakes the driver callSpi_Callout_CsControlso the integration code toggles the CS line.Event handling is per channel. With
Pollingyou must callSpi_PollFunctioncyclically; withInterruptthe driver services events inSpi_Interrupt.Element width —
data_widthsets the transfer element size; the driver casts the buffer elements accordingly (see Concepts).