machine/samd21: use pins specified in I2CConfig

Instead of configuring machine.I2C0, machine.I2C1, etc. statically,
allow the pins to be set using machine.I2CConfig. This will also
automatically configure the correct pin mode for each pin instead of
having to specify that manually.
This commit is contained in:
Ayke van Laethem
2019-09-30 14:21:52 +02:00
committed by Ron Evans
parent 8fe126b1f6
commit d266e44bc5
7 changed files with 52 additions and 31 deletions
+8 -8
View File
@@ -94,15 +94,15 @@ const (
// I2C on the Circuit Playground Express.
var (
// external device
I2C0 = I2C{Bus: sam.SERCOM5_I2CM,
SDA: SDA_PIN,
SCL: SCL_PIN,
PinMode: PinSERCOM}
I2C0 = I2C{
Bus: sam.SERCOM5_I2CM,
SERCOM: 5,
}
// internal device
I2C1 = I2C{Bus: sam.SERCOM1_I2CM,
SDA: SDA1_PIN,
SCL: SCL1_PIN,
PinMode: PinSERCOMAlt}
I2C1 = I2C{
Bus: sam.SERCOM1_I2CM,
SERCOM: 1,
}
)
// SPI pins (internal flash)