Skip to content

Bl808/i2c#4

Merged
Hunter1753 merged 6 commits intoHunter1753:bl808/i2cfrom
kadamski:bl808/i2c
Apr 6, 2023
Merged

Bl808/i2c#4
Hunter1753 merged 6 commits intoHunter1753:bl808/i2cfrom
kadamski:bl808/i2c

Conversation

@kadamski
Copy link

@kadamski kadamski commented Apr 6, 2023

Some additional fixes for some specific cases. This time I was able to test this code myself :)

kadamski added 6 commits April 6, 2023 19:26
The value was shifted the wrong way causing it to be always zero and
limiting the subaddr to 1 byte.
The interrupt is always masked when it is disabled and it is unmasked
when it is enabled. For this reason there is no point in having both
functions.
This patch simplifies passing arguments to the interrupt management
functions by leveraging the fact that enable bits are shifted by
constant offset from enable bits. This not only shortens the code but
also removes unneeded additional read/write to the register.
Wrong number of bytes was subtracted from the msg_buf_remaining in case
of messages longer than 4. This caused the msg_buf_remaining to be
always 0 after reading 4 bytes. With this change, reading more than 4
bytes works (I was able to test this only with 6 bytes read so far).
Similarly to the change in bl808_fill_tx_fifo, we can use min_t to
remove code duplication for those two cases.
This value is never bigger than 4 so u16 is not needed and it might be
confusing why it was chosen.
Current code, in case of multiple messages would start sending the next
message in TXF interrupt. This is not correct as when we get TXF
interrupt, the fifo may not yet be drained by the controller. The new
message should be sent from END interrupt instead.

With this fix, the multi-message sending works. This can be checked
using something like this on SSD1306:

i2ctransfer -y 0 w16@0x3c 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09
0x0a 0xb 0xc 0xd 0xe 0xf 0x10 w4@0x3c 0x21 0x22 0x23 0x24

Without this patch, the first message consisting of 16 bytes would be
cut somewhere around 0xc. With this patch, it is working fine.
@Hunter1753 Hunter1753 merged commit 71c620f into Hunter1753:bl808/i2c Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants