LibDriver ENS160
Loading...
Searching...
No Matches
driver_ens160.h File Reference

driver ens160 header file More...

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

Go to the source code of this file.

Data Structures

struct  ens160_handle_s
 ens160 handle structure definition More...
struct  ens160_info_s
 ens160 information structure definition More...

Macros

#define DRIVER_ENS160_LINK_INIT(HANDLE, STRUCTURE)
 initialize ens160_handle_t structure
#define DRIVER_ENS160_LINK_IIC_INIT(HANDLE, FUC)
 link iic_init function
#define DRIVER_ENS160_LINK_IIC_DEINIT(HANDLE, FUC)
 link iic_deinit function
#define DRIVER_ENS160_LINK_IIC_READ(HANDLE, FUC)
 link iic_read function
#define DRIVER_ENS160_LINK_IIC_WRITE(HANDLE, FUC)
 link iic_write function
#define DRIVER_ENS160_LINK_SPI_INIT(HANDLE, FUC)
 link spi_init function
#define DRIVER_ENS160_LINK_SPI_DEINIT(HANDLE, FUC)
 link spi_deinit function
#define DRIVER_ENS160_LINK_SPI_READ(HANDLE, FUC)
 link spi_read function
#define DRIVER_ENS160_LINK_SPI_WRITE(HANDLE, FUC)
 link spi_write function
#define DRIVER_ENS160_LINK_DELAY_MS(HANDLE, FUC)
 link delay_ms function
#define DRIVER_ENS160_LINK_DEBUG_PRINT(HANDLE, FUC)
 link debug_print function
#define DRIVER_ENS160_LINK_RECEIVE_CALLBACK(HANDLE, FUC)
 link receive_callback function

Typedefs

typedef struct ens160_handle_s ens160_handle_t
 ens160 handle structure definition
typedef struct ens160_info_s ens160_info_t
 ens160 information structure definition

Enumerations

enum  ens160_interface_t { ENS160_INTERFACE_IIC = 0x00 , ENS160_INTERFACE_SPI = 0x01 }
 ens160 interface enumeration definition More...
enum  ens160_address_t { ENS160_ADDRESS_0 = (0x52 << 1) , ENS160_ADDRESS_1 = (0x53 << 1) }
 ens160 address enumeration definition More...
enum  ens160_bool_t { ENS160_BOOL_FALSE = 0x00 , ENS160_BOOL_TRUE = 0x01 }
 ens160 bool enumeration definition More...
enum  ens160_mode_t { ENS160_MODE_DEEP_SLEEP = 0x00 , ENS160_MODE_IDLE = 0x01 , ENS160_MODE_STANDARD = 0x02 }
 ens160 mode enumeration definition More...
enum  ens160_pin_polarity_t { ENS160_PIN_POLARITY_LOW = 0x00 , ENS160_PIN_POLARITY_HIGH = 0x01 }
 ens160 pin polarity enumeration definition More...
enum  ens160_pin_drive_t { ENS160_PIN_DRIVE_OPEN_DRAIN = 0x00 , ENS160_PIN_DRIVE_PUSH_PULL = 0x01 }
 ens160 pin drive enumeration definition More...
enum  ens160_status_t {
  ENS160_STATUS_RUNNING = (1 << 7) , ENS160_STATUS_ERROR = (1 << 6) , ENS160_STATUS_NORMAL = (0 << 2) , ENS160_STATUS_WARM_UP = (1 << 2) ,
  ENS160_STATUS_START_UP = (2 << 2) , ENS160_STATUS_INVALID = (3 << 2) , ENS160_STATUS_NEWDAT = (1 << 1) , ENS160_STATUS_NEWGPR = (1 << 0)
}
 ens160 status enumeration definition More...

Functions

uint8_t ens160_info (ens160_info_t *info)
 get chip's information
uint8_t ens160_set_interface (ens160_handle_t *handle, ens160_interface_t interface)
 set the chip interface
uint8_t ens160_get_interface (ens160_handle_t *handle, ens160_interface_t *interface)
 get the chip interface
uint8_t ens160_set_addr_pin (ens160_handle_t *handle, ens160_address_t addr_pin)
 set the iic address pin
uint8_t ens160_get_addr_pin (ens160_handle_t *handle, ens160_address_t *addr_pin)
 get the iic address pin
uint8_t ens160_irq_handler (ens160_handle_t *handle)
 irq handler
uint8_t ens160_init (ens160_handle_t *handle)
 initialize the chip
uint8_t ens160_deinit (ens160_handle_t *handle)
 close the chip
uint8_t ens160_read_aqi (ens160_handle_t *handle, uint8_t *uba)
 read aqi
uint8_t ens160_read_tvoc (ens160_handle_t *handle, uint16_t *tvoc_ppb)
 read tvoc
uint8_t ens160_read_eco2 (ens160_handle_t *handle, uint16_t *eco2_ppm)
 read eco2
uint8_t ens160_read_etoh (ens160_handle_t *handle, uint16_t *etoh_ppb)
 read etoh
uint8_t ens160_set_mode (ens160_handle_t *handle, ens160_mode_t mode)
 set mode
uint8_t ens160_get_mode (ens160_handle_t *handle, ens160_mode_t *mode)
 get mode
uint8_t ens160_soft_reset (ens160_handle_t *handle)
 soft reset
uint8_t ens160_set_interrupt_pin_polarity (ens160_handle_t *handle, ens160_pin_polarity_t polarity)
 set interrupt pin polarity
uint8_t ens160_get_interrupt_pin_polarity (ens160_handle_t *handle, ens160_pin_polarity_t *polarity)
 get interrupt pin polarity
uint8_t ens160_set_interrupt_pin_drive (ens160_handle_t *handle, ens160_pin_drive_t drive)
 set interrupt pin drive
uint8_t ens160_get_interrupt_pin_drive (ens160_handle_t *handle, ens160_pin_drive_t *drive)
 get interrupt pin drive
uint8_t ens160_set_general_purpose_read_interrupt_pin_asserted (ens160_handle_t *handle, ens160_bool_t enable)
 set general purpose read interrupt pin asserted
uint8_t ens160_get_general_purpose_read_interrupt_pin_asserted (ens160_handle_t *handle, ens160_bool_t *enable)
 get general purpose read interrupt pin asserted
uint8_t ens160_set_data_interrupt_pin_asserted (ens160_handle_t *handle, ens160_bool_t enable)
 set data interrupt pin asserted
uint8_t ens160_get_data_interrupt_pin_asserted (ens160_handle_t *handle, ens160_bool_t *enable)
 get data interrupt pin asserted
uint8_t ens160_set_interrupt (ens160_handle_t *handle, ens160_bool_t enable)
 enable or disable interrupt
uint8_t ens160_get_interrupt (ens160_handle_t *handle, ens160_bool_t *enable)
 get interrupt
uint8_t ens160_nop (ens160_handle_t *handle)
 nop
uint8_t ens160_get_app_version (ens160_handle_t *handle, uint8_t *major, uint8_t *minor, uint8_t *release)
 get app version
uint8_t ens160_clear (ens160_handle_t *handle)
 clear
uint8_t ens160_set_temperature_compensation (ens160_handle_t *handle, uint16_t raw)
 set temperature compensation
uint8_t ens160_get_temperature_compensation (ens160_handle_t *handle, uint16_t *raw)
 get temperature compensation
uint8_t ens160_set_humidity_compensation (ens160_handle_t *handle, uint16_t raw)
 set humidity compensation
uint8_t ens160_get_humidity_compensation (ens160_handle_t *handle, uint16_t *raw)
 get humidity compensation
uint8_t ens160_get_status (ens160_handle_t *handle, uint8_t *status)
 get status
uint8_t ens160_get_calculation_temperature (ens160_handle_t *handle, uint16_t *raw)
 get calculation temperature
uint8_t ens160_get_calculation_humidity (ens160_handle_t *handle, uint16_t *raw)
 get calculation humidity
uint8_t ens160_get_checksum (ens160_handle_t *handle, uint8_t *checksum)
 get checksum
uint8_t ens160_set_params (ens160_handle_t *handle, uint8_t params[8])
 set params
uint8_t ens160_get_params (ens160_handle_t *handle, uint8_t params[8])
 get params
uint8_t ens160_get_params_output (ens160_handle_t *handle, uint8_t params[8])
 get params output
uint8_t ens160_temperature_convert_to_register (ens160_handle_t *handle, float celsius_deg, uint16_t *reg)
 convert the temperature to the register raw data
uint8_t ens160_temperature_convert_to_data (ens160_handle_t *handle, uint16_t reg, float *celsius_deg)
 convert the register raw data to the temperature
uint8_t ens160_humidity_convert_to_register (ens160_handle_t *handle, float percentage, uint16_t *reg)
 convert the humidity to the register raw data
uint8_t ens160_humidity_convert_to_data (ens160_handle_t *handle, uint16_t reg, float *percentage)
 convert the register raw data to the humidity
uint8_t ens160_resistance_convert_to_register (ens160_handle_t *handle, float ohm, uint16_t *reg)
 convert the resistance to the register raw data
uint8_t ens160_resistance_convert_to_data (ens160_handle_t *handle, uint16_t reg, float *ohm)
 convert the register raw data to the resistance
uint8_t ens160_resistance_split (ens160_handle_t *handle, uint8_t raw[8], uint16_t *resistance0, uint16_t *resistance1, uint16_t *resistance2, uint16_t *resistance3)
 resistance split
uint8_t ens160_set_reg (ens160_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 set the chip register
uint8_t ens160_get_reg (ens160_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 get the chip register

Detailed Description

driver ens160 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
2026-02-23

history

Date Version Author Description
2026/02/23 1.0 Shifeng Li first upload

Definition in file driver_ens160.h.