/* Automatically generated nanopb header */
/* Generated by nanopb-0.4.9.1 */

#ifndef PB_TIDA010939_PB_H_INCLUDED
#define PB_TIDA010939_PB_H_INCLUDED
#include <everest/3rd_party/nanopb/pb.h>

#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif

/* Enum definitions */
typedef enum _CpState {
    CpState_STATE_A = 0,
    CpState_STATE_B = 1,
    CpState_STATE_C = 2,
    CpState_STATE_D = 3,
    CpState_STATE_E = 4,
    CpState_STATE_F = 5
} CpState;

typedef enum _ResetReason {
    ResetReason_USER = 0,
    ResetReason_WATCHDOG = 1
} ResetReason;

typedef enum _PpState {
    PpState_STATE_NC = 0,
    PpState_STATE_13A = 1,
    PpState_STATE_20A = 2,
    PpState_STATE_32A = 3,
    PpState_STATE_70A = 4,
    PpState_STATE_FAULT = 5
} PpState;

typedef enum _LockState {
    LockState_UNDEFINED = 0,
    LockState_UNLOCKED = 1,
    LockState_LOCKED = 2
} LockState;

/* Struct definitions */
typedef struct _ErrorFlags {
    bool diode_fault;
    bool rcd_selftest_failed;
    bool rcd_triggered;
    bool ventilation_not_available;
    bool connector_lock_failed;
    bool cp_signal_fault;
    bool over_current;
} ErrorFlags;

typedef struct _KeepAliveLo {
    uint32_t time_stamp;
    uint32_t hw_type;
    uint32_t hw_revision;
    uint32_t protocol_version_major;
    uint32_t protocol_version_minor;
    char sw_version_string[51];
    float hwcap_max_current;
    float hwcap_min_current;
    uint32_t hwcap_max_phase_count;
    uint32_t hwcap_min_phase_count;
    bool supports_changing_phases_during_charging;
} KeepAliveLo;

typedef struct _KeepAlive {
    uint32_t time_stamp;
    uint32_t hw_type;
    uint32_t hw_revision;
    char sw_version_string[51];
} KeepAlive;

typedef struct _Telemetry {
    float cp_voltage_hi;
    float cp_voltage_lo;
    float temp0;
    float temp1;
} Telemetry;

/* *
 This container message is send from MCU to EVerest and may contain any allowed message in that direction. */
typedef struct _McuToEverest {
    pb_size_t which_payload;
    union {
        KeepAliveLo keep_alive;
        ResetReason reset;
        CpState cp_state;
        /* false: relais are off, true: relais are on */
        bool relais_state;
        ErrorFlags error_flags;
        Telemetry telemetry;
        PpState pp_state;
        LockState lock_state;
    } payload;
} McuToEverest;

typedef struct _FirmwareUpdate {
    bool invoke_rom_bootloader;
} FirmwareUpdate;

typedef struct _RcdCommand {
    bool test; /* true -> set TEST pin high, false -> set TEST pin low */
    bool reset; /* reset RCD/emergency off if set to true */
} RcdCommand;

/* *
 This container message is send from EVerest to MCU and may contain any allowed message in that direction. */
typedef struct _EverestToMcu {
    pb_size_t which_payload;
    union {
        FirmwareUpdate firmware_update;
        KeepAlive keep_alive;
        /* false: unlock, true: lock */
        bool connector_lock;
        /* in 0.01 %, 0 = State F, 10000 = X1 */
        uint32_t pwm_duty_cycle;
        bool allow_power_on;
        bool reset;
        RcdCommand rcd_cmd;
    } payload;
} EverestToMcu;


#ifdef __cplusplus
extern "C" {
#endif

/* Helper constants for enums */
#define _CpState_MIN CpState_STATE_A
#define _CpState_MAX CpState_STATE_F
#define _CpState_ARRAYSIZE ((CpState)(CpState_STATE_F+1))

#define _ResetReason_MIN ResetReason_USER
#define _ResetReason_MAX ResetReason_WATCHDOG
#define _ResetReason_ARRAYSIZE ((ResetReason)(ResetReason_WATCHDOG+1))

#define _PpState_MIN PpState_STATE_NC
#define _PpState_MAX PpState_STATE_FAULT
#define _PpState_ARRAYSIZE ((PpState)(PpState_STATE_FAULT+1))

#define _LockState_MIN LockState_UNDEFINED
#define _LockState_MAX LockState_LOCKED
#define _LockState_ARRAYSIZE ((LockState)(LockState_LOCKED+1))


#define McuToEverest_payload_reset_ENUMTYPE ResetReason
#define McuToEverest_payload_cp_state_ENUMTYPE CpState
#define McuToEverest_payload_pp_state_ENUMTYPE PpState
#define McuToEverest_payload_lock_state_ENUMTYPE LockState








/* Initializer values for message structs */
#define EverestToMcu_init_default                {0, {FirmwareUpdate_init_default}}
#define McuToEverest_init_default                {0, {KeepAliveLo_init_default}}
#define ErrorFlags_init_default                  {0, 0, 0, 0, 0, 0, 0}
#define KeepAliveLo_init_default                 {0, 0, 0, 0, 0, "", 0, 0, 0, 0, 0}
#define KeepAlive_init_default                   {0, 0, 0, ""}
#define Telemetry_init_default                   {0, 0, 0, 0}
#define FirmwareUpdate_init_default              {0}
#define RcdCommand_init_default                  {0, 0}
#define EverestToMcu_init_zero                   {0, {FirmwareUpdate_init_zero}}
#define McuToEverest_init_zero                   {0, {KeepAliveLo_init_zero}}
#define ErrorFlags_init_zero                     {0, 0, 0, 0, 0, 0, 0}
#define KeepAliveLo_init_zero                    {0, 0, 0, 0, 0, "", 0, 0, 0, 0, 0}
#define KeepAlive_init_zero                      {0, 0, 0, ""}
#define Telemetry_init_zero                      {0, 0, 0, 0}
#define FirmwareUpdate_init_zero                 {0}
#define RcdCommand_init_zero                     {0, 0}

/* Field tags (for use in manual encoding/decoding) */
#define ErrorFlags_diode_fault_tag               1
#define ErrorFlags_rcd_selftest_failed_tag       2
#define ErrorFlags_rcd_triggered_tag             3
#define ErrorFlags_ventilation_not_available_tag 4
#define ErrorFlags_connector_lock_failed_tag     5
#define ErrorFlags_cp_signal_fault_tag           6
#define ErrorFlags_over_current_tag              7
#define KeepAliveLo_time_stamp_tag               1
#define KeepAliveLo_hw_type_tag                  2
#define KeepAliveLo_hw_revision_tag              3
#define KeepAliveLo_protocol_version_major_tag   4
#define KeepAliveLo_protocol_version_minor_tag   5
#define KeepAliveLo_sw_version_string_tag        6
#define KeepAliveLo_hwcap_max_current_tag        7
#define KeepAliveLo_hwcap_min_current_tag        8
#define KeepAliveLo_hwcap_max_phase_count_tag    9
#define KeepAliveLo_hwcap_min_phase_count_tag    10
#define KeepAliveLo_supports_changing_phases_during_charging_tag 11
#define KeepAlive_time_stamp_tag                 1
#define KeepAlive_hw_type_tag                    2
#define KeepAlive_hw_revision_tag                3
#define KeepAlive_sw_version_string_tag          6
#define Telemetry_cp_voltage_hi_tag              1
#define Telemetry_cp_voltage_lo_tag              2
#define Telemetry_temp0_tag                      3
#define Telemetry_temp1_tag                      4
#define McuToEverest_keep_alive_tag              1
#define McuToEverest_reset_tag                   2
#define McuToEverest_cp_state_tag                3
#define McuToEverest_relais_state_tag            4
#define McuToEverest_error_flags_tag             5
#define McuToEverest_telemetry_tag               6
#define McuToEverest_pp_state_tag                7
#define McuToEverest_lock_state_tag              8
#define FirmwareUpdate_invoke_rom_bootloader_tag 1
#define RcdCommand_test_tag                      1
#define RcdCommand_reset_tag                     2
#define EverestToMcu_firmware_update_tag         1
#define EverestToMcu_keep_alive_tag              2
#define EverestToMcu_connector_lock_tag          3
#define EverestToMcu_pwm_duty_cycle_tag          4
#define EverestToMcu_allow_power_on_tag          5
#define EverestToMcu_reset_tag                   6
#define EverestToMcu_rcd_cmd_tag                 8

/* Struct field encoding specification for nanopb */
#define EverestToMcu_FIELDLIST(X, a) \
X(a, STATIC,   ONEOF,    MESSAGE,  (payload,firmware_update,payload.firmware_update),   1) \
X(a, STATIC,   ONEOF,    MESSAGE,  (payload,keep_alive,payload.keep_alive),   2) \
X(a, STATIC,   ONEOF,    BOOL,     (payload,connector_lock,payload.connector_lock),   3) \
X(a, STATIC,   ONEOF,    UINT32,   (payload,pwm_duty_cycle,payload.pwm_duty_cycle),   4) \
X(a, STATIC,   ONEOF,    BOOL,     (payload,allow_power_on,payload.allow_power_on),   5) \
X(a, STATIC,   ONEOF,    BOOL,     (payload,reset,payload.reset),   6) \
X(a, STATIC,   ONEOF,    MESSAGE,  (payload,rcd_cmd,payload.rcd_cmd),   8)
#define EverestToMcu_CALLBACK NULL
#define EverestToMcu_DEFAULT NULL
#define EverestToMcu_payload_firmware_update_MSGTYPE FirmwareUpdate
#define EverestToMcu_payload_keep_alive_MSGTYPE KeepAlive
#define EverestToMcu_payload_rcd_cmd_MSGTYPE RcdCommand

#define McuToEverest_FIELDLIST(X, a) \
X(a, STATIC,   ONEOF,    MESSAGE,  (payload,keep_alive,payload.keep_alive),   1) \
X(a, STATIC,   ONEOF,    UENUM,    (payload,reset,payload.reset),   2) \
X(a, STATIC,   ONEOF,    UENUM,    (payload,cp_state,payload.cp_state),   3) \
X(a, STATIC,   ONEOF,    BOOL,     (payload,relais_state,payload.relais_state),   4) \
X(a, STATIC,   ONEOF,    MESSAGE,  (payload,error_flags,payload.error_flags),   5) \
X(a, STATIC,   ONEOF,    MESSAGE,  (payload,telemetry,payload.telemetry),   6) \
X(a, STATIC,   ONEOF,    UENUM,    (payload,pp_state,payload.pp_state),   7) \
X(a, STATIC,   ONEOF,    UENUM,    (payload,lock_state,payload.lock_state),   8)
#define McuToEverest_CALLBACK NULL
#define McuToEverest_DEFAULT NULL
#define McuToEverest_payload_keep_alive_MSGTYPE KeepAliveLo
#define McuToEverest_payload_error_flags_MSGTYPE ErrorFlags
#define McuToEverest_payload_telemetry_MSGTYPE Telemetry

#define ErrorFlags_FIELDLIST(X, a) \
X(a, STATIC,   SINGULAR, BOOL,     diode_fault,       1) \
X(a, STATIC,   SINGULAR, BOOL,     rcd_selftest_failed,   2) \
X(a, STATIC,   SINGULAR, BOOL,     rcd_triggered,     3) \
X(a, STATIC,   SINGULAR, BOOL,     ventilation_not_available,   4) \
X(a, STATIC,   SINGULAR, BOOL,     connector_lock_failed,   5) \
X(a, STATIC,   SINGULAR, BOOL,     cp_signal_fault,   6) \
X(a, STATIC,   SINGULAR, BOOL,     over_current,      7)
#define ErrorFlags_CALLBACK NULL
#define ErrorFlags_DEFAULT NULL

#define KeepAliveLo_FIELDLIST(X, a) \
X(a, STATIC,   SINGULAR, UINT32,   time_stamp,        1) \
X(a, STATIC,   SINGULAR, UINT32,   hw_type,           2) \
X(a, STATIC,   SINGULAR, UINT32,   hw_revision,       3) \
X(a, STATIC,   SINGULAR, UINT32,   protocol_version_major,   4) \
X(a, STATIC,   SINGULAR, UINT32,   protocol_version_minor,   5) \
X(a, STATIC,   SINGULAR, STRING,   sw_version_string,   6) \
X(a, STATIC,   SINGULAR, FLOAT,    hwcap_max_current,   7) \
X(a, STATIC,   SINGULAR, FLOAT,    hwcap_min_current,   8) \
X(a, STATIC,   SINGULAR, UINT32,   hwcap_max_phase_count,   9) \
X(a, STATIC,   SINGULAR, UINT32,   hwcap_min_phase_count,  10) \
X(a, STATIC,   SINGULAR, BOOL,     supports_changing_phases_during_charging,  11)
#define KeepAliveLo_CALLBACK NULL
#define KeepAliveLo_DEFAULT NULL

#define KeepAlive_FIELDLIST(X, a) \
X(a, STATIC,   SINGULAR, UINT32,   time_stamp,        1) \
X(a, STATIC,   SINGULAR, UINT32,   hw_type,           2) \
X(a, STATIC,   SINGULAR, UINT32,   hw_revision,       3) \
X(a, STATIC,   SINGULAR, STRING,   sw_version_string,   6)
#define KeepAlive_CALLBACK NULL
#define KeepAlive_DEFAULT NULL

#define Telemetry_FIELDLIST(X, a) \
X(a, STATIC,   SINGULAR, FLOAT,    cp_voltage_hi,     1) \
X(a, STATIC,   SINGULAR, FLOAT,    cp_voltage_lo,     2) \
X(a, STATIC,   SINGULAR, FLOAT,    temp0,             3) \
X(a, STATIC,   SINGULAR, FLOAT,    temp1,             4)
#define Telemetry_CALLBACK NULL
#define Telemetry_DEFAULT NULL

#define FirmwareUpdate_FIELDLIST(X, a) \
X(a, STATIC,   SINGULAR, BOOL,     invoke_rom_bootloader,   1)
#define FirmwareUpdate_CALLBACK NULL
#define FirmwareUpdate_DEFAULT NULL

#define RcdCommand_FIELDLIST(X, a) \
X(a, STATIC,   SINGULAR, BOOL,     test,              1) \
X(a, STATIC,   SINGULAR, BOOL,     reset,             2)
#define RcdCommand_CALLBACK NULL
#define RcdCommand_DEFAULT NULL

extern const pb_msgdesc_t EverestToMcu_msg;
extern const pb_msgdesc_t McuToEverest_msg;
extern const pb_msgdesc_t ErrorFlags_msg;
extern const pb_msgdesc_t KeepAliveLo_msg;
extern const pb_msgdesc_t KeepAlive_msg;
extern const pb_msgdesc_t Telemetry_msg;
extern const pb_msgdesc_t FirmwareUpdate_msg;
extern const pb_msgdesc_t RcdCommand_msg;

/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
#define EverestToMcu_fields &EverestToMcu_msg
#define McuToEverest_fields &McuToEverest_msg
#define ErrorFlags_fields &ErrorFlags_msg
#define KeepAliveLo_fields &KeepAliveLo_msg
#define KeepAlive_fields &KeepAlive_msg
#define Telemetry_fields &Telemetry_msg
#define FirmwareUpdate_fields &FirmwareUpdate_msg
#define RcdCommand_fields &RcdCommand_msg

/* Maximum encoded size of messages (where known) */
#define ErrorFlags_size                          14
#define EverestToMcu_size                        72
#define FirmwareUpdate_size                      2
#define KeepAliveLo_size                         106
#define KeepAlive_size                           70
#define McuToEverest_size                        108
#define RcdCommand_size                          4
#define TIDA010939_PB_H_MAX_SIZE                 McuToEverest_size
#define Telemetry_size                           20

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif
