From 5b9e4233e69ae4ea39b4aab47ffdc3bfd769aa7e Mon Sep 17 00:00:00 2001 From: Edward Emelianov Date: Sun, 14 Feb 2021 23:50:12 +0300 Subject: [PATCH] add HTU21D --- F1-nolib/SI7005/Readme | 1 - F1-nolib/{SI7005 => SI7005_HTU21D}/Makefile | 0 F1-nolib/SI7005_HTU21D/Readme | 1 + F1-nolib/{SI7005 => SI7005_HTU21D}/dewpoint.c | 2 +- F1-nolib/{SI7005 => SI7005_HTU21D}/dewpoint.h | 0 F1-nolib/{SI7005 => SI7005_HTU21D}/hardware.c | 0 F1-nolib/{SI7005 => SI7005_HTU21D}/hardware.h | 0 F1-nolib/SI7005_HTU21D/htu21d.c | 155 ++++++++++++++++++ F1-nolib/SI7005_HTU21D/htu21d.h | 42 +++++ F1-nolib/{SI7005 => SI7005_HTU21D}/i2c.c | 48 ++++++ F1-nolib/{SI7005 => SI7005_HTU21D}/i2c.h | 1 + F1-nolib/{SI7005 => SI7005_HTU21D}/main.c | 20 ++- F1-nolib/{SI7005 => SI7005_HTU21D}/proto.c | 17 +- F1-nolib/{SI7005 => SI7005_HTU21D}/proto.h | 0 F1-nolib/{SI7005 => SI7005_HTU21D}/si7005.bin | Bin 11172 -> 12120 bytes F1-nolib/{SI7005 => SI7005_HTU21D}/si7005.c | 4 +- F1-nolib/{SI7005 => SI7005_HTU21D}/si7005.h | 0 F1-nolib/{SI7005 => SI7005_HTU21D}/usb.c | 0 F1-nolib/{SI7005 => SI7005_HTU21D}/usb.h | 0 F1-nolib/{SI7005 => SI7005_HTU21D}/usb_defs.h | 0 F1-nolib/{SI7005 => SI7005_HTU21D}/usb_lib.c | 0 F1-nolib/{SI7005 => SI7005_HTU21D}/usb_lib.h | 0 22 files changed, 276 insertions(+), 15 deletions(-) delete mode 100644 F1-nolib/SI7005/Readme rename F1-nolib/{SI7005 => SI7005_HTU21D}/Makefile (100%) create mode 100644 F1-nolib/SI7005_HTU21D/Readme rename F1-nolib/{SI7005 => SI7005_HTU21D}/dewpoint.c (97%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/dewpoint.h (100%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/hardware.c (100%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/hardware.h (100%) create mode 100644 F1-nolib/SI7005_HTU21D/htu21d.c create mode 100644 F1-nolib/SI7005_HTU21D/htu21d.h rename F1-nolib/{SI7005 => SI7005_HTU21D}/i2c.c (77%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/i2c.h (95%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/main.c (85%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/proto.c (89%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/proto.h (100%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/si7005.bin (54%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/si7005.c (97%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/si7005.h (100%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/usb.c (100%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/usb.h (100%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/usb_defs.h (100%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/usb_lib.c (100%) rename F1-nolib/{SI7005 => SI7005_HTU21D}/usb_lib.h (100%) diff --git a/F1-nolib/SI7005/Readme b/F1-nolib/SI7005/Readme deleted file mode 100644 index 5221b9b..0000000 --- a/F1-nolib/SI7005/Readme +++ /dev/null @@ -1 +0,0 @@ -Work with I2C humidity/temperature sensor SI7005 diff --git a/F1-nolib/SI7005/Makefile b/F1-nolib/SI7005_HTU21D/Makefile similarity index 100% rename from F1-nolib/SI7005/Makefile rename to F1-nolib/SI7005_HTU21D/Makefile diff --git a/F1-nolib/SI7005_HTU21D/Readme b/F1-nolib/SI7005_HTU21D/Readme new file mode 100644 index 0000000..74e8004 --- /dev/null +++ b/F1-nolib/SI7005_HTU21D/Readme @@ -0,0 +1 @@ +Work with I2C humidity/temperature sensors SI7005 & HTU21D diff --git a/F1-nolib/SI7005/dewpoint.c b/F1-nolib/SI7005_HTU21D/dewpoint.c similarity index 97% rename from F1-nolib/SI7005/dewpoint.c rename to F1-nolib/SI7005_HTU21D/dewpoint.c index 1a27dff..4a4cd85 100644 --- a/F1-nolib/SI7005/dewpoint.c +++ b/F1-nolib/SI7005_HTU21D/dewpoint.c @@ -54,7 +54,7 @@ float ln(uint16_t RH){ } if(idx < 0) idx = 0; else if(idx > NKNOTS-1) idx = NKNOTS - 1; - USB_send("idx="); USB_send(u2str(idx)); USB_send("\n"); + //USB_send("idx="); USB_send(u2str(idx)); USB_send("\n"); float l = Y[idx] + K[idx]*(RH - X[idx]); #undef NKNOTS return l; diff --git a/F1-nolib/SI7005/dewpoint.h b/F1-nolib/SI7005_HTU21D/dewpoint.h similarity index 100% rename from F1-nolib/SI7005/dewpoint.h rename to F1-nolib/SI7005_HTU21D/dewpoint.h diff --git a/F1-nolib/SI7005/hardware.c b/F1-nolib/SI7005_HTU21D/hardware.c similarity index 100% rename from F1-nolib/SI7005/hardware.c rename to F1-nolib/SI7005_HTU21D/hardware.c diff --git a/F1-nolib/SI7005/hardware.h b/F1-nolib/SI7005_HTU21D/hardware.h similarity index 100% rename from F1-nolib/SI7005/hardware.h rename to F1-nolib/SI7005_HTU21D/hardware.h diff --git a/F1-nolib/SI7005_HTU21D/htu21d.c b/F1-nolib/SI7005_HTU21D/htu21d.c new file mode 100644 index 0000000..f7e5ece --- /dev/null +++ b/F1-nolib/SI7005_HTU21D/htu21d.c @@ -0,0 +1,155 @@ +/* + * This file is part of the si7005 project. + * Copyright 2021 Edward V. Emelianov . + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "htu21d.h" +#include "i2c.h" + +#define DEVID (0x40) + +#ifdef EBUG +#include "usb.h" +#include "proto.h" +#define DBG(x) do{USB_send(x);}while(0) +#else +#define DBG(x) +#endif + +// read with no hold master! +#define HTU21_READ_TEMP (0xF3) +#define HTU21_READ_HUMID (0xF5) +#define HTU21_READ_REG (0xE7) +#define HTU21_WRITE_REG (0xE6) +#define HTU21_SOFT_RESET (0xFE) +// status mask & val +#define HTU21_STATUS_MASK (0x03) +#define HTU21_HUMID_FLAG (0x02) +// user reg fields +#define HTU21_REG_VBAT (0x40) +#define HTU21_REG_D1 (0x80) +#define HTU21_REG_D0 (0x01) +#define HTU21_REG_HTR (0x04) +#define HTU21_REG_ODIS (0x02) + +typedef enum{ + RELAX = 0, + WAITFORT, // T + WAITFORH // humidity +} HTU21D_state; + +static HTU21D_state state = RELAX; +static HTU21D_status htustatus = HTU21D_RELAX; +static uint16_t TH; // data for T or H + +HTU21D_status HTU21D_get_status(){ + return htustatus; +} + +//output in Cx10 +int32_t HTU21D_getT(){ + DBG("HTU getT\n"); + htustatus = HTU21D_RELAX; + if(TH & HTU21_HUMID_FLAG) return -5000; // humidity measured + uint32_t a = TH & 0xFFFC; + a *= 17572; + a >>= 16; + int32_t val = (a - 4685)/10; + return val; +} + +//output in %x10 +uint32_t HTU21D_getH(){ + DBG("HTU getH\n"); + htustatus = HTU21D_RELAX; + if(!(TH & HTU21_HUMID_FLAG)) return 5000; // temperature measured + uint32_t a = TH & 0xFFFC; + a *= 1250; + a >>= 16; + a -= 60; + return a; +} + +void HTU21D_setup(){ + DBG("HTU setup\n"); + htustatus = HTU21D_RELAX; + state = RELAX; + i2c_setup(); + i2c_set_addr7(DEVID); +} + + +#define SHIFTED_DIVISOR 0x988000 //This is the 0x0131 polynomial shifted to farthest left of three bytes +// check CRC, return 0 if all OK +static uint32_t htu_check_crc(uint8_t *crc){ + DBG("HTU check CRC\n"); + uint32_t remainder = (crc[0] << 16) | (crc[1] << 8) | crc[2]; + uint32_t divsor = (uint32_t)SHIFTED_DIVISOR; + int i; + for(i = 0; i < 16; i++) { + if (remainder & (uint32_t)1 << (23 - i)) + remainder ^= divsor; + divsor >>= 1; + } + return remainder; +} + +static int htusendcmd(uint8_t cmd){ + DBG("htu cmd\n"); + if(state != RELAX) return 1; + htustatus = HTU21D_BUSY; + if(I2C_OK != i2c_7bit_send_onebyte(cmd, 1)){ + htustatus = HTU21D_ERR; + DBG("htu read err\n"); + return 1; + } + return 0; +} + +int HTU21D_cmdT(){ + DBG("htu read T\n"); + if(htusendcmd(HTU21_READ_TEMP)) return 1; + state = WAITFORT; + return 0; +} + +int HTU21D_cmdH(){ + DBG("htu read H\n"); + if(htusendcmd(HTU21_READ_HUMID)) return 1; + state = WAITFORH; + return 0; +} + +void HTU21D_process(){ + uint8_t d[3]; + if(state == RELAX) return; + if(state == WAITFORH || state == WAITFORT){ // poll RDY + if(I2C_OK != i2c_7bit_receive(d, 3)) return; // NACKed + DBG("HTU got H or T:"); + DBG(u2str(d[0])); DBG(", "); + DBG(u2str(d[1])); DBG(", "); + DBG(u2str(d[2])); DBG("\n"); + if(htu_check_crc(d)){ + htustatus = HTU21D_ERR; + DBG("CRC failed\n"); + state = RELAX; + return; + } + TH = (d[0] << 8) | d[1]; + htustatus = (state == WAITFORH) ? HTU21D_HRDY : HTU21D_TRDY; + state = RELAX; + } +} diff --git a/F1-nolib/SI7005_HTU21D/htu21d.h b/F1-nolib/SI7005_HTU21D/htu21d.h new file mode 100644 index 0000000..ffdfd3b --- /dev/null +++ b/F1-nolib/SI7005_HTU21D/htu21d.h @@ -0,0 +1,42 @@ +/* + * This file is part of the HTU21D project. + * Copyright 2021 Edward V. Emelianov . + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once +#ifndef HTU21D_H__ + +#include + +typedef enum{ + HTU21D_BUSY, // measurement in progress + HTU21D_ERR, // error in I2C + HTU21D_RELAX, // relaxed state + HTU21D_TRDY, // data ready - can get it + HTU21D_HRDY +} HTU21D_status; + +HTU21D_status HTU21D_get_status(); + +void HTU21D_setup(); +int HTU21D_read_ID(uint8_t *devid); +int HTU21D_cmdT(); +int HTU21D_cmdH(); +void HTU21D_process(); +int32_t HTU21D_getT(); +uint32_t HTU21D_getH(); + +#define HTU21D_H__ +#endif // HTU21D_H__ diff --git a/F1-nolib/SI7005/i2c.c b/F1-nolib/SI7005_HTU21D/i2c.c similarity index 77% rename from F1-nolib/SI7005/i2c.c rename to F1-nolib/SI7005_HTU21D/i2c.c index 8e1c8f9..b9f1f7f 100644 --- a/F1-nolib/SI7005/i2c.c +++ b/F1-nolib/SI7005_HTU21D/i2c.c @@ -170,19 +170,67 @@ i2c_status i2c_7bit_receive_twobytes(uint8_t *data){ //I2C_LINEWAIT(); I2C1->CR1 |= I2C_CR1_START | I2C_CR1_POS | I2C_CR1_ACK; // generate start sequence, set pos & ack I2C_WAIT(I2C1->SR1 & I2C_SR1_SB); // wait for SB + DBG("2 Rx sb\n"); (void) I2C1->SR1; // clear SB I2C1->DR = addr7r; // set address I2C_WAIT(I2C1->SR1 & I2C_SR1_ADDR); // wait for ADDR flag + DBG("2 ADDR\n"); if(I2C1->SR1 & I2C_SR1_AF){ // NACK ret = I2C_NACK; goto eotr; } + DBG("2 ACK\n"); (void) I2C1->SR2; // clear ADDR I2C1->CR1 &= ~I2C_CR1_ACK; // clear ACK I2C_WAIT(I2C1->SR1 & I2C_SR1_BTF); // wait for BTF + DBG("2 BTF\n"); I2C1->CR1 |= I2C_CR1_STOP; // program STOP *data++ = I2C1->DR; *data = I2C1->DR; // read data & clear RxNE ret = I2C_OK; eotr: return ret; } + +// receive any amount of bytes +i2c_status i2c_7bit_receive(uint8_t *data, uint16_t nbytes){ + if(nbytes == 0) return I2C_HWPROBLEM; + I2C1->SR1 = 0; // clear previous NACK flag & other error flags + if(nbytes == 1) return i2c_7bit_receive_onebyte(data, 1); + else if(nbytes == 2) return i2c_7bit_receive_twobytes(data); + i2c_status ret = I2C_LINEBUSY; + //I2C_LINEWAIT(); + I2C1->CR1 |= I2C_CR1_START | I2C_CR1_ACK; // generate start sequence, set pos & ack + I2C_WAIT(I2C1->SR1 & I2C_SR1_SB); // wait for SB + DBG("got SB\n"); + (void) I2C1->SR1; // clear SB + I2C1->DR = addr7r; // set address + I2C_WAIT(I2C1->SR1 & I2C_SR1_ADDR); // wait for ADDR flag + DBG("send addr\n"); + if(I2C1->SR1 & I2C_SR1_AF){ // NACK + DBG("NACKed\n"); + ret = I2C_NACK; + goto eotr; + } + DBG("ACKed\n"); + (void) I2C1->SR2; // clear ADDR + for(uint16_t x = nbytes - 3; x > 0; --x){ + I2C_WAIT(I2C1->SR1 & I2C_SR1_RXNE); // wait next byte + *data++ = I2C1->DR; // get data + } + DBG("three left\n"); + // three bytes remain to be read + I2C_WAIT(I2C1->SR1 & I2C_SR1_RXNE); // wait dataN-2 + DBG("dataN-2\n"); + I2C_WAIT(I2C1->SR1 & I2C_SR1_BTF); // wait for BTF + DBG("BTF\n"); + I2C1->CR1 &= ~I2C_CR1_ACK; // clear ACK + *data++ = I2C1->DR; // read dataN-2 + I2C1->CR1 |= I2C_CR1_STOP; // program STOP + *data++ = I2C1->DR; // read dataN-1 + I2C_WAIT(I2C1->SR1 & I2C_SR1_RXNE); // wait next byte + *data = I2C1->DR; // read dataN + DBG("got it\n"); + ret = I2C_OK; +eotr: + return ret; +} diff --git a/F1-nolib/SI7005/i2c.h b/F1-nolib/SI7005_HTU21D/i2c.h similarity index 95% rename from F1-nolib/SI7005/i2c.h rename to F1-nolib/SI7005_HTU21D/i2c.h index 1c68806..baaf248 100644 --- a/F1-nolib/SI7005/i2c.h +++ b/F1-nolib/SI7005_HTU21D/i2c.h @@ -35,6 +35,7 @@ i2c_status i2c_7bit_send_onebyte(uint8_t data, uint8_t stop); i2c_status i2c_7bit_send(const uint8_t *data, int datalen); i2c_status i2c_7bit_receive_onebyte(uint8_t *data, uint8_t stop); i2c_status i2c_7bit_receive_twobytes(uint8_t *data); +i2c_status i2c_7bit_receive(uint8_t *data, uint16_t nbytes); #define I2C_H__ #endif // I2C_H__ diff --git a/F1-nolib/SI7005/main.c b/F1-nolib/SI7005_HTU21D/main.c similarity index 85% rename from F1-nolib/SI7005/main.c rename to F1-nolib/SI7005_HTU21D/main.c index d9d1c7d..6c2c9cf 100644 --- a/F1-nolib/SI7005/main.c +++ b/F1-nolib/SI7005_HTU21D/main.c @@ -18,6 +18,7 @@ #include "dewpoint.h" #include "hardware.h" +#include "htu21d.h" #include "proto.h" #include "si7005.h" #include "usb.h" @@ -68,6 +69,7 @@ int main(void){ StartHSE(); hw_setup(); si7005_setup(); + HTU21D_setup(); SysTick_Config(72000); RCC->CSR |= RCC_CSR_RMVF; // remove reset flags @@ -85,17 +87,20 @@ int main(void){ } usb_proc(); si7005_process(); + HTU21D_process(); + HTU21D_status h = HTU21D_get_status(); si7005_status s = si7005_get_status(); - if(s == SI7005_HRDY){ // humidity can be shown - //USB_send(u2str(Tms)); USB_send("\n"); - mH = si7005_getH(); + + if(s == SI7005_HRDY || h == HTU21D_HRDY){ // humidity can be shown + if(s == SI7005_HRDY) mH = si7005_getH(); + else mH = HTU21D_getH(); USB_send("Hum="); USB_send(u2str(mH)); USB_send("*10%\n"); showd(mT, mH); - }else if(s == SI7005_TRDY){ // T can be shown - //USB_send(u2str(Tms)); USB_send("\n"); - mT = si7005_getT(); + }else if(s == SI7005_TRDY || h == HTU21D_TRDY){ // T can be shown + if(s == SI7005_TRDY) mT = si7005_getT(); + else mT = HTU21D_getT(); int32_t T = mT; USB_send("T="); if(T < 0){ @@ -105,9 +110,10 @@ int main(void){ USB_send(u2str(T)); USB_send("*10degrC\n"); showd(mT, mH); - }else if(s == SI7005_ERR){ + }else if(s == SI7005_ERR || h == HTU21D_ERR){ USB_send("Error in H/T measurement\n"); si7005_setup(); + HTU21D_setup(); } char *txt, *ans; diff --git a/F1-nolib/SI7005/proto.c b/F1-nolib/SI7005_HTU21D/proto.c similarity index 89% rename from F1-nolib/SI7005/proto.c rename to F1-nolib/SI7005_HTU21D/proto.c index b49ff45..6a93928 100644 --- a/F1-nolib/SI7005/proto.c +++ b/F1-nolib/SI7005_HTU21D/proto.c @@ -17,6 +17,7 @@ */ #include "dewpoint.h" +#include "htu21d.h" #include "proto.h" #include "si7005.h" #include "usb.h" @@ -156,10 +157,10 @@ char *getnum(const char *txt, uint32_t *N){ const char* helpmsg = "'0' - reset I2C\n" "'I' - read SI7005 device ID\n" - "'H' - start Humidity measurement\n" + "'hH' - start Humidity measurement (h-si,H-htu)\n" "'N' - read number (0..1000) and show its ln\n" "'R' - software reset\n" - "'T' - start Temperature measurement\n" + "'tT' - start Temperature measurement (t-si,T-htu)\n" "'W' - test watchdog\n" ; @@ -169,6 +170,7 @@ const char *parse_cmd(const char *buf){ switch(*buf){ case '0': si7005_setup(); + HTU21D_setup(); return "Reset I2C\n"; break; /*case 'p': @@ -185,16 +187,21 @@ const char *parse_cmd(const char *buf){ USB_send("\n"); }else USB_send("Can't read ID\n"); break; + case 'h': + if(si7005_cmdH()) USB_send("SI7005 not found\n"); + break; case 'H': - if(si7005_cmdH()) USB_send("Humid. read error\n"); + if(HTU21D_cmdH()) USB_send("HTU21D not found\n"); break; case 'R': USB_send("Soft reset\n"); NVIC_SystemReset(); break; + case 't': + if(si7005_cmdT()) USB_send("SI7005 not found\n"); + break; case 'T': - if(si7005_cmdT()) USB_send("Temper. read error\n"); - //USB_send(u2str(Tms)); USB_send("\n"); + if(HTU21D_cmdT()) USB_send("HTU21D not found\n"); break; case 'W': USB_send("Wait for reboot\n"); diff --git a/F1-nolib/SI7005/proto.h b/F1-nolib/SI7005_HTU21D/proto.h similarity index 100% rename from F1-nolib/SI7005/proto.h rename to F1-nolib/SI7005_HTU21D/proto.h diff --git a/F1-nolib/SI7005/si7005.bin b/F1-nolib/SI7005_HTU21D/si7005.bin similarity index 54% rename from F1-nolib/SI7005/si7005.bin rename to F1-nolib/SI7005_HTU21D/si7005.bin index 141543d00017c9861fc10e37c9e25920edb126c1..ff782d0f3381e798b219e96ab03dd48e03c62ac2 100755 GIT binary patch delta 3425 zcmb_eeQ*=U72mx(ec6^R+fXEb;Im|xvjw#hU{F4hWpnv5(dmSJeQR(_ zAesKr+|0YT`}X&KZ*Sl3zI)>b(G3Dxf!O2uNZ$|AbC;mI9)cl4%tQ~S-0O2U$N%UH z_XORU`+t+(!}-mV5Wf9j{{Di(vLa+P+06B6qwD4_mNQ-L=2my{P@}2SoqnOio%XlI za<=QRTN+v~FYq!<|Dn_&+tYbOIy|aqeEAb4NIS>TAsO4W6A*QlPblh@(%t1o{}V) zl0Ho^eAlr`HQuFSo&{r(l3Ak#%_Xt4L1h3+$kt7}8IBBIMHoxtlZ1rjO91z0An8j` zlJ}MelO4NHQHK#B)KM{f0VQb7~J}ogrO4F8q?U12R2fI*x5NzcYkc z4&EqCu*BzX{KPc=hHN@ceGOhftiM06ZdbRh89#*WB~iK%cOmITg*`FHc2L%=I4Cn- zjyfo7S=TkKE33v-!7B84mV`6tF?FFiTxVa50$SeW%k)u>Hh22@j^IbS)L{!>d*iqB8tbXi z_TWVwJzVC^_O-a>q183*!Am;V*lU3`p0;3abLuXWFB?4fyN&1Dg9mjf!?gl9)=xVg zxWkdJZh_&KM_PjGG{P`FpKeFe&Hw}{o>ve)hL^bNmQ-dEs{1TUd`S9G9MYAsS(7a93<*}+Ls#c`Ij=Ls018S3%Yp2fFIx3Qxd%K4 zYAwE&?s5rZi+7#RJ)ZGGifg?$$M>4JQNPsC>dEo#qnC}mBEG5rA>JbD3}ph9l)ej_ zNkK(wyfvv~mrJO8gJ;9?#`?9jPk3LE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%4`&nn(5Yj-Pv+#(4`o7G<}VaTD3m%j6=I4FWjL zW2T@!X!_03YishL;=wlfWZzl)Ud=C*^k@*yhXFU8^pZ7jS{*enRC)h^Ga$J6!p@9t9 zkgF0S7uu7=<%%%EkJp3wpMwYfL$Io0aMEyhtnzNzS`$k@tlTPFUC6fZw_Oh_bvAp` zLCrG?4a8X~H$61S4>QEDSo!nO-!>Wg7SO&d!}MEgL2woC%kgS@l68p`>Os- z9%O9HX^ELb;02UVA$XiK9?p&L0YXGHB5q)*58!yz9e=E5FR5bwvk2zPQZT*~6?iO_ zU)Js-pjhi3$M2y!KYlONwN`zR%ca=S!}myVAdVv!8*j!#_tat3Jl}n|0KV4U6X}lrql5DF#&0OU-B_<^8~w`m bO-`j}(?<>g>0`)QgiALNFTgJd&dl&v*uM)8 diff --git a/F1-nolib/SI7005/si7005.c b/F1-nolib/SI7005_HTU21D/si7005.c similarity index 97% rename from F1-nolib/SI7005/si7005.c rename to F1-nolib/SI7005_HTU21D/si7005.c index 8c5ad8b..47b5b48 100644 --- a/F1-nolib/SI7005/si7005.c +++ b/F1-nolib/SI7005_HTU21D/si7005.c @@ -83,6 +83,7 @@ int si7005_cmdT(){ sistatus = SI7005_BUSY; i2c_status st = i2c_7bit_send(cmd, 2); if(st != I2C_OK){ + sistatus = SI7005_ERR; return 1; } DBG("Wait for T\n"); @@ -101,6 +102,7 @@ int si7005_cmdH(){ sistatus = SI7005_BUSY; i2c_status st = i2c_7bit_send(cmd, 2); if(st != I2C_OK){ + sistatus = SI7005_ERR; return 1; } state = WAITFORH; @@ -117,7 +119,7 @@ int32_t si7005_getT(){ // T*10 return d; } uint32_t si7005_getH(){ // hum * 10 - if(sistatus != SI7005_HRDY) return 0; + if(sistatus != SI7005_HRDY) return 5000; TH >>= 4; uint32_t d = (TH*10)/16 - 240; sistatus = SI7005_RELAX; diff --git a/F1-nolib/SI7005/si7005.h b/F1-nolib/SI7005_HTU21D/si7005.h similarity index 100% rename from F1-nolib/SI7005/si7005.h rename to F1-nolib/SI7005_HTU21D/si7005.h diff --git a/F1-nolib/SI7005/usb.c b/F1-nolib/SI7005_HTU21D/usb.c similarity index 100% rename from F1-nolib/SI7005/usb.c rename to F1-nolib/SI7005_HTU21D/usb.c diff --git a/F1-nolib/SI7005/usb.h b/F1-nolib/SI7005_HTU21D/usb.h similarity index 100% rename from F1-nolib/SI7005/usb.h rename to F1-nolib/SI7005_HTU21D/usb.h diff --git a/F1-nolib/SI7005/usb_defs.h b/F1-nolib/SI7005_HTU21D/usb_defs.h similarity index 100% rename from F1-nolib/SI7005/usb_defs.h rename to F1-nolib/SI7005_HTU21D/usb_defs.h diff --git a/F1-nolib/SI7005/usb_lib.c b/F1-nolib/SI7005_HTU21D/usb_lib.c similarity index 100% rename from F1-nolib/SI7005/usb_lib.c rename to F1-nolib/SI7005_HTU21D/usb_lib.c diff --git a/F1-nolib/SI7005/usb_lib.h b/F1-nolib/SI7005_HTU21D/usb_lib.h similarity index 100% rename from F1-nolib/SI7005/usb_lib.h rename to F1-nolib/SI7005_HTU21D/usb_lib.h