49 lines
1019 B
C
49 lines
1019 B
C
/*
|
|
* sht30_driver.h
|
|
*
|
|
* Created on: 30. apr. 2025
|
|
* Author: Chris
|
|
*/
|
|
|
|
#ifndef MAIN_SHT30_DRIVER_SHT30_DRIVER_H_
|
|
#define MAIN_SHT30_DRIVER_SHT30_DRIVER_H_
|
|
#include "stdio.h"
|
|
#include <stdint.h>
|
|
|
|
enum{
|
|
SHT30_I2C_GET = 0,
|
|
SHT30_I2C_SET = 1,
|
|
|
|
};
|
|
|
|
typedef int (*setGet_I2C_Event_fpt)(void *inst, uint8_t *data, uint32_t len, uint8_t set_get);
|
|
|
|
typedef struct SHT30_Message{
|
|
uint16_t RawTemp;
|
|
uint8_t CRC_Temp;
|
|
uint16_t RawHumidity;
|
|
uint8_t CRC_Humidity;
|
|
|
|
|
|
}__attribute__((packed)) SHT30_Message_Type;
|
|
|
|
typedef struct SHT30_Struct
|
|
{
|
|
// I2C interface
|
|
void *i2c_transfer_inst;
|
|
setGet_I2C_Event_fpt i2c_transfer_evt;
|
|
|
|
// Data
|
|
SHT30_Message_Type Message;
|
|
int32_t Temperature_mC;
|
|
uint32_t Humidity;
|
|
|
|
} __attribute__((packed)) SHT30_Struct_Type;
|
|
|
|
|
|
int sht30_init(SHT30_Struct_Type *inst, void *i2c_transfer_inst, setGet_I2C_Event_fpt i2c_transfer_evt);
|
|
void sht30_ReadData(SHT30_Struct_Type *p);
|
|
uint8_t crc8_i2c_u16(uint16_t input);
|
|
|
|
#endif /* MAIN_SHT30_DRIVER_SHT30_DRIVER_H_ */
|