Fix: Use dependent buffer as readout buffer, then copy to readout array

This commit is contained in:
Isoheptane 2024-09-16 03:26:13 +08:00
parent 1db54985c6
commit ef7336734c
No known key found for this signature in database
GPG Key ID: 21ECF6DDEED59BDF
2 changed files with 6 additions and 3 deletions

View File

@ -6,8 +6,8 @@
#if defined BOARD_MAI_PICO
#define I2C_PORT i2c1
#define I2C_SDA 6
#define I2C_SCL 7
#define I2C_SDA 16
#define I2C_SCL 17
#define I2C_FREQ 400*1000
#define RGB_PIN 13

View File

@ -156,10 +156,13 @@ bool touch_sensor_ok(unsigned i)
const uint16_t *touch_raw()
{
static uint16_t readout[36] = {0};
// Do not use readout as buffer directly, update readout with buffer when operation finishes
uint16_t buf[36] = {0};
for (int i = 0; i < 3; i++) {
sensor_ok[i] = mpr121_raw(MPR121_BASE_ADDR + i, readout + i * 12, 12);
sensor_ok[i] = mpr121_raw(MPR121_BASE_ADDR + i, buf + i * 12, 12);
}
memcpy(readout, buf, sizeof(readout));
return readout;
}