esp-idf-hal
esp-idf-hal copied to clipboard
Fix for #412
Use the newer calculation for the i2c
@ivmarkov I would need some advice, log2 is not available in std but would be required for the calculation, I could do this with ilog2, but then I have no idea how to ensure the ceiling() is done correctly. Any advice?
@ivmarkov I would need some advice, log2 is not available in std but would be required for the calculation, I could do this with ilog2, but then I have no idea how to ensure the ceiling() is done correctly. Any advice?
... assuming you do the math with u64
, the following might work:
abc.ilog2() + (if abc.leading_zeroes() + abc.trailing_zeroes() + 1 < 64 { 1 } else { 0 })
NOTE 1: Ideally, you should avoid floating point math anyway, on MCUs and esps specifically. NOTE 2: I have not checked yet your computation and why you need to take the logarithm of something
Ok this seems to work, 104ms returns 22 for the register while 105 rounds up to 23 and is properly failing
Thanks!