-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
205d8b2
commit 5146822
Showing
1 changed file
with
6 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5146822
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.
This can't be right. freq_khz is still there, but not used for anything. Have a look in the official twi.c.
Why is the "new" implementation introduced in ArduinoCore-megaAVR #90 better than the implementation you're attempting to replace here?
5146822
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.
(commas for human readability)
F_CPU = 16,000,000
t_rise = 1,000
(F_CPU * t_rise) - 16,000,000,000
This is 0x03 B9AC A000.
truncate to fit 4 bytes
0xB9AC A000
Not sure if it's significant in terms of it's impact (haven't gone any further than what I wrote above - which satisfied me that there was a problem being fixed here)
5146822
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.
Huh, but yeah, you're right, the new formula is ALSO wrong - at least, assuming what the original formula presumably intended was correct...
5146822
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.
What I meant was that in order for the function to be correct, you'll either have to replace
frequency
withfreq_khz
, everywhere (and adjust the formula) or vice versa. Right now it's a mix of the "old" and "new" implementation5146822
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.
OH! Thanks... I hadn't realized that there had been another change in between the two which renamed a variable. Goddamnit...