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 of device_config (one entry per chip select, each with a cs_logical_id). A target channel has a single device_config and no cs_ctrl.

  • Chip-select control is per controller: ViaHW lets the SPI hardware drive CS; ViaGPIO makes the driver call Spi_Callout_CsControl so the integration code toggles the CS line.

  • Event handling is per channel. With Polling you must call Spi_PollFunction cyclically; with Interrupt the driver services events in Spi_Interrupt.

  • Element widthdata_width sets the transfer element size; the driver casts the buffer elements accordingly (see Concepts).