44 #include "em_device.h" 57 #define SHT30_ADDRESS 0x44 60 #define SOFT_RESET_CMD 0x30A2 61 #define HIGH_REP_MEAS_CMD 0x2400 62 #define SEND_MEASUREMENT_COMMAND 0x2C 63 #define HIGH_REPEATABILITY_COMMAND 0x06 94 if (
initI2C() != 0)
return (-6);
100 I2C_TransferSeq_TypeDef i2cTransfer;
101 I2C_TransferReturn_TypeDef result;
105 i2cTransfer.flags = I2C_FLAG_WRITE;
106 i2cTransfer.buf[0].data = cmd_buf;
107 i2cTransfer.buf[0].len = 2;
108 result = I2C_TransferInit(
BUS_I2C, &i2cTransfer);
111 while (result == i2cTransferInProgress) result = I2C_Transfer(
BUS_I2C);
113 #if DEBUG_DBPRINT == 1 114 dbinfo(
"Soft reset SHT30");
137 if (
initI2C() != 0)
return (-6);
143 I2C_TransferSeq_TypeDef i2cTransfer;
144 I2C_TransferReturn_TypeDef result;
147 uint8_t data_buf[6] = {0, 0, 0, 0, 0, 0};
155 i2cTransfer.flags = I2C_FLAG_WRITE;
156 i2cTransfer.buf[0].data = cmd_buf;
157 i2cTransfer.buf[0].len = 2;
158 result = I2C_TransferInit(
BUS_I2C, &i2cTransfer);
161 while (result == i2cTransferInProgress) result = I2C_Transfer(
BUS_I2C);
166 i2cTransfer.flags = I2C_FLAG_READ;
167 i2cTransfer.buf[0].data = data_buf;
168 i2cTransfer.buf[0].len = 6;
169 result = I2C_TransferInit(
BUS_I2C, &i2cTransfer);
172 while (result == i2cTransferInProgress) result = I2C_Transfer(
BUS_I2C);
174 return ((
int32_t)((((((data_buf[0] * 256.0) + data_buf[1]) * 175) / 65535.0) - 45) * 1000));
signed char int8_t
Typedef defining 8 bit char type. The developer should modify this to suit the platform being deploye...
int32_t SHT30_readTemp(void)
Do I2C transfers to get the temperature from the SHT30.
void dbinfo(char *message)
Print an info string (char array) to USARTx and go to the next line.
int int32_t
Typedef defining 32 bit int type. The developer should modify this to suit the platform being deploye...
The pin definitions for the custom board.
Enable or disable printing to UART with dbprint.
int8_t softResetSHT30(void)
Soft reset the SHT30.
void delay(uint32_t msDelay)
Wait for a certain amount of milliseconds in EM2/3.
int8_t initI2C(void)
I2C initialization (if not already initialized).
unsigned char uint8_t
Typedef defining 8 bit unsigned char type. The developer should modify this to suit the platform bein...
#define HIGH_REP_MEAS_CMD