# Copyright (C) 2015-2021 Swift Navigation Inc.
# Contact: https://support.swiftnav.com
#
# This source is subject to the license found in the file 'LICENSE' which must
# be distributed together with this source. All other rights reserved.
#
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

package: swiftnav.sbp.ext_events
description: >
  Messages reporting accurately-timestamped external events,
  e.g. camera shutter time.
stable: True
public: True
include:
  - types.yaml
definitions:

 - MSG_EXT_EVENT:
    id: 0x0101
    short_desc: Reports timestamped external pin event
    desc: >
        Reports detection of an external event, the GPS time it occurred,
        which pin it was and whether it was rising or falling.
    fields:
        - wn:
            type: u16
            units: weeks
            desc: GPS week number
        - tow:
            type: u32
            units: ms
            desc: GPS time of week rounded to the nearest millisecond
        - ns_residual:
            type: s32
            units: ns
            desc: >
              Nanosecond residual of millisecond-rounded TOW (ranges
              from -500000 to 500000)
        - flags:
            type: u8
            desc: Flags
            fields:
              - 2-7:
                  desc: Reserved
              - 1:
                  desc: Time quality
                  values:
                      - 0: Unknown - don't have nav solution
                      - 1: Good (< 1 microsecond)
              - 0:
                  desc: New level of pin
                  values:
                      - 0: Low (falling edge)
                      - 1: High (rising edge)
        - pin:
            type: u8
            desc: Pin number.  0..9 = DEBUG0..9.
