doc: 'This is a sample configuration file. It''s written in YAML because that''s structured
  and easy to read.

  The "cfg" program can extract single entries from this. It will concatenate list
  entries and convert hashes to C flags definitions.

  ''_ref'' means that whatever key is not here is looked up there, so the value of
  test.1.foo is ''bar''. ''_default'' does the same thing, except that the key is
  skipped, so the value of test.1.foo.seven is ''six''.

  ''targets:'' lists the devices that are built by default.

  "cfg <file> .cdefs DEVICE" generates -DXXX=yy command-line arguments.

  "cfg <file> .cfiles DEVICE" lists the input files required for building.

  "cfg <file> .type DEVICE" generates "foo N" stanzas for gen_eeprom''s "type" entry.

  "cfg <file> .hdr DEVICE" generates the file ''device/DEVICE/dev_config.h''.

  The "cfg_write" program updates or adds values. It does not follow ''_ref'' links
  and ''_default'' entries, so only specific values will be overwritten.'
test:
- foo:
    one: two
    three: four
    _default: six
  baz: quux
- _ref: test.0
  ever:
  - you say
  - too
  foo:
    one: five
env:
  prog: usbtiny
  avrdude: sudo avrdude
codes:
  _doc: Do not modify! These are also used by OWFS.
  onewire:
    moat: F0
    boot: F1
    ds2408: 29
    ds2423: 1D
  blocks:
  - _list
  - _nums
  - euid
  - rf12
  - crypto
  - owid
  - type
  - name
  - loader
  types:
  - config
  - alert
  - status
  - console
  - port
  - pwm
  - count
  - adc
  - temp
  - humid
  - pid
  - smoke
  status:
  - _nums
  - reboot
  - loader
_doc:
  codes:
    _doc: 'constants for code generation.

      NOTE: These values are also defined in OWFS at module/owlib/src/include/ow_moat.h.'
    blocks: data types in EPROM, 0-based, values starting with an underscore are special
    types: Message types on the bus, 0-based
    onewire: unique 1wire ID (starts with 'x' to prevent interpretation as a number,
      in case all hex digits happen to be 0-9)
  devices:
    NAME:
      defs:
        have_uart: Use serial port
        have_uart_irq: Use interrupt-based serial (otherwise poll)
        have_uart_sync: Don't buffer serial data (no IRQ, no polling, severe delays)
        have_timer: setup timer interrupt
        have_tov0: for the IRQ catcher
        have_watchdog: enable the watchdog timer (longest possible timeout)
        debug_uart: debug UART IRQ/poll
        debug_eeprom: debug EEPROM code
        debug_onewire: low-level debug onewire comms
        uart_debug: send debug output to the serial port
        console_debug: send debug output to the console
        console_write: 'send to the console buf via 1wire (good for testing); 2: interpret
          commands'
        console_ping: send a '!' every console_ping tenths-of-a-second
        have_dbg_port: Use a port for diag code output
        have_dbg_pin: Use a port for diag signalling
        is_onewire: OW type (moat, ds2408, ds2423)
        is_bootloader: build a reprogrammable version
        use_bootloader: build code to load onto a reprogrammable version
        use_eeprom: Store writeable config in EEPROM. 1:EEPROM-only, 2:initial load from flash
        use_eeprom_crc: additional CRC check for EEPROM contents
        conditional_search: Make 1wire device discoverable conditionally (alarms,
          changes etc.)
        single_device: Add 1wire code for SKIP_ROM and READ_ROM
        need_bits: code needs to read/write single bits on 1wire bus
        onewire_io: hardware pin to use for 1wire
        use_adc_as_digital: do not disable digital logic for ADC pins used as ADC (affects all ADC pins)
      pin_irq: 'mapping from pin to INT/PCINT. negative: INT(-n-1), otherwise PCINT(n+pin)'
      types:
        _doc:
        - Emitted as N_XXX=y definitions for y>0 with ".cdefs"
        - Emitted as "name
        - also see OWFS: ow_moat.h
        console: channel present? (only one is supported)
        port: binary inputs and outputs
        temp: temperature sensors
        humid: humidity sensors
        adc: analog-to-digital converters
        pid: autonomous PID controllers
        pwm: outputs that are PWM controlled, i.e. poor man's DAC
        smoke: interfaces with Gira Dual detector
        count: transition counter
      port:
      - Port to read/write by default. Like "B2" or "D0". Indexed by port number
      - '''^'' : A: 1: output high'
      - '''_'' : B: 0: output low'
      - '''+'' : C: 1: pull-up resistor'
      - '''~'' : D: 0: high-impedance'
      - 'Standard behavior: switch between states A/B and C/D when writing 0/1.'
      - Add / to switch A/D and B/C instead.
      - Add ! to switch A/C and B/D instead. (In that case, CD is 'high'.)
      - Add * to alert on state change. Setting a port sets the expected state to
        whatever you write.
      - 'Note: If some pins are unused, it is recommended to ensure that these pins
        have a defined level to reduce current consumption.
        The way to do this with the MOAT device is to make them a "port"
        input with pull-up enabled (suffix +).'
      pwm:
      - Number of the port to manage
      - Add * to alert if the PWM stops (zero value, i.e. one-shot)
      - Add ! to immediately switch if PWM is set
      count:
      - Number of the port to count transitions on. Default count both rising/falling edges.
      - Add * to alert on counter change.
      - Add + to only trigger on rising edges.
      - Add - to only trigger on falling edges.
      adc:
      - 0…7: Analog input pin to read
      - G: read ground pin (to measure ADC offset)
      - R: read bandgap voltage (Do not use "R-", that obviously makes no sense)
      - T: read temperature sensor (Do use "T-" instead of "T")
      - '-': use bandgap voltage (Vbg) as reference (~1.1V)
      temp:
      - 'Device to read.'
      - 'Format: driver=number'
      - drivers:
        dummy: 'test, doesn''t do much'
      - Add * to alert on value outside thresholds
