no-OS
common_data.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * @file common_data.h
3  * @brief Common data header file
4  * @author Robert Budai (robert.budai@analog.com)
5  ********************************************************************************
6  * Copyright (c) 2024 Analog Devices, Inc.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of Analog Devices, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
25  * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *******************************************************************************/
33 
34 #ifndef __COMMON_DATA_H__
35 #define __COMMON_DATA_H__
36 
37 /******************************************************************************/
38 /***************************** Include Files **********************************/
39 /******************************************************************************/
40 
41 #if defined(PQM_CONN_T1L)
42 #include "lwip_socket.h"
43 #include "lwip_adin1110.h"
44 #include "adin1110.h"
45 #endif
46 
47 #include "adi_pqlib.h"
48 #include "iio.h"
49 #include "iio_app.h"
50 #include "iio_pqm.h"
51 #include "iio_types.h"
52 #include "no_os_i2c.h"
53 #include "no_os_irq.h"
54 #include "no_os_spi.h"
55 #include "no_os_timer.h"
56 #include "no_os_uart.h"
57 #include "parameters.h"
58 #include "pqlib_example.h"
59 
60 /******************************************************************************/
61 /********************** Macros and Constants Definitions **********************/
62 /******************************************************************************/
63 
64 #define FW_VERSION 2.2
65 
66 #define IIO_BUFF_TYPE int16_t
67 #define SAMPLES_PER_CHANNEL_PLATFORM 256
68 #define MAX_SIZE_BASE_ADDR (SAMPLES_PER_CHANNEL_PLATFORM * TOTAL_PQM_CHANNELS)
69 #define MAX_SIZE_BASE_ADDR_WITH_SIZE \
70  (MAX_SIZE_BASE_ADDR * sizeof(IIO_BUFF_TYPE))
71 
72 #define TOTAL_PQM_CHANNELS 11
73 #define VOLTAGE_CH_NUMBER 3
74 #define MAX_CH_ATTRS 23
75 #define PQM_DEVICE_ATTR_NUMBER 35
76 #define WAVEFORM_BUFFER_LENGTH (256 * 7)
77 #define MAX_EVENT_NUMBER 6
78 
80 
81 #if defined(PQM_CONN_USB)
82 extern struct no_os_uart_init_param iio_demo_usb_ip;
83 #elif defined(PQM_CONN_SERIAL)
84 extern struct no_os_uart_init_param iio_demo_serial_ip;
85 #elif defined(PQM_CONN_T1L)
86 extern struct no_os_uart_init_param iio_demo_serial_ip;
87 extern const struct no_os_gpio_init_param adin1110_int_ip;
89 extern const struct no_os_gpio_init_param adin1110_swpd_ip;
90 extern const struct no_os_gpio_init_param adin1110_tx2p4_ip;
91 extern const struct no_os_gpio_init_param adin1110_mssel_ip;
92 extern const struct no_os_gpio_init_param adin1110_cfg0_ip;
93 extern const struct no_os_gpio_init_param adin1110_cfg1_ip;
94 extern const struct no_os_spi_init_param adin1110_spi_ip;
95 
96 extern struct adin1110_init_param adin1110_ip;
97 extern struct lwip_network_param lwip_ip;
98 #endif
99 
100 extern struct pqm_init_para pqm_ip;
101 extern struct no_os_spi_init_param spi_egy_ip;
102 extern struct no_os_i2c_init_param i2c_ip;
104 extern struct no_os_timer_init_param timer_ip;
106 extern struct no_os_gpio_init_param intr_gpio_ip;
109 
110 static const char *const pqm_v_consel_available[] = {
111  [VCONSEL_4W_WYE] = "4W_WYE",
112  [VCONSEL_3W_DELTA_VB_VA_NEGVC] = "3W_DELTA_VA_VB_NEGVC",
113  [VCONSEL_4W_WYE_VB_NEGVA_NEGVC] = "4W_WYE_VB_NEGVA_NEGVC",
114  [VCONSEL_4W_DELTA_VB_NEGVA] = "4W_DELTA_VB_NEGVA",
115  [VCONSEL_4W_DELTA_VA_VB_VC] = "4W_DELTA_VA_VB_VC",
116 };
117 
118 static const char *const pqm_flicker_model_available[] = {
119  [ADI_PQLIB_FLICKER_MODEL_230V_50HZ] = "230V_50HZ",
120  [ADI_PQLIB_FLICKER_MODEL_120V_50HZ] = "120V_50HZ",
121  [ADI_PQLIB_FLICKER_MODEL_230V_60HZ] = "230V_60HZ",
122  [ADI_PQLIB_FLICKER_MODEL_120V_60HZ] = "120V_60HZ",
123 };
124 
125 static const char *const pqm_nominal_frequency_available[] = {
126  [ADI_PQLIB_NOMINAL_FREQUENCY_50HZ] = "50",
127  [ADI_PQLIB_NOMINAL_FREQUENCY_60HZ] = "60",
128 };
129 
130 struct pqm_desc {
134  uint32_t active_ch;
135  uint32_t ext_buff_len;
136  int16_t *ext_buff;
137 };
138 
142  uint32_t ext_buff_len;
143  int16_t *ext_buff;
144 };
145 
146 #endif /* __COMMON_DATA_H__ */
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
IIO_BUFF_TYPE
#define IIO_BUFF_TYPE
Definition: common_data.h:66
pqm_init_para::dev_global_attr
float dev_global_attr[PQM_DEVICE_ATTR_NUMBER]
Definition: common_data.h:140
PQM_DEVICE_ATTR_NUMBER
#define PQM_DEVICE_ATTR_NUMBER
Definition: common_data.h:75
no_os_callback_desc
Structure describing a callback to be registered.
Definition: no_os_irq.h:142
pqm_desc::pqm_global_attr
float pqm_global_attr[PQM_DEVICE_ATTR_NUMBER]
Definition: common_data.h:132
no_os_spi.h
Header file of SPI Interface.
no_os_irq.h
Header file of IRQ interface.
iio_data_buffer_loc
IIO_BUFF_TYPE iio_data_buffer_loc[MAX_SIZE_BASE_ADDR]
Definition: common_data.c:149
iio_app.h
Header file of iio_app.
pqm_desc::reg
uint8_t reg[TOTAL_PQM_CHANNELS]
Definition: common_data.h:131
VCONSEL_4W_DELTA_VA_VB_VC
@ VCONSEL_4W_DELTA_VA_VB_VC
Definition: pqlib_example.h:79
pqm_desc
Definition: common_data.h:130
adin1110_swpd_ip
const struct no_os_gpio_init_param adin1110_swpd_ip
Definition: common_data.c:165
adin1110_init_param
Initialization parameter for the device descriptor.
Definition: adin1110.h:214
TOTAL_PQM_CHANNELS
#define TOTAL_PQM_CHANNELS
Definition: common_data.h:72
no_os_timer.h
Timer control module header.
pqm_init_para::dev_ch_attr
uint32_t dev_ch_attr[TOTAL_PQM_CHANNELS][MAX_CH_ATTRS]
Definition: common_data.h:141
adin1110.h
pqm_desc::active_ch
uint32_t active_ch
Definition: common_data.h:134
MAX_SIZE_BASE_ADDR
#define MAX_SIZE_BASE_ADDR
Definition: common_data.h:68
pqm_desc::pqm_ch_attr
uint32_t pqm_ch_attr[TOTAL_PQM_CHANNELS][MAX_CH_ATTRS]
Definition: common_data.h:133
iio.h
Header file of iio.
pqm_desc::ext_buff_len
uint32_t ext_buff_len
Definition: common_data.h:135
reset_gpio_ip
struct no_os_gpio_init_param reset_gpio_ip
Definition: common_data.c:226
spi_egy_ip
struct no_os_spi_init_param spi_egy_ip
Definition: common_data.c:216
VCONSEL_4W_DELTA_VB_NEGVA
@ VCONSEL_4W_DELTA_VB_NEGVA
Definition: pqlib_example.h:78
pqlib_example.h
pqm_desc::ext_buff
int16_t * ext_buff
Definition: common_data.h:136
adin1110_cfg0_ip
const struct no_os_gpio_init_param adin1110_cfg0_ip
Definition: common_data.c:189
adin1110_spi_ip
struct no_os_spi_init_param adin1110_spi_ip
Definition: common_data.c:46
pqm_init_para::ext_buff
int16_t * ext_buff
Definition: common_data.h:143
adin1110_int_ip
const struct no_os_gpio_init_param adin1110_int_ip
Definition: common_data.c:69
afe_callback_ctrl_ip
struct no_os_irq_init_param afe_callback_ctrl_ip
Definition: common_data.c:243
adin1110_cfg1_ip
const struct no_os_gpio_init_param adin1110_cfg1_ip
Definition: common_data.c:197
iio_pqm.h
i2c_ip
struct no_os_i2c_init_param i2c_ip
Definition: common_data.c:197
no_os_timer_init_param
Structure holding the parameters for timer initialization.
Definition: no_os_timer.h:83
no_os_i2c.h
Header file of I2C Interface.
afe0_callback_desc
struct no_os_callback_desc afe0_callback_desc
Definition: common_data.c:250
iio_types.h
Header file for iio_types.
adin1110_mssel_ip
const struct no_os_gpio_init_param adin1110_mssel_ip
Definition: common_data.c:181
no_os_i2c_init_param
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
no_os_uart_init_param
Structure holding the parameters for UART initialization.
Definition: no_os_uart.h:110
adin1110_tx2p4_ip
const struct no_os_gpio_init_param adin1110_tx2p4_ip
Definition: common_data.c:173
VCONSEL_4W_WYE
@ VCONSEL_4W_WYE
Definition: pqlib_example.h:75
no_os_irq_init_param
Structure holding the initial parameters for Interrupt Request.
Definition: no_os_irq.h:107
pqm_ip
struct pqm_init_para pqm_ip
Definition: common_data.c:151
intr_gpio_ip
struct no_os_gpio_init_param intr_gpio_ip
Definition: common_data.c:234
adin1110_ip
struct adin1110_init_param adin1110_ip
Definition: common_data.c:221
no_os_uart.h
Header file of UART interface.
pqm_init_para::ext_buff_len
uint32_t ext_buff_len
Definition: common_data.h:142
timer_ip
struct no_os_timer_init_param timer_ip
Definition: common_data.c:60
VCONSEL_4W_WYE_VB_NEGVA_NEGVC
@ VCONSEL_4W_WYE_VB_NEGVA_NEGVC
Definition: pqlib_example.h:77
adin1110_rst_gpio_ip
const struct no_os_gpio_init_param adin1110_rst_gpio_ip
Definition: common_data.c:77
MAX_CH_ATTRS
#define MAX_CH_ATTRS
Definition: common_data.h:74
pqm_init_para
Definition: common_data.h:139
VCONSEL_3W_DELTA_VB_VA_NEGVC
@ VCONSEL_3W_DELTA_VB_VA_NEGVC
Definition: pqlib_example.h:76
uart_ip_stdio
struct no_os_uart_init_param uart_ip_stdio
Definition: common_data.c:205
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140