no-OS
common_data.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef __COMMON_DATA_H__
34 #define __COMMON_DATA_H__
35 
36 /******************************************************************************/
37 /***************************** Include Files **********************************/
38 /******************************************************************************/
39 #include "ade7913.h"
40 #include "no_os_uart.h"
41 #include "no_os_pwm.h"
42 #include "no_os_delay.h"
43 #include "no_os_gpio.h"
44 #include "no_os_spi.h"
45 #include "no_os_print_log.h"
46 #include "no_os_units.h"
47 #include "no_os_util.h"
48 #include "no_os_error.h"
49 #include "maxim_uart.h"
50 #include "maxim_gpio.h"
51 #include "maxim_uart_stdio.h"
52 #include "maxim_pwm.h"
53 #include "maxim_spi.h"
54 #include "maxim_irq.h"
55 
56 /******************************************************************************/
57 /********************** Macros and Constants Definitions **********************/
58 /******************************************************************************/
59 
60 // UART init params
61 extern struct no_os_uart_init_param uart_ip;
62 // GPIO LED init params
64 // SPI init params
68 //GPIO RDY init params
70 
71 /* Initial values for the rms filters */
72 #define INITIAL 1024
73 #define SAMPLES 1024
74 
75 /* Scale for voltage divider */
76 #define V_MULT (1000ul)
77 #define V_DIVIDER (1001ul)
78 
79 struct rms_adc_values {
80 
81  /* I rms value */
82  int32_t *i_rms;
83  /* V1 rms value */
84  int32_t *v1_rms;
85  /* V2 rms value */
86  int32_t *v2_rms;
87  /* I ADC value */
88  int32_t *i_rms_adc;
89  /* V1 ADC value */
90  int32_t *v1_rms_adc;
91  /* V2 ADC value */
92  int32_t *v2_rms_adc;
93 };
94 
95 /******************************************************************************/
96 /************************ Functions Declarations ******************************/
97 /******************************************************************************/
98 
99 /* Toggle user LED */
100 int interface_toggle_led(struct no_os_gpio_desc *gpio_led_desc);
101 
102 /* Saves the current and voltage values of device 1 in rms_adc structure */
103 int rms_adc_values_read(struct ade7913_dev *dev, struct rms_adc_values *rms);
104 
105 /* Saves the current and voltage values of device 2 in rms_adc structure */
106 int rms_adc_values_read_2(struct ade7913_dev *dev, struct rms_adc_values *rms);
107 
108 /* Saves the current and voltage values of device 3 in rms_adc structure */
109 int rms_adc_values_read_3(struct ade7913_dev *dev, struct rms_adc_values *rms);
110 
111 /* Compute v1 rms value for device 1 */
112 int64_t rms_filter_v1(int32_t sample);
113 
114 /* Compute v2 rms value for device 1 */
115 int64_t rms_filter_v2(int32_t sample);
116 
117 /* Compute i rms value for device 1 */
118 int64_t rms_filter_i(int32_t sample);
119 
120 /* Compute v1_2 rms value for device 2 */
121 int64_t rms_filter_v1_2(int32_t sample);
122 
123 /* Compute v2_2 rms value for device 2 */
124 int64_t rms_filter_v2_2(int32_t sample);
125 
126 /* Compute i_2 rms value for device 2 */
127 int64_t rms_filter_i_2(int32_t sample);
128 
129 /* Compute v1_3 rms value for device 3 */
130 int64_t rms_filter_v1_3(int32_t sample);
131 
132 /* Compute v2_3 rms value for device 3 */
133 int64_t rms_filter_v2_3(int32_t sample);
134 
135 /* Compute i_3 rms value for device 3 */
136 int64_t rms_filter_i_3(int32_t sample);
137 
138 /* Scale V value */
139 int64_t supply_scale_v(int32_t val);
140 
141 #endif /* __COMMON_DATA_H__ */
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
interface_toggle_led
int interface_toggle_led(struct no_os_gpio_desc *gpio_led_desc)
Toggle LED.
Definition: interface.c:102
rms_filter_v2_3
int64_t rms_filter_v2_3(int32_t sample)
Compute v2_3 rms value for device 3.
Definition: common_data.c:289
ade7913_spi_ip0
struct no_os_spi_init_param ade7913_spi_ip0
Definition: platform.c:90
supply_scale_v
int64_t supply_scale_v(int32_t val)
Scale V value.
Definition: common_data.c:323
no_os_spi.h
Header file of SPI Interface.
ade7913_gpio_rdy_ip
struct no_os_gpio_init_param ade7913_gpio_rdy_ip
Definition: platform.c:81
no_os_units.h
Header file of Units.
no_os_delay.h
Header file of Delay functions.
uart_ip
struct no_os_uart_init_param uart_ip
Definition: common_data.c:52
no_os_print_log.h
Print messages helpers.
rms_filter_i
int64_t rms_filter_i(int32_t sample)
Compute i rms value.
Definition: supply.c:333
ade7913_dev
ADE7913 Device structure.
Definition: ade7913.h:164
rms_filter_v1_3
int64_t rms_filter_v1_3(int32_t sample)
Compute v1_3 rms value for device 3.
Definition: common_data.c:272
rms_adc_values_read_3
int rms_adc_values_read_3(struct ade7913_dev *dev, struct rms_adc_values *rms)
Saves the current and voltage values of device 3 in rms_adc structure.
Definition: common_data.c:139
rms_filter_i_3
int64_t rms_filter_i_3(int32_t sample)
Compute i_3 rms value for device 3.
Definition: common_data.c:306
no_os_error.h
Error codes definition.
rms_adc_values::i_rms_adc
int32_t * i_rms_adc
Definition: common_data.h:88
rms_filter_v1_2
int64_t rms_filter_v1_2(int32_t sample)
Compute v1_2 rms value for device 2.
Definition: common_data.c:221
rms_adc_values
Definition: state_machine.h:224
ade7913_spi_ip2
struct no_os_spi_init_param ade7913_spi_ip2
Definition: platform.c:112
rms_filter_v2_2
int64_t rms_filter_v2_2(int32_t sample)
Compute v2_2 rms value for device 2.
Definition: common_data.c:238
rms_filter_v2
int64_t rms_filter_v2(int32_t sample)
Compute v2 rms value.
Definition: supply.c:316
rms_adc_values::v2_rms_adc
int32_t * v2_rms_adc
Definition: common_data.h:92
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
ade7913_spi_ip1
struct no_os_spi_init_param ade7913_spi_ip1
Definition: platform.c:101
ade7913.h
Header file of ADE7913 Driver.
rms_adc_values_read
int rms_adc_values_read(struct ade7913_dev *dev, struct rms_adc_values *rms)
Saves the current and voltage values of device 1 in rms_adc structure.
Definition: common_data.c:75
rms_filter_i_2
int64_t rms_filter_i_2(int32_t sample)
Compute i_2 rms value for device 2.
Definition: common_data.c:255
no_os_pwm.h
Header file of PWM Interface.
gpio_led1_ip
struct no_os_gpio_init_param gpio_led1_ip
Definition: platform.c:72
rms_filter_v1
int64_t rms_filter_v1(int32_t sample)
Compute v1 rms value.
Definition: supply.c:299
no_os_uart_init_param
Structure holding the parameters for UART initialization.
Definition: no_os_uart.h:110
rms_adc_values::i_rms
int32_t * i_rms
Definition: common_data.h:82
rms_adc_values_read_2
int rms_adc_values_read_2(struct ade7913_dev *dev, struct rms_adc_values *rms)
Saves the current and voltage values of device 2 in rms_adc structure.
Definition: common_data.c:107
no_os_gpio.h
Header file of GPIO Interface.
rms_adc_values::v1_rms_adc
int32_t * v1_rms_adc
Definition: common_data.h:90
no_os_uart.h
Header file of UART interface.
rms_adc_values::v2_rms
int32_t * v2_rms
Definition: common_data.h:86
no_os_util.h
Header file of utility functions.
rms_adc_values::v1_rms
int32_t * v1_rms
Definition: common_data.h:84
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:125