Skip to content

Conversation

@Matteocaroleo
Copy link

@Matteocaroleo Matteocaroleo commented May 15, 2025

Hi, we at Politek (the audio engineering team at Politecnico di Torino) have found the problem in the libDaisy library and propose a solution.

You can check us out at https://politek.polito.it/

Problem

In the files libDaisy/src/per/i2c.h and libDaisy/src/per/i2c.cpp to read from an I2C device the function ReceiveBlocking(...) is used.
Looking at the i2c.cpp file, at line 346, in its function definition the hal function HAL_I2C_Master_Receive (...) is used. The problem is that this hal function doesn't comply with the I2C reading protocol defined in the MPR121 datasheet, resulting in a wrong read.

Solution

We found that the hal function HAL_I2C_Mem_Read (...) implements the correct procedure to read from the MPR121, so we added a new function inside the i2c.cpp and inside the src/dev/mpr121.h files to correctly use it.
Using the function FilteredData() now returns the correct values of capacitance reading from the mpr121 device.

Closes #651

@cvpines
Copy link
Contributor

cvpines commented May 20, 2025

Hi @Matteocaroleo, HAL_I2C_Mem_Read is already implemented via I2CHandle::ReadDataAtAddress. If you look at the source for that method, you will see that it is implemented the same way as method this PR adds.

The only difference is that I2CHandle::ReadDataAtAddress does not currently shift the address left before passing it, but #668 adds that change.

@Matteocaroleo
Copy link
Author

You're right, so the ReadDataAtAddress() function can be used inside the mpr121 class instead of the one made to make it work, since it's the same anyway. I will do that and make another PR

@github-actions
Copy link

github-actions bot commented May 28, 2025

Test Results

150 tests  ±0   150 ✅ ±0   0s ⏱️ ±0s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit aedc1be. ± Comparison against base commit f7c63ae.

♻️ This comment has been updated with latest results.

@stephenhensley
Copy link
Collaborator

@Matteocaroleo thanks for the contribution!

You can modify this branch with additional commits, without having to make a separate PR.

The CI also has a few issues with the code formatting. So if you wouldn't mind cleaning those up to conform, that would be great.
Thanks!

@stephenhensley stephenhensley added the bug Something isn't working label May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MPR121 class FilteredData() returns wrong data

3 participants