/* ============================================================================= * sht30_convert.h - SHT30 원시 데이터 변환/CRC (이식성 있는 순수 로직) * * I2C 전송과 분리하여 호스트/ARM 컴파일 게이트에서 검증 가능하게 한다. * RPi 대응: sht30_monitor.py crc8_sht3x() / read_sht30() 변환식. * ===========================================================================*/ #ifndef SHT30_CONVERT_H #define SHT30_CONVERT_H #include #include /* SHT3x CRC-8: poly 0x31, init 0xFF, no reflection, no final xor. */ uint8_t sht30_crc8(const uint8_t *data, size_t len); /* 6바이트 측정 프레임(T_msb,T_lsb,T_crc,RH_msb,RH_lsb,RH_crc) 검증 + 변환. * *temp_c = -45 + 175 * raw_t / 65535 * *rh = 100 * raw_rh / 65535 * 반환: 0 성공, -1 온도 CRC 오류, -2 습도 CRC 오류. */ int sht30_parse(const uint8_t frame[6], double *temp_c, double *rh); #endif /* SHT30_CONVERT_H */