// Autogenerated C header file for GPIO
#ifndef _JACDAC_SPEC_GPIO_H
#define _JACDAC_SPEC_GPIO_H 1

#define JD_SERVICE_CLASS_GPIO  0x10d85a69

// enum Mode (uint8_t)
#define JD_GPIO_MODE_OFF 0x0
#define JD_GPIO_MODE_OFF_PULL_UP 0x10
#define JD_GPIO_MODE_OFF_PULL_DOWN 0x20
#define JD_GPIO_MODE_INPUT 0x1
#define JD_GPIO_MODE_INPUT_PULL_UP 0x11
#define JD_GPIO_MODE_INPUT_PULL_DOWN 0x21
#define JD_GPIO_MODE_OUTPUT 0x2
#define JD_GPIO_MODE_OUTPUT_HIGH 0x12
#define JD_GPIO_MODE_OUTPUT_LOW 0x22
#define JD_GPIO_MODE_ANALOG_IN 0x3
#define JD_GPIO_MODE_ALTERNATIVE 0x4
#define JD_GPIO_MODE_BASE_MODE_MASK 0xf

// enum Capabilities (uint16_t)
#define JD_GPIO_CAPABILITIES_PULL_UP 0x1
#define JD_GPIO_CAPABILITIES_PULL_DOWN 0x2
#define JD_GPIO_CAPABILITIES_INPUT 0x4
#define JD_GPIO_CAPABILITIES_OUTPUT 0x8
#define JD_GPIO_CAPABILITIES_ANALOG 0x10

/**
 * Read-only digital_values bytes. For every pin set to `Input*` the corresponding **bit** in `digital_values` will be `1` if and only if
 * the pin is high.
 * For other pins, the bit is `0`.
 * This is normally streamed at low-ish speed, but it's also automatically reported whenever
 * a digital input pin changes value (throttled to ~100Hz).
 * The analog values can be read with the `ADC` service.
 */
#define JD_GPIO_REG_STATE JD_REG_READING

/**
 * Read-only # uint8_t. Number of pins that can be operated through this service.
 */
#define JD_GPIO_REG_NUM_PINS 0x180

/**
 * Configure (including setting the value) zero or more pins.
 * `Alternative` settings means the pin is controlled by other service (SPI, I2C, UART, PWM, etc.).
 */
#define JD_GPIO_CMD_CONFIGURE 0x80
typedef struct jd_gpio_configure {
    uint8_t pin;
    uint8_t mode;  // Mode
} jd_gpio_configure_t;


/**
 * Argument: pin uint8_t. Report capabilities and name of a pin.
 */
#define JD_GPIO_CMD_PIN_INFO 0x81

/**
 * Report: 
 */
typedef struct jd_gpio_pin_info_report {
    uint8_t pin;
    uint8_t hw_pin;
    uint16_t capabilities;  // Capabilities
    uint8_t mode;  // Mode
    char label[0];  // string
} jd_gpio_pin_info_report_t;


/**
 * Argument: label string (bytes). This responds with `pin_info` report.
 */
#define JD_GPIO_CMD_PIN_BY_LABEL 0x83

/**
 * Report: 
 */
typedef struct jd_gpio_pin_by_label_report {
    uint8_t pin;
    uint8_t hw_pin;
    uint16_t capabilities;  // Capabilities
    uint8_t mode;  // Mode
    char label[0];  // string
} jd_gpio_pin_by_label_report_t;


/**
 * Argument: hw_pin uint8_t. This responds with `pin_info` report.
 */
#define JD_GPIO_CMD_PIN_BY_HW_PIN 0x84

/**
 * Report: 
 */
typedef struct jd_gpio_pin_by_hw_pin_report {
    uint8_t pin;
    uint8_t hw_pin;
    uint16_t capabilities;  // Capabilities
    uint8_t mode;  // Mode
    char label[0];  // string
} jd_gpio_pin_by_hw_pin_report_t;


#endif
