stm32-rs / stm32l4xx-hal

A Hardware abstraction layer for the stm32l432xx series chips written in rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I2C doesn't work with repeating starts

David-OConnor opened this issue · comments

This is part of the spec, and is required by some devices. Fixed in this PR. Copy+pasted write_read method and 2 supporting macros from the H7 HAL.

Pre-fix: https://i.imgur.com/wONAYTl.png
Post-fix: https://i.imgur.com/8NhBxVk.png

Note the Sr (Repeating start) flag towards the left on the fixed one, replacing the P S (Stop, start) on the current impl. And note the correct data on the fix towards the right, compared to 0xFF.

Per the Embedded Hal docs, this is how WriteRead is expected to behave.

Just weighing in here to point to the I2C specification corroborating this. See: Figure 13 in section 3.1.10 of UM10204.

I replaced write and read with H7's impls as well after encountering additional problems that these resolved. Regrettably, I haven't identified them. I removed the Tx, Rx and Blocking structs as well.

As a secondary reason, I think these were a bit obfuscating in terms of code style: The task is a linear set of operations.