crate: esp-hal

options:
- name: place-spi-master-driver-in-ram
  description: Places the SPI master driver in RAM for better performance
  default:
    - value: false

- name: place-switch-tables-in-ram
  description: "Places switch-tables, some lookup tables and constants related to
               interrupt handling into RAM - resulting in better performance but slightly more
               RAM consumption."
  default:
    - value: true
  stability: !Stable '1.0.0'

- name: place-anon-in-ram
  description: "Places anonymous symbols into RAM - resulting in better performance
               at the cost of significant more RAM consumption. Best to be combined with
               `place-switch-tables-in-ram`."
  default:
    - value: false
  stability: !Stable '1.0.0'

- name: place-rmt-driver-in-ram
  description: Places the RMT driver in RAM for better performance
  default:
    - value: false

# Ideally, we should be able to set any clock frequency for any chip. However,
# currently only the 32 and C2 implements any sort of configurability, and
# the rest have a fixed clock frequency.
- name: xtal-frequency
  description: "The frequency of the crystal oscillator, in MHz. Set to `auto` to
               automatically detect the frequency. `auto` may not be able to identify the clock
               frequency in some cases. Also, configuring a specific frequency may increase
               performance slightly."
  default:
    - if: 'chip == "esp32" || chip == "esp32c2"'
      value: '"auto"'
    - if: 'chip == "esp32c3" || chip == "esp32c6" || chip == "esp32s2" || chip == "esp32s3"'
      value: '"40"'
    - if: 'chip == "esp32h2"'
      value: '"32"'
  constraints:
    - if: 'chip == "esp32" || chip == "esp32c2"'
      type:
        validator: enumeration
        value:
        - 'auto'
        - '26'
        - '40'
    - if: 'chip == "esp32c3" || chip == "esp32c6" || chip == "esp32s2" || chip == "esp32s3"'
      type:
        validator: enumeration
        value:
        - '40'
    - if: 'chip == "esp32h2"'
      type:
        validator: enumeration
        value:
        - '32'
  active: 'chip == "esp32" || chip == "esp32c2"'

- name: spi-address-workaround
  description: "Enables a workaround for the issue where SPI in
               half-duplex mode incorrectly transmits the address on a single line if the
               data buffer is empty."
  default:
    - value: true
  active: 'chip == "esp32"'

- name: psram-mode
  description: SPIRAM chip mode
  default:
    - value: '"quad"'
  constraints:
    - if: 'feature("octal_psram")'
      type:
        validator: enumeration
        value:
        - 'quad'
        - 'octal'
    - if: '!feature("octal_psram")'
      type:
        validator: enumeration
        value:
        - 'quad'
  active: 'feature("psram")'

- name: stack-guard-offset
  description: The stack guard variable will be placed this many bytes from the stack's end. Needs to be a multiple of 4.
  default:
    - value: 60
  active: 'true'
  stability: !Stable '1.0.0'

- name: stack-guard-value
  description: The value to be written to the stack guard variable.
  default:
    - value: 3740121773
  display_hint: Hex

- name: stack-guard-monitoring
  description: Use a data watchpoint to check if the stack guard was overwritten.
  default:
    - value: true

- name: write-vec-table-monitoring
  description: Use a data watchpoint to check that the vector table was not unintentionally overwritten.
  default:
    - value: false
  active: 'chip == "esp32c2" || chip == "esp32c3" || chip == "esp32c6" || chip == "esp32h2"'

- name: stack-guard-monitoring-with-debugger-connected
  description: Enable the stack guard also with a debugger connected. Also applies to `write-vec-table-monitoring`.
  default:
    - value: true

- name: impl-critical-section
  description: "Provide a `critical-section` implementation. Note that if disabled,
               you will need to provide a `critical-section` implementation which is
               using `restore-state-u32`."
  default:
    - value: true

- name: instruction-cache-size
  description: Instruction cache size to be set on application startup.
  default:
    - value: '"32KB"'
  constraints:
    - type:
        validator: enumeration
        value:
          - '16KB'
          - '32KB'
  active: 'chip == "esp32s3"'

- name: instruction-cache-line-size
  description: Instruction cache line size to be set on application startup.
  default:
    - value: '"32B"'
  constraints:
    - type:
        validator: enumeration
        value:
          - '16B'
          - '32B'
  active: 'chip == "esp32s3"'

- name: icache-associated-ways
  description: Instruction cache associated ways to be set on application startup.
  default:
    - value: '"8"'
  constraints:
    - type:
        validator: enumeration
        value:
          - '4'
          - '8'
  active: 'chip == "esp32s3"'

- name: data-cache-size
  description: Data cache size to be set on application startup.
  default:
    - value: '"32KB"'
  constraints:
    - type:
        validator: enumeration
        value:
          - '16KB'
          - '32KB'
          - '64KB'
  active: 'chip == "esp32s3"'

- name: data-cache-line-size
  description: Data cache line size to be set on application startup.
  default:
    - value: '"32B"'
  constraints:
    - type:
        validator: enumeration
        value:
          - '16B'
          - '32B'
          - '64B'
  active: 'chip == "esp32s3"'

- name: dcache-associated-ways
  description: Data cache associated ways to be set on application startup.
  default:
    - value: '"8"'
  constraints:
    - type:
        validator: enumeration
        value:
          - '4'
          - '8'
  active: 'chip == "esp32s3"'

checks:
  - "ESP_HAL_CONFIG_STACK_GUARD_OFFSET % 4 == 0"
