Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
69 #define PWRMETER3_REG_EEPROM_0B 0x0B
70 #define PWRMETER3_REG_EEPROM_0C 0x0C
71 #define PWRMETER3_REG_EEPROM_0D 0x0D
72 #define PWRMETER3_REG_EEPROM_0E 0x0E
73 #define PWRMETER3_REG_EEPROM_0F 0x0F
82 #define PWRMETER3_REG_SHADOW_1B 0x1B
83 #define PWRMETER3_REG_SHADOW_1C 0x1C
84 #define PWRMETER3_REG_SHADOW_1D 0x1D
85 #define PWRMETER3_REG_SHADOW_1E 0x1E
86 #define PWRMETER3_REG_SHADOW_1F 0x1F
92 #define PWRMETER3_REG_VOLATILE_20 0x20
93 #define PWRMETER3_REG_VOLATILE_21 0x21
94 #define PWRMETER3_REG_VOLATILE_22 0x22
95 #define PWRMETER3_REG_VOLATILE_25 0x25
96 #define PWRMETER3_REG_VOLATILE_26 0x26
97 #define PWRMETER3_REG_VOLATILE_27 0x27
98 #define PWRMETER3_REG_VOLATILE_28 0x28
99 #define PWRMETER3_REG_VOLATILE_29 0x29
100 #define PWRMETER3_REG_VOLATILE_2A 0x2A
101 #define PWRMETER3_REG_VOLATILE_2C 0x2C
102 #define PWRMETER3_REG_VOLATILE_2D 0x2D
103 #define PWRMETER3_REG_VOLATILE_2F 0x2F
104 #define PWRMETER3_REG_VOLATILE_30 0x30
122 #define PWRMETER3_CUST_ACCESS_CODE 0x4F70656Eul
123 #define PWRMETER3_CUST_ACCESS_CODE_CLEAR 0x00000000ul
129 #define PWRMETER3_VEVENT_CYCS_MASK 0x0000003Ful
130 #define PWRMETER3_OVERVREG_MASK 0x00003F00ul
131 #define PWRMETER3_UNDERVREG_MASK 0x000FC000ul
132 #define PWRMETER3_DELAYCNT_SEL_MASK 0x00100000ul
133 #define PWRMETER3_HALFCYCLC_EN_MASK 0x00200000ul
134 #define PWRMETER3_SQUAREWAVE_EN_MASK 0x00400000ul
135 #define PWRMETER3_ZEROCROSSCHANSEL_MASK 0x00800000ul
136 #define PWRMETER3_ZEROCROSSEDGESEL_MASK 0x01000000ul
137 #define PWRMETER3_ECC_MASK 0xFC000000ul
138 #define PWRMETER3_OVERVREG_MAX 63
139 #define PWRMETER3_UNDERVREG_MAX 63
140 #define PWRMETER3_OVERVREG_3 3
141 #define PWRMETER3_UNDERVREG_1 1
147 #define PWRMETER3_I2C_SLV_ADDR_MASK 0x000001FCul
148 #define PWRMETER3_I2C_DIS_SLV_ADDR 0x00000200ul
149 #define PWRMETER3_DIO_0_SEL_MASK 0x00000C00ul
150 #define PWRMETER3_DIO_1_SEL_MASK 0x00003000ul
151 #define PWRMETER3_N_MASK 0x00FFC000ul
152 #define PWRMETER3_BYPASS_N_EN_MASK 0x01000000ul
153 #define PWRMETER3_DIO_0_SEL_ZC 0
154 #define PWRMETER3_DIO_0_SEL_OV 1
155 #define PWRMETER3_DIO_0_SEL_UV 2
156 #define PWRMETER3_DIO_0_SEL_OV_UV 3
157 #define PWRMETER3_DIO_1_SEL_OCF 0
158 #define PWRMETER3_DIO_1_SEL_UV 1
159 #define PWRMETER3_DIO_1_SEL_OV 2
160 #define PWRMETER3_DIO_1_SEL_OV_UV_OCF 3
161 #define PWRMETER3_BYPASS_N_DISABLE 0
162 #define PWRMETER3_BYPASS_N_ENABLE 1
163 #define PWRMETER3_MAX_NUM_SAMPLES 1023u
169 #define PWRMETER3_RSENSE_OHM 2000.0f
170 #define PWRMETER3_AC_RDIV_OHM 2000000.0f
171 #define PWRMETER3_DC_RDIV_OHM 4000000.0f
172 #define PWRMETER3_ADC_FSCALE 55000u
173 #define PWRMETER3_DELTA_VIN_MAX_mV 250
174 #define PWRMETER3_mV_TO_V 1000u
175 #define PWRMETER3_MAX_CURRENT 90
176 #define PWRMETER3_DEF_AVG_SAMPLES 500u
183 #define PWRMETER3_DEVICE_ADDRESS_0 0x60
184 #define PWRMETER3_DEVICE_ADDRESS_1 0x61
185 #define PWRMETER3_DEVICE_ADDRESS_2 0x64
186 #define PWRMETER3_DEVICE_ADDRESS_3 0x65
204 #define PWRMETER3_MAP_MIKROBUS( cfg, mikrobus ) \
205 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
206 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
207 cfg.dio1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
208 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
209 cfg.dio0 = MIKROBUS( mikrobus, MIKROBUS_INT )
526 #endif // PWRMETER3_H
pin_name_t dio1
Definition: pwrmeter3.h:246
err_t pwrmeter3_set_bypass_n_state(pwrmeter3_t *ctx, uint8_t state)
PWR Meter 3 set bypass n state function.
err_t pwrmeter3_init(pwrmeter3_t *ctx, pwrmeter3_cfg_t *cfg)
PWR Meter 3 initialization function.
err_t pwrmeter3_set_ovrms_threshold(pwrmeter3_t *ctx, uint8_t ovrms)
PWR Meter 3 set ovrms threshold function.
@ PWRMETER3_OK
Definition: pwrmeter3.h:261
uint8_t pwrmeter3_get_dio1_pin(pwrmeter3_t *ctx)
PWR Meter 3 get dio1 pin function.
pin_name_t dio0
Definition: pwrmeter3.h:247
err_t pwrmeter3_set_dio1_sel(pwrmeter3_t *ctx, uint8_t dio_sel)
PWR Meter 3 set dio1 sel function.
uint8_t pwrmeter3_get_dio0_pin(pwrmeter3_t *ctx)
PWR Meter 3 get dio0 pin function.
err_t pwrmeter3_read_register(pwrmeter3_t *ctx, uint8_t reg, uint32_t *data_out)
PWR Meter 3 read register function.
pin_name_t scl
Definition: pwrmeter3.h:243
uint8_t bypass_n_en
Definition: pwrmeter3.h:233
err_t pwrmeter3_set_dio0_sel(pwrmeter3_t *ctx, uint8_t dio_sel)
PWR Meter 3 set dio0 sel function.
uint8_t i2c_address
Definition: pwrmeter3.h:251
err_t pwrmeter3_allow_write_access(pwrmeter3_t *ctx)
PWR Meter 3 allow write access function.
err_t pwrmeter3_default_cfg(pwrmeter3_t *ctx)
PWR Meter 3 default configuration function.
PWR Meter 3 Click context object.
Definition: pwrmeter3.h:219
err_t pwrmeter3_set_num_samples(pwrmeter3_t *ctx, uint16_t num_samples)
PWR Meter 3 set num samples function.
err_t pwrmeter3_deny_write_access(pwrmeter3_t *ctx)
PWR Meter 3 deny write access function.
pin_name_t en
Definition: pwrmeter3.h:248
void pwrmeter3_disable_device(pwrmeter3_t *ctx)
PWR Meter 3 disable device function.
@ PWRMETER3_ERROR
Definition: pwrmeter3.h:262
void pwrmeter3_cfg_setup(pwrmeter3_cfg_t *cfg)
PWR Meter 3 configuration object setup function.
pwrmeter3_return_value_t
PWR Meter 3 Click return value data.
Definition: pwrmeter3.h:260
uint32_t i2c_speed
Definition: pwrmeter3.h:250
void pwrmeter3_enable_device(pwrmeter3_t *ctx)
PWR Meter 3 enable device function.
err_t pwrmeter3_write_register(pwrmeter3_t *ctx, uint8_t reg, uint32_t data_in)
PWR Meter 3 write register function.
digital_out_t en
Definition: pwrmeter3.h:221
err_t pwrmeter3_read_average_rms(pwrmeter3_t *ctx, float *v_rms, float *i_rms, uint16_t num_avg)
PWR Meter 3 read average rms function.
digital_in_t dio1
Definition: pwrmeter3.h:224
i2c_master_t i2c
Definition: pwrmeter3.h:228
digital_in_t dio0
Definition: pwrmeter3.h:225
uint8_t slave_address
Definition: pwrmeter3.h:231
PWR Meter 3 Click configuration object.
Definition: pwrmeter3.h:242
err_t pwrmeter3_set_uvrms_threshold(pwrmeter3_t *ctx, uint8_t uvrms)
PWR Meter 3 set uvrms threshold function.
pin_name_t sda
Definition: pwrmeter3.h:244
err_t pwrmeter3_read_rms(pwrmeter3_t *ctx, float *v_rms, float *i_rms)
PWR Meter 3 read rms function.