mcu:
  _default:
    _doc: 'The default matches the ATmega 88/168/328, mostly'
    defs:
      onewire_io: D2
    pin_irq:
      D2: -1
      D3: -2
      B: 0
      C: 8
      D: 16
  tiny13:
    _doc: incomplete and untested
    defs:
      onewire_io: B1
  tiny84:
    _doc: untested for some time
    mcu: attiny84
    flash:
      size: 8
    prog: t84
    defs:
      onewire_io: B2
  tiny85:
    _doc: untested for some time
    mcu: attiny85
    flash:
      size: 8
    prog: t85
    defs:
      onewire_io: B1
  mega8:
    mcu: atmega8
    prog: m8
    flash:
      size: 8
      align: 32
  mega88:
    mcu: atmega88
    prog: m88
    flash:
      size: 8
      align: 32
  mega168:
    mcu: atmega168
    prog: m168
    flash:
      size: 16
  mega328:
    mcu: atmega328
    prog: m328
    flash:
      size: 32
defaults:
  flags: null
  types:
    config: -1
    alert: -1
    console: 0
    port: 0
    temp: 0
    humid: 0
    adc: 0
    pid: 0
    pwm: 0
    smoke: 0
    count: 0
  target:
    _default:
      defs:
        is_onewire: moat
        is_bootloader: 0
        use_bootloader: 0
        have_uart: 0
        use_eeprom: 1
        conditional_search: 1
        single_device: 1
        have_timer: 1
        have_watchdog: 0
        have_uart_irq: 0
        have_irq_catcher: 0
        have_dbg_port: 0
        have_dbg_pin: 0
        have_tov0: 1
        console_ping: 0
    m168:
      _doc: basic atmega168 with internal crystal
      _ref: mcu.mega168
    heiz:
      _doc: m88 controlling heating
      _ref: defaults.target.m88
      types:
        console: 1
        port: 6
        pwm: 2
      port:
        1: B2_
        2: B1_
        3: C0~
        4: C1~
        5: C2~
        6: C3~
    t85:
      _doc: basic attiny85 with internal crystal
      _ref: mcu.tiny85
      defs:
        f_cpu: 8000000
        have_timer: 0
        have_dbg_port: 0
        have_dbg_pin: 0
      types:
        pwm: 0
      fuse:
        l: xE2
        h: xFF
        e: x01
        _doc: fuse.e might have to be xFF, depending on what the unused bits do
      port:
        1: B0~
        2: B1~
        3: B3~
        4: B4~
        5: B5~
      count:
        1: 1
        2: 2
        3: 3
        4: 4
        5: 5
      adc:
        1: 2
        2: 3
        3: 4
    m8x_base:
      _doc: basic atmega8/atmega88, to be extended
      defs:
        f_cpu: 8000000
      port:
        1: B0~
        2: B1~
        3: B2~
        4: B3~
        5: B4~
        6: B5~
        7: D3~
        8: D4~
        9: D5~
        10: D6~
        11: D7~
        12: C0~
        13: C1~
        14: C2~
        15: C3~
        16: C4~
        17: C5~
        18: C6~
        19: B6~
        20: B7~
      pwm:
        1: 1
        2: 2
        3: 3
        4: 4
        5: 5
        6: 6
        7: 7
        8: 8
        9: 9
      count:
        1: 1
        2: 2
        3: 3
        4: 4
        5: 5
        6: 6
        7: 7
        8: 8
        9: 9
      adc:
        1: 0
        2: 1
        3: 2
        4: 3
        5: 4
        6: 5
        7: 6
        8: 7
        9: T-
        10: R
        11: G
    m8:
      _doc: basic atmega8 with internal crystal
      _ref:
        - defaults.target.m8x_base
        - mcu.mega8
      defs:
        have_timer: 0
    m88:
      _doc: basic atmega88 with internal crystal
      _ref:
        - defaults.target.m8x_base
        - mcu.mega88
      fuse:
        l: xE2
        h: xDC
        e: x00
        _doc: fuse.e might have to be xF8, depending on what the unused bits do
    m88f:
      _doc: version of m88 with external crystal
      _ref: defaults.target.m88
      defs:
        f_cpu: 20000000
      fuse:
        l: FF
