-
Notifications
You must be signed in to change notification settings - Fork 1.2k
MSPM0: Add I2C Controller (blocking & async) + examples for mspm0l1306, mspm0g3507 (tested MCUs) #4435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
i509VCB
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still going through this.
669590c to
f0eb466
Compare
|
After switching to I2C standard mode, driver start working incorrectly (write-read test of 17 bytes test failed). I will do the research |
Seems very likely that this is because of the wrong timer period. When executing the tests, a specific case with FastMode seems to work but all other cases fail. Probably the new calculation is a little bit wrong. Make sure you really work periods instead of frequencies (or account for that). That was my error at the beginning. |
This bug is reproducible even with old timer period calculation, I will dig into it more. Added: this is expected behavior according TI. Blocking API is capable to transfer max 8 bytes in one transaction. It's explicitly mentioned in the same TI example and it shows the same faulty behavior. Async (with interrupts) API works well with different i2c speeds |
|
Checking in, I assume the driver is still being worked on? (and whether it is working?) |
yep, still working on. Added: @i509VCB I guess I addressed all issues |
- lib: add i2c mod to lib - lib: add `bind_interrupts` mod for async workflow - lib: set SYSOSCBASE as system oscillator - config: add I2C SDA,SCA pin traits code generation - config: add clock source for the I2C - config: add clock divider for the I2C - config: add I2C BusSpeed configuration - I2C: add blocking API: blocking_read, blocking_write, blocking_write_read - I2C: add async API: async_write, async_read, async_write_read - I2C: add embedded-hal (v0.2) API for blocking & async impl. - I2C: add embedded-hal (v1.0) API for blocking & async impl. - I2C-tests: checks for timer_period & check_clock_rate fn's
- mspm0l1306 examples: add I2C blocking & async examples - mspm0l1306 examples: add -O2 optimization due to Flash limitations - mspm0g3507 examples: add I2C blocking & async examples
- i2c-config: automatically defines clock source based on input I2C rate - i2c: proper config functions naming - i2c-examples: adapt to changed API - i2c: save initialization pf cctr register
- blocking API for transfering max 8 bytes - async API has no such limitations
|
Implementation looks fine. I'll give the errata sheet a look just in case there is something possibly sneaky there we need to know about. |
| for byte in chunk { | ||
| *byte = self.info.regs.controller(0).crxdata().read().value(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should verify this does not cause problems with I2C_ERR_08 errata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@i509VCB I couldn't add errata to the project due to compiling issues. could you point, what exactly should I verify here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.ti.com/lit/pdf/slaz742, I2C_ERR_08 states:
FIFO Read directly after RXDONE interrupt will cause erroneous data to be read
The workaround listed is:
Wait 2 I2C CLK cycles for the FIFO to guarantee to have the latest data. I2C CLK will
based on the CLKSEL register in the I2C registers.
Steps:
- IRQ handler wakes the tasking which is pending
- poll_fn closure is run, when RXDONE is set then return from poll_fn.
- Check a branch and maybe stop the controller transmission.
- Read from the fifo
The time gap between step 1 and 4 is non-deterministic. To properly address the errata we would need to insert a wait for 2 I2C clock cycles. Although giving that a thought we would need to know the core clock speed to issue the correct number of cycles to delay. But that is going to depend on #4445.
I'll open an issue about that errata, as we will need to deal with it later.
|
Giving the errata a check:
|
|
Flaky tests... Lets hope another run works. |
|
@Dirbaio when you can please merge. 5340dk tests are flaking. |
Iooon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to throws this in now, but I noticed that the tests in the i2c.rs file don't work. If the implementation seems to be correct we should at least change the tests.
Failing tests are:
i2c::tests::ti_calculate_timer_period
i2c::tests::ti_calculate_timer_period_2
i2c::tests::ti_calculate_timer_period_3
i2c::tests::ti_calculate_timer_period_4
fixed and tested with oscillator |
|
I'll open a pull request to disable the 5340 tests, as those seem to have broken. I can only use the merge queue myself. |
bind_interruptsmacros for async workflowLooking forward for a feedback: @i509VCB