no-OS
supply.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef __SUPPLY_H__
34 #define __SUPPLY_H__
35 
36 /******************************************************************************/
37 /***************************** Include Files **********************************/
38 /******************************************************************************/
39 #include "state_machine.h"
40 #include "parameters.h"
41 #include "no_os_irq.h"
42 
43 #define V1_MULT (1000000ul)
44 #define V1_DIVIDER (1328233ul)
45 #define V2_DIVIDER (1996007ul)
46 
48 #define INITIAL 4096
49 #define SAMPLES 4096
50 
53 
56 
58 int supply_init(struct ade9113_dev **device);
59 
61 int32_t supply_scale_v1(int32_t val);
62 
64 int32_t supply_scale_v2(int32_t val);
65 
67 int64_t rms_filter_v1(int32_t sample);
68 
70 int64_t rms_filter_v2(int32_t sample);
71 
73 int64_t rms_filter_i(int32_t sample);
74 
76 int rms_adc_values_read(struct stout *stout, struct rms_adc_values *rms);
77 
78 #endif /* __SUPPLY_H__ */
rms_adc_values_read
int rms_adc_values_read(struct stout *stout, struct rms_adc_values *rms)
saves the current and voltage values in rms_adc structure
Definition: supply.c:351
get_zero_cross_flag_state
int get_zero_cross_flag_state(void)
Get zero crossing flag value.
Definition: supply.c:71
ade9113_convert_to_millivolts
int ade9113_convert_to_millivolts(struct ade9113_dev *dev, uint8_t dev_no, enum ade9113_wav_e ch, int32_t *mv_val)
Convert a 24-bit raw sample to millivolts.
Definition: ade9113.c:719
V1_DIVIDER
#define V1_DIVIDER
Definition: supply.h:44
ADE9113_SINC3_LPF_EN_4_KHZ_SAMPLING
@ ADE9113_SINC3_LPF_EN_4_KHZ_SAMPLING
Definition: ade9113.h:247
ADE9113_VREF
#define ADE9113_VREF
Definition: ade9113.h:210
ade9113_ip
struct ade9113_init_param ade9113_ip
Definition: common_data.c:180
SAMPLES
#define SAMPLES
Definition: supply.h:49
rms_adc_values::v2_rms_adc
int32_t v2_rms_adc
Definition: state_machine.h:237
stout::ade9113
struct ade9113_dev * ade9113
Definition: state_machine.h:187
no_os_callback_desc
Structure describing a callback to be registered.
Definition: no_os_irq.h:142
ade9113_init_param::drdy_callback
void(* drdy_callback)(void *context)
Definition: ade9113.h:339
ade9113_set_dsp_config
int ade9113_set_dsp_config(struct ade9113_dev *dev, enum ade9113_datapath_config_e config)
Set digital signal processing configuration.
Definition: ade9113.c:1096
no_os_irq.h
Header file of IRQ interface.
no_os_irq_register_callback
int32_t no_os_irq_register_callback(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id, struct no_os_callback_desc *callback_desc)
Register a callback to handle the irq events.
Definition: no_os_irq.c:92
ade9113_set_normal_mode
int ade9113_set_normal_mode(struct ade9113_dev *dev)
Set normal mode of operation.
Definition: ade9113.c:927
get_zero_cross_flag_state
int get_zero_cross_flag_state(void)
Get zero crossing flag value.
Definition: supply.c:71
ADE9113_ZX_INPUT_SIGNAL_SIGN
@ ADE9113_ZX_INPUT_SIGNAL_SIGN
Definition: ade9113.h:275
ade9113_dev::i_wav
int32_t * i_wav
Definition: ade9113.h:356
stout
Structure for Stout machine.
Definition: state_machine.h:185
device
Definition: ad9361_util.h:69
ade9113_init
int ade9113_init(struct ade9113_dev **device, struct ade9113_init_param init_param)
Initialize the device.
Definition: ade9113.c:395
rms_adc_values_read
int rms_adc_values_read(struct stout *stout, struct rms_adc_values *rms)
saves the current and voltage values in rms_adc structure
Definition: supply.c:351
ADE9113_V1_WAV
@ ADE9113_V1_WAV
Definition: ade9113.h:318
no_os_print_log.h
Print messages helpers.
ade9113_dev::gpio_rdy
struct no_os_gpio_desc * gpio_rdy
Definition: ade9113.h:362
supply_scale_v2
int32_t supply_scale_v2(int32_t val)
Scale V2 value.
Definition: supply.c:284
no_os_gpio_direction_input
int32_t no_os_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition: no_os_gpio.c:124
ADE9113_ZX_V1_SEL
@ ADE9113_ZX_V1_SEL
Definition: ade9113.h:294
NO_OS_IRQ_EDGE_FALLING
@ NO_OS_IRQ_EDGE_FALLING
Definition: no_os_irq.h:79
supply.h
Power supply phase interface file.
ade9113_init_param::irq_ctrl
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: ade9113.h:336
supply_scale_v1
int32_t supply_scale_v1(int32_t val)
Scale V1 value.
Definition: supply.c:269
no_os_irq_set_priority
int32_t no_os_irq_set_priority(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id, uint32_t priority_level)
Set the priority for an interrupt.
Definition: no_os_irq.c:216
ade9113_select_zero_crossing_channel
int ade9113_select_zero_crossing_channel(struct ade9113_dev *dev, enum ade9113_zx_channel_cfg_e cfg)
Select zero crossing channel.
Definition: ade9113.c:1812
pr_debug
#define pr_debug(fmt, args...)
Definition: no_os_print_log.h:129
ADE9113_I_WAV
@ ADE9113_I_WAV
Definition: ade9113.h:316
rms_adc_values::v2_rms
int32_t v2_rms
Definition: state_machine.h:231
no_os_get_unaligned_le24
uint32_t no_os_get_unaligned_le24(uint8_t *buf)
rms_filter_v1
int64_t rms_filter_v1(int32_t sample)
Compute v1 rms value.
Definition: supply.c:299
ade9113_select_zero_crossing_edge
int ade9113_select_zero_crossing_edge(struct ade9113_dev *dev, enum ade9113_zx_edge_sel_e sel)
Select zero crossing edge.
Definition: ade9113.c:1793
ADE9113_V2_WAV
@ ADE9113_V2_WAV
Definition: ade9113.h:320
rms_adc_values
Definition: state_machine.h:224
INITIAL
#define INITIAL
Definition: supply.h:48
supply_scale_v2
int32_t supply_scale_v2(int32_t val)
Scale V2 value.
Definition: supply.c:284
ade9113_remove
int ade9113_remove(struct ade9113_dev *dev)
Remove the device and release resources.
Definition: ade9113.c:621
V2_DIVIDER
#define V2_DIVIDER
Definition: supply.h:45
V1_MULT
#define V1_MULT
Definition: supply.h:43
no_os_irq_ctrl_init
int32_t no_os_irq_ctrl_init(struct no_os_irq_ctrl_desc **desc, const struct no_os_irq_init_param *param)
Initialize the IRQ interrupts.
Definition: no_os_irq.c:45
ade9113_dev::irq_ctrl
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: ade9113.h:366
no_os_callback_desc::callback
void(* callback)(void *context)
Definition: no_os_irq.h:144
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
rms_filter_i
int64_t rms_filter_i(int32_t sample)
Compute i rms value.
Definition: supply.c:333
supply_init
int supply_init(struct ade9113_dev **device)
Initialize supply component.
Definition: supply.c:156
ade9113_gpio_ZX_ip
struct no_os_gpio_init_param ade9113_gpio_ZX_ip
Definition: common_data.c:104
ade9113_dev::v1_wav
int32_t * v1_wav
Definition: ade9113.h:358
reset_zero_cross_flag_state
void reset_zero_cross_flag_state(void)
Reset zero crossing flag value.
Definition: supply.c:81
state_machine.h
STOUT state machine header file.
rms_filter_i
int64_t rms_filter_i(int32_t sample)
Compute i rms value.
Definition: supply.c:333
supply_init
int supply_init(struct ade9113_dev **device)
Initialize supply component.
Definition: supply.c:156
rms_filter_v2
int64_t rms_filter_v2(int32_t sample)
Compute v2 rms value.
Definition: supply.c:316
ADE9113_3_CHANNEL_ADE9113
#define ADE9113_3_CHANNEL_ADE9113
Definition: ade9113.h:205
GPIO_ZC_PIN
#define GPIO_ZC_PIN
Definition: parameters.h:91
ade9113_set_crc_en_state
int ade9113_set_crc_en_state(struct ade9113_dev *dev, uint8_t crc_en_state)
Set CRC enable on SPI write setting.
Definition: ade9113.c:836
rms_filter_v1
int64_t rms_filter_v1(int32_t sample)
Compute v1 rms value.
Definition: supply.c:299
ADE9113_2_CHANNEL_ADE9112
#define ADE9113_2_CHANNEL_ADE9112
Definition: ade9113.h:206
supply_scale_v1
int32_t supply_scale_v1(int32_t val)
Scale V1 value.
Definition: supply.c:269
NULL
#define NULL
Definition: wrapper.h:64
NO_OS_EVT_GPIO
@ NO_OS_EVT_GPIO
Definition: no_os_irq.h:62
rms_adc_values::i_rms_adc
int32_t i_rms_adc
Definition: state_machine.h:233
rms_adc_values::v1_rms
int32_t v1_rms
Definition: state_machine.h:229
no_os_irq_ctrl_remove
int32_t no_os_irq_ctrl_remove(struct no_os_irq_ctrl_desc *desc)
Free the resources allocated by no_os_irq_ctrl_init().
Definition: no_os_irq.c:71
no_os_irq_enable
int32_t no_os_irq_enable(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id)
Enable specific interrupt.
Definition: no_os_irq.c:181
NO_OS_GPIO_IRQ
@ NO_OS_GPIO_IRQ
Definition: no_os_irq.h:85
ade9113_dev::v2_wav
int32_t * v2_wav
Definition: ade9113.h:360
rms_adc_values::v1_rms_adc
int32_t v1_rms_adc
Definition: state_machine.h:235
ade9113_gpio_irq_ip
struct no_os_irq_init_param ade9113_gpio_irq_ip
Definition: common_data.c:162
no_os_sign_extend32
int32_t no_os_sign_extend32(uint32_t value, int index)
no_os_irq_trigger_level_set
int32_t no_os_irq_trigger_level_set(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id, enum no_os_irq_trig_level trig)
Set interrupt trigger level.
Definition: no_os_irq.c:162
ade9113_dev
ADE9113 Device structure.
Definition: ade9113.h:348
no_os_irq_disable
int32_t no_os_irq_disable(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id)
Disable specific interrupt.
Definition: no_os_irq.c:198
ADE9113_NONISOLATED_ADE9103
#define ADE9113_NONISOLATED_ADE9103
Definition: ade9113.h:207
no_os_irq_ctrl_desc
Definition: no_os_irq.h:123
rms_adc_values::i_rms
int32_t i_rms
Definition: state_machine.h:227
rms_filter_v2
int64_t rms_filter_v2(int32_t sample)
Compute v2 rms value.
Definition: supply.c:316
no_os_gpio_desc::number
int32_t number
Definition: no_os_gpio.h:100
reset_zero_cross_flag_state
void reset_zero_cross_flag_state(void)
Reset zero crossing flag value.
Definition: supply.c:81
no_os_gpio_get_optional
int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Get the value of an optional GPIO.
Definition: no_os_gpio.c:75