devices:
  test_ser:
    defs:
      have_uart: 1
      have_uart_irq: 0
      have_uart_sync: 1
      have_irq_catcher: 0
      have_dbg_port: 1
      have_dbg_pin: 1
      have_tov0: 0
      is_onewire: 0
      uart_debug: 1
    code:
    - test
  test2:
    _ref: devices.test
    defs:
      is_onewire: ds2408
      conditional_search: 1
    onewire_id: xdbff6af36f26
  heiz1:
    _doc: Test board for heating, v2.7
    _ref: defaults.target.heiz
    onewire_id: x94b934ca233f
  test85:
    _doc: Test build for ATtiny85
    _ref: defaults.target.t85
    port:
      _doc: 'Test setup: B0 is connected to B3'
      1: B0_
      2: B1^
      3: B3+*
    count:
      1: 3*
      2: 4*+
    pwm:
      _doc: just to mix things up a bit ;-)
      1: 2
      2: 1
    adc:
      _doc: This switches between reference voltages. Connect ADC0 to B0 via a slow
        R-C network (10 µF @ 1 MOhm)
      1: R
      2: T
      3: T-
      4: 2*
    types:
      console: 1
      port: 3
      count: 2
      adc: 4
      status: 1
    onewire_id: x43b794f48007
  test:
    _doc: '"test8"-Boarduino, using 16MHz crystal osc'
    _ref: devices.test8
    defs:
      f_cpu: 16000000
    fuse:
      l: DE
    onewire_id: x4cff5504bd15
  test8b:
    _doc: '"test8"-Boarduino, reprogrammable'
    _ref: devices.test8
    defs:
      is_bootloader: 1
    onewire_id: x2a87d2ef670b
  test8bc:
    _doc: '"test8"-Boarduino, code for reprogrammable'
    _ref: devices.test8b
    defs:
      use_bootloader: test8b
    onewire_id: x2a87d2ef670c
  test8:
    _doc: 'Boarduino, ~8MHz internal osc. Ports used: D0+D1 serial  D2 1wire  D3 debug-bit  C0-C4
      debug-nibble(and a bit)  C5 analog test input   B3-B5,C6 Programmer '
    defs:
      have_uart: 1
      have_uart_irq: 0
      have_uart_sync: 1
      have_dbg_port: 0
      have_dbg_pin: 0
      have_irq_catcher: 0
      have_watchdog: 0
      console_write: 2
      debug_uart: 0
      debug_eeprom: 0
      debug_onewire: 0
      console_debug: 0
      uart_debug: 1
      console_ping: 0
      use_eeprom: 2
    onewire_id: x947476a5f130
    fuse:
      h: xDC
    port:
      _doc: 'Test setup: B0 is connected to D6, B1 to D7'
      1: B0_
      2: B1^
      3: D6+*
      4: D7~*
    count:
      1: 3*
      2: 4*
    pwm:
      _doc: just to mix things up a bit ;-)
      1: 2
      2: 1
    adc:
      _doc: This switches between reference voltages. Connect ADC0 to B0 via a slow
        R-C network (10 µF @ 1 MOhm)
      1: R
      2: T
      3: T-
      4: 5*
    temp:
      - dummy=1
      - dummy=10
    types:
      console: 1
      port: 4
      pwm: 2
      count: 2
      adc: 4
      status: 1
      temp: 2
  _default:
    _ref: defaults.target.m88
    types:
      _ref: defaults.types
    code: []
  two:
    _ref: defaults.target.m88f
  one:
    onewire_id: x7b034e8262c2
  test_ds2408:
    defs:
      is_onewire: ds2408
      conditional_search: 0
    onewire_id: x3ed0badc460f
  test_ds2423:
    defs:
      is_onewire: ds2423
    onewire_id: xcacf2c9d0fef
  test_ds2423_m8:
    _ref: defaults.target.m8
    defs:
      analog: 1
      is_onewire: ds2423
    onewire_id: x13390287799c
  load88:
    _ref: defaults.target.m88
    defs:
      is_bootloader: 1
      is_onewire: boot
      have_uart: 0
      use_eeprom: 0
      conditional_search: 0
      single_device: 0
      have_timer: 0
      have_watchdog: 0
    onewire_id: x07d4aab6c972
  test88:
    _ref: devices.test8
    defs:
      use_eeprom: 2
    onewire_id: x2fb6640aae69
targets:
- test
- one
- two
