cpu/nrf52: optimized I2C driver#8385
Conversation
PeterKietzmann
left a comment
There was a problem hiding this comment.
In which setup did you test this? I only gave it a quick try without logic analyzer (nrf52dk + srf02 with tests/driver_srf02). Initialization of the device seems successful. Single shot or periodic sampling directly hangs
|
|
||
| /* shortcuts configuration */ | ||
| dev(bus)->SHORTS = (TWIM_SHORTS_LASTTX_STOP_Enabled << TWIM_SHORTS_LASTTX_STOP_Pos) | | ||
| (TWIM_SHORTS_LASTRX_STOP_Enabled << TWIM_SHORTS_LASTRX_STOP_Pos); |
There was a problem hiding this comment.
Don't understand why you remove this initialization.
There was a problem hiding this comment.
The shorts are set on-demand in the transfer functions...
| /* enable the device */ | ||
| dev(bus)->ENABLE = (TWIM_ENABLE_ENABLE_Enabled << TWIM_ENABLE_ENABLE_Pos); | ||
| /* configure bus clock speed */ | ||
| dev(bus)->FREQUENCY = speed; |
There was a problem hiding this comment.
You removed the shift because TWIM_ENABLE_ENABLE_Pos is 0 right?
| int i2c_acquire(i2c_t bus) | ||
| { | ||
| assert(bus <= I2C_NUMOF); | ||
| assert(bus < I2C_NUMOF); |
There was a problem hiding this comment.
Should have seen this before :/ ...
|
|
||
| /* start read sequence */ | ||
| dev(bus)->EVENTS_STOPPED = 0; | ||
| dev(bus)->ADDRESS = addr; |
There was a problem hiding this comment.
Why did you remove the 7-bit-address mask?
There was a problem hiding this comment.
because this way we save one redundant instruction. The ADRESS register does only use the 7 LSB anyway, so no need for manual masking the address.
I tested this mainly with the |
0028118 to
27479aa
Compare
|
rebased (before I start debugging the |
|
Thanks for your feedback! |
|
Thanks for your review! |
27479aa to
ef6bed1
Compare
|
found the problem: The I2C driver expected the I will also look at the drivers for |
|
Great, works now. I'm fine with this PR. Let's wait for #8486 and rebase/squash then |
|
Perfect. Would you mind to ACK #8486?! |
|
@haukepetersen please rebase |
This function is supposed to be used for putting the CPU into sleep mode for short amounts of time (e.g. in typical polling loops used in periph drivers).
|
rebased |
ef6bed1 to
3813f88
Compare
3813f88 to
2b2accf
Compare
|
and squashed. |
|
Travis CI fails due to previously set "Waiting For Other PR" flag. How is this machine restarted, only by a new commit? |
|
As Travis is not needed for a final verdict, I'd say we simply ignore it in this case. |
This needs to be restarted manually. It would be good to remove this check from travis. |
Contribution description
This PR applies some enhancements to the I2C driver for the
nrf52. It mainly consists of some minor fixes and a little re-structuring for better code re-usage. Further the driver is now using assertions for all API functions.If I saw it correctly, the previous version of the driver had also a problem as it was not using a repeated start condition when reading register(s), this is also fixed now.
Issues/PRs references
none