diff options
author | Alex Maclean <monkeh@monkeh.net> | 2021-11-18 23:20:59 +0000 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2021-11-20 13:28:35 -0500 |
commit | 92ca1119868abbd859c8f7a3f88143cf53561eb3 (patch) | |
tree | 87f1ea7e9c5394c0e8ffa16367d3a47fd75811df /src | |
parent | 01a223393e5c364203524539d5edba2ac52529cc (diff) | |
download | kutter-92ca1119868abbd859c8f7a3f88143cf53561eb3.tar.gz kutter-92ca1119868abbd859c8f7a3f88143cf53561eb3.tar.xz kutter-92ca1119868abbd859c8f7a3f88143cf53561eb3.zip |
atsam: Fix I2C bitrate
Multiplying the desired bitrate by 4 results in half the
desired period and thus twice the desired bitrate.
Signed-off-by: Alex Maclean <monkeh@monkeh.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/atsam/i2c.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/atsam/i2c.c b/src/atsam/i2c.c index 672eacef..fc56ce50 100644 --- a/src/atsam/i2c.c +++ b/src/atsam/i2c.c @@ -49,7 +49,7 @@ i2c_init(Twi *p_twi, uint32_t rate) p_twi->TWI_CR = TWI_CR_MSEN; uint32_t cldiv = 0, chdiv = 0, ckdiv = 0; - cldiv = SystemCoreClock / ((rate > 384000 ? 384000 : rate) * 4) - 4; + cldiv = SystemCoreClock / ((rate > 384000 ? 384000 : rate) * 2) - 4; while ((cldiv > 255) && (ckdiv < 7)) { ckdiv++; @@ -57,7 +57,7 @@ i2c_init(Twi *p_twi, uint32_t rate) } if (rate > 348000) { - chdiv = SystemCoreClock / ((2 * rate - 384000) * 4) - 4; + chdiv = SystemCoreClock / ((2 * rate - 384000) * 2) - 4; while ((chdiv > 255) && (ckdiv < 7)) { ckdiv++; chdiv /= 2; |