Merge pull request #9958 from Staars/sps30

SPS30: adapt for ESP32
This commit is contained in:
Theo Arends 2020-11-23 15:56:55 +01:00 committed by GitHub
commit bda2d38304
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -26,7 +26,9 @@
#define SPS30_ADDR 0x69
#include <Wire.h>
#ifdef ESP8266
#include <twi.h>
#endif
uint8_t sps30_ready = 0;
uint8_t sps30_running;
@ -74,7 +76,9 @@ uint8_t sps30_calc_CRC(uint8_t *data) {
void CmdClean(void);
#ifdef ESP8266
unsigned char twi_readFrom(unsigned char address, unsigned char* buf, unsigned int len, unsigned char sendStop);
#endif
void sps30_get_data(uint16_t cmd, uint8_t *data, uint8_t dlen) {
unsigned char cmdb[2];
@ -93,7 +97,11 @@ uint8_t twi_buff[64];
dlen/=2;
dlen*=3;
#ifdef ESP8266
twi_readFrom(SPS30_ADDR,twi_buff,dlen,1);
#else
Wire.readTransmission(SPS30_ADDR,twi_buff,dlen,1, NULL);
#endif
uint8_t bind=0;
while (bind<dlen) {