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 "ade9153a.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
66 extern struct no_os_gpio_init_param gpio_ss_ip;
68 // GPIO RESET init params
70 // GPIO RDY init params
72 // GPIO IRQ init params
74 
75 /* Configuration for AD-APARD32690-SL */
76 // Port and pin for user LED
77 #define GPIO_LED_PORT 2
78 #define GPIO_LED_PIN 7
79 // SPI port and pins
80 #define GPIO_SS_PORT 2
81 #define GPIO_SS_PIN 26
82 #define GPIO_SCK_PORT 2
83 #define GPIO_SCK_PIN 29
84 // Hardware reset port and pin
85 #define GPIO_RESET_PORT 2
86 #define GPIO_RESET_PIN 8
87 // Data ready interrup port and pin
88 #define GPIO_OPS &max_gpio_ops
89 #define GPIO_EXTRA &ade9153_gpio_extra_ip
90 #define GPIO_RDY_PORT 2
91 #define GPIO_RDY_PIN 9
92 // SPI config
93 #define SPI_DEVICE_ID 0
94 #define SPI_BAUDRATE 1000000
95 #define SPI_CS 1
96 #define SPI_SLAVE_NUM 1
97 // UART config
98 #define UART_DEV_ID 0
99 #define UART_BAUD 115200
100 // IRQ config
101 #define GPIO_IRQ_OPS &max_gpio_irq_ops
102 #define GPIO_CTRL_IRQ_ID 0
103 #define GPIO_IRQ_EXTRA &ade9153a_gpio_extra_ip
104 #define NVIC_GPIO_IRQ GPIO2_IRQn
105 // Value used for delay after reset
106 #define RESET_TIME 500
107 #define SPI_EN 1
108 // Read data interval in ms
109 #define READ_INTERVAL 3000
110 
111 // Setup values for ADE9153A used for EV-ADE9153ASHIELDZ
112 // Vlevel value assuming 1/2 full scale
113 #define ADE9153A_VLEVEL 0x002C11E8
114 // value for R_small 1k
115 #define ADE9153A_RSMALL 0x03E8
116 // energy accumulate no of samples set to 4000
117 #define ADE9153A_NO_SAMPLES 0x0F9F
118 // AIGAIN -1 (IAP-IAN swap) AIGAIN = -1*2^28
119 #define ADE9153A_AIGAIN -(1 << 28)
120 #define ADE9153A_AIGAIN2 -(1 << 27)
121 
122 // Calibration values for EV-ADE9153ASHIELDZ
123 // Energy vals calibration coeffiecient (uWh/code)
124 #define ENERGY_CC 0.858307
125 // Energy vals calibration coeffiecient (uW/code)
126 #define POWER_CC 1508.743
127 // Current calibration coeffiecient (uA/code)
128 #define RMS_CURENT_CC 0.838190
129 // Voltage calibration coeffiecient (uV/code)
130 #define RMS_VOLTAGE_CC 13.41105
131 // PF calibration coeffiecient
132 #define PF_CC 134217728
133 // Frequency calibration coeffiecient
134 #define FREQ_CC 262144000
135 // Frequency multiplier for angle compute
136 #define MULT_CC_50HZ 0.017578125
137 // Frequency multiplier for angle compute
138 #define MULT_CC_60HZ 0.02109375
139 
140 /******************************************************************************/
141 /************************ Functions Declarations ******************************/
142 /******************************************************************************/
143 
144 /* Toggle user LED */
145 int interface_toggle_led(struct no_os_gpio_desc *gpio_led_desc);
146 
147 /* Read measurements */
148 int read_measurements(struct ade9153a_dev *dev);
149 
150 /* Autocalibration read values */
151 int autocalibration_read_vals(struct ade9153a_dev *dev);
152 
153 /* Autocalibration start */
154 int autocalibration_start(struct ade9153a_dev *dev);
155 
156 #endif
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
no_os_spi.h
Header file of SPI Interface.
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.
ade9153a_spi_ip
struct no_os_spi_init_param ade9153a_spi_ip
Definition: common_data.c:116
no_os_error.h
Error codes definition.
gpio_ss_ip
struct no_os_gpio_init_param gpio_ss_ip
Definition: common_data.c:81
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
ade9153a_gpio_rdy_ip
struct no_os_gpio_init_param ade9153a_gpio_rdy_ip
Definition: common_data.c:108
ade9153a_gpio_irq_ip
struct no_os_irq_init_param ade9153a_gpio_irq_ip
Definition: common_data.c:126
no_os_pwm.h
Header file of PWM Interface.
gpio_sck_ip
struct no_os_gpio_init_param gpio_sck_ip
Definition: common_data.c:90
gpio_led1_ip
struct no_os_gpio_init_param gpio_led1_ip
Definition: platform.c:72
autocalibration_start
int autocalibration_start(struct ade9153a_dev *dev)
Autocalibration start.
Definition: common_data.c:364
no_os_uart_init_param
Structure holding the parameters for UART initialization.
Definition: no_os_uart.h:110
ade9153a.h
Header file of ADE9153A Driver.
autocalibration_read_vals
int autocalibration_read_vals(struct ade9153a_dev *dev)
Autocalibration read values.
Definition: common_data.c:307
no_os_irq_init_param
Structure holding the initial parameters for Interrupt Request.
Definition: no_os_irq.h:107
no_os_gpio.h
Header file of GPIO Interface.
no_os_uart.h
Header file of UART interface.
ade9153a_dev
ADE9153A Device structure.
Definition: ade9153a.h:712
no_os_util.h
Header file of utility functions.
read_measurements
int read_measurements(struct ade9153a_dev *dev)
Read measurements.
Definition: common_data.c:163
gpio_reset_ip
struct no_os_gpio_init_param gpio_reset_ip
Definition: common_data.c:99
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:125