LibDriver HLW8032
Loading...
Searching...
No Matches
hlw8032 basic driver function

hlw8032 basic driver modules More...

Collaboration diagram for hlw8032 basic driver function:

Data Structures

struct  hlw8032_data_s
 hlw8032 data structure definition More...
struct  hlw8032_handle_s
 hlw8032 handle structure definition More...
struct  hlw8032_info_s
 hlw8032 information structure definition More...

Typedefs

typedef struct hlw8032_data_s hlw8032_data_t
 hlw8032 data structure definition
typedef struct hlw8032_handle_s hlw8032_handle_t
 hlw8032 handle structure definition
typedef struct hlw8032_info_s hlw8032_info_t
 hlw8032 information structure definition

Enumerations

enum  hlw8032_mode_t { HLW8032_MODE_SAMPLE = 0 , HLW8032_MODE_TRANSFORMER = 1 }
 hlw8032 mode enumeration definition More...
enum  hlw8032_status_t { HLW8032_STATUS_VOLTAGE_OVERFLOW = (1 << 3) , HLW8032_STATUS_CURRENT_OVERFLOW = (1 << 2) , HLW8032_STATUS_POWER_OVERFLOW = (1 << 1) , HLW8032_STATUS_REGISTER_INVALID = (1 << 0) }
 hlw8032 status enumeration definition More...
enum  hlw8032_update_status_t { HLW8032_UPDATE_STATUS_PF_OVERFLOW = (1 << 7) , HLW8032_UPDATE_STATUS_VOLTAGE_UPDATED = (1 << 6) , HLW8032_UPDATE_STATUS_CURRENT_UPDATED = (1 << 5) , HLW8032_UPDATE_STATUS_POWER_UPDATED = (1 << 4) }
 hlw8032 update status enumeration definition More...

Functions

uint8_t hlw8032_info (hlw8032_info_t *info)
 get chip's information
uint8_t hlw8032_init (hlw8032_handle_t *handle)
 initialize the chip
uint8_t hlw8032_deinit (hlw8032_handle_t *handle)
 close the chip
uint8_t hlw8032_read (hlw8032_handle_t *handle, hlw8032_data_t *data)
 read the data
uint8_t hlw8032_set_mode (hlw8032_handle_t *handle, hlw8032_mode_t mode)
 set mode
uint8_t hlw8032_get_mode (hlw8032_handle_t *handle, hlw8032_mode_t *mode)
 get mode
uint8_t hlw8032_quantity_electricity_export (hlw8032_handle_t *handle, int64_t *quantity_electricity_counter)
 quantity electricity export
uint8_t hlw8032_quantity_electricity_import (hlw8032_handle_t *handle, int64_t quantity_electricity_counter)
 quantity electricity import
uint8_t hlw8032_set_sample_voltage_coefficient (hlw8032_handle_t *handle, float coeff)
 set sample voltage coefficient
uint8_t hlw8032_get_sample_voltage_coefficient (hlw8032_handle_t *handle, float *coeff)
 get sample voltage coefficient
uint8_t hlw8032_set_sample_current_coefficient (hlw8032_handle_t *handle, float coeff)
 set sample current coefficient
uint8_t hlw8032_get_sample_current_coefficient (hlw8032_handle_t *handle, float *coeff)
 get sample current coefficient
uint8_t hlw8032_set_transformer_voltage_k1 (hlw8032_handle_t *handle, float coeff)
 set transformer voltage k1
uint8_t hlw8032_get_transformer_voltage_k1 (hlw8032_handle_t *handle, float *coeff)
 get transformer voltage k1
uint8_t hlw8032_set_transformer_current_k2 (hlw8032_handle_t *handle, float coeff)
 set transformer current k2
uint8_t hlw8032_get_transformer_current_k2 (hlw8032_handle_t *handle, float *coeff)
 get transformer current k2
uint8_t hlw8032_set_transformer_power_k3 (hlw8032_handle_t *handle, float coeff)
 set transformer power k3
uint8_t hlw8032_get_transformer_power_k3 (hlw8032_handle_t *handle, float *coeff)
 get transformer power k3

Detailed Description

hlw8032 basic driver modules

Typedef Documentation

◆ hlw8032_data_t

hlw8032 data structure definition

◆ hlw8032_handle_t

hlw8032 handle structure definition

◆ hlw8032_info_t

hlw8032 information structure definition

Enumeration Type Documentation

◆ hlw8032_mode_t

hlw8032 mode enumeration definition

Enumerator
HLW8032_MODE_SAMPLE 

sample

HLW8032_MODE_TRANSFORMER 

transformer

Definition at line 97 of file driver_hlw8032.h.

◆ hlw8032_status_t

hlw8032 status enumeration definition

Enumerator
HLW8032_STATUS_VOLTAGE_OVERFLOW 

voltage overflow

HLW8032_STATUS_CURRENT_OVERFLOW 

current overflow

HLW8032_STATUS_POWER_OVERFLOW 

power overflow

HLW8032_STATUS_REGISTER_INVALID 

register invalid

Definition at line 106 of file driver_hlw8032.h.

◆ hlw8032_update_status_t

hlw8032 update status enumeration definition

Enumerator
HLW8032_UPDATE_STATUS_PF_OVERFLOW 

pf overflow

HLW8032_UPDATE_STATUS_VOLTAGE_UPDATED 

voltage updated

HLW8032_UPDATE_STATUS_CURRENT_UPDATED 

current updated

HLW8032_UPDATE_STATUS_POWER_UPDATED 

power updated

Definition at line 117 of file driver_hlw8032.h.

Function Documentation

◆ hlw8032_deinit()

uint8_t hlw8032_deinit ( hlw8032_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to a hlw8032 handle structure
Returns
status code
  • 0 success
  • 1 uart deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 133 of file driver_hlw8032.c.

◆ hlw8032_get_mode()

uint8_t hlw8032_get_mode ( hlw8032_handle_t * handle,
hlw8032_mode_t * mode )

get mode

Parameters
[in]*handlepointer to a hlw8032 handle structure
[out]*modepointer to a chip mode buffer
Returns
status code
  • 0 success
  • 1 get mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 562 of file driver_hlw8032.c.

◆ hlw8032_get_sample_current_coefficient()

uint8_t hlw8032_get_sample_current_coefficient ( hlw8032_handle_t * handle,
float * coeff )

get sample current coefficient

Parameters
[in]*handlepointer to a hlw8032 handle structure
[out]*coeffpointer to a current coefficient buffer
Returns
status code
  • 0 success
  • 1 get sample current coefficient failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 670 of file driver_hlw8032.c.

◆ hlw8032_get_sample_voltage_coefficient()

uint8_t hlw8032_get_sample_voltage_coefficient ( hlw8032_handle_t * handle,
float * coeff )

get sample voltage coefficient

Parameters
[in]*handlepointer to a hlw8032 handle structure
[out]*coeffpointer to a voltage coefficient buffer
Returns
status code
  • 0 success
  • 1 get sample voltage coefficient failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 616 of file driver_hlw8032.c.

◆ hlw8032_get_transformer_current_k2()

uint8_t hlw8032_get_transformer_current_k2 ( hlw8032_handle_t * handle,
float * coeff )

get transformer current k2

Parameters
[in]*handlepointer to a hlw8032 handle structure
[out]*coeffpointer to a current coefficient buffer
Returns
status code
  • 0 success
  • 1 get transformer current k2 failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 778 of file driver_hlw8032.c.

◆ hlw8032_get_transformer_power_k3()

uint8_t hlw8032_get_transformer_power_k3 ( hlw8032_handle_t * handle,
float * coeff )

get transformer power k3

Parameters
[in]*handlepointer to a hlw8032 handle structure
[out]*coeffpointer to a power coefficient buffer
Returns
status code
  • 0 success
  • 1 get transformer power k3 failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 832 of file driver_hlw8032.c.

◆ hlw8032_get_transformer_voltage_k1()

uint8_t hlw8032_get_transformer_voltage_k1 ( hlw8032_handle_t * handle,
float * coeff )

get transformer voltage k1

Parameters
[in]*handlepointer to a hlw8032 handle structure
[out]*coeffpointer to a voltage coefficient buffer
Returns
status code
  • 0 success
  • 1 get transformer voltage k1 failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 724 of file driver_hlw8032.c.

◆ hlw8032_info()

uint8_t hlw8032_info ( hlw8032_info_t * info)

get chip's information

Parameters
[out]*infopointer to a hlw8032 info structure
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 902 of file driver_hlw8032.c.

◆ hlw8032_init()

uint8_t hlw8032_init ( hlw8032_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to a hlw8032 handle structure
Returns
status code
  • 0 success
  • 1 uart initialization failed
  • 2 handle is NULL
  • 3 linked functions is NULL
Note
none

Definition at line 61 of file driver_hlw8032.c.

◆ hlw8032_quantity_electricity_export()

uint8_t hlw8032_quantity_electricity_export ( hlw8032_handle_t * handle,
int64_t * quantity_electricity_counter )

quantity electricity export

Parameters
[in]*handlepointer to a hlw8032 handle structure
[out]*quantity_electricity_counterpointer to a quantity electricity counter buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 420 of file driver_hlw8032.c.

◆ hlw8032_quantity_electricity_import()

uint8_t hlw8032_quantity_electricity_import ( hlw8032_handle_t * handle,
int64_t quantity_electricity_counter )

quantity electricity import

Parameters
[in]*handlepointer to a hlw8032 handle structure
[in]quantity_electricity_counterquantity electricity counter
Returns
status code
  • 0 success
  • 1 import failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 frame is error
Note
none

Definition at line 448 of file driver_hlw8032.c.

◆ hlw8032_read()

uint8_t hlw8032_read ( hlw8032_handle_t * handle,
hlw8032_data_t * data )

read the data

Parameters
[in]*handlepointer to a hlw8032 handle structure
[out]*datapointer to a data structure
Returns
status code
  • 0 success
  • 1 read failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 frame is error
  • 5 data is invalid
Note
none

Definition at line 168 of file driver_hlw8032.c.

◆ hlw8032_set_mode()

uint8_t hlw8032_set_mode ( hlw8032_handle_t * handle,
hlw8032_mode_t mode )

set mode

Parameters
[in]*handlepointer to a hlw8032 handle structure
[in]modechip mode
Returns
status code
  • 0 success
  • 1 set mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 535 of file driver_hlw8032.c.

◆ hlw8032_set_sample_current_coefficient()

uint8_t hlw8032_set_sample_current_coefficient ( hlw8032_handle_t * handle,
float coeff )

set sample current coefficient

Parameters
[in]*handlepointer to a hlw8032 handle structure
[in]coeffcurrent coefficient
Returns
status code
  • 0 success
  • 1 set sample current coefficient failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 643 of file driver_hlw8032.c.

◆ hlw8032_set_sample_voltage_coefficient()

uint8_t hlw8032_set_sample_voltage_coefficient ( hlw8032_handle_t * handle,
float coeff )

set sample voltage coefficient

Parameters
[in]*handlepointer to a hlw8032 handle structure
[in]coeffvoltage coefficient
Returns
status code
  • 0 success
  • 1 set sample voltage coefficient failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 589 of file driver_hlw8032.c.

◆ hlw8032_set_transformer_current_k2()

uint8_t hlw8032_set_transformer_current_k2 ( hlw8032_handle_t * handle,
float coeff )

set transformer current k2

Parameters
[in]*handlepointer to a hlw8032 handle structure
[in]coeffcurrent coefficient
Returns
status code
  • 0 success
  • 1 set transformer current k2 failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 751 of file driver_hlw8032.c.

◆ hlw8032_set_transformer_power_k3()

uint8_t hlw8032_set_transformer_power_k3 ( hlw8032_handle_t * handle,
float coeff )

set transformer power k3

Parameters
[in]*handlepointer to a hlw8032 handle structure
[in]coeffpower coefficient
Returns
status code
  • 0 success
  • 1 set transformer power k3 failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 805 of file driver_hlw8032.c.

◆ hlw8032_set_transformer_voltage_k1()

uint8_t hlw8032_set_transformer_voltage_k1 ( hlw8032_handle_t * handle,
float coeff )

set transformer voltage k1

Parameters
[in]*handlepointer to a hlw8032 handle structure
[in]coeffvoltage coefficient
Returns
status code
  • 0 success
  • 1 set transformer voltage k1 failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 697 of file driver_hlw8032.c.