BME680 optimizations
This commit is contained in:
parent
2940561c26
commit
b328dd61a0
@ -101,34 +101,28 @@ void bme_loop(void *pvParameters) {
|
|||||||
|
|
||||||
int8_t i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data,
|
int8_t i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data,
|
||||||
uint16_t len) {
|
uint16_t len) {
|
||||||
int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */
|
int8_t rslt = 0;
|
||||||
uint16_t i;
|
|
||||||
|
|
||||||
Wire.beginTransmission(dev_id);
|
Wire.beginTransmission(dev_id);
|
||||||
Wire.write(reg_addr);
|
Wire.write(reg_addr);
|
||||||
rslt = Wire.endTransmission();
|
rslt = Wire.endTransmission(false);
|
||||||
|
|
||||||
Wire.requestFrom((int)dev_id, (int)len);
|
Wire.requestFrom((int)dev_id, (int)len);
|
||||||
for (i = 0; (i < len) && Wire.available(); i++) {
|
for (uint16_t i = 0; (i < len) && Wire.available(); i++) {
|
||||||
reg_data[i] = Wire.read();
|
reg_data[i] = Wire.read();
|
||||||
}
|
}
|
||||||
|
// return 0 for success, non-zero for failure
|
||||||
return rslt;
|
return rslt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data,
|
int8_t i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data,
|
||||||
uint16_t len) {
|
uint16_t len) {
|
||||||
int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */
|
|
||||||
uint16_t i;
|
|
||||||
|
|
||||||
Wire.beginTransmission(dev_id);
|
Wire.beginTransmission(dev_id);
|
||||||
Wire.write(reg_addr);
|
Wire.write(reg_addr);
|
||||||
for (i = 0; i < len; i++) {
|
for (uint16_t i = 0; i < len; i++) {
|
||||||
Wire.write(reg_data[i]);
|
Wire.write(reg_data[i]);
|
||||||
}
|
}
|
||||||
rslt = Wire.endTransmission();
|
// return 0 for success, non-zero for failure
|
||||||
|
return Wire.endTransmission(true);
|
||||||
return rslt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -35,9 +35,11 @@ IDLE 0 0 ESP32 arduino scheduler -> runs wifi sniffer
|
|||||||
looptask 1 1 arduino core -> runs the LMIC LoRa stack
|
looptask 1 1 arduino core -> runs the LMIC LoRa stack
|
||||||
irqhandler 1 1 executes tasks triggered by irq
|
irqhandler 1 1 executes tasks triggered by irq
|
||||||
gpsloop 1 2 reads data from GPS via serial or i2c
|
gpsloop 1 2 reads data from GPS via serial or i2c
|
||||||
bmeloop 1 2 reads data from BME sensor via i2c
|
bmeloop 1 0 reads data from BME sensor via i2c
|
||||||
IDLE 1 0 ESP32 arduino scheduler
|
IDLE 1 0 ESP32 arduino scheduler
|
||||||
|
|
||||||
|
Low priority numbers denote low priority tasks.
|
||||||
|
|
||||||
ESP32 hardware timers
|
ESP32 hardware timers
|
||||||
==========================
|
==========================
|
||||||
0 Trigger display refresh
|
0 Trigger display refresh
|
||||||
@ -239,7 +241,7 @@ void setup() {
|
|||||||
"bmeloop", // name of task
|
"bmeloop", // name of task
|
||||||
4096, // stack size of task
|
4096, // stack size of task
|
||||||
(void *)1, // parameter of the task
|
(void *)1, // parameter of the task
|
||||||
2, // priority of the task
|
0, // priority of the task
|
||||||
&BmeTask, // task handle
|
&BmeTask, // task handle
|
||||||
1); // CPU core
|
1); // CPU core
|
||||||
}
|
}
|
||||||
@ -331,7 +333,7 @@ void setup() {
|
|||||||
ESP_LOGI(TAG, "Starting IRQ Handler...");
|
ESP_LOGI(TAG, "Starting IRQ Handler...");
|
||||||
xTaskCreatePinnedToCore(irqHandler, // task function
|
xTaskCreatePinnedToCore(irqHandler, // task function
|
||||||
"irqhandler", // name of task
|
"irqhandler", // name of task
|
||||||
2048, // stack size of task
|
4096, // stack size of task
|
||||||
(void *)1, // parameter of the task
|
(void *)1, // parameter of the task
|
||||||
1, // priority of the task
|
1, // priority of the task
|
||||||
&irqHandlerTask, // task handle
|
&irqHandlerTask, // task handle
|
||||||
|
Loading…
Reference in New Issue
Block a user