1 /* 2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef APP_AHT20_H 17 #define APP_AHT20_H 18 19 #define AHT_SLEEP_20MS (20) // 20ms 20 #define AHT_SLEEP_50MS (50) // 5ms 21 #define AHT_SLEEP_1S (1000) // 1s 22 #define AHT_DELAY_10MS (10000) // 10ms 23 #define AHT_DELAY_40MS (40000) // 40ms 24 #define AHT_DELAY_100MS (100000) // 100ms 25 #define AHT_DEVICE_ADDR (0x38) // device addr 26 #define AHT_DEVICE_READ_STATUS (0x71) // befor read tem&humi data need to send cmd to comfir the 27 #define AHT_DEVICE_INIT_CMD (0xBE) // aht init cmd 28 #define AHT_DEVICE_TEST_CMD (0xAC) // test cmd 29 #define AHT_DEVICE_PARAM_HIGH_BYTE (0x33) 30 #define AHT_DEVICE_PARAM_LOW_BYTE (0x00) 31 #define AHT_DEVICE_PARAM_INIT_HIGH (0x08) 32 #define AHT_DEVICE_CALIBRATION (0x80) 33 #define AHT_DEVICE_CALIBRATION_ERR (0x1C) 34 #define AHT_DEVICE_CALIBRATION_ERR_R (0x18) 35 #define AHT_TASK_SLEEP_TIME (200) // thread sleep 20ms 36 #define BAUDRATE_INIT (400000) 37 38 typedef enum { 39 AHT_TEMPERATURE = 1, 40 AHT_HUMIDITY = 2, 41 }AhtSersonType; 42 43 typedef enum { 44 HI_I2C_SDA_SCL = 6, 45 } HiI2cConfig; 46 47 typedef struct { 48 float g_ahtTemper; 49 float g_ahtHumi; 50 } AhtSersonValue; 51 52 float GetAhtSensorValue(AhtSersonType type); 53 void GetAht20SensorData(void); 54 55 #endif