/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2023-04-17 19813 the first version */ #ifndef APPLICATIONS_PROC_IIC_SHT30_H_ #define APPLICATIONS_PROC_IIC_SHT30_H_ /*********************↓ define ↓************************/ #define IIC_SCL(sta) (sta == 1 ? HAL_GPIO_WritePin(I2C_SCL_GPIO_Port, I2C_SCL_Pin, GPIO_PIN_SET) : HAL_GPIO_WritePin(I2C_SCL_GPIO_Port, I2C_SCL_Pin, GPIO_PIN_RESET)) #define IIC_SDA(sta) (sta == 1 ? HAL_GPIO_WritePin(I2C_SDA_GPIO_Port, I2C_SDA_Pin, GPIO_PIN_SET) : HAL_GPIO_WritePin(I2C_SDA_GPIO_Port, I2C_SDA_Pin, GPIO_PIN_RESET)) #define READ_SDA HAL_GPIO_ReadPin(I2C_SDA_GPIO_Port, I2C_SDA_Pin) #define TEM_HUM_ADDR 0x8A #define LIGHT_ADDR 0x46 /*********************↑ define ↑************************/ /** * * * * * */ /*********************↓ include ↓************************/ #include /*********************↑ include ↑************************/ /** * * * * * */ /*********************↓ extern ↓************************/ /*********************↑ extern ↑************************/ /** * * * * * */ /********************↓ declaration ↓***********************/ typedef enum { /* TEM AND HUM */ // CMD_READ_SERIALNBR = 0x3780, // read serial number CMD_READ_STATUS = 0xF32D, // read status register // CMD_CLEAR_STATUS = 0x3041, // clear status register // CMD_HEATER_ENABLE = 0x306D, // enabled heater // CMD_HEATER_DISABLE = 0x3066, // disable heater // CMD_SOFT_RESET = 0x30A2, // soft reset // CMD_MEAS_CLOCKSTR_H = 0x2C06, // meas. clock stretching, high rep. // CMD_MEAS_CLOCKSTR_M = 0x2C0D, // meas. clock stretching, medium rep. // CMD_MEAS_CLOCKSTR_L = 0x2C10, // meas. clock stretching, low rep. CMD_MEAS_POLLING_H = 0x2400, // meas. no clock stretching, high rep. // CMD_MEAS_POLLING_M = 0x240B, // meas. no clock stretching, medium rep. CMD_MEAS_POLLING_L = 0x2416, // meas. no clock stretching, low rep. // CMD_MEAS_PERI_05_H = 0x2032, // meas. periodic 0.5 mps, high rep. // CMD_MEAS_PERI_05_M = 0x2024, // meas. periodic 0.5 mps, medium rep. // CMD_MEAS_PERI_05_L = 0x202F, // meas. periodic 0.5 mps, low rep. // CMD_MEAS_PERI_1_H = 0x2130, // meas. periodic 1 mps, high rep. // CMD_MEAS_PERI_1_M = 0x2126, // meas. periodic 1 mps, medium rep. // CMD_MEAS_PERI_1_L = 0x212D, // meas. periodic 1 mps, low rep. // CMD_MEAS_PERI_2_H = 0x2236, // meas. periodic 2 mps, high rep. CMD_MEAS_PERI_2_M = 0x2220, // meas. periodic 2 mps, medium rep. // CMD_MEAS_PERI_2_L = 0x222B, // meas. periodic 2 mps, low rep. // CMD_MEAS_PERI_4_H = 0x2334, // meas. periodic 4 mps, high rep.S CMD_MEAS_PERI_4_M = 0x2322, // meas. periodic 4 mps, medium rep. // CMD_MEAS_PERI_4_L = 0x2329, // meas. periodic 4 mps, low rep. // CMD_MEAS_PERI_10_H = 0x2737, // meas. periodic 10 mps, high rep. // CMD_MEAS_PERI_10_M = 0x2721, // meas. periodic 10 mps, medium rep. // CMD_MEAS_PERI_10_L = 0x272A, // meas. periodic 10 mps, low rep. CMD_STOP_MEAS_PERI = 0x3093, CMD_FETCH_DATA = 0xE000, // readout measurements for periodic mode // CMD_R_AL_LIM_LS = 0xE102, // read alert limits, low set // CMD_R_AL_LIM_LC = 0xE109, // read alert limits, low clear // CMD_R_AL_LIM_HS = 0xE11F, // read alert limits, high set // CMD_R_AL_LIM_HC = 0xE114, // read alert limits, high clear // CMD_W_AL_LIM_LS = 0x6100, // write alert limits, low set // CMD_W_AL_LIM_LC = 0x610B, // write alert limits, low clear // CMD_W_AL_LIM_HS = 0x611D, // write alert limits, high set // CMD_W_AL_LIM_HC = 0x6116, // write alert limits, high clear // CMD_NO_SLEEP = 0x303E, } sensor_status; unsigned char tem_hum_per_init(void); unsigned char find_iic_addr(void); unsigned char tem_hum_single_init(void); unsigned char tem_hum_stop(void); unsigned char tem_hum_read(int *temp, int *hump); unsigned char crc8_checksum(unsigned char *ptr, unsigned char len); void SHT30_Init(void); uint8_t SHT30_Read(int *temp, int *hump); uint8_t SHT30_AddrCheck(void); /********************↑ declaration ↑***********************/ /** * * * * * */ /*********************↓ global variables ↓************************/ /*********************↑ global variables ↑************************/ /** * * * * * */ #endif /* APPLICATIONS_PROC_IIC_SHT30_H_ */