LibDriver HLW8032
Loading...
Searching...
No Matches
driver_hlw8032.h File Reference

driver hlw8032 header file More...

#include <stdio.h>
#include <stdint.h>
#include <string.h>
Include dependency graph for driver_hlw8032.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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...

Macros

#define HLW8032_VOLTAGE_COEFFICIENT   1.88f
 hlw8032 voltage coefficient definition
#define HLW8032_CURRENT_COEFFICIENT   1.0f
 hlw8032 current coefficient definition
#define HLW8032_VOLTAGE_K1   2.045f
 hlw8032 voltage k1 definition
#define HLW8032_CURRENT_K2   1.0f
 hlw8032 current k2 definition
#define HLW8032_POWER_K3   2.045f
 hlw8032 power k3 definition
#define DRIVER_HLW8032_LINK_INIT(HANDLE, STRUCTURE)
 initialize hlw8032_handle_t structure
#define DRIVER_HLW8032_LINK_UART_INIT(HANDLE, FUC)
 link uart_init function
#define DRIVER_HLW8032_LINK_UART_DEINIT(HANDLE, FUC)
 link uart_deinit function
#define DRIVER_HLW8032_LINK_UART_READ(HANDLE, FUC)
 link uart_read function
#define DRIVER_HLW8032_LINK_UART_FLUSH(HANDLE, FUC)
 link uart_flush function
#define DRIVER_HLW8032_LINK_DELAY_MS(HANDLE, FUC)
 link delay_ms function
#define DRIVER_HLW8032_LINK_DEBUG_PRINT(HANDLE, FUC)
 link debug_print function

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
uint8_t hlw8032_get_buffer (hlw8032_handle_t *handle, char *buf, uint16_t len, uint32_t ms)
 get buffer

Detailed Description

driver hlw8032 header file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2025-09-15

history

Date Version Author Description
2025/09/15 1.0 Shifeng Li first upload

Definition in file driver_hlw8032.h.