Hi Kevin,

On Mon, Jul 16, 2018 at 10:57:32PM +0200, Kevin Townsend wrote:
> I'm trying to add I2C support to the existing (SPI only) BME280 driver, 
> but I'm not sure how to enforce the following conditional restrictions 
> in the syscfg.yml file(s):
> 
>   * If BME280_SHELL_ITF_TYPE == 1, I2C_0 must be set
>   * If BME280_SHELL_ITF_TYPE == 0, SPI_0_MASTER must be set

It's a bit ugly, but this should do the trick:

    BME280_SHELL_ITF_TYPE:
        description: 'Shell interface type for the BME280'
        value: 0
        restrictions:
            - '(BME280_SHELL_ITF_TYPE && I2C_0) ||
               (!BME280_SHELL_ITF_TYPE && SPI_0_MASTER)'

(I think we should add support for an `I2C_0 if 0` notation here).

> How would you check the contents of a field, rather than simply testing 
> 'on' or 'off', and verify the appropriate transport is enabled?

You can use the <, <=, >=, >, and == operators to check contents.  The
first four operators coerce the setting value to an integer.  The `==`
operator converts a setting value to the same type as the other operand.

Examples:

    - BME280_LOG_MODULE     # True if not "", 0, or false.
    - BME280_LOG_MODULE < 100
    - CONSOLE_UART_BAUD == "UART_FLOW_CTL_NONE"

Chris

Reply via email to