/*
 * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#ifndef _DEVICE_PARAMS
#define _DEVICE_PARAMS

#include <stdint.h>

#pragma pack(push, 1)

// Discrete Inputs
typedef struct {
    uint8_t discrete_input0 : 1;
    uint8_t discrete_input1 : 1;
    uint8_t discrete_input2 : 1;
    uint8_t discrete_input3 : 1;
    uint8_t discrete_input4 : 1;
    uint8_t discrete_input5 : 1;
    uint8_t discrete_input6 : 1;
    uint8_t discrete_input7 : 1;
    uint8_t discrete_input_port1;
    uint8_t discrete_input_port2;
} discrete_reg_params_t;

// Coils
typedef struct {
    uint8_t coils_port0;
    uint8_t coils_port1;
    uint8_t coils_port2;
} coil_reg_params_t;

// Input Registers (pode manter caso use em outro driver)
typedef struct {
    float input_data0;
    float input_data1;
    float input_data2;
    float input_data3;
    uint16_t data[150];
    float input_data4;
    float input_data5;
    float input_data6;
    float input_data7;
    uint16_t data_block1[150];
} input_reg_params_t;


// Holding Registers (ajustado para os campos usados no ORNO 516)
typedef struct {
    float l1_current;          
    float l2_current;          
    float l3_current;          

    float l1_voltage;          
    float l2_voltage;          
    float l3_voltage;          

    float active_energy; 
    float reactive_energy;  

    float active_power;
    float apparent_power;
    float reactive_power;

    float frequency;
    float power_factor;
} holding_reg_params_t;



#pragma pack(pop)

// Instâncias globais das estruturas
extern holding_reg_params_t holding_reg_params;
extern input_reg_params_t input_reg_params;
extern coil_reg_params_t coil_reg_params;
extern discrete_reg_params_t discrete_reg_params;

#endif // !_DEVICE_PARAMS
