aboutsummaryrefslogtreecommitdiffstats
path: root/src/sam3/i2c.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-12-26 20:31:23 -0500
committerKevin O'Connor <kevin@koconnor.net>2019-01-07 19:34:31 -0500
commit75ad16ea1a3ffcb7026c69f6f1ea78197b055779 (patch)
tree98273f13f386e9da0378a6f9c3d109b652865c63 /src/sam3/i2c.c
parent519f2cff4123b8cd8e18ca5342e1bf8c4d01cd5a (diff)
downloadkutter-75ad16ea1a3ffcb7026c69f6f1ea78197b055779.tar.gz
kutter-75ad16ea1a3ffcb7026c69f6f1ea78197b055779.tar.xz
kutter-75ad16ea1a3ffcb7026c69f6f1ea78197b055779.zip
sam3: Add support for sam4s8c chips
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/sam3/i2c.c')
-rw-r--r--src/sam3/i2c.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/sam3/i2c.c b/src/sam3/i2c.c
index 27a04738..910471fd 100644
--- a/src/sam3/i2c.c
+++ b/src/sam3/i2c.c
@@ -5,7 +5,6 @@
//
// This file may be distributed under the terms of the GNU GPLv3 license.
-#include "autoconf.h" // CONFIG_CLOCK_FREQ
#include "board/misc.h" // timer_from_us
#include "command.h" // shutdown
#include "gpio.h" // i2c_setup
@@ -18,7 +17,7 @@
#define TWI0_SDA_GPIO GPIO('A', 17)
#define TWI1_SCL_GPIO GPIO('B', 13)
#define TWI1_SDA_GPIO GPIO('B', 12)
-#elif CONFIG_MACH_SAM4E8E
+#elif CONFIG_MACH_SAM4S8C || CONFIG_MACH_SAM4E8E
#define TWI0_SCL_GPIO GPIO('A', 4)
#define TWI0_SDA_GPIO GPIO('A', 3)
#define TWI1_SCL_GPIO GPIO('B', 5)
@@ -48,7 +47,7 @@ i2c_init(Twi *p_twi, uint32_t rate)
uint32_t chdiv = 0;
uint32_t ckdiv = 0;
- cldiv = CONFIG_CLOCK_FREQ / ((rate > 384000 ? 384000 : rate) * 2) - 4;
+ cldiv = SystemCoreClock / ((rate > 384000 ? 384000 : rate) * 4) - 4;
while((cldiv > 255) && (ckdiv < 7)) {
ckdiv++;
@@ -56,7 +55,7 @@ i2c_init(Twi *p_twi, uint32_t rate)
}
if (rate > 348000) {
- chdiv = CONFIG_CLOCK_FREQ / ((2 * rate - 384000) * 2) - 4;
+ chdiv = SystemCoreClock / ((2 * rate - 384000) * 4) - 4;
while((chdiv > 255) && (ckdiv < 7)) {
ckdiv++;
chdiv /= 2;