From 3538ba943c7abfc6933b72307d1bc24cf581d488 Mon Sep 17 00:00:00 2001 From: Ron Evans Date: Mon, 4 Mar 2019 17:08:52 +0100 Subject: [PATCH] machine/samd21: move definitions for I2C interfaces into board files, since pin connections on each SAMD21-based board implementation can differ Signed-off-by: Ron Evans --- src/machine/board_circuitplay_express.go | 8 ++++++++ src/machine/board_itsybitsy-m0.go | 7 +++++++ src/machine/machine_atsamd21.go | 6 ------ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/machine/board_circuitplay_express.go b/src/machine/board_circuitplay_express.go index 5ef42830..d1e02b3f 100644 --- a/src/machine/board_circuitplay_express.go +++ b/src/machine/board_circuitplay_express.go @@ -2,6 +2,8 @@ package machine +import "device/sam" + // GPIO Pins const ( D0 = PB09 @@ -68,3 +70,9 @@ const ( SDA_PIN = PA00 // SDA: SERCOM3/PAD[0] SCL_PIN = PA01 // SCL: SERCOM3/PAD[1] ) + +// I2C on the Circuit Playground Express. +var ( + I2C0 = I2C{Bus: sam.SERCOM5_I2CM} // external device + I2C1 = I2C{Bus: sam.SERCOM1_I2CM} // internal device +) diff --git a/src/machine/board_itsybitsy-m0.go b/src/machine/board_itsybitsy-m0.go index be8a81e7..d823a8d1 100644 --- a/src/machine/board_itsybitsy-m0.go +++ b/src/machine/board_itsybitsy-m0.go @@ -2,6 +2,8 @@ package machine +import "device/sam" + // GPIO Pins const ( D0 = PA11 // UART0 RX @@ -51,3 +53,8 @@ const ( SDA_PIN = PA22 // SDA: SERCOM3/PAD[0] SCL_PIN = PA23 // SCL: SERCOM3/PAD[1] ) + +// I2C on the ItsyBitsy M0. +var ( + I2C0 = I2C{Bus: sam.SERCOM3_I2CM} +) diff --git a/src/machine/machine_atsamd21.go b/src/machine/machine_atsamd21.go index 0a040527..b71be37d 100644 --- a/src/machine/machine_atsamd21.go +++ b/src/machine/machine_atsamd21.go @@ -420,12 +420,6 @@ type I2C struct { Bus *sam.SERCOM_I2CM_Type } -// Since the I2C interfaces on the SAMD21 use the SERCOMx peripherals, -// you can have multiple ones. we currently only implement one. -var ( - I2C0 = I2C{Bus: sam.SERCOM3_I2CM} -) - // I2CConfig is used to store config info for I2C. type I2CConfig struct { Frequency uint32