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  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  * - Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * - Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in
16  * the documentation and/or other materials provided with the
17  * distribution.
18  * - Neither the name of Analog Devices, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  * - The use of this software may or may not infringe the patent rights
22  * of one or more patent holders. This license does not release you
23  * from the requirement that you obtain separate licenses from these
24  * patent holders to use this software.
25  * - Use of the software either in source or binary form, must be run
26  * on or directly connected to an Analog Devices Inc. component.
27  *
28  * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
29  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
30  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
31  * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
32  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33  * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
34  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36  *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
37  *OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
38  *DAMAGE.
39  *******************************************************************************/
40 
41 #ifndef __COMMON_DATA_H__
42 #define __COMMON_DATA_H__
43 
44 /******************************************************************************/
45 /***************************** Include Files **********************************/
46 /******************************************************************************/
47 
48 #include "adi_pqlib.h"
49 #include "iio.h"
50 #include "iio_app.h"
51 #include "iio_pqm.h"
52 #include "iio_types.h"
53 #include "no_os_i2c.h"
54 #include "no_os_irq.h"
55 #include "no_os_spi.h"
56 #include "no_os_timer.h"
57 #include "no_os_uart.h"
58 #include "parameters.h"
59 #include "pqlib_example.h"
60 
61 /******************************************************************************/
62 /********************** Macros and Constants Definitions **********************/
63 /******************************************************************************/
64 
65 #define FW_VERSION 2.0
66 
67 #define IIO_BUFF_TYPE int16_t
68 #define SAMPLES_PER_CHANNEL_PLATFORM 256
69 #define MAX_SIZE_BASE_ADDR (SAMPLES_PER_CHANNEL_PLATFORM * TOTAL_PQM_CHANNELS)
70 #define MAX_SIZE_BASE_ADDR_WITH_SIZE \
71  (MAX_SIZE_BASE_ADDR * sizeof(IIO_BUFF_TYPE))
72 
73 #define TOTAL_PQM_CHANNELS 7
74 #define VOLTAGE_CH_NUMBER 3
75 #define MAX_CH_ATTRS 12
76 #define PQM_DEVICE_ATTR_NUMBER 35
77 #define WAVEFORM_BUFFER_LENGTH (256 * 7)
78 
81 extern struct pqm_init_para pqm_ip;
82 extern struct no_os_spi_init_param spi_egy_ip;
83 extern struct no_os_i2c_init_param i2c_ip;
85 extern struct no_os_timer_init_param timer_ip;
90 
91 static const char *const pqm_v_consel_available[] = {
92  [VCONSEL_4W_WYE] = "4W_WYE",
93  [VCONSEL_3W_DELTA_VB_VA_NEGVC] = "3W_DELTA_VA_VB_NEGVC",
94  [VCONSEL_4W_WYE_VB_NEGVA_NEGVC] = "4W_WYE_VB_NEGVA_NEGVC",
95  [VCONSEL_4W_DELTA_VB_NEGVA] = "4W_DELTA_VB_NEGVA",
96  [VCONSEL_4W_DELTA_VA_VB_VC] = "4W_DELTA_VA_VB_VC",
97 };
98 
99 static const char *const pqm_flicker_model_available[] = {
100  [ADI_PQLIB_FLICKER_MODEL_230V_50HZ] = "230V_50HZ",
101  [ADI_PQLIB_FLICKER_MODEL_120V_50HZ] = "120V_50HZ",
102  [ADI_PQLIB_FLICKER_MODEL_230V_60HZ] = "230V_60HZ",
103  [ADI_PQLIB_FLICKER_MODEL_120V_60HZ] = "120V_60HZ",
104 };
105 
106 static const char *const pqm_nominal_frequency_available[] = {
107  [ADI_PQLIB_NOMINAL_FREQUENCY_50HZ] = "50",
108  [ADI_PQLIB_NOMINAL_FREQUENCY_60HZ] = "60",
109 };
110 
111 struct pqm_desc {
115  uint32_t active_ch;
116  uint32_t ext_buff_len;
117  int16_t *ext_buff;
118 };
119 
123  uint32_t ext_buff_len;
124  int16_t *ext_buff;
125 };
126 
127 #endif /* __COMMON_DATA_H__ */
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:85
IIO_BUFF_TYPE
#define IIO_BUFF_TYPE
Definition: common_data.h:67
pqm_init_para::dev_global_attr
float dev_global_attr[PQM_DEVICE_ATTR_NUMBER]
Definition: common_data.h:121
PQM_DEVICE_ATTR_NUMBER
#define PQM_DEVICE_ATTR_NUMBER
Definition: common_data.h:76
no_os_callback_desc
Structure describing a callback to be registered.
Definition: no_os_irq.h:148
pqm_desc::pqm_global_attr
float pqm_global_attr[PQM_DEVICE_ATTR_NUMBER]
Definition: common_data.h:113
no_os_spi.h
Header file of SPI Interface.
iio_demo_uart_ip
struct no_os_uart_init_param iio_demo_uart_ip
Definition: common_data.c:51
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:63
iio_app.h
Header file of iio_app.
pqm_desc::reg
uint8_t reg[TOTAL_PQM_CHANNELS]
Definition: common_data.h:112
VCONSEL_4W_DELTA_VA_VB_VC
@ VCONSEL_4W_DELTA_VA_VB_VC
Definition: pqlib_example.h:85
pqm_desc
Definition: common_data.h:111
TOTAL_PQM_CHANNELS
#define TOTAL_PQM_CHANNELS
Definition: common_data.h:73
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:122
pqm_desc::active_ch
uint32_t active_ch
Definition: common_data.h:115
MAX_SIZE_BASE_ADDR
#define MAX_SIZE_BASE_ADDR
Definition: common_data.h:69
pqm_desc::pqm_ch_attr
uint32_t pqm_ch_attr[TOTAL_PQM_CHANNELS][MAX_CH_ATTRS]
Definition: common_data.h:114
iio.h
Header file of iio.
pqm_desc::ext_buff_len
uint32_t ext_buff_len
Definition: common_data.h:116
reset_gpio_ip
struct no_os_gpio_init_param reset_gpio_ip
Definition: common_data.c:140
spi_egy_ip
struct no_os_spi_init_param spi_egy_ip
Definition: common_data.c:130
VCONSEL_4W_DELTA_VB_NEGVA
@ VCONSEL_4W_DELTA_VB_NEGVA
Definition: pqlib_example.h:84
pqlib_example.h
pqm_desc::ext_buff
int16_t * ext_buff
Definition: common_data.h:117
pqm_init_para::ext_buff
int16_t * ext_buff
Definition: common_data.h:124
afe_callback_ctrl_ip
struct no_os_irq_init_param afe_callback_ctrl_ip
Definition: common_data.c:157
iio_pqm.h
i2c_ip
struct no_os_i2c_init_param i2c_ip
Definition: common_data.c:111
no_os_timer_init_param
Structure holding the parameters for timer initialization.
Definition: no_os_timer.h:89
no_os_i2c.h
Header file of I2C Interface.
afe0_callback_desc
struct no_os_callback_desc afe0_callback_desc
Definition: common_data.c:164
iio_types.h
Header file for iio_types.
no_os_i2c_init_param
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:70
no_os_uart_init_param
Structure holding the parameters for UART initialization.
Definition: no_os_uart.h:116
VCONSEL_4W_WYE
@ VCONSEL_4W_WYE
Definition: pqlib_example.h:81
no_os_irq_init_param
Structure holding the initial parameters for Interrupt Request.
Definition: no_os_irq.h:113
pqm_ip
struct pqm_init_para pqm_ip
Definition: common_data.c:65
intr_gpio_ip
struct no_os_gpio_init_param intr_gpio_ip
Definition: common_data.c:148
no_os_uart.h
Header file of UART interface.
pqm_init_para::ext_buff_len
uint32_t ext_buff_len
Definition: common_data.h:123
timer_ip
struct no_os_timer_init_param timer_ip
Definition: common_data.c:66
VCONSEL_4W_WYE_VB_NEGVA_NEGVC
@ VCONSEL_4W_WYE_VB_NEGVA_NEGVC
Definition: pqlib_example.h:83
MAX_CH_ATTRS
#define MAX_CH_ATTRS
Definition: common_data.h:75
pqm_init_para
Definition: common_data.h:120
VCONSEL_3W_DELTA_VB_VA_NEGVC
@ VCONSEL_3W_DELTA_VB_VA_NEGVC
Definition: pqlib_example.h:82
uart_ip_stdio
struct no_os_uart_init_param uart_ip_stdio
Definition: common_data.c:119
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:131