blob: 5b8a30abd593b58c2d373e789ca59981f57d8990 [file] [log] [blame]
Harald Weltec3f170d2019-02-24 09:06:59 +01001#include "atmel_start_pins.h"
2#include "i2c_bitbang.h"
3
4/* FIXME: This somehow ends up with measured 125 kHz SCL speed ?!? We should probably
5 * switch away from using delay_us() and instead use some hardware timer? */
6#define I2C_DELAY_US 1
7
8#ifndef SDA1
9/* We should define those pins in Atmel START. Until they are, define them here */
10#define SDA1 GPIO(GPIO_PORTB, 15)
11#define SCL1 GPIO(GPIO_PORTB, 14)
12#define SDA2 GPIO(GPIO_PORTB, 3)
13#define SCL2 GPIO(GPIO_PORTB, 2)
14#define SDA3 GPIO(GPIO_PORTB, 7)
15#define SCL3 GPIO(GPIO_PORTB, 6)
16#define SDA4 GPIO(GPIO_PORTC, 28)
17#define SCL4 GPIO(GPIO_PORTC, 27)
18#endif
19
20/* Unfortunately the schematics count I2C busses from '1', not from '0' :(
21 * In software, we [obviously] count from '0' upwards. */
22const struct i2c_adapter i2c[4] = {
23 [0] = {
24 .pin_sda = SDA1,
25 .pin_scl = SCL1,
26 .udelay = I2C_DELAY_US,
27 },
28 [1] = {
29 .pin_sda = SDA2,
30 .pin_scl = SCL2,
31 .udelay = I2C_DELAY_US,
32 },
33 [2] = {
34 .pin_sda = SDA3,
35 .pin_scl = SCL3,
36 .udelay = I2C_DELAY_US,
37 },
38 [3] = {
39 .pin_sda = SDA4,
40 .pin_scl = SCL4,
41 .udelay = I2C_DELAY_US,
42 }
43};