aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/machine/machine_atsamd51p20.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2021-10-15 22:52:34 +0200
committerRon Evans <[email protected]>2021-10-25 14:49:02 +0200
commitae864bdf0c58049c6c65969497acc7c8dce01bcb (patch)
treee640669d8240a096fe333f5c1ef6cf5b4ef915a2 /src/machine/machine_atsamd51p20.go
parente50885a6f2ac2752e1f8c64d20acc7776d355779 (diff)
downloadtinygo-ae864bdf0c58049c6c65969497acc7c8dce01bcb.tar.gz
tinygo-ae864bdf0c58049c6c65969497acc7c8dce01bcb.zip
sam: simplify I2C peripheral declarations
This commit changes the I2C declarations so that the objects are instantiated in each chip file (e.g. machine_atsamd21e18.go) and used to define I2C0 (and similar) in the board file (e.g. board_qtpy.go). This should make it easier to define new board files, and reduces the need for separate *_baremetal.go files. I have tested this the following way: - With the LIS3DH driver example on the Circuit Playground Express and the PyBadge. - With the LSM6DS3 driver example on the Arduino Nano 33 IoT. They both still work fine.
Diffstat (limited to 'src/machine/machine_atsamd51p20.go')
-rw-r--r--src/machine/machine_atsamd51p20.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/machine/machine_atsamd51p20.go b/src/machine/machine_atsamd51p20.go
index 0d3776e82..733cc0c02 100644
--- a/src/machine/machine_atsamd51p20.go
+++ b/src/machine/machine_atsamd51p20.go
@@ -11,6 +11,17 @@ import "device/sam"
const HSRAM_SIZE = 0x00040000
+var (
+ sercomI2CM0 = &I2C{Bus: sam.SERCOM0_I2CM, SERCOM: 0}
+ sercomI2CM1 = &I2C{Bus: sam.SERCOM1_I2CM, SERCOM: 1}
+ sercomI2CM2 = &I2C{Bus: sam.SERCOM2_I2CM, SERCOM: 2}
+ sercomI2CM3 = &I2C{Bus: sam.SERCOM3_I2CM, SERCOM: 3}
+ sercomI2CM4 = &I2C{Bus: sam.SERCOM4_I2CM, SERCOM: 4}
+ sercomI2CM5 = &I2C{Bus: sam.SERCOM5_I2CM, SERCOM: 5}
+ sercomI2CM6 = &I2C{Bus: sam.SERCOM6_I2CM, SERCOM: 6}
+ sercomI2CM7 = &I2C{Bus: sam.SERCOM7_I2CM, SERCOM: 7}
+)
+
// This chip has five TCC peripherals, which have PWM as one feature.
var (
TCC0 = (*TCC)(sam.TCC0)