adapt for ESP32

This commit is contained in:
Staars 2020-11-23 14:26:41 +01:00
parent 250b08ba61
commit 94077cf047

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